Reviewers: jarin,

Description:
Add constants for FrameState input parameters

R=ja...@chromium.org

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

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

Affected files (+41, -23 lines):
  M src/compiler/frame-states.h
  M src/compiler/instruction-selector.cc
  M src/compiler/js-typed-lowering.cc


Index: src/compiler/frame-states.h
diff --git a/src/compiler/frame-states.h b/src/compiler/frame-states.h
index 849a038174740c3257ee212df40abf4667e618b0..a1a002886fca238021f2120d19614b218e3837d8 100644
--- a/src/compiler/frame-states.h
+++ b/src/compiler/frame-states.h
@@ -101,6 +101,13 @@ size_t hash_value(FrameStateCallInfo const&);

 std::ostream& operator<<(std::ostream&, FrameStateCallInfo const&);

+static const int kFrameStateParametersInput = 0;
+static const int kFrameStateLocalsInput = 1;
+static const int kFrameStateStackInput = 2;
+static const int kFrameStateContextInput = 3;
+static const int kFrameStateFunctionInput = 4;
+static const int kFrameStateOuterStateInput = 5;
+static const int kFrameStateInputCount = kFrameStateOuterStateInput + 1;

 }  // namespace compiler
 }  // namespace internal
Index: src/compiler/instruction-selector.cc
diff --git a/src/compiler/instruction-selector.cc b/src/compiler/instruction-selector.cc index 1d2552e3915eb33f23d3eef38b5bc84fc821e9b0..43f5297a941713daeb51d485f8464be0a450b34f 100644
--- a/src/compiler/instruction-selector.cc
+++ b/src/compiler/instruction-selector.cc
@@ -1028,19 +1028,24 @@ void InstructionSelector::VisitThrow(Node* value) {
 FrameStateDescriptor* InstructionSelector::GetFrameStateDescriptor(
     Node* state) {
   DCHECK(state->opcode() == IrOpcode::kFrameState);
-  DCHECK_EQ(6, state->InputCount());
-  DCHECK_EQ(IrOpcode::kTypedStateValues, state->InputAt(0)->opcode());
-  DCHECK_EQ(IrOpcode::kTypedStateValues, state->InputAt(1)->opcode());
-  DCHECK_EQ(IrOpcode::kTypedStateValues, state->InputAt(2)->opcode());
+  DCHECK_EQ(kFrameStateInputCount, state->InputCount());
+  DCHECK_EQ(IrOpcode::kTypedStateValues,
+            state->InputAt(kFrameStateParametersInput)->opcode());
+  DCHECK_EQ(IrOpcode::kTypedStateValues,
+            state->InputAt(kFrameStateLocalsInput)->opcode());
+  DCHECK_EQ(IrOpcode::kTypedStateValues,
+            state->InputAt(kFrameStateStackInput)->opcode());
   FrameStateCallInfo state_info = OpParameter<FrameStateCallInfo>(state);

-  int parameters =
-      static_cast<int>(StateValuesAccess(state->InputAt(0)).size());
- int locals = static_cast<int>(StateValuesAccess(state->InputAt(1)).size()); - int stack = static_cast<int>(StateValuesAccess(state->InputAt(2)).size());
+  int parameters = static_cast<int>(
+ StateValuesAccess(state->InputAt(kFrameStateParametersInput)).size());
+  int locals = static_cast<int>(
+      StateValuesAccess(state->InputAt(kFrameStateLocalsInput)).size());
+  int stack = static_cast<int>(
+      StateValuesAccess(state->InputAt(kFrameStateStackInput)).size());

   FrameStateDescriptor* outer_state = NULL;
-  Node* outer_node = state->InputAt(5);
+  Node* outer_node = state->InputAt(kFrameStateOuterStateInput);
   if (outer_node->opcode() == IrOpcode::kFrameState) {
     outer_state = GetFrameStateDescriptor(outer_node);
   }
@@ -1070,14 +1075,15 @@ void InstructionSelector::AddFrameStateInputs(
   DCHECK_EQ(IrOpcode::kFrameState, state->op()->opcode());

   if (descriptor->outer_state()) {
- AddFrameStateInputs(state->InputAt(5), inputs, descriptor->outer_state());
+    AddFrameStateInputs(state->InputAt(kFrameStateOuterStateInput), inputs,
+                        descriptor->outer_state());
   }

-  Node* parameters = state->InputAt(0);
-  Node* locals = state->InputAt(1);
-  Node* stack = state->InputAt(2);
-  Node* context = state->InputAt(3);
-  Node* function = state->InputAt(4);
+  Node* parameters = state->InputAt(kFrameStateParametersInput);
+  Node* locals = state->InputAt(kFrameStateLocalsInput);
+  Node* stack = state->InputAt(kFrameStateStackInput);
+  Node* context = state->InputAt(kFrameStateContextInput);
+  Node* function = state->InputAt(kFrameStateFunctionInput);

   DCHECK_EQ(IrOpcode::kTypedStateValues, parameters->op()->opcode());
   DCHECK_EQ(IrOpcode::kTypedStateValues, locals->op()->opcode());
Index: src/compiler/js-typed-lowering.cc
diff --git a/src/compiler/js-typed-lowering.cc b/src/compiler/js-typed-lowering.cc index 7d8d20043e43711289215b286115fd16f9f30d24..c1b879af25f46848c5408dff14736aedef454fe9 100644
--- a/src/compiler/js-typed-lowering.cc
+++ b/src/compiler/js-typed-lowering.cc
@@ -287,10 +287,13 @@ class JSBinopReduction final {
         state_info.type(), state_info.bailout_id(),
         OutputFrameStateCombine::PokeAt(1));

-    return graph()->NewNode(op, frame_state->InputAt(0),
- frame_state->InputAt(1), frame_state->InputAt(2), - frame_state->InputAt(3), frame_state->InputAt(4),
-                            frame_state->InputAt(5));
+    return graph()->NewNode(op,
+ frame_state->InputAt(kFrameStateParametersInput),
+                            frame_state->InputAt(kFrameStateLocalsInput),
+                            frame_state->InputAt(kFrameStateStackInput),
+                            frame_state->InputAt(kFrameStateContextInput),
+                            frame_state->InputAt(kFrameStateFunctionInput),
+ frame_state->InputAt(kFrameStateOuterStateInput));
   }

Node* CreateFrameStateForRightInput(Node* frame_state, Node* converted_left) {
@@ -325,10 +328,12 @@ class JSBinopReduction final {
     Node* new_stack =
graph()->NewNode(stack->op(), stack->InputCount(), &new_values.front());

-    return graph()->NewNode(op, frame_state->InputAt(0),
-                            frame_state->InputAt(1), new_stack,
- frame_state->InputAt(3), frame_state->InputAt(4),
-                            frame_state->InputAt(5));
+    return graph()->NewNode(
+        op, frame_state->InputAt(kFrameStateParametersInput),
+        frame_state->InputAt(kFrameStateLocalsInput), new_stack,
+        frame_state->InputAt(kFrameStateContextInput),
+        frame_state->InputAt(kFrameStateFunctionInput),
+        frame_state->InputAt(kFrameStateOuterStateInput));
   }

   Node* ConvertPlainPrimitiveToNumber(Node* node) {


--
--
v8-dev mailing list
v8-dev@googlegroups.com
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 v8-dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to