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

Unified Diff: runtime/vm/stub_code_mips.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_ia32.cc ('k') | runtime/vm/stub_code_x64.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/stub_code_mips.cc
===================================================================
--- runtime/vm/stub_code_mips.cc (revision 45519)
+++ runtime/vm/stub_code_mips.cc (working copy)
@@ -2255,6 +2255,61 @@
__ Ret();
}
+
+void StubCode::EmitMegamorphicLookup(
+ Assembler* assembler, Register receiver, Register cache, Register target) {
+ ASSERT((cache != T0) && (cache != T2));
+ __ LoadTaggedClassIdMayBeSmi(T0, receiver);
+ // T0: class ID of the receiver (smi).
+ __ lw(T2, FieldAddress(cache, MegamorphicCache::buckets_offset()));
+ __ lw(T1, FieldAddress(cache, MegamorphicCache::mask_offset()));
+ // T2: cache buckets array.
+ // T1: mask.
+ __ mov(T3, T0);
+
+ Label loop, update, call_target_function;
+ __ b(&loop);
+
+ __ Bind(&update);
+ __ addiu(T3, T3, Immediate(Smi::RawValue(1)));
+ __ Bind(&loop);
+ __ and_(T3, T3, T1);
+ const intptr_t base = Array::data_offset();
+ // T3 is smi tagged, but table entries are two words, so LSL 2.
+ __ sll(TMP, T3, 2);
+ __ addu(TMP, T2, TMP);
+ __ lw(T4, FieldAddress(TMP, base));
+
+ ASSERT(kIllegalCid == 0);
+ __ beq(T4, ZR, &call_target_function);
+ __ bne(T4, T0, &update);
+
+ __ 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.
+ __ sll(T1, T3, 2);
+ __ addu(T1, T2, T1);
+ __ lw(T0, FieldAddress(T1, base + kWordSize));
+
+ __ lw(target, FieldAddress(T0, Function::instructions_offset()));
+ // TODO(srdjan): Evaluate performance impact of moving the instruction below
+ // to the call site, instead of having it here.
+ __ AddImmediate(target, Instructions::HeaderSize() - kHeapObjectTag);
+}
+
+
+// Called from megamorphic calls.
+// T0: receiver.
+// T1: lookup cache.
+// Result:
+// T1: entry point.
+void StubCode::GenerateMegamorphicLookupStub(Assembler* assembler) {
+ EmitMegamorphicLookup(assembler, T0, T1, T1);
+ __ Ret();
+}
+
} // namespace dart
#endif // defined TARGET_ARCH_MIPS
« no previous file with comments | « runtime/vm/stub_code_ia32.cc ('k') | runtime/vm/stub_code_x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698