| 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 <map> | 5 #include <map> |
| 6 #include <set> | 6 #include <set> |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "vm/kernel_to_il.h" | 9 #include "vm/kernel_to_il.h" |
| 10 | 10 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 scope_ = new (Z) LocalScope(scope_, depth_.function_, depth_.loop_); | 34 scope_ = new (Z) LocalScope(scope_, depth_.function_, depth_.loop_); |
| 35 result_->scopes.Insert(node, scope_); | 35 result_->scopes.Insert(node, scope_); |
| 36 } | 36 } |
| 37 | 37 |
| 38 | 38 |
| 39 void ScopeBuilder::ExitScope() { scope_ = scope_->parent(); } | 39 void ScopeBuilder::ExitScope() { scope_ = scope_->parent(); } |
| 40 | 40 |
| 41 | 41 |
| 42 LocalVariable* ScopeBuilder::MakeVariable(const dart::String& name) { | 42 LocalVariable* ScopeBuilder::MakeVariable(const dart::String& name) { |
| 43 return new (Z) | 43 return new (Z) |
| 44 LocalVariable(TokenPosition::kNoSource, name, Object::dynamic_type()); | 44 LocalVariable(TokenPosition::kNoSource, |
| 45 TokenPosition::kNoSource, |
| 46 name, |
| 47 Object::dynamic_type()); |
| 45 } | 48 } |
| 46 | 49 |
| 47 | 50 |
| 48 LocalVariable* ScopeBuilder::MakeVariable(const dart::String& name, | 51 LocalVariable* ScopeBuilder::MakeVariable(const dart::String& name, |
| 49 const Type& type) { | 52 const Type& type) { |
| 50 return new (Z) LocalVariable(TokenPosition::kNoSource, name, type); | 53 return new (Z) LocalVariable(TokenPosition::kNoSource, |
| 54 TokenPosition::kNoSource, |
| 55 name, |
| 56 type); |
| 51 } | 57 } |
| 52 | 58 |
| 53 | 59 |
| 54 void ScopeBuilder::AddParameters(FunctionNode* function, intptr_t pos) { | 60 void ScopeBuilder::AddParameters(FunctionNode* function, intptr_t pos) { |
| 55 List<VariableDeclaration>& positional = function->positional_parameters(); | 61 List<VariableDeclaration>& positional = function->positional_parameters(); |
| 56 for (intptr_t i = 0; i < positional.length(); ++i) { | 62 for (intptr_t i = 0; i < positional.length(); ++i) { |
| 57 AddParameter(positional[i], pos++); | 63 AddParameter(positional[i], pos++); |
| 58 } | 64 } |
| 59 List<VariableDeclaration>& named = function->named_parameters(); | 65 List<VariableDeclaration>& named = function->named_parameters(); |
| 60 for (intptr_t i = 0; i < named.length(); ++i) { | 66 for (intptr_t i = 0; i < named.length(); ++i) { |
| (...skipping 2435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2496 ASSERT(function != Object::null()); | 2502 ASSERT(function != Object::null()); |
| 2497 return function; | 2503 return function; |
| 2498 } | 2504 } |
| 2499 | 2505 |
| 2500 | 2506 |
| 2501 LocalVariable* FlowGraphBuilder::MakeTemporary() { | 2507 LocalVariable* FlowGraphBuilder::MakeTemporary() { |
| 2502 char name[64]; | 2508 char name[64]; |
| 2503 intptr_t index = stack_->definition()->temp_index(); | 2509 intptr_t index = stack_->definition()->temp_index(); |
| 2504 OS::SNPrint(name, 64, ":temp%" Pd, index); | 2510 OS::SNPrint(name, 64, ":temp%" Pd, index); |
| 2505 LocalVariable* variable = new (Z) LocalVariable( | 2511 LocalVariable* variable = new (Z) LocalVariable( |
| 2506 TokenPosition::kNoSource, H.DartSymbol(name), Object::dynamic_type()); | 2512 TokenPosition::kNoSource, |
| 2513 TokenPosition::kNoSource, |
| 2514 H.DartSymbol(name), |
| 2515 Object::dynamic_type()); |
| 2507 // Set the index relative to the base of the expression stack including | 2516 // Set the index relative to the base of the expression stack including |
| 2508 // outgoing arguments. | 2517 // outgoing arguments. |
| 2509 variable->set_index(parsed_function_->first_stack_local_index() - | 2518 variable->set_index(parsed_function_->first_stack_local_index() - |
| 2510 parsed_function_->num_stack_locals() - | 2519 parsed_function_->num_stack_locals() - |
| 2511 pending_argument_count_ - index); | 2520 pending_argument_count_ - index); |
| 2512 | 2521 |
| 2513 // The value has uses as if it were a local variable. Mark the definition | 2522 // The value has uses as if it were a local variable. Mark the definition |
| 2514 // as used so that its temp index will not be cleared (causing it to never | 2523 // as used so that its temp index will not be cleared (causing it to never |
| 2515 // be materialized in the expression stack). | 2524 // be materialized in the expression stack). |
| 2516 stack_->definition()->set_ssa_temp_index(0); | 2525 stack_->definition()->set_ssa_temp_index(0); |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2757 LocalScope* scope = parsed_function_->node_sequence()->scope(); | 2766 LocalScope* scope = parsed_function_->node_sequence()->scope(); |
| 2758 intptr_t parameter_count = dart_function.NumParameters(); | 2767 intptr_t parameter_count = dart_function.NumParameters(); |
| 2759 intptr_t parameter_index = parsed_function_->first_parameter_index(); | 2768 intptr_t parameter_index = parsed_function_->first_parameter_index(); |
| 2760 for (intptr_t i = 0; i < parameter_count; ++i, --parameter_index) { | 2769 for (intptr_t i = 0; i < parameter_count; ++i, --parameter_index) { |
| 2761 LocalVariable* variable = scope->VariableAt(i); | 2770 LocalVariable* variable = scope->VariableAt(i); |
| 2762 if (variable->is_captured()) { | 2771 if (variable->is_captured()) { |
| 2763 // There is no LocalVariable describing the on-stack parameter so | 2772 // There is no LocalVariable describing the on-stack parameter so |
| 2764 // create one directly. | 2773 // create one directly. |
| 2765 LocalVariable* parameter = | 2774 LocalVariable* parameter = |
| 2766 new (Z) LocalVariable(TokenPosition::kNoSource, | 2775 new (Z) LocalVariable(TokenPosition::kNoSource, |
| 2767 Symbols::TempParam(), Object::dynamic_type()); | 2776 TokenPosition::kNoSource, |
| 2777 Symbols::TempParam(), |
| 2778 Object::dynamic_type()); |
| 2768 parameter->set_index(parameter_index); | 2779 parameter->set_index(parameter_index); |
| 2769 // Mark the stack variable so it will be ignored by the code for | 2780 // Mark the stack variable so it will be ignored by the code for |
| 2770 // try/catch. | 2781 // try/catch. |
| 2771 parameter->set_is_captured_parameter(true); | 2782 parameter->set_is_captured_parameter(true); |
| 2772 | 2783 |
| 2773 // Copy the parameter from the stack to the context. Overwrite it | 2784 // Copy the parameter from the stack to the context. Overwrite it |
| 2774 // with a null constant on the stack so the original value is | 2785 // with a null constant on the stack so the original value is |
| 2775 // eligible for garbage collection. | 2786 // eligible for garbage collection. |
| 2776 body += LoadLocal(context); | 2787 body += LoadLocal(context); |
| 2777 body += LoadLocal(parameter); | 2788 body += LoadLocal(parameter); |
| (...skipping 2780 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5558 instructions += LoadLocal(closure); | 5569 instructions += LoadLocal(closure); |
| 5559 instructions += LoadLocal(parsed_function_->current_context_var()); | 5570 instructions += LoadLocal(parsed_function_->current_context_var()); |
| 5560 instructions += StoreInstanceField(Closure::context_offset()); | 5571 instructions += StoreInstanceField(Closure::context_offset()); |
| 5561 | 5572 |
| 5562 return instructions; | 5573 return instructions; |
| 5563 } | 5574 } |
| 5564 | 5575 |
| 5565 | 5576 |
| 5566 } // namespace kernel | 5577 } // namespace kernel |
| 5567 } // namespace dart | 5578 } // namespace dart |
| OLD | NEW |