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

Unified Diff: runtime/vm/stub_code_x64.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_mips.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/stub_code_x64.cc
===================================================================
--- runtime/vm/stub_code_x64.cc (revision 45519)
+++ runtime/vm/stub_code_x64.cc (working copy)
@@ -2103,6 +2103,59 @@
__ ret();
}
+
+void StubCode::EmitMegamorphicLookup(
+ Assembler* assembler, Register receiver, Register cache, Register target) {
+ ASSERT((cache != RAX) && (cache != RDI));
+ __ LoadTaggedClassIdMayBeSmi(RAX, receiver);
+ // RAX: class ID of the receiver (smi).
+ __ movq(RDI, FieldAddress(cache, MegamorphicCache::buckets_offset()));
+ __ movq(RBX, FieldAddress(cache, MegamorphicCache::mask_offset()));
+ // RDI: cache buckets array.
+ // RBX: mask.
+ __ movq(RCX, RAX);
+
+ Label loop, update, call_target_function;
+ __ jmp(&loop);
+
+ __ Bind(&update);
+ __ AddImmediate(RCX, Immediate(Smi::RawValue(1)), PP);
+ __ Bind(&loop);
+ __ andq(RCX, RBX);
+ const intptr_t base = Array::data_offset();
+ // RCX is smi tagged, but table entries are two words, so TIMES_8.
+ __ movq(RDX, FieldAddress(RDI, RCX, TIMES_8, base));
+
+ ASSERT(kIllegalCid == 0);
+ __ testq(RDX, RDX);
+ __ j(ZERO, &call_target_function, Assembler::kNearJump);
+ __ cmpq(RDX, RAX);
+ __ j(NOT_EQUAL, &update, Assembler::kNearJump);
+
+ __ 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.
+ __ movq(RAX, FieldAddress(RDI, RCX, TIMES_8, base + kWordSize));
+ __ movq(target, FieldAddress(RAX, Function::instructions_offset()));
+ // TODO(srdjan): Evaluate performance impact of moving the instruction below
+ // to the call site, instead of having it here.
+ __ AddImmediate(
+ target, Immediate(Instructions::HeaderSize() - kHeapObjectTag), PP);
+}
+
+
+// Called from megamorphic calls.
+// RDI: receiver.
+// RBX: lookup cache.
+// Result:
+// RCX: entry point.
+void StubCode::GenerateMegamorphicLookupStub(Assembler* assembler) {
+ EmitMegamorphicLookup(assembler, RDI, RBX, RCX);
+ __ ret();
+}
+
} // namespace dart
#endif // defined TARGET_ARCH_X64
« no previous file with comments | « runtime/vm/stub_code_mips.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698