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

Unified Diff: runtime/vm/code_generator.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/code_generator.cc
diff --git a/runtime/vm/code_generator.cc b/runtime/vm/code_generator.cc
index ed9073110582af7dc30436a5ca5a3bc21c30357a..07d67b05a9bcc8aac9b21c1fe1c1dd075e9b1340 100644
--- a/runtime/vm/code_generator.cc
+++ b/runtime/vm/code_generator.cc
@@ -1011,6 +1011,55 @@ DEFINE_RUNTIME_ENTRY(InlineCacheMissHandlerThreeArgs, 3) {
}
+// Arg0: Receiver's class ID.
srdjan 2012/12/03 19:10:46 This seems to be receiver not cid. Arg1 is ICData
Kevin Millikin (Google) 2012/12/06 14:03:11 Comment is fixed.
+// Arg1: Megamorphic cache.
+// Arg2: Arguments descriptor.
+// Arg3: IC data.
srdjan 2012/12/03 19:10:46 Describe results (target not found vs found).
+DEFINE_RUNTIME_ENTRY(MegamorphicCacheMissHandler, 3) {
+ ASSERT(arguments.ArgCount() ==
+ kMegamorphicCacheMissHandlerRuntimeEntry.argument_count());
+ const Instance& receiver =
+ Instance::CheckedHandle(isolate, arguments.ArgAt(0));
+ const ICData& ic_data = ICData::CheckedHandle(isolate, arguments.ArgAt(1));
+ const Array& descriptor = Array::CheckedHandle(isolate, arguments.ArgAt(2));
+ const String& name = String::Handle(isolate, ic_data.target_name());
+ const MegamorphicCache& cache = MegamorphicCache::Handle(isolate,
+ isolate->megamorphic_cache_table()->Lookup(name, descriptor));
+ Class& cls = Class::Handle(isolate, receiver.clazz());
+ if (cls.IsNullClass()) {
Vyacheslav Egorov (Google) 2012/12/03 14:55:22 Please add a comment.
Kevin Millikin (Google) 2012/12/06 14:03:11 The comment at the site I took this from said "For
+ cls = isolate->object_store()->object_class();
+ }
+ ASSERT(!cls.IsNull());
+ intptr_t arg_count =
+ Smi::Cast(Object::Handle(isolate, descriptor.At(0))).Value();
Vyacheslav Egorov (Google) 2012/12/03 14:55:22 I know that this is not your code but I really don
Kevin Millikin (Google) 2012/12/06 14:03:11 I have fixed this in another change.
+ intptr_t named_arg_count =
+ arg_count - Smi::Cast(Object::Handle(isolate, descriptor.At(1))).Value();
+ const Function& target = Function::Handle(isolate,
+ Resolver::ResolveDynamicForReceiverClass(cls,
+ name,
+ arg_count,
+ named_arg_count));
+
+ Instructions& instructions = Instructions::Handle(isolate);
+ if (!target.IsNull()) {
+ if (!target.HasCode()) {
+ const Error& error =
+ Error::Handle(isolate, Compiler::CompileFunction(target));
+ if (!error.IsNull()) Exceptions::PropagateError(error);
+ }
+ ASSERT(target.HasCode());
+ instructions = Code::Handle(isolate, target.CurrentCode()).instructions();
+ }
+ arguments.SetReturn(instructions);
+ if (instructions.IsNull()) return;
srdjan 2012/12/03 19:10:46 Would the code above be simpler if changed to: ar
Kevin Millikin (Google) 2012/12/06 14:03:11 Possibly. I think we can sort out the code duplic
+
+ cache.EnsureCapacity();
+ const Smi& class_id = Smi::Handle(isolate, Smi::New(cls.id()));
+ cache.Insert(class_id, target);
+ return;
srdjan 2012/12/03 19:10:46 I also think that using isolate here explicitly ma
Kevin Millikin (Google) 2012/12/06 14:03:11 Removed.
+}
srdjan 2012/12/03 19:10:46 Could you also add tracing flag and code to be abl
Kevin Millikin (Google) 2012/12/06 14:03:11 I just printed something for --trace-ic and --trac
+
+
// Updates IC data for two arguments. Used by the equality operation when
// the control flow bypasses regular inline cache (null arguments).
// Arg0: Receiver object.

Powered by Google App Engine
This is Rietveld 408576698