Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(754)

Unified Diff: runtime/vm/stub_code_arm64.cc

Issue 1125623003: Move megamorphic lookup code to stub instead of inlining. Preformance loss < 5%, instruction size r… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/stub_code_arm.cc ('k') | runtime/vm/stub_code_ia32.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/stub_code_arm64.cc
===================================================================
--- runtime/vm/stub_code_arm64.cc (revision 45519)
+++ runtime/vm/stub_code_arm64.cc (working copy)
@@ -2108,6 +2108,60 @@
__ ret();
}
+
+void StubCode::EmitMegamorphicLookup(
+ Assembler* assembler, Register receiver, Register cache, Register target) {
+ ASSERT((cache != R0) && (cache != R2));
+ __ LoadTaggedClassIdMayBeSmi(R0, receiver);
+ // R0: class ID of the receiver (smi).
+ __ LoadFieldFromOffset(R2, cache, MegamorphicCache::buckets_offset(), PP);
+ __ LoadFieldFromOffset(R1, cache, MegamorphicCache::mask_offset(), PP);
+ // R2: cache buckets array.
+ // R1: mask.
+ __ mov(R3, R0);
+
+ Label loop, update, call_target_function;
+ __ b(&loop);
+
+ __ Bind(&update);
+ __ add(R3, R3, Operand(Smi::RawValue(1)));
+ __ Bind(&loop);
+ __ and_(R3, R3, Operand(R1));
+ 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, PP);
+
+ ASSERT(kIllegalCid == 0);
+ __ tst(R4, Operand(R4));
+ __ b(&call_target_function, EQ);
+ __ CompareRegisters(R4, R0);
+ __ b(&update, NE);
+
+ __ Bind(&call_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, PP);
+ __ LoadFieldFromOffset(R1, R0, Function::instructions_offset(), PP);
+ // TODO(srdjan): Evaluate performance impact of moving the instruction below
+ // to the call site, instead of having it here.
+ __ AddImmediate(target, R1, Instructions::HeaderSize() - kHeapObjectTag, PP);
+}
+
+
+// Called from megamorphic calls.
+// R0: receiver.
+// R1: lookup cache.
+// Result:
+// R1: entry point.
+void StubCode::GenerateMegamorphicLookupStub(Assembler* assembler) {
+ EmitMegamorphicLookup(assembler, R0, R1, R1);
+ __ ret();
+}
+
} // namespace dart
#endif // defined TARGET_ARCH_ARM64
« no previous file with comments | « runtime/vm/stub_code_arm.cc ('k') | runtime/vm/stub_code_ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698