/[pcre]/code/trunk/pcre_jit_compile.c
ViewVC logotype

Diff of /code/trunk/pcre_jit_compile.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1506 by zherczeg, Sat Sep 27 06:25:26 2014 UTC revision 1507 by zherczeg, Tue Sep 30 06:35:20 2014 UTC
# Line 52  POSSIBILITY OF SUCH DAMAGE. Line 52  POSSIBILITY OF SUCH DAMAGE.
52  we just include it. This way we don't need to touch the build  we just include it. This way we don't need to touch the build
53  system files. */  system files. */
54    
55  #define SLJIT_MALLOC(size) (PUBL(malloc))(size)  #define SLJIT_MALLOC(size, allocator_data) (PUBL(malloc))(size)
56  #define SLJIT_FREE(ptr) (PUBL(free))(ptr)  #define SLJIT_FREE(ptr, allocator_data) (PUBL(free))(ptr)
57  #define SLJIT_CONFIG_AUTO 1  #define SLJIT_CONFIG_AUTO 1
58  #define SLJIT_CONFIG_STATIC 1  #define SLJIT_CONFIG_STATIC 1
59  #define SLJIT_VERBOSE 0  #define SLJIT_VERBOSE 0
# Line 3584  if (range_right >= 0) Line 3584  if (range_right >= 0)
3584    /* Since no data is consumed (see the assert in the beginning    /* Since no data is consumed (see the assert in the beginning
3585    of this function), this space can be reallocated. */    of this function), this space can be reallocated. */
3586    if (common->read_only_data)    if (common->read_only_data)
3587      SLJIT_FREE(common->read_only_data);      SLJIT_FREE(common->read_only_data, compiler->allocator_data);
3588    
3589    common->read_only_data_size += 256;    common->read_only_data_size += 256;
3590    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);
3591    if (common->read_only_data == NULL)    if (common->read_only_data == NULL)
3592      return TRUE;      return TRUE;
3593    
# Line 9849  ccend = bracketend(common->start); Line 9849  ccend = bracketend(common->start);
9849    
9850  /* Calculate the local space size on the stack. */  /* Calculate the local space size on the stack. */
9851  common->ovector_start = LIMIT_MATCH + sizeof(sljit_sw);  common->ovector_start = LIMIT_MATCH + sizeof(sljit_sw);
9852  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);
9853  if (!common->optimized_cbracket)  if (!common->optimized_cbracket)
9854    return;    return;
9855  #if defined DEBUG_FORCE_UNOPTIMIZED_CBRAS && DEBUG_FORCE_UNOPTIMIZED_CBRAS == 1  #if defined DEBUG_FORCE_UNOPTIMIZED_CBRAS && DEBUG_FORCE_UNOPTIMIZED_CBRAS == 1
# Line 9865  common->ovector_start += sizeof(sljit_sw Line 9865  common->ovector_start += sizeof(sljit_sw
9865  #endif  #endif
9866  if (!check_opcode_types(common, common->start, ccend))  if (!check_opcode_types(common, common->start, ccend))
9867    {    {
9868    SLJIT_FREE(common->optimized_cbracket);    SLJIT_FREE(common->optimized_cbracket, compiler->allocator_data);
9869    return;    return;
9870    }    }
9871    
# Line 9927  SLJIT_ASSERT(!(common->req_char_ptr != 0 Line 9927  SLJIT_ASSERT(!(common->req_char_ptr != 0
9927  common->cbra_ptr = OVECTOR_START + (re->top_bracket + 1) * 2 * sizeof(sljit_sw);  common->cbra_ptr = OVECTOR_START + (re->top_bracket + 1) * 2 * sizeof(sljit_sw);
9928    
9929  total_length = ccend - common->start;  total_length = ccend - common->start;
9930  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);
9931  if (!common->private_data_ptrs)  if (!common->private_data_ptrs)
9932    {    {
9933    SLJIT_FREE(common->optimized_cbracket);    SLJIT_FREE(common->optimized_cbracket, compiler->allocator_data);
9934    return;    return;
9935    }    }
9936  memset(common->private_data_ptrs, 0, total_length * sizeof(sljit_si));  memset(common->private_data_ptrs, 0, total_length * sizeof(sljit_si));
# Line 9939  private_data_size = common->cbra_ptr + ( Line 9939  private_data_size = common->cbra_ptr + (
9939  set_private_data_ptrs(common, &private_data_size, ccend);  set_private_data_ptrs(common, &private_data_size, ccend);
9940  if (private_data_size > SLJIT_MAX_LOCAL_SIZE)  if (private_data_size > SLJIT_MAX_LOCAL_SIZE)
9941    {    {
9942    SLJIT_FREE(common->private_data_ptrs);    SLJIT_FREE(common->private_data_ptrs, compiler->allocator_data);
9943    SLJIT_FREE(common->optimized_cbracket);    SLJIT_FREE(common->optimized_cbracket, compiler->allocator_data);
9944    return;    return;
9945    }    }
9946    
# Line 9953  if (common->has_then) Line 9953  if (common->has_then)
9953    
9954  if (common->read_only_data_size > 0)  if (common->read_only_data_size > 0)
9955    {    {
9956    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);
9957    if (common->read_only_data == NULL)    if (common->read_only_data == NULL)
9958      {      {
9959      SLJIT_FREE(common->optimized_cbracket);      SLJIT_FREE(common->optimized_cbracket, compiler->allocator_data);
9960      SLJIT_FREE(common->private_data_ptrs);      SLJIT_FREE(common->private_data_ptrs, compiler->allocator_data);
9961      return;      return;
9962      }      }
9963    common->read_only_data_ptr = common->read_only_data;    common->read_only_data_ptr = common->read_only_data;
9964    }    }
9965    
9966  compiler = sljit_create_compiler();  compiler = sljit_create_compiler(NULL);
9967  if (!compiler)  if (!compiler)
9968    {    {
9969    SLJIT_FREE(common->optimized_cbracket);    SLJIT_FREE(common->optimized_cbracket, compiler->allocator_data);
9970    SLJIT_FREE(common->private_data_ptrs);    SLJIT_FREE(common->private_data_ptrs, compiler->allocator_data);
9971    if (common->read_only_data)    if (common->read_only_data)
9972      SLJIT_FREE(common->read_only_data);      SLJIT_FREE(common->read_only_data, compiler->allocator_data);
9973    return;    return;
9974    }    }
9975  common->compiler = compiler;  common->compiler = compiler;
# Line 10013  if ((re->options & PCRE_ANCHORED) == 0) Line 10013  if ((re->options & PCRE_ANCHORED) == 0)
10013        if (common->read_only_data_size > 0 && common->read_only_data == NULL)        if (common->read_only_data_size > 0 && common->read_only_data == NULL)
10014          {          {
10015          sljit_free_compiler(compiler);          sljit_free_compiler(compiler);
10016          SLJIT_FREE(common->optimized_cbracket);          SLJIT_FREE(common->optimized_cbracket, compiler->allocator_data);
10017          SLJIT_FREE(common->private_data_ptrs);          SLJIT_FREE(common->private_data_ptrs, compiler->allocator_data);
10018          return;          return;
10019          }          }
10020        }        }
# Line 10068  compile_matchingpath(common, common->sta Line 10068  compile_matchingpath(common, common->sta
10068  if (SLJIT_UNLIKELY(sljit_get_compiler_error(compiler)))  if (SLJIT_UNLIKELY(sljit_get_compiler_error(compiler)))
10069    {    {
10070    sljit_free_compiler(compiler);    sljit_free_compiler(compiler);
10071    SLJIT_FREE(common->optimized_cbracket);    SLJIT_FREE(common->optimized_cbracket, compiler->allocator_data);
10072    SLJIT_FREE(common->private_data_ptrs);    SLJIT_FREE(common->private_data_ptrs, compiler->allocator_data);
10073    if (common->read_only_data)    if (common->read_only_data)
10074      SLJIT_FREE(common->read_only_data);      SLJIT_FREE(common->read_only_data, compiler->allocator_data);
10075    return;    return;
10076    }    }
10077    
# Line 10109  compile_backtrackingpath(common, rootbac Line 10109  compile_backtrackingpath(common, rootbac
10109  if (SLJIT_UNLIKELY(sljit_get_compiler_error(compiler)))  if (SLJIT_UNLIKELY(sljit_get_compiler_error(compiler)))
10110    {    {
10111    sljit_free_compiler(compiler);    sljit_free_compiler(compiler);
10112    SLJIT_FREE(common->optimized_cbracket);    SLJIT_FREE(common->optimized_cbracket, compiler->allocator_data);
10113    SLJIT_FREE(common->private_data_ptrs);    SLJIT_FREE(common->private_data_ptrs, compiler->allocator_data);
10114    if (common->read_only_data)    if (common->read_only_data)
10115      SLJIT_FREE(common->read_only_data);      SLJIT_FREE(common->read_only_data, compiler->allocator_data);
10116    return;    return;
10117    }    }
10118    
# Line 10190  while (common->currententry != NULL) Line 10190  while (common->currententry != NULL)
10190    if (SLJIT_UNLIKELY(sljit_get_compiler_error(compiler)))    if (SLJIT_UNLIKELY(sljit_get_compiler_error(compiler)))
10191      {      {
10192      sljit_free_compiler(compiler);      sljit_free_compiler(compiler);
10193      SLJIT_FREE(common->optimized_cbracket);      SLJIT_FREE(common->optimized_cbracket, compiler->allocator_data);
10194      SLJIT_FREE(common->private_data_ptrs);      SLJIT_FREE(common->private_data_ptrs, compiler->allocator_data);
10195      if (common->read_only_data)      if (common->read_only_data)
10196        SLJIT_FREE(common->read_only_data);        SLJIT_FREE(common->read_only_data, compiler->allocator_data);
10197      return;      return;
10198      }      }
10199    flush_stubs(common);    flush_stubs(common);
# Line 10304  if (common->getucd != NULL) Line 10304  if (common->getucd != NULL)
10304  #endif  #endif
10305    
10306  SLJIT_ASSERT(common->read_only_data + (common->read_only_data_size >> SLJIT_WORD_SHIFT) == common->read_only_data_ptr);  SLJIT_ASSERT(common->read_only_data + (common->read_only_data_size >> SLJIT_WORD_SHIFT) == common->read_only_data_ptr);
10307  SLJIT_FREE(common->optimized_cbracket);  SLJIT_FREE(common->optimized_cbracket, compiler->allocator_data);
10308  SLJIT_FREE(common->private_data_ptrs);  SLJIT_FREE(common->private_data_ptrs, compiler->allocator_data);
10309    
10310  executable_func = sljit_generate_code(compiler);  executable_func = sljit_generate_code(compiler);
10311  executable_size = sljit_get_generated_code_size(compiler);  executable_size = sljit_get_generated_code_size(compiler);
# Line 10319  sljit_free_compiler(compiler); Line 10319  sljit_free_compiler(compiler);
10319  if (executable_func == NULL)  if (executable_func == NULL)
10320    {    {
10321    if (common->read_only_data)    if (common->read_only_data)
10322      SLJIT_FREE(common->read_only_data);      SLJIT_FREE(common->read_only_data, compiler->allocator_data);
10323    return;    return;
10324    }    }
10325    
# Line 10337  else Line 10337  else
10337     * bit remains set, as the bit indicates that the pointer to the data     * bit remains set, as the bit indicates that the pointer to the data
10338     * is valid.)     * is valid.)
10339     */     */
10340    functions = SLJIT_MALLOC(sizeof(executable_functions));    functions = SLJIT_MALLOC(sizeof(executable_functions), compiler->allocator_data);
10341    if (functions == NULL)    if (functions == NULL)
10342      {      {
10343      /* This case is highly unlikely since we just recently      /* This case is highly unlikely since we just recently
10344      freed a lot of memory. Not impossible though. */      freed a lot of memory. Not impossible though. */
10345      sljit_free_code(executable_func);      sljit_free_code(executable_func);
10346      if (common->read_only_data)      if (common->read_only_data)
10347        SLJIT_FREE(common->read_only_data);        SLJIT_FREE(common->read_only_data, compiler->allocator_data);
10348      return;      return;
10349      }      }
10350    memset(functions, 0, sizeof(executable_functions));    memset(functions, 0, sizeof(executable_functions));
# Line 10543  for (i = 0; i < JIT_NUMBER_OF_COMPILE_MO Line 10543  for (i = 0; i < JIT_NUMBER_OF_COMPILE_MO
10543    if (functions->executable_funcs[i] != NULL)    if (functions->executable_funcs[i] != NULL)
10544      sljit_free_code(functions->executable_funcs[i]);      sljit_free_code(functions->executable_funcs[i]);
10545    if (functions->read_only_data[i] != NULL)    if (functions->read_only_data[i] != NULL)
10546      SLJIT_FREE(functions->read_only_data[i]);      SLJIT_FREE(functions->read_only_data[i], compiler->allocator_data);
10547    }    }
10548  SLJIT_FREE(functions);  SLJIT_FREE(functions, compiler->allocator_data);
10549  }  }
10550    
10551  int  int
# Line 10582  if (startsize > maxsize) Line 10582  if (startsize > maxsize)
10582    startsize = maxsize;    startsize = maxsize;
10583  startsize = (startsize + STACK_GROWTH_RATE - 1) & ~(STACK_GROWTH_RATE - 1);  startsize = (startsize + STACK_GROWTH_RATE - 1) & ~(STACK_GROWTH_RATE - 1);
10584  maxsize = (maxsize + STACK_GROWTH_RATE - 1) & ~(STACK_GROWTH_RATE - 1);  maxsize = (maxsize + STACK_GROWTH_RATE - 1) & ~(STACK_GROWTH_RATE - 1);
10585  return (PUBL(jit_stack)*)sljit_allocate_stack(startsize, maxsize);  return (PUBL(jit_stack)*)sljit_allocate_stack(startsize, maxsize, NULL);
10586  }  }
10587    
10588  #if defined COMPILE_PCRE8  #if defined COMPILE_PCRE8
# Line 10596  PCRE_EXP_DECL void Line 10596  PCRE_EXP_DECL void
10596  pcre32_jit_stack_free(pcre32_jit_stack *stack)  pcre32_jit_stack_free(pcre32_jit_stack *stack)
10597  #endif  #endif
10598  {  {
10599  sljit_free_stack((struct sljit_stack *)stack);  sljit_free_stack((struct sljit_stack *)stack, NULL);
10600  }  }
10601    
10602  #if defined COMPILE_PCRE8  #if defined COMPILE_PCRE8

Legend:
Removed from v.1506  
changed lines
  Added in v.1507

  ViewVC Help
Powered by ViewVC 1.1.5