Browse Source

Merge branch 'fix-ptr-compression-64bit'

user-stack-check-macro
Sami Vaarala 9 years ago
parent
commit
8e9117160b
  1. 2
      RELEASES.rst
  2. 9
      src/duk_hbuffer_alloc.c
  3. 4
      src/duk_heap_alloc.c
  4. 6
      src/duk_hobject_alloc.c

2
RELEASES.rst

@ -995,6 +995,8 @@ Planned
* Fix compile error from array fast path when using low memory options * Fix compile error from array fast path when using low memory options
(GH-174) (GH-174)
* Fix a few pointer compression issues (DUK_USE_HEAPPTR16) on 64-bit platforms
* Fix harmless MSVC warnings when using DUK_OPT_FASTINT on x86 (GH-172) * Fix harmless MSVC warnings when using DUK_OPT_FASTINT on x86 (GH-172)
* Fix harmless MSVC warnings for size_t casts on x64 (GH-177) * Fix harmless MSVC warnings for size_t casts on x64 (GH-177)

9
src/duk_hbuffer_alloc.c

@ -63,9 +63,14 @@ DUK_INTERNAL duk_hbuffer *duk_hbuffer_alloc(duk_heap *heap, duk_size_t size, duk
DUK_HBUFFER_DYNAMIC_SET_DATA_PTR(heap, h, ptr); DUK_HBUFFER_DYNAMIC_SET_DATA_PTR(heap, h, ptr);
DUK_HBUFFER_DYNAMIC_SET_ALLOC_SIZE(h, size); /* snug */ DUK_HBUFFER_DYNAMIC_SET_ALLOC_SIZE(h, size); /* snug */
} else { } else {
#ifdef DUK_USE_EXPLICIT_NULL_INIT #if defined(DUK_USE_EXPLICIT_NULL_INIT)
h->curr_alloc = NULL; #if defined(DUK_USE_HEAPPTR16)
/* the compressed pointer is zeroed which maps to NULL, so nothing to do. */
#else
DUK_HBUFFER_DYNAMIC_SET_DATA_PTR(heap, h, NULL);
#endif
#endif #endif
DUK_ASSERT(DUK_HBUFFER_DYNAMIC_GET_DATA_PTR(heap, h) == NULL);
DUK_ASSERT(DUK_HBUFFER_DYNAMIC_GET_ALLOC_SIZE(h) == 0); DUK_ASSERT(DUK_HBUFFER_DYNAMIC_GET_ALLOC_SIZE(h) == 0);
} }
} }

4
src/duk_heap_alloc.c

@ -720,12 +720,16 @@ duk_heap *duk_heap_alloc(duk_alloc_function alloc_func,
res->strtable = (duk_hstring **) NULL; res->strtable = (duk_hstring **) NULL;
#endif #endif
#endif #endif
#if defined(DUK_USE_HEAPPTR16)
/* res->strs16[] is zeroed and zero decodes to NULL, so no NULL inits. */
#else
{ {
duk_small_uint_t i; duk_small_uint_t i;
for (i = 0; i < DUK_HEAP_NUM_STRINGS; i++) { for (i = 0; i < DUK_HEAP_NUM_STRINGS; i++) {
res->strs[i] = NULL; res->strs[i] = NULL;
} }
} }
#endif
#if defined(DUK_USE_DEBUGGER_SUPPORT) #if defined(DUK_USE_DEBUGGER_SUPPORT)
res->dbg_read_cb = NULL; res->dbg_read_cb = NULL;
res->dbg_write_cb = NULL; res->dbg_write_cb = NULL;

6
src/duk_hobject_alloc.c

@ -78,7 +78,7 @@ DUK_INTERNAL duk_hcompiledfunction *duk_hcompiledfunction_alloc(duk_heap *heap,
duk__init_object_parts(heap, &res->obj, hobject_flags); duk__init_object_parts(heap, &res->obj, hobject_flags);
#ifdef DUK_USE_EXPLICIT_NULL_INIT #ifdef DUK_USE_EXPLICIT_NULL_INIT
#ifdef DUK_HEAPPTR16 #ifdef DUK_USE_HEAPPTR16
/* NULL pointer is required to encode to zero, so memset is enough. */ /* NULL pointer is required to encode to zero, so memset is enough. */
#else #else
res->data = NULL; res->data = NULL;
@ -156,7 +156,11 @@ DUK_INTERNAL duk_hthread *duk_hthread_alloc(duk_heap *heap, duk_uint_t hobject_f
res->catchstack = NULL; res->catchstack = NULL;
res->resumer = NULL; res->resumer = NULL;
res->compile_ctx = NULL, res->compile_ctx = NULL,
#ifdef DUK_USE_HEAPPTR16
res->strs16 = NULL;
#else
res->strs = NULL; res->strs = NULL;
#endif
{ {
int i; int i;
for (i = 0; i < DUK_NUM_BUILTINS; i++) { for (i = 0; i < DUK_NUM_BUILTINS; i++) {

Loading…
Cancel
Save