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

Unified Diff: src/preparser.h

Issue 1317033005: Always lazy compile arrow functions (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Add test and comment Created 5 years, 3 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
« no previous file with comments | « no previous file | test/mjsunit/harmony/regress/regress-4395.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/preparser.h
diff --git a/src/preparser.h b/src/preparser.h
index a5aa3709a6d509174fe9c02530b80cd940c907ab..2b07de94c47037d58c1f1a0652f96a75fe2d2677 100644
--- a/src/preparser.h
+++ b/src/preparser.h
@@ -1083,6 +1083,7 @@ class PreParserExpression {
// More dummy implementations of things PreParser doesn't need to track:
void set_index(int index) {} // For YieldExpressions
void set_should_eager_compile() {}
+ FunctionKind kind() const { return FunctionKind::kNormalFunction; }
int position() const { return RelocInfo::kNoPosition; }
void set_function_token_position(int position) {}
@@ -3279,8 +3280,12 @@ ParserBase<Traits>::ParseLeftHandSideExpression(
pos = peek_position();
// Also the trailing parenthesis are a hint that the function will
// be called immediately. If we happen to have parsed a preceding
- // function literal eagerly, we can also compile it eagerly.
- if (result->IsFunctionLiteral() && mode() == PARSE_EAGERLY) {
+ // function literal eagerly, we can also compile it eagerly (unless
+ // that literal was an arrow function, in which case we always
+ // compile lazily in order to get scoping right for its parameters,
+ // see https://code.google.com/p/v8/issues/detail?id=4395).
+ if (result->IsFunctionLiteral() && mode() == PARSE_EAGERLY &&
+ !IsArrowFunction(result->AsFunctionLiteral()->kind())) {
caitp (gmail) 2015/09/19 21:34:36 The only time you _need_ to force re-parsing of ar
rossberg 2015/09/22 15:33:05 That's a good point. It might make sense to avoid
result->AsFunctionLiteral()->set_should_eager_compile();
}
}
« no previous file with comments | « no previous file | test/mjsunit/harmony/regress/regress-4395.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698