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/js-inlining.h" | 5 #include "src/compiler/js-inlining.h" |
6 | 6 |
7 #include "src/ast/ast-numbering.h" | 7 #include "src/ast/ast-numbering.h" |
8 #include "src/ast/ast.h" | 8 #include "src/ast/ast.h" |
9 #include "src/ast/scopes.h" | 9 #include "src/ast/scopes.h" |
10 #include "src/compiler.h" | 10 #include "src/compiler.h" |
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
427 Node* receiver = jsgraph()->UndefinedConstant(); // Implicit receiver. | 427 Node* receiver = jsgraph()->UndefinedConstant(); // Implicit receiver. |
428 if (NeedsImplicitReceiver(shared_info)) { | 428 if (NeedsImplicitReceiver(shared_info)) { |
429 Node* frame_state_before = NodeProperties::FindFrameStateBefore(node); | 429 Node* frame_state_before = NodeProperties::FindFrameStateBefore(node); |
430 Node* effect = NodeProperties::GetEffectInput(node); | 430 Node* effect = NodeProperties::GetEffectInput(node); |
431 Node* context = NodeProperties::GetContextInput(node); | 431 Node* context = NodeProperties::GetContextInput(node); |
432 Node* create = graph()->NewNode(javascript()->Create(), call.target(), | 432 Node* create = graph()->NewNode(javascript()->Create(), call.target(), |
433 call.new_target(), context, | 433 call.new_target(), context, |
434 frame_state_before, effect); | 434 frame_state_before, effect); |
435 NodeProperties::ReplaceEffectInput(node, create); | 435 NodeProperties::ReplaceEffectInput(node, create); |
436 // Insert a check of the return value to determine whether the return | 436 // Insert a check of the return value to determine whether the return |
437 // value | 437 // value or the implicit receiver should be selected as a result of the |
438 // or the implicit receiver should be selected as a result of the call. | 438 // call. The check is wired into the successful control completion. |
| 439 Node* success = graph()->NewNode(common()->IfSuccess(), node); |
439 Node* check = graph()->NewNode( | 440 Node* check = graph()->NewNode( |
440 javascript()->CallRuntime(Runtime::kInlineIsJSReceiver, 1), node, | 441 javascript()->CallRuntime(Runtime::kInlineIsJSReceiver, 1), node, |
441 context, node, start); | 442 context, node, success); |
442 Node* select = | 443 Node* select = |
443 graph()->NewNode(common()->Select(MachineRepresentation::kTagged), | 444 graph()->NewNode(common()->Select(MachineRepresentation::kTagged), |
444 check, node, create); | 445 check, node, create); |
445 NodeProperties::ReplaceUses(node, select, check, node, node); | 446 NodeProperties::ReplaceUses(node, select, check, check, node); |
446 NodeProperties::ReplaceValueInput(select, node, 1); | 447 // Fix-up inputs that have been mangled by the {ReplaceUses} call above. |
447 NodeProperties::ReplaceValueInput(check, node, 0); | 448 NodeProperties::ReplaceValueInput(select, node, 1); // Fix-up input. |
448 NodeProperties::ReplaceEffectInput(check, node); | 449 NodeProperties::ReplaceValueInput(check, node, 0); // Fix-up input. |
| 450 NodeProperties::ReplaceEffectInput(check, node); // Fix-up input. |
| 451 NodeProperties::ReplaceControlInput(success, node); // Fix-up input. |
449 receiver = create; // The implicit receiver. | 452 receiver = create; // The implicit receiver. |
450 } | 453 } |
451 | 454 |
452 // Swizzle the inputs of the {JSCallConstruct} node to look like inputs to a | 455 // Swizzle the inputs of the {JSCallConstruct} node to look like inputs to a |
453 // normal {JSCallFunction} node so that the rest of the inlining machinery | 456 // normal {JSCallFunction} node so that the rest of the inlining machinery |
454 // behaves as if we were dealing with a regular function invocation. | 457 // behaves as if we were dealing with a regular function invocation. |
455 new_target = call.new_target(); // Retrieve new target value input. | 458 new_target = call.new_target(); // Retrieve new target value input. |
456 node->RemoveInput(call.formal_arguments() + 1); // Drop new target. | 459 node->RemoveInput(call.formal_arguments() + 1); // Drop new target. |
457 node->InsertInput(graph()->zone(), 1, receiver); | 460 node->InsertInput(graph()->zone(), 1, receiver); |
458 | 461 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
520 | 523 |
521 JSOperatorBuilder* JSInliner::javascript() const { | 524 JSOperatorBuilder* JSInliner::javascript() const { |
522 return jsgraph()->javascript(); | 525 return jsgraph()->javascript(); |
523 } | 526 } |
524 | 527 |
525 CommonOperatorBuilder* JSInliner::common() const { return jsgraph()->common(); } | 528 CommonOperatorBuilder* JSInliner::common() const { return jsgraph()->common(); } |
526 | 529 |
527 } // namespace compiler | 530 } // namespace compiler |
528 } // namespace internal | 531 } // namespace internal |
529 } // namespace v8 | 532 } // namespace v8 |
OLD | NEW |