Changeset 38621 in webkit for trunk/JavaScriptCore/wrec/WREC.cpp
- Timestamp:
- Nov 20, 2008, 9:38:50 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/wrec/WREC.cpp
r38600 r38621 44 44 static const int MaxPatternSize = (1 << 16); 45 45 46 #if COMPILER(MSVC) 47 // MSVC has 3 extra arguments on the stack because it doesn't use the register calling convention. 48 static const int outputParameter = 16 + sizeof(const UChar*) + sizeof(unsigned) + sizeof(unsigned); 49 #else 50 static const int outputParameter = 16; 51 #endif 52 46 53 CompiledRegExp compileRegExp(Interpreter* interpreter, const UString& pattern, unsigned* numSubpatterns_ptr, const char** error_ptr, bool ignoreCase, bool multiline) 47 54 { … … 54 61 Parser parser(pattern, ignoreCase, multiline, assembler); 55 62 63 // (0) Setup: 64 // Preserve callee save regs and initialize output register. 56 65 __ convertToFastCall(); 57 // (0) Setup: 58 // Preserve regs & initialize outputRegister. 59 __ pushl_r(Generator::outputRegister); 60 __ pushl_r(Generator::currentValueRegister); 61 // push pos onto the stack, both to preserve and as a parameter available to parseDisjunction 62 __ pushl_r(Generator::currentPositionRegister); 63 // load output pointer 64 __ movl_mr(16 65 #if COMPILER(MSVC) 66 + 3 * sizeof(void*) 67 #endif 68 , X86::esp, Generator::outputRegister); 66 __ pushl_r(Generator::output); 67 __ pushl_r(Generator::character); 68 __ pushl_r(Generator::index); // load index into TOS as an argument to the top-level disjunction. 69 __ movl_mr(outputParameter, X86::esp, Generator::output); 69 70 70 71 #ifndef NDEBUG 71 72 // ASSERT that the output register is not null. 72 __ testl_rr(Generator::output Register, Generator::outputRegister);73 X86Assembler::JmpSrc output RegisterNotNull = __ jne();73 __ testl_rr(Generator::output, Generator::output); 74 X86Assembler::JmpSrc outputNotNull = __ jne(); 74 75 __ int3(); 75 __ link(output RegisterNotNull, __ label());76 __ link(outputNotNull, __ label()); 76 77 #endif 77 78 78 // restart point on match fail.79 Generator::JmpDst nextLabel= __ label();79 // Restart point for top-level disjunction. 80 Generator::JmpDst beginPattern = __ label(); 80 81 81 // (1) Parse Disjunction:82 82 // (1) Parse Pattern: 83 83 84 JmpSrcVector failures; 84 parser.parseDisjunction(failures); 85 86 // Parsing the disjunction should fully consume the pattern. 87 if (!parser.atEndOfPattern() || parser.error()) { 85 if (!parser.parsePattern(failures)) { 88 86 *error_ptr = "Regular expression malformed."; 89 87 return 0; … … 93 91 // Set return value & pop registers from the stack. 94 92 95 __ movl_rm(Generator::currentPositionRegister, 4, Generator::outputRegister);96 93 __ popl_r(X86::eax); 97 __ movl_rm(X86::eax, Generator::outputRegister); 98 __ popl_r(Generator::currentValueRegister); 99 __ popl_r(Generator::outputRegister); 94 __ movl_rm(X86::eax, Generator::output); // match begin 95 __ movl_rm(Generator::index, 4, Generator::output); // match end 96 __ popl_r(Generator::character); 97 __ popl_r(Generator::output); 100 98 __ ret(); 101 99 102 100 // (3) Failure: 103 // All fails link to here.104 Generator::JmpDst here = __ label();101 // All top-level failures link to here. 102 Generator::JmpDst failure = __ label(); 105 103 for (unsigned i = 0; i < failures.size(); ++i) 106 __ link(failures[i], here);104 __ link(failures[i], failure); 107 105 failures.clear(); 108 106 109 107 // Move to the next input character and try again. 110 __ movl_mr(X86::esp, Generator:: currentPositionRegister);111 __ addl_i8r(1, Generator:: currentPositionRegister);112 __ movl_rm(Generator:: currentPositionRegister, X86::esp);113 __ cmpl_rr(Generator::length Register, Generator::currentPositionRegister);114 __ link(__ jle(), nextLabel);108 __ movl_mr(X86::esp, Generator::index); 109 __ addl_i8r(1, Generator::index); 110 __ movl_rm(Generator::index, X86::esp); 111 __ cmpl_rr(Generator::length, Generator::index); 112 __ link(__ jle(), beginPattern); 115 113 116 114 // No more input characters: return failure. 117 115 __ addl_i8r(4, X86::esp); 118 116 __ movl_i32r(-1, X86::eax); 119 __ popl_r(Generator::c urrentValueRegister);120 __ popl_r(Generator::output Register);117 __ popl_r(Generator::character); 118 __ popl_r(Generator::output); 121 119 __ ret(); 122 120
Note:
See TracChangeset
for help on using the changeset viewer.