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/ast-graph-builder.h" | 5 #include "src/compiler/ast-graph-builder.h" |
6 | 6 |
7 #include "src/compiler.h" | 7 #include "src/compiler.h" |
8 #include "src/compiler/ast-loop-assignment-analyzer.h" | 8 #include "src/compiler/ast-loop-assignment-analyzer.h" |
9 #include "src/compiler/control-builders.h" | 9 #include "src/compiler/control-builders.h" |
10 #include "src/compiler/js-type-feedback.h" | 10 #include "src/compiler/js-type-feedback.h" |
(...skipping 2624 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2635 | 2635 |
2636 Node* AstGraphBuilder::BuildPatchReceiverToGlobalProxy(Node* receiver) { | 2636 Node* AstGraphBuilder::BuildPatchReceiverToGlobalProxy(Node* receiver) { |
2637 // Sloppy mode functions and builtins need to replace the receiver with the | 2637 // Sloppy mode functions and builtins need to replace the receiver with the |
2638 // global proxy when called as functions (without an explicit receiver | 2638 // global proxy when called as functions (without an explicit receiver |
2639 // object). Otherwise there is nothing left to do here. | 2639 // object). Otherwise there is nothing left to do here. |
2640 if (is_strict(language_mode()) || info()->is_native()) return receiver; | 2640 if (is_strict(language_mode()) || info()->is_native()) return receiver; |
2641 | 2641 |
2642 // There is no need to perform patching if the receiver is never used. Note | 2642 // There is no need to perform patching if the receiver is never used. Note |
2643 // that scope predicates are purely syntactical, a call to eval might still | 2643 // that scope predicates are purely syntactical, a call to eval might still |
2644 // inspect the receiver value. | 2644 // inspect the receiver value. |
2645 if (!info()->scope()->uses_this() && !info()->scope()->inner_uses_this() && | 2645 if (!info()->MayUseThis()) return receiver; |
2646 !info()->scope()->calls_sloppy_eval()) { | |
2647 return receiver; | |
2648 } | |
2649 | 2646 |
2650 IfBuilder receiver_check(this); | 2647 IfBuilder receiver_check(this); |
2651 Node* undefined = jsgraph()->UndefinedConstant(); | 2648 Node* undefined = jsgraph()->UndefinedConstant(); |
2652 Node* check = NewNode(javascript()->StrictEqual(), receiver, undefined); | 2649 Node* check = NewNode(javascript()->StrictEqual(), receiver, undefined); |
2653 receiver_check.If(check); | 2650 receiver_check.If(check); |
2654 receiver_check.Then(); | 2651 receiver_check.Then(); |
2655 Node* proxy = BuildLoadGlobalProxy(); | 2652 Node* proxy = BuildLoadGlobalProxy(); |
2656 environment()->Push(proxy); | 2653 environment()->Push(proxy); |
2657 receiver_check.Else(); | 2654 receiver_check.Else(); |
2658 environment()->Push(receiver); | 2655 environment()->Push(receiver); |
(...skipping 912 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3571 // Phi does not exist yet, introduce one. | 3568 // Phi does not exist yet, introduce one. |
3572 value = NewPhi(inputs, value, control); | 3569 value = NewPhi(inputs, value, control); |
3573 value->ReplaceInput(inputs - 1, other); | 3570 value->ReplaceInput(inputs - 1, other); |
3574 } | 3571 } |
3575 return value; | 3572 return value; |
3576 } | 3573 } |
3577 | 3574 |
3578 } // namespace compiler | 3575 } // namespace compiler |
3579 } // namespace internal | 3576 } // namespace internal |
3580 } // namespace v8 | 3577 } // namespace v8 |
OLD | NEW |