| 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 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 ++arity; | 160 ++arity; |
| 161 } | 161 } |
| 162 // Drop the {target} from the {node}. | 162 // Drop the {target} from the {node}. |
| 163 node->RemoveInput(0); | 163 node->RemoveInput(0); |
| 164 --arity; | 164 --arity; |
| 165 } else { | 165 } else { |
| 166 return NoChange(); | 166 return NoChange(); |
| 167 } | 167 } |
| 168 // Change {node} to the new {JSCallFunction} operator. | 168 // Change {node} to the new {JSCallFunction} operator. |
| 169 NodeProperties::ChangeOp( | 169 NodeProperties::ChangeOp( |
| 170 node, javascript()->CallFunction(arity, p.language_mode(), | 170 node, javascript()->CallFunction(arity, CallCountFeedback(p.feedback()), |
| 171 CallCountFeedback(p.feedback()), | |
| 172 convert_mode, p.tail_call_mode())); | 171 convert_mode, p.tail_call_mode())); |
| 173 // Change context of {node} to the Function.prototype.apply context, | 172 // Change context of {node} to the Function.prototype.apply context, |
| 174 // to ensure any exception is thrown in the correct context. | 173 // to ensure any exception is thrown in the correct context. |
| 175 NodeProperties::ReplaceContextInput( | 174 NodeProperties::ReplaceContextInput( |
| 176 node, jsgraph()->HeapConstant(handle(apply->context(), isolate()))); | 175 node, jsgraph()->HeapConstant(handle(apply->context(), isolate()))); |
| 177 // Try to further reduce the JSCallFunction {node}. | 176 // Try to further reduce the JSCallFunction {node}. |
| 178 Reduction const reduction = ReduceJSCallFunction(node); | 177 Reduction const reduction = ReduceJSCallFunction(node); |
| 179 return reduction.Changed() ? reduction : Changed(node); | 178 return reduction.Changed() ? reduction : Changed(node); |
| 180 } | 179 } |
| 181 | 180 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 201 convert_mode = ConvertReceiverMode::kNullOrUndefined; | 200 convert_mode = ConvertReceiverMode::kNullOrUndefined; |
| 202 node->ReplaceInput(0, node->InputAt(1)); | 201 node->ReplaceInput(0, node->InputAt(1)); |
| 203 node->ReplaceInput(1, jsgraph()->UndefinedConstant()); | 202 node->ReplaceInput(1, jsgraph()->UndefinedConstant()); |
| 204 } else { | 203 } else { |
| 205 // Just remove the target, which is the first value input. | 204 // Just remove the target, which is the first value input. |
| 206 convert_mode = ConvertReceiverMode::kAny; | 205 convert_mode = ConvertReceiverMode::kAny; |
| 207 node->RemoveInput(0); | 206 node->RemoveInput(0); |
| 208 --arity; | 207 --arity; |
| 209 } | 208 } |
| 210 NodeProperties::ChangeOp( | 209 NodeProperties::ChangeOp( |
| 211 node, javascript()->CallFunction(arity, p.language_mode(), | 210 node, javascript()->CallFunction(arity, CallCountFeedback(p.feedback()), |
| 212 CallCountFeedback(p.feedback()), | |
| 213 convert_mode, p.tail_call_mode())); | 211 convert_mode, p.tail_call_mode())); |
| 214 // Try to further reduce the JSCallFunction {node}. | 212 // Try to further reduce the JSCallFunction {node}. |
| 215 Reduction const reduction = ReduceJSCallFunction(node); | 213 Reduction const reduction = ReduceJSCallFunction(node); |
| 216 return reduction.Changed() ? reduction : Changed(node); | 214 return reduction.Changed() ? reduction : Changed(node); |
| 217 } | 215 } |
| 218 | 216 |
| 219 | 217 |
| 220 Reduction JSCallReducer::ReduceJSCallFunction(Node* node) { | 218 Reduction JSCallReducer::ReduceJSCallFunction(Node* node) { |
| 221 DCHECK_EQ(IrOpcode::kJSCallFunction, node->opcode()); | 219 DCHECK_EQ(IrOpcode::kJSCallFunction, node->opcode()); |
| 222 CallFunctionParameters const& p = CallFunctionParametersOf(node->op()); | 220 CallFunctionParameters const& p = CallFunctionParametersOf(node->op()); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 node, jsgraph()->Constant(bound_target_function), 0); | 282 node, jsgraph()->Constant(bound_target_function), 0); |
| 285 NodeProperties::ReplaceValueInput(node, jsgraph()->Constant(bound_this), | 283 NodeProperties::ReplaceValueInput(node, jsgraph()->Constant(bound_this), |
| 286 1); | 284 1); |
| 287 // Insert the [[BoundArguments]] for {node}. | 285 // Insert the [[BoundArguments]] for {node}. |
| 288 for (int i = 0; i < bound_arguments->length(); ++i) { | 286 for (int i = 0; i < bound_arguments->length(); ++i) { |
| 289 node->InsertInput( | 287 node->InsertInput( |
| 290 graph()->zone(), i + 2, | 288 graph()->zone(), i + 2, |
| 291 jsgraph()->Constant(handle(bound_arguments->get(i), isolate()))); | 289 jsgraph()->Constant(handle(bound_arguments->get(i), isolate()))); |
| 292 arity++; | 290 arity++; |
| 293 } | 291 } |
| 294 NodeProperties::ChangeOp( | 292 NodeProperties::ChangeOp(node, javascript()->CallFunction( |
| 295 node, javascript()->CallFunction(arity, p.language_mode(), | 293 arity, CallCountFeedback(p.feedback()), |
| 296 CallCountFeedback(p.feedback()), | 294 convert_mode, p.tail_call_mode())); |
| 297 convert_mode, p.tail_call_mode())); | |
| 298 // Try to further reduce the JSCallFunction {node}. | 295 // Try to further reduce the JSCallFunction {node}. |
| 299 Reduction const reduction = ReduceJSCallFunction(node); | 296 Reduction const reduction = ReduceJSCallFunction(node); |
| 300 return reduction.Changed() ? reduction : Changed(node); | 297 return reduction.Changed() ? reduction : Changed(node); |
| 301 } | 298 } |
| 302 | 299 |
| 303 // Don't mess with other {node}s that have a constant {target}. | 300 // Don't mess with other {node}s that have a constant {target}. |
| 304 // TODO(bmeurer): Also support proxies here. | 301 // TODO(bmeurer): Also support proxies here. |
| 305 return NoChange(); | 302 return NoChange(); |
| 306 } | 303 } |
| 307 | 304 |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 555 } | 552 } |
| 556 | 553 |
| 557 | 554 |
| 558 JSOperatorBuilder* JSCallReducer::javascript() const { | 555 JSOperatorBuilder* JSCallReducer::javascript() const { |
| 559 return jsgraph()->javascript(); | 556 return jsgraph()->javascript(); |
| 560 } | 557 } |
| 561 | 558 |
| 562 } // namespace compiler | 559 } // namespace compiler |
| 563 } // namespace internal | 560 } // namespace internal |
| 564 } // namespace v8 | 561 } // namespace v8 |
| OLD | NEW |