OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/compiler/instruction-selector.h" | 5 #include "src/compiler/instruction-selector.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "src/base/adapters.h" | 9 #include "src/base/adapters.h" |
10 #include "src/compiler/instruction-selector-impl.h" | 10 #include "src/compiler/instruction-selector-impl.h" |
(...skipping 1010 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1021 | 1021 |
1022 void InstructionSelector::VisitThrow(Node* value) { | 1022 void InstructionSelector::VisitThrow(Node* value) { |
1023 OperandGenerator g(this); | 1023 OperandGenerator g(this); |
1024 Emit(kArchNop, g.NoOutput()); // TODO(titzer) | 1024 Emit(kArchNop, g.NoOutput()); // TODO(titzer) |
1025 } | 1025 } |
1026 | 1026 |
1027 | 1027 |
1028 FrameStateDescriptor* InstructionSelector::GetFrameStateDescriptor( | 1028 FrameStateDescriptor* InstructionSelector::GetFrameStateDescriptor( |
1029 Node* state) { | 1029 Node* state) { |
1030 DCHECK(state->opcode() == IrOpcode::kFrameState); | 1030 DCHECK(state->opcode() == IrOpcode::kFrameState); |
1031 DCHECK_EQ(6, state->InputCount()); | 1031 DCHECK_EQ(kFrameStateInputCount, state->InputCount()); |
1032 DCHECK_EQ(IrOpcode::kTypedStateValues, state->InputAt(0)->opcode()); | 1032 DCHECK_EQ(IrOpcode::kTypedStateValues, |
1033 DCHECK_EQ(IrOpcode::kTypedStateValues, state->InputAt(1)->opcode()); | 1033 state->InputAt(kFrameStateParametersInput)->opcode()); |
1034 DCHECK_EQ(IrOpcode::kTypedStateValues, state->InputAt(2)->opcode()); | 1034 DCHECK_EQ(IrOpcode::kTypedStateValues, |
| 1035 state->InputAt(kFrameStateLocalsInput)->opcode()); |
| 1036 DCHECK_EQ(IrOpcode::kTypedStateValues, |
| 1037 state->InputAt(kFrameStateStackInput)->opcode()); |
1035 FrameStateCallInfo state_info = OpParameter<FrameStateCallInfo>(state); | 1038 FrameStateCallInfo state_info = OpParameter<FrameStateCallInfo>(state); |
1036 | 1039 |
1037 int parameters = | 1040 int parameters = static_cast<int>( |
1038 static_cast<int>(StateValuesAccess(state->InputAt(0)).size()); | 1041 StateValuesAccess(state->InputAt(kFrameStateParametersInput)).size()); |
1039 int locals = static_cast<int>(StateValuesAccess(state->InputAt(1)).size()); | 1042 int locals = static_cast<int>( |
1040 int stack = static_cast<int>(StateValuesAccess(state->InputAt(2)).size()); | 1043 StateValuesAccess(state->InputAt(kFrameStateLocalsInput)).size()); |
| 1044 int stack = static_cast<int>( |
| 1045 StateValuesAccess(state->InputAt(kFrameStateStackInput)).size()); |
1041 | 1046 |
1042 FrameStateDescriptor* outer_state = NULL; | 1047 FrameStateDescriptor* outer_state = NULL; |
1043 Node* outer_node = state->InputAt(5); | 1048 Node* outer_node = state->InputAt(kFrameStateOuterStateInput); |
1044 if (outer_node->opcode() == IrOpcode::kFrameState) { | 1049 if (outer_node->opcode() == IrOpcode::kFrameState) { |
1045 outer_state = GetFrameStateDescriptor(outer_node); | 1050 outer_state = GetFrameStateDescriptor(outer_node); |
1046 } | 1051 } |
1047 | 1052 |
1048 return new (instruction_zone()) FrameStateDescriptor( | 1053 return new (instruction_zone()) FrameStateDescriptor( |
1049 instruction_zone(), state_info.type(), state_info.bailout_id(), | 1054 instruction_zone(), state_info.type(), state_info.bailout_id(), |
1050 state_info.state_combine(), parameters, locals, stack, outer_state); | 1055 state_info.state_combine(), parameters, locals, stack, outer_state); |
1051 } | 1056 } |
1052 | 1057 |
1053 | 1058 |
1054 static InstructionOperand SlotOrImmediate(OperandGenerator* g, Node* input) { | 1059 static InstructionOperand SlotOrImmediate(OperandGenerator* g, Node* input) { |
1055 switch (input->opcode()) { | 1060 switch (input->opcode()) { |
1056 case IrOpcode::kInt32Constant: | 1061 case IrOpcode::kInt32Constant: |
1057 case IrOpcode::kNumberConstant: | 1062 case IrOpcode::kNumberConstant: |
1058 case IrOpcode::kFloat64Constant: | 1063 case IrOpcode::kFloat64Constant: |
1059 case IrOpcode::kHeapConstant: | 1064 case IrOpcode::kHeapConstant: |
1060 return g->UseImmediate(input); | 1065 return g->UseImmediate(input); |
1061 default: | 1066 default: |
1062 return g->UseUniqueSlot(input); | 1067 return g->UseUniqueSlot(input); |
1063 } | 1068 } |
1064 } | 1069 } |
1065 | 1070 |
1066 | 1071 |
1067 void InstructionSelector::AddFrameStateInputs( | 1072 void InstructionSelector::AddFrameStateInputs( |
1068 Node* state, InstructionOperandVector* inputs, | 1073 Node* state, InstructionOperandVector* inputs, |
1069 FrameStateDescriptor* descriptor) { | 1074 FrameStateDescriptor* descriptor) { |
1070 DCHECK_EQ(IrOpcode::kFrameState, state->op()->opcode()); | 1075 DCHECK_EQ(IrOpcode::kFrameState, state->op()->opcode()); |
1071 | 1076 |
1072 if (descriptor->outer_state()) { | 1077 if (descriptor->outer_state()) { |
1073 AddFrameStateInputs(state->InputAt(5), inputs, descriptor->outer_state()); | 1078 AddFrameStateInputs(state->InputAt(kFrameStateOuterStateInput), inputs, |
| 1079 descriptor->outer_state()); |
1074 } | 1080 } |
1075 | 1081 |
1076 Node* parameters = state->InputAt(0); | 1082 Node* parameters = state->InputAt(kFrameStateParametersInput); |
1077 Node* locals = state->InputAt(1); | 1083 Node* locals = state->InputAt(kFrameStateLocalsInput); |
1078 Node* stack = state->InputAt(2); | 1084 Node* stack = state->InputAt(kFrameStateStackInput); |
1079 Node* context = state->InputAt(3); | 1085 Node* context = state->InputAt(kFrameStateContextInput); |
1080 Node* function = state->InputAt(4); | 1086 Node* function = state->InputAt(kFrameStateFunctionInput); |
1081 | 1087 |
1082 DCHECK_EQ(IrOpcode::kTypedStateValues, parameters->op()->opcode()); | 1088 DCHECK_EQ(IrOpcode::kTypedStateValues, parameters->op()->opcode()); |
1083 DCHECK_EQ(IrOpcode::kTypedStateValues, locals->op()->opcode()); | 1089 DCHECK_EQ(IrOpcode::kTypedStateValues, locals->op()->opcode()); |
1084 DCHECK_EQ(IrOpcode::kTypedStateValues, stack->op()->opcode()); | 1090 DCHECK_EQ(IrOpcode::kTypedStateValues, stack->op()->opcode()); |
1085 | 1091 |
1086 DCHECK_EQ(descriptor->parameters_count(), | 1092 DCHECK_EQ(descriptor->parameters_count(), |
1087 StateValuesAccess(parameters).size()); | 1093 StateValuesAccess(parameters).size()); |
1088 DCHECK_EQ(descriptor->locals_count(), StateValuesAccess(locals).size()); | 1094 DCHECK_EQ(descriptor->locals_count(), StateValuesAccess(locals).size()); |
1089 DCHECK_EQ(descriptor->stack_count(), StateValuesAccess(stack).size()); | 1095 DCHECK_EQ(descriptor->stack_count(), StateValuesAccess(stack).size()); |
1090 | 1096 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1147 MachineOperatorBuilder::Flags | 1153 MachineOperatorBuilder::Flags |
1148 InstructionSelector::SupportedMachineOperatorFlags() { | 1154 InstructionSelector::SupportedMachineOperatorFlags() { |
1149 return MachineOperatorBuilder::Flag::kNoFlags; | 1155 return MachineOperatorBuilder::Flag::kNoFlags; |
1150 } | 1156 } |
1151 | 1157 |
1152 #endif // !V8_TURBOFAN_BACKEND | 1158 #endif // !V8_TURBOFAN_BACKEND |
1153 | 1159 |
1154 } // namespace compiler | 1160 } // namespace compiler |
1155 } // namespace internal | 1161 } // namespace internal |
1156 } // namespace v8 | 1162 } // namespace v8 |
OLD | NEW |