Index: runtime/vm/stub_code_arm64.cc |
diff --git a/runtime/vm/stub_code_arm64.cc b/runtime/vm/stub_code_arm64.cc |
index 7d6f022fe5196c26de82d7415591a8d4a4a81123..8c197ae9633a60e4a181dce76346ca96927bc3c6 100644 |
--- a/runtime/vm/stub_code_arm64.cc |
+++ b/runtime/vm/stub_code_arm64.cc |
@@ -567,9 +567,9 @@ static void GenerateDispatcherCode(Assembler* assembler, |
__ add(TMP, FP, Operand(R2, LSL, 2)); // R2 is Smi. |
__ LoadFromOffset(R6, TMP, kParamEndSlotFromFp * kWordSize); |
__ PushObject(Object::null_object()); |
- __ Push(R6); |
- __ Push(R5); |
- __ Push(R4); |
+ __ Push(R6); // Receiver. |
+ __ Push(R5); // ICData/MegamorphicCache. |
+ __ Push(R4); // Arguments descriptor. |
// R2: Smi-tagged arguments array length. |
PushArgumentsArray(assembler); |
const intptr_t kNumArgs = 4; |
@@ -2098,18 +2098,18 @@ void StubCode::GenerateOptimizedIdenticalWithNumberCheckStub( |
} |
-void StubCode::EmitMegamorphicLookup( |
- Assembler* assembler, Register receiver, Register cache, Register target) { |
- ASSERT((cache != R0) && (cache != R2)); |
- __ LoadTaggedClassIdMayBeSmi(R0, receiver); |
+void StubCode::EmitMegamorphicLookup(Assembler* assembler) { |
+ __ LoadTaggedClassIdMayBeSmi(R0, R0); |
// R0: class ID of the receiver (smi). |
- __ LoadFieldFromOffset(R2, cache, MegamorphicCache::buckets_offset()); |
- __ LoadFieldFromOffset(R1, cache, MegamorphicCache::mask_offset()); |
+ __ ldr(R4, FieldAddress(R5, MegamorphicCache::arguments_descriptor_offset())); |
+ __ ldr(R2, FieldAddress(R5, MegamorphicCache::buckets_offset())); |
+ __ ldr(R1, FieldAddress(R5, MegamorphicCache::mask_offset())); |
// R2: cache buckets array. |
// R1: mask. |
__ mov(R3, R0); |
+ // R3: probe. |
- Label loop, update, call_target_function; |
+ Label loop, update, load_target_function; |
__ b(&loop); |
__ Bind(&update); |
@@ -2119,33 +2119,77 @@ void StubCode::EmitMegamorphicLookup( |
const intptr_t base = Array::data_offset(); |
// R3 is smi tagged, but table entries are 16 bytes, so LSL 3. |
__ add(TMP, R2, Operand(R3, LSL, 3)); |
- __ LoadFieldFromOffset(R4, TMP, base); |
+ __ ldr(R6, FieldAddress(TMP, base)); |
ASSERT(kIllegalCid == 0); |
- __ tst(R4, Operand(R4)); |
- __ b(&call_target_function, EQ); |
- __ CompareRegisters(R4, R0); |
+ __ tst(R6, Operand(R6)); |
+ __ b(&load_target_function, EQ); |
+ __ CompareRegisters(R6, R0); |
__ b(&update, NE); |
- __ Bind(&call_target_function); |
+ __ Bind(&load_target_function); |
// Call the target found in the cache. For a class id match, this is a |
// proper target for the given name and arguments descriptor. If the |
// illegal class id was found, the target is a cache miss handler that can |
// be invoked as a normal Dart function. |
__ add(TMP, R2, Operand(R3, LSL, 3)); |
- __ LoadFieldFromOffset(R0, TMP, base + kWordSize); |
- __ LoadFieldFromOffset(CODE_REG, R0, Function::code_offset()); |
- __ LoadFieldFromOffset(R1, R0, Function::entry_point_offset()); |
+ __ ldr(R0, FieldAddress(TMP, base + kWordSize)); |
+ __ ldr(R1, FieldAddress(R0, Function::entry_point_offset())); |
+ __ ldr(CODE_REG, FieldAddress(R0, Function::code_offset())); |
} |
// Called from megamorphic calls. |
-// R0: receiver. |
-// R1: lookup cache. |
+// R0: receiver |
+// R5: MegamorphicCache (preserved) |
// Result: |
-// R1: entry point. |
+// R1: target entry point |
+// CODE_REG: target Code |
+// R4: arguments descriptor |
void StubCode::GenerateMegamorphicLookupStub(Assembler* assembler) { |
- EmitMegamorphicLookup(assembler, R0, R1, R1); |
+ EmitMegamorphicLookup(assembler); |
+ __ ret(); |
+} |
+ |
+ |
+// Called from switchable IC calls. |
+// R0: receiver |
+// R5: ICData (preserved) |
+// Result: |
+// R1: target entry point |
+// CODE_REG: target Code object |
+// R4: arguments descriptor |
+void StubCode::GenerateICLookupStub(Assembler* assembler) { |
+ Label loop, found, miss; |
+ __ ldr(R4, FieldAddress(R5, ICData::arguments_descriptor_offset())); |
+ __ ldr(R8, FieldAddress(R5, ICData::ic_data_offset())); |
+ __ AddImmediate(R8, R8, Array::data_offset() - kHeapObjectTag); |
+ // R8: first IC entry |
+ __ LoadTaggedClassIdMayBeSmi(R1, R0); |
+ // R1: receiver cid as Smi |
+ |
+ __ Bind(&loop); |
+ __ ldr(R2, Address(R8, 0)); |
+ __ cmp(R1, Operand(R2)); |
+ __ b(&found, EQ); |
+ __ CompareImmediate(R2, Smi::RawValue(kIllegalCid)); |
+ __ b(&miss, EQ); |
+ |
+ const intptr_t entry_length = ICData::TestEntryLengthFor(1) * kWordSize; |
+ __ AddImmediate(R8, R8, entry_length); // Next entry. |
+ __ b(&loop); |
+ |
+ __ Bind(&found); |
+ const intptr_t target_offset = ICData::TargetIndexFor(1) * kWordSize; |
+ __ ldr(R0, Address(R8, target_offset)); |
+ __ ldr(R1, FieldAddress(R0, Function::entry_point_offset())); |
+ __ ldr(CODE_REG, FieldAddress(R0, Function::code_offset())); |
+ __ ret(); |
+ |
+ __ Bind(&miss); |
+ __ LoadIsolate(R2); |
+ __ ldr(CODE_REG, Address(R2, Isolate::ic_miss_code_offset())); |
+ __ ldr(R1, FieldAddress(CODE_REG, Code::entry_point_offset())); |
__ ret(); |
} |