| 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/code_descriptors.h" | 9 #include "vm/code_descriptors.h" |
| 10 #include "vm/dart_entry.h" | 10 #include "vm/dart_entry.h" |
| (...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 613 return CreateSuccessorFor(false_successor_addresses_); | 613 return CreateSuccessorFor(false_successor_addresses_); |
| 614 } | 614 } |
| 615 | 615 |
| 616 | 616 |
| 617 void TestGraphVisitor::ReturnValue(Value* value) { | 617 void TestGraphVisitor::ReturnValue(Value* value) { |
| 618 if (FLAG_enable_type_checks) { | 618 if (FLAG_enable_type_checks) { |
| 619 value = Bind(new AssertBooleanInstr(condition_token_pos(), value)); | 619 value = Bind(new AssertBooleanInstr(condition_token_pos(), value)); |
| 620 } | 620 } |
| 621 Value* constant_true = Bind(new ConstantInstr(Bool::True())); | 621 Value* constant_true = Bind(new ConstantInstr(Bool::True())); |
| 622 StrictCompareInstr* comp = | 622 StrictCompareInstr* comp = |
| 623 new StrictCompareInstr(Token::kEQ_STRICT, value, constant_true); | 623 new StrictCompareInstr(condition_token_pos(), |
| 624 Token::kEQ_STRICT, |
| 625 value, |
| 626 constant_true); |
| 624 BranchInstr* branch = new BranchInstr(comp); | 627 BranchInstr* branch = new BranchInstr(comp); |
| 625 AddInstruction(branch); | 628 AddInstruction(branch); |
| 626 CloseFragment(); | 629 CloseFragment(); |
| 627 | 630 |
| 628 true_successor_addresses_.Add(branch->true_successor_address()); | 631 true_successor_addresses_.Add(branch->true_successor_address()); |
| 629 false_successor_addresses_.Add(branch->false_successor_address()); | 632 false_successor_addresses_.Add(branch->false_successor_address()); |
| 630 } | 633 } |
| 631 | 634 |
| 632 | 635 |
| 633 void TestGraphVisitor::MergeBranchWithComparison(ComparisonInstr* comp) { | 636 void TestGraphVisitor::MergeBranchWithComparison(ComparisonInstr* comp) { |
| 634 ControlInstruction* branch; | 637 ControlInstruction* branch; |
| 635 if (Token::IsStrictEqualityOperator(comp->kind())) { | 638 if (Token::IsStrictEqualityOperator(comp->kind())) { |
| 636 branch = new BranchInstr(new StrictCompareInstr(comp->kind(), | 639 branch = new BranchInstr(new StrictCompareInstr(comp->token_pos(), |
| 640 comp->kind(), |
| 637 comp->left(), | 641 comp->left(), |
| 638 comp->right())); | 642 comp->right())); |
| 639 } else if (Token::IsEqualityOperator(comp->kind()) && | 643 } else if (Token::IsEqualityOperator(comp->kind()) && |
| 640 (comp->left()->BindsToConstantNull() || | 644 (comp->left()->BindsToConstantNull() || |
| 641 comp->right()->BindsToConstantNull())) { | 645 comp->right()->BindsToConstantNull())) { |
| 642 branch = new BranchInstr(new StrictCompareInstr( | 646 branch = new BranchInstr(new StrictCompareInstr( |
| 647 comp->token_pos(), |
| 643 (comp->kind() == Token::kEQ) ? Token::kEQ_STRICT : Token::kNE_STRICT, | 648 (comp->kind() == Token::kEQ) ? Token::kEQ_STRICT : Token::kNE_STRICT, |
| 644 comp->left(), | 649 comp->left(), |
| 645 comp->right())); | 650 comp->right())); |
| 646 } else { | 651 } else { |
| 647 branch = new BranchInstr(comp, FLAG_enable_type_checks); | 652 branch = new BranchInstr(comp, FLAG_enable_type_checks); |
| 648 } | 653 } |
| 649 AddInstruction(branch); | 654 AddInstruction(branch); |
| 650 CloseFragment(); | 655 CloseFragment(); |
| 651 true_successor_addresses_.Add(branch->true_successor_address()); | 656 true_successor_addresses_.Add(branch->true_successor_address()); |
| 652 false_successor_addresses_.Add(branch->false_successor_address()); | 657 false_successor_addresses_.Add(branch->false_successor_address()); |
| 653 } | 658 } |
| 654 | 659 |
| 655 | 660 |
| 656 void TestGraphVisitor::MergeBranchWithNegate(BooleanNegateInstr* neg) { | 661 void TestGraphVisitor::MergeBranchWithNegate(BooleanNegateInstr* neg) { |
| 657 ASSERT(!FLAG_enable_type_checks); | 662 ASSERT(!FLAG_enable_type_checks); |
| 658 Value* constant_true = Bind(new ConstantInstr(Bool::True())); | 663 Value* constant_true = Bind(new ConstantInstr(Bool::True())); |
| 659 BranchInstr* branch = new BranchInstr( | 664 BranchInstr* branch = new BranchInstr( |
| 660 new StrictCompareInstr(Token::kNE_STRICT, neg->value(), constant_true)); | 665 new StrictCompareInstr(condition_token_pos(), |
| 666 Token::kNE_STRICT, |
| 667 neg->value(), |
| 668 constant_true)); |
| 661 AddInstruction(branch); | 669 AddInstruction(branch); |
| 662 CloseFragment(); | 670 CloseFragment(); |
| 663 true_successor_addresses_.Add(branch->true_successor_address()); | 671 true_successor_addresses_.Add(branch->true_successor_address()); |
| 664 false_successor_addresses_.Add(branch->false_successor_address()); | 672 false_successor_addresses_.Add(branch->false_successor_address()); |
| 665 } | 673 } |
| 666 | 674 |
| 667 | 675 |
| 668 void TestGraphVisitor::ReturnDefinition(Definition* definition) { | 676 void TestGraphVisitor::ReturnDefinition(Definition* definition) { |
| 669 ComparisonInstr* comp = definition->AsComparison(); | 677 ComparisonInstr* comp = definition->AsComparison(); |
| 670 if (comp != NULL) { | 678 if (comp != NULL) { |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 952 ValueGraphVisitor for_right(owner(), temp_index()); | 960 ValueGraphVisitor for_right(owner(), temp_index()); |
| 953 node->right()->Visit(&for_right); | 961 node->right()->Visit(&for_right); |
| 954 Value* right_value = for_right.value(); | 962 Value* right_value = for_right.value(); |
| 955 if (FLAG_enable_type_checks) { | 963 if (FLAG_enable_type_checks) { |
| 956 right_value = | 964 right_value = |
| 957 for_right.Bind(new AssertBooleanInstr(node->right()->token_pos(), | 965 for_right.Bind(new AssertBooleanInstr(node->right()->token_pos(), |
| 958 right_value)); | 966 right_value)); |
| 959 } | 967 } |
| 960 Value* constant_true = for_right.Bind(new ConstantInstr(Bool::True())); | 968 Value* constant_true = for_right.Bind(new ConstantInstr(Bool::True())); |
| 961 Value* compare = | 969 Value* compare = |
| 962 for_right.Bind(new StrictCompareInstr(Token::kEQ_STRICT, | 970 for_right.Bind(new StrictCompareInstr(node->token_pos(), |
| 971 Token::kEQ_STRICT, |
| 963 right_value, | 972 right_value, |
| 964 constant_true)); | 973 constant_true)); |
| 965 for_right.Do(BuildStoreExprTemp(compare)); | 974 for_right.Do(BuildStoreExprTemp(compare)); |
| 966 | 975 |
| 967 if (node->kind() == Token::kAND) { | 976 if (node->kind() == Token::kAND) { |
| 968 ValueGraphVisitor for_false(owner(), temp_index()); | 977 ValueGraphVisitor for_false(owner(), temp_index()); |
| 969 Value* constant_false = for_false.Bind(new ConstantInstr(Bool::False())); | 978 Value* constant_false = for_false.Bind(new ConstantInstr(Bool::False())); |
| 970 for_false.Do(BuildStoreExprTemp(constant_false)); | 979 for_false.Do(BuildStoreExprTemp(constant_false)); |
| 971 Join(for_test, for_right, for_false); | 980 Join(for_test, for_right, for_false); |
| 972 } else { | 981 } else { |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1262 return; | 1271 return; |
| 1263 } | 1272 } |
| 1264 if ((node->kind() == Token::kEQ_STRICT) || | 1273 if ((node->kind() == Token::kEQ_STRICT) || |
| 1265 (node->kind() == Token::kNE_STRICT)) { | 1274 (node->kind() == Token::kNE_STRICT)) { |
| 1266 ValueGraphVisitor for_left_value(owner(), temp_index()); | 1275 ValueGraphVisitor for_left_value(owner(), temp_index()); |
| 1267 node->left()->Visit(&for_left_value); | 1276 node->left()->Visit(&for_left_value); |
| 1268 Append(for_left_value); | 1277 Append(for_left_value); |
| 1269 ValueGraphVisitor for_right_value(owner(), temp_index()); | 1278 ValueGraphVisitor for_right_value(owner(), temp_index()); |
| 1270 node->right()->Visit(&for_right_value); | 1279 node->right()->Visit(&for_right_value); |
| 1271 Append(for_right_value); | 1280 Append(for_right_value); |
| 1272 StrictCompareInstr* comp = new StrictCompareInstr( | 1281 StrictCompareInstr* comp = new StrictCompareInstr(node->token_pos(), |
| 1273 node->kind(), for_left_value.value(), for_right_value.value()); | 1282 node->kind(), |
| 1283 for_left_value.value(), |
| 1284 for_right_value.value()); |
| 1274 ReturnDefinition(comp); | 1285 ReturnDefinition(comp); |
| 1275 return; | 1286 return; |
| 1276 } | 1287 } |
| 1277 | 1288 |
| 1278 if ((node->kind() == Token::kEQ) || (node->kind() == Token::kNE)) { | 1289 if ((node->kind() == Token::kEQ) || (node->kind() == Token::kNE)) { |
| 1279 ValueGraphVisitor for_left_value(owner(), temp_index()); | 1290 ValueGraphVisitor for_left_value(owner(), temp_index()); |
| 1280 node->left()->Visit(&for_left_value); | 1291 node->left()->Visit(&for_left_value); |
| 1281 Append(for_left_value); | 1292 Append(for_left_value); |
| 1282 ValueGraphVisitor for_right_value(owner(), temp_index()); | 1293 ValueGraphVisitor for_right_value(owner(), temp_index()); |
| 1283 node->right()->Visit(&for_right_value); | 1294 node->right()->Visit(&for_right_value); |
| (...skipping 2111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3395 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1; | 3406 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1; |
| 3396 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 3407 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); |
| 3397 OS::SNPrint(chars, len, kFormat, function_name, reason); | 3408 OS::SNPrint(chars, len, kFormat, function_name, reason); |
| 3398 const Error& error = Error::Handle( | 3409 const Error& error = Error::Handle( |
| 3399 LanguageError::New(String::Handle(String::New(chars)))); | 3410 LanguageError::New(String::Handle(String::New(chars)))); |
| 3400 Isolate::Current()->long_jump_base()->Jump(1, error); | 3411 Isolate::Current()->long_jump_base()->Jump(1, error); |
| 3401 } | 3412 } |
| 3402 | 3413 |
| 3403 | 3414 |
| 3404 } // namespace dart | 3415 } // namespace dart |
| OLD | NEW |