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