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

Unified Diff: runtime/vm/code_generator.cc

Issue 2137673002: Sped up hashCode by removing megamorphic call to _identityHashCode. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Improved the speed of instance-of for unoptimized code. Created 4 years, 5 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/bootstrap_natives.h ('k') | runtime/vm/flow_graph_builder.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/code_generator.cc
diff --git a/runtime/vm/code_generator.cc b/runtime/vm/code_generator.cc
index 3082168307cae0439c17f58c3d0c774a39f692fc..393ef507175fe76150312fd81d09b869ba6ee707 100644
--- a/runtime/vm/code_generator.cc
+++ b/runtime/vm/code_generator.cc
@@ -782,6 +782,25 @@ RawFunction* InlineCacheMissHelper(
return result.raw();
}
+
+// Perform the subtype and return constant function based on the result.
+static RawFunction* ComputeTypeCheckTarget(const Instance& receiver,
+ const AbstractType& type,
+ const ArgumentsDescriptor& desc) {
+ const TypeArguments& checked_type_arguments = TypeArguments::Handle();
+ Error& error = Error::Handle();
+ bool result = receiver.IsInstanceOf(type, checked_type_arguments, &error);
+ ASSERT(error.IsNull());
+ ObjectStore* store = Isolate::Current()->object_store();
+ Function& target
+ = Function::Handle(result
+ ? store->simple_instance_of_true_function()
+ : store->simple_instance_of_false_function());
+ ASSERT(!target.IsNull());
+ return target.raw();;
+}
+
+
static RawFunction* InlineCacheMissHandler(
const GrowableArray<const Instance*>& args,
const ICData& ic_data) {
@@ -790,8 +809,17 @@ static RawFunction* InlineCacheMissHandler(
arguments_descriptor(Array::Handle(ic_data.arguments_descriptor()));
String& function_name = String::Handle(ic_data.target_name());
ASSERT(function_name.IsSymbol());
+
Function& target_function = Function::Handle(
Resolver::ResolveDynamic(receiver, function_name, arguments_descriptor));
+
+ ObjectStore* store = Isolate::Current()->object_store();
+ if (target_function.raw() == store->simple_instance_of_function()) {
+ // Replace the target function with constant function.
+ const AbstractType& type = AbstractType::Cast(*args[1]);
+ target_function
+ = ComputeTypeCheckTarget(receiver, type, arguments_descriptor);
+ }
if (target_function.IsNull()) {
if (FLAG_trace_ic) {
OS::PrintErr("InlineCacheMissHandler NULL function for %s receiver: %s\n",
« no previous file with comments | « runtime/vm/bootstrap_natives.h ('k') | runtime/vm/flow_graph_builder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698