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

Unified Diff: runtime/vm/flow_graph_builder.cc

Issue 2153013002: Added negative is check support ot simpleInstanceOf. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Added missing line. 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 | « no previous file | no next file » | 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 f61e9ff725cf12d01e33639a73b639edbe3d0d54..a55328f4b1eafdea19435c07acb2da82cf5e5878 100644
--- a/runtime/vm/flow_graph_builder.cc
+++ b/runtime/vm/flow_graph_builder.cc
@@ -1618,7 +1618,7 @@ void EffectGraphVisitor::BuildTypeTest(ComparisonNode* node) {
// We now know type is a real class (!num, !int, !smi, !string)
// and the type check could NOT be removed at compile time.
PushArgumentInstr* push_left = PushArgument(for_left_value.value());
- if (simpleInstanceOfType(type) && (node->kind() == Token::kIS)) {
+ if (simpleInstanceOfType(type)) {
ASSERT(!node->right()->AsTypeNode()->type().IsNull());
ZoneGrowableArray<PushArgumentInstr*>* arguments =
new(Z) ZoneGrowableArray<PushArgumentInstr*>(2);
@@ -1626,7 +1626,7 @@ void EffectGraphVisitor::BuildTypeTest(ComparisonNode* node) {
Value* type_const = Bind(new(Z) ConstantInstr(type));
arguments->Add(PushArgument(type_const));
const intptr_t kNumArgsChecked = 2;
- InstanceCallInstr* call = new(Z) InstanceCallInstr(
+ Definition* result = new(Z) InstanceCallInstr(
node->token_pos(),
Library::PrivateCoreLibName(Symbols::_simpleInstanceOf()),
node->kind(),
@@ -1634,35 +1634,39 @@ void EffectGraphVisitor::BuildTypeTest(ComparisonNode* node) {
Object::null_array(), // No argument names.
kNumArgsChecked,
owner()->ic_data_array());
- ReturnDefinition(call);
- } else {
- PushArgumentInstr* push_type_args = NULL;
- if (type.IsInstantiated()) {
- push_type_args = PushArgument(BuildNullValue(node->token_pos()));
- } else {
- BuildTypecheckPushArguments(node->token_pos(), &push_type_args);
+ if (negate_result) {
+ result = new(Z) BooleanNegateInstr(Bind(result));
}
- ZoneGrowableArray<PushArgumentInstr*>* arguments =
- new(Z) ZoneGrowableArray<PushArgumentInstr*>(4);
- arguments->Add(push_left);
- arguments->Add(push_type_args);
- ASSERT(!node->right()->AsTypeNode()->type().IsNull());
- 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));
- const intptr_t kNumArgsChecked = 1;
- InstanceCallInstr* call = new(Z) InstanceCallInstr(
- node->token_pos(),
- Library::PrivateCoreLibName(Symbols::_instanceOf()),
- node->kind(),
- arguments,
- Object::null_array(), // No argument names.
- kNumArgsChecked,
- owner()->ic_data_array());
- ReturnDefinition(call);
+ ReturnDefinition(result);
+ return;
}
+
+ PushArgumentInstr* push_type_args = NULL;
+ if (type.IsInstantiated()) {
+ push_type_args = PushArgument(BuildNullValue(node->token_pos()));
+ } else {
+ BuildTypecheckPushArguments(node->token_pos(), &push_type_args);
+ }
+ ZoneGrowableArray<PushArgumentInstr*>* arguments =
+ new(Z) ZoneGrowableArray<PushArgumentInstr*>(4);
+ arguments->Add(push_left);
+ arguments->Add(push_type_args);
+ ASSERT(!node->right()->AsTypeNode()->type().IsNull());
+ 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));
+ const intptr_t kNumArgsChecked = 1;
+ InstanceCallInstr* call = new(Z) InstanceCallInstr(
+ node->token_pos(),
+ Library::PrivateCoreLibName(Symbols::_instanceOf()),
+ node->kind(),
+ arguments,
+ Object::null_array(), // No argument names.
+ kNumArgsChecked,
+ owner()->ic_data_array());
+ ReturnDefinition(call);
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698