Merge lcache into context (#2498)

It is superfluous to maintain multiple globals when the whole
reason of context is to keep them in a single place. It also
simplifies initialization and external context creation a bit.

Also removed unused lcache header includes.

JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
This commit is contained in:
Akos Kiss
2018-08-31 13:10:37 +02:00
committed by GitHub
parent a2645601ae
commit 6049c0378d
11 changed files with 9 additions and 90 deletions
+5 -24
View File
@@ -33,20 +33,6 @@
*/
#define ECMA_LCACHE_HASH_MASK (ECMA_LCACHE_HASH_ROWS_COUNT - 1)
#endif /* !CONFIG_ECMA_LCACHE_DISABLE */
/**
* Initialize LCache
*/
void
ecma_lcache_init (void)
{
#ifndef CONFIG_ECMA_LCACHE_DISABLE
memset (JERRY_HASH_TABLE_CONTEXT (table), 0, sizeof (jerry_hash_table_t));
#endif /* !CONFIG_ECMA_LCACHE_DISABLE */
} /* ecma_lcache_init */
#ifndef CONFIG_ECMA_LCACHE_DISABLE
/**
* Invalidate specified LCache entry
*/
@@ -74,6 +60,7 @@ ecma_lcache_row_index (jmem_cpointer_t object_cp, /**< compressed pointer to obj
* so properties of different objects with the same name can be cached effectively. */
return (size_t) ((name_hash ^ object_cp) & ECMA_LCACHE_HASH_MASK);
} /* ecma_lcache_row_index */
#endif /* !CONFIG_ECMA_LCACHE_DISABLE */
/**
@@ -96,7 +83,7 @@ ecma_lcache_insert (ecma_object_t *object_p, /**< object */
lit_string_hash_t name_hash = ecma_string_get_property_name_hash (*prop_p, name_cp);
size_t row_index = ecma_lcache_row_index (object_cp, name_hash);
ecma_lcache_hash_entry_t *entries_p = JERRY_HASH_TABLE_CONTEXT (table)[row_index];
ecma_lcache_hash_entry_t *entries_p = JERRY_CONTEXT (lcache) [row_index];
uint32_t entry_index;
for (entry_index = 0; entry_index < ECMA_LCACHE_HASH_ROW_LENGTH; entry_index++)
@@ -132,12 +119,6 @@ ecma_lcache_insert (ecma_object_t *object_p, /**< object */
#endif /* !CONFIG_ECMA_LCACHE_DISABLE */
} /* ecma_lcache_insert */
#ifndef CONFIG_ECMA_LCACHE_DISABLE
#endif /* !CONFIG_ECMA_LCACHE_DISABLE */
/**
* Lookup property in the LCache
*
@@ -182,7 +163,7 @@ ecma_lcache_lookup (ecma_object_t *object_p, /**< object */
size_t row_index = ecma_lcache_row_index (object_cp, name_hash);
ecma_lcache_hash_entry_t *entry_p = JERRY_HASH_TABLE_CONTEXT (table) [row_index];
ecma_lcache_hash_entry_t *entry_p = JERRY_CONTEXT (lcache) [row_index];
ecma_lcache_hash_entry_t *entry_end_p = entry_p + ECMA_LCACHE_HASH_ROW_LENGTH;
while (entry_p < entry_end_p)
@@ -230,12 +211,12 @@ ecma_lcache_invalidate (ecma_object_t *object_p, /**< object */
lit_string_hash_t name_hash = ecma_string_get_property_name_hash (*prop_p, name_cp);
size_t row_index = ecma_lcache_row_index (object_cp, name_hash);
ecma_lcache_hash_entry_t *entry_p = JERRY_HASH_TABLE_CONTEXT (table) [row_index];
ecma_lcache_hash_entry_t *entry_p = JERRY_CONTEXT (lcache) [row_index];
while (true)
{
/* The property must be present. */
JERRY_ASSERT (entry_p - JERRY_HASH_TABLE_CONTEXT (table) [row_index] < ECMA_LCACHE_HASH_ROW_LENGTH);
JERRY_ASSERT (entry_p - JERRY_CONTEXT (lcache) [row_index] < ECMA_LCACHE_HASH_ROW_LENGTH);
if (entry_p->object_cp != ECMA_NULL_POINTER && entry_p->prop_p == prop_p)
{