Index: runtime/vm/intrinsifier_ia32.cc |
diff --git a/runtime/vm/intrinsifier_ia32.cc b/runtime/vm/intrinsifier_ia32.cc |
index 6e24ad845dd1c0ccf5158b1bb2f25db8a77d20ee..e8584a967517829bc9c32513bebd030925c458f9 100644 |
--- a/runtime/vm/intrinsifier_ia32.cc |
+++ b/runtime/vm/intrinsifier_ia32.cc |
@@ -1700,6 +1700,99 @@ void Intrinsifier::TwoByteString_equality(Assembler* assembler) { |
} |
+static void GenerateRegexpSpecializationFor( |
+ Assembler* assembler, |
+ intptr_t cid, |
+ Label* entry, |
+ Label* exit, |
+ bool jump_kind = Assembler::kFarJump) { |
+ ASSERT(cid == kOneByteStringCid || cid == kExternalOneByteStringCid || |
+ cid == kTwoByteStringCid || cid == kExternalTwoByteStringCid); |
+ |
+ __ Bind(entry); |
+ |
+ // The passed string is of class cid. |
+ |
+ __ movl(EAX, FieldAddress(EBX, JSRegExp::function_offset(cid))); |
+ |
+ // Set the subject if it is currently unset. |
+ |
+ __ LoadObject(ECX, Object::null_object()); |
+ __ cmpl(ECX, FieldAddress(EBX, JSRegExp::subject_offset(cid))); |
+ __ j(NOT_EQUAL, exit, jump_kind); |
+ |
+ __ StoreIntoObject(EBX, |
+ FieldAddress(EBX, JSRegExp::subject_offset(cid)), |
+ EDI, |
+ false); |
+ |
+ __ jmp(exit, jump_kind); |
+} |
+ |
+ |
+void Intrinsifier::JSRegExp_ExecuteMatch(Assembler* assembler) { |
+ Label is_one_byte_string; |
+ Label is_two_byte_string; |
+ Label is_external_one_byte_string; |
+ Label is_external_two_byte_string; |
+ Label fallthrough; |
+ |
+ static const intptr_t kRegExpParamOffset = + 3 * kWordSize; |
+ static const intptr_t kStringParamOffset = + 2 * kWordSize; |
+ // const Smi& start_index is located at (+ 1 * kWordSize). |
+ |
+ // Register assignments are as follows: |
+ // EAX: The appropriate specialized matcher function. |
+ // EBX: The regexp object. |
+ // ECX: Temp. |
+ // EDI: Temp, Pointer to the function's code which we then tail-call. |
+ |
+ __ movl(EBX, Address(ESP, kRegExpParamOffset)); |
+ __ movl(EDI, Address(ESP, kStringParamOffset)); |
+ |
+ // Check which string class we have been passed. |
+ |
+ __ CompareClassId(EDI, kOneByteStringCid, ECX); |
+ __ j(EQUAL, &is_one_byte_string); |
+ |
+ __ CompareClassId(EDI, kTwoByteStringCid, ECX); |
+ __ j(EQUAL, &is_two_byte_string); |
+ |
+ __ CompareClassId(EDI, kExternalOneByteStringCid, ECX); |
+ __ j(EQUAL, &is_external_one_byte_string); |
+ |
+ __ CompareClassId(EDI, kExternalTwoByteStringCid, ECX); |
+ __ j(EQUAL, &is_external_two_byte_string); |
+ |
+ __ Stop("Unexpected class id"); |
+ |
+ GenerateRegexpSpecializationFor(assembler, kExternalTwoByteStringCid, |
+ &is_external_two_byte_string, &fallthrough); |
+ GenerateRegexpSpecializationFor(assembler, kExternalOneByteStringCid, |
+ &is_external_one_byte_string, &fallthrough); |
+ GenerateRegexpSpecializationFor(assembler, kTwoByteStringCid, |
+ &is_two_byte_string, &fallthrough, |
+ Assembler::kNearJump); |
+ GenerateRegexpSpecializationFor(assembler, kOneByteStringCid, |
+ &is_one_byte_string, &fallthrough, |
+ Assembler::kNearJump); |
+ |
+ // EAX contains the appropriate specialized function. |
+ |
+ __ Bind(&fallthrough); |
+ |
+ // Registers have been set up for the lazy compile stub at this point. |
+ // It expects the function in EAX, the argument descriptor in EDX, and |
+ // IC-Data in ECX. Irregexp generated functions do not use either the |
Florian Schneider
2014/10/01 17:04:13
ECX is destroyed by GenerateRegexpSpecializationFo
|
+ // arguments descriptor or IC-Data, and hence these are not set here. |
+ |
+ // Tail-call the function. |
+ __ movl(EDI, FieldAddress(EAX, Function::instructions_offset())); |
+ __ addl(EDI, Immediate(Instructions::HeaderSize() - kHeapObjectTag)); |
+ __ jmp(EDI); |
+} |
+ |
+ |
// On stack: user tag (+1), return-address (+0). |
void Intrinsifier::UserTag_makeCurrent(Assembler* assembler) { |
Isolate* isolate = Isolate::Current(); |