Check reference count of objects
Throw an error if the object reference count reached the limit. Related issue: #118 JerryScript-DCO-1.0-Signed-off-by: László Langó llango.u-szeged@partner.samsung.com
This commit is contained in:
@@ -82,6 +82,8 @@
|
||||
*/
|
||||
#define CONFIG_ECMA_REFERENCE_COUNTER_WIDTH (10)
|
||||
|
||||
#define CONFIG_ECMA_REFERENCE_COUNTER_LIMIT ((1u << CONFIG_ECMA_REFERENCE_COUNTER_WIDTH) - 1u)
|
||||
|
||||
/**
|
||||
* Maximum length of strings' concatenation
|
||||
*/
|
||||
|
||||
@@ -211,7 +211,16 @@ ecma_init_gc_info (ecma_object_t *object_p) /**< object */
|
||||
void
|
||||
ecma_ref_object (ecma_object_t *object_p) /**< object */
|
||||
{
|
||||
ecma_gc_set_object_refs (object_p, ecma_gc_get_object_refs (object_p) + 1);
|
||||
uint32_t ref_cnt = ecma_gc_get_object_refs (object_p);
|
||||
|
||||
if (ref_cnt < (uint32_t) CONFIG_ECMA_REFERENCE_COUNTER_LIMIT)
|
||||
{
|
||||
ecma_gc_set_object_refs (object_p, ref_cnt + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
jerry_fatal (ERR_REF_COUNT_LIMIT);
|
||||
}
|
||||
} /* ecma_ref_object */
|
||||
|
||||
/**
|
||||
|
||||
@@ -1334,11 +1334,10 @@ ecma_get_property_descriptor_from_property (ecma_property_t *prop_p) /**< proper
|
||||
void
|
||||
ecma_bytecode_ref (ecma_compiled_code_t *bytecode_p) /**< byte code pointer */
|
||||
{
|
||||
/* Abort program if maximum reference number is reached.
|
||||
* Note: This is not tested for objects. */
|
||||
/* Abort program if maximum reference number is reached. */
|
||||
if ((bytecode_p->status_flags >> ECMA_BYTECODE_REF_SHIFT) >= 0x3ff)
|
||||
{
|
||||
jerry_fatal (ERR_UNIMPLEMENTED_CASE);
|
||||
jerry_fatal (ERR_REF_COUNT_LIMIT);
|
||||
}
|
||||
|
||||
bytecode_p->status_flags = (uint16_t) (bytecode_p->status_flags + (1 << ECMA_BYTECODE_REF_SHIFT));
|
||||
|
||||
@@ -50,6 +50,7 @@ typedef enum
|
||||
{
|
||||
ERR_OUT_OF_MEMORY = 10,
|
||||
ERR_SYSCALL = 11,
|
||||
ERR_REF_COUNT_LIMIT = 12,
|
||||
ERR_UNIMPLEMENTED_CASE = 118,
|
||||
ERR_FAILED_INTERNAL_ASSERTION = 120
|
||||
} jerry_fatal_code_t;
|
||||
|
||||
@@ -47,6 +47,11 @@ jerry_fatal (jerry_fatal_code_t code) /**< status code */
|
||||
/* print nothing as it may invoke syscall recursively */
|
||||
break;
|
||||
}
|
||||
case ERR_REF_COUNT_LIMIT:
|
||||
{
|
||||
printf ("ERR_REF_COUNT_LIMIT\n");
|
||||
break;
|
||||
}
|
||||
case ERR_UNIMPLEMENTED_CASE:
|
||||
{
|
||||
printf ("ERR_UNIMPLEMENTED_CASE\n");
|
||||
|
||||
Reference in New Issue
Block a user