Allow API usage in native_free_callbacks (#3515)
This patch allows the use of API functions in native_free_callbacks for native pointers once again. JerryScript-DCO-1.0-Signed-off-by: Daniel Balla dballa@inf.u-szeged.hu
This commit is contained in:
committed by
Dániel Bátyai
parent
71d4e12105
commit
f46d061d19
@@ -2956,7 +2956,7 @@ jerry_get_object_native_pointer (const jerry_value_t obj_val, /**< object to get
|
||||
* Note:
|
||||
* If a non-NULL free callback is specified in the native type info,
|
||||
* it will be called by the garbage collector when the object is freed.
|
||||
* This callback **must not** invoke API functions.
|
||||
* Referred values by this method must have at least 1 reference. (Correct API usage satisfies this condition)
|
||||
* The type info always overwrites the previous value, so passing
|
||||
* a NULL value deletes the current type info.
|
||||
*/
|
||||
|
||||
@@ -700,10 +700,6 @@ ecma_gc_free_native_pointer (ecma_property_t *property_p) /**< property */
|
||||
native_pointer_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_native_pointer_t,
|
||||
value_p->value);
|
||||
|
||||
#ifndef JERRY_NDEBUG
|
||||
JERRY_CONTEXT (status_flags) &= (uint32_t) ~ECMA_STATUS_API_AVAILABLE;
|
||||
#endif /* !JERRY_NDEBUG */
|
||||
|
||||
while (native_pointer_p != NULL)
|
||||
{
|
||||
if (native_pointer_p->info_p != NULL)
|
||||
@@ -722,10 +718,6 @@ ecma_gc_free_native_pointer (ecma_property_t *property_p) /**< property */
|
||||
|
||||
native_pointer_p = next_p;
|
||||
}
|
||||
|
||||
#ifndef JERRY_NDEBUG
|
||||
JERRY_CONTEXT (status_flags) |= ECMA_STATUS_API_AVAILABLE;
|
||||
#endif /* !JERRY_NDEBUG */
|
||||
} /* ecma_gc_free_native_pointer */
|
||||
|
||||
/**
|
||||
@@ -1405,6 +1397,7 @@ ecma_gc_run (void)
|
||||
while (marked_anything_during_current_iteration);
|
||||
|
||||
black_end_p->gc_next_cp = JMEM_CP_NULL;
|
||||
JERRY_CONTEXT (ecma_gc_objects_cp) = black_list_head.gc_next_cp;
|
||||
|
||||
/* Sweep objects that are currently unmarked. */
|
||||
obj_iter_cp = white_gray_list_head.gc_next_cp;
|
||||
@@ -1420,8 +1413,6 @@ ecma_gc_run (void)
|
||||
obj_iter_cp = obj_next_cp;
|
||||
}
|
||||
|
||||
JERRY_CONTEXT (ecma_gc_objects_cp) = black_list_head.gc_next_cp;
|
||||
|
||||
#if ENABLED (JERRY_BUILTIN_REGEXP)
|
||||
/* Free RegExp bytecodes stored in cache */
|
||||
re_cache_gc_run ();
|
||||
|
||||
@@ -29,6 +29,11 @@
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Maximum number of GC loops on cleanup.
|
||||
*/
|
||||
#define JERRY_GC_LOOP_LIMIT 100
|
||||
|
||||
/**
|
||||
* Initialize ECMA components
|
||||
*/
|
||||
@@ -73,8 +78,17 @@ ecma_finalize (void)
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
|
||||
ecma_finalize_global_lex_env ();
|
||||
ecma_finalize_builtins ();
|
||||
ecma_gc_run ();
|
||||
uint8_t runs = 0;
|
||||
do
|
||||
{
|
||||
ecma_finalize_builtins ();
|
||||
ecma_gc_run ();
|
||||
if (++runs >= JERRY_GC_LOOP_LIMIT)
|
||||
{
|
||||
jerry_fatal (ERR_UNTERMINATED_GC_LOOPS);
|
||||
}
|
||||
}
|
||||
while (JERRY_CONTEXT (ecma_gc_new_objects) != 0);
|
||||
ecma_finalize_lit_storage ();
|
||||
} /* ecma_finalize */
|
||||
|
||||
|
||||
@@ -51,6 +51,7 @@ typedef enum
|
||||
ERR_OUT_OF_MEMORY = 10,
|
||||
ERR_REF_COUNT_LIMIT = 12,
|
||||
ERR_DISABLED_BYTE_CODE = 13,
|
||||
ERR_UNTERMINATED_GC_LOOPS = 14,
|
||||
ERR_FAILED_INTERNAL_ASSERTION = 120
|
||||
} jerry_fatal_code_t;
|
||||
|
||||
|
||||
@@ -42,6 +42,11 @@ jerry_fatal (jerry_fatal_code_t code) /**< status code */
|
||||
JERRY_ERROR_MSG ("Error: ERR_REF_COUNT_LIMIT\n");
|
||||
break;
|
||||
}
|
||||
case ERR_UNTERMINATED_GC_LOOPS:
|
||||
{
|
||||
JERRY_ERROR_MSG ("Error: ERR_UNTERMINATED_GC_LOOPS\n");
|
||||
break;
|
||||
}
|
||||
case ERR_DISABLED_BYTE_CODE:
|
||||
{
|
||||
JERRY_ERROR_MSG ("Error: ERR_DISABLED_BYTE_CODE\n");
|
||||
|
||||
Reference in New Issue
Block a user