Skip to content

Commit 29b5a40

Browse files
committed
Unify internal property creation
Furthermore free up a bit in the property descriptor. JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
1 parent 68b47f5 commit 29b5a40

18 files changed

+331
-380
lines changed

jerry-core/debugger/debugger.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -1482,8 +1482,7 @@ jerry_debugger_exception_object_to_string (ecma_value_t exception_obj_value) /**
14821482
property_p = ecma_find_named_property (ecma_get_object_from_value (exception_obj_value),
14831483
ecma_get_magic_string (LIT_MAGIC_STRING_MESSAGE));
14841484

1485-
if (property_p == NULL
1486-
|| ECMA_PROPERTY_GET_TYPE (*property_p) != ECMA_PROPERTY_TYPE_NAMEDDATA)
1485+
if (property_p == NULL || !(*property_p & ECMA_PROPERTY_FLAG_DATA))
14871486
{
14881487
return ecma_stringbuilder_finalize (&builder);
14891488
}

jerry-core/ecma/base/ecma-gc.c

+87-84
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "ecma-globals.h"
2626
#include "ecma-gc.h"
2727
#include "ecma-helpers.h"
28+
#include "ecma-lcache.h"
2829
#include "ecma-objects.h"
2930
#include "ecma-property-hashmap.h"
3031
#include "ecma-proxy-object.h"
@@ -223,69 +224,63 @@ ecma_gc_mark_properties (ecma_property_pair_t *property_pair_p) /**< property pa
223224
{
224225
uint8_t property = property_pair_p->header.types[index];
225226

226-
switch (ECMA_PROPERTY_GET_TYPE (property))
227+
if (JERRY_LIKELY (ECMA_PROPERTY_IS_RAW (property)))
227228
{
228-
case ECMA_PROPERTY_TYPE_NAMEDDATA:
229+
if (property & ECMA_PROPERTY_FLAG_DATA)
229230
{
230231
ecma_value_t value = property_pair_p->values[index].value;
231232

232233
if (ecma_is_value_object (value))
233234
{
234235
ecma_gc_set_object_visited (ecma_get_object_from_value (value));
235236
}
236-
break;
237+
continue;
237238
}
238-
case ECMA_PROPERTY_TYPE_NAMEDACCESSOR:
239-
{
240-
ecma_property_value_t *accessor_objs_p = property_pair_p->values + index;
241239

242-
ecma_getter_setter_pointers_t *get_set_pair_p = ecma_get_named_accessor_property (accessor_objs_p);
240+
ecma_property_value_t *accessor_objs_p = property_pair_p->values + index;
243241

244-
if (get_set_pair_p->getter_cp != JMEM_CP_NULL)
245-
{
246-
ecma_gc_set_object_visited (ECMA_GET_NON_NULL_POINTER (ecma_object_t, get_set_pair_p->getter_cp));
247-
}
242+
ecma_getter_setter_pointers_t *get_set_pair_p = ecma_get_named_accessor_property (accessor_objs_p);
248243

249-
if (get_set_pair_p->setter_cp != JMEM_CP_NULL)
250-
{
251-
ecma_gc_set_object_visited (ECMA_GET_NON_NULL_POINTER (ecma_object_t, get_set_pair_p->setter_cp));
252-
}
253-
break;
244+
if (get_set_pair_p->getter_cp != JMEM_CP_NULL)
245+
{
246+
ecma_gc_set_object_visited (ECMA_GET_NON_NULL_POINTER (ecma_object_t, get_set_pair_p->getter_cp));
254247
}
255-
case ECMA_PROPERTY_TYPE_INTERNAL:
248+
249+
if (get_set_pair_p->setter_cp != JMEM_CP_NULL)
256250
{
257-
JERRY_ASSERT (ECMA_PROPERTY_GET_NAME_TYPE (property) == ECMA_DIRECT_STRING_MAGIC
258-
&& property_pair_p->names_cp[index] >= LIT_INTERNAL_MAGIC_STRING_FIRST_DATA
259-
&& property_pair_p->names_cp[index] < LIT_MAGIC_STRING__COUNT);
251+
ecma_gc_set_object_visited (ECMA_GET_NON_NULL_POINTER (ecma_object_t, get_set_pair_p->setter_cp));
252+
}
260253

261-
#if ENABLED (JERRY_ESNEXT)
262-
if (property_pair_p->names_cp[index] == LIT_INTERNAL_MAGIC_STRING_ENVIRONMENT_RECORD)
263-
{
264-
ecma_environment_record_t *environment_record_p;
265-
environment_record_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_environment_record_t,
266-
property_pair_p->values[index].value);
254+
continue;
255+
}
267256

268-
if (environment_record_p->this_binding != ECMA_VALUE_UNINITIALIZED)
269-
{
270-
JERRY_ASSERT (ecma_is_value_object (environment_record_p->this_binding));
271-
ecma_gc_set_object_visited (ecma_get_object_from_value (environment_record_p->this_binding));
272-
}
257+
if (!ECMA_PROPERTY_IS_INTERNAL (property))
258+
{
259+
JERRY_ASSERT (property == ECMA_PROPERTY_TYPE_DELETED
260+
|| property == ECMA_PROPERTY_TYPE_HASHMAP);
261+
continue;
262+
}
273263

274-
JERRY_ASSERT (ecma_is_value_object (environment_record_p->function_object));
275-
ecma_gc_set_object_visited (ecma_get_object_from_value (environment_record_p->function_object));
276-
}
277-
#endif /* ENABLED (JERRY_ESNEXT) */
278-
break;
279-
}
280-
default:
281-
{
282-
JERRY_ASSERT (ECMA_PROPERTY_GET_TYPE (property) == ECMA_PROPERTY_TYPE_SPECIAL);
264+
JERRY_ASSERT (property_pair_p->names_cp[index] >= LIT_INTERNAL_MAGIC_STRING_FIRST_DATA
265+
&& property_pair_p->names_cp[index] < LIT_MAGIC_STRING__COUNT);
283266

284-
JERRY_ASSERT (property == ECMA_PROPERTY_TYPE_HASHMAP
285-
|| property == ECMA_PROPERTY_TYPE_DELETED);
286-
break;
267+
#if ENABLED (JERRY_ESNEXT)
268+
if (property_pair_p->names_cp[index] == LIT_INTERNAL_MAGIC_STRING_ENVIRONMENT_RECORD)
269+
{
270+
ecma_environment_record_t *environment_record_p;
271+
environment_record_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_environment_record_t,
272+
property_pair_p->values[index].value);
273+
274+
if (environment_record_p->this_binding != ECMA_VALUE_UNINITIALIZED)
275+
{
276+
JERRY_ASSERT (ecma_is_value_object (environment_record_p->this_binding));
277+
ecma_gc_set_object_visited (ecma_get_object_from_value (environment_record_p->this_binding));
287278
}
279+
280+
JERRY_ASSERT (ecma_is_value_object (environment_record_p->function_object));
281+
ecma_gc_set_object_visited (ecma_get_object_from_value (environment_record_p->function_object));
288282
}
283+
#endif /* ENABLED (JERRY_ESNEXT) */
289284
}
290285
} /* ecma_gc_mark_properties */
291286

@@ -1316,65 +1311,73 @@ ecma_gc_free_properties (ecma_object_t *object_p) /**< object */
13161311
ecma_property_t *property_p = (ecma_property_t *) (prop_iter_p->types + i);
13171312
jmem_cpointer_t name_cp = prop_pair_p->names_cp[i];
13181313

1319-
if (ECMA_PROPERTY_GET_TYPE (*property_p) == ECMA_PROPERTY_TYPE_INTERNAL)
1314+
if (*property_p == ECMA_PROPERTY_TYPE_DELETED)
13201315
{
1321-
JERRY_ASSERT (ECMA_PROPERTY_GET_NAME_TYPE (*property_p) == ECMA_DIRECT_STRING_MAGIC);
1316+
continue;
1317+
}
13221318

1323-
/* Call the native's free callback. */
1324-
switch (name_cp)
1325-
{
1319+
if (!ECMA_PROPERTY_IS_INTERNAL (*property_p))
1320+
{
1321+
ecma_free_property (object_p, name_cp, property_p);
1322+
continue;
1323+
}
1324+
1325+
/* Call the native's free callback. */
1326+
switch (name_cp)
1327+
{
13261328
#if ENABLED (JERRY_ESNEXT)
1327-
case LIT_INTERNAL_MAGIC_STRING_ENVIRONMENT_RECORD:
1328-
{
1329-
ecma_environment_record_t *environment_record_p;
1330-
environment_record_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_environment_record_t,
1329+
case LIT_INTERNAL_MAGIC_STRING_ENVIRONMENT_RECORD:
1330+
{
1331+
ecma_environment_record_t *environment_record_p;
1332+
environment_record_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_environment_record_t,
13311333
prop_pair_p->values[i].value);
1332-
jmem_heap_free_block (environment_record_p, sizeof (ecma_environment_record_t));
1333-
break;
1334-
}
1335-
case LIT_INTERNAL_MAGIC_STRING_CLASS_FIELD_COMPUTED:
1336-
{
1337-
ecma_value_t *compact_collection_p;
1338-
compact_collection_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_value_t,
1334+
jmem_heap_free_block (environment_record_p, sizeof (ecma_environment_record_t));
1335+
break;
1336+
}
1337+
case LIT_INTERNAL_MAGIC_STRING_CLASS_FIELD_COMPUTED:
1338+
{
1339+
ecma_value_t *compact_collection_p;
1340+
compact_collection_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_value_t,
13391341
prop_pair_p->values[i].value);
1340-
ecma_compact_collection_free (compact_collection_p);
1341-
break;
1342-
}
1342+
ecma_compact_collection_free (compact_collection_p);
1343+
break;
1344+
}
13431345
#endif /* ENABLED (JERRY_ESNEXT) */
13441346
#if ENABLED (JERRY_BUILTIN_WEAKMAP) || ENABLED (JERRY_BUILTIN_WEAKSET)
1345-
case LIT_INTERNAL_MAGIC_STRING_WEAK_REFS:
1346-
{
1347-
ecma_collection_t *refs_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t,
1347+
case LIT_INTERNAL_MAGIC_STRING_WEAK_REFS:
1348+
{
1349+
ecma_collection_t *refs_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t,
13481350
prop_pair_p->values[i].value);
1349-
for (uint32_t j = 0; j < refs_p->item_count; j++)
1351+
for (uint32_t j = 0; j < refs_p->item_count; j++)
1352+
{
1353+
const ecma_value_t value = refs_p->buffer_p[j];
1354+
if (!ecma_is_value_empty (value))
13501355
{
1351-
const ecma_value_t value = refs_p->buffer_p[j];
1352-
if (!ecma_is_value_empty (value))
1353-
{
1354-
ecma_object_t *container_p = ecma_get_object_from_value (value);
1356+
ecma_object_t *container_p = ecma_get_object_from_value (value);
13551357

1356-
ecma_op_container_remove_weak_entry (container_p,
1357-
ecma_make_object_value (object_p));
1358-
}
1358+
ecma_op_container_remove_weak_entry (container_p,
1359+
ecma_make_object_value (object_p));
13591360
}
1360-
1361-
ecma_collection_destroy (refs_p);
1362-
break;
13631361
}
1362+
1363+
ecma_collection_destroy (refs_p);
1364+
break;
1365+
}
13641366
#endif /* ENABLED (JERRY_BUILTIN_WEAKMAP) || ENABLED (JERRY_BUILTIN_WEAKSET) */
1365-
default:
1366-
{
1367-
JERRY_ASSERT (name_cp == LIT_INTERNAL_MAGIC_STRING_NATIVE_POINTER);
1368-
ecma_gc_free_native_pointer (property_p);
1369-
break;
1370-
}
1367+
default:
1368+
{
1369+
JERRY_ASSERT (name_cp == LIT_INTERNAL_MAGIC_STRING_NATIVE_POINTER);
1370+
ecma_gc_free_native_pointer (property_p);
1371+
break;
13711372
}
13721373
}
13731374

1374-
if (prop_iter_p->types[i] != ECMA_PROPERTY_TYPE_DELETED)
1375+
#if ENABLED (JERRY_LCACHE)
1376+
if (ecma_is_property_lcached (property_p))
13751377
{
1376-
ecma_free_property (object_p, name_cp, property_p);
1378+
ecma_lcache_invalidate (object_p, name_cp, property_p);
13771379
}
1380+
#endif /* ENABLED (JERRY_LCACHE) */
13781381
}
13791382

13801383
prop_iter_cp = prop_iter_p->next_property_cp;

0 commit comments

Comments
 (0)