Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(130)

Unified Diff: src/compiler/ast-graph-builder.cc

Issue 883823002: Implement proper scoping for "this" in arrow functions Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Make sure an unresolved VariableProxy for "this" is not considered a valid LHS Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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;
}

Powered by Google App Engine
This is Rietveld 408576698