1 // Copyright 2011 the V8 project authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 6 #ifndef V8_REGEXP_BYTECODES_IRREGEXP_H_ 7 #define V8_REGEXP_BYTECODES_IRREGEXP_H_ 8 9 #ifdef V8_INTERPRETED_REGEXP 10 11 namespace v8 { 12 namespace internal { 13 14 15 const int BYTECODE_MASK = 0xff; 16 // The first argument is packed in with the byte code in one word, but so it 17 // has 24 bits, but it can be positive and negative so only use 23 bits for 18 // positive values. 19 const unsigned int MAX_FIRST_ARG = 0x7fffffu; 20 const int BYTECODE_SHIFT = 8; 21 22 #define BYTECODE_ITERATOR(V) \ 23 V(BREAK, 0, 4) /* bc8 */ \ 24 V(PUSH_CP, 1, 4) /* bc8 pad24 */ \ 25 V(PUSH_BT, 2, 8) /* bc8 pad24 offset32 */ \ 26 V(PUSH_REGISTER, 3, 4) /* bc8 reg_idx24 */ \ 27 V(SET_REGISTER_TO_CP, 4, 8) /* bc8 reg_idx24 offset32 */ \ 28 V(SET_CP_TO_REGISTER, 5, 4) /* bc8 reg_idx24 */ \ 29 V(SET_REGISTER_TO_SP, 6, 4) /* bc8 reg_idx24 */ \ 30 V(SET_SP_TO_REGISTER, 7, 4) /* bc8 reg_idx24 */ \ 31 V(SET_REGISTER, 8, 8) /* bc8 reg_idx24 value32 */ \ 32 V(ADVANCE_REGISTER, 9, 8) /* bc8 reg_idx24 value32 */ \ 33 V(POP_CP, 10, 4) /* bc8 pad24 */ \ 34 V(POP_BT, 11, 4) /* bc8 pad24 */ \ 35 V(POP_REGISTER, 12, 4) /* bc8 reg_idx24 */ \ 36 V(FAIL, 13, 4) /* bc8 pad24 */ \ 37 V(SUCCEED, 14, 4) /* bc8 pad24 */ \ 38 V(ADVANCE_CP, 15, 4) /* bc8 offset24 */ \ 39 V(GOTO, 16, 8) /* bc8 pad24 addr32 */ \ 40 V(LOAD_CURRENT_CHAR, 17, 8) /* bc8 offset24 addr32 */ \ 41 V(LOAD_CURRENT_CHAR_UNCHECKED, 18, 4) /* bc8 offset24 */ \ 42 V(LOAD_2_CURRENT_CHARS, 19, 8) /* bc8 offset24 addr32 */ \ 43 V(LOAD_2_CURRENT_CHARS_UNCHECKED, 20, 4) /* bc8 offset24 */ \ 44 V(LOAD_4_CURRENT_CHARS, 21, 8) /* bc8 offset24 addr32 */ \ 45 V(LOAD_4_CURRENT_CHARS_UNCHECKED, 22, 4) /* bc8 offset24 */ \ 46 V(CHECK_4_CHARS, 23, 12) /* bc8 pad24 uint32 addr32 */ \ 47 V(CHECK_CHAR, 24, 8) /* bc8 pad8 uint16 addr32 */ \ 48 V(CHECK_NOT_4_CHARS, 25, 12) /* bc8 pad24 uint32 addr32 */ \ 49 V(CHECK_NOT_CHAR, 26, 8) /* bc8 pad8 uint16 addr32 */ \ 50 V(AND_CHECK_4_CHARS, 27, 16) /* bc8 pad24 uint32 uint32 addr32 */ \ 51 V(AND_CHECK_CHAR, 28, 12) /* bc8 pad8 uint16 uint32 addr32 */ \ 52 V(AND_CHECK_NOT_4_CHARS, 29, 16) /* bc8 pad24 uint32 uint32 addr32 */ \ 53 V(AND_CHECK_NOT_CHAR, 30, 12) /* bc8 pad8 uint16 uint32 addr32 */ \ 54 V(MINUS_AND_CHECK_NOT_CHAR, 31, 12) /* bc8 pad8 uc16 uc16 uc16 addr32 */ \ 55 V(CHECK_CHAR_IN_RANGE, 32, 12) /* bc8 pad24 uc16 uc16 addr32 */ \ 56 V(CHECK_CHAR_NOT_IN_RANGE, 33, 12) /* bc8 pad24 uc16 uc16 addr32 */ \ 57 V(CHECK_BIT_IN_TABLE, 34, 24) /* bc8 pad24 addr32 bits128 */ \ 58 V(CHECK_LT, 35, 8) /* bc8 pad8 uc16 addr32 */ \ 59 V(CHECK_GT, 36, 8) /* bc8 pad8 uc16 addr32 */ \ 60 V(CHECK_NOT_BACK_REF, 37, 8) /* bc8 reg_idx24 addr32 */ \ 61 V(CHECK_NOT_BACK_REF_NO_CASE, 38, 8) /* bc8 reg_idx24 addr32 */ \ 62 V(CHECK_NOT_BACK_REF_NO_CASE_UNICODE, 39, 8) \ 63 V(CHECK_NOT_BACK_REF_BACKWARD, 40, 8) /* bc8 reg_idx24 addr32 */ \ 64 V(CHECK_NOT_BACK_REF_NO_CASE_BACKWARD, 41, 8) /* bc8 reg_idx24 addr32 */ \ 65 V(CHECK_NOT_BACK_REF_NO_CASE_UNICODE_BACKWARD, 42, 8) \ 66 V(CHECK_NOT_REGS_EQUAL, 43, 12) /* bc8 regidx24 reg_idx32 addr32 */ \ 67 V(CHECK_REGISTER_LT, 44, 12) /* bc8 reg_idx24 value32 addr32 */ \ 68 V(CHECK_REGISTER_GE, 45, 12) /* bc8 reg_idx24 value32 addr32 */ \ 69 V(CHECK_REGISTER_EQ_POS, 46, 8) /* bc8 reg_idx24 addr32 */ \ 70 V(CHECK_AT_START, 47, 8) /* bc8 pad24 addr32 */ \ 71 V(CHECK_NOT_AT_START, 48, 8) /* bc8 offset24 addr32 */ \ 72 V(CHECK_GREEDY, 49, 8) /* bc8 pad24 addr32 */ \ 73 V(ADVANCE_CP_AND_GOTO, 50, 8) /* bc8 offset24 addr32 */ \ 74 V(SET_CURRENT_POSITION_FROM_END, 51, 4) /* bc8 idx24 */ 75 76 #define DECLARE_BYTECODES(name, code, length) \ 77 static const int BC_##name = code; 78 BYTECODE_ITERATOR(DECLARE_BYTECODES) 79 #undef DECLARE_BYTECODES 80 81 #define DECLARE_BYTECODE_LENGTH(name, code, length) \ 82 static const int BC_##name##_LENGTH = length; 83 BYTECODE_ITERATOR(DECLARE_BYTECODE_LENGTH) 84 #undef DECLARE_BYTECODE_LENGTH 85 86 } // namespace internal 87 } // namespace v8 88 89 #endif // V8_INTERPRETED_REGEXP 90 91 #endif // V8_REGEXP_BYTECODES_IRREGEXP_H_ 92