Support multiple primary functions in a single snapshot. (#1797)

This patch adds an extension to snapshots which allows storing
multiple position independent primary functions in a single
snapshot data. A new application called jerry-snapshot is
added to the project to manage snapshots. Currently the only
option is merging snapshots.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
This commit is contained in:
Zoltan Herczeg
2017-10-12 14:43:32 +02:00
committed by GitHub
parent 9f0cf9ef1c
commit fe26674752
17 changed files with 1280 additions and 462 deletions
+29 -8
View File
@@ -24,18 +24,39 @@
typedef struct
{
/* The size of this structure is recommended to be divisible by
* JMEM_ALIGNMENT. Otherwise some bytes after the header are wasted. */
* uint32_t alignment. Otherwise some bytes after the header are wasted. */
uint32_t magic; /**< four byte magic number */
uint32_t version; /**< version number */
uint32_t lit_table_offset; /**< offset of the literal table */
uint32_t lit_table_size; /**< size of literal table */
uint32_t is_run_global; /**< flag, indicating whether the snapshot
* was saved as 'Global scope'-mode code (true)
* or as eval-mode code (false) */
uint32_t global_flags; /**< global configuration and feature flags */
uint32_t lit_table_offset; /**< byte offset of the literal table */
uint32_t number_of_funcs; /**< number of primary ECMAScript functions */
uint32_t func_offsets[1]; /**< function offsets (lowest bit: global(0) or eval(1) context) */
} jerry_snapshot_header_t;
/**
* Jerry snapshot format version
* Evaluate this function on the top of the scope chain.
*/
#define JERRY_SNAPSHOT_VERSION (7u)
#define JERRY_SNAPSHOT_EVAL_CONTEXT 0x1u
/**
* Jerry snapshot magic marker.
*/
#define JERRY_SNAPSHOT_MAGIC (0x5952524Au)
/**
* Jerry snapshot format version.
*/
#define JERRY_SNAPSHOT_VERSION (8u)
/**
* Snapshot configuration flags.
*/
typedef enum
{
/* 8 bits are reserved for dynamic features */
JERRY_SNAPSHOT_HAS_REGEX_LITERAL = (1u << 0), /**< byte code has regex literal */
/* 24 bits are reserved for compile time features */
JERRY_SNAPSHOT_FOUR_BYTE_CPOINTER = (1u << 8) /**< compressed pointers are four byte long */
} jerry_snapshot_global_flags_t;
#endif /* !JERRY_SNAPSHOT_H */