Chromium Code Reviews| 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 "vm/ast_printer.h" | 7 #include "vm/ast_printer.h" |
| 8 #include "vm/flags.h" | 8 #include "vm/flags.h" |
| 9 #include "vm/intermediate_language.h" | 9 #include "vm/intermediate_language.h" |
| 10 #include "vm/longjump.h" | 10 #include "vm/longjump.h" |
| (...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 531 arguments->Add(new TempVal(value_index)); | 531 arguments->Add(new TempVal(value_index)); |
| 532 InstanceCallComp* store = | 532 InstanceCallComp* store = |
| 533 new InstanceCallComp(node->store_id(), node->token_index(), store_name, | 533 new InstanceCallComp(node->store_id(), node->token_index(), store_name, |
| 534 arguments, Array::ZoneHandle(), 1); | 534 arguments, Array::ZoneHandle(), 1); |
| 535 AddInstruction(new DoInstr(store)); | 535 AddInstruction(new DoInstr(store)); |
| 536 ReturnValue(new TempVal(AllocateTempIndex())); | 536 ReturnValue(new TempVal(AllocateTempIndex())); |
| 537 } | 537 } |
| 538 | 538 |
| 539 | 539 |
| 540 void EffectGraphVisitor::VisitConditionalExprNode(ConditionalExprNode* node) { | 540 void EffectGraphVisitor::VisitConditionalExprNode(ConditionalExprNode* node) { |
| 541 Bailout("EffectGraphVisitor::VisitConditionalExprNode"); | 541 TestGraphVisitor for_test(owner(), temp_index()); |
| 542 node->condition()->Visit(&for_test); | |
| 543 ASSERT(for_test.can_be_true() && for_test.can_be_false()); | |
| 544 | |
| 545 // Translate the subexpressions for their effects. | |
| 546 EffectGraphVisitor for_true(owner(), temp_index()); | |
| 547 node->true_expr()->Visit(&for_true); | |
| 548 EffectGraphVisitor for_false(owner(), temp_index()); | |
| 549 node->false_expr()->Visit(&for_false); | |
| 550 | |
| 551 Join(for_test, for_true, for_false); | |
| 542 } | 552 } |
| 543 | 553 |
| 544 | 554 |
| 555 void ValueGraphVisitor::VisitConditionalExprNode(ConditionalExprNode* node) { | |
| 556 TestGraphVisitor for_test(owner(), temp_index()); | |
| 557 node->condition()->Visit(&for_test); | |
| 558 ASSERT(for_test.can_be_true() && for_test.can_be_false()); | |
|
srdjan
2012/03/08 17:43:53
Again, what is the point of can_be_true and can_be
Kevin Millikin (Google)
2012/03/09 09:53:01
To support online constant folding of conditional
| |
| 559 | |
| 560 // Ensure that the value of the true/false subexpressions are named with | |
| 561 // the same temporary name. | |
| 562 ValueGraphVisitor for_true(owner(), temp_index()); | |
| 563 node->true_expr()->Visit(&for_true); | |
| 564 ASSERT(for_true.is_open()); | |
| 565 if (for_true.value()->IsTemp()) { | |
| 566 ASSERT(for_true.value()->AsTemp()->index() == temp_index()); | |
| 567 } else { | |
| 568 for_true.AddInstruction(new BindInstr(temp_index(), for_true.value())); | |
| 569 } | |
| 570 | |
| 571 ValueGraphVisitor for_false(owner(), temp_index()); | |
| 572 node->false_expr()->Visit(&for_false); | |
| 573 ASSERT(for_false.is_open()); | |
| 574 if (for_false.value()->IsTemp()) { | |
| 575 ASSERT(for_false.value()->AsTemp()->index() == temp_index()); | |
| 576 } else { | |
| 577 for_false.AddInstruction(new BindInstr(temp_index(), for_false.value())); | |
| 578 } | |
| 579 | |
| 580 Join(for_test, for_true, for_false); | |
| 581 ReturnValue(new TempVal(AllocateTempIndex())); | |
| 582 } | |
| 583 | |
| 584 | |
| 545 // <Statement> ::= If { condition: <Expression> | 585 // <Statement> ::= If { condition: <Expression> |
| 546 // true_branch: <Sequence> | 586 // true_branch: <Sequence> |
| 547 // false_branch: <Sequence> } | 587 // false_branch: <Sequence> } |
| 548 void EffectGraphVisitor::VisitIfNode(IfNode* node) { | 588 void EffectGraphVisitor::VisitIfNode(IfNode* node) { |
| 549 TestGraphVisitor for_test(owner(), temp_index()); | 589 TestGraphVisitor for_test(owner(), temp_index()); |
| 550 node->condition()->Visit(&for_test); | 590 node->condition()->Visit(&for_test); |
| 551 | 591 |
| 552 EffectGraphVisitor for_true(owner(), temp_index()); | 592 EffectGraphVisitor for_true(owner(), temp_index()); |
| 553 EffectGraphVisitor for_false(owner(), temp_index()); | 593 EffectGraphVisitor for_false(owner(), temp_index()); |
| 554 | 594 |
| (...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1176 char* chars = reinterpret_cast<char*>( | 1216 char* chars = reinterpret_cast<char*>( |
| 1177 Isolate::Current()->current_zone()->Allocate(len)); | 1217 Isolate::Current()->current_zone()->Allocate(len)); |
| 1178 OS::SNPrint(chars, len, kFormat, function_name, reason); | 1218 OS::SNPrint(chars, len, kFormat, function_name, reason); |
| 1179 const Error& error = Error::Handle( | 1219 const Error& error = Error::Handle( |
| 1180 LanguageError::New(String::Handle(String::New(chars)))); | 1220 LanguageError::New(String::Handle(String::New(chars)))); |
| 1181 Isolate::Current()->long_jump_base()->Jump(1, error); | 1221 Isolate::Current()->long_jump_base()->Jump(1, error); |
| 1182 } | 1222 } |
| 1183 | 1223 |
| 1184 | 1224 |
| 1185 } // namespace dart | 1225 } // namespace dart |
| OLD | NEW |