[turbofan] Use OSR value for innermost context value.
authormstarzinger <mstarzinger@chromium.org>
Mon, 6 Jul 2015 03:39:15 +0000 (20:39 -0700)
committerCommit bot <commit-bot@chromium.org>
Mon, 6 Jul 2015 03:39:32 +0000 (03:39 +0000)
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}

src/compiler/ast-graph-builder.cc
src/compiler/ast-graph-builder.h
src/compiler/linkage-impl.h
src/compiler/linkage.h

index 0abc991..c04c378 100644 (file)
@@ -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);
index 770d2d9..7fb7eb6 100644 (file)
@@ -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);
index d79c2c5..27b0235 100644 (file)
@@ -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;
index e403f63..31b9fac 100644 (file)
@@ -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_;