59
59
* @return true - if visited
60
60
* false - otherwise
61
61
*/
62
- static inline bool
62
+ static inline bool JERRY_ATTR_ALWAYS_INLINE
63
63
ecma_gc_is_object_visited (ecma_object_t * object_p ) /**< object */
64
64
{
65
65
JERRY_ASSERT (object_p != NULL );
@@ -69,15 +69,25 @@ ecma_gc_is_object_visited (ecma_object_t *object_p) /**< object */
69
69
70
70
/**
71
71
* Set visited flag of the object.
72
+ * Note: This macro can be inlined for performance critical code paths
72
73
*/
73
- static inline void
74
+ #define ECMA_GC_SET_OBJECT_VISITED (object_p ) \
75
+ do \
76
+ { \
77
+ if ((object_p)->type_flags_refs < ECMA_OBJECT_REF_ONE) \
78
+ { \
79
+ (object_p)->type_flags_refs |= ECMA_OBJECT_REF_ONE; \
80
+ } \
81
+ } while (0)
82
+
83
+ /**
84
+ * Set visited flag of the object.
85
+ */
86
+ static void JERRY_ATTR_NOINLINE
74
87
ecma_gc_set_object_visited (ecma_object_t * object_p ) /**< object */
75
88
{
76
89
/* Set reference counter to one if it is zero. */
77
- if (object_p -> type_flags_refs < ECMA_OBJECT_REF_ONE )
78
- {
79
- object_p -> type_flags_refs |= ECMA_OBJECT_REF_ONE ;
80
- }
90
+ ECMA_GC_SET_OBJECT_VISITED (object_p );
81
91
} /* ecma_gc_set_object_visited */
82
92
83
93
/**
@@ -144,7 +154,7 @@ ecma_gc_mark_properties (ecma_property_pair_t *property_pair_p) /**< property pa
144
154
{
145
155
ecma_object_t * value_obj_p = ecma_get_object_from_value (value );
146
156
147
- ecma_gc_set_object_visited (value_obj_p );
157
+ ECMA_GC_SET_OBJECT_VISITED (value_obj_p );
148
158
}
149
159
break ;
150
160
}
@@ -305,7 +315,7 @@ ecma_gc_mark (ecma_object_t *object_p) /**< object to mark from */
305
315
306
316
if (outer_lex_env_cp != JMEM_CP_NULL )
307
317
{
308
- ecma_gc_set_object_visited (ECMA_GET_NON_NULL_POINTER (ecma_object_t , outer_lex_env_cp ));
318
+ ECMA_GC_SET_OBJECT_VISITED (ECMA_GET_NON_NULL_POINTER (ecma_object_t , outer_lex_env_cp ));
309
319
}
310
320
311
321
if (ecma_get_lex_env_type (object_p ) != ECMA_LEXICAL_ENVIRONMENT_DECLARATIVE )
@@ -322,7 +332,7 @@ ecma_gc_mark (ecma_object_t *object_p) /**< object to mark from */
322
332
323
333
if (proto_cp != JMEM_CP_NULL )
324
334
{
325
- ecma_gc_set_object_visited (ECMA_GET_NON_NULL_POINTER (ecma_object_t , proto_cp ));
335
+ ECMA_GC_SET_OBJECT_VISITED (ECMA_GET_NON_NULL_POINTER (ecma_object_t , proto_cp ));
326
336
}
327
337
328
338
switch (ecma_get_object_type (object_p ))
@@ -432,7 +442,7 @@ ecma_gc_mark (ecma_object_t *object_p) /**< object to mark from */
432
442
{
433
443
if (ecma_is_value_object (values_p [i ]))
434
444
{
435
- ecma_gc_set_object_visited (ecma_get_object_from_value (values_p [i ]));
445
+ ECMA_GC_SET_OBJECT_VISITED (ecma_get_object_from_value (values_p [i ]));
436
446
}
437
447
}
438
448
@@ -481,7 +491,7 @@ ecma_gc_mark (ecma_object_t *object_p) /**< object to mark from */
481
491
{
482
492
ecma_extended_object_t * ext_func_p = (ecma_extended_object_t * ) object_p ;
483
493
484
- ecma_gc_set_object_visited (ECMA_GET_INTERNAL_VALUE_POINTER (ecma_object_t ,
494
+ ECMA_GC_SET_OBJECT_VISITED (ECMA_GET_INTERNAL_VALUE_POINTER (ecma_object_t ,
485
495
ext_func_p -> u .function .scope_cp ));
486
496
}
487
497
break ;
@@ -663,8 +673,8 @@ ecma_gc_free_object (ecma_object_t *object_p) /**< object to free */
663
673
jmem_cpointer_t name_cp = prop_pair_p -> names_cp [i ];
664
674
665
675
/* Call the native's free callback. */
666
- if (ECMA_PROPERTY_GET_NAME_TYPE (* property_p ) == ECMA_DIRECT_STRING_MAGIC
667
- && (name_cp == LIT_INTERNAL_MAGIC_STRING_NATIVE_POINTER ))
676
+ if (JERRY_UNLIKELY ( ECMA_PROPERTY_GET_NAME_TYPE (* property_p ) == ECMA_DIRECT_STRING_MAGIC
677
+ && (name_cp == LIT_INTERNAL_MAGIC_STRING_NATIVE_POINTER ) ))
668
678
{
669
679
ecma_gc_free_native_pointer (property_p );
670
680
}
0 commit comments