Skip to content

Commit 572402e

Browse files
committed
Akos idea.
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
1 parent 5e836ad commit 572402e

File tree

3 files changed

+21
-20
lines changed

3 files changed

+21
-20
lines changed

jerry-core/context/context.c

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,6 @@
2828
*/
2929
jerry_context_t jerry_global_context;
3030

31-
/**
32-
* Jerry global heap section attribute.
33-
*/
34-
#ifndef JERRY_HEAP_SECTION_ATTR
35-
#define JERRY_GLOBAL_HEAP_SECTION
36-
#else /* JERRY_HEAP_SECTION_ATTR */
37-
#define JERRY_GLOBAL_HEAP_SECTION __attribute__ ((section (JERRY_HEAP_SECTION_ATTR)))
38-
#endif /* !JERRY_HEAP_SECTION_ATTR */
39-
40-
/**
41-
* Global heap.
42-
*/
43-
mem_heap_t jerry_global_heap __attribute__ ((aligned (MEM_ALIGNMENT))) JERRY_GLOBAL_HEAP_SECTION;
44-
4531
/**
4632
* @}
4733
* @}

jerry-core/context/context.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,18 +72,15 @@ typedef struct
7272
bool valgrind_freya_mempool_request; /**< Tells whether a pool manager
7373
* allocator request is in progress */
7474
#endif /* JERRY_VALGRIND_FREYA */
75+
76+
mem_heap_t *heap_p;
7577
} jerry_context_t;
7678

7779
/**
7880
* Jerry global context.
7981
*/
8082
extern jerry_context_t jerry_global_context;
8183

82-
/**
83-
* Jerry global heap.
84-
*/
85-
extern mem_heap_t jerry_global_heap;
86-
8784
/**
8885
* Provides a reference to a field in the current context.
8986
*/
@@ -92,7 +89,7 @@ extern mem_heap_t jerry_global_heap;
9289
/**
9390
* Provides a reference to the area field of the heap.
9491
*/
95-
#define MEM_HEAP_CONTEXT(field) (jerry_global_heap.field)
92+
#define MEM_HEAP_CONTEXT(field) (jerry_global_context.heap_p->field)
9693

9794
/**
9895
* @}

jerry-core/mem/mem-heap.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,20 @@ static void mem_heap_stat_free_iter ();
140140
# define MEM_HEAP_STAT_FREE_ITER()
141141
#endif /* MEM_STATS */
142142

143+
/**
144+
* Jerry global heap section attribute.
145+
*/
146+
#ifndef JERRY_HEAP_SECTION_ATTR
147+
#define JERRY_GLOBAL_HEAP_SECTION
148+
#else /* JERRY_HEAP_SECTION_ATTR */
149+
#define JERRY_GLOBAL_HEAP_SECTION __attribute__ ((section (JERRY_HEAP_SECTION_ATTR)))
150+
#endif /* !JERRY_HEAP_SECTION_ATTR */
151+
152+
/**
153+
* Global heap.
154+
*/
155+
mem_heap_t jerry_global_heap __attribute__ ((aligned (MEM_ALIGNMENT))) JERRY_GLOBAL_HEAP_SECTION;
156+
143157
/**
144158
* Startup initialization of heap
145159
*/
@@ -155,6 +169,8 @@ mem_heap_init (void)
155169
JERRY_CONTEXT (mem_heap_limit) = CONFIG_MEM_HEAP_DESIRED_LIMIT;
156170
JERRY_CONTEXT (mem_try_give_memory_back_callback) = NULL;
157171

172+
JERRY_CONTEXT (heap_p) = &jerry_global_heap;
173+
158174
MEM_HEAP_CONTEXT (first).size = 0;
159175
mem_heap_free_t *const region_p = (mem_heap_free_t *) MEM_HEAP_CONTEXT (area);
160176
MEM_HEAP_CONTEXT (first).next_offset = MEM_HEAP_GET_OFFSET_FROM_ADDR (region_p);
@@ -179,6 +195,8 @@ void mem_heap_finalize (void)
179195
{
180196
JERRY_ASSERT (JERRY_CONTEXT (mem_heap_allocated_size) == 0);
181197
VALGRIND_NOACCESS_SPACE (&MEM_HEAP_CONTEXT (first), sizeof (mem_heap_t));
198+
199+
JERRY_CONTEXT (heap_p) = NULL;
182200
} /* mem_heap_finalize */
183201

184202
/**

0 commit comments

Comments
 (0)