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

Side by Side Diff: runtime/vm/flow_graph_builder.cc

Issue 10389041: Adapt compile time constants and integrate with Kevin's CL 10302007 (Remove temporaries using expli… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/code_descriptors.h" 8 #include "vm/code_descriptors.h"
9 #include "vm/dart_entry.h" 9 #include "vm/dart_entry.h"
10 #include "vm/flags.h" 10 #include "vm/flags.h"
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 if (FLAG_enable_type_checks) { 393 if (FLAG_enable_type_checks) {
394 BindInstr* assert_boolean = 394 BindInstr* assert_boolean =
395 new BindInstr(new AssertBooleanComp(node->right()->token_index(), 395 new BindInstr(new AssertBooleanComp(node->right()->token_index(),
396 owner()->try_index(), 396 owner()->try_index(),
397 right_value)); 397 right_value));
398 for_right.AddInstruction(assert_boolean); 398 for_right.AddInstruction(assert_boolean);
399 right_value = new UseVal(assert_boolean); 399 right_value = new UseVal(assert_boolean);
400 } 400 }
401 BindInstr* constant_true = new BindInstr(new ConstantVal(bool_true)); 401 BindInstr* constant_true = new BindInstr(new ConstantVal(bool_true));
402 for_right.AddInstruction(constant_true); 402 for_right.AddInstruction(constant_true);
403 StrictCompareComp* comp = new StrictCompareComp(Token::kEQ_STRICT, 403 BindInstr* comp =
404 right_value, new UseVal(constant_true)); 404 new BindInstr(new StrictCompareComp(Token::kEQ_STRICT,
405 for_right.AddInstruction(new BindInstr(comp)); 405 right_value,
406 new UseVal(constant_true)));
407 for_right.AddInstruction(comp);
408 for_right.AddInstruction(
409 new DoInstr(new StoreLocalComp(
410 *owner()->parsed_function().expression_temp_var(),
411 new UseVal(comp),
412 owner()->context_level())));
406 413
407 if (node->kind() == Token::kAND) { 414 if (node->kind() == Token::kAND) {
408 ValueGraphVisitor for_false(owner(), temp_index()); 415 ValueGraphVisitor for_false(owner(), temp_index());
409 for_false.ReturnComputation(new ConstantVal(bool_false)); 416 BindInstr* constant_false = new BindInstr(new ConstantVal(bool_false));
417 for_false.AddInstruction(constant_false);
418 for_false.AddInstruction(
419 new DoInstr(new StoreLocalComp(
420 *owner()->parsed_function().expression_temp_var(),
421 new UseVal(constant_false),
422 owner()->context_level())));
410 Join(for_test, for_right, for_false); 423 Join(for_test, for_right, for_false);
411 } else { 424 } else {
412 ASSERT(node->kind() == Token::kOR); 425 ASSERT(node->kind() == Token::kOR);
413 ValueGraphVisitor for_true(owner(), temp_index()); 426 ValueGraphVisitor for_true(owner(), temp_index());
414 for_true.ReturnComputation(new ConstantVal(bool_true)); 427 BindInstr* constant_true = new BindInstr(new ConstantVal(bool_true));
428 for_true.AddInstruction(constant_true);
429 for_true.AddInstruction(
430 new DoInstr(new StoreLocalComp(
431 *owner()->parsed_function().expression_temp_var(),
432 new UseVal(constant_true),
433 owner()->context_level())));
415 Join(for_test, for_true, for_right); 434 Join(for_test, for_true, for_right);
416 } 435 }
417 ReturnValue(new TempVal(temp_index() - 1)); 436 ReturnComputation(
437 new LoadLocalComp(*owner()->parsed_function().expression_temp_var(),
438 owner()->context_level()));
418 return; 439 return;
419 } 440 }
420 EffectGraphVisitor::VisitBinaryOpNode(node); 441 EffectGraphVisitor::VisitBinaryOpNode(node);
421 } 442 }
422 443
423 444
424 void EffectGraphVisitor::CompiletimeStringInterpolation( 445 void EffectGraphVisitor::CompiletimeStringInterpolation(
425 const Function& interpol_func, const Array& literals) { 446 const Function& interpol_func, const Array& literals) {
426 // Do nothing. 447 // Do nothing.
427 } 448 }
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
739 Join(for_test, for_true, for_false); 760 Join(for_test, for_true, for_false);
740 } 761 }
741 762
742 763
743 void ValueGraphVisitor::VisitConditionalExprNode(ConditionalExprNode* node) { 764 void ValueGraphVisitor::VisitConditionalExprNode(ConditionalExprNode* node) {
744 TestGraphVisitor for_test(owner(), 765 TestGraphVisitor for_test(owner(),
745 temp_index(), 766 temp_index(),
746 node->condition()->token_index()); 767 node->condition()->token_index());
747 node->condition()->Visit(&for_test); 768 node->condition()->Visit(&for_test);
748 769
749 // Ensure that the value of the true/false subexpressions are named with
750 // the same temporary name.
751 ValueGraphVisitor for_true(owner(), temp_index()); 770 ValueGraphVisitor for_true(owner(), temp_index());
752 node->true_expr()->Visit(&for_true); 771 node->true_expr()->Visit(&for_true);
753 ASSERT(for_true.is_open()); 772 ASSERT(for_true.is_open());
754 ASSERT(for_true.value()->IsTemp() || for_true.value()->IsUse()); 773 for_true.AddInstruction(
774 new DoInstr(
775 new StoreLocalComp(*owner()->parsed_function().expression_temp_var(),
776 for_true.value(),
777 owner()->context_level())));
755 778
756 ValueGraphVisitor for_false(owner(), temp_index()); 779 ValueGraphVisitor for_false(owner(), temp_index());
757 node->false_expr()->Visit(&for_false); 780 node->false_expr()->Visit(&for_false);
758 ASSERT(for_false.is_open()); 781 ASSERT(for_false.is_open());
759 ASSERT(for_false.value()->IsTemp() || for_false.value()->IsUse()); 782 for_false.AddInstruction(
783 new DoInstr(
784 new StoreLocalComp(*owner()->parsed_function().expression_temp_var(),
785 for_false.value(),
786 owner()->context_level())));
760 787
761 Join(for_test, for_true, for_false); 788 Join(for_test, for_true, for_false);
762 ReturnValue(new TempVal(temp_index() - 1)); 789 ReturnComputation(
790 new LoadLocalComp(*owner()->parsed_function().expression_temp_var(),
791 owner()->context_level()));
763 } 792 }
764 793
765 794
766 // <Statement> ::= If { condition: <Expression> 795 // <Statement> ::= If { condition: <Expression>
767 // true_branch: <Sequence> 796 // true_branch: <Sequence>
768 // false_branch: <Sequence> } 797 // false_branch: <Sequence> }
769 void EffectGraphVisitor::VisitIfNode(IfNode* node) { 798 void EffectGraphVisitor::VisitIfNode(IfNode* node) {
770 TestGraphVisitor for_test(owner(), 799 TestGraphVisitor for_test(owner(),
771 temp_index(), 800 temp_index(),
772 node->condition()->token_index()); 801 node->condition()->token_index());
(...skipping 1305 matching lines...) Expand 10 before | Expand all | Expand 10 after
2078 // For readability label blocks with their reverse postorder index, 2107 // For readability label blocks with their reverse postorder index,
2079 // not their postorder block number, so the first block is 0 (not 2108 // not their postorder block number, so the first block is 0 (not
2080 // n-1). 2109 // n-1).
2081 OS::Print(" goto %d", reverse_index(successor->postorder_number())); 2110 OS::Print(" goto %d", reverse_index(successor->postorder_number()));
2082 } 2111 }
2083 OS::Print("\n"); 2112 OS::Print("\n");
2084 } 2113 }
2085 } 2114 }
2086 2115
2087 2116
2088 void FlowGraphPrinter::VisitTemp(TempVal* val) {
2089 OS::Print("t%d", val->index());
2090 }
2091
2092
2093 void FlowGraphPrinter::VisitUse(UseVal* val) { 2117 void FlowGraphPrinter::VisitUse(UseVal* val) {
2094 OS::Print("s%d", val->definition()->temp_index()); 2118 OS::Print("t%d", val->definition()->temp_index());
2095 } 2119 }
2096 2120
2097 2121
2098 void FlowGraphPrinter::VisitConstant(ConstantVal* val) { 2122 void FlowGraphPrinter::VisitConstant(ConstantVal* val) {
2099 OS::Print("#%s", val->value().ToCString()); 2123 OS::Print("#%s", val->value().ToCString());
2100 } 2124 }
2101 2125
2102 2126
2103 void FlowGraphPrinter::VisitAssertAssignable(AssertAssignableComp* comp) { 2127 void FlowGraphPrinter::VisitAssertAssignable(AssertAssignableComp* comp) {
2104 OS::Print("AssertAssignable("); 2128 OS::Print("AssertAssignable(");
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after
2595 char* chars = reinterpret_cast<char*>( 2619 char* chars = reinterpret_cast<char*>(
2596 Isolate::Current()->current_zone()->Allocate(len)); 2620 Isolate::Current()->current_zone()->Allocate(len));
2597 OS::SNPrint(chars, len, kFormat, function_name, reason); 2621 OS::SNPrint(chars, len, kFormat, function_name, reason);
2598 const Error& error = Error::Handle( 2622 const Error& error = Error::Handle(
2599 LanguageError::New(String::Handle(String::New(chars)))); 2623 LanguageError::New(String::Handle(String::New(chars))));
2600 Isolate::Current()->long_jump_base()->Jump(1, error); 2624 Isolate::Current()->long_jump_base()->Jump(1, error);
2601 } 2625 }
2602 2626
2603 2627
2604 } // namespace dart 2628 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698