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/code-factory.h" | 7 #include "src/code-factory.h" |
8 #include "src/code-stubs.h" | 8 #include "src/code-stubs.h" |
9 #include "src/compilation-dependencies.h" | 9 #include "src/compilation-dependencies.h" |
10 #include "src/compiler/js-graph.h" | 10 #include "src/compiler/js-graph.h" |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
127 if (!NodeProperties::IsValueEdge(edge)) continue; | 127 if (!NodeProperties::IsValueEdge(edge)) continue; |
128 if (edge.from() == node) continue; | 128 if (edge.from() == node) continue; |
129 return NoChange(); | 129 return NoChange(); |
130 } | 130 } |
131 // Check if the arguments can be handled in the fast case (i.e. we don't | 131 // Check if the arguments can be handled in the fast case (i.e. we don't |
132 // have aliased sloppy arguments), and compute the {start_index} for | 132 // have aliased sloppy arguments), and compute the {start_index} for |
133 // rest parameters. | 133 // rest parameters. |
134 CreateArgumentsType const type = CreateArgumentsTypeOf(arg_array->op()); | 134 CreateArgumentsType const type = CreateArgumentsTypeOf(arg_array->op()); |
135 Node* frame_state = NodeProperties::GetFrameStateInput(arg_array); | 135 Node* frame_state = NodeProperties::GetFrameStateInput(arg_array); |
136 FrameStateInfo state_info = OpParameter<FrameStateInfo>(frame_state); | 136 FrameStateInfo state_info = OpParameter<FrameStateInfo>(frame_state); |
137 int formal_parameter_count; | |
138 int start_index = 0; | 137 int start_index = 0; |
139 { | 138 // Determine the formal parameter count; |
140 Handle<SharedFunctionInfo> shared; | 139 Handle<SharedFunctionInfo> shared; |
141 if (!state_info.shared_info().ToHandle(&shared)) return NoChange(); | 140 if (!state_info.shared_info().ToHandle(&shared)) return NoChange(); |
142 formal_parameter_count = shared->internal_formal_parameter_count(); | 141 int formal_parameter_count = shared->internal_formal_parameter_count(); |
143 } | |
144 if (type == CreateArgumentsType::kMappedArguments) { | 142 if (type == CreateArgumentsType::kMappedArguments) { |
145 // Mapped arguments (sloppy mode) cannot be handled if they are aliased. | 143 // Mapped arguments (sloppy mode) that are aliased can only be handled |
146 if (formal_parameter_count != 0) return NoChange(); | 144 // here if there's no side-effect between the {node} and the {arg_array}. |
145 // TODO(turbofan): Further relax this constraint. | |
146 if (formal_parameter_count != 0) { | |
147 Node* effect = NodeProperties::GetEffectInput(node); | |
danno
2017/04/04 07:55:11
Does it make sense to turn this into a predicate?
Benedikt Meurer
2017/04/04 08:02:14
Given that we might want to relax the constraints
| |
148 while (effect != arg_array) { | |
149 if (effect->op()->EffectInputCount() != 1 || | |
150 !(effect->op()->properties() & Operator::kNoWrite)) { | |
151 return NoChange(); | |
152 } | |
153 effect = NodeProperties::GetEffectInput(effect); | |
154 } | |
155 } | |
147 } else if (type == CreateArgumentsType::kRestParameter) { | 156 } else if (type == CreateArgumentsType::kRestParameter) { |
148 start_index = formal_parameter_count; | 157 start_index = formal_parameter_count; |
149 } | 158 } |
150 // Check if are applying to inlined arguments or to the arguments of | 159 // Check if are applying to inlined arguments or to the arguments of |
151 // the outermost function. | 160 // the outermost function. |
152 Node* outer_state = frame_state->InputAt(kFrameStateOuterStateInput); | 161 Node* outer_state = frame_state->InputAt(kFrameStateOuterStateInput); |
153 if (outer_state->opcode() != IrOpcode::kFrameState) { | 162 if (outer_state->opcode() != IrOpcode::kFrameState) { |
154 // Reduce {node} to a JSCallForwardVarargs operation, which just | 163 // Reduce {node} to a JSCallForwardVarargs operation, which just |
155 // re-pushes the incoming arguments and calls the {target}. | 164 // re-pushes the incoming arguments and calls the {target}. |
156 node->RemoveInput(0); // Function.prototype.apply | 165 node->RemoveInput(0); // Function.prototype.apply |
(...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
856 return jsgraph()->javascript(); | 865 return jsgraph()->javascript(); |
857 } | 866 } |
858 | 867 |
859 SimplifiedOperatorBuilder* JSCallReducer::simplified() const { | 868 SimplifiedOperatorBuilder* JSCallReducer::simplified() const { |
860 return jsgraph()->simplified(); | 869 return jsgraph()->simplified(); |
861 } | 870 } |
862 | 871 |
863 } // namespace compiler | 872 } // namespace compiler |
864 } // namespace internal | 873 } // namespace internal |
865 } // namespace v8 | 874 } // namespace v8 |
OLD | NEW |