Skip to content

Commit 7825e47

Browse files
akosthekissLaszloLango
authored andcommitted
Properly guard off LCache-related functionality (#2511)
JerryScript-DCO-1.0-Signed-off-by: Akos Kiss [email protected]
1 parent 8f64339 commit 7825e47

File tree

6 files changed

+27
-14
lines changed

6 files changed

+27
-14
lines changed

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

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -580,12 +580,15 @@ ecma_find_named_property (ecma_object_t *obj_p, /**< object to find property in
580580
JERRY_ASSERT (obj_p != NULL);
581581
JERRY_ASSERT (name_p != NULL);
582582

583-
ecma_property_t *property_p = ecma_lcache_lookup (obj_p, name_p);
583+
ecma_property_t *property_p = NULL;
584584

585+
#ifndef CONFIG_ECMA_LCACHE_DISABLE
586+
property_p = ecma_lcache_lookup (obj_p, name_p);
585587
if (property_p != NULL)
586588
{
587589
return property_p;
588590
}
591+
#endif /* !CONFIG_ECMA_LCACHE_DISABLE */
589592

590593
ecma_property_header_t *prop_iter_p = ecma_get_property_list (obj_p);
591594

@@ -597,11 +600,13 @@ ecma_find_named_property (ecma_object_t *obj_p, /**< object to find property in
597600
name_p,
598601
&property_real_name_cp);
599602

603+
#ifndef CONFIG_ECMA_LCACHE_DISABLE
600604
if (property_p != NULL
601605
&& !ecma_is_property_lcached (property_p))
602606
{
603607
ecma_lcache_insert (obj_p, property_real_name_cp, property_p);
604608
}
609+
#endif /* !CONFIG_ECMA_LCACHE_DISABLE */
605610

606611
return property_p;
607612
}
@@ -693,11 +698,13 @@ ecma_find_named_property (ecma_object_t *obj_p, /**< object to find property in
693698
ecma_property_hashmap_create (obj_p);
694699
}
695700

701+
#ifndef CONFIG_ECMA_LCACHE_DISABLE
696702
if (property_p != NULL
697703
&& !ecma_is_property_lcached (property_p))
698704
{
699705
ecma_lcache_insert (obj_p, property_name_cp, property_p);
700706
}
707+
#endif /* !CONFIG_ECMA_LCACHE_DISABLE */
701708

702709
return property_p;
703710
} /* ecma_find_named_property */
@@ -762,10 +769,12 @@ ecma_free_property (ecma_object_t *object_p, /**< object the property belongs to
762769
}
763770
}
764771

772+
#ifndef CONFIG_ECMA_LCACHE_DISABLE
765773
if (ecma_is_property_lcached (property_p))
766774
{
767775
ecma_lcache_invalidate (object_p, name_cp, property_p);
768776
}
777+
#endif /* !CONFIG_ECMA_LCACHE_DISABLE */
769778

770779
if (ECMA_PROPERTY_GET_NAME_TYPE (*property_p) == ECMA_DIRECT_STRING_PTR)
771780
{
@@ -1241,6 +1250,8 @@ ecma_set_property_configurable_attr (ecma_property_t *property_p, /**< [in,out]
12411250
}
12421251
} /* ecma_set_property_configurable_attr */
12431252

1253+
#ifndef CONFIG_ECMA_LCACHE_DISABLE
1254+
12441255
/**
12451256
* Check whether the property is registered in LCache
12461257
*
@@ -1277,6 +1288,8 @@ ecma_set_property_lcached (ecma_property_t *property_p, /**< property */
12771288
}
12781289
} /* ecma_set_property_lcached */
12791290

1291+
#endif /* !CONFIG_ECMA_LCACHE_DISABLE */
1292+
12801293
/**
12811294
* Construct empty property descriptor, i.e.:
12821295
* property descriptor with all is_defined flags set to false and the rest - to default value.

jerry-core/ecma/base/ecma-helpers.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,8 +339,10 @@ void ecma_set_property_enumerable_attr (ecma_property_t *property_p, bool is_enu
339339
bool ecma_is_property_configurable (ecma_property_t property);
340340
void ecma_set_property_configurable_attr (ecma_property_t *property_p, bool is_configurable);
341341

342+
#ifndef CONFIG_ECMA_LCACHE_DISABLE
342343
bool ecma_is_property_lcached (ecma_property_t *property_p);
343344
void ecma_set_property_lcached (ecma_property_t *property_p, bool is_lcached);
345+
#endif /* !CONFIG_ECMA_LCACHE_DISABLE */
344346

345347
ecma_property_descriptor_t ecma_make_empty_property_descriptor (void);
346348
void ecma_free_property_descriptor (ecma_property_descriptor_t *prop_desc_p);

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

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,6 @@ ecma_lcache_row_index (jmem_cpointer_t object_cp, /**< compressed pointer to obj
6161
return (size_t) ((name_hash ^ object_cp) & ECMA_LCACHE_HASH_MASK);
6262
} /* ecma_lcache_row_index */
6363

64-
#endif /* !CONFIG_ECMA_LCACHE_DISABLE */
65-
6664
/**
6765
* Insert an entry into LCache
6866
*/
@@ -77,7 +75,6 @@ ecma_lcache_insert (ecma_object_t *object_p, /**< object */
7775
|| ECMA_PROPERTY_GET_TYPE (*prop_p) == ECMA_PROPERTY_TYPE_NAMEDACCESSOR
7876
|| ECMA_PROPERTY_GET_TYPE (*prop_p) == ECMA_PROPERTY_TYPE_INTERNAL);
7977

80-
#ifndef CONFIG_ECMA_LCACHE_DISABLE
8178
jmem_cpointer_t object_cp;
8279

8380
ECMA_SET_NON_NULL_POINTER (object_cp, object_p);
@@ -115,9 +112,6 @@ ecma_lcache_insert (ecma_object_t *object_p, /**< object */
115112
entry_p->prop_p = prop_p;
116113

117114
ecma_set_property_lcached (entry_p->prop_p, true);
118-
#else /* CONFIG_ECMA_LCACHE_DISABLE */
119-
JERRY_UNUSED (name_cp);
120-
#endif /* !CONFIG_ECMA_LCACHE_DISABLE */
121115
} /* ecma_lcache_insert */
122116

123117
/**
@@ -133,7 +127,6 @@ ecma_lcache_lookup (ecma_object_t *object_p, /**< object */
133127
JERRY_ASSERT (object_p != NULL);
134128
JERRY_ASSERT (prop_name_p != NULL);
135129

136-
#ifndef CONFIG_ECMA_LCACHE_DISABLE
137130
jmem_cpointer_t object_cp;
138131
ECMA_SET_NON_NULL_POINTER (object_cp, object_p);
139132

@@ -188,7 +181,6 @@ ecma_lcache_lookup (ecma_object_t *object_p, /**< object */
188181

189182
entry_p++;
190183
}
191-
#endif /* !CONFIG_ECMA_LCACHE_DISABLE */
192184

193185
return NULL;
194186
} /* ecma_lcache_lookup */
@@ -206,7 +198,6 @@ ecma_lcache_invalidate (ecma_object_t *object_p, /**< object */
206198
JERRY_ASSERT (ECMA_PROPERTY_GET_TYPE (*prop_p) == ECMA_PROPERTY_TYPE_NAMEDDATA
207199
|| ECMA_PROPERTY_GET_TYPE (*prop_p) == ECMA_PROPERTY_TYPE_NAMEDACCESSOR);
208200

209-
#ifndef CONFIG_ECMA_LCACHE_DISABLE
210201
jmem_cpointer_t object_cp;
211202
ECMA_SET_NON_NULL_POINTER (object_cp, object_p);
212203

@@ -228,11 +219,10 @@ ecma_lcache_invalidate (ecma_object_t *object_p, /**< object */
228219
}
229220
entry_p++;
230221
}
231-
#else /* CONFIG_ECMA_LCACHE_DISABLE */
232-
JERRY_UNUSED (name_cp);
233-
#endif /* !CONFIG_ECMA_LCACHE_DISABLE */
234222
} /* ecma_lcache_invalidate */
235223

224+
#endif /* !CONFIG_ECMA_LCACHE_DISABLE */
225+
236226
/**
237227
* @}
238228
* @}

jerry-core/ecma/base/ecma-lcache.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,14 @@
2323
* @{
2424
*/
2525

26+
#ifndef CONFIG_ECMA_LCACHE_DISABLE
27+
2628
void ecma_lcache_insert (ecma_object_t *object_p, jmem_cpointer_t name_cp, ecma_property_t *prop_p);
2729
ecma_property_t *ecma_lcache_lookup (ecma_object_t *object_p, const ecma_string_t *prop_name_p);
2830
void ecma_lcache_invalidate (ecma_object_t *object_p, jmem_cpointer_t name_cp, ecma_property_t *prop_p);
2931

32+
#endif /* !CONFIG_ECMA_LCACHE_DISABLE */
33+
3034
/**
3135
* @}
3236
* @}

jerry-core/ecma/operations/ecma-reference.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ ecma_op_resolve_reference_value (ecma_object_t *lex_env_p, /**< starting lexical
8787

8888
ecma_object_t *binding_obj_p = ecma_get_lex_env_binding_object (lex_env_p);
8989

90+
#ifndef CONFIG_ECMA_LCACHE_DISABLE
9091
ecma_property_t *property_p = ecma_lcache_lookup (binding_obj_p, name_p);
9192

9293
if (property_p != NULL)
@@ -110,6 +111,7 @@ ecma_op_resolve_reference_value (ecma_object_t *lex_env_p, /**< starting lexical
110111
ecma_value_t base_value = ecma_make_object_value (binding_obj_p);
111112
return ecma_op_function_call (getter_p, base_value, NULL, 0);
112113
}
114+
#endif /* !CONFIG_ECMA_LCACHE_DISABLE */
113115

114116
ecma_value_t prop_value = ecma_op_object_find (binding_obj_p, name_p);
115117

jerry-core/vm/vm.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ vm_op_get_value (ecma_value_t object, /**< base object */
5353
{
5454
if (ecma_is_value_object (object))
5555
{
56-
ecma_object_t *object_p = ecma_get_object_from_value (object);
5756
ecma_string_t *property_name_p = NULL;
5857

5958
if (ecma_is_value_integer_number (property))
@@ -73,13 +72,16 @@ vm_op_get_value (ecma_value_t object, /**< base object */
7372

7473
if (property_name_p != NULL)
7574
{
75+
#ifndef CONFIG_ECMA_LCACHE_DISABLE
76+
ecma_object_t *object_p = ecma_get_object_from_value (object);
7677
ecma_property_t *property_p = ecma_lcache_lookup (object_p, property_name_p);
7778

7879
if (property_p != NULL &&
7980
ECMA_PROPERTY_GET_TYPE (*property_p) == ECMA_PROPERTY_TYPE_NAMEDDATA)
8081
{
8182
return ecma_fast_copy_value (ECMA_PROPERTY_VALUE_PTR (property_p)->value);
8283
}
84+
#endif /* !CONFIG_ECMA_LCACHE_DISABLE */
8385

8486
/* There is no need to free the name. */
8587
return ecma_op_object_get (ecma_get_object_from_value (object), property_name_p);

0 commit comments

Comments
 (0)