Support static snapshots. (#2239)
Unlike normal snapshots, no part of a static snapshot is loaded into the RAM when executed from ROM. Static snapshots rely heavily on external magic strings. JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
This commit is contained in:
@@ -631,10 +631,22 @@ ecma_gc_free_object (ecma_object_t *object_p) /**< object to free */
|
||||
/* Function with byte-code (not a built-in function). */
|
||||
ecma_extended_object_t *ext_func_p = (ecma_extended_object_t *) object_p;
|
||||
|
||||
#ifdef JERRY_ENABLE_SNAPSHOT_EXEC
|
||||
if (ext_func_p->u.function.bytecode_cp != ECMA_NULL_POINTER)
|
||||
{
|
||||
ecma_bytecode_deref (ECMA_GET_INTERNAL_VALUE_POINTER (ecma_compiled_code_t,
|
||||
ext_func_p->u.function.bytecode_cp));
|
||||
ecma_dealloc_extended_object (object_p, sizeof (ecma_extended_object_t));
|
||||
}
|
||||
else
|
||||
{
|
||||
ecma_dealloc_extended_object (object_p, sizeof (ecma_static_function_t));
|
||||
}
|
||||
#else /* !JERRY_ENABLE_SNAPSHOT_EXEC */
|
||||
ecma_bytecode_deref (ECMA_GET_INTERNAL_VALUE_POINTER (ecma_compiled_code_t,
|
||||
ext_func_p->u.function.bytecode_cp));
|
||||
|
||||
ecma_dealloc_extended_object (object_p, sizeof (ecma_extended_object_t));
|
||||
#endif /* JERRY_ENABLE_SNAPSHOT_EXEC */
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -643,12 +655,24 @@ ecma_gc_free_object (ecma_object_t *object_p) /**< object to free */
|
||||
{
|
||||
ecma_arrow_function_t *arrow_func_p = (ecma_arrow_function_t *) object_p;
|
||||
|
||||
ecma_bytecode_deref (ECMA_GET_NON_NULL_POINTER (ecma_compiled_code_t,
|
||||
arrow_func_p->bytecode_cp));
|
||||
|
||||
ecma_free_value_if_not_object (arrow_func_p->this_binding);
|
||||
|
||||
#ifdef JERRY_ENABLE_SNAPSHOT_EXEC
|
||||
if (arrow_func_p->bytecode_cp != ECMA_NULL_POINTER)
|
||||
{
|
||||
ecma_bytecode_deref (ECMA_GET_NON_NULL_POINTER (ecma_compiled_code_t,
|
||||
arrow_func_p->bytecode_cp));
|
||||
ecma_dealloc_extended_object (object_p, sizeof (ecma_arrow_function_t));
|
||||
}
|
||||
else
|
||||
{
|
||||
ecma_dealloc_extended_object (object_p, sizeof (ecma_static_arrow_function_t));
|
||||
}
|
||||
#else /* !JERRY_ENABLE_SNAPSHOT_EXEC */
|
||||
ecma_bytecode_deref (ECMA_GET_NON_NULL_POINTER (ecma_compiled_code_t,
|
||||
arrow_func_p->bytecode_cp));
|
||||
ecma_dealloc_extended_object (object_p, sizeof (ecma_arrow_function_t));
|
||||
#endif /* JERRY_ENABLE_SNAPSHOT_EXEC */
|
||||
return;
|
||||
}
|
||||
#endif /* !CONFIG_DISABLE_ES2015_ARROW_FUNCTION */
|
||||
|
||||
@@ -797,6 +797,33 @@ typedef struct
|
||||
ecma_built_in_props_t built_in; /**< built-in object part */
|
||||
} ecma_extended_built_in_object_t;
|
||||
|
||||
/**
|
||||
* Compiled byte code data.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint16_t size; /**< real size >> JMEM_ALIGNMENT_LOG */
|
||||
uint16_t refs; /**< reference counter for the byte code */
|
||||
uint16_t status_flags; /**< various status flags:
|
||||
* CBC_CODE_FLAGS_FUNCTION flag tells whether
|
||||
* the byte code is function or regular expression.
|
||||
* If function, the other flags must be CBC_CODE_FLAGS...
|
||||
* If regexp, the other flags must be RE_FLAG... */
|
||||
} ecma_compiled_code_t;
|
||||
|
||||
#ifdef JERRY_ENABLE_SNAPSHOT_EXEC
|
||||
|
||||
/**
|
||||
* Description of static function objects.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
ecma_extended_object_t header;
|
||||
const ecma_compiled_code_t *bytecode_p;
|
||||
} ecma_static_function_t;
|
||||
|
||||
#endif /* JERRY_ENABLE_SNAPSHOT_EXEC */
|
||||
|
||||
#ifndef CONFIG_DISABLE_ES2015_ARROW_FUNCTION
|
||||
|
||||
/**
|
||||
@@ -810,6 +837,19 @@ typedef struct
|
||||
jmem_cpointer_t bytecode_cp; /**< function byte code */
|
||||
} ecma_arrow_function_t;
|
||||
|
||||
#ifdef JERRY_ENABLE_SNAPSHOT_EXEC
|
||||
|
||||
/**
|
||||
* Description of static arrow function objects.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
ecma_arrow_function_t header;
|
||||
const ecma_compiled_code_t *bytecode_p;
|
||||
} ecma_static_arrow_function_t;
|
||||
|
||||
#endif /* JERRY_ENABLE_SNAPSHOT_EXEC */
|
||||
|
||||
#endif /* !CONFIG_DISABLE_ES2015_ARROW_FUNCTION */
|
||||
|
||||
/**
|
||||
@@ -1276,20 +1316,6 @@ typedef struct
|
||||
ecma_value_t value; /**< referenced value */
|
||||
} ecma_error_reference_t;
|
||||
|
||||
/**
|
||||
* Compiled byte code data.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint16_t size; /**< real size >> JMEM_ALIGNMENT_LOG */
|
||||
uint16_t refs; /**< reference counter for the byte code */
|
||||
uint16_t status_flags; /**< various status flags:
|
||||
* CBC_CODE_FLAGS_FUNCTION flag tells whether
|
||||
* the byte code is function or regular expression.
|
||||
* If function, the other flags must be CBC_CODE_FLAGS...
|
||||
* If regexp, the other flags must be RE_FLAG... */
|
||||
} ecma_compiled_code_t;
|
||||
|
||||
#ifndef CONFIG_ECMA_PROPERTY_HASHMAP_DISABLE
|
||||
|
||||
/**
|
||||
|
||||
@@ -311,6 +311,18 @@ ecma_is_value_string (ecma_value_t value) /**< ecma value */
|
||||
return ((value & (ECMA_VALUE_TYPE_MASK - 0x4)) == ECMA_TYPE_STRING);
|
||||
} /* ecma_is_value_string */
|
||||
|
||||
/**
|
||||
* Check if the value is direct_ecma-string.
|
||||
*
|
||||
* @return true - if the value contains ecma-string value,
|
||||
* false - otherwise
|
||||
*/
|
||||
inline bool __attr_const___ __attr_always_inline___
|
||||
ecma_is_value_direct_string (ecma_value_t value) /**< ecma value */
|
||||
{
|
||||
return (ecma_get_value_type_field (value) == ECMA_TYPE_DIRECT_STRING);
|
||||
} /* ecma_is_value_direct_string */
|
||||
|
||||
/**
|
||||
* Check if the value is object.
|
||||
*
|
||||
|
||||
@@ -1487,6 +1487,7 @@ void
|
||||
ecma_bytecode_deref (ecma_compiled_code_t *bytecode_p) /**< byte code pointer */
|
||||
{
|
||||
JERRY_ASSERT (bytecode_p->refs > 0);
|
||||
JERRY_ASSERT (!(bytecode_p->status_flags & CBC_CODE_FLAGS_STATIC_FUNCTION));
|
||||
|
||||
bytecode_p->refs--;
|
||||
|
||||
|
||||
@@ -154,6 +154,7 @@ bool ecma_are_values_integer_numbers (ecma_value_t first_value, ecma_value_t sec
|
||||
bool ecma_is_value_float_number (ecma_value_t value) __attr_const___;
|
||||
bool ecma_is_value_number (ecma_value_t value) __attr_const___;
|
||||
bool ecma_is_value_string (ecma_value_t value) __attr_const___;
|
||||
bool ecma_is_value_direct_string (ecma_value_t value) __attr_const___;
|
||||
bool ecma_is_value_object (ecma_value_t value) __attr_const___;
|
||||
bool ecma_is_value_error_reference (ecma_value_t value) __attr_const___;
|
||||
bool ecma_is_value_collection_chunk (ecma_value_t value) __attr_const___;
|
||||
|
||||
Reference in New Issue
Block a user