| 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/ast-this-access-visitor.h" |
| 7 #include "src/compiler.h" | 8 #include "src/compiler.h" |
| 8 #include "src/compiler/ast-loop-assignment-analyzer.h" | 9 #include "src/compiler/ast-loop-assignment-analyzer.h" |
| 9 #include "src/compiler/control-builders.h" | 10 #include "src/compiler/control-builders.h" |
| 10 #include "src/compiler/machine-operator.h" | 11 #include "src/compiler/machine-operator.h" |
| 11 #include "src/compiler/node-matchers.h" | 12 #include "src/compiler/node-matchers.h" |
| 12 #include "src/compiler/node-properties-inl.h" | 13 #include "src/compiler/node-properties-inl.h" |
| 13 #include "src/compiler/node-properties.h" | 14 #include "src/compiler/node-properties.h" |
| 14 #include "src/full-codegen.h" | 15 #include "src/full-codegen.h" |
| 15 #include "src/parser.h" | 16 #include "src/parser.h" |
| 16 #include "src/scopes.h" | 17 #include "src/scopes.h" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 // It will be replaced with {Dead} after typing and optimizations. | 74 // It will be replaced with {Dead} after typing and optimizations. |
| 74 NewNode(common()->OsrNormalEntry()); | 75 NewNode(common()->OsrNormalEntry()); |
| 75 } | 76 } |
| 76 | 77 |
| 77 // Initialize the incoming context. | 78 // Initialize the incoming context. |
| 78 Node* outer_context = GetFunctionContext(); | 79 Node* outer_context = GetFunctionContext(); |
| 79 set_current_context(outer_context); | 80 set_current_context(outer_context); |
| 80 | 81 |
| 81 // Build receiver check for sloppy mode if necessary. | 82 // Build receiver check for sloppy mode if necessary. |
| 82 // TODO(mstarzinger/verwaest): Should this be moved back into the CallIC? | 83 // TODO(mstarzinger/verwaest): Should this be moved back into the CallIC? |
| 83 Node* original_receiver = env.Lookup(scope->receiver()); | 84 if (scope->has_this_declaration()) { |
| 84 Node* patched_receiver = BuildPatchReceiverToGlobalProxy(original_receiver); | 85 Node* original_receiver = env.Lookup(scope->receiver()); |
| 85 env.Bind(scope->receiver(), patched_receiver); | 86 Node* patched_receiver = BuildPatchReceiverToGlobalProxy(original_receiver); |
| 87 env.Bind(scope->receiver(), patched_receiver); |
| 88 } |
| 86 | 89 |
| 87 // Build node to initialize local function context. | 90 // Build node to initialize local function context. |
| 88 Node* closure = GetFunctionClosure(); | 91 Node* closure = GetFunctionClosure(); |
| 89 Node* inner_context = BuildLocalFunctionContext(outer_context, closure); | 92 Node* inner_context = BuildLocalFunctionContext(outer_context, closure); |
| 90 | 93 |
| 91 // Push top-level function scope for the function body. | 94 // Push top-level function scope for the function body. |
| 92 ContextScope top_context(this, scope, inner_context); | 95 ContextScope top_context(this, scope, inner_context); |
| 93 | 96 |
| 94 // Build the arguments object if it is used. | 97 // Build the arguments object if it is used. |
| 95 BuildArgumentsObject(scope->arguments()); | 98 BuildArgumentsObject(scope->arguments()); |
| (...skipping 1853 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1949 | 1952 |
| 1950 Node* AstGraphBuilder::BuildPatchReceiverToGlobalProxy(Node* receiver) { | 1953 Node* AstGraphBuilder::BuildPatchReceiverToGlobalProxy(Node* receiver) { |
| 1951 // Sloppy mode functions and builtins need to replace the receiver with the | 1954 // Sloppy mode functions and builtins need to replace the receiver with the |
| 1952 // global proxy when called as functions (without an explicit receiver | 1955 // global proxy when called as functions (without an explicit receiver |
| 1953 // object). Otherwise there is nothing left to do here. | 1956 // object). Otherwise there is nothing left to do here. |
| 1954 if (info()->strict_mode() != SLOPPY || info()->is_native()) return receiver; | 1957 if (info()->strict_mode() != SLOPPY || info()->is_native()) return receiver; |
| 1955 | 1958 |
| 1956 // There is no need to perform patching if the receiver is never used. Note | 1959 // There is no need to perform patching if the receiver is never used. Note |
| 1957 // that scope predicates are purely syntactical, a call to eval might still | 1960 // that scope predicates are purely syntactical, a call to eval might still |
| 1958 // inspect the receiver value. | 1961 // inspect the receiver value. |
| 1959 if (!info()->scope()->uses_this() && !info()->scope()->inner_uses_this() && | 1962 |
| 1963 AstThisAccessVisitor this_access_visitor(isolate(), zone()); |
| 1964 this_access_visitor.VisitStatements(info()->function()->body()); |
| 1965 |
| 1966 if (!this_access_visitor.UsesThis() && |
| 1960 !info()->scope()->calls_sloppy_eval()) { | 1967 !info()->scope()->calls_sloppy_eval()) { |
| 1961 return receiver; | 1968 return receiver; |
| 1962 } | 1969 } |
| 1963 | 1970 |
| 1964 IfBuilder receiver_check(this); | 1971 IfBuilder receiver_check(this); |
| 1965 Node* undefined = jsgraph()->UndefinedConstant(); | 1972 Node* undefined = jsgraph()->UndefinedConstant(); |
| 1966 Node* check = NewNode(javascript()->StrictEqual(), receiver, undefined); | 1973 Node* check = NewNode(javascript()->StrictEqual(), receiver, undefined); |
| 1967 receiver_check.If(check); | 1974 receiver_check.If(check); |
| 1968 receiver_check.Then(); | 1975 receiver_check.Then(); |
| 1969 environment()->Push(BuildLoadGlobalProxy()); | 1976 environment()->Push(BuildLoadGlobalProxy()); |
| (...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2434 | 2441 |
| 2435 BitVector* AstGraphBuilder::GetVariablesAssignedInLoop( | 2442 BitVector* AstGraphBuilder::GetVariablesAssignedInLoop( |
| 2436 IterationStatement* stmt) { | 2443 IterationStatement* stmt) { |
| 2437 if (loop_assignment_analysis_ == NULL) return NULL; | 2444 if (loop_assignment_analysis_ == NULL) return NULL; |
| 2438 return loop_assignment_analysis_->GetVariablesAssignedInLoop(stmt); | 2445 return loop_assignment_analysis_->GetVariablesAssignedInLoop(stmt); |
| 2439 } | 2446 } |
| 2440 | 2447 |
| 2441 } // namespace compiler | 2448 } // namespace compiler |
| 2442 } // namespace internal | 2449 } // namespace internal |
| 2443 } // namespace v8 | 2450 } // namespace v8 |
| OLD | NEW |