mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
regexec.c: fix build with direct threaded VM
* regexec.c (match_at): move direct threaded VM code to get rid of mixed declarations and code, and enable it only for gcc since it depends on a gcc extension. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53251 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
03cc02c9ab
commit
9fb596815d
2 changed files with 197 additions and 187 deletions
|
@ -1,3 +1,9 @@
|
|||
Wed Dec 23 02:34:36 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* regexec.c (match_at): move direct threaded VM code to get rid of
|
||||
mixed declarations and code, and enable it only for gcc since it
|
||||
depends on a gcc extension.
|
||||
|
||||
Wed Dec 23 02:23:19 2015 Yuki Nishijima <mail@yukinishijima.net>
|
||||
|
||||
* gems/bundled_gems: Upgrade the did_you_mean gem to 1.0.0
|
||||
|
|
154
regexec.c
154
regexec.c
|
@ -33,7 +33,11 @@
|
|||
/* #define USE_MATCH_RANGE_MUST_BE_INSIDE_OF_SPECIFIED_RANGE */
|
||||
|
||||
#ifndef USE_DIRECT_THREADED_VM
|
||||
# ifdef __GNUC__
|
||||
# define USE_DIRECT_THREADED_VM 1
|
||||
# else
|
||||
# define USE_DIRECT_THREADED_VM 0
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef USE_CRNL_AS_LINE_TERMINATOR
|
||||
|
@ -1360,81 +1364,6 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
|
|||
int num_comb_exp_check = reg->num_comb_exp_check;
|
||||
#endif
|
||||
|
||||
#ifdef USE_SUBEXP_CALL
|
||||
/* Stack #0 is used to store the pattern itself and used for (?R), \g<0>, etc. */
|
||||
n = reg->num_repeat + (reg->num_mem + 1) * 2;
|
||||
|
||||
STACK_INIT(alloca_base, xmalloc_base, n, INIT_MATCH_STACK_SIZE);
|
||||
pop_level = reg->stack_pop_level;
|
||||
num_mem = reg->num_mem;
|
||||
repeat_stk = (OnigStackIndex* )alloca_base;
|
||||
|
||||
mem_start_stk = (OnigStackIndex* )(repeat_stk + reg->num_repeat);
|
||||
mem_end_stk = mem_start_stk + (num_mem + 1);
|
||||
for (i = 0; i <= num_mem; i++) {
|
||||
mem_start_stk[i] = mem_end_stk[i] = INVALID_STACK_INDEX;
|
||||
}
|
||||
#else /* USE_SUBEXP_CALL */
|
||||
/* Stack #0 not is used. */
|
||||
n = reg->num_repeat + reg->num_mem * 2;
|
||||
|
||||
STACK_INIT(alloca_base, xmalloc_base, n, INIT_MATCH_STACK_SIZE);
|
||||
pop_level = reg->stack_pop_level;
|
||||
num_mem = reg->num_mem;
|
||||
repeat_stk = (OnigStackIndex* )alloca_base;
|
||||
|
||||
mem_start_stk = (OnigStackIndex* )(repeat_stk + reg->num_repeat);
|
||||
mem_end_stk = mem_start_stk + num_mem;
|
||||
mem_start_stk--; /* for index start from 1,
|
||||
mem_start_stk[1]..mem_start_stk[num_mem] */
|
||||
mem_end_stk--; /* for index start from 1,
|
||||
mem_end_stk[1]..mem_end_stk[num_mem] */
|
||||
for (i = 1; i <= num_mem; i++) {
|
||||
mem_start_stk[i] = mem_end_stk[i] = INVALID_STACK_INDEX;
|
||||
}
|
||||
#endif /* USE_SUBEXP_CALL */
|
||||
|
||||
#ifdef ONIG_DEBUG_MATCH
|
||||
fprintf(stderr, "match_at: str: %"PRIdPTR" (%p), end: %"PRIdPTR" (%p), start: %"PRIdPTR" (%p), sprev: %"PRIdPTR" (%p)\n",
|
||||
(intptr_t )str, str, (intptr_t )end, end, (intptr_t )sstart, sstart, (intptr_t )sprev, sprev);
|
||||
fprintf(stderr, "size: %d, start offset: %d\n",
|
||||
(int )(end - str), (int )(sstart - str));
|
||||
#endif
|
||||
|
||||
STACK_PUSH_ENSURED(STK_ALT, (UChar* )FinishCode); /* bottom stack */
|
||||
best_len = ONIG_MISMATCH;
|
||||
s = (UChar* )sstart;
|
||||
pkeep = (UChar* )sstart;
|
||||
|
||||
|
||||
#ifdef ONIG_DEBUG_MATCH
|
||||
#define OPCODE_EXEC_HOOK \
|
||||
if (s) { \
|
||||
UChar *q, *bp, buf[50]; \
|
||||
int len; \
|
||||
fprintf(stderr, "%4"PRIdPTR"> \"", (*p == OP_FINISH) ? (ptrdiff_t )-1 : s - str); \
|
||||
bp = buf; \
|
||||
q = s; \
|
||||
if (*p != OP_FINISH) { /* s may not be a valid pointer if OP_FINISH. */ \
|
||||
for (i = 0; i < 7 && q < end; i++) { \
|
||||
len = enclen(encode, q, end); \
|
||||
while (len-- > 0) *bp++ = *q++; \
|
||||
} \
|
||||
} \
|
||||
if (q < end) { xmemcpy(bp, "...\"", 4); bp += 4; } \
|
||||
else { xmemcpy(bp, "\"", 1); bp += 1; } \
|
||||
*bp = 0; \
|
||||
fputs((char* )buf, stderr); \
|
||||
for (i = 0; i < 20 - (bp - buf); i++) fputc(' ', stderr); \
|
||||
fprintf(stderr, "%4"PRIdPTR":", (p == FinishCode) ? (ptrdiff_t )-1 : p - reg->p); \
|
||||
onig_print_compiled_byte_code(stderr, p, p + strlen((char *)p),NULL, encode); \
|
||||
fprintf(stderr, "\n"); \
|
||||
}
|
||||
#else
|
||||
#define OPCODE_EXEC_HOOK ((void) 0)
|
||||
#endif
|
||||
|
||||
|
||||
#if USE_DIRECT_THREADED_VM
|
||||
#define VM_LOOP JUMP;
|
||||
#define VM_LOOP_END
|
||||
|
@ -1621,6 +1550,81 @@ static void *oplabels[] = {
|
|||
#endif
|
||||
|
||||
|
||||
#ifdef USE_SUBEXP_CALL
|
||||
/* Stack #0 is used to store the pattern itself and used for (?R), \g<0>, etc. */
|
||||
n = reg->num_repeat + (reg->num_mem + 1) * 2;
|
||||
|
||||
STACK_INIT(alloca_base, xmalloc_base, n, INIT_MATCH_STACK_SIZE);
|
||||
pop_level = reg->stack_pop_level;
|
||||
num_mem = reg->num_mem;
|
||||
repeat_stk = (OnigStackIndex* )alloca_base;
|
||||
|
||||
mem_start_stk = (OnigStackIndex* )(repeat_stk + reg->num_repeat);
|
||||
mem_end_stk = mem_start_stk + (num_mem + 1);
|
||||
for (i = 0; i <= num_mem; i++) {
|
||||
mem_start_stk[i] = mem_end_stk[i] = INVALID_STACK_INDEX;
|
||||
}
|
||||
#else /* USE_SUBEXP_CALL */
|
||||
/* Stack #0 not is used. */
|
||||
n = reg->num_repeat + reg->num_mem * 2;
|
||||
|
||||
STACK_INIT(alloca_base, xmalloc_base, n, INIT_MATCH_STACK_SIZE);
|
||||
pop_level = reg->stack_pop_level;
|
||||
num_mem = reg->num_mem;
|
||||
repeat_stk = (OnigStackIndex* )alloca_base;
|
||||
|
||||
mem_start_stk = (OnigStackIndex* )(repeat_stk + reg->num_repeat);
|
||||
mem_end_stk = mem_start_stk + num_mem;
|
||||
mem_start_stk--; /* for index start from 1,
|
||||
mem_start_stk[1]..mem_start_stk[num_mem] */
|
||||
mem_end_stk--; /* for index start from 1,
|
||||
mem_end_stk[1]..mem_end_stk[num_mem] */
|
||||
for (i = 1; i <= num_mem; i++) {
|
||||
mem_start_stk[i] = mem_end_stk[i] = INVALID_STACK_INDEX;
|
||||
}
|
||||
#endif /* USE_SUBEXP_CALL */
|
||||
|
||||
#ifdef ONIG_DEBUG_MATCH
|
||||
fprintf(stderr, "match_at: str: %"PRIdPTR" (%p), end: %"PRIdPTR" (%p), start: %"PRIdPTR" (%p), sprev: %"PRIdPTR" (%p)\n",
|
||||
(intptr_t )str, str, (intptr_t )end, end, (intptr_t )sstart, sstart, (intptr_t )sprev, sprev);
|
||||
fprintf(stderr, "size: %d, start offset: %d\n",
|
||||
(int )(end - str), (int )(sstart - str));
|
||||
#endif
|
||||
|
||||
STACK_PUSH_ENSURED(STK_ALT, (UChar* )FinishCode); /* bottom stack */
|
||||
best_len = ONIG_MISMATCH;
|
||||
s = (UChar* )sstart;
|
||||
pkeep = (UChar* )sstart;
|
||||
|
||||
|
||||
#ifdef ONIG_DEBUG_MATCH
|
||||
#define OPCODE_EXEC_HOOK \
|
||||
if (s) { \
|
||||
UChar *q, *bp, buf[50]; \
|
||||
int len; \
|
||||
fprintf(stderr, "%4"PRIdPTR"> \"", (*p == OP_FINISH) ? (ptrdiff_t )-1 : s - str); \
|
||||
bp = buf; \
|
||||
q = s; \
|
||||
if (*p != OP_FINISH) { /* s may not be a valid pointer if OP_FINISH. */ \
|
||||
for (i = 0; i < 7 && q < end; i++) { \
|
||||
len = enclen(encode, q, end); \
|
||||
while (len-- > 0) *bp++ = *q++; \
|
||||
} \
|
||||
} \
|
||||
if (q < end) { xmemcpy(bp, "...\"", 4); bp += 4; } \
|
||||
else { xmemcpy(bp, "\"", 1); bp += 1; } \
|
||||
*bp = 0; \
|
||||
fputs((char* )buf, stderr); \
|
||||
for (i = 0; i < 20 - (bp - buf); i++) fputc(' ', stderr); \
|
||||
fprintf(stderr, "%4"PRIdPTR":", (p == FinishCode) ? (ptrdiff_t )-1 : p - reg->p); \
|
||||
onig_print_compiled_byte_code(stderr, p, p + strlen((char *)p),NULL, encode); \
|
||||
fprintf(stderr, "\n"); \
|
||||
}
|
||||
#else
|
||||
#define OPCODE_EXEC_HOOK ((void) 0)
|
||||
#endif
|
||||
|
||||
|
||||
VM_LOOP {
|
||||
CASE(OP_END) MOP_IN(OP_END);
|
||||
n = s - sstart;
|
||||
|
|
Loading…
Reference in a new issue