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

Unified Diff: runtime/vm/flow_graph_compiler_x64.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: One change I forgot. 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
« no previous file with comments | « runtime/vm/flow_graph_compiler_x64.h ('k') | runtime/vm/intermediate_language_ia32.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/flow_graph_compiler_x64.cc
diff --git a/runtime/vm/flow_graph_compiler_x64.cc b/runtime/vm/flow_graph_compiler_x64.cc
index ac94468aed536afa1286d47521dea615ffda62c3..a998490a5ece5aaea49e446ba00ab51bd4783822 100644
--- a/runtime/vm/flow_graph_compiler_x64.cc
+++ b/runtime/vm/flow_graph_compiler_x64.cc
@@ -1102,6 +1102,73 @@ 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;
+ __ movq(RAX, Address(RSP, (argument_count - 1) * kWordSize));
+ __ testq(RAX, Immediate(kSmiTagMask));
+ __ j(NOT_ZERO, &not_smi, Assembler::kNearJump);
+ __ movq(RAX, Immediate(Smi::RawValue(kSmiCid)));
+ __ jmp(&load_cache);
+
+ __ Bind(&not_smi);
+ __ LoadClassId(RAX, RAX);
+ __ SmiTag(RAX);
+
+ // RAX: class ID of the receiver (smi).
+ __ Bind(&load_cache);
+ __ LoadObject(RBX, cache);
+ __ movq(RDI, FieldAddress(RBX, MegamorphicCache::buckets_offset()));
+ __ movq(RBX, FieldAddress(RBX, MegamorphicCache::mask_offset()));
+ // RDI: cache buckets array.
+ // RBX: mask.
+ __ movq(RCX, RAX);
+
+ Label loop, update, call_target_function;
+ __ jmp(&loop);
+
+ __ Bind(&update);
+ __ addq(RCX, Immediate(Smi::RawValue(1)));
+ __ 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(RAX, FieldAddress(RAX, Function::code_offset()));
+ __ movq(RAX, FieldAddress(RAX, Code::instructions_offset()));
+ __ LoadObject(RBX, ic_data);
+ __ LoadObject(R10, arguments_descriptor);
+ __ addq(RAX, Immediate(Instructions::HeaderSize() - kHeapObjectTag));
+ __ call(RAX);
+ 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,
« no previous file with comments | « runtime/vm/flow_graph_compiler_x64.h ('k') | runtime/vm/intermediate_language_ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698