Reviewers: titzer, Benedikt Meurer,

Message:
Ben: PTAL.
Benedikt: FYI.

Description:
[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.

[email protected]

Please review this at https://codereview.chromium.org/1213043005/

Base URL: https://chromium.googlesource.com/v8/v8.git@master

Affected files (+12, -12 lines):
  M src/compiler/ast-graph-builder.h
  M src/compiler/ast-graph-builder.cc
  M src/compiler/linkage.h
  M src/compiler/linkage-impl.h


Index: src/compiler/ast-graph-builder.cc
diff --git a/src/compiler/ast-graph-builder.cc b/src/compiler/ast-graph-builder.cc index 0abc9918df6595454e83f095732f71049ddc4088..c04c378fcdde3e8275a7f952f892fbe52c9c8354 100644
--- a/src/compiler/ast-graph-builder.cc
+++ b/src/compiler/ast-graph-builder.cc
@@ -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: src/compiler/ast-graph-builder.h
diff --git a/src/compiler/ast-graph-builder.h b/src/compiler/ast-graph-builder.h index 770d2d94345f41972f30df9095fbee428191f142..7fb7eb67301bfa6234271c59f6711b0ab4319e1e 100644
--- a/src/compiler/ast-graph-builder.h
+++ b/src/compiler/ast-graph-builder.h
@@ -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: src/compiler/linkage-impl.h
diff --git a/src/compiler/linkage-impl.h b/src/compiler/linkage-impl.h
index d79c2c56f5695138d126be20453d40dc385b7a74..27b0235b9701e343512072d9b968d1154b11cf46 100644
--- a/src/compiler/linkage-impl.h
+++ b/src/compiler/linkage-impl.h
@@ -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: src/compiler/linkage.h
diff --git a/src/compiler/linkage.h b/src/compiler/linkage.h
index e403f63bb14ac890ded2dd295d1131538627a734..31b9faca2a9f15f145141b2160c117b6c24fb3cd 100644
--- a/src/compiler/linkage.h
+++ b/src/compiler/linkage.h
@@ -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_;



--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to