Index: runtime/vm/intrinsifier_arm64.cc |
diff --git a/runtime/vm/intrinsifier_arm64.cc b/runtime/vm/intrinsifier_arm64.cc |
index c5d94b31f3571f6d2aaf08f8fc447a1af16cfe37..b527a2f138f16f02366d373eb8731829508d87b4 100644 |
--- a/runtime/vm/intrinsifier_arm64.cc |
+++ b/runtime/vm/intrinsifier_arm64.cc |
@@ -1492,6 +1492,98 @@ void Intrinsifier::TwoByteString_equality(Assembler* assembler) { |
} |
+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. |
+ |
+ __ ldr(R0, FieldAddress(R2, JSRegExp::function_offset(cid))); |
+ |
+ // Set the subject if it is currently unset. |
+ |
+ __ LoadObject(R4, Object::null_object(), PP); |
+ __ ldr(R5, FieldAddress(R2, JSRegExp::subject_offset(cid))); |
+ __ cmp(R4, Operand(R5)); |
+ __ b(exit, NE); |
+ |
+ __ StoreIntoObject(R2, |
+ FieldAddress(R2, JSRegExp::subject_offset(cid)), |
+ R1, |
+ 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: |
+ // R0: The appropriate specialized matcher function. |
+ // R2: The regexp object. |
+ // R4: Temp. |
+ // R5: Temp. |
+ // R1: Temp, Pointer to the function's code which we then tail-call. |
+ |
+ __ ldr(R2, Address(SP, kRegExpParamOffset)); |
+ __ ldr(R1, Address(SP, kStringParamOffset)); |
+ |
+ // Check which string class we have been passed. |
+ |
+ __ CompareClassId(R1, kOneByteStringCid, R4); |
+ __ b(&is_one_byte_string, EQ); |
+ |
+ __ CompareClassId(R1, kTwoByteStringCid, R4); |
+ __ b(&is_two_byte_string, EQ); |
+ |
+ __ CompareClassId(R1, kExternalOneByteStringCid, R4); |
+ __ b(&is_external_one_byte_string, EQ); |
+ |
+ __ CompareClassId(R1, kExternalTwoByteStringCid, R4); |
+ __ b(&is_external_two_byte_string, EQ); |
+ |
+ __ 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); |
+ |
+ // R0 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 R0, the argument descriptor in R5, and |
+ // IC-Data in R4. Irregexp generated functions do not use either the |
+ // arguments descriptor or IC-Data, and hence these are not set here. |
+ |
+ // Tail-call the function. |
+ __ ldr(R1, FieldAddress(R0, Function::instructions_offset())); |
+ __ AddImmediate(R1, R1, Instructions::HeaderSize() - kHeapObjectTag, PP); |
+ __ br(R1); |
+} |
+ |
+ |
// On stack: user tag (+0). |
void Intrinsifier::UserTag_makeCurrent(Assembler* assembler) { |
// R1: Isolate. |