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

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, 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_arm64.cc ('k') | runtime/vm/stub_code_mips.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/stub_code_ia32.cc
===================================================================
--- runtime/vm/stub_code_ia32.cc (revision 45519)
+++ runtime/vm/stub_code_ia32.cc (working copy)
@@ -2054,6 +2054,60 @@
__ ret();
}
+
+void StubCode::EmitMegamorphicLookup(
+ Assembler* assembler, Register receiver, Register cache, Register target) {
+ ASSERT((cache != EAX) && (cache != EDI));
+ __ LoadTaggedClassIdMayBeSmi(EAX, receiver);
+
+ // EAX: class ID of the receiver (smi).
+ __ movl(EDI, FieldAddress(cache, MegamorphicCache::buckets_offset()));
+ __ movl(EBX, FieldAddress(cache, 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(target, 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(target, Immediate(Instructions::HeaderSize() - kHeapObjectTag));
+}
+
+
+// Called from megamorphic calls.
+// EDI: receiver.
+// EBX: lookup cache.
+// Result:
+// EBX: entry point.
+void StubCode::GenerateMegamorphicLookupStub(Assembler* assembler) {
+ EmitMegamorphicLookup(assembler, EDI, EBX, EBX);
+ __ ret();
+}
+
+
} // namespace dart
#endif // defined TARGET_ARCH_IA32
« no previous file with comments | « runtime/vm/stub_code_arm64.cc ('k') | runtime/vm/stub_code_mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698