39 assembler_(assembler) {
42 const char* impl_names[] = {
"IA32",
"ARM",
"MIPS",
"X64",
"Bytecode"};
43 PrintF(
"RegExpMacroAssembler%s();\n", impl_names[type]);
53 static int LabelToInt(Label* label) {
54 return static_cast<int>(
reinterpret_cast<intptr_t
>(label));
59 PrintF(
"label[%08x]: (Bind)\n", LabelToInt(label));
60 assembler_->
Bind(label);
65 PrintF(
" AdvanceCurrentPosition(by=%d);\n", by);
71 PrintF(
" CheckGreedyLoop(label[%08x]);\n\n", LabelToInt(label));
77 PrintF(
" PopCurrentPosition();\n");
83 PrintF(
" PushCurrentPosition();\n");
95 PrintF(
" GoTo(label[%08x]);\n\n", LabelToInt(label));
96 assembler_->
GoTo(label);
101 PrintF(
" PushBacktrack(label[%08x]);\n", LabelToInt(label));
107 bool restart = assembler_->
Succeed();
108 PrintF(
" Succeed();%s\n", restart ?
" [restart for global match]" :
"");
120 PrintF(
" PopRegister(register=%d);\n", register_index);
128 PrintF(
" PushRegister(register=%d, %s);\n",
130 check_stack_limit ?
"check stack limit" :
"");
131 assembler_->
PushRegister(register_index, check_stack_limit);
136 PrintF(
" AdvanceRegister(register=%d, by=%d);\n", reg, by);
142 PrintF(
" SetCurrentPositionFromEnd(by=%d);\n", by);
148 PrintF(
" SetRegister(register=%d, to=%d);\n", register_index, to);
155 PrintF(
" WriteCurrentPositionToRegister(register=%d,cp_offset=%d);\n",
163 PrintF(
" ClearRegister(from=%d, to=%d);\n", reg_from, reg_to);
169 PrintF(
" ReadCurrentPositionFromRegister(register=%d);\n", reg);
175 PrintF(
" WriteStackPointerToRegister(register=%d);\n", reg);
181 PrintF(
" ReadStackPointerFromRegister(register=%d);\n", reg);
187 Label* on_end_of_input,
190 const char* check_msg = check_bounds ?
"" :
" (unchecked)";
191 PrintF(
" LoadCurrentCharacter(cp_offset=%d, label[%08x]%s (%d chars));\n",
193 LabelToInt(on_end_of_input),
208 if (character_ >=
' ' && character_ <=
'~') {
210 buffer_[1] =
static_cast<char>(character_);
227 PrintF(
" CheckCharacterLT(c=0x%04x%s, label[%08x]);\n",
230 LabelToInt(on_less));
238 PrintF(
" CheckCharacterGT(c=0x%04x%s, label[%08x]);\n",
241 LabelToInt(on_greater));
248 PrintF(
" CheckCharacter(c=0x%04x%s, label[%08x]);\n",
251 LabelToInt(on_equal));
257 PrintF(
" CheckAtStart(label[%08x]);\n", LabelToInt(on_at_start));
263 PrintF(
" CheckNotAtStart(label[%08x]);\n", LabelToInt(on_not_at_start));
269 Label* on_not_equal) {
271 PrintF(
" CheckNotCharacter(c=0x%04x%s, label[%08x]);\n",
274 LabelToInt(on_not_equal));
284 PrintF(
" CheckCharacterAfterAnd(c=0x%04x%s, mask=0x%04x, label[%08x]);\n",
288 LabelToInt(on_equal));
296 Label* on_not_equal) {
298 PrintF(
" CheckNotCharacterAfterAnd(c=0x%04x%s, mask=0x%04x, label[%08x]);\n",
302 LabelToInt(on_not_equal));
311 Label* on_not_equal) {
312 PrintF(
" CheckNotCharacterAfterMinusAnd(c=0x%04x, minus=%04x, mask=0x%04x, "
317 LabelToInt(on_not_equal));
325 Label* on_not_in_range) {
328 PrintF(
" CheckCharacterInRange(from=0x%04x%s, to=0x%04x%s, label[%08x]);\n",
333 LabelToInt(on_not_in_range));
341 Label* on_in_range) {
345 " CheckCharacterNotInRange(from=0x%04x%s," " to=%04x%s, label[%08x]);\n",
350 LabelToInt(on_in_range));
357 PrintF(
" CheckBitInTable(label[%08x] ", LabelToInt(on_bit_set));
359 PrintF(
"%c", table->get(i) != 0 ?
'X' :
'.');
370 Label* on_no_match) {
371 PrintF(
" CheckNotBackReference(register=%d, label[%08x]);\n", start_reg,
372 LabelToInt(on_no_match));
379 Label* on_no_match) {
380 PrintF(
" CheckNotBackReferenceIgnoreCase(register=%d, label[%08x]);\n",
381 start_reg, LabelToInt(on_no_match));
389 bool check_end_of_string) {
391 check_end_of_string ?
"CheckCharacters" :
"CheckCharactersUnchecked");
392 for (
int i = 0; i < str.
length(); i++) {
395 PrintF(
"\", cp_offset=%d, label[%08x])\n",
396 cp_offset, LabelToInt(on_failure));
397 assembler_->
CheckCharacters(str, cp_offset, on_failure, check_end_of_string);
403 Label* on_no_match) {
406 PrintF(
" CheckSpecialCharacterClass(type='%c', label[%08x]): %s;\n",
408 LabelToInt(on_no_match),
409 supported ?
"true" :
"false");
415 int comparand, Label* if_lt) {
416 PrintF(
" IfRegisterLT(register=%d, number=%d, label[%08x]);\n",
417 register_index, comparand, LabelToInt(if_lt));
418 assembler_->
IfRegisterLT(register_index, comparand, if_lt);
424 PrintF(
" IfRegisterEqPos(register=%d, label[%08x]);\n",
425 register_index, LabelToInt(if_eq));
431 int comparand, Label* if_ge) {
432 PrintF(
" IfRegisterGE(register=%d, number=%d, label[%08x]);\n",
433 register_index, comparand, LabelToInt(if_ge));
434 assembler_->
IfRegisterGE(register_index, comparand, if_ge);
445 PrintF(
" GetCode(%s);\n", *(source->ToCString()));
446 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 CheckCharacters(Vector< const uc16 > str, int cp_offset, Label *on_failure, bool check_end_of_string)
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)
virtual void CheckCharacters(Vector< const uc16 > str, int cp_offset, Label *on_failure, bool check_eos)=0
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)