Storing byte code size in the byte code header. This reduces the
memory consumption, because the new allocator uses less memory if the size as available when a block is freed. Snapshot generation is also simplified. JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
This commit is contained in:
@@ -741,17 +741,15 @@ typedef uintptr_t ecma_external_pointer_t;
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint16_t status_flags; /**< various status flags */
|
||||
uint16_t size; /**< real size >> MEM_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;
|
||||
|
||||
/**
|
||||
* Shift value for byte code reference counting.
|
||||
* The last 10 bit of the first uint16_t value
|
||||
* of compact byte code or regexp byte code
|
||||
* is reserved for reference counting.
|
||||
*/
|
||||
#define ECMA_BYTECODE_REF_SHIFT 6
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
@@ -1316,12 +1316,12 @@ void
|
||||
ecma_bytecode_ref (ecma_compiled_code_t *bytecode_p) /**< byte code pointer */
|
||||
{
|
||||
/* Abort program if maximum reference number is reached. */
|
||||
if ((bytecode_p->status_flags >> ECMA_BYTECODE_REF_SHIFT) >= 0x3ff)
|
||||
if (bytecode_p->refs >= UINT16_MAX)
|
||||
{
|
||||
jerry_fatal (ERR_REF_COUNT_LIMIT);
|
||||
}
|
||||
|
||||
bytecode_p->status_flags = (uint16_t) (bytecode_p->status_flags + (1u << ECMA_BYTECODE_REF_SHIFT));
|
||||
bytecode_p->refs++;
|
||||
} /* ecma_bytecode_ref */
|
||||
|
||||
/**
|
||||
@@ -1331,11 +1331,11 @@ ecma_bytecode_ref (ecma_compiled_code_t *bytecode_p) /**< byte code pointer */
|
||||
void
|
||||
ecma_bytecode_deref (ecma_compiled_code_t *bytecode_p) /**< byte code pointer */
|
||||
{
|
||||
JERRY_ASSERT ((bytecode_p->status_flags >> ECMA_BYTECODE_REF_SHIFT) > 0);
|
||||
JERRY_ASSERT (bytecode_p->refs > 0);
|
||||
|
||||
bytecode_p->status_flags = (uint16_t) (bytecode_p->status_flags - (1u << ECMA_BYTECODE_REF_SHIFT));
|
||||
bytecode_p->refs--;
|
||||
|
||||
if (bytecode_p->status_flags >= (1u << ECMA_BYTECODE_REF_SHIFT))
|
||||
if (bytecode_p->refs > 0)
|
||||
{
|
||||
/* Non-zero reference counter. */
|
||||
return;
|
||||
@@ -1388,7 +1388,8 @@ ecma_bytecode_deref (ecma_compiled_code_t *bytecode_p) /**< byte code pointer */
|
||||
#endif /* !CONFIG_ECMA_COMPACT_PROFILE_DISABLE_REGEXP_BUILTIN */
|
||||
}
|
||||
|
||||
mem_heap_free_block_size_stored (bytecode_p);
|
||||
mem_heap_free_block (bytecode_p,
|
||||
((size_t) bytecode_p->size) << MEM_ALIGNMENT_LOG);
|
||||
} /* ecma_bytecode_deref */
|
||||
|
||||
/**
|
||||
|
||||
@@ -256,7 +256,7 @@ ecma_op_create_regexp_object_from_bytecode (re_compiled_code_t *bytecode_p) /**<
|
||||
/* Initialize RegExp object properties */
|
||||
re_initialize_props (obj_p,
|
||||
ECMA_GET_NON_NULL_POINTER (ecma_string_t, bytecode_p->pattern_cp),
|
||||
bytecode_p->flags);
|
||||
bytecode_p->header.status_flags);
|
||||
|
||||
return ecma_make_object_value (obj_p);
|
||||
} /* ecma_op_create_regexp_object_from_bytecode */
|
||||
@@ -1298,7 +1298,7 @@ ecma_regexp_exec_helper (ecma_value_t regexp_value, /**< RegExp object */
|
||||
re_ctx.input_end_p = input_end_p;
|
||||
|
||||
/* 1. Read bytecode header and init regexp matcher context. */
|
||||
re_ctx.flags = bc_p->flags;
|
||||
re_ctx.flags = bc_p->header.status_flags;
|
||||
|
||||
if (ignore_global)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user