39 assembler_(assembler) {
42 const char* impl_names[] = {
"IA32",
"ARM",
"ARM64",
43 "MIPS",
"X64",
"Bytecode"};
44 PrintF(
"RegExpMacroAssembler%s();\n", impl_names[type]);
54 static int LabelToInt(Label* label) {
55 return static_cast<int>(
reinterpret_cast<intptr_t
>(label));
60 PrintF(
"label[%08x]: (Bind)\n", LabelToInt(label));
61 assembler_->
Bind(label);
66 PrintF(
" AdvanceCurrentPosition(by=%d);\n", by);
72 PrintF(
" CheckGreedyLoop(label[%08x]);\n\n", LabelToInt(label));
78 PrintF(
" PopCurrentPosition();\n");
84 PrintF(
" PushCurrentPosition();\n");
96 PrintF(
" GoTo(label[%08x]);\n\n", LabelToInt(label));
97 assembler_->
GoTo(label);
102 PrintF(
" PushBacktrack(label[%08x]);\n", LabelToInt(label));
108 bool restart = assembler_->
Succeed();
109 PrintF(
" Succeed();%s\n", restart ?
" [restart for global match]" :
"");
121 PrintF(
" PopRegister(register=%d);\n", register_index);
129 PrintF(
" PushRegister(register=%d, %s);\n",
131 check_stack_limit ?
"check stack limit" :
"");
132 assembler_->
PushRegister(register_index, check_stack_limit);
137 PrintF(
" AdvanceRegister(register=%d, by=%d);\n", reg, by);
143 PrintF(
" SetCurrentPositionFromEnd(by=%d);\n", by);
149 PrintF(
" SetRegister(register=%d, to=%d);\n", register_index, to);
156 PrintF(
" WriteCurrentPositionToRegister(register=%d,cp_offset=%d);\n",
164 PrintF(
" ClearRegister(from=%d, to=%d);\n", reg_from, reg_to);
170 PrintF(
" ReadCurrentPositionFromRegister(register=%d);\n", reg);
176 PrintF(
" WriteStackPointerToRegister(register=%d);\n", reg);
182 PrintF(
" ReadStackPointerFromRegister(register=%d);\n", reg);
188 Label* on_end_of_input,
191 const char* check_msg = check_bounds ?
"" :
" (unchecked)";
192 PrintF(
" LoadCurrentCharacter(cp_offset=%d, label[%08x]%s (%d chars));\n",
194 LabelToInt(on_end_of_input),
209 if (character_ >=
' ' && character_ <=
'~') {
211 buffer_[1] =
static_cast<char>(character_);
228 PrintF(
" CheckCharacterLT(c=0x%04x%s, label[%08x]);\n",
231 LabelToInt(on_less));
239 PrintF(
" CheckCharacterGT(c=0x%04x%s, label[%08x]);\n",
242 LabelToInt(on_greater));
249 PrintF(
" CheckCharacter(c=0x%04x%s, label[%08x]);\n",
252 LabelToInt(on_equal));
258 PrintF(
" CheckAtStart(label[%08x]);\n", LabelToInt(on_at_start));
264 PrintF(
" CheckNotAtStart(label[%08x]);\n", LabelToInt(on_not_at_start));
270 Label* on_not_equal) {
272 PrintF(
" CheckNotCharacter(c=0x%04x%s, label[%08x]);\n",
275 LabelToInt(on_not_equal));
285 PrintF(
" CheckCharacterAfterAnd(c=0x%04x%s, mask=0x%04x, label[%08x]);\n",
289 LabelToInt(on_equal));
297 Label* on_not_equal) {
299 PrintF(
" CheckNotCharacterAfterAnd(c=0x%04x%s, mask=0x%04x, label[%08x]);\n",
303 LabelToInt(on_not_equal));
312 Label* on_not_equal) {
313 PrintF(
" CheckNotCharacterAfterMinusAnd(c=0x%04x, minus=%04x, mask=0x%04x, "
318 LabelToInt(on_not_equal));
326 Label* on_not_in_range) {
329 PrintF(
" CheckCharacterInRange(from=0x%04x%s, to=0x%04x%s, label[%08x]);\n",
334 LabelToInt(on_not_in_range));
342 Label* on_in_range) {
346 " CheckCharacterNotInRange(from=0x%04x%s," " to=%04x%s, label[%08x]);\n",
351 LabelToInt(on_in_range));
358 PrintF(
" CheckBitInTable(label[%08x] ", LabelToInt(on_bit_set));
360 PrintF(
"%c", table->get(i) != 0 ?
'X' :
'.');
371 Label* on_no_match) {
372 PrintF(
" CheckNotBackReference(register=%d, label[%08x]);\n", start_reg,
373 LabelToInt(on_no_match));
380 Label* on_no_match) {
381 PrintF(
" CheckNotBackReferenceIgnoreCase(register=%d, label[%08x]);\n",
382 start_reg, LabelToInt(on_no_match));
389 Label* on_no_match) {
392 PrintF(
" CheckSpecialCharacterClass(type='%c', label[%08x]): %s;\n",
394 LabelToInt(on_no_match),
395 supported ?
"true" :
"false");
401 int comparand, Label* if_lt) {
402 PrintF(
" IfRegisterLT(register=%d, number=%d, label[%08x]);\n",
403 register_index, comparand, LabelToInt(if_lt));
404 assembler_->
IfRegisterLT(register_index, comparand, if_lt);
410 PrintF(
" IfRegisterEqPos(register=%d, label[%08x]);\n",
411 register_index, LabelToInt(if_eq));
417 int comparand, Label* if_ge) {
418 PrintF(
" IfRegisterGE(register=%d, number=%d, label[%08x]);\n",
419 register_index, comparand, LabelToInt(if_ge));
420 assembler_->
IfRegisterGE(register_index, comparand, if_ge);
431 PrintF(
" GetCode(%s);\n", source->ToCString().get());
432 return assembler_->
GetCode(source);
virtual void WriteStackPointerToRegister(int reg)=0
virtual IrregexpImplementation Implementation()=0
virtual void CheckNotBackReferenceIgnoreCase(int start_reg, Label *on_no_match)
virtual void GoTo(Label *label)=0
virtual void CheckCharacterLT(uc16 limit, Label *on_less)
virtual void IfRegisterLT(int reg, int comparand, Label *if_lt)
virtual void ClearRegisters(int reg_from, int reg_to)
void PrintF(const char *format,...)
virtual void ReadCurrentPositionFromRegister(int reg)
virtual void CheckNotBackReference(int start_reg, Label *on_no_match)=0
virtual void IfRegisterEqPos(int reg, Label *if_eq)
virtual void SetRegister(int register_index, int to)=0
virtual void ClearRegisters(int reg_from, int reg_to)=0
virtual ~RegExpMacroAssemblerTracer()
virtual void CheckCharacterNotInRange(uc16 from, uc16 to, Label *on_not_in_range)
virtual void LoadCurrentCharacter(int cp_offset, Label *on_end_of_input, bool check_bounds=true, int characters=1)=0
virtual void PushCurrentPosition()
#define ASSERT(condition)
virtual void GoTo(Label *label)
virtual void PopCurrentPosition()
virtual void ReadCurrentPositionFromRegister(int reg)=0
virtual void PopCurrentPosition()=0
virtual void CheckNotCharacterAfterAnd(unsigned c, unsigned and_with, Label *on_not_equal)
virtual void AdvanceCurrentPosition(int by)=0
virtual void CheckNotCharacterAfterMinusAnd(uc16 c, uc16 minus, uc16 and_with, Label *on_not_equal)
virtual void WriteCurrentPositionToRegister(int reg, int cp_offset)
virtual void CheckBitInTable(Handle< ByteArray > table, Label *on_bit_set)
virtual void CheckCharacterGT(uc16 limit, Label *on_greater)=0
virtual void CheckGreedyLoop(Label *on_tos_equals_current_position)
virtual void CheckNotAtStart(Label *on_not_at_start)
static const int kTableSize
virtual void PushRegister(int register_index, StackCheckFlag check_stack_limit)=0
virtual void ReadStackPointerFromRegister(int reg)=0
virtual void CheckAtStart(Label *on_at_start)=0
virtual void CheckCharacterNotInRange(uc16 from, uc16 to, Label *on_not_in_range)=0
virtual void IfRegisterLT(int reg, int comparand, Label *if_lt)=0
virtual void CheckNotBackReferenceIgnoreCase(int start_reg, Label *on_no_match)=0
virtual void LoadCurrentCharacter(int cp_offset, Label *on_end_of_input, bool check_bounds=true, int characters=1)
virtual void CheckCharacter(unsigned c, Label *on_equal)
virtual void CheckNotCharacterAfterMinusAnd(uc16 c, uc16 minus, uc16 and_with, Label *on_not_equal)=0
virtual void CheckNotAtStart(Label *on_not_at_start)=0
virtual void CheckNotBackReference(int start_reg, Label *on_no_match)
virtual void SetCurrentPositionFromEnd(int by)
virtual void CheckCharacterAfterAnd(unsigned c, unsigned and_with, Label *on_equal)
virtual void CheckCharacter(unsigned c, Label *on_equal)=0
virtual Handle< HeapObject > GetCode(Handle< String > source)
virtual void AdvanceRegister(int reg, int by)=0
virtual void PopRegister(int register_index)=0
virtual void PushCurrentPosition()=0
static const int kTableMask
virtual void IfRegisterGE(int reg, int comparand, Label *if_ge)
virtual void ReadStackPointerFromRegister(int reg)
virtual IrregexpImplementation Implementation()
virtual bool CheckSpecialCharacterClass(uc16 type, Label *on_no_match)
virtual void WriteCurrentPositionToRegister(int reg, int cp_offset)=0
virtual bool CheckSpecialCharacterClass(uc16 type, Label *on_no_match)
virtual void Bind(Label *label)=0
virtual void CheckCharacterLT(uc16 limit, Label *on_less)=0
virtual void SetCurrentPositionFromEnd(int by)=0
virtual void Backtrack()=0
virtual void CheckCharacterAfterAnd(unsigned c, unsigned and_with, Label *on_equal)=0
virtual void IfRegisterEqPos(int reg, Label *if_eq)=0
virtual void CheckBitInTable(Handle< ByteArray > table, Label *on_bit_set)=0
virtual void CheckCharacterInRange(uc16 from, uc16 to, Label *on_in_range)
virtual void CheckAtStart(Label *on_at_start)
virtual void CheckNotCharacter(unsigned c, Label *on_not_equal)
virtual void Bind(Label *label)
virtual void CheckGreedyLoop(Label *on_tos_equals_current_position)=0
PrintablePrinter(uc16 character)
virtual void PushRegister(int register_index, StackCheckFlag check_stack_limit)
virtual void AdvanceRegister(int reg, int by)
RegExpMacroAssemblerTracer(RegExpMacroAssembler *assembler)
virtual void CheckNotCharacter(unsigned c, Label *on_not_equal)=0
virtual void PushBacktrack(Label *label)
virtual void SetRegister(int register_index, int to)
virtual void PopRegister(int register_index)
virtual void WriteStackPointerToRegister(int reg)
virtual void CheckNotCharacterAfterAnd(unsigned c, unsigned and_with, Label *on_not_equal)=0
virtual void CheckCharacterInRange(uc16 from, uc16 to, Label *on_in_range)=0
virtual Handle< HeapObject > GetCode(Handle< String > source)=0
virtual void AdvanceCurrentPosition(int by)
virtual void IfRegisterGE(int reg, int comparand, Label *if_ge)=0
virtual void PushBacktrack(Label *label)=0
virtual void CheckCharacterGT(uc16 limit, Label *on_greater)