Enable 32bit compressed pointers on 64bit systems. (#1567)
JerryScript-DCO-1.0-Signed-off-by: László Langó llango.u-szeged@partner.samsung.com
This commit is contained in:
@@ -16,7 +16,7 @@
|
|||||||
/**
|
/**
|
||||||
* Allocator implementation
|
* Allocator implementation
|
||||||
*/
|
*/
|
||||||
|
#include "ecma-globals.h"
|
||||||
#include "jcontext.h"
|
#include "jcontext.h"
|
||||||
#include "jmem.h"
|
#include "jmem.h"
|
||||||
#include "jrt-libc-includes.h"
|
#include "jrt-libc-includes.h"
|
||||||
@@ -24,14 +24,6 @@
|
|||||||
#define JMEM_ALLOCATOR_INTERNAL
|
#define JMEM_ALLOCATOR_INTERNAL
|
||||||
#include "jmem-allocator-internal.h"
|
#include "jmem-allocator-internal.h"
|
||||||
|
|
||||||
#ifdef JERRY_CPOINTER_32_BIT
|
|
||||||
|
|
||||||
/* This check will go away when we will support 64 bit compressed pointers. */
|
|
||||||
JERRY_STATIC_ASSERT (sizeof (uintptr_t) <= sizeof (jmem_cpointer_t),
|
|
||||||
size_of_uintpt_t_must_be_equal_to_jmem_cpointer_t);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize memory allocators.
|
* Initialize memory allocators.
|
||||||
*/
|
*/
|
||||||
@@ -74,17 +66,21 @@ jmem_compress_pointer (const void *pointer_p) /**< pointer to compress */
|
|||||||
|
|
||||||
JERRY_ASSERT (uint_ptr % JMEM_ALIGNMENT == 0);
|
JERRY_ASSERT (uint_ptr % JMEM_ALIGNMENT == 0);
|
||||||
|
|
||||||
#ifdef JERRY_CPOINTER_32_BIT
|
#if defined (ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY) && defined (JERRY_CPOINTER_32_BIT)
|
||||||
JERRY_ASSERT (((jmem_cpointer_t) uint_ptr) == uint_ptr);
|
JERRY_ASSERT (((jmem_cpointer_t) uint_ptr) == uint_ptr);
|
||||||
#else /* !JERRY_CPOINTER_32_BIT */
|
#else /* !ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY || !JERRY_CPOINTER_32_BIT */
|
||||||
const uintptr_t heap_start = (uintptr_t) &JERRY_HEAP_CONTEXT (first);
|
const uintptr_t heap_start = (uintptr_t) &JERRY_HEAP_CONTEXT (first);
|
||||||
|
|
||||||
uint_ptr -= heap_start;
|
uint_ptr -= heap_start;
|
||||||
uint_ptr >>= JMEM_ALIGNMENT_LOG;
|
uint_ptr >>= JMEM_ALIGNMENT_LOG;
|
||||||
|
|
||||||
|
#ifdef JERRY_CPOINTER_32_BIT
|
||||||
|
JERRY_ASSERT (uint_ptr <= UINT32_MAX);
|
||||||
|
#else /* !JERRY_CPOINTER_32_BIT */
|
||||||
JERRY_ASSERT (uint_ptr <= UINT16_MAX);
|
JERRY_ASSERT (uint_ptr <= UINT16_MAX);
|
||||||
JERRY_ASSERT (uint_ptr != JMEM_CP_NULL);
|
|
||||||
#endif /* JERRY_CPOINTER_32_BIT */
|
#endif /* JERRY_CPOINTER_32_BIT */
|
||||||
|
JERRY_ASSERT (uint_ptr != JMEM_CP_NULL);
|
||||||
|
#endif /* ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY && JERRY_CPOINTER_32_BIT */
|
||||||
|
|
||||||
return (jmem_cpointer_t) uint_ptr;
|
return (jmem_cpointer_t) uint_ptr;
|
||||||
} /* jmem_compress_pointer */
|
} /* jmem_compress_pointer */
|
||||||
@@ -103,16 +99,16 @@ jmem_decompress_pointer (uintptr_t compressed_pointer) /**< pointer to decompres
|
|||||||
|
|
||||||
JERRY_ASSERT (((jmem_cpointer_t) uint_ptr) == uint_ptr);
|
JERRY_ASSERT (((jmem_cpointer_t) uint_ptr) == uint_ptr);
|
||||||
|
|
||||||
#ifdef JERRY_CPOINTER_32_BIT
|
#if defined (ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY) && defined (JERRY_CPOINTER_32_BIT)
|
||||||
JERRY_ASSERT (uint_ptr % JMEM_ALIGNMENT == 0);
|
JERRY_ASSERT (uint_ptr % JMEM_ALIGNMENT == 0);
|
||||||
#else /* !JERRY_CPOINTER_32_BIT */
|
#else /* !ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY || !JERRY_CPOINTER_32_BIT */
|
||||||
const uintptr_t heap_start = (uintptr_t) &JERRY_HEAP_CONTEXT (first);
|
const uintptr_t heap_start = (uintptr_t) &JERRY_HEAP_CONTEXT (first);
|
||||||
|
|
||||||
uint_ptr <<= JMEM_ALIGNMENT_LOG;
|
uint_ptr <<= JMEM_ALIGNMENT_LOG;
|
||||||
uint_ptr += heap_start;
|
uint_ptr += heap_start;
|
||||||
|
|
||||||
JERRY_ASSERT (jmem_is_heap_pointer ((void *) uint_ptr));
|
JERRY_ASSERT (jmem_is_heap_pointer ((void *) uint_ptr));
|
||||||
#endif /* JERRY_CPOINTER_32_BIT */
|
#endif /* ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY && JERRY_CPOINTER_32_BIT */
|
||||||
|
|
||||||
return (void *) uint_ptr;
|
return (void *) uint_ptr;
|
||||||
} /* jmem_decompress_pointer */
|
} /* jmem_decompress_pointer */
|
||||||
|
|||||||
@@ -83,14 +83,14 @@
|
|||||||
*/
|
*/
|
||||||
#define JMEM_HEAP_END_OF_LIST ((uint32_t) 0xffffffff)
|
#define JMEM_HEAP_END_OF_LIST ((uint32_t) 0xffffffff)
|
||||||
|
|
||||||
#if UINTPTR_MAX > UINT32_MAX
|
#ifdef ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY
|
||||||
#define JMEM_HEAP_GET_OFFSET_FROM_ADDR(p) ((uint32_t) ((uint8_t *) (p) - JERRY_HEAP_CONTEXT (area)))
|
|
||||||
#define JMEM_HEAP_GET_ADDR_FROM_OFFSET(u) ((jmem_heap_free_t *) (JERRY_HEAP_CONTEXT (area) + (u)))
|
|
||||||
#else /* UINTPTR_MAX <= UINT32_MAX */
|
|
||||||
/* In this case we simply store the pointer, since it fits anyway. */
|
/* In this case we simply store the pointer, since it fits anyway. */
|
||||||
#define JMEM_HEAP_GET_OFFSET_FROM_ADDR(p) ((uint32_t) (p))
|
#define JMEM_HEAP_GET_OFFSET_FROM_ADDR(p) ((uint32_t) (p))
|
||||||
#define JMEM_HEAP_GET_ADDR_FROM_OFFSET(u) ((jmem_heap_free_t *) (u))
|
#define JMEM_HEAP_GET_ADDR_FROM_OFFSET(u) ((jmem_heap_free_t *) (u))
|
||||||
#endif /* UINTPTR_MAX > UINT32_MAX */
|
#else /* !ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY */
|
||||||
|
#define JMEM_HEAP_GET_OFFSET_FROM_ADDR(p) ((uint32_t) ((uint8_t *) (p) - JERRY_HEAP_CONTEXT (area)))
|
||||||
|
#define JMEM_HEAP_GET_ADDR_FROM_OFFSET(u) ((jmem_heap_free_t *) (JERRY_HEAP_CONTEXT (area) + (u)))
|
||||||
|
#endif /* ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY */
|
||||||
|
|
||||||
#ifndef JERRY_SYSTEM_ALLOCATOR
|
#ifndef JERRY_SYSTEM_ALLOCATOR
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ var array = [];
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
for (var i = 0; i < 15; i++)
|
for (var i = 0; i < 30; i++)
|
||||||
{
|
{
|
||||||
array[i] = eval(str);
|
array[i] = eval(str);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -75,6 +75,7 @@ jerry_unittests_options = [
|
|||||||
jerry_tests_options = [
|
jerry_tests_options = [
|
||||||
Options('jerry_tests'),
|
Options('jerry_tests'),
|
||||||
Options('jerry_tests-debug', ['--debug']),
|
Options('jerry_tests-debug', ['--debug']),
|
||||||
|
Options('jerry_tests-debug', ['--debug', '--cpointer-32bit=on', '--mem-heap=1024']),
|
||||||
Options('jerry_tests-snapshot', ['--snapshot-save=on', '--snapshot-exec=on'], ['--snapshot']),
|
Options('jerry_tests-snapshot', ['--snapshot-save=on', '--snapshot-exec=on'], ['--snapshot']),
|
||||||
Options('jerry_tests-debug-snapshot', ['--debug', '--snapshot-save=on', '--snapshot-exec=on'], ['--snapshot']),
|
Options('jerry_tests-debug-snapshot', ['--debug', '--snapshot-save=on', '--snapshot-exec=on'], ['--snapshot']),
|
||||||
]
|
]
|
||||||
|
|||||||
Reference in New Issue
Block a user