| 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/class_finalizer.h" | 10 #include "vm/class_finalizer.h" |
| (...skipping 2088 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2099 Append(for_value); | 2099 Append(for_value); |
| 2100 Value* temp_val = for_value.value(); | 2100 Value* temp_val = for_value.value(); |
| 2101 node->TempAt(i)->set_index(GetCurrentTempLocalIndex()); | 2101 node->TempAt(i)->set_index(GetCurrentTempLocalIndex()); |
| 2102 Do(new PushTempInstr(temp_val)); | 2102 Do(new PushTempInstr(temp_val)); |
| 2103 owner()->AllocateTemp(); | 2103 owner()->AllocateTemp(); |
| 2104 } | 2104 } |
| 2105 } | 2105 } |
| 2106 | 2106 |
| 2107 | 2107 |
| 2108 void EffectGraphVisitor::VisitLetNode(LetNode* node) { | 2108 void EffectGraphVisitor::VisitLetNode(LetNode* node) { |
| 2109 BuildLetTempExpressions(node); |
| 2110 |
| 2111 // Visit body. |
| 2112 for (intptr_t i = 0; i < node->nodes().length(); ++i) { |
| 2113 EffectGraphVisitor for_effect(owner()); |
| 2114 node->nodes()[i]->Visit(&for_effect); |
| 2115 Append(for_effect); |
| 2116 } |
| 2117 |
| 2109 intptr_t num_temps = node->num_temps(); | 2118 intptr_t num_temps = node->num_temps(); |
| 2110 if (num_temps > 0) { | 2119 if (num_temps > 0) { |
| 2111 BuildLetTempExpressions(node); | |
| 2112 // TODO(fschneider): Generate better code for effect context by visiting the | |
| 2113 // body for effect. Currently, the value of the body expression is | |
| 2114 // materialized and then dropped. This also requires changing DropTempsInstr | |
| 2115 // to have zero or one inputs. | |
| 2116 | |
| 2117 // Visit body. | |
| 2118 for (intptr_t i = 0; i < node->nodes().length() - 1; ++i) { | |
| 2119 EffectGraphVisitor for_effect(owner()); | |
| 2120 node->nodes()[i]->Visit(&for_effect); | |
| 2121 Append(for_effect); | |
| 2122 } | |
| 2123 // Visit the last body expression for value. | |
| 2124 ValueGraphVisitor for_value(owner()); | |
| 2125 node->nodes().Last()->Visit(&for_value); | |
| 2126 Append(for_value); | |
| 2127 Value* result_value = for_value.value(); | |
| 2128 owner()->DeallocateTemps(num_temps); | 2120 owner()->DeallocateTemps(num_temps); |
| 2129 Do(new DropTempsInstr(num_temps, result_value)); | 2121 Do(new DropTempsInstr(num_temps)); |
| 2130 } else { | |
| 2131 ASSERT(num_temps == 0); | |
| 2132 for (intptr_t i = 0; i < node->nodes().length(); ++i) { | |
| 2133 EffectGraphVisitor for_effect(owner()); | |
| 2134 node->nodes()[i]->Visit(&for_effect); | |
| 2135 Append(for_effect); | |
| 2136 } | |
| 2137 } | 2122 } |
| 2138 } | 2123 } |
| 2139 | 2124 |
| 2140 | 2125 |
| 2141 void ValueGraphVisitor::VisitLetNode(LetNode* node) { | 2126 void ValueGraphVisitor::VisitLetNode(LetNode* node) { |
| 2142 BuildLetTempExpressions(node); | 2127 BuildLetTempExpressions(node); |
| 2143 | 2128 |
| 2144 // Visit body. | 2129 // Visit body. |
| 2145 for (intptr_t i = 0; i < node->nodes().length() - 1; ++i) { | 2130 for (intptr_t i = 0; i < node->nodes().length() - 1; ++i) { |
| 2146 EffectGraphVisitor for_effect(owner()); | 2131 EffectGraphVisitor for_effect(owner()); |
| (...skipping 1755 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3902 LanguageError::kError, | 3887 LanguageError::kError, |
| 3903 Heap::kNew, | 3888 Heap::kNew, |
| 3904 "FlowGraphBuilder Bailout: %s %s", | 3889 "FlowGraphBuilder Bailout: %s %s", |
| 3905 String::Handle(function.name()).ToCString(), | 3890 String::Handle(function.name()).ToCString(), |
| 3906 reason)); | 3891 reason)); |
| 3907 Isolate::Current()->long_jump_base()->Jump(1, error); | 3892 Isolate::Current()->long_jump_base()->Jump(1, error); |
| 3908 } | 3893 } |
| 3909 | 3894 |
| 3910 | 3895 |
| 3911 } // namespace dart | 3896 } // namespace dart |
| OLD | NEW |