29 for (
int i = 0;
i < len;
i++) {
32 if (old_char == new_char)
continue;
35 interp_canonicalize->
get(old_char,
'\0', old_string);
36 interp_canonicalize->
get(new_char,
'\0', new_string);
37 if (old_string[0] != new_string[0]) {
50 for (
int i = 0;
i < len;
i++) {
51 unsigned int old_char = subject[from++];
52 unsigned int new_char = subject[current++];
53 if (old_char == new_char)
continue;
57 if (old_char != new_char)
return false;
59 if (!(old_char -
'a' <=
'z' -
'a') &&
60 !(old_char - 224 <= 254 - 224 && old_char != 247)) {
69 static void TraceInterpreter(
const byte* code_base,
75 const char* bytecode_name) {
76 if (FLAG_trace_regexp_bytecodes) {
77 bool printable = (current_char < 127 && current_char >= 32);
80 "pc = %02x, sp = %d, curpos = %d, curchar = %08x (%c), bc = %s" :
81 "pc = %02x, sp = %d, curpos = %d, curchar = %08x .%c., bc = %s";
87 printable ? current_char :
'.',
89 for (
int i = 0;
i < bytecode_length;
i++) {
90 printf(
", %02x",
pc[
i]);
93 for (
int i = 1;
i < bytecode_length;
i++) {
94 unsigned char b =
pc[
i];
95 if (b < 127 && b >= 32) {
106 #define BYTECODE(name) \
108 TraceInterpreter(code_base, \
110 static_cast<int>(backtrack_sp - backtrack_stack_base), \
113 BC_##name##_LENGTH, \
116 #define BYTECODE(name) \
122 DCHECK((
reinterpret_cast<intptr_t
>(
pc) & 3) == 0);
123 return *
reinterpret_cast<const int32_t *
>(
pc);
128 DCHECK((
reinterpret_cast<intptr_t
>(
pc) & 1) == 0);
129 return *
reinterpret_cast<const uint16_t *
>(
pc);
158 template <
typename Char>
160 const byte* code_base,
165 const byte*
pc = code_base;
170 int* backtrack_stack_base = backtrack_stack.
data();
171 int* backtrack_sp = backtrack_stack_base;
172 int backtrack_stack_space = backtrack_stack.
max_size();
174 if (FLAG_trace_regexp_bytecodes) {
175 PrintF(
"\n\nStart bytecode interpreter\n\n");
185 if (--backtrack_stack_space < 0) {
188 *backtrack_sp++ = current;
189 pc += BC_PUSH_CP_LENGTH;
192 if (--backtrack_stack_space < 0) {
196 pc += BC_PUSH_BT_LENGTH;
199 if (--backtrack_stack_space < 0) {
203 pc += BC_PUSH_REGISTER_LENGTH;
207 pc += BC_SET_REGISTER_LENGTH;
211 pc += BC_ADVANCE_REGISTER_LENGTH;
215 pc += BC_SET_REGISTER_TO_CP_LENGTH;
219 pc += BC_SET_CP_TO_REGISTER_LENGTH;
223 static_cast<int>(backtrack_sp - backtrack_stack_base);
224 pc += BC_SET_REGISTER_TO_SP_LENGTH;
227 backtrack_sp = backtrack_stack_base + registers[insn >>
BYTECODE_SHIFT];
228 backtrack_stack_space = backtrack_stack.
max_size() -
229 static_cast<int>(backtrack_sp - backtrack_stack_base);
230 pc += BC_SET_SP_TO_REGISTER_LENGTH;
233 backtrack_stack_space++;
235 current = *backtrack_sp;
236 pc += BC_POP_CP_LENGTH;
239 backtrack_stack_space++;
241 pc = code_base + *backtrack_sp;
244 backtrack_stack_space++;
247 pc += BC_POP_REGISTER_LENGTH;
255 pc += BC_ADVANCE_CP_LENGTH;
265 if (current == backtrack_sp[-1]) {
267 backtrack_stack_space++;
270 pc += BC_CHECK_GREEDY_LENGTH;
275 if (pos >= subject.
length()) {
278 current_char = subject[pos];
279 pc += BC_LOAD_CURRENT_CHAR_LENGTH;
283 BYTECODE(LOAD_CURRENT_CHAR_UNCHECKED) {
285 current_char = subject[pos];
286 pc += BC_LOAD_CURRENT_CHAR_UNCHECKED_LENGTH;
291 if (pos + 2 > subject.
length()) {
294 Char next = subject[pos + 1];
296 (subject[pos] | (next << (
kBitsPerByte *
sizeof(Char))));
297 pc += BC_LOAD_2_CURRENT_CHARS_LENGTH;
301 BYTECODE(LOAD_2_CURRENT_CHARS_UNCHECKED) {
303 Char next = subject[pos + 1];
304 current_char = (subject[pos] | (next << (
kBitsPerByte *
sizeof(Char))));
305 pc += BC_LOAD_2_CURRENT_CHARS_UNCHECKED_LENGTH;
309 DCHECK(
sizeof(Char) == 1);
311 if (pos + 4 > subject.
length()) {
314 Char next1 = subject[pos + 1];
315 Char next2 = subject[pos + 2];
316 Char next3 = subject[pos + 3];
317 current_char = (subject[pos] |
321 pc += BC_LOAD_4_CURRENT_CHARS_LENGTH;
325 BYTECODE(LOAD_4_CURRENT_CHARS_UNCHECKED) {
326 DCHECK(
sizeof(Char) == 1);
328 Char next1 = subject[pos + 1];
329 Char next2 = subject[pos + 2];
330 Char next3 = subject[pos + 3];
331 current_char = (subject[pos] |
335 pc += BC_LOAD_4_CURRENT_CHARS_UNCHECKED_LENGTH;
340 if (c == current_char) {
343 pc += BC_CHECK_4_CHARS_LENGTH;
349 if (c == current_char) {
352 pc += BC_CHECK_CHAR_LENGTH;
358 if (c != current_char) {
361 pc += BC_CHECK_NOT_4_CHARS_LENGTH;
367 if (c != current_char) {
370 pc += BC_CHECK_NOT_CHAR_LENGTH;
379 pc += BC_AND_CHECK_4_CHARS_LENGTH;
388 pc += BC_AND_CHECK_CHAR_LENGTH;
397 pc += BC_AND_CHECK_NOT_4_CHARS_LENGTH;
406 pc += BC_AND_CHECK_NOT_CHAR_LENGTH;
410 BYTECODE(MINUS_AND_CHECK_NOT_CHAR) {
414 if (c != ((current_char - minus) & mask)) {
417 pc += BC_MINUS_AND_CHECK_NOT_CHAR_LENGTH;
424 if (from <= current_char && current_char <=
to) {
427 pc += BC_CHECK_CHAR_IN_RANGE_LENGTH;
434 if (from > current_char || current_char >
to) {
437 pc += BC_CHECK_CHAR_NOT_IN_RANGE_LENGTH;
445 if ((b & (1 << bit)) != 0) {
448 pc += BC_CHECK_BIT_IN_TABLE_LENGTH;
454 if (current_char < limit) {
457 pc += BC_CHECK_LT_LENGTH;
463 if (current_char > limit) {
466 pc += BC_CHECK_GT_LENGTH;
474 pc += BC_CHECK_REGISTER_LT_LENGTH;
481 pc += BC_CHECK_REGISTER_GE_LENGTH;
488 pc += BC_CHECK_REGISTER_EQ_POS_LENGTH;
494 pc += BC_CHECK_NOT_REGS_EQUAL_LENGTH;
502 if (from < 0 || len <= 0) {
503 pc += BC_CHECK_NOT_BACK_REF_LENGTH;
506 if (current + len > subject.
length()) {
511 for (
i = 0;
i < len;
i++) {
512 if (subject[from +
i] != subject[current +
i]) {
520 pc += BC_CHECK_NOT_BACK_REF_LENGTH;
523 BYTECODE(CHECK_NOT_BACK_REF_NO_CASE) {
526 if (from < 0 || len <= 0) {
527 pc += BC_CHECK_NOT_BACK_REF_NO_CASE_LENGTH;
530 if (current + len > subject.
length()) {
535 from, current, len, subject)) {
537 pc += BC_CHECK_NOT_BACK_REF_NO_CASE_LENGTH;
548 pc += BC_CHECK_AT_START_LENGTH;
553 pc += BC_CHECK_NOT_AT_START_LENGTH;
558 BYTECODE(SET_CURRENT_POSITION_FROM_END) {
560 if (subject.
length() - current > by) {
561 current = subject.
length() - by;
562 current_char = subject[current - 1];
564 pc += BC_SET_CURRENT_POSITION_FROM_END_LENGTH;
580 int start_position) {
581 DCHECK(subject->IsFlat());
584 const byte* code_base = code_array->GetDataStartAddress();
585 uc16 previous_char =
'\n';
589 if (start_position != 0) previous_char = subject_vector[start_position - 1];
599 if (start_position != 0) previous_char = subject_vector[start_position - 1];
int get(uchar c, uchar n, uchar *result)
DISALLOW_COPY_AND_ASSIGN(BacktrackStack)
static const int kBacktrackStackSize
static RegExpImpl::IrregexpResult Match(Isolate *isolate, Handle< ByteArray > code, Handle< String > subject, int *captures, int start_position)
unibrow::Mapping< unibrow::Ecma262Canonicalize > * interp_canonicalize_mapping()
static const int kTableMask
Vector< const uint8_t > ToOneByteVector()
Vector< const uc16 > ToUC16Vector()
enable harmony numeric enable harmony object literal extensions Optimize object Array DOM strings and string trace pretenuring decisions of HAllocate instructions Enables optimizations which favor memory size over execution speed maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining trace the tracking of allocation sites deoptimize every n garbage collections perform array bounds checks elimination analyze liveness of environment slots and zap dead values flushes the cache of optimized code for closures on every GC allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes enable context specialization in TurboFan execution budget before interrupt is triggered max percentage of megamorphic generic ICs to allow optimization enable use of SAHF instruction if enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable use of MLS instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long enable alignment of csp to bytes on platforms which prefer the register to always be expose gc extension under the specified name show built in functions in stack traces use random jit cookie to mask large constants minimum length for automatic enable preparsing CPU profiler sampling interval in microseconds trace out of bounds accesses to external arrays default size of stack region v8 is allowed to maximum length of function source code printed in a stack trace min size of a semi the new space consists of two semi spaces print one trace line following each garbage collection do not print trace line after scavenger collection print cumulative GC statistics in only print modified registers Trace simulator debug messages Implied by trace sim abort randomize hashes to avoid predictable hash Fixed seed to use to hash property Print the time it takes to deserialize the snapshot A filename with extra code to be included in the A file to write the raw snapshot bytes to(mksnapshot only)") DEFINE_STRING(raw_context_file
#define DCHECK(condition)
void DeleteArray(T *array)
static int32_t Load16Aligned(const byte *pc)
static RegExpImpl::IrregexpResult RawMatch(Isolate *isolate, const byte *code_base, Vector< const Char > subject, int *registers, int current, uint32_t current_char)
static int32_t Load32Aligned(const byte *pc)
static bool BackRefMatchesNoCase(Canonicalize *interp_canonicalize, int from, int current, int len, Vector< const uc16 > subject)
const int kBitsPerByteLog2
void PrintF(const char *format,...)
unibrow::Mapping< unibrow::Ecma262Canonicalize > Canonicalize
Debugger support for the V8 JavaScript engine.
Definitions and convenience functions for working with unicode.