| OLD | NEW |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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/js-call-reducer.h" | 5 #include "src/compiler/js-call-reducer.h" |
| 6 | 6 |
| 7 #include "src/compiler/js-graph.h" | 7 #include "src/compiler/js-graph.h" |
| 8 #include "src/compiler/node-matchers.h" | 8 #include "src/compiler/node-matchers.h" |
| 9 #include "src/objects-inl.h" | 9 #include "src/objects-inl.h" |
| 10 #include "src/type-feedback-vector-inl.h" | 10 #include "src/type-feedback-vector-inl.h" |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 if (arg_array->opcode() != IrOpcode::kJSCreateArguments) return NoChange(); | 122 if (arg_array->opcode() != IrOpcode::kJSCreateArguments) return NoChange(); |
| 123 for (Edge edge : arg_array->use_edges()) { | 123 for (Edge edge : arg_array->use_edges()) { |
| 124 if (edge.from()->opcode() == IrOpcode::kStateValues) continue; | 124 if (edge.from()->opcode() == IrOpcode::kStateValues) continue; |
| 125 if (!NodeProperties::IsValueEdge(edge)) continue; | 125 if (!NodeProperties::IsValueEdge(edge)) continue; |
| 126 if (edge.from() == node) continue; | 126 if (edge.from() == node) continue; |
| 127 return NoChange(); | 127 return NoChange(); |
| 128 } | 128 } |
| 129 // Get to the actual frame state from which to extract the arguments; | 129 // Get to the actual frame state from which to extract the arguments; |
| 130 // we can only optimize this in case the {node} was already inlined into | 130 // we can only optimize this in case the {node} was already inlined into |
| 131 // some other function (and same for the {arg_array}). | 131 // some other function (and same for the {arg_array}). |
| 132 CreateArgumentsParameters const& p = | 132 CreateArgumentsType type = CreateArgumentsTypeOf(arg_array->op()); |
| 133 CreateArgumentsParametersOf(arg_array->op()); | |
| 134 Node* frame_state = NodeProperties::GetFrameStateInput(arg_array, 0); | 133 Node* frame_state = NodeProperties::GetFrameStateInput(arg_array, 0); |
| 135 Node* outer_state = frame_state->InputAt(kFrameStateOuterStateInput); | 134 Node* outer_state = frame_state->InputAt(kFrameStateOuterStateInput); |
| 136 if (outer_state->opcode() != IrOpcode::kFrameState) return NoChange(); | 135 if (outer_state->opcode() != IrOpcode::kFrameState) return NoChange(); |
| 137 FrameStateInfo outer_info = OpParameter<FrameStateInfo>(outer_state); | 136 FrameStateInfo outer_info = OpParameter<FrameStateInfo>(outer_state); |
| 138 if (outer_info.type() == FrameStateType::kArgumentsAdaptor) { | 137 if (outer_info.type() == FrameStateType::kArgumentsAdaptor) { |
| 139 // Need to take the parameters from the arguments adaptor. | 138 // Need to take the parameters from the arguments adaptor. |
| 140 frame_state = outer_state; | 139 frame_state = outer_state; |
| 141 } | 140 } |
| 142 FrameStateInfo state_info = OpParameter<FrameStateInfo>(frame_state); | 141 FrameStateInfo state_info = OpParameter<FrameStateInfo>(frame_state); |
| 143 if (p.type() == CreateArgumentsParameters::kMappedArguments) { | 142 int start_index = 0; |
| 143 if (type == CreateArgumentsType::kMappedArguments) { |
| 144 // Mapped arguments (sloppy mode) cannot be handled if they are aliased. | 144 // Mapped arguments (sloppy mode) cannot be handled if they are aliased. |
| 145 Handle<SharedFunctionInfo> shared; | 145 Handle<SharedFunctionInfo> shared; |
| 146 if (!state_info.shared_info().ToHandle(&shared)) return NoChange(); | 146 if (!state_info.shared_info().ToHandle(&shared)) return NoChange(); |
| 147 if (shared->internal_formal_parameter_count() != 0) return NoChange(); | 147 if (shared->internal_formal_parameter_count() != 0) return NoChange(); |
| 148 } else if (type == CreateArgumentsType::kRestParameter) { |
| 149 Handle<SharedFunctionInfo> shared; |
| 150 if (!state_info.shared_info().ToHandle(&shared)) return NoChange(); |
| 151 start_index = shared->internal_formal_parameter_count(); |
| 148 } | 152 } |
| 149 // Remove the argArray input from the {node}. | 153 // Remove the argArray input from the {node}. |
| 150 node->RemoveInput(static_cast<int>(--arity)); | 154 node->RemoveInput(static_cast<int>(--arity)); |
| 151 // Add the actual parameters to the {node}, skipping the receiver. | 155 // Add the actual parameters to the {node}, skipping the receiver. |
| 152 Node* const parameters = frame_state->InputAt(kFrameStateParametersInput); | 156 Node* const parameters = frame_state->InputAt(kFrameStateParametersInput); |
| 153 for (int i = p.start_index() + 1; i < state_info.parameter_count(); ++i) { | 157 for (int i = start_index + 1; i < state_info.parameter_count(); ++i) { |
| 154 node->InsertInput(graph()->zone(), static_cast<int>(arity), | 158 node->InsertInput(graph()->zone(), static_cast<int>(arity), |
| 155 parameters->InputAt(i)); | 159 parameters->InputAt(i)); |
| 156 ++arity; | 160 ++arity; |
| 157 } | 161 } |
| 158 // Drop the {target} from the {node}. | 162 // Drop the {target} from the {node}. |
| 159 node->RemoveInput(0); | 163 node->RemoveInput(0); |
| 160 --arity; | 164 --arity; |
| 161 } else { | 165 } else { |
| 162 return NoChange(); | 166 return NoChange(); |
| 163 } | 167 } |
| (...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 551 } | 555 } |
| 552 | 556 |
| 553 | 557 |
| 554 JSOperatorBuilder* JSCallReducer::javascript() const { | 558 JSOperatorBuilder* JSCallReducer::javascript() const { |
| 555 return jsgraph()->javascript(); | 559 return jsgraph()->javascript(); |
| 556 } | 560 } |
| 557 | 561 |
| 558 } // namespace compiler | 562 } // namespace compiler |
| 559 } // namespace internal | 563 } // namespace internal |
| 560 } // namespace v8 | 564 } // namespace v8 |
| OLD | NEW |