Skip to content

Commit 6290b2d

Browse files
committed
Remove MEM_HEAP_PTR_64 macro
MEM_HEAP_PTR_64 is duplicating existing information: stdint.h, which header is already used by the project, defines various _MAX macros for upper limits of integer types. The comparison of UINTPTR_MAX and UINT32_MAX can give the same info as encoded in MEM_HEAP_PTR_64. The stdint.h-based approach has the benefit that jerry can support any 64-bit architecture without the need for editing the build system. (With the existing approach, CMakeLists has to know about every 64-bit architecture to work properly.) Thus, removing the extraneous macro from the code. The patch also changes the mem_pools_chunk_t struct, as it turned out that the struct does not have to be padded to MEM_POOL_CHUNK_SIZE. (The padding also depended on MEM_HEAP_PTR_64.) It is enough if the size of the struct is smaller than (or equal to) MEM_POOL_CHUNK_SIZE. JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
1 parent 2027cae commit 6290b2d

File tree

3 files changed

+3
-9
lines changed

3 files changed

+3
-9
lines changed

CMakeLists.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -223,9 +223,6 @@ project (Jerry C ASM)
223223

224224
# Compiler / Linker flags
225225
set(COMPILE_FLAGS_JERRY "-fno-builtin")
226-
if(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64")
227-
set(COMPILE_FLAGS_JERRY "${COMPILE_FLAGS_JERRY} -DMEM_HEAP_PTR_64")
228-
endif()
229226
if(NOT ("${PLATFORM}" STREQUAL "DARWIN"))
230227
set(LINKER_FLAGS_COMMON "-Wl,-z,noexecstack")
231228
endif()

jerry-core/mem/mem-heap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ typedef struct
103103
uint32_t size; /* Size of region */
104104
} mem_heap_free_t;
105105

106-
#ifdef MEM_HEAP_PTR_64
106+
#if UINTPTR_MAX > UINT32_MAX
107107
#define MEM_HEAP_GET_OFFSET_FROM_ADDR(p) ((uint32_t) ((uint8_t *) (p) - (uint8_t *) mem_heap.area))
108108
#define MEM_HEAP_GET_ADDR_FROM_OFFSET(u) ((mem_heap_free_t *) &mem_heap.area[u])
109109
#else

jerry-core/mem/mem-poolman.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,6 @@
4040
typedef struct mem_pools_chunk
4141
{
4242
struct mem_pools_chunk *next_p; /* pointer to next pool chunk */
43-
#ifndef MEM_HEAP_PTR_64
44-
uint32_t dummy; /* dummy member for alignment */
45-
#endif
4643
} mem_pools_chunk_t;
4744

4845
/**
@@ -107,8 +104,8 @@ static void mem_pools_stat_dealloc (void);
107104
void
108105
mem_pools_init (void)
109106
{
110-
JERRY_STATIC_ASSERT (sizeof (mem_pools_chunk_t) == MEM_POOL_CHUNK_SIZE,
111-
size_of_mem_pool_chunk_t_must_be_equal_to_MEM_POOL_CHUNK_SIZE);
107+
JERRY_STATIC_ASSERT (sizeof (mem_pools_chunk_t) <= MEM_POOL_CHUNK_SIZE,
108+
size_of_mem_pools_chunk_t_must_be_less_than_or_equal_to_MEM_POOL_CHUNK_SIZE);
112109

113110
mem_free_chunk_p = NULL;
114111

0 commit comments

Comments
 (0)