Index: src/compiler/instruction-selector.cc |
diff --git a/src/compiler/instruction-selector.cc b/src/compiler/instruction-selector.cc |
index 299138e70fb6028e827dd20caa9fda1cc4b9d91f..2954f0f6e9df672f01790eebc35140583e15bae4 100644 |
--- a/src/compiler/instruction-selector.cc |
+++ b/src/compiler/instruction-selector.cc |
@@ -254,84 +254,6 @@ void InstructionSelector::MarkAsRepresentation(MachineType rep, Node* node) { |
} |
-namespace { |
- |
-enum class FrameStateInputKind { kAny, kStackSlot }; |
- |
- |
-InstructionOperand OperandForDeopt(OperandGenerator* g, Node* input, |
- FrameStateInputKind kind) { |
- switch (input->opcode()) { |
- case IrOpcode::kInt32Constant: |
- case IrOpcode::kNumberConstant: |
- case IrOpcode::kFloat32Constant: |
- case IrOpcode::kFloat64Constant: |
- case IrOpcode::kHeapConstant: |
- return g->UseImmediate(input); |
- default: |
- switch (kind) { |
- case FrameStateInputKind::kStackSlot: |
- return g->UseUniqueSlot(input); |
- case FrameStateInputKind::kAny: |
- return g->UseAny(input); |
- } |
- UNREACHABLE(); |
- return InstructionOperand(); |
- } |
-} |
- |
- |
-void AddFrameStateInputs(Node* state, OperandGenerator* g, |
- InstructionOperandVector* inputs, |
- FrameStateDescriptor* descriptor, |
- FrameStateInputKind kind, Zone* zone) { |
- DCHECK_EQ(IrOpcode::kFrameState, state->op()->opcode()); |
- |
- if (descriptor->outer_state()) { |
- AddFrameStateInputs(state->InputAt(kFrameStateOuterStateInput), g, inputs, |
- descriptor->outer_state(), kind, zone); |
- } |
- |
- 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(descriptor->parameters_count(), |
- StateValuesAccess(parameters).size()); |
- DCHECK_EQ(descriptor->locals_count(), StateValuesAccess(locals).size()); |
- DCHECK_EQ(descriptor->stack_count(), StateValuesAccess(stack).size()); |
- |
- ZoneVector<MachineType> types(zone); |
- types.reserve(descriptor->GetSize()); |
- |
- size_t value_index = 0; |
- inputs->push_back(OperandForDeopt(g, function, kind)); |
- descriptor->SetType(value_index++, kMachAnyTagged); |
- for (StateValuesAccess::TypedNode input_node : |
- StateValuesAccess(parameters)) { |
- inputs->push_back(OperandForDeopt(g, input_node.node, kind)); |
- descriptor->SetType(value_index++, input_node.type); |
- } |
- if (descriptor->HasContext()) { |
- inputs->push_back(OperandForDeopt(g, context, kind)); |
- descriptor->SetType(value_index++, kMachAnyTagged); |
- } |
- for (StateValuesAccess::TypedNode input_node : StateValuesAccess(locals)) { |
- inputs->push_back(OperandForDeopt(g, input_node.node, kind)); |
- descriptor->SetType(value_index++, input_node.type); |
- } |
- for (StateValuesAccess::TypedNode input_node : StateValuesAccess(stack)) { |
- inputs->push_back(OperandForDeopt(g, input_node.node, kind)); |
- descriptor->SetType(value_index++, input_node.type); |
- } |
- DCHECK(value_index == descriptor->GetSize()); |
-} |
- |
-} // namespace |
- |
- |
// An internal helper class for generating the operands to calls. |
// TODO(bmeurer): Get rid of the CallBuffer business and make |
// InstructionSelector::VisitCall platform independent instead. |
@@ -458,6 +380,7 @@ void InstructionSelector::InitializeCallBuffer(Node* call, CallBuffer* buffer, |
// follows (n is the number of value inputs to the frame state): |
// arg 1 : deoptimization id. |
// arg 2 - arg (n + 1) : value inputs to the frame state. |
+ size_t frame_state_entries = 0; |
if (buffer->frame_state_descriptor != NULL) { |
InstructionSequence::StateId state_id = |
sequence()->AddFrameStateDescriptor(buffer->frame_state_descriptor); |
@@ -465,12 +388,17 @@ void InstructionSelector::InitializeCallBuffer(Node* call, CallBuffer* buffer, |
Node* frame_state = |
call->InputAt(static_cast<int>(buffer->descriptor->InputCount())); |
- AddFrameStateInputs(frame_state, &g, &buffer->instruction_args, |
- buffer->frame_state_descriptor, |
- FrameStateInputKind::kStackSlot, instruction_zone()); |
+ |
+ StateObjectCache cache(instruction_zone()); |
+ |
+ frame_state_entries = |
+ 1 + |
+ buffer->frame_state_descriptor->AddInputs( |
+ frame_state, &g, &cache, &buffer->instruction_args, |
+ FrameStateInputKind::kStackSlot, instruction_zone()); |
+ |
+ DCHECK_EQ(1 + frame_state_entries, buffer->instruction_args.size()); |
} |
- DCHECK(1 + buffer->frame_state_value_count() == |
- buffer->instruction_args.size()); |
size_t input_count = static_cast<size_t>(buffer->input_count()); |
@@ -506,7 +434,7 @@ void InstructionSelector::InitializeCallBuffer(Node* call, CallBuffer* buffer, |
} |
} |
DCHECK_EQ(input_count, buffer->instruction_args.size() + pushed_count - |
- buffer->frame_state_value_count()); |
+ frame_state_entries); |
Jarin
2015/12/02 12:24:34
Hmm, does not the compiler complain that frame_sta
sigurds
2015/12/02 16:35:13
Done.
|
if (call_tail && stack_param_delta != 0) { |
// For tail calls that change the size of their parameter list, move the |
// saved caller return address, parent frame pointer and parent constant |
@@ -733,6 +661,7 @@ void InstructionSelector::VisitNode(Node* node) { |
return VisitCall(node); |
case IrOpcode::kFrameState: |
case IrOpcode::kStateValues: |
+ case IrOpcode::kObjectState: |
return; |
case IrOpcode::kLoad: { |
LoadRepresentation rep = OpParameter<LoadRepresentation>(node); |
@@ -1421,21 +1350,20 @@ void InstructionSelector::VisitDeoptimize(Node* value) { |
OperandGenerator g(this); |
FrameStateDescriptor* desc = GetFrameStateDescriptor(value); |
- size_t arg_count = desc->GetTotalSize() + 1; // Include deopt id. |
InstructionOperandVector args(instruction_zone()); |
- args.reserve(arg_count); |
+ args.reserve(desc->GetTotalSize() + 1); // Include deopt id. |
InstructionSequence::StateId state_id = |
sequence()->AddFrameStateDescriptor(desc); |
args.push_back(g.TempImmediate(state_id.ToInt())); |
- AddFrameStateInputs(value, &g, &args, desc, FrameStateInputKind::kAny, |
- instruction_zone()); |
+ StateObjectCache cache(instruction_zone()); |
- DCHECK_EQ(args.size(), arg_count); |
+ desc->AddInputs(value, &g, &cache, &args, FrameStateInputKind::kAny, |
+ instruction_zone()); |
- Emit(kArchDeoptimize, 0, nullptr, arg_count, &args.front(), 0, nullptr); |
+ Emit(kArchDeoptimize, 0, nullptr, args.size(), &args.front(), 0, nullptr); |
} |