Index: runtime/vm/intrinsifier_ia32.cc |
diff --git a/runtime/vm/intrinsifier_ia32.cc b/runtime/vm/intrinsifier_ia32.cc |
index 6e24ad845dd1c0ccf5158b1bb2f25db8a77d20ee..79e54d403581108bc22f78c23ea2684f77b33ff9 100644 |
--- a/runtime/vm/intrinsifier_ia32.cc |
+++ b/runtime/vm/intrinsifier_ia32.cc |
@@ -1700,6 +1700,95 @@ 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 == kTwoByteStringCid || |
+ cid == kExternalOneByteStringCid || 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 (one- or two-byte 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 if the string is a one byte string. |
+ |
+ __ 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); |
+ |
+ 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 (one- or two-byte string) function. |
+ |
+ __ Bind(&fallthrough); |
+ |
+ // Registers have been set up for the lazy compile stub at this point. |
+ // It expects the function in EAX while; EDX and ECX are unused. |
+ |
srdjan
2014/09/22 22:34:07
Registers EDX (arguments descriptor) and ECX (func
jgruber1
2014/09/23 10:58:47
Done.
|
+ // 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(); |