| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/flow_graph_builder.h" | 5 #include "vm/flow_graph_builder.h" |
| 6 | 6 |
| 7 #include "lib/invocation_mirror.h" | 7 #include "lib/invocation_mirror.h" |
| 8 #include "vm/ast_printer.h" | 8 #include "vm/ast_printer.h" |
| 9 #include "vm/bit_vector.h" | 9 #include "vm/bit_vector.h" |
| 10 #include "vm/compiler.h" | 10 #include "vm/compiler.h" |
| (...skipping 973 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 984 false); // No number check. | 984 false); // No number check. |
| 985 BranchInstr* branch = new (Z) BranchInstr(comp); | 985 BranchInstr* branch = new (Z) BranchInstr(comp); |
| 986 AddInstruction(branch); | 986 AddInstruction(branch); |
| 987 CloseFragment(); | 987 CloseFragment(); |
| 988 | 988 |
| 989 true_successor_addresses_.Add(branch->true_successor_address()); | 989 true_successor_addresses_.Add(branch->true_successor_address()); |
| 990 false_successor_addresses_.Add(branch->false_successor_address()); | 990 false_successor_addresses_.Add(branch->false_successor_address()); |
| 991 } | 991 } |
| 992 | 992 |
| 993 | 993 |
| 994 void TestGraphVisitor::MergeBranchWithComparison(ComparisonInstr* comp) { | 994 void TestGraphVisitor::MergeBranchWithStrictCompare(StrictCompareInstr* comp) { |
| 995 BranchInstr* branch; | 995 BranchInstr* branch = new (Z) BranchInstr(comp); |
| 996 if (Token::IsStrictEqualityOperator(comp->kind())) { | |
| 997 ASSERT(comp->IsStrictCompare()); | |
| 998 branch = new (Z) BranchInstr(comp); | |
| 999 } else if (Token::IsEqualityOperator(comp->kind()) && | |
| 1000 (comp->left()->BindsToConstantNull() || | |
| 1001 comp->right()->BindsToConstantNull())) { | |
| 1002 branch = new (Z) BranchInstr(new (Z) StrictCompareInstr( | |
| 1003 comp->token_pos(), | |
| 1004 (comp->kind() == Token::kEQ) ? Token::kEQ_STRICT : Token::kNE_STRICT, | |
| 1005 comp->left(), comp->right(), | |
| 1006 false)); // No number check. | |
| 1007 } else { | |
| 1008 branch = new (Z) BranchInstr(comp); | |
| 1009 branch->set_is_checked(Isolate::Current()->type_checks()); | |
| 1010 } | |
| 1011 AddInstruction(branch); | 996 AddInstruction(branch); |
| 1012 CloseFragment(); | 997 CloseFragment(); |
| 1013 true_successor_addresses_.Add(branch->true_successor_address()); | 998 true_successor_addresses_.Add(branch->true_successor_address()); |
| 1014 false_successor_addresses_.Add(branch->false_successor_address()); | 999 false_successor_addresses_.Add(branch->false_successor_address()); |
| 1015 } | 1000 } |
| 1016 | 1001 |
| 1017 | 1002 |
| 1018 void TestGraphVisitor::MergeBranchWithNegate(BooleanNegateInstr* neg) { | 1003 void TestGraphVisitor::MergeBranchWithNegate(BooleanNegateInstr* neg) { |
| 1019 ASSERT(!Isolate::Current()->type_checks()); | 1004 ASSERT(!Isolate::Current()->type_checks()); |
| 1020 Value* constant_true = Bind(new (Z) ConstantInstr(Bool::True())); | 1005 Value* constant_true = Bind(new (Z) ConstantInstr(Bool::True())); |
| 1021 StrictCompareInstr* comp = new (Z) StrictCompareInstr( | 1006 StrictCompareInstr* comp = new (Z) StrictCompareInstr( |
| 1022 condition_token_pos(), Token::kNE_STRICT, neg->value(), constant_true, | 1007 condition_token_pos(), Token::kNE_STRICT, neg->value(), constant_true, |
| 1023 false); // No number check. | 1008 false); // No number check. |
| 1024 BranchInstr* branch = new (Z) BranchInstr(comp); | 1009 BranchInstr* branch = new (Z) BranchInstr(comp); |
| 1025 AddInstruction(branch); | 1010 AddInstruction(branch); |
| 1026 CloseFragment(); | 1011 CloseFragment(); |
| 1027 true_successor_addresses_.Add(branch->true_successor_address()); | 1012 true_successor_addresses_.Add(branch->true_successor_address()); |
| 1028 false_successor_addresses_.Add(branch->false_successor_address()); | 1013 false_successor_addresses_.Add(branch->false_successor_address()); |
| 1029 } | 1014 } |
| 1030 | 1015 |
| 1031 | 1016 |
| 1032 void TestGraphVisitor::ReturnDefinition(Definition* definition) { | 1017 void TestGraphVisitor::ReturnDefinition(Definition* definition) { |
| 1033 ComparisonInstr* comp = definition->AsComparison(); | 1018 StrictCompareInstr* comp = definition->AsStrictCompare(); |
| 1034 if (comp != NULL) { | 1019 if (comp != NULL) { |
| 1035 MergeBranchWithComparison(comp); | 1020 MergeBranchWithStrictCompare(comp); |
| 1036 return; | 1021 return; |
| 1037 } | 1022 } |
| 1038 if (!Isolate::Current()->type_checks()) { | 1023 if (!Isolate::Current()->type_checks()) { |
| 1039 BooleanNegateInstr* neg = definition->AsBooleanNegate(); | 1024 BooleanNegateInstr* neg = definition->AsBooleanNegate(); |
| 1040 if (neg != NULL) { | 1025 if (neg != NULL) { |
| 1041 MergeBranchWithNegate(neg); | 1026 MergeBranchWithNegate(neg); |
| 1042 return; | 1027 return; |
| 1043 } | 1028 } |
| 1044 } | 1029 } |
| 1045 ReturnValue(Bind(definition)); | 1030 ReturnValue(Bind(definition)); |
| (...skipping 3302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4348 graph_entry_->PruneUnreachable(graph_entry_, NULL, osr_id_, block_marks); | 4333 graph_entry_->PruneUnreachable(graph_entry_, NULL, osr_id_, block_marks); |
| 4349 ASSERT(found); | 4334 ASSERT(found); |
| 4350 } | 4335 } |
| 4351 | 4336 |
| 4352 | 4337 |
| 4353 void FlowGraphBuilder::Bailout(const char* reason) const { | 4338 void FlowGraphBuilder::Bailout(const char* reason) const { |
| 4354 parsed_function_.Bailout("FlowGraphBuilder", reason); | 4339 parsed_function_.Bailout("FlowGraphBuilder", reason); |
| 4355 } | 4340 } |
| 4356 | 4341 |
| 4357 } // namespace dart | 4342 } // namespace dart |
| OLD | NEW |