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

Unified Diff: runtime/vm/flow_graph_compiler_ia32.cc

Issue 11299298: Cache lookups at megamorphic call sites in optimized code. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years 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/flow_graph_compiler_ia32.cc
diff --git a/runtime/vm/flow_graph_compiler_ia32.cc b/runtime/vm/flow_graph_compiler_ia32.cc
index 832c5f12e0d5dea6269e44b80a40069fafcf203e..ed913da5a0fb5f627e2d49b0655c039082bfd422 100644
--- a/runtime/vm/flow_graph_compiler_ia32.cc
+++ b/runtime/vm/flow_graph_compiler_ia32.cc
@@ -1093,6 +1093,69 @@ void FlowGraphCompiler::EmitInstanceCall(ExternalLabel* target_label,
}
+void FlowGraphCompiler::EmitMegamorphicInstanceCall(
+ const ICData& ic_data,
+ const Array& arguments_descriptor,
+ intptr_t argument_count,
+ intptr_t deopt_id,
+ intptr_t token_pos,
+ LocationSummary* locs) {
+ MegamorphicCacheTable* table = Isolate::Current()->megamorphic_cache_table();
+ const String& name = String::Handle(ic_data.target_name());
+ const MegamorphicCache& cache =
+ MegamorphicCache::ZoneHandle(table->Lookup(name, arguments_descriptor));
+ Label not_smi, load_cache;
+ __ movl(EAX, Address(ESP, (argument_count - 1) * kWordSize));
+ __ testl(EAX, Immediate(kSmiTagMask));
+ __ j(NOT_ZERO, &not_smi, Assembler::kNearJump);
+ __ movl(EAX, Immediate(Smi::RawValue(kSmiCid)));
+ __ jmp(&load_cache);
+
+ __ Bind(&not_smi);
+ __ LoadClassId(EAX, EAX);
+ __ SmiTag(EAX);
+
+ // EAX: class ID of the receiver (smi).
+ __ Bind(&load_cache);
+ __ LoadObject(EBX, cache);
+ __ 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, found;
+ __ 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, &found, Assembler::kNearJump);
srdjan 2012/12/03 19:10:46 Maybe use a different label e.g., megamorphic_miss
Kevin Millikin (Google) 2012/12/06 14:03:11 Changed to call_target.
+ __ cmpl(EDX, EAX);
+ __ j(NOT_EQUAL, &update, Assembler::kNearJump);
+
+ __ Bind(&found);
+ __ movl(EAX, FieldAddress(EDI, ECX, TIMES_4, base + kWordSize));
+ __ movl(EAX, FieldAddress(EAX, Function::code_offset()));
+ __ movl(EAX, FieldAddress(EAX, Code::instructions_offset()));
+ __ LoadObject(ECX, ic_data);
+ __ LoadObject(EDX, arguments_descriptor);
+ __ addl(EAX, Immediate(Instructions::HeaderSize() - kHeapObjectTag));
+ __ call(EAX);
+ AddCurrentDescriptor(PcDescriptors::kOther, Isolate::kNoDeoptId, token_pos);
+ RecordSafepoint(locs);
+ AddDeoptIndexAtCall(deopt_id, token_pos);
+ __ Drop(argument_count);
+}
+
+
void FlowGraphCompiler::EmitStaticCall(const Function& function,
const Array& arguments_descriptor,
intptr_t argument_count,

Powered by Google App Engine
This is Rietveld 408576698