Add info to external pointer free callback. (#4642)

Furthermore reduce memory consumption when only
one external pointer is assigned to an object.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
This commit is contained in:
Zoltan Herczeg
2021-04-13 09:51:39 +02:00
committed by GitHub
parent b3ec217b50
commit 053389de80
28 changed files with 304 additions and 123 deletions
+6 -2
View File
@@ -106,18 +106,22 @@ handler_throw_test (const jerry_call_info_t *call_info_p, /**< call information
} /* handler_throw_test */
static void
handler_construct_1_freecb (void *native_p)
handler_construct_1_freecb (void *native_p, /**< native pointer */
jerry_object_native_info_t *info_p) /**< native info */
{
TEST_ASSERT ((uintptr_t) native_p == (uintptr_t) 0x0000000000000000ull);
TEST_ASSERT (info_p->free_cb == handler_construct_1_freecb);
printf ("ok object free callback\n");
test_api_is_free_callback_was_called = true;
} /* handler_construct_1_freecb */
static void
handler_construct_2_freecb (void *native_p)
handler_construct_2_freecb (void *native_p, /**< native pointer */
jerry_object_native_info_t *info_p) /**< native info */
{
TEST_ASSERT ((uintptr_t) native_p == (uintptr_t) 0x0012345678abcdefull);
TEST_ASSERT (info_p->free_cb == handler_construct_2_freecb);
printf ("ok object free callback\n");
test_api_is_free_callback_was_called = true;
+3 -1
View File
@@ -22,9 +22,11 @@ static void *global_p = (void *) &global_int;
static int global_counter = 0;
static void
native_free_callback (void *native_p) /**< native pointer */
native_free_callback (void *native_p, /**< native pointer */
jerry_object_native_info_t *info_p) /**< native info */
{
(void) native_p;
TEST_ASSERT (info_p->free_cb == native_free_callback);
global_counter++;
} /* native_free_callback */
+4 -2
View File
@@ -132,9 +132,11 @@ test_internal_prop (void)
static int test_data = 1;
static void free_test_data (void *data_p)
static void free_test_data (void *native_p, /**< native pointer */
jerry_object_native_info_t *info_p) /**< native info */
{
TEST_ASSERT ((int *) data_p == &test_data);
TEST_ASSERT ((int *) native_p == &test_data);
TEST_ASSERT (info_p->free_cb == free_test_data);
} /* free_test_data */
static const jerry_object_native_info_t test_info =
+6 -4
View File
@@ -150,11 +150,13 @@ struct test_data
};
static void
proxy_native_freecb (void *user_p)
proxy_native_freecb (void *native_p, /**< native pointer */
jerry_object_native_info_t *info_p) /**< native info */
{
TEST_ASSERT (user_p != NULL);
struct test_data *native_p = (struct test_data *) user_p;
native_p->value = -1;
TEST_ASSERT (native_p != NULL);
TEST_ASSERT (info_p->free_cb == proxy_native_freecb);
struct test_data *data_p = (struct test_data *) native_p;
data_p->value = -1;
} /* proxy_native_freecb */
static const jerry_object_native_info_t proxy_native_info =
+4 -2
View File
@@ -24,10 +24,12 @@
static int native_free_cb_call_count;
static void
native_free_cb (void *native_p)
native_free_cb (void *native_p, /**< native pointer */
jerry_object_native_info_t *info_p) /**< native info */
{
++native_free_cb_call_count;
(void) native_p;
(void) info_p;
++native_free_cb_call_count;
} /* native_free_cb */
static const jerry_object_native_info_t native_info =
@@ -24,10 +24,12 @@
static int native_free_cb_call_count;
static void
native_free_cb (void *native_p)
native_free_cb (void *native_p, /**< native pointer */
jerry_object_native_info_t *info_p) /**< native info */
{
++native_free_cb_call_count;
(void) native_p;
(void) info_p;
++native_free_cb_call_count;
} /* native_free_cb */
static const jerry_object_native_info_t native_info =
@@ -27,10 +27,12 @@ static size_t native_free_cb_call_count;
static const size_t handle_count = JERRYX_HANDLE_PRELIST_SIZE + 1;
static void
native_free_cb (void *native_p)
native_free_cb (void *native_p, /**< native pointer */
jerry_object_native_info_t *info_p) /**< native info */
{
++native_free_cb_call_count;
(void) native_p;
(void) info_p;
++native_free_cb_call_count;
} /* native_free_cb */
static const jerry_object_native_info_t native_info =
@@ -27,10 +27,12 @@ static size_t native_free_cb_call_count;
static const size_t handle_count = JERRYX_HANDLE_PRELIST_SIZE * 2;
static void
native_free_cb (void *native_p)
native_free_cb (void *native_p, /**< native pointer */
jerry_object_native_info_t *info_p) /**< native info */
{
++native_free_cb_call_count;
(void) native_p;
(void) info_p;
++native_free_cb_call_count;
} /* native_free_cb */
static const jerry_object_native_info_t native_info =
@@ -27,10 +27,12 @@
static int native_free_cb_call_count;
static void
native_free_cb (void *native_p)
native_free_cb (void *native_p, /**< native pointer */
jerry_object_native_info_t *info_p) /**< native info */
{
++native_free_cb_call_count;
(void) native_p;
(void) info_p;
++native_free_cb_call_count;
} /* native_free_cb */
static const jerry_object_native_info_t native_info =
@@ -24,10 +24,12 @@
static int native_free_cb_call_count;
static void
native_free_cb (void *native_p)
native_free_cb (void *native_p, /**< native pointer */
jerry_object_native_info_t *info_p) /**< native info */
{
++native_free_cb_call_count;
(void) native_p;
(void) info_p;
++native_free_cb_call_count;
} /* native_free_cb */
static const jerry_object_native_info_t native_info =
+4 -2
View File
@@ -25,10 +25,12 @@ static int native_free_cb_call_count;
static int reusing_times = 10;
static void
native_free_cb (void *native_p)
native_free_cb (void *native_p, /**< native pointer */
jerry_object_native_info_t *info_p) /**< native info */
{
++native_free_cb_call_count;
(void) native_p;
(void) info_p;
++native_free_cb_call_count;
} /* native_free_cb */
static const jerry_object_native_info_t native_info =
+4 -2
View File
@@ -24,10 +24,12 @@
static int native_free_cb_call_count;
static void
native_free_cb (void *native_p)
native_free_cb (void *native_p, /**< native pointer */
jerry_object_native_info_t *info_p) /**< native info */
{
++native_free_cb_call_count;
(void) native_p;
(void) info_p;
++native_free_cb_call_count;
} /* native_free_cb */
static const jerry_object_native_info_t native_info =