| 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/code_descriptors.h" | 10 #include "vm/code_descriptors.h" |
| (...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 679 BranchInstr* branch = new BranchInstr(comp); | 679 BranchInstr* branch = new BranchInstr(comp); |
| 680 AddInstruction(branch); | 680 AddInstruction(branch); |
| 681 CloseFragment(); | 681 CloseFragment(); |
| 682 | 682 |
| 683 true_successor_addresses_.Add(branch->true_successor_address()); | 683 true_successor_addresses_.Add(branch->true_successor_address()); |
| 684 false_successor_addresses_.Add(branch->false_successor_address()); | 684 false_successor_addresses_.Add(branch->false_successor_address()); |
| 685 } | 685 } |
| 686 | 686 |
| 687 | 687 |
| 688 void TestGraphVisitor::MergeBranchWithComparison(ComparisonInstr* comp) { | 688 void TestGraphVisitor::MergeBranchWithComparison(ComparisonInstr* comp) { |
| 689 ControlInstruction* branch; | 689 BranchInstr* branch; |
| 690 if (Token::IsStrictEqualityOperator(comp->kind())) { | 690 if (Token::IsStrictEqualityOperator(comp->kind())) { |
| 691 branch = new BranchInstr(new StrictCompareInstr(comp->token_pos(), | 691 branch = new BranchInstr(new StrictCompareInstr(comp->token_pos(), |
| 692 comp->kind(), | 692 comp->kind(), |
| 693 comp->left(), | 693 comp->left(), |
| 694 comp->right())); | 694 comp->right())); |
| 695 } else if (Token::IsEqualityOperator(comp->kind()) && | 695 } else if (Token::IsEqualityOperator(comp->kind()) && |
| 696 (comp->left()->BindsToConstantNull() || | 696 (comp->left()->BindsToConstantNull() || |
| 697 comp->right()->BindsToConstantNull())) { | 697 comp->right()->BindsToConstantNull())) { |
| 698 branch = new BranchInstr(new StrictCompareInstr( | 698 branch = new BranchInstr(new StrictCompareInstr( |
| 699 comp->token_pos(), | 699 comp->token_pos(), |
| (...skipping 713 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1413 node->token_pos(), | 1413 node->token_pos(), |
| 1414 node->kind(), | 1414 node->kind(), |
| 1415 for_left_value.value(), | 1415 for_left_value.value(), |
| 1416 for_right_value.value(), | 1416 for_right_value.value(), |
| 1417 owner()->ic_data_array()); | 1417 owner()->ic_data_array()); |
| 1418 ReturnDefinition(comp); | 1418 ReturnDefinition(comp); |
| 1419 } | 1419 } |
| 1420 return; | 1420 return; |
| 1421 } | 1421 } |
| 1422 | 1422 |
| 1423 ZoneGrowableArray<PushArgumentInstr*>* arguments = |
| 1424 new ZoneGrowableArray<PushArgumentInstr*>(2); |
| 1425 |
| 1423 ValueGraphVisitor for_left_value(owner(), temp_index()); | 1426 ValueGraphVisitor for_left_value(owner(), temp_index()); |
| 1424 node->left()->Visit(&for_left_value); | 1427 node->left()->Visit(&for_left_value); |
| 1425 Append(for_left_value); | 1428 Append(for_left_value); |
| 1429 PushArgumentInstr* push_left = PushArgument(for_left_value.value()); |
| 1430 arguments->Add(push_left); |
| 1431 |
| 1426 ValueGraphVisitor for_right_value(owner(), temp_index()); | 1432 ValueGraphVisitor for_right_value(owner(), temp_index()); |
| 1427 node->right()->Visit(&for_right_value); | 1433 node->right()->Visit(&for_right_value); |
| 1428 Append(for_right_value); | 1434 Append(for_right_value); |
| 1429 RelationalOpInstr* comp = new RelationalOpInstr(node->token_pos(), | 1435 PushArgumentInstr* push_right = PushArgument(for_right_value.value()); |
| 1430 node->kind(), | 1436 arguments->Add(push_right); |
| 1431 for_left_value.value(), | 1437 |
| 1432 for_right_value.value(), | 1438 ASSERT(Token::IsRelationalOperator(node->kind())); |
| 1433 owner()->ic_data_array()); | 1439 InstanceCallInstr* comp = |
| 1440 new InstanceCallInstr(node->token_pos(), |
| 1441 String::ZoneHandle(Symbols::New(node->Name())), |
| 1442 node->kind(), |
| 1443 arguments, |
| 1444 Object::null_array(), |
| 1445 2, |
| 1446 owner()->ic_data_array()); |
| 1434 ReturnDefinition(comp); | 1447 ReturnDefinition(comp); |
| 1435 } | 1448 } |
| 1436 | 1449 |
| 1437 | 1450 |
| 1438 void EffectGraphVisitor::VisitUnaryOpNode(UnaryOpNode* node) { | 1451 void EffectGraphVisitor::VisitUnaryOpNode(UnaryOpNode* node) { |
| 1439 // "!" cannot be overloaded, therefore do not call operator. | 1452 // "!" cannot be overloaded, therefore do not call operator. |
| 1440 if (node->kind() == Token::kNOT) { | 1453 if (node->kind() == Token::kNOT) { |
| 1441 ValueGraphVisitor for_value(owner(), temp_index()); | 1454 ValueGraphVisitor for_value(owner(), temp_index()); |
| 1442 node->operand()->Visit(&for_value); | 1455 node->operand()->Visit(&for_value); |
| 1443 Append(for_value); | 1456 Append(for_value); |
| 1444 Value* value = for_value.value(); | 1457 Value* value = for_value.value(); |
| 1445 if (FLAG_enable_type_checks) { | 1458 if (FLAG_enable_type_checks) { |
| 1446 value = | 1459 value = |
| 1447 Bind(new AssertBooleanInstr(node->operand()->token_pos(), value)); | 1460 Bind(new AssertBooleanInstr(node->operand()->token_pos(), value)); |
| 1448 } | 1461 } |
| 1449 BooleanNegateInstr* negate = new BooleanNegateInstr(value); | 1462 BooleanNegateInstr* negate = new BooleanNegateInstr(value); |
| 1450 ReturnDefinition(negate); | 1463 ReturnDefinition(negate); |
| 1451 return; | 1464 return; |
| 1452 } | 1465 } |
| 1453 | 1466 |
| 1454 ValueGraphVisitor for_value(owner(), temp_index()); | 1467 ValueGraphVisitor for_value(owner(), temp_index()); |
| 1455 node->operand()->Visit(&for_value); | 1468 node->operand()->Visit(&for_value); |
| 1456 Append(for_value); | 1469 Append(for_value); |
| 1457 PushArgumentInstr* push_value = PushArgument(for_value.value()); | 1470 PushArgumentInstr* push_value = PushArgument(for_value.value()); |
| 1458 ZoneGrowableArray<PushArgumentInstr*>* arguments = | 1471 ZoneGrowableArray<PushArgumentInstr*>* arguments = |
| 1459 new ZoneGrowableArray<PushArgumentInstr*>(1); | 1472 new ZoneGrowableArray<PushArgumentInstr*>(1); |
| 1460 arguments->Add(push_value); | 1473 arguments->Add(push_value); |
| 1461 InstanceCallInstr* call = | 1474 InstanceCallInstr* call = |
| 1462 new InstanceCallInstr(node->token_pos(), | 1475 new InstanceCallInstr(node->token_pos(), |
| 1463 String::ZoneHandle( | 1476 String::ZoneHandle(Symbols::New(node->Name())), |
| 1464 Symbols::New(Token::Str(node->kind()))), | |
| 1465 node->kind(), | 1477 node->kind(), |
| 1466 arguments, | 1478 arguments, |
| 1467 Object::null_array(), | 1479 Object::null_array(), |
| 1468 1, | 1480 1, |
| 1469 owner()->ic_data_array()); | 1481 owner()->ic_data_array()); |
| 1470 ReturnDefinition(call); | 1482 ReturnDefinition(call); |
| 1471 } | 1483 } |
| 1472 | 1484 |
| 1473 | 1485 |
| 1474 void EffectGraphVisitor::VisitConditionalExprNode(ConditionalExprNode* node) { | 1486 void EffectGraphVisitor::VisitConditionalExprNode(ConditionalExprNode* node) { |
| (...skipping 2333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3808 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1; | 3820 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1; |
| 3809 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 3821 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); |
| 3810 OS::SNPrint(chars, len, kFormat, function_name, reason); | 3822 OS::SNPrint(chars, len, kFormat, function_name, reason); |
| 3811 const Error& error = Error::Handle( | 3823 const Error& error = Error::Handle( |
| 3812 LanguageError::New(String::Handle(String::New(chars)))); | 3824 LanguageError::New(String::Handle(String::New(chars)))); |
| 3813 Isolate::Current()->long_jump_base()->Jump(1, error); | 3825 Isolate::Current()->long_jump_base()->Jump(1, error); |
| 3814 } | 3826 } |
| 3815 | 3827 |
| 3816 | 3828 |
| 3817 } // namespace dart | 3829 } // namespace dart |
| OLD | NEW |