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

Unified Diff: runtime/vm/flow_graph_builder.cc

Issue 1222863003: Make frequent type checks (instanceof) faster by adding dedicated instanceof methods; improves dart… (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: flag Created 5 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_optimizer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/flow_graph_builder.cc
diff --git a/runtime/vm/flow_graph_builder.cc b/runtime/vm/flow_graph_builder.cc
index 0329ca3a2828dc5813f541b8e3be6387355833ac..abdd58e44ff523cd98b833ddbb8e43e63d437dec 100644
--- a/runtime/vm/flow_graph_builder.cc
+++ b/runtime/vm/flow_graph_builder.cc
@@ -1811,6 +1811,44 @@ void EffectGraphVisitor::BuildTypeTest(ComparisonNode* node) {
ValueGraphVisitor for_left_value(owner());
node->left()->Visit(&for_left_value);
Append(for_left_value);
+
+ if (!FLAG_warn_on_javascript_compatibility) {
+ if (type.IsNumberType() || type.IsIntType() || type.IsDoubleType() ||
+ type.IsSmiType() || type.IsStringType()) {
+ String& method_name = String::ZoneHandle(Z);
+ if (type.IsNumberType()) {
+ method_name = Symbols::_instanceOfNum().raw();
+ } else if (type.IsIntType()) {
+ method_name = Symbols::_instanceOfInt().raw();
+ } else if (type.IsDoubleType()) {
+ method_name = Symbols::_instanceOfDouble().raw();
+ } else if (type.IsSmiType()) {
+ method_name = Symbols::_instanceOfSmi().raw();
+ } else if (type.IsStringType()) {
+ method_name = Symbols::_instanceOfString().raw();
+ }
+ ASSERT(!method_name.IsNull());
+ PushArgumentInstr* push_left = PushArgument(for_left_value.value());
+ ZoneGrowableArray<PushArgumentInstr*>* arguments =
+ new(Z) ZoneGrowableArray<PushArgumentInstr*>(2);
+ arguments->Add(push_left);
+ const Bool& negate = Bool::Get(node->kind() == Token::kISNOT);
+ Value* negate_arg = Bind(new(Z) ConstantInstr(negate));
+ arguments->Add(PushArgument(negate_arg));
+ const intptr_t kNumArgsChecked = 1;
+ InstanceCallInstr* call = new(Z) InstanceCallInstr(
+ node->token_pos(),
+ Library::PrivateCoreLibName(method_name),
+ node->kind(),
+ arguments,
+ Object::null_array(), // No argument names.
+ kNumArgsChecked,
+ owner()->ic_data_array());
+ ReturnDefinition(call);
+ return;
+ }
+ }
+
PushArgumentInstr* push_left = PushArgument(for_left_value.value());
PushArgumentInstr* push_instantiator = NULL;
PushArgumentInstr* push_type_args = NULL;
@@ -1828,9 +1866,8 @@ void EffectGraphVisitor::BuildTypeTest(ComparisonNode* node) {
arguments->Add(push_instantiator);
arguments->Add(push_type_args);
ASSERT(!node->right()->AsTypeNode()->type().IsNull());
- Value* type_arg = Bind(
- new(Z) ConstantInstr(node->right()->AsTypeNode()->type()));
- arguments->Add(PushArgument(type_arg));
+ Value* type_const = Bind(new(Z) ConstantInstr(type));
+ arguments->Add(PushArgument(type_const));
const Bool& negate = Bool::Get(node->kind() == Token::kISNOT);
Value* negate_arg = Bind(new(Z) ConstantInstr(negate));
arguments->Add(PushArgument(negate_arg));
« no previous file with comments | « runtime/vm/bootstrap_natives.h ('k') | runtime/vm/flow_graph_optimizer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698