Skip to content

Commit 466d219

Browse files
committed
Merge lcache into context
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 [email protected]
1 parent a264560 commit 466d219

File tree

11 files changed

+9
-90
lines changed

11 files changed

+9
-90
lines changed

jerry-core/api/jerry.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2648,10 +2648,6 @@ jerry_create_instance (uint32_t heap_size, /**< the size of heap */
26482648
total_size += heap_size;
26492649
#endif /* !JERRY_SYSTEM_ALLOCATOR */
26502650

2651-
#ifndef CONFIG_ECMA_LCACHE_DISABLE
2652-
total_size += sizeof (jerry_hash_table_t);
2653-
#endif /* !CONFIG_ECMA_LCACHE_DISABLE */
2654-
26552651
total_size = JERRY_ALIGNUP (total_size, JMEM_ALIGNMENT);
26562652

26572653
jerry_instance_t *instance_p = (jerry_instance_t *) alloc (total_size, cb_data_p);
@@ -2674,11 +2670,6 @@ jerry_create_instance (uint32_t heap_size, /**< the size of heap */
26742670
byte_p += heap_size;
26752671
#endif /* !JERRY_SYSTEM_ALLOCATOR */
26762672

2677-
#ifndef CONFIG_ECMA_LCACHE_DISABLE
2678-
instance_p->lcache_p = byte_p;
2679-
byte_p += sizeof (jerry_hash_table_t);
2680-
#endif /* !JERRY_SYSTEM_ALLOCATOR */
2681-
26822673
JERRY_ASSERT (byte_p <= ((uint8_t *) instance_p) + total_size);
26832674

26842675
JERRY_UNUSED (byte_p);

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#include "ecma-alloc.h"
1717
#include "ecma-globals.h"
1818
#include "ecma-gc.h"
19-
#include "ecma-lcache.h"
2019
#include "jrt.h"
2120
#include "jmem.h"
2221

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
#include "ecma-globals.h"
2222
#include "ecma-gc.h"
2323
#include "ecma-helpers.h"
24-
#include "ecma-lcache.h"
2524
#include "ecma-property-hashmap.h"
2625
#include "jcontext.h"
2726
#include "jrt.h"

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
#include "ecma-gc.h"
1818
#include "ecma-globals.h"
1919
#include "ecma-helpers.h"
20-
#include "ecma-lcache.h"
2120
#include "jrt.h"
2221
#include "jrt-libc-includes.h"
2322
#include "lit-char-helpers.h"

jerry-core/ecma/base/ecma-init-finalize.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
#include "ecma-gc.h"
1818
#include "ecma-helpers.h"
1919
#include "ecma-init-finalize.h"
20-
#include "ecma-lcache.h"
2120
#include "ecma-lex-env.h"
2221
#include "ecma-literal-storage.h"
2322
#include "jmem.h"
@@ -36,7 +35,6 @@
3635
void
3736
ecma_init (void)
3837
{
39-
ecma_lcache_init ();
4038
ecma_init_global_lex_env ();
4139

4240
jmem_register_free_unused_memory_callback (ecma_free_unused_memory);

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

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -33,20 +33,6 @@
3333
*/
3434
#define ECMA_LCACHE_HASH_MASK (ECMA_LCACHE_HASH_ROWS_COUNT - 1)
3535

36-
#endif /* !CONFIG_ECMA_LCACHE_DISABLE */
37-
38-
/**
39-
* Initialize LCache
40-
*/
41-
void
42-
ecma_lcache_init (void)
43-
{
44-
#ifndef CONFIG_ECMA_LCACHE_DISABLE
45-
memset (JERRY_HASH_TABLE_CONTEXT (table), 0, sizeof (jerry_hash_table_t));
46-
#endif /* !CONFIG_ECMA_LCACHE_DISABLE */
47-
} /* ecma_lcache_init */
48-
49-
#ifndef CONFIG_ECMA_LCACHE_DISABLE
5036
/**
5137
* Invalidate specified LCache entry
5238
*/
@@ -74,6 +60,7 @@ ecma_lcache_row_index (jmem_cpointer_t object_cp, /**< compressed pointer to obj
7460
* so properties of different objects with the same name can be cached effectively. */
7561
return (size_t) ((name_hash ^ object_cp) & ECMA_LCACHE_HASH_MASK);
7662
} /* ecma_lcache_row_index */
63+
7764
#endif /* !CONFIG_ECMA_LCACHE_DISABLE */
7865

7966
/**
@@ -96,7 +83,7 @@ ecma_lcache_insert (ecma_object_t *object_p, /**< object */
9683

9784
lit_string_hash_t name_hash = ecma_string_get_property_name_hash (*prop_p, name_cp);
9885
size_t row_index = ecma_lcache_row_index (object_cp, name_hash);
99-
ecma_lcache_hash_entry_t *entries_p = JERRY_HASH_TABLE_CONTEXT (table)[row_index];
86+
ecma_lcache_hash_entry_t *entries_p = JERRY_CONTEXT (lcache) [row_index];
10087

10188
uint32_t entry_index;
10289
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 */
132119
#endif /* !CONFIG_ECMA_LCACHE_DISABLE */
133120
} /* ecma_lcache_insert */
134121

135-
#ifndef CONFIG_ECMA_LCACHE_DISABLE
136-
137-
138-
139-
#endif /* !CONFIG_ECMA_LCACHE_DISABLE */
140-
141122
/**
142123
* Lookup property in the LCache
143124
*
@@ -182,7 +163,7 @@ ecma_lcache_lookup (ecma_object_t *object_p, /**< object */
182163

183164
size_t row_index = ecma_lcache_row_index (object_cp, name_hash);
184165

185-
ecma_lcache_hash_entry_t *entry_p = JERRY_HASH_TABLE_CONTEXT (table) [row_index];
166+
ecma_lcache_hash_entry_t *entry_p = JERRY_CONTEXT (lcache) [row_index];
186167
ecma_lcache_hash_entry_t *entry_end_p = entry_p + ECMA_LCACHE_HASH_ROW_LENGTH;
187168

188169
while (entry_p < entry_end_p)
@@ -230,12 +211,12 @@ ecma_lcache_invalidate (ecma_object_t *object_p, /**< object */
230211

231212
lit_string_hash_t name_hash = ecma_string_get_property_name_hash (*prop_p, name_cp);
232213
size_t row_index = ecma_lcache_row_index (object_cp, name_hash);
233-
ecma_lcache_hash_entry_t *entry_p = JERRY_HASH_TABLE_CONTEXT (table) [row_index];
214+
ecma_lcache_hash_entry_t *entry_p = JERRY_CONTEXT (lcache) [row_index];
234215

235216
while (true)
236217
{
237218
/* The property must be present. */
238-
JERRY_ASSERT (entry_p - JERRY_HASH_TABLE_CONTEXT (table) [row_index] < ECMA_LCACHE_HASH_ROW_LENGTH);
219+
JERRY_ASSERT (entry_p - JERRY_CONTEXT (lcache) [row_index] < ECMA_LCACHE_HASH_ROW_LENGTH);
239220

240221
if (entry_p->object_cp != ECMA_NULL_POINTER && entry_p->prop_p == prop_p)
241222
{

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
* @{
2424
*/
2525

26-
void ecma_lcache_init (void);
2726
void ecma_lcache_insert (ecma_object_t *object_p, jmem_cpointer_t name_cp, ecma_property_t *prop_p);
2827
ecma_property_t *ecma_lcache_lookup (ecma_object_t *object_p, const ecma_string_t *prop_name_p);
2928
void ecma_lcache_invalidate (ecma_object_t *object_p, jmem_cpointer_t name_cp, ecma_property_t *prop_p);

jerry-core/ecma/operations/ecma-objects-arguments.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
#include "ecma-gc.h"
2121
#include "ecma-globals.h"
2222
#include "ecma-helpers.h"
23-
#include "ecma-lcache.h"
2423
#include "ecma-lex-env.h"
2524
#include "ecma-objects.h"
2625
#include "ecma-objects-arguments.h"

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
#include "ecma-gc.h"
2121
#include "ecma-globals.h"
2222
#include "ecma-function-object.h"
23-
#include "ecma-lcache.h"
2423
#include "ecma-lex-env.h"
2524
#include "ecma-string-object.h"
2625
#include "ecma-objects-arguments.h"

jerry-core/jcontext/jcontext.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,6 @@ jerry_context_t jerry_global_context;
4141
jmem_heap_t jerry_global_heap JERRY_ATTR_ALIGNED (JMEM_ALIGNMENT) JERRY_GLOBAL_HEAP_SECTION;
4242
#endif /* !JERRY_SYSTEM_ALLOCATOR */
4343

44-
#ifndef CONFIG_ECMA_LCACHE_DISABLE
45-
46-
/**
47-
* Global hash table.
48-
*/
49-
jerry_hash_table_t jerry_global_hash_table;
50-
51-
#endif /* !CONFIG_ECMA_LCACHE_DISABLE */
5244
#endif /* !JERRY_ENABLE_EXTERNAL_CONTEXT */
5345

5446
/**

0 commit comments

Comments
 (0)