Skip to content

Commit a0e256e

Browse files
committed
Reorganize the fields of the global context.
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg [email protected]
1 parent dc87ce0 commit a0e256e

File tree

2 files changed

+30
-46
lines changed

2 files changed

+30
-46
lines changed

jerry-core/jcontext/jcontext.h

Lines changed: 30 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
#include "ecma-builtins.h"
2424
#include "jmem-allocator.h"
2525
#include "jmem-config.h"
26-
#include "jrt.h"
2726
#include "re-bytecode.h"
2827
#include "vm-defines.h"
2928

@@ -37,7 +36,7 @@
3736
/**
3837
* First member of the jerry context
3938
*/
40-
#define JERRY_CONTEXT_FIRST_MEMBER jmem_heap_allocated_size
39+
#define JERRY_CONTEXT_FIRST_MEMBER ecma_builtin_objects
4140

4241
/**
4342
* JerryScript context
@@ -47,58 +46,45 @@
4746
*/
4847
typedef struct
4948
{
50-
/**
51-
* Memory manager part.
52-
*/
53-
size_t jmem_heap_allocated_size; /**< size of allocated regions */
54-
size_t jmem_heap_limit; /**< current limit of heap usage, that is upon being reached,
55-
* causes call of "try give memory back" callbacks */
49+
/* Update JERRY_CONTEXT_FIRST_MEMBER if the first member changes */
50+
ecma_object_t *ecma_builtin_objects[ECMA_BUILTIN_ID__COUNT]; /**< pointer to instances of built-in objects */
51+
#ifndef CONFIG_DISABLE_REGEXP_BUILTIN
52+
const re_compiled_code_t *re_cache[RE_CACHE_SIZE]; /**< regex cache */
53+
#endif /* !CONFIG_DISABLE_REGEXP_BUILTIN */
54+
ecma_object_t *ecma_gc_objects_lists[ECMA_GC_COLOR__COUNT]; /**< List of marked (visited during
55+
* current GC session) and umarked objects */
5656
jmem_heap_free_t *jmem_heap_list_skip_p; /**< This is used to speed up deallocation. */
5757
jmem_pools_chunk_t *jmem_free_chunk_p; /**< list of free pool chunks */
5858
jmem_free_unused_memory_callback_t jmem_free_unused_memory_callback; /**< Callback for freeing up memory. */
59-
60-
#ifdef JMEM_STATS
61-
jmem_heap_stats_t jmem_heap_stats; /**< heap's memory usage statistics */
62-
jmem_pools_stats_t jmem_pools_stats; /**< pools' memory usage statistics */
63-
#endif /* MEM_STATS */
64-
65-
#ifdef JERRY_VALGRIND_FREYA
66-
bool valgrind_freya_mempool_request; /**< Tells whether a pool manager
67-
* allocator request is in progress */
68-
#endif /* JERRY_VALGRIND_FREYA */
69-
70-
/**
71-
* Literal part.
72-
*/
7359
const lit_utf8_byte_t **lit_magic_string_ex_array; /**< array of external magic strings */
74-
uint32_t lit_magic_string_ex_count; /**< external magic strings count */
7560
const lit_utf8_size_t *lit_magic_string_ex_sizes; /**< external magic string lengths */
76-
77-
/**
78-
* Ecma part.
79-
*/
80-
ecma_object_t *ecma_builtin_objects[ECMA_BUILTIN_ID__COUNT]; /**< pointer to instances of built-in objects */
81-
ecma_object_t *ecma_gc_objects_lists[ECMA_GC_COLOR__COUNT]; /**< List of marked (visited during
82-
* current GC session) and umarked objects */
83-
#ifndef CONFIG_DISABLE_REGEXP_BUILTIN
84-
const re_compiled_code_t *re_cache[RE_CACHE_SIZE]; /**< regex cache */
85-
uint8_t re_cache_idx; /**< evicted item index when regex cache is full (round-robin) */
86-
#endif /* !CONFIG_DISABLE_REGEXP_BUILTIN */
87-
88-
bool ecma_gc_visited_flip_flag; /**< current state of an object's visited flag */
89-
bool is_direct_eval_form_call; /**< direct call from eval */
90-
size_t ecma_gc_objects_number; /**< number of currently allocated objects */
91-
size_t ecma_gc_new_objects; /**< number of newly allocated objects since last GC session */
9261
ecma_lit_storage_item_t *string_list_first_p; /**< first item of the literal string list */
9362
ecma_lit_storage_item_t *number_list_first_p; /**< first item of the literal number list */
9463
ecma_object_t *ecma_global_lex_env_p; /**< global lexical environment */
9564
vm_frame_ctx_t *vm_top_context_p; /**< top (current) interpreter context */
65+
size_t ecma_gc_objects_number; /**< number of currently allocated objects */
66+
size_t ecma_gc_new_objects; /**< number of newly allocated objects since last GC session */
67+
size_t jmem_heap_allocated_size; /**< size of allocated regions */
68+
size_t jmem_heap_limit; /**< current limit of heap usage, that is upon being reached,
69+
* causes call of "try give memory back" callbacks */
70+
uint32_t lit_magic_string_ex_count; /**< external magic strings count */
71+
uint32_t jerry_init_flags; /**< run-time configuration flags */
72+
uint8_t ecma_gc_visited_flip_flag; /**< current state of an object's visited flag */
73+
uint8_t is_direct_eval_form_call; /**< direct call from eval */
74+
uint8_t jerry_api_available; /**< API availability flag */
75+
#ifndef CONFIG_DISABLE_REGEXP_BUILTIN
76+
uint8_t re_cache_idx; /**< evicted item index when regex cache is full (round-robin) */
77+
#endif /* !CONFIG_DISABLE_REGEXP_BUILTIN */
9678

97-
/**
98-
* API part.
99-
*/
100-
jerry_init_flag_t jerry_init_flags; /**< run-time configuration flags */
101-
bool jerry_api_available; /**< API availability flag */
79+
#ifdef JMEM_STATS
80+
jmem_heap_stats_t jmem_heap_stats; /**< heap's memory usage statistics */
81+
jmem_pools_stats_t jmem_pools_stats; /**< pools' memory usage statistics */
82+
#endif /* JMEM_STATS */
83+
84+
#ifdef JERRY_VALGRIND_FREYA
85+
uint8_t valgrind_freya_mempool_request; /**< Tells whether a pool manager
86+
* allocator request is in progress */
87+
#endif /* JERRY_VALGRIND_FREYA */
10288
} jerry_context_t;
10389

10490
/**

jerry-core/jerry.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
#include <stdio.h>
1818

19-
#include "lit-magic-strings.h"
2019
#include "ecma-alloc.h"
2120
#include "ecma-array-object.h"
2221
#include "ecma-builtin-helpers.h"
@@ -36,7 +35,6 @@
3635
#include "jerry-snapshot.h"
3736
#include "js-parser.h"
3837
#include "re-compiler.h"
39-
#include "vm.h"
4038

4139
#define JERRY_INTERNAL
4240
#include "jerry-internal.h"

0 commit comments

Comments
 (0)