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

Unified Diff: runtime/vm/stub_code_ia32.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, 8 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
Index: runtime/vm/stub_code_ia32.cc
===================================================================
--- runtime/vm/stub_code_ia32.cc (revision 45488)
+++ runtime/vm/stub_code_ia32.cc (working copy)
@@ -2054,6 +2054,53 @@
__ ret();
}
+
+// Called from megamorphic calls.
+// EDI: receiver.
+// EBX: lookup cache.
+// Result:
+// EBX: entry point.
+void StubCode::GenerateMegamorphicLookupStub(Assembler* assembler) {
+ __ LoadTaggedClassIdMayBeSmi(EAX, EDI);
+
+ // EAX: class ID of the receiver (smi).
+ __ movl(EDI, FieldAddress(EBX, MegamorphicCache::buckets_offset()));
+ __ movl(EBX, FieldAddress(EBX, MegamorphicCache::mask_offset()));
+ // EDI: cache buckets array.
+ // EBX: mask.
+ __ movl(ECX, EAX);
+
+ Label loop, update, call_target_function;
+ __ jmp(&loop);
+
+ __ Bind(&update);
+ __ addl(ECX, Immediate(Smi::RawValue(1)));
+ __ Bind(&loop);
+ __ andl(ECX, EBX);
+ const intptr_t base = Array::data_offset();
+ // ECX is smi tagged, but table entries are two words, so TIMES_4.
+ __ movl(EDX, FieldAddress(EDI, ECX, TIMES_4, base));
+
+ ASSERT(kIllegalCid == 0);
+ __ testl(EDX, EDX);
+ __ j(ZERO, &call_target_function, Assembler::kNearJump);
+ __ cmpl(EDX, EAX);
+ __ 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.
+ __ movl(EAX, FieldAddress(EDI, ECX, TIMES_4, base + kWordSize));
+ __ movl(EBX, FieldAddress(EAX, Function::instructions_offset()));
+ // TODO(srdjan): Evaluate performance impact of moving the instruction below
+ // to the call site, instead of having it here.
+ __ addl(EBX, Immediate(Instructions::HeaderSize() - kHeapObjectTag));
+ __ ret();
+}
+
+
} // namespace dart
#endif // defined TARGET_ARCH_IA32

Powered by Google App Engine
This is Rietveld 408576698