| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/compiler/ast-graph-builder.h" | 5 #include "src/compiler/ast-graph-builder.h" |
| 6 | 6 |
| 7 #include "src/compiler.h" | 7 #include "src/compiler.h" |
| 8 #include "src/compiler/ast-loop-assignment-analyzer.h" | 8 #include "src/compiler/ast-loop-assignment-analyzer.h" |
| 9 #include "src/compiler/control-builders.h" | 9 #include "src/compiler/control-builders.h" |
| 10 #include "src/compiler/js-type-feedback.h" | 10 #include "src/compiler/js-type-feedback.h" |
| (...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 491 | 491 |
| 492 | 492 |
| 493 Node* AstGraphBuilder::NewOuterContextParam() { | 493 Node* AstGraphBuilder::NewOuterContextParam() { |
| 494 // Parameter (arity + 1) is special for the outer context of the function | 494 // Parameter (arity + 1) is special for the outer context of the function |
| 495 const Operator* op = | 495 const Operator* op = |
| 496 common()->Parameter(info()->num_parameters_including_this(), "%context"); | 496 common()->Parameter(info()->num_parameters_including_this(), "%context"); |
| 497 return NewNode(op, graph()->start()); | 497 return NewNode(op, graph()->start()); |
| 498 } | 498 } |
| 499 | 499 |
| 500 | 500 |
| 501 Node* AstGraphBuilder::NewCurrentContextOsrValue() { | |
| 502 // TODO(titzer): use a real OSR value here; a parameter works by accident. | |
| 503 // Parameter (arity + 1) is special for the outer context of the function | |
| 504 const Operator* op = common()->Parameter( | |
| 505 info()->num_parameters_including_this(), "%osr-context"); | |
| 506 return NewNode(op, graph()->start()); | |
| 507 } | |
| 508 | |
| 509 | |
| 510 bool AstGraphBuilder::CreateGraph(bool constant_context, bool stack_check) { | 501 bool AstGraphBuilder::CreateGraph(bool constant_context, bool stack_check) { |
| 511 Scope* scope = info()->scope(); | 502 Scope* scope = info()->scope(); |
| 512 DCHECK(graph() != NULL); | 503 DCHECK(graph() != NULL); |
| 513 | 504 |
| 514 // Set up the basic structure of the graph. | 505 // Set up the basic structure of the graph. |
| 515 int parameter_count = info()->num_parameters(); | 506 int parameter_count = info()->num_parameters(); |
| 516 graph()->SetStart(graph()->NewNode(common()->Start(parameter_count))); | 507 graph()->SetStart(graph()->NewNode(common()->Start(parameter_count))); |
| 517 | 508 |
| 518 // Initialize the top-level environment. | 509 // Initialize the top-level environment. |
| 519 Environment env(this, scope, graph()->start()); | 510 Environment env(this, scope, graph()->start()); |
| (...skipping 3566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4086 values()->at(i) = builder_->MergeValue(val, osr_value, control); | 4077 values()->at(i) = builder_->MergeValue(val, osr_value, control); |
| 4087 } | 4078 } |
| 4088 } | 4079 } |
| 4089 | 4080 |
| 4090 // Rename all the contexts in the environment. | 4081 // Rename all the contexts in the environment. |
| 4091 // The innermost context is the OSR value, and the outer contexts are | 4082 // The innermost context is the OSR value, and the outer contexts are |
| 4092 // reconstructed by dynamically walking up the context chain. | 4083 // reconstructed by dynamically walking up the context chain. |
| 4093 Node* osr_context = nullptr; | 4084 Node* osr_context = nullptr; |
| 4094 const Operator* op = | 4085 const Operator* op = |
| 4095 builder_->javascript()->LoadContext(0, Context::PREVIOUS_INDEX, true); | 4086 builder_->javascript()->LoadContext(0, Context::PREVIOUS_INDEX, true); |
| 4087 const Operator* op_inner = |
| 4088 builder_->common()->OsrValue(Linkage::kOsrContextSpillSlotIndex); |
| 4096 int last = static_cast<int>(contexts()->size() - 1); | 4089 int last = static_cast<int>(contexts()->size() - 1); |
| 4097 for (int i = last; i >= 0; i--) { | 4090 for (int i = last; i >= 0; i--) { |
| 4098 Node* val = contexts()->at(i); | 4091 Node* val = contexts()->at(i); |
| 4099 if (!IrOpcode::IsConstantOpcode(val->opcode())) { | 4092 if (!IrOpcode::IsConstantOpcode(val->opcode())) { |
| 4100 osr_context = (i == last) ? builder_->NewCurrentContextOsrValue() | 4093 osr_context = (i == last) ? graph->NewNode(op_inner, osr_loop_entry) |
| 4101 : graph->NewNode(op, osr_context, osr_context, | 4094 : graph->NewNode(op, osr_context, osr_context, |
| 4102 osr_loop_entry); | 4095 osr_loop_entry); |
| 4103 contexts()->at(i) = builder_->MergeValue(val, osr_context, control); | 4096 contexts()->at(i) = builder_->MergeValue(val, osr_context, control); |
| 4104 } else { | 4097 } else { |
| 4105 osr_context = val; | 4098 osr_context = val; |
| 4106 } | 4099 } |
| 4107 } | 4100 } |
| 4108 } | 4101 } |
| 4109 } | 4102 } |
| 4110 | 4103 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4177 // Phi does not exist yet, introduce one. | 4170 // Phi does not exist yet, introduce one. |
| 4178 value = NewPhi(inputs, value, control); | 4171 value = NewPhi(inputs, value, control); |
| 4179 value->ReplaceInput(inputs - 1, other); | 4172 value->ReplaceInput(inputs - 1, other); |
| 4180 } | 4173 } |
| 4181 return value; | 4174 return value; |
| 4182 } | 4175 } |
| 4183 | 4176 |
| 4184 } // namespace compiler | 4177 } // namespace compiler |
| 4185 } // namespace internal | 4178 } // namespace internal |
| 4186 } // namespace v8 | 4179 } // namespace v8 |
| OLD | NEW |