Commit 21d330c8 authored by mstarzinger's avatar mstarzinger Committed by Commit bot

[turbofan] Use OSR value for innermost context value.

This changes the OsrValue insertion in the AstGraphBuilder to emit a
proper OsrValue instead of a special Parameter for the inner context
value at the OSR entry point.

R=titzer@chromium.org

Review URL: https://codereview.chromium.org/1213043005

Cr-Commit-Position: refs/heads/master@{#29471}
parent 26991892
......@@ -498,15 +498,6 @@ Node* AstGraphBuilder::NewOuterContextParam() {
}
Node* AstGraphBuilder::NewCurrentContextOsrValue() {
// TODO(titzer): use a real OSR value here; a parameter works by accident.
// Parameter (arity + 1) is special for the outer context of the function
const Operator* op = common()->Parameter(
info()->num_parameters_including_this(), "%osr-context");
return NewNode(op, graph()->start());
}
bool AstGraphBuilder::CreateGraph(bool constant_context, bool stack_check) {
Scope* scope = info()->scope();
DCHECK(graph() != NULL);
......@@ -4093,11 +4084,13 @@ void AstGraphBuilder::Environment::PrepareForLoop(BitVector* assigned,
Node* osr_context = nullptr;
const Operator* op =
builder_->javascript()->LoadContext(0, Context::PREVIOUS_INDEX, true);
const Operator* op_inner =
builder_->common()->OsrValue(Linkage::kOsrContextSpillSlotIndex);
int last = static_cast<int>(contexts()->size() - 1);
for (int i = last; i >= 0; i--) {
Node* val = contexts()->at(i);
if (!IrOpcode::IsConstantOpcode(val->opcode())) {
osr_context = (i == last) ? builder_->NewCurrentContextOsrValue()
osr_context = (i == last) ? graph->NewNode(op_inner, osr_loop_entry)
: graph->NewNode(op, osr_context, osr_context,
osr_loop_entry);
contexts()->at(i) = builder_->MergeValue(val, osr_context, control);
......
......@@ -203,7 +203,6 @@ class AstGraphBuilder : public AstVisitor {
Node* NewEffectPhi(int count, Node* input, Node* control);
Node* NewOuterContextParam();
Node* NewCurrentContextOsrValue();
// Helpers for merging control, effect or value dependencies.
Node* MergeControl(Node* control, Node* other);
......
......@@ -277,7 +277,12 @@ LinkageLocation Linkage::GetOsrValueLocation(int index) const {
int parameter_count = static_cast<int>(incoming_->JSParameterCount() - 1);
int first_stack_slot = OsrHelper::FirstStackSlotIndex(parameter_count);
if (index >= first_stack_slot) {
if (index == kOsrContextSpillSlotIndex) {
// Context. Use the parameter location of the context spill slot.
// Parameter (arity + 1) is special for the context of the function frame.
int context_index = 1 + 1 + parameter_count; // target + receiver + params
return incoming_->GetInputLocation(context_index);
} else if (index >= first_stack_slot) {
// Local variable stored in this (callee) stack.
int spill_index =
LinkageLocation::ANY_REGISTER + 1 + index - first_stack_slot;
......
......@@ -268,6 +268,9 @@ class Linkage : public ZoneObject {
// A special parameter index for JSCalls that represents the closure.
static const int kJSFunctionCallClosureParamIndex = -1;
// A special {OsrValue} index to indicate the context spill slot.
static const int kOsrContextSpillSlotIndex = -1;
private:
CallDescriptor* const incoming_;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment