[Pcre-svn] [1507] code/trunk: Support custom memory allocato…

トップ ページ
このメッセージを削除
著者: Subversion repository
日付:  
To: pcre-svn
題目: [Pcre-svn] [1507] code/trunk: Support custom memory allocators in the JIT compiler.
Revision: 1507
          http://vcs.pcre.org/viewvc?view=rev&revision=1507
Author:   zherczeg
Date:     2014-09-30 07:35:20 +0100 (Tue, 30 Sep 2014)


Log Message:
-----------
Support custom memory allocators in the JIT compiler.

Modified Paths:
--------------
    code/trunk/pcre_jit_compile.c
    code/trunk/sljit/sljitConfigInternal.h
    code/trunk/sljit/sljitLir.c
    code/trunk/sljit/sljitLir.h
    code/trunk/sljit/sljitNativeARM_32.c
    code/trunk/sljit/sljitNativeX86_common.c
    code/trunk/sljit/sljitUtils.c


Modified: code/trunk/pcre_jit_compile.c
===================================================================
--- code/trunk/pcre_jit_compile.c    2014-09-27 06:25:26 UTC (rev 1506)
+++ code/trunk/pcre_jit_compile.c    2014-09-30 06:35:20 UTC (rev 1507)
@@ -52,8 +52,8 @@
 we just include it. This way we don't need to touch the build
 system files. */


-#define SLJIT_MALLOC(size) (PUBL(malloc))(size)
-#define SLJIT_FREE(ptr) (PUBL(free))(ptr)
+#define SLJIT_MALLOC(size, allocator_data) (PUBL(malloc))(size)
+#define SLJIT_FREE(ptr, allocator_data) (PUBL(free))(ptr)
 #define SLJIT_CONFIG_AUTO 1
 #define SLJIT_CONFIG_STATIC 1
 #define SLJIT_VERBOSE 0
@@ -3584,10 +3584,10 @@
   /* Since no data is consumed (see the assert in the beginning
   of this function), this space can be reallocated. */
   if (common->read_only_data)
-    SLJIT_FREE(common->read_only_data);
+    SLJIT_FREE(common->read_only_data, compiler->allocator_data);


   common->read_only_data_size += 256;
-  common->read_only_data = (sljit_uw *)SLJIT_MALLOC(common->read_only_data_size);
+  common->read_only_data = (sljit_uw *)SLJIT_MALLOC(common->read_only_data_size, compiler->allocator_data);
   if (common->read_only_data == NULL)
     return TRUE;


@@ -9849,7 +9849,7 @@

/* Calculate the local space size on the stack. */
common->ovector_start = LIMIT_MATCH + sizeof(sljit_sw);
-common->optimized_cbracket = (pcre_uint8 *)SLJIT_MALLOC(re->top_bracket + 1);
+common->optimized_cbracket = (pcre_uint8 *)SLJIT_MALLOC(re->top_bracket + 1, compiler->allocator_data);
if (!common->optimized_cbracket)
return;
#if defined DEBUG_FORCE_UNOPTIMIZED_CBRAS && DEBUG_FORCE_UNOPTIMIZED_CBRAS == 1
@@ -9865,7 +9865,7 @@
#endif
if (!check_opcode_types(common, common->start, ccend))
{
- SLJIT_FREE(common->optimized_cbracket);
+ SLJIT_FREE(common->optimized_cbracket, compiler->allocator_data);
return;
}

@@ -9927,10 +9927,10 @@
common->cbra_ptr = OVECTOR_START + (re->top_bracket + 1) * 2 * sizeof(sljit_sw);

total_length = ccend - common->start;
-common->private_data_ptrs = (sljit_si *)SLJIT_MALLOC(total_length * (sizeof(sljit_si) + (common->has_then ? 1 : 0)));
+common->private_data_ptrs = (sljit_si *)SLJIT_MALLOC(total_length * (sizeof(sljit_si) + (common->has_then ? 1 : 0)), compiler->allocator_data);
if (!common->private_data_ptrs)
{
- SLJIT_FREE(common->optimized_cbracket);
+ SLJIT_FREE(common->optimized_cbracket, compiler->allocator_data);
return;
}
memset(common->private_data_ptrs, 0, total_length * sizeof(sljit_si));
@@ -9939,8 +9939,8 @@
set_private_data_ptrs(common, &private_data_size, ccend);
if (private_data_size > SLJIT_MAX_LOCAL_SIZE)
{
- SLJIT_FREE(common->private_data_ptrs);
- SLJIT_FREE(common->optimized_cbracket);
+ SLJIT_FREE(common->private_data_ptrs, compiler->allocator_data);
+ SLJIT_FREE(common->optimized_cbracket, compiler->allocator_data);
return;
}

@@ -9953,23 +9953,23 @@

 if (common->read_only_data_size > 0)
   {
-  common->read_only_data = (sljit_uw *)SLJIT_MALLOC(common->read_only_data_size);
+  common->read_only_data = (sljit_uw *)SLJIT_MALLOC(common->read_only_data_size, compiler->allocator_data);
   if (common->read_only_data == NULL)
     {
-    SLJIT_FREE(common->optimized_cbracket);
-    SLJIT_FREE(common->private_data_ptrs);
+    SLJIT_FREE(common->optimized_cbracket, compiler->allocator_data);
+    SLJIT_FREE(common->private_data_ptrs, compiler->allocator_data);
     return;
     }
   common->read_only_data_ptr = common->read_only_data;
   }


-compiler = sljit_create_compiler();
+compiler = sljit_create_compiler(NULL);
 if (!compiler)
   {
-  SLJIT_FREE(common->optimized_cbracket);
-  SLJIT_FREE(common->private_data_ptrs);
+  SLJIT_FREE(common->optimized_cbracket, compiler->allocator_data);
+  SLJIT_FREE(common->private_data_ptrs, compiler->allocator_data);
   if (common->read_only_data)
-    SLJIT_FREE(common->read_only_data);
+    SLJIT_FREE(common->read_only_data, compiler->allocator_data);
   return;
   }
 common->compiler = compiler;
@@ -10013,8 +10013,8 @@
       if (common->read_only_data_size > 0 && common->read_only_data == NULL)
         {
         sljit_free_compiler(compiler);
-        SLJIT_FREE(common->optimized_cbracket);
-        SLJIT_FREE(common->private_data_ptrs);
+        SLJIT_FREE(common->optimized_cbracket, compiler->allocator_data);
+        SLJIT_FREE(common->private_data_ptrs, compiler->allocator_data);
         return;
         }
       }
@@ -10068,10 +10068,10 @@
 if (SLJIT_UNLIKELY(sljit_get_compiler_error(compiler)))
   {
   sljit_free_compiler(compiler);
-  SLJIT_FREE(common->optimized_cbracket);
-  SLJIT_FREE(common->private_data_ptrs);
+  SLJIT_FREE(common->optimized_cbracket, compiler->allocator_data);
+  SLJIT_FREE(common->private_data_ptrs, compiler->allocator_data);
   if (common->read_only_data)
-    SLJIT_FREE(common->read_only_data);
+    SLJIT_FREE(common->read_only_data, compiler->allocator_data);
   return;
   }


@@ -10109,10 +10109,10 @@
 if (SLJIT_UNLIKELY(sljit_get_compiler_error(compiler)))
   {
   sljit_free_compiler(compiler);
-  SLJIT_FREE(common->optimized_cbracket);
-  SLJIT_FREE(common->private_data_ptrs);
+  SLJIT_FREE(common->optimized_cbracket, compiler->allocator_data);
+  SLJIT_FREE(common->private_data_ptrs, compiler->allocator_data);
   if (common->read_only_data)
-    SLJIT_FREE(common->read_only_data);
+    SLJIT_FREE(common->read_only_data, compiler->allocator_data);
   return;
   }


@@ -10190,10 +10190,10 @@
   if (SLJIT_UNLIKELY(sljit_get_compiler_error(compiler)))
     {
     sljit_free_compiler(compiler);
-    SLJIT_FREE(common->optimized_cbracket);
-    SLJIT_FREE(common->private_data_ptrs);
+    SLJIT_FREE(common->optimized_cbracket, compiler->allocator_data);
+    SLJIT_FREE(common->private_data_ptrs, compiler->allocator_data);
     if (common->read_only_data)
-      SLJIT_FREE(common->read_only_data);
+      SLJIT_FREE(common->read_only_data, compiler->allocator_data);
     return;
     }
   flush_stubs(common);
@@ -10304,8 +10304,8 @@
 #endif


SLJIT_ASSERT(common->read_only_data + (common->read_only_data_size >> SLJIT_WORD_SHIFT) == common->read_only_data_ptr);
-SLJIT_FREE(common->optimized_cbracket);
-SLJIT_FREE(common->private_data_ptrs);
+SLJIT_FREE(common->optimized_cbracket, compiler->allocator_data);
+SLJIT_FREE(common->private_data_ptrs, compiler->allocator_data);

 executable_func = sljit_generate_code(compiler);
 executable_size = sljit_get_generated_code_size(compiler);
@@ -10319,7 +10319,7 @@
 if (executable_func == NULL)
   {
   if (common->read_only_data)
-    SLJIT_FREE(common->read_only_data);
+    SLJIT_FREE(common->read_only_data, compiler->allocator_data);
   return;
   }


@@ -10337,14 +10337,14 @@
    * bit remains set, as the bit indicates that the pointer to the data
    * is valid.)
    */
-  functions = SLJIT_MALLOC(sizeof(executable_functions));
+  functions = SLJIT_MALLOC(sizeof(executable_functions), compiler->allocator_data);
   if (functions == NULL)
     {
     /* This case is highly unlikely since we just recently
     freed a lot of memory. Not impossible though. */
     sljit_free_code(executable_func);
     if (common->read_only_data)
-      SLJIT_FREE(common->read_only_data);
+      SLJIT_FREE(common->read_only_data, compiler->allocator_data);
     return;
     }
   memset(functions, 0, sizeof(executable_functions));
@@ -10543,9 +10543,9 @@
   if (functions->executable_funcs[i] != NULL)
     sljit_free_code(functions->executable_funcs[i]);
   if (functions->read_only_data[i] != NULL)
-    SLJIT_FREE(functions->read_only_data[i]);
+    SLJIT_FREE(functions->read_only_data[i], compiler->allocator_data);
   }
-SLJIT_FREE(functions);
+SLJIT_FREE(functions, compiler->allocator_data);
 }


int
@@ -10582,7 +10582,7 @@
startsize = maxsize;
startsize = (startsize + STACK_GROWTH_RATE - 1) & ~(STACK_GROWTH_RATE - 1);
maxsize = (maxsize + STACK_GROWTH_RATE - 1) & ~(STACK_GROWTH_RATE - 1);
-return (PUBL(jit_stack)*)sljit_allocate_stack(startsize, maxsize);
+return (PUBL(jit_stack)*)sljit_allocate_stack(startsize, maxsize, NULL);
}

#if defined COMPILE_PCRE8
@@ -10596,7 +10596,7 @@
pcre32_jit_stack_free(pcre32_jit_stack *stack)
#endif
{
-sljit_free_stack((struct sljit_stack *)stack);
+sljit_free_stack((struct sljit_stack *)stack, NULL);
}

#if defined COMPILE_PCRE8

Modified: code/trunk/sljit/sljitConfigInternal.h
===================================================================
--- code/trunk/sljit/sljitConfigInternal.h    2014-09-27 06:25:26 UTC (rev 1506)
+++ code/trunk/sljit/sljitConfigInternal.h    2014-09-30 06:35:20 UTC (rev 1507)
@@ -203,11 +203,11 @@
 */


#ifndef SLJIT_MALLOC
-#define SLJIT_MALLOC(size) malloc(size)
+#define SLJIT_MALLOC(size, allocator_data) malloc(size)
#endif

#ifndef SLJIT_FREE
-#define SLJIT_FREE(ptr) free(ptr)
+#define SLJIT_FREE(ptr, allocator_data) free(ptr)
#endif

#ifndef SLJIT_MEMMOVE

Modified: code/trunk/sljit/sljitLir.c
===================================================================
--- code/trunk/sljit/sljitLir.c    2014-09-27 06:25:26 UTC (rev 1506)
+++ code/trunk/sljit/sljitLir.c    2014-09-30 06:35:20 UTC (rev 1507)
@@ -325,9 +325,9 @@
 static void init_compiler(void);
 #endif


-SLJIT_API_FUNC_ATTRIBUTE struct sljit_compiler* sljit_create_compiler(void)
+SLJIT_API_FUNC_ATTRIBUTE struct sljit_compiler* sljit_create_compiler(void *allocator_data)
 {
-    struct sljit_compiler *compiler = (struct sljit_compiler*)SLJIT_MALLOC(sizeof(struct sljit_compiler));
+    struct sljit_compiler *compiler = (struct sljit_compiler*)SLJIT_MALLOC(sizeof(struct sljit_compiler), allocator_data);
     if (!compiler)
         return NULL;
     SLJIT_ZEROMEM(compiler, sizeof(struct sljit_compiler));
@@ -349,15 +349,16 @@
     /* Only the non-zero members must be set. */
     compiler->error = SLJIT_SUCCESS;


-    compiler->buf = (struct sljit_memory_fragment*)SLJIT_MALLOC(BUF_SIZE);
-    compiler->abuf = (struct sljit_memory_fragment*)SLJIT_MALLOC(ABUF_SIZE);
+    compiler->allocator_data = allocator_data;
+    compiler->buf = (struct sljit_memory_fragment*)SLJIT_MALLOC(BUF_SIZE, allocator_data);
+    compiler->abuf = (struct sljit_memory_fragment*)SLJIT_MALLOC(ABUF_SIZE, allocator_data);


     if (!compiler->buf || !compiler->abuf) {
         if (compiler->buf)
-            SLJIT_FREE(compiler->buf);
+            SLJIT_FREE(compiler->buf, allocator_data);
         if (compiler->abuf)
-            SLJIT_FREE(compiler->abuf);
-        SLJIT_FREE(compiler);
+            SLJIT_FREE(compiler->abuf, allocator_data);
+        SLJIT_FREE(compiler, allocator_data);
         return NULL;
     }


@@ -377,11 +378,12 @@
#endif

 #if (defined SLJIT_CONFIG_ARM_V5 && SLJIT_CONFIG_ARM_V5)
-    compiler->cpool = (sljit_uw*)SLJIT_MALLOC(CPOOL_SIZE * sizeof(sljit_uw) + CPOOL_SIZE * sizeof(sljit_ub));
+    compiler->cpool = (sljit_uw*)SLJIT_MALLOC(CPOOL_SIZE * sizeof(sljit_uw)
+        + CPOOL_SIZE * sizeof(sljit_ub), allocator_data);
     if (!compiler->cpool) {
-        SLJIT_FREE(compiler->buf);
-        SLJIT_FREE(compiler->abuf);
-        SLJIT_FREE(compiler);
+        SLJIT_FREE(compiler->buf, allocator_data);
+        SLJIT_FREE(compiler->abuf, allocator_data);
+        SLJIT_FREE(compiler, allocator_data);
         return NULL;
     }
     compiler->cpool_unique = (sljit_ub*)(compiler->cpool + CPOOL_SIZE);
@@ -410,25 +412,27 @@
 {
     struct sljit_memory_fragment *buf;
     struct sljit_memory_fragment *curr;
+    void *allocator_data = compiler->allocator_data;
+    SLJIT_UNUSED_ARG(allocator_data);


     buf = compiler->buf;
     while (buf) {
         curr = buf;
         buf = buf->next;
-        SLJIT_FREE(curr);
+        SLJIT_FREE(curr, allocator_data);
     }


     buf = compiler->abuf;
     while (buf) {
         curr = buf;
         buf = buf->next;
-        SLJIT_FREE(curr);
+        SLJIT_FREE(curr, allocator_data);
     }


 #if (defined SLJIT_CONFIG_ARM_V5 && SLJIT_CONFIG_ARM_V5)
-    SLJIT_FREE(compiler->cpool);
+    SLJIT_FREE(compiler->cpool, allocator_data);
 #endif
-    SLJIT_FREE(compiler);
+    SLJIT_FREE(compiler, allocator_data);
 }


 #if (defined SLJIT_CONFIG_ARM_THUMB2 && SLJIT_CONFIG_ARM_THUMB2)
@@ -484,7 +488,7 @@
         compiler->buf->used_size += size;
         return ret;
     }
-    new_frag = (struct sljit_memory_fragment*)SLJIT_MALLOC(BUF_SIZE);
+    new_frag = (struct sljit_memory_fragment*)SLJIT_MALLOC(BUF_SIZE, compiler->allocator_data);
     PTR_FAIL_IF_NULL(new_frag);
     new_frag->next = compiler->buf;
     compiler->buf = new_frag;
@@ -503,7 +507,7 @@
         compiler->abuf->used_size += size;
         return ret;
     }
-    new_frag = (struct sljit_memory_fragment*)SLJIT_MALLOC(ABUF_SIZE);
+    new_frag = (struct sljit_memory_fragment*)SLJIT_MALLOC(ABUF_SIZE, compiler->allocator_data);
     PTR_FAIL_IF_NULL(new_frag);
     new_frag->next = compiler->abuf;
     compiler->abuf = new_frag;
@@ -547,6 +551,7 @@
     sljit_si options, sljit_si args, sljit_si scratches, sljit_si saveds,
     sljit_si fscratches, sljit_si fsaveds, sljit_si local_size)
 {
+    SLJIT_UNUSED_ARG(args);
     SLJIT_UNUSED_ARG(local_size);


     compiler->options = options;
@@ -563,6 +568,7 @@
     sljit_si options, sljit_si args, sljit_si scratches, sljit_si saveds,
     sljit_si fscratches, sljit_si fsaveds, sljit_si local_size)
 {
+    SLJIT_UNUSED_ARG(args);
     SLJIT_UNUSED_ARG(local_size);


     compiler->options = options;


Modified: code/trunk/sljit/sljitLir.h
===================================================================
--- code/trunk/sljit/sljitLir.h    2014-09-27 06:25:26 UTC (rev 1506)
+++ code/trunk/sljit/sljitLir.h    2014-09-30 06:35:20 UTC (rev 1507)
@@ -307,6 +307,7 @@
     struct sljit_jump *last_jump;
     struct sljit_const *last_const;


+    void *allocator_data;
     struct sljit_memory_fragment *buf;
     struct sljit_memory_fragment *abuf;


@@ -409,11 +410,16 @@
 /*  Main functions                                                       */
 /* --------------------------------------------------------------------- */


-/* Creates an sljit compiler.
+/* Creates an sljit compiler. The allocator_data is required by some
+   custom memory managers. This pointer is passed to SLJIT_MALLOC
+   and SLJIT_FREE macros. Most allocators (including the default
+   one) ignores this value, and it is recommended to pass NULL
+   as a dummy value for allocator_data.
+
    Returns NULL if failed. */
-SLJIT_API_FUNC_ATTRIBUTE struct sljit_compiler* sljit_create_compiler(void);
+SLJIT_API_FUNC_ATTRIBUTE struct sljit_compiler* sljit_create_compiler(void *allocator_data);


-/* Free everything except the compiled machine code. */
+/* Frees everything except the compiled machine code. */
SLJIT_API_FUNC_ATTRIBUTE void sljit_free_compiler(struct sljit_compiler *compiler);

/* Returns the current error code. If an error is occurred, future sljit
@@ -1095,7 +1101,7 @@
/* --------------------------------------------------------------------- */

 #define SLJIT_MAJOR_VERSION    0
-#define SLJIT_MINOR_VERSION    92
+#define SLJIT_MINOR_VERSION    93


 /* Get the human readable name of the platform. Can be useful on platforms
    like ARM, where ARM and Thumb2 functions can be mixed, and
@@ -1141,10 +1147,11 @@
 };


/* Returns NULL if unsuccessful.
- Note: limit and max_limit contains the size for stack allocation
- Note: the top field is initialized to base. */
-SLJIT_API_FUNC_ATTRIBUTE struct sljit_stack* SLJIT_CALL sljit_allocate_stack(sljit_uw limit, sljit_uw max_limit);
-SLJIT_API_FUNC_ATTRIBUTE void SLJIT_CALL sljit_free_stack(struct sljit_stack* stack);
+ Note: limit and max_limit contains the size for stack allocation.
+ Note: the top field is initialized to base.
+ Note: see sljit_create_compiler for the explanation of allocator_data. */
+SLJIT_API_FUNC_ATTRIBUTE struct sljit_stack* SLJIT_CALL sljit_allocate_stack(sljit_uw limit, sljit_uw max_limit, void *allocator_data);
+SLJIT_API_FUNC_ATTRIBUTE void SLJIT_CALL sljit_free_stack(struct sljit_stack *stack, void *allocator_data);

 /* Can be used to increase (allocate) or decrease (free) the memory area.
    Returns with a non-zero value if unsuccessful. If new_limit is greater than
@@ -1152,7 +1159,7 @@
    since the growth ratio can be added to the current limit, and sljit_stack_resize
    will do all the necessary checks. The fields of the stack are not changed if
    sljit_stack_resize fails. */
-SLJIT_API_FUNC_ATTRIBUTE sljit_sw SLJIT_CALL sljit_stack_resize(struct sljit_stack* stack, sljit_uw new_limit);
+SLJIT_API_FUNC_ATTRIBUTE sljit_sw SLJIT_CALL sljit_stack_resize(struct sljit_stack *stack, sljit_uw new_limit);


#endif /* (defined SLJIT_UTIL_STACK && SLJIT_UTIL_STACK) */


Modified: code/trunk/sljit/sljitNativeARM_32.c
===================================================================
--- code/trunk/sljit/sljitNativeARM_32.c    2014-09-27 06:25:26 UTC (rev 1506)
+++ code/trunk/sljit/sljitNativeARM_32.c    2014-09-30 06:35:20 UTC (rev 1507)
@@ -337,7 +337,7 @@
                     prev_patch->next = curr_patch->next;
                 else
                     *first_patch = curr_patch->next;
-                SLJIT_FREE(curr_patch);
+                SLJIT_FREE(curr_patch, compiler->allocator_data);
                 break;
             }
             prev_patch = curr_patch;
@@ -347,12 +347,12 @@


     if (value >= 0) {
         if ((sljit_uw)value > cpool_current_index) {
-            curr_patch = (struct future_patch*)SLJIT_MALLOC(sizeof(struct future_patch));
+            curr_patch = (struct future_patch*)SLJIT_MALLOC(sizeof(struct future_patch), compiler->allocator_data);
             if (!curr_patch) {
                 while (*first_patch) {
                     curr_patch = *first_patch;
                     *first_patch = (*first_patch)->next;
-                    SLJIT_FREE(curr_patch);
+                    SLJIT_FREE(curr_patch, compiler->allocator_data);
                 }
                 return SLJIT_ERR_ALLOC_FAILED;
             }


Modified: code/trunk/sljit/sljitNativeX86_common.c
===================================================================
--- code/trunk/sljit/sljitNativeX86_common.c    2014-09-27 06:25:26 UTC (rev 1506)
+++ code/trunk/sljit/sljitNativeX86_common.c    2014-09-30 06:35:20 UTC (rev 1507)
@@ -2661,6 +2661,7 @@


     CHECK_ERROR();
     CHECK(check_sljit_emit_op_flags(compiler, op, dst, dstw, src, srcw, type));
+    SLJIT_UNUSED_ARG(srcw);


     if (dst == SLJIT_UNUSED)
         return SLJIT_SUCCESS;


Modified: code/trunk/sljit/sljitUtils.c
===================================================================
--- code/trunk/sljit/sljitUtils.c    2014-09-27 06:25:26 UTC (rev 1506)
+++ code/trunk/sljit/sljitUtils.c    2014-09-30 06:35:20 UTC (rev 1507)
@@ -200,7 +200,7 @@
 /* Planning to make it even more clever in the future. */
 static sljit_sw sljit_page_align = 0;


-SLJIT_API_FUNC_ATTRIBUTE struct sljit_stack* SLJIT_CALL sljit_allocate_stack(sljit_uw limit, sljit_uw max_limit)
+SLJIT_API_FUNC_ATTRIBUTE struct sljit_stack* SLJIT_CALL sljit_allocate_stack(sljit_uw limit, sljit_uw max_limit, void *allocator_data)
 {
     struct sljit_stack *stack;
     union {
@@ -232,7 +232,7 @@
     /* Align limit and max_limit. */
     max_limit = (max_limit + sljit_page_align) & ~sljit_page_align;


-    stack = (struct sljit_stack*)SLJIT_MALLOC(sizeof(struct sljit_stack));
+    stack = (struct sljit_stack*)SLJIT_MALLOC(sizeof(struct sljit_stack), allocator_data);
     if (!stack)
         return NULL;


@@ -262,7 +262,7 @@
     base.ptr = mmap(NULL, max_limit, PROT_READ | PROT_WRITE, MAP_PRIVATE, dev_zero, 0);
 #endif
     if (base.ptr == MAP_FAILED) {
-        SLJIT_FREE(stack);
+        SLJIT_FREE(stack, allocator_data);
         return NULL;
     }
     stack->base = base.uw;
@@ -275,14 +275,14 @@


#undef PAGE_ALIGN

-SLJIT_API_FUNC_ATTRIBUTE void SLJIT_CALL sljit_free_stack(struct sljit_stack* stack)
+SLJIT_API_FUNC_ATTRIBUTE void SLJIT_CALL sljit_free_stack(struct sljit_stack* stack, void *allocator_data)
 {
 #ifdef _WIN32
     VirtualFree((void*)stack->base, 0, MEM_RELEASE);
 #else
     munmap((void*)stack->base, stack->max_limit - stack->base);
 #endif
-    SLJIT_FREE(stack);
+    SLJIT_FREE(stack, allocator_data);
 }


SLJIT_API_FUNC_ATTRIBUTE sljit_sw SLJIT_CALL sljit_stack_resize(struct sljit_stack* stack, sljit_uw new_limit)