| Index: src/compiler/ast-graph-builder.cc
|
| diff --git a/src/compiler/ast-graph-builder.cc b/src/compiler/ast-graph-builder.cc
|
| index 28378a59a5d2fa6372e2bc73e49dd8953dfd8f13..b4056ce812faec114a5f4e883fce41d9fd1225e9 100644
|
| --- a/src/compiler/ast-graph-builder.cc
|
| +++ b/src/compiler/ast-graph-builder.cc
|
| @@ -4,6 +4,7 @@
|
|
|
| #include "src/compiler/ast-graph-builder.h"
|
|
|
| +#include "src/ast-this-access-visitor.h"
|
| #include "src/compiler.h"
|
| #include "src/compiler/ast-loop-assignment-analyzer.h"
|
| #include "src/compiler/control-builders.h"
|
| @@ -80,9 +81,11 @@ bool AstGraphBuilder::CreateGraph() {
|
|
|
| // Build receiver check for sloppy mode if necessary.
|
| // TODO(mstarzinger/verwaest): Should this be moved back into the CallIC?
|
| - Node* original_receiver = env.Lookup(scope->receiver());
|
| - Node* patched_receiver = BuildPatchReceiverToGlobalProxy(original_receiver);
|
| - env.Bind(scope->receiver(), patched_receiver);
|
| + if (scope->has_this_declaration()) {
|
| + Node* original_receiver = env.Lookup(scope->receiver());
|
| + Node* patched_receiver = BuildPatchReceiverToGlobalProxy(original_receiver);
|
| + env.Bind(scope->receiver(), patched_receiver);
|
| + }
|
|
|
| // Build node to initialize local function context.
|
| Node* closure = GetFunctionClosure();
|
| @@ -1956,7 +1959,11 @@ Node* AstGraphBuilder::BuildPatchReceiverToGlobalProxy(Node* receiver) {
|
| // There is no need to perform patching if the receiver is never used. Note
|
| // that scope predicates are purely syntactical, a call to eval might still
|
| // inspect the receiver value.
|
| - if (!info()->scope()->uses_this() && !info()->scope()->inner_uses_this() &&
|
| +
|
| + AstThisAccessVisitor this_access_visitor(isolate(), zone());
|
| + this_access_visitor.VisitStatements(info()->function()->body());
|
| +
|
| + if (!this_access_visitor.UsesThis() &&
|
| !info()->scope()->calls_sloppy_eval()) {
|
| return receiver;
|
| }
|
|
|