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 2649 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2660 return value; | 2660 return value; |
2661 } | 2661 } |
2662 | 2662 |
2663 | 2663 |
2664 Node* AstGraphBuilder::BuildPatchReceiverToGlobalProxy(Node* receiver) { | 2664 Node* AstGraphBuilder::BuildPatchReceiverToGlobalProxy(Node* receiver) { |
2665 // Sloppy mode functions and builtins need to replace the receiver with the | 2665 // Sloppy mode functions and builtins need to replace the receiver with the |
2666 // global proxy when called as functions (without an explicit receiver | 2666 // global proxy when called as functions (without an explicit receiver |
2667 // object). Otherwise there is nothing left to do here. | 2667 // object). Otherwise there is nothing left to do here. |
2668 if (is_strict(language_mode()) || info()->is_native()) return receiver; | 2668 if (is_strict(language_mode()) || info()->is_native()) return receiver; |
2669 | 2669 |
2670 // There is no need to perform patching if the receiver is never used. Note | 2670 // There is no need to perform patching if the receiver will never be used. |
2671 // that scope predicates are purely syntactical, a call to eval might still | |
2672 // inspect the receiver value. | |
2673 if (!info()->MayUseThis()) return receiver; | 2671 if (!info()->MayUseThis()) return receiver; |
2674 | 2672 |
2675 IfBuilder receiver_check(this); | 2673 IfBuilder receiver_check(this); |
2676 Node* undefined = jsgraph()->UndefinedConstant(); | 2674 Node* undefined = jsgraph()->UndefinedConstant(); |
2677 Node* check = NewNode(javascript()->StrictEqual(), receiver, undefined); | 2675 Node* check = NewNode(javascript()->StrictEqual(), receiver, undefined); |
2678 receiver_check.If(check); | 2676 receiver_check.If(check); |
2679 receiver_check.Then(); | 2677 receiver_check.Then(); |
2680 Node* proxy = BuildLoadGlobalProxy(); | 2678 Node* proxy = BuildLoadGlobalProxy(); |
2681 environment()->Push(proxy); | 2679 environment()->Push(proxy); |
2682 receiver_check.Else(); | 2680 receiver_check.Else(); |
(...skipping 924 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3607 // Phi does not exist yet, introduce one. | 3605 // Phi does not exist yet, introduce one. |
3608 value = NewPhi(inputs, value, control); | 3606 value = NewPhi(inputs, value, control); |
3609 value->ReplaceInput(inputs - 1, other); | 3607 value->ReplaceInput(inputs - 1, other); |
3610 } | 3608 } |
3611 return value; | 3609 return value; |
3612 } | 3610 } |
3613 | 3611 |
3614 } // namespace compiler | 3612 } // namespace compiler |
3615 } // namespace internal | 3613 } // namespace internal |
3616 } // namespace v8 | 3614 } // namespace v8 |
OLD | NEW |