Index: runtime/vm/intrinsifier_mips.cc |
diff --git a/runtime/vm/intrinsifier_mips.cc b/runtime/vm/intrinsifier_mips.cc |
index 736621b24d64185d1dac70232c9fe9f56c8e9b8b..835cb04bbfd780e15fd2d8b2b62b8dac068cdea5 100644 |
--- a/runtime/vm/intrinsifier_mips.cc |
+++ b/runtime/vm/intrinsifier_mips.cc |
@@ -1640,6 +1640,92 @@ void Intrinsifier::TwoByteString_equality(Assembler* assembler) { |
StringEquality(assembler, kTwoByteStringCid); |
} |
+ |
+static void GenerateRegexpSpecializationFor( |
+ Assembler* assembler, |
+ intptr_t cid, |
+ Label* entry, |
+ Label* exit) { |
+ ASSERT(cid == kOneByteStringCid || cid == kExternalOneByteStringCid || |
+ cid == kTwoByteStringCid || cid == kExternalTwoByteStringCid); |
+ |
+ __ Bind(entry); |
+ |
+ // The passed string is of class cid. |
+ |
+ __ lw(T0, FieldAddress(T1, JSRegExp::function_offset(cid))); |
+ |
+ // Set the subject if it is currently unset. |
+ |
+ __ LoadObject(T2, Object::null_object()); |
+ __ lw(T4, FieldAddress(T1, JSRegExp::subject_offset(cid))); |
+ __ bnel(T2, T4, exit); |
+ |
+ __ StoreIntoObject(T1, |
+ FieldAddress(T1, JSRegExp::subject_offset(cid)), |
+ T3, |
+ false); |
+ |
+ __ b(exit); |
+} |
+ |
+ |
+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 = + 2 * kWordSize; |
+ static const intptr_t kStringParamOffset = + 1 * kWordSize; |
+ // const Smi& start_index is located at (+ 0 * kWordSize). |
+ |
+ // Register assignments are as follows: |
+ // T0: The appropriate specialized matcher function. |
+ // T1: The regexp object. |
+ // T2: Temp. |
+ // T4: Temp. |
+ // T3: Temp, Pointer to the function's code which we then tail-call. |
+ |
+ __ lw(T1, Address(SP, kRegExpParamOffset)); |
+ __ lw(T3, Address(SP, kStringParamOffset)); |
+ |
+ // Check which string class we have been passed. |
+ |
+ __ LoadClassId(T2, T3); |
+ |
+ __ BranchEqual(T2, kOneByteStringCid, &is_one_byte_string); |
+ __ BranchEqual(T2, kTwoByteStringCid, &is_two_byte_string); |
+ __ BranchEqual(T2, kExternalOneByteStringCid, &is_external_one_byte_string); |
+ __ BranchEqual(T2, kExternalTwoByteStringCid, &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); |
+ GenerateRegexpSpecializationFor(assembler, kOneByteStringCid, |
+ &is_one_byte_string, &fallthrough); |
+ |
+ // T0 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 T0, the argument descriptor in S4, and |
+ // IC-Data in S5. Irregexp generated functions do not use either the |
+ // arguments descriptor or IC-Data, and hence these are not set here. |
+ |
+ // Tail-call the function. |
+ __ lw(T3, FieldAddress(T0, Function::instructions_offset())); |
+ __ AddImmediate(T3, Instructions::HeaderSize() - kHeapObjectTag); |
+ __ jr(T3); |
+} |
+ |
// On stack: user tag (+0). |
void Intrinsifier::UserTag_makeCurrent(Assembler* assembler) { |
// T1: Isolate. |