11cb0ef41Sopenharmony_ci// Copyright 2012 the V8 project authors. All rights reserved. 21cb0ef41Sopenharmony_ci// Use of this source code is governed by a BSD-style license that can be 31cb0ef41Sopenharmony_ci// found in the LICENSE file. 41cb0ef41Sopenharmony_ci 51cb0ef41Sopenharmony_ci#include "src/regexp/regexp-macro-assembler-tracer.h" 61cb0ef41Sopenharmony_ci 71cb0ef41Sopenharmony_ci#include "src/objects/fixed-array-inl.h" 81cb0ef41Sopenharmony_ci#include "src/objects/string.h" 91cb0ef41Sopenharmony_ci 101cb0ef41Sopenharmony_cinamespace v8 { 111cb0ef41Sopenharmony_cinamespace internal { 121cb0ef41Sopenharmony_ci 131cb0ef41Sopenharmony_ciRegExpMacroAssemblerTracer::RegExpMacroAssemblerTracer( 141cb0ef41Sopenharmony_ci Isolate* isolate, RegExpMacroAssembler* assembler) 151cb0ef41Sopenharmony_ci : RegExpMacroAssembler(isolate, assembler->zone()), assembler_(assembler) { 161cb0ef41Sopenharmony_ci PrintF("RegExpMacroAssembler%s();\n", 171cb0ef41Sopenharmony_ci ImplementationToString(assembler->Implementation())); 181cb0ef41Sopenharmony_ci} 191cb0ef41Sopenharmony_ci 201cb0ef41Sopenharmony_ciRegExpMacroAssemblerTracer::~RegExpMacroAssemblerTracer() = default; 211cb0ef41Sopenharmony_ci 221cb0ef41Sopenharmony_civoid RegExpMacroAssemblerTracer::AbortedCodeGeneration() { 231cb0ef41Sopenharmony_ci PrintF(" AbortedCodeGeneration\n"); 241cb0ef41Sopenharmony_ci assembler_->AbortedCodeGeneration(); 251cb0ef41Sopenharmony_ci} 261cb0ef41Sopenharmony_ci 271cb0ef41Sopenharmony_ci 281cb0ef41Sopenharmony_ci// This is used for printing out debugging information. It makes an integer 291cb0ef41Sopenharmony_ci// that is closely related to the address of an object. 301cb0ef41Sopenharmony_cistatic int LabelToInt(Label* label) { 311cb0ef41Sopenharmony_ci return static_cast<int>(reinterpret_cast<intptr_t>(label)); 321cb0ef41Sopenharmony_ci} 331cb0ef41Sopenharmony_ci 341cb0ef41Sopenharmony_ci 351cb0ef41Sopenharmony_civoid RegExpMacroAssemblerTracer::Bind(Label* label) { 361cb0ef41Sopenharmony_ci PrintF("label[%08x]: (Bind)\n", LabelToInt(label)); 371cb0ef41Sopenharmony_ci assembler_->Bind(label); 381cb0ef41Sopenharmony_ci} 391cb0ef41Sopenharmony_ci 401cb0ef41Sopenharmony_ci 411cb0ef41Sopenharmony_civoid RegExpMacroAssemblerTracer::AdvanceCurrentPosition(int by) { 421cb0ef41Sopenharmony_ci PrintF(" AdvanceCurrentPosition(by=%d);\n", by); 431cb0ef41Sopenharmony_ci assembler_->AdvanceCurrentPosition(by); 441cb0ef41Sopenharmony_ci} 451cb0ef41Sopenharmony_ci 461cb0ef41Sopenharmony_ci 471cb0ef41Sopenharmony_civoid RegExpMacroAssemblerTracer::CheckGreedyLoop(Label* label) { 481cb0ef41Sopenharmony_ci PrintF(" CheckGreedyLoop(label[%08x]);\n\n", LabelToInt(label)); 491cb0ef41Sopenharmony_ci assembler_->CheckGreedyLoop(label); 501cb0ef41Sopenharmony_ci} 511cb0ef41Sopenharmony_ci 521cb0ef41Sopenharmony_ci 531cb0ef41Sopenharmony_civoid RegExpMacroAssemblerTracer::PopCurrentPosition() { 541cb0ef41Sopenharmony_ci PrintF(" PopCurrentPosition();\n"); 551cb0ef41Sopenharmony_ci assembler_->PopCurrentPosition(); 561cb0ef41Sopenharmony_ci} 571cb0ef41Sopenharmony_ci 581cb0ef41Sopenharmony_ci 591cb0ef41Sopenharmony_civoid RegExpMacroAssemblerTracer::PushCurrentPosition() { 601cb0ef41Sopenharmony_ci PrintF(" PushCurrentPosition();\n"); 611cb0ef41Sopenharmony_ci assembler_->PushCurrentPosition(); 621cb0ef41Sopenharmony_ci} 631cb0ef41Sopenharmony_ci 641cb0ef41Sopenharmony_ci 651cb0ef41Sopenharmony_civoid RegExpMacroAssemblerTracer::Backtrack() { 661cb0ef41Sopenharmony_ci PrintF(" Backtrack();\n"); 671cb0ef41Sopenharmony_ci assembler_->Backtrack(); 681cb0ef41Sopenharmony_ci} 691cb0ef41Sopenharmony_ci 701cb0ef41Sopenharmony_ci 711cb0ef41Sopenharmony_civoid RegExpMacroAssemblerTracer::GoTo(Label* label) { 721cb0ef41Sopenharmony_ci PrintF(" GoTo(label[%08x]);\n\n", LabelToInt(label)); 731cb0ef41Sopenharmony_ci assembler_->GoTo(label); 741cb0ef41Sopenharmony_ci} 751cb0ef41Sopenharmony_ci 761cb0ef41Sopenharmony_ci 771cb0ef41Sopenharmony_civoid RegExpMacroAssemblerTracer::PushBacktrack(Label* label) { 781cb0ef41Sopenharmony_ci PrintF(" PushBacktrack(label[%08x]);\n", LabelToInt(label)); 791cb0ef41Sopenharmony_ci assembler_->PushBacktrack(label); 801cb0ef41Sopenharmony_ci} 811cb0ef41Sopenharmony_ci 821cb0ef41Sopenharmony_ci 831cb0ef41Sopenharmony_cibool RegExpMacroAssemblerTracer::Succeed() { 841cb0ef41Sopenharmony_ci bool restart = assembler_->Succeed(); 851cb0ef41Sopenharmony_ci PrintF(" Succeed();%s\n", restart ? " [restart for global match]" : ""); 861cb0ef41Sopenharmony_ci return restart; 871cb0ef41Sopenharmony_ci} 881cb0ef41Sopenharmony_ci 891cb0ef41Sopenharmony_ci 901cb0ef41Sopenharmony_civoid RegExpMacroAssemblerTracer::Fail() { 911cb0ef41Sopenharmony_ci PrintF(" Fail();"); 921cb0ef41Sopenharmony_ci assembler_->Fail(); 931cb0ef41Sopenharmony_ci} 941cb0ef41Sopenharmony_ci 951cb0ef41Sopenharmony_ci 961cb0ef41Sopenharmony_civoid RegExpMacroAssemblerTracer::PopRegister(int register_index) { 971cb0ef41Sopenharmony_ci PrintF(" PopRegister(register=%d);\n", register_index); 981cb0ef41Sopenharmony_ci assembler_->PopRegister(register_index); 991cb0ef41Sopenharmony_ci} 1001cb0ef41Sopenharmony_ci 1011cb0ef41Sopenharmony_ci 1021cb0ef41Sopenharmony_civoid RegExpMacroAssemblerTracer::PushRegister( 1031cb0ef41Sopenharmony_ci int register_index, 1041cb0ef41Sopenharmony_ci StackCheckFlag check_stack_limit) { 1051cb0ef41Sopenharmony_ci PrintF(" PushRegister(register=%d, %s);\n", 1061cb0ef41Sopenharmony_ci register_index, 1071cb0ef41Sopenharmony_ci check_stack_limit ? "check stack limit" : ""); 1081cb0ef41Sopenharmony_ci assembler_->PushRegister(register_index, check_stack_limit); 1091cb0ef41Sopenharmony_ci} 1101cb0ef41Sopenharmony_ci 1111cb0ef41Sopenharmony_ci 1121cb0ef41Sopenharmony_civoid RegExpMacroAssemblerTracer::AdvanceRegister(int reg, int by) { 1131cb0ef41Sopenharmony_ci PrintF(" AdvanceRegister(register=%d, by=%d);\n", reg, by); 1141cb0ef41Sopenharmony_ci assembler_->AdvanceRegister(reg, by); 1151cb0ef41Sopenharmony_ci} 1161cb0ef41Sopenharmony_ci 1171cb0ef41Sopenharmony_ci 1181cb0ef41Sopenharmony_civoid RegExpMacroAssemblerTracer::SetCurrentPositionFromEnd(int by) { 1191cb0ef41Sopenharmony_ci PrintF(" SetCurrentPositionFromEnd(by=%d);\n", by); 1201cb0ef41Sopenharmony_ci assembler_->SetCurrentPositionFromEnd(by); 1211cb0ef41Sopenharmony_ci} 1221cb0ef41Sopenharmony_ci 1231cb0ef41Sopenharmony_ci 1241cb0ef41Sopenharmony_civoid RegExpMacroAssemblerTracer::SetRegister(int register_index, int to) { 1251cb0ef41Sopenharmony_ci PrintF(" SetRegister(register=%d, to=%d);\n", register_index, to); 1261cb0ef41Sopenharmony_ci assembler_->SetRegister(register_index, to); 1271cb0ef41Sopenharmony_ci} 1281cb0ef41Sopenharmony_ci 1291cb0ef41Sopenharmony_ci 1301cb0ef41Sopenharmony_civoid RegExpMacroAssemblerTracer::WriteCurrentPositionToRegister(int reg, 1311cb0ef41Sopenharmony_ci int cp_offset) { 1321cb0ef41Sopenharmony_ci PrintF(" WriteCurrentPositionToRegister(register=%d,cp_offset=%d);\n", 1331cb0ef41Sopenharmony_ci reg, 1341cb0ef41Sopenharmony_ci cp_offset); 1351cb0ef41Sopenharmony_ci assembler_->WriteCurrentPositionToRegister(reg, cp_offset); 1361cb0ef41Sopenharmony_ci} 1371cb0ef41Sopenharmony_ci 1381cb0ef41Sopenharmony_ci 1391cb0ef41Sopenharmony_civoid RegExpMacroAssemblerTracer::ClearRegisters(int reg_from, int reg_to) { 1401cb0ef41Sopenharmony_ci PrintF(" ClearRegister(from=%d, to=%d);\n", reg_from, reg_to); 1411cb0ef41Sopenharmony_ci assembler_->ClearRegisters(reg_from, reg_to); 1421cb0ef41Sopenharmony_ci} 1431cb0ef41Sopenharmony_ci 1441cb0ef41Sopenharmony_ci 1451cb0ef41Sopenharmony_civoid RegExpMacroAssemblerTracer::ReadCurrentPositionFromRegister(int reg) { 1461cb0ef41Sopenharmony_ci PrintF(" ReadCurrentPositionFromRegister(register=%d);\n", reg); 1471cb0ef41Sopenharmony_ci assembler_->ReadCurrentPositionFromRegister(reg); 1481cb0ef41Sopenharmony_ci} 1491cb0ef41Sopenharmony_ci 1501cb0ef41Sopenharmony_ci 1511cb0ef41Sopenharmony_civoid RegExpMacroAssemblerTracer::WriteStackPointerToRegister(int reg) { 1521cb0ef41Sopenharmony_ci PrintF(" WriteStackPointerToRegister(register=%d);\n", reg); 1531cb0ef41Sopenharmony_ci assembler_->WriteStackPointerToRegister(reg); 1541cb0ef41Sopenharmony_ci} 1551cb0ef41Sopenharmony_ci 1561cb0ef41Sopenharmony_ci 1571cb0ef41Sopenharmony_civoid RegExpMacroAssemblerTracer::ReadStackPointerFromRegister(int reg) { 1581cb0ef41Sopenharmony_ci PrintF(" ReadStackPointerFromRegister(register=%d);\n", reg); 1591cb0ef41Sopenharmony_ci assembler_->ReadStackPointerFromRegister(reg); 1601cb0ef41Sopenharmony_ci} 1611cb0ef41Sopenharmony_ci 1621cb0ef41Sopenharmony_civoid RegExpMacroAssemblerTracer::LoadCurrentCharacterImpl( 1631cb0ef41Sopenharmony_ci int cp_offset, Label* on_end_of_input, bool check_bounds, int characters, 1641cb0ef41Sopenharmony_ci int eats_at_least) { 1651cb0ef41Sopenharmony_ci const char* check_msg = check_bounds ? "" : " (unchecked)"; 1661cb0ef41Sopenharmony_ci PrintF( 1671cb0ef41Sopenharmony_ci " LoadCurrentCharacter(cp_offset=%d, label[%08x]%s (%d chars) (eats at " 1681cb0ef41Sopenharmony_ci "least %d));\n", 1691cb0ef41Sopenharmony_ci cp_offset, LabelToInt(on_end_of_input), check_msg, characters, 1701cb0ef41Sopenharmony_ci eats_at_least); 1711cb0ef41Sopenharmony_ci assembler_->LoadCurrentCharacter(cp_offset, on_end_of_input, check_bounds, 1721cb0ef41Sopenharmony_ci characters, eats_at_least); 1731cb0ef41Sopenharmony_ci} 1741cb0ef41Sopenharmony_ci 1751cb0ef41Sopenharmony_cinamespace { 1761cb0ef41Sopenharmony_ci 1771cb0ef41Sopenharmony_ciclass PrintablePrinter { 1781cb0ef41Sopenharmony_ci public: 1791cb0ef41Sopenharmony_ci explicit PrintablePrinter(base::uc16 character) : character_(character) {} 1801cb0ef41Sopenharmony_ci 1811cb0ef41Sopenharmony_ci const char* operator*() { 1821cb0ef41Sopenharmony_ci if (character_ >= ' ' && character_ <= '~') { 1831cb0ef41Sopenharmony_ci buffer_[0] = '('; 1841cb0ef41Sopenharmony_ci buffer_[1] = static_cast<char>(character_); 1851cb0ef41Sopenharmony_ci buffer_[2] = ')'; 1861cb0ef41Sopenharmony_ci buffer_[3] = '\0'; 1871cb0ef41Sopenharmony_ci } else { 1881cb0ef41Sopenharmony_ci buffer_[0] = '\0'; 1891cb0ef41Sopenharmony_ci } 1901cb0ef41Sopenharmony_ci return &buffer_[0]; 1911cb0ef41Sopenharmony_ci } 1921cb0ef41Sopenharmony_ci 1931cb0ef41Sopenharmony_ci private: 1941cb0ef41Sopenharmony_ci base::uc16 character_; 1951cb0ef41Sopenharmony_ci char buffer_[4]; 1961cb0ef41Sopenharmony_ci}; 1971cb0ef41Sopenharmony_ci 1981cb0ef41Sopenharmony_ci} // namespace 1991cb0ef41Sopenharmony_ci 2001cb0ef41Sopenharmony_civoid RegExpMacroAssemblerTracer::CheckCharacterLT(base::uc16 limit, 2011cb0ef41Sopenharmony_ci Label* on_less) { 2021cb0ef41Sopenharmony_ci PrintablePrinter printable(limit); 2031cb0ef41Sopenharmony_ci PrintF(" CheckCharacterLT(c=0x%04x%s, label[%08x]);\n", 2041cb0ef41Sopenharmony_ci limit, 2051cb0ef41Sopenharmony_ci *printable, 2061cb0ef41Sopenharmony_ci LabelToInt(on_less)); 2071cb0ef41Sopenharmony_ci assembler_->CheckCharacterLT(limit, on_less); 2081cb0ef41Sopenharmony_ci} 2091cb0ef41Sopenharmony_ci 2101cb0ef41Sopenharmony_civoid RegExpMacroAssemblerTracer::CheckCharacterGT(base::uc16 limit, 2111cb0ef41Sopenharmony_ci Label* on_greater) { 2121cb0ef41Sopenharmony_ci PrintablePrinter printable(limit); 2131cb0ef41Sopenharmony_ci PrintF(" CheckCharacterGT(c=0x%04x%s, label[%08x]);\n", 2141cb0ef41Sopenharmony_ci limit, 2151cb0ef41Sopenharmony_ci *printable, 2161cb0ef41Sopenharmony_ci LabelToInt(on_greater)); 2171cb0ef41Sopenharmony_ci assembler_->CheckCharacterGT(limit, on_greater); 2181cb0ef41Sopenharmony_ci} 2191cb0ef41Sopenharmony_ci 2201cb0ef41Sopenharmony_civoid RegExpMacroAssemblerTracer::CheckCharacter(unsigned c, Label* on_equal) { 2211cb0ef41Sopenharmony_ci PrintablePrinter printable(c); 2221cb0ef41Sopenharmony_ci PrintF(" CheckCharacter(c=0x%04x%s, label[%08x]);\n", 2231cb0ef41Sopenharmony_ci c, 2241cb0ef41Sopenharmony_ci *printable, 2251cb0ef41Sopenharmony_ci LabelToInt(on_equal)); 2261cb0ef41Sopenharmony_ci assembler_->CheckCharacter(c, on_equal); 2271cb0ef41Sopenharmony_ci} 2281cb0ef41Sopenharmony_ci 2291cb0ef41Sopenharmony_civoid RegExpMacroAssemblerTracer::CheckAtStart(int cp_offset, 2301cb0ef41Sopenharmony_ci Label* on_at_start) { 2311cb0ef41Sopenharmony_ci PrintF(" CheckAtStart(cp_offset=%d, label[%08x]);\n", cp_offset, 2321cb0ef41Sopenharmony_ci LabelToInt(on_at_start)); 2331cb0ef41Sopenharmony_ci assembler_->CheckAtStart(cp_offset, on_at_start); 2341cb0ef41Sopenharmony_ci} 2351cb0ef41Sopenharmony_ci 2361cb0ef41Sopenharmony_civoid RegExpMacroAssemblerTracer::CheckNotAtStart(int cp_offset, 2371cb0ef41Sopenharmony_ci Label* on_not_at_start) { 2381cb0ef41Sopenharmony_ci PrintF(" CheckNotAtStart(cp_offset=%d, label[%08x]);\n", cp_offset, 2391cb0ef41Sopenharmony_ci LabelToInt(on_not_at_start)); 2401cb0ef41Sopenharmony_ci assembler_->CheckNotAtStart(cp_offset, on_not_at_start); 2411cb0ef41Sopenharmony_ci} 2421cb0ef41Sopenharmony_ci 2431cb0ef41Sopenharmony_ci 2441cb0ef41Sopenharmony_civoid RegExpMacroAssemblerTracer::CheckNotCharacter(unsigned c, 2451cb0ef41Sopenharmony_ci Label* on_not_equal) { 2461cb0ef41Sopenharmony_ci PrintablePrinter printable(c); 2471cb0ef41Sopenharmony_ci PrintF(" CheckNotCharacter(c=0x%04x%s, label[%08x]);\n", 2481cb0ef41Sopenharmony_ci c, 2491cb0ef41Sopenharmony_ci *printable, 2501cb0ef41Sopenharmony_ci LabelToInt(on_not_equal)); 2511cb0ef41Sopenharmony_ci assembler_->CheckNotCharacter(c, on_not_equal); 2521cb0ef41Sopenharmony_ci} 2531cb0ef41Sopenharmony_ci 2541cb0ef41Sopenharmony_ci 2551cb0ef41Sopenharmony_civoid RegExpMacroAssemblerTracer::CheckCharacterAfterAnd( 2561cb0ef41Sopenharmony_ci unsigned c, 2571cb0ef41Sopenharmony_ci unsigned mask, 2581cb0ef41Sopenharmony_ci Label* on_equal) { 2591cb0ef41Sopenharmony_ci PrintablePrinter printable(c); 2601cb0ef41Sopenharmony_ci PrintF(" CheckCharacterAfterAnd(c=0x%04x%s, mask=0x%04x, label[%08x]);\n", 2611cb0ef41Sopenharmony_ci c, 2621cb0ef41Sopenharmony_ci *printable, 2631cb0ef41Sopenharmony_ci mask, 2641cb0ef41Sopenharmony_ci LabelToInt(on_equal)); 2651cb0ef41Sopenharmony_ci assembler_->CheckCharacterAfterAnd(c, mask, on_equal); 2661cb0ef41Sopenharmony_ci} 2671cb0ef41Sopenharmony_ci 2681cb0ef41Sopenharmony_ci 2691cb0ef41Sopenharmony_civoid RegExpMacroAssemblerTracer::CheckNotCharacterAfterAnd( 2701cb0ef41Sopenharmony_ci unsigned c, 2711cb0ef41Sopenharmony_ci unsigned mask, 2721cb0ef41Sopenharmony_ci Label* on_not_equal) { 2731cb0ef41Sopenharmony_ci PrintablePrinter printable(c); 2741cb0ef41Sopenharmony_ci PrintF(" CheckNotCharacterAfterAnd(c=0x%04x%s, mask=0x%04x, label[%08x]);\n", 2751cb0ef41Sopenharmony_ci c, 2761cb0ef41Sopenharmony_ci *printable, 2771cb0ef41Sopenharmony_ci mask, 2781cb0ef41Sopenharmony_ci LabelToInt(on_not_equal)); 2791cb0ef41Sopenharmony_ci assembler_->CheckNotCharacterAfterAnd(c, mask, on_not_equal); 2801cb0ef41Sopenharmony_ci} 2811cb0ef41Sopenharmony_ci 2821cb0ef41Sopenharmony_civoid RegExpMacroAssemblerTracer::CheckNotCharacterAfterMinusAnd( 2831cb0ef41Sopenharmony_ci base::uc16 c, base::uc16 minus, base::uc16 mask, Label* on_not_equal) { 2841cb0ef41Sopenharmony_ci PrintF(" CheckNotCharacterAfterMinusAnd(c=0x%04x, minus=%04x, mask=0x%04x, " 2851cb0ef41Sopenharmony_ci "label[%08x]);\n", 2861cb0ef41Sopenharmony_ci c, 2871cb0ef41Sopenharmony_ci minus, 2881cb0ef41Sopenharmony_ci mask, 2891cb0ef41Sopenharmony_ci LabelToInt(on_not_equal)); 2901cb0ef41Sopenharmony_ci assembler_->CheckNotCharacterAfterMinusAnd(c, minus, mask, on_not_equal); 2911cb0ef41Sopenharmony_ci} 2921cb0ef41Sopenharmony_ci 2931cb0ef41Sopenharmony_civoid RegExpMacroAssemblerTracer::CheckCharacterInRange(base::uc16 from, 2941cb0ef41Sopenharmony_ci base::uc16 to, 2951cb0ef41Sopenharmony_ci Label* on_not_in_range) { 2961cb0ef41Sopenharmony_ci PrintablePrinter printable_from(from); 2971cb0ef41Sopenharmony_ci PrintablePrinter printable_to(to); 2981cb0ef41Sopenharmony_ci PrintF(" CheckCharacterInRange(from=0x%04x%s, to=0x%04x%s, label[%08x]);\n", 2991cb0ef41Sopenharmony_ci from, 3001cb0ef41Sopenharmony_ci *printable_from, 3011cb0ef41Sopenharmony_ci to, 3021cb0ef41Sopenharmony_ci *printable_to, 3031cb0ef41Sopenharmony_ci LabelToInt(on_not_in_range)); 3041cb0ef41Sopenharmony_ci assembler_->CheckCharacterInRange(from, to, on_not_in_range); 3051cb0ef41Sopenharmony_ci} 3061cb0ef41Sopenharmony_ci 3071cb0ef41Sopenharmony_civoid RegExpMacroAssemblerTracer::CheckCharacterNotInRange(base::uc16 from, 3081cb0ef41Sopenharmony_ci base::uc16 to, 3091cb0ef41Sopenharmony_ci Label* on_in_range) { 3101cb0ef41Sopenharmony_ci PrintablePrinter printable_from(from); 3111cb0ef41Sopenharmony_ci PrintablePrinter printable_to(to); 3121cb0ef41Sopenharmony_ci PrintF( 3131cb0ef41Sopenharmony_ci " CheckCharacterNotInRange(from=0x%04x%s," " to=%04x%s, label[%08x]);\n", 3141cb0ef41Sopenharmony_ci from, 3151cb0ef41Sopenharmony_ci *printable_from, 3161cb0ef41Sopenharmony_ci to, 3171cb0ef41Sopenharmony_ci *printable_to, 3181cb0ef41Sopenharmony_ci LabelToInt(on_in_range)); 3191cb0ef41Sopenharmony_ci assembler_->CheckCharacterNotInRange(from, to, on_in_range); 3201cb0ef41Sopenharmony_ci} 3211cb0ef41Sopenharmony_ci 3221cb0ef41Sopenharmony_cinamespace { 3231cb0ef41Sopenharmony_ci 3241cb0ef41Sopenharmony_civoid PrintRangeArray(const ZoneList<CharacterRange>* ranges) { 3251cb0ef41Sopenharmony_ci for (int i = 0; i < ranges->length(); i++) { 3261cb0ef41Sopenharmony_ci base::uc16 from = ranges->at(i).from(); 3271cb0ef41Sopenharmony_ci base::uc16 to = ranges->at(i).to(); 3281cb0ef41Sopenharmony_ci PrintablePrinter printable_from(from); 3291cb0ef41Sopenharmony_ci PrintablePrinter printable_to(to); 3301cb0ef41Sopenharmony_ci PrintF(" [from=0x%04x%s, to=%04x%s],\n", from, *printable_from, to, 3311cb0ef41Sopenharmony_ci *printable_to); 3321cb0ef41Sopenharmony_ci } 3331cb0ef41Sopenharmony_ci} 3341cb0ef41Sopenharmony_ci 3351cb0ef41Sopenharmony_ci} // namespace 3361cb0ef41Sopenharmony_ci 3371cb0ef41Sopenharmony_cibool RegExpMacroAssemblerTracer::CheckCharacterInRangeArray( 3381cb0ef41Sopenharmony_ci const ZoneList<CharacterRange>* ranges, Label* on_in_range) { 3391cb0ef41Sopenharmony_ci PrintF( 3401cb0ef41Sopenharmony_ci " CheckCharacterInRangeArray(\n" 3411cb0ef41Sopenharmony_ci " label[%08x]);\n", 3421cb0ef41Sopenharmony_ci LabelToInt(on_in_range)); 3431cb0ef41Sopenharmony_ci PrintRangeArray(ranges); 3441cb0ef41Sopenharmony_ci return assembler_->CheckCharacterInRangeArray(ranges, on_in_range); 3451cb0ef41Sopenharmony_ci} 3461cb0ef41Sopenharmony_ci 3471cb0ef41Sopenharmony_cibool RegExpMacroAssemblerTracer::CheckCharacterNotInRangeArray( 3481cb0ef41Sopenharmony_ci const ZoneList<CharacterRange>* ranges, Label* on_not_in_range) { 3491cb0ef41Sopenharmony_ci PrintF( 3501cb0ef41Sopenharmony_ci " CheckCharacterNotInRangeArray(\n" 3511cb0ef41Sopenharmony_ci " label[%08x]);\n", 3521cb0ef41Sopenharmony_ci LabelToInt(on_not_in_range)); 3531cb0ef41Sopenharmony_ci PrintRangeArray(ranges); 3541cb0ef41Sopenharmony_ci return assembler_->CheckCharacterNotInRangeArray(ranges, on_not_in_range); 3551cb0ef41Sopenharmony_ci} 3561cb0ef41Sopenharmony_ci 3571cb0ef41Sopenharmony_civoid RegExpMacroAssemblerTracer::CheckBitInTable( 3581cb0ef41Sopenharmony_ci Handle<ByteArray> table, Label* on_bit_set) { 3591cb0ef41Sopenharmony_ci PrintF(" CheckBitInTable(label[%08x] ", LabelToInt(on_bit_set)); 3601cb0ef41Sopenharmony_ci for (int i = 0; i < kTableSize; i++) { 3611cb0ef41Sopenharmony_ci PrintF("%c", table->get(i) != 0 ? 'X' : '.'); 3621cb0ef41Sopenharmony_ci if (i % 32 == 31 && i != kTableMask) { 3631cb0ef41Sopenharmony_ci PrintF("\n "); 3641cb0ef41Sopenharmony_ci } 3651cb0ef41Sopenharmony_ci } 3661cb0ef41Sopenharmony_ci PrintF(");\n"); 3671cb0ef41Sopenharmony_ci assembler_->CheckBitInTable(table, on_bit_set); 3681cb0ef41Sopenharmony_ci} 3691cb0ef41Sopenharmony_ci 3701cb0ef41Sopenharmony_ci 3711cb0ef41Sopenharmony_civoid RegExpMacroAssemblerTracer::CheckNotBackReference(int start_reg, 3721cb0ef41Sopenharmony_ci bool read_backward, 3731cb0ef41Sopenharmony_ci Label* on_no_match) { 3741cb0ef41Sopenharmony_ci PrintF(" CheckNotBackReference(register=%d, %s, label[%08x]);\n", start_reg, 3751cb0ef41Sopenharmony_ci read_backward ? "backward" : "forward", LabelToInt(on_no_match)); 3761cb0ef41Sopenharmony_ci assembler_->CheckNotBackReference(start_reg, read_backward, on_no_match); 3771cb0ef41Sopenharmony_ci} 3781cb0ef41Sopenharmony_ci 3791cb0ef41Sopenharmony_civoid RegExpMacroAssemblerTracer::CheckNotBackReferenceIgnoreCase( 3801cb0ef41Sopenharmony_ci int start_reg, bool read_backward, bool unicode, Label* on_no_match) { 3811cb0ef41Sopenharmony_ci PrintF(" CheckNotBackReferenceIgnoreCase(register=%d, %s %s, label[%08x]);\n", 3821cb0ef41Sopenharmony_ci start_reg, read_backward ? "backward" : "forward", 3831cb0ef41Sopenharmony_ci unicode ? "unicode" : "non-unicode", LabelToInt(on_no_match)); 3841cb0ef41Sopenharmony_ci assembler_->CheckNotBackReferenceIgnoreCase(start_reg, read_backward, unicode, 3851cb0ef41Sopenharmony_ci on_no_match); 3861cb0ef41Sopenharmony_ci} 3871cb0ef41Sopenharmony_ci 3881cb0ef41Sopenharmony_civoid RegExpMacroAssemblerTracer::CheckPosition(int cp_offset, 3891cb0ef41Sopenharmony_ci Label* on_outside_input) { 3901cb0ef41Sopenharmony_ci PrintF(" CheckPosition(cp_offset=%d, label[%08x]);\n", cp_offset, 3911cb0ef41Sopenharmony_ci LabelToInt(on_outside_input)); 3921cb0ef41Sopenharmony_ci assembler_->CheckPosition(cp_offset, on_outside_input); 3931cb0ef41Sopenharmony_ci} 3941cb0ef41Sopenharmony_ci 3951cb0ef41Sopenharmony_cibool RegExpMacroAssemblerTracer::CheckSpecialCharacterClass( 3961cb0ef41Sopenharmony_ci StandardCharacterSet type, Label* on_no_match) { 3971cb0ef41Sopenharmony_ci bool supported = assembler_->CheckSpecialCharacterClass(type, 3981cb0ef41Sopenharmony_ci on_no_match); 3991cb0ef41Sopenharmony_ci PrintF(" CheckSpecialCharacterClass(type='%c', label[%08x]): %s;\n", 4001cb0ef41Sopenharmony_ci static_cast<char>(type), LabelToInt(on_no_match), 4011cb0ef41Sopenharmony_ci supported ? "true" : "false"); 4021cb0ef41Sopenharmony_ci return supported; 4031cb0ef41Sopenharmony_ci} 4041cb0ef41Sopenharmony_ci 4051cb0ef41Sopenharmony_civoid RegExpMacroAssemblerTracer::IfRegisterLT(int register_index, 4061cb0ef41Sopenharmony_ci int comparand, Label* if_lt) { 4071cb0ef41Sopenharmony_ci PrintF(" IfRegisterLT(register=%d, number=%d, label[%08x]);\n", 4081cb0ef41Sopenharmony_ci register_index, comparand, LabelToInt(if_lt)); 4091cb0ef41Sopenharmony_ci assembler_->IfRegisterLT(register_index, comparand, if_lt); 4101cb0ef41Sopenharmony_ci} 4111cb0ef41Sopenharmony_ci 4121cb0ef41Sopenharmony_ci 4131cb0ef41Sopenharmony_civoid RegExpMacroAssemblerTracer::IfRegisterEqPos(int register_index, 4141cb0ef41Sopenharmony_ci Label* if_eq) { 4151cb0ef41Sopenharmony_ci PrintF(" IfRegisterEqPos(register=%d, label[%08x]);\n", 4161cb0ef41Sopenharmony_ci register_index, LabelToInt(if_eq)); 4171cb0ef41Sopenharmony_ci assembler_->IfRegisterEqPos(register_index, if_eq); 4181cb0ef41Sopenharmony_ci} 4191cb0ef41Sopenharmony_ci 4201cb0ef41Sopenharmony_ci 4211cb0ef41Sopenharmony_civoid RegExpMacroAssemblerTracer::IfRegisterGE(int register_index, 4221cb0ef41Sopenharmony_ci int comparand, Label* if_ge) { 4231cb0ef41Sopenharmony_ci PrintF(" IfRegisterGE(register=%d, number=%d, label[%08x]);\n", 4241cb0ef41Sopenharmony_ci register_index, comparand, LabelToInt(if_ge)); 4251cb0ef41Sopenharmony_ci assembler_->IfRegisterGE(register_index, comparand, if_ge); 4261cb0ef41Sopenharmony_ci} 4271cb0ef41Sopenharmony_ci 4281cb0ef41Sopenharmony_ci 4291cb0ef41Sopenharmony_ciRegExpMacroAssembler::IrregexpImplementation 4301cb0ef41Sopenharmony_ci RegExpMacroAssemblerTracer::Implementation() { 4311cb0ef41Sopenharmony_ci return assembler_->Implementation(); 4321cb0ef41Sopenharmony_ci} 4331cb0ef41Sopenharmony_ci 4341cb0ef41Sopenharmony_ci 4351cb0ef41Sopenharmony_ciHandle<HeapObject> RegExpMacroAssemblerTracer::GetCode(Handle<String> source) { 4361cb0ef41Sopenharmony_ci PrintF(" GetCode(%s);\n", source->ToCString().get()); 4371cb0ef41Sopenharmony_ci return assembler_->GetCode(source); 4381cb0ef41Sopenharmony_ci} 4391cb0ef41Sopenharmony_ci 4401cb0ef41Sopenharmony_ci} // namespace internal 4411cb0ef41Sopenharmony_ci} // namespace v8 442