Changeset 38669 in webkit
- Timestamp:
- Nov 21, 2008 11:31:34 AM (15 years ago)
- Location:
- trunk/JavaScriptCore
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/ChangeLog
r38666 r38669 1 2008-11-21 Geoffrey Garen <ggaren@apple.com> 2 3 Reviewed by Sam Weinig. 4 5 A little more RegExp refactoring. 6 7 Moved all assembly from WREC.cpp into WRECGenerator helper functions. 8 This should help with portability and readability. 9 10 Removed ASSERTs after calls to executableCopy(), and changed 11 executableCopy() to ASSERT instead. 12 13 * assembler/X86Assembler.h: 14 (JSC::X86Assembler::executableCopy): 15 * jit/JIT.cpp: 16 (JSC::JIT::privateCompile): 17 (JSC::JIT::privateCompileGetByIdSelf): 18 (JSC::JIT::privateCompileGetByIdProto): 19 (JSC::JIT::privateCompileGetByIdChain): 20 (JSC::JIT::privateCompilePutByIdReplace): 21 (JSC::JIT::privateCompilePutByIdTransition): 22 (JSC::JIT::privateCompileCTIMachineTrampolines): 23 (JSC::JIT::privateCompilePatchGetArrayLength): 24 * wrec/WREC.cpp: 25 (JSC::WREC::compileRegExp): 26 * wrec/WRECGenerator.cpp: 27 (JSC::WREC::Generator::generateEnter): 28 (JSC::WREC::Generator::generateReturnSuccess): 29 (JSC::WREC::Generator::generateSaveIndex): 30 (JSC::WREC::Generator::generateIncrementIndex): 31 (JSC::WREC::Generator::generateLoopIfNotEndOfInput): 32 (JSC::WREC::Generator::generateReturnFailure): 33 * wrec/WRECGenerator.h: 34 * wrec/WRECParser.h: 35 (JSC::WREC::Parser::ignoreCase): 36 (JSC::WREC::Parser::generator): 37 1 38 2008-11-21 Alexey Proskuryakov <ap@webkit.org> 2 39 -
trunk/JavaScriptCore/assembler/X86Assembler.h
r38641 r38669 1007 1007 } 1008 1008 1009 void* executableCopy() 1010 { 1011 return m_buffer->executableCopy(); 1009 void* executableCopy() 1010 { 1011 void* copy = m_buffer->executableCopy(); 1012 ASSERT(copy); 1013 return copy; 1012 1014 } 1013 1015 -
trunk/JavaScriptCore/jit/JIT.cpp
r38652 r38669 3060 3060 3061 3061 void* code = __ executableCopy(); 3062 ASSERT(code);3063 3062 3064 3063 // Translate vPC offsets into addresses in JIT generated code, for switch tables. … … 3132 3131 3133 3132 void* code = __ executableCopy(); 3134 ASSERT(code);3135 3133 3136 3134 X86Assembler::link(code, failureCases1, reinterpret_cast<void*>(Interpreter::cti_op_get_by_id_self_fail)); … … 3175 3173 3176 3174 void* code = __ executableCopy(); 3177 ASSERT(code);3178 3175 3179 3176 // Use the repatch information to link the failure cases back to the original slow case routine. … … 3216 3213 3217 3214 void* code = __ executableCopy(); 3218 ASSERT(code);3219 3215 3220 3216 #if USE(CTI_REPATCH_PIC) … … 3259 3255 3260 3256 void* code = __ executableCopy(); 3261 ASSERT(code);3262 3257 3263 3258 // Use the repatch information to link the failure cases back to the original slow case routine. … … 3313 3308 3314 3309 void* code = __ executableCopy(); 3315 ASSERT(code);3316 3310 3317 3311 for (unsigned i = 0; i < bucketsOfFail.size(); ++i) … … 3336 3330 3337 3331 void* code = __ executableCopy(); 3338 ASSERT(code);3339 3332 3340 3333 X86Assembler::link(code, failureCases1, reinterpret_cast<void*>(Interpreter::cti_op_put_by_id_fail)); … … 3432 3425 3433 3426 void* code = __ executableCopy(); 3434 ASSERT(code);3435 3427 3436 3428 if (failureCases.size()) … … 3641 3633 3642 3634 void* code = __ executableCopy(); 3643 ASSERT(code);3644 3635 3645 3636 X86Assembler::link(code, array_failureCases1, reinterpret_cast<void*>(Interpreter::cti_op_get_by_id_array_fail)); … … 3722 3713 3723 3714 void* code = __ executableCopy(); 3724 ASSERT(code);3725 3715 3726 3716 // Use the repatch information to link the failure cases back to the original slow case routine. -
trunk/JavaScriptCore/wrec/WREC.cpp
r38641 r38669 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 #else50 static const int outputParameter = 16;51 #endif52 53 46 CompiledRegExp compileRegExp(Interpreter* interpreter, const UString& pattern, unsigned* numSubpatterns_ptr, const char** error_ptr, bool ignoreCase, bool multiline) 54 47 { … … 60 53 X86Assembler assembler(interpreter->assemblerBuffer()); 61 54 Parser parser(pattern, ignoreCase, multiline, assembler); 62 63 // (0) Setup: 64 // Preserve callee save regs and initialize output register. 65 __ convertToFastCall(); 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); 55 Generator& generator = parser.generator(); 56 JmpSrcVector failures; 70 57 71 #ifndef NDEBUG 72 // ASSERT that the output register is not null. 73 __ testl_rr(Generator::output, Generator::output); 74 X86Assembler::JmpSrc outputNotNull = __ jne(); 75 __ int3(); 76 __ link(outputNotNull, __ label()); 77 #endif 78 79 // Restart point for top-level disjunction. 58 generator.generateEnter(); 59 generator.generateSaveIndex(); 60 80 61 Generator::JmpDst beginPattern = __ label(); 81 82 // (1) Parse Pattern:83 84 JmpSrcVector failures;85 62 if (!parser.parsePattern(failures)) { 86 63 *error_ptr = "Regular expression malformed."; 87 64 return 0; 88 65 } 66 generator.generateReturnSuccess(); 89 67 90 // (2) Success:91 // Set return value & pop registers from the stack.92 93 __ popl_r(X86::eax);94 __ movl_rm(X86::eax, Generator::output); // match begin95 __ movl_rm(Generator::index, 4, Generator::output); // match end96 __ popl_r(Generator::character);97 __ popl_r(Generator::output);98 __ ret();99 100 // (3) Failure:101 // All failures in the top-level disjunction link to here.102 68 __ link(failures, __ label()); 103 104 // Move to the next input character and try again. 105 __ movl_mr(X86::esp, Generator::index); 106 __ addl_i8r(1, Generator::index); 107 __ movl_rm(Generator::index, X86::esp); 108 __ cmpl_rr(Generator::length, Generator::index); 109 __ link(__ jle(), beginPattern); 110 111 // No more input characters: return failure. 112 __ addl_i8r(4, X86::esp); 113 __ movl_i32r(-1, X86::eax); 114 __ popl_r(Generator::character); 115 __ popl_r(Generator::output); 116 __ ret(); 69 generator.generateIncrementIndex(); 70 generator.generateLoopIfNotEndOfInput(beginPattern); 71 generator.generateReturnFailure(); 117 72 118 73 *numSubpatterns_ptr = parser.numSubpatterns(); 119 120 void* code = __ executableCopy(); 121 ASSERT(code); 122 return reinterpret_cast<CompiledRegExp>(code); 74 return reinterpret_cast<CompiledRegExp>(__ executableCopy()); 123 75 } 124 76 -
trunk/JavaScriptCore/wrec/WRECGenerator.cpp
r38641 r38669 41 41 namespace JSC { namespace WREC { 42 42 43 #if COMPILER(MSVC) 44 // MSVC has 3 extra arguments on the stack because it doesn't use the register calling convention. 45 static const int outputParameter = 16 + sizeof(const UChar*) + sizeof(unsigned) + sizeof(unsigned); 46 #else 47 static const int outputParameter = 16; 48 #endif 49 50 void Generator::generateEnter() 51 { 52 __ convertToFastCall(); 53 54 // Save callee save registers. 55 __ pushl_r(Generator::output); 56 __ pushl_r(Generator::character); 57 58 // Initialize output register. 59 __ movl_mr(outputParameter, X86::esp, Generator::output); 60 61 #ifndef NDEBUG 62 // ASSERT that the output register is not null. 63 __ testl_rr(Generator::output, Generator::output); 64 X86Assembler::JmpSrc outputNotNull = __ jne(); 65 __ int3(); 66 __ link(outputNotNull, __ label()); 67 #endif 68 } 69 70 void Generator::generateReturnSuccess() 71 { 72 // Set return value. 73 __ popl_r(X86::eax); // match begin 74 __ movl_rm(X86::eax, Generator::output); 75 __ movl_rm(Generator::index, 4, Generator::output); // match end 76 77 // Restore callee save registers. 78 __ popl_r(Generator::character); 79 __ popl_r(Generator::output); 80 __ ret(); 81 } 82 83 void Generator::generateSaveIndex() 84 { 85 __ pushl_r(Generator::index); 86 } 87 88 void Generator::generateIncrementIndex() 89 { 90 __ movl_mr(X86::esp, Generator::index); 91 __ addl_i8r(1, Generator::index); 92 __ movl_rm(Generator::index, X86::esp); 93 } 94 95 void Generator::generateLoopIfNotEndOfInput(JmpDst target) 96 { 97 __ cmpl_rr(Generator::length, Generator::index); 98 __ link(__ jle(), target); 99 } 100 101 void Generator::generateReturnFailure() 102 { 103 __ addl_i8r(4, X86::esp); 104 __ movl_i32r(-1, X86::eax); 105 __ popl_r(Generator::character); 106 __ popl_r(Generator::output); 107 __ ret(); 108 } 109 43 110 void Generator::generateBacktrack1() 44 111 { -
trunk/JavaScriptCore/wrec/WRECGenerator.h
r38621 r38669 61 61 static const RegisterID output = X86::edi; 62 62 static const RegisterID repeatCount = X86::ebx; // How many times the current atom repeats in the current match. 63 64 void generateEnter(); 65 void generateSaveIndex(); 66 void generateIncrementIndex(); 67 void generateLoopIfNotEndOfInput(JmpDst); 68 void generateReturnSuccess(); 69 void generateReturnFailure(); 63 70 64 71 void generateGreedyQuantifier(JmpSrcVector& failures, GenerateAtomFunctor& functor, unsigned min, unsigned max); -
trunk/JavaScriptCore/wrec/WRECParser.h
r38641 r38669 160 160 161 161 bool ignoreCase() { return m_ignoreCase; } 162 bool multiline() { return m_multiline; } 162 163 163 bool multiline() { return m_multiline; }164 Generator& generator() { return m_generator; } 164 165 165 166 private:
Note: See TracChangeset
for help on using the changeset viewer.