5 #ifndef V8_REGEXP_X64_REGEXP_MACRO_ASSEMBLER_X64_H_ 6 #define V8_REGEXP_X64_REGEXP_MACRO_ASSEMBLER_X64_H_ 8 #include "src/macro-assembler.h" 9 #include "src/regexp/regexp-macro-assembler.h" 10 #include "src/x64/assembler-x64.h" 11 #include "src/zone/zone-chunk-list.h" 16 #ifndef V8_INTERPRETED_REGEXP 21 int registers_to_save);
23 int stack_limit_slack()
override;
24 void AdvanceCurrentPosition(
int by)
override;
25 void AdvanceRegister(
int reg,
int by)
override;
26 void Backtrack()
override;
27 void Bind(
Label* label)
override;
28 void CheckAtStart(
Label* on_at_start)
override;
31 Label* on_equal)
override;
32 void CheckCharacterGT(uc16 limit,
Label* on_greater)
override;
33 void CheckCharacterLT(uc16 limit,
Label* on_less)
override;
36 void CheckGreedyLoop(
Label* on_tos_equals_current_position)
override;
37 void CheckNotAtStart(
int cp_offset,
Label* on_not_at_start)
override;
38 void CheckNotBackReference(
int start_reg,
bool read_backward,
39 Label* on_no_match)
override;
40 void CheckNotBackReferenceIgnoreCase(
int start_reg,
bool read_backward,
42 Label* on_no_match)
override;
43 void CheckNotCharacter(
uint32_t c,
Label* on_not_equal)
override;
45 Label* on_not_equal)
override;
46 void CheckNotCharacterAfterMinusAnd(uc16 c, uc16 minus, uc16 mask,
47 Label* on_not_equal)
override;
48 void CheckCharacterInRange(uc16 from, uc16 to,
Label* on_in_range)
override;
49 void CheckCharacterNotInRange(uc16 from, uc16 to,
50 Label* on_not_in_range)
override;
55 void CheckPosition(
int cp_offset,
Label* on_outside_input)
override;
56 bool CheckSpecialCharacterClass(uc16
type,
Label* on_no_match)
override;
59 void GoTo(
Label* label)
override;
60 void IfRegisterGE(
int reg,
int comparand,
Label* if_ge)
override;
61 void IfRegisterLT(
int reg,
int comparand,
Label* if_lt)
override;
62 void IfRegisterEqPos(
int reg,
Label* if_eq)
override;
63 IrregexpImplementation Implementation()
override;
64 void LoadCurrentCharacter(
int cp_offset,
Label* on_end_of_input,
65 bool check_bounds =
true,
66 int characters = 1)
override;
67 void PopCurrentPosition()
override;
68 void PopRegister(
int register_index)
override;
69 void PushBacktrack(
Label* label)
override;
70 void PushCurrentPosition()
override;
71 void PushRegister(
int register_index,
72 StackCheckFlag check_stack_limit)
override;
73 void ReadCurrentPositionFromRegister(
int reg)
override;
74 void ReadStackPointerFromRegister(
int reg)
override;
75 void SetCurrentPositionFromEnd(
int by)
override;
76 void SetRegister(
int register_index,
int to)
override;
77 bool Succeed()
override;
78 void WriteCurrentPositionToRegister(
int reg,
int cp_offset)
override;
79 void ClearRegisters(
int reg_from,
int reg_to)
override;
80 void WriteStackPointerToRegister(
int reg)
override;
86 static int CheckStackGuardState(
Address* return_address,
Address raw_code,
91 static const int kFramePointer = 0;
93 static const int kReturn_eip = kFramePointer + kRegisterSize;
94 static const int kFrameAlign = kReturn_eip + kRegisterSize;
101 static const int kInputString = kFrameAlign;
103 static const int kStartIndex = kInputString + kRegisterSize;
104 static const int kInputStart = kStartIndex + kRegisterSize;
105 static const int kInputEnd = kInputStart + kRegisterSize;
106 static const int kRegisterOutput = kInputEnd + kRegisterSize;
111 static const int kNumOutputRegisters = kRegisterOutput + kRegisterSize;
112 static const int kStackHighEnd = kNumOutputRegisters + kRegisterSize;
114 static const int kDirectCall = kStackHighEnd + kRegisterSize;
115 static const int kIsolate = kDirectCall + kRegisterSize;
120 static const int kInputString = kFramePointer - kRegisterSize;
121 static const int kStartIndex = kInputString - kRegisterSize;
122 static const int kInputStart = kStartIndex - kRegisterSize;
123 static const int kInputEnd = kInputStart - kRegisterSize;
124 static const int kRegisterOutput = kInputEnd - kRegisterSize;
129 static const int kNumOutputRegisters = kRegisterOutput - kRegisterSize;
130 static const int kStackHighEnd = kFrameAlign;
131 static const int kDirectCall = kStackHighEnd + kRegisterSize;
132 static const int kIsolate = kDirectCall + kRegisterSize;
138 static const int kBackup_rsi = kFramePointer - kRegisterSize;
139 static const int kBackup_rdi = kBackup_rsi - kRegisterSize;
140 static const int kBackup_rbx = kBackup_rdi - kRegisterSize;
141 static const int kLastCalleeSaveRegister = kBackup_rbx;
146 static const int kBackup_rbx = kNumOutputRegisters - kRegisterSize;
147 static const int kLastCalleeSaveRegister = kBackup_rbx;
150 static const int kSuccessfulCaptures = kLastCalleeSaveRegister - kPointerSize;
153 static const int kStringStartMinusOne = kSuccessfulCaptures - kPointerSize;
156 static const int kRegisterZero = kStringStartMinusOne - kPointerSize;
159 static const size_t kRegExpCodeSize = 1024;
163 void LoadCurrentCharacterUnchecked(
int cp_offset,
int character_count);
166 void CheckPreemption();
169 void CheckStackLimit();
172 void CallCheckStackGuardState();
175 Operand register_location(
int register_index);
178 inline Register current_character() {
return rdx; }
182 inline Register backtrack_stackpointer() {
return rcx; }
185 inline Register code_object_pointer() {
return r8; }
188 inline int char_size() {
return static_cast<int>(mode_); }
192 void BranchOrBacktrack(Condition condition,
Label* to);
194 void MarkPositionForCodeRelativeFixup() {
195 code_relative_fixup_positions_.push_back(masm_.pc_offset());
198 void FixupCodeRelativePositions();
202 inline void SafeCall(
Label* to);
203 inline void SafeCallTarget(
Label* label);
204 inline void SafeReturn();
217 inline void Push(
Label* label);
227 inline void ReadPositionFromRegister(
Register dst,
int reg);
229 Isolate* isolate()
const {
return masm_.isolate(); }
244 int num_saved_registers_;
249 Label success_label_;
250 Label backtrack_label_;
252 Label check_preempt_label_;
253 Label stack_overflow_label_;
256 #endif // V8_INTERPRETED_REGEXP 261 #endif // V8_REGEXP_X64_REGEXP_MACRO_ASSEMBLER_X64_H_