Ticket #18: 01_exec_memory_alloc.diff

File 01_exec_memory_alloc.diff, 4.0 KB (added by santtu, 6 years ago)

Updated Infinoid's 01 patch to work in HEAD (r37916)

  • src/jit/i386/jit_defs.c

    === src/jit/i386/jit_defs.c
    ==================================================================
     
    22882288            case '2': 
    22892289            case '3': 
    22902290            case '4': 
    2291                 mem_free_executable(jit_info.native_ptr); 
     2291                mem_free_executable(jit_info.native_ptr, JIT_ALLOC_SIZE); 
    22922292                return NULL; 
    22932293                break; 
    22942294                /* This might be right. Or not... */ 
     
    23052305                 * oops unknown signature: 
    23062306                 * cleanup and try nci.c 
    23072307                 */ 
    2308                 mem_free_executable(jit_info.native_ptr); 
     2308                mem_free_executable(jit_info.native_ptr, JIT_ALLOC_SIZE); 
    23092309                return NULL; 
    23102310        } 
    23112311        args_offset +=4; 
     
    24322432             * oops unknown signature: 
    24332433             * cleanup and try nci.c 
    24342434             */ 
    2435             mem_free_executable(jit_info.native_ptr); 
     2435            mem_free_executable(jit_info.native_ptr, JIT_ALLOC_SIZE); 
    24362436            return NULL; 
    24372437    } 
    24382438 
  • src/jit.c

    === src/jit.c
    ==================================================================
     
    12571257    } 
    12581258    /* arena stuff */ 
    12591259    mem_sys_free(jit_info->arena.op_map); 
    1260     mem_free_executable(jit_info->arena.start); 
     1260    mem_free_executable(jit_info->arena.start, jit_info->arena.size); 
    12611261    fixup = jit_info->arena.fixups; 
    12621262    while (fixup) { 
    12631263        next_f = fixup->next; 
     
    15251525                Parrot_jit_extend_arena(jit_info); 
    15261526#else 
    15271527                new_arena = (char *)mem_realloc_executable(jit_info->arena.start, 
    1528                         (size_t)jit_info->arena.size * 2); 
     1528                        jit_info->arena.size, (size_t)jit_info->arena.size * 2); 
    15291529                jit_info->arena.size *= 2; 
    15301530                jit_info->native_ptr  = new_arena + 
    15311531                    (jit_info->native_ptr - jit_info->arena.start); 
  • config/gen/platform/openbsd/memexec.c

    === config/gen/platform/openbsd/memexec.c
    ==================================================================
     
    4949 
    5050/* 
    5151 
    52 =item C<void mem_free_executable(void *p)> 
     52=item C<void mem_free_executable(void *p, size_t size)> 
    5353 
     54Free a buffer allocated with mem_alloc_executable(). 
     55 
    5456=cut 
    5557 
    5658*/ 
    5759 
    5860void 
    59 mem_free_executable(void *p) 
     61mem_free_executable(void *p, size_t size) 
    6062{ 
    6163    free(p); 
    6264} 
  • config/gen/platform/platform_interface.h

    === config/gen/platform/platform_interface.h
    ==================================================================
     
    4040 
    4141#ifdef PARROT_HAS_EXEC_PROTECT 
    4242void *mem_alloc_executable(size_t); 
    43 void mem_free_executable(void *); 
    44 void *mem_realloc_executable(void *, size_t); 
     43void mem_free_executable(void *, size_t); 
     44void *mem_realloc_executable(void *, size_t, size_t); 
    4545#else 
    4646#  define mem_alloc_executable mem_sys_allocate 
    47 #  define mem_free_executable mem_sys_free 
    48 #  define mem_realloc_executable mem_sys_realloc 
     47#  define mem_free_executable(a,b) mem_sys_free(a) 
     48#  define mem_realloc_executable(a,b,c) mem_sys_realloc((a),(c)) 
    4949#endif 
    5050 
    5151void* Parrot_memcpy_aligned(void*, void*, size_t); 
  • config/gen/platform/generic/memexec.c

    === config/gen/platform/generic/memexec.c
    ==================================================================
     
    4747 
    4848/* 
    4949 
    50 =item C<void mem_free_executable(void *p)> 
     50=item C<void mem_free_executable(void *p, size_t)> 
    5151 
     52Free a buffer allocated with mem_alloc_executable(). 
     53 
    5254=cut 
    5355 
    5456*/ 
    5557 
    5658void 
    57 mem_free_executable(void *p) 
     59mem_free_executable(void *p, size_t size) 
    5860{ 
    5961    free(p); 
    6062} 
     
    7274*/ 
    7375 
    7476void * 
    75 mem_realloc_executable(void* oldp, size_t newsize) 
     77mem_realloc_executable(void* oldp, size_t oldsize, size_t newsize) 
    7678{ 
    7779    void *temp; 
    7880    void *newp;