| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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/kernel_binary_flowgraph.h" | 5 #include "vm/kernel_binary_flowgraph.h" |
| 6 #include "vm/compiler.h" | 6 #include "vm/compiler.h" |
| 7 #include "vm/longjump.h" | 7 #include "vm/longjump.h" |
| 8 #include "vm/object_store.h" | 8 #include "vm/object_store.h" |
| 9 | 9 |
| 10 #if !defined(DART_PRECOMPILED_RUNTIME) | 10 #if !defined(DART_PRECOMPILED_RUNTIME) |
| (...skipping 1262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1273 } | 1273 } |
| 1274 // TODO(jensj): From kernel_binary.cc | 1274 // TODO(jensj): From kernel_binary.cc |
| 1275 // forinstmt->variable_->set_end_position(forinstmt->position_); | 1275 // forinstmt->variable_->set_end_position(forinstmt->position_); |
| 1276 ExitScope(body_position, builder_->reader_->max_position()); | 1276 ExitScope(body_position, builder_->reader_->max_position()); |
| 1277 --depth_.loop_; | 1277 --depth_.loop_; |
| 1278 --depth_.for_in_; | 1278 --depth_.for_in_; |
| 1279 return; | 1279 return; |
| 1280 } | 1280 } |
| 1281 case kSwitchStatement: { | 1281 case kSwitchStatement: { |
| 1282 AddSwitchVariable(); | 1282 AddSwitchVariable(); |
| 1283 builder_->ReadPosition(); // read position. |
| 1283 VisitExpression(); // read condition. | 1284 VisitExpression(); // read condition. |
| 1284 int case_count = builder_->ReadListLength(); // read number of cases. | 1285 int case_count = builder_->ReadListLength(); // read number of cases. |
| 1285 for (intptr_t i = 0; i < case_count; ++i) { | 1286 for (intptr_t i = 0; i < case_count; ++i) { |
| 1286 int expression_count = | 1287 int expression_count = |
| 1287 builder_->ReadListLength(); // read number of expressions. | 1288 builder_->ReadListLength(); // read number of expressions. |
| 1288 for (intptr_t j = 0; j < expression_count; ++j) { | 1289 for (intptr_t j = 0; j < expression_count; ++j) { |
| 1289 builder_->ReadPosition(); // read jth position. | 1290 builder_->ReadPosition(); // read jth position. |
| 1290 VisitExpression(); // read jth expression. | 1291 VisitExpression(); // read jth expression. |
| 1291 } | 1292 } |
| 1292 builder_->ReadBool(); // read is_default. | 1293 builder_->ReadBool(); // read is_default. |
| (...skipping 3263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4556 } | 4557 } |
| 4557 case kForInStatement: | 4558 case kForInStatement: |
| 4558 case kAsyncForInStatement: | 4559 case kAsyncForInStatement: |
| 4559 ReadPosition(); // read position. | 4560 ReadPosition(); // read position. |
| 4560 ReadPosition(); // read body position. | 4561 ReadPosition(); // read body position. |
| 4561 SkipVariableDeclaration(); // read variable. | 4562 SkipVariableDeclaration(); // read variable. |
| 4562 SkipExpression(); // read iterable. | 4563 SkipExpression(); // read iterable. |
| 4563 SkipStatement(); // read body. | 4564 SkipStatement(); // read body. |
| 4564 return; | 4565 return; |
| 4565 case kSwitchStatement: { | 4566 case kSwitchStatement: { |
| 4567 ReadPosition(); // read position. |
| 4566 SkipExpression(); // read condition. | 4568 SkipExpression(); // read condition. |
| 4567 int case_count = ReadListLength(); // read number of cases. | 4569 int case_count = ReadListLength(); // read number of cases. |
| 4568 for (intptr_t i = 0; i < case_count; ++i) { | 4570 for (intptr_t i = 0; i < case_count; ++i) { |
| 4569 int expression_count = ReadListLength(); // read number of expressions. | 4571 int expression_count = ReadListLength(); // read number of expressions. |
| 4570 for (intptr_t j = 0; j < expression_count; ++j) { | 4572 for (intptr_t j = 0; j < expression_count; ++j) { |
| 4571 ReadPosition(); // read jth position. | 4573 ReadPosition(); // read jth position. |
| 4572 SkipExpression(); // read jth expression. | 4574 SkipExpression(); // read jth expression. |
| 4573 } | 4575 } |
| 4574 ReadBool(); // read is_default. | 4576 ReadBool(); // read is_default. |
| 4575 SkipStatement(); // read body. | 4577 SkipStatement(); // read body. |
| (...skipping 2167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6743 } else { | 6745 } else { |
| 6744 instructions += condition; | 6746 instructions += condition; |
| 6745 } | 6747 } |
| 6746 | 6748 |
| 6747 loop_depth_dec(); | 6749 loop_depth_dec(); |
| 6748 for_in_depth_dec(); | 6750 for_in_depth_dec(); |
| 6749 return Fragment(instructions.entry, loop_exit); | 6751 return Fragment(instructions.entry, loop_exit); |
| 6750 } | 6752 } |
| 6751 | 6753 |
| 6752 Fragment StreamingFlowGraphBuilder::BuildSwitchStatement() { | 6754 Fragment StreamingFlowGraphBuilder::BuildSwitchStatement() { |
| 6755 ReadPosition(); // read position. |
| 6753 // We need the number of cases. So start by getting that, then go back. | 6756 // We need the number of cases. So start by getting that, then go back. |
| 6754 intptr_t offset = ReaderOffset(); | 6757 intptr_t offset = ReaderOffset(); |
| 6755 SkipExpression(); // temporarily skip condition | 6758 SkipExpression(); // temporarily skip condition |
| 6756 int case_count = ReadListLength(); // read number of cases. | 6759 int case_count = ReadListLength(); // read number of cases. |
| 6757 SetOffset(offset); | 6760 SetOffset(offset); |
| 6758 | 6761 |
| 6759 SwitchBlock block(flow_graph_builder_, case_count); | 6762 SwitchBlock block(flow_graph_builder_, case_count); |
| 6760 | 6763 |
| 6761 // Instead of using a variable we should reuse the expression on the stack, | 6764 // Instead of using a variable we should reuse the expression on the stack, |
| 6762 // since it won't be assigned again, we don't need phi nodes. | 6765 // since it won't be assigned again, we don't need phi nodes. |
| (...skipping 1049 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7812 } | 7815 } |
| 7813 } | 7816 } |
| 7814 | 7817 |
| 7815 return Array::Handle(Array::null()); | 7818 return Array::Handle(Array::null()); |
| 7816 } | 7819 } |
| 7817 | 7820 |
| 7818 } // namespace kernel | 7821 } // namespace kernel |
| 7819 } // namespace dart | 7822 } // namespace dart |
| 7820 | 7823 |
| 7821 #endif // !defined(DART_PRECOMPILED_RUNTIME) | 7824 #endif // !defined(DART_PRECOMPILED_RUNTIME) |
| OLD | NEW |