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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | test/mjsunit/harmony/regress/regress-4395.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 #ifndef V8_PREPARSER_H 5 #ifndef V8_PREPARSER_H
6 #define V8_PREPARSER_H 6 #define V8_PREPARSER_H
7 7
8 #include "src/bailout-reason.h" 8 #include "src/bailout-reason.h"
9 #include "src/expression-classifier.h" 9 #include "src/expression-classifier.h"
10 #include "src/func-name-inferrer.h" 10 #include "src/func-name-inferrer.h"
(...skipping 1065 matching lines...) Expand 10 before | Expand all | Expand 10 after
1076 return TypeField::decode(code_) == kBinaryOperationExpression; 1076 return TypeField::decode(code_) == kBinaryOperationExpression;
1077 } 1077 }
1078 1078
1079 // Dummy implementation for making expression->somefunc() work in both Parser 1079 // Dummy implementation for making expression->somefunc() work in both Parser
1080 // and PreParser. 1080 // and PreParser.
1081 PreParserExpression* operator->() { return this; } 1081 PreParserExpression* operator->() { return this; }
1082 1082
1083 // More dummy implementations of things PreParser doesn't need to track: 1083 // More dummy implementations of things PreParser doesn't need to track:
1084 void set_index(int index) {} // For YieldExpressions 1084 void set_index(int index) {} // For YieldExpressions
1085 void set_should_eager_compile() {} 1085 void set_should_eager_compile() {}
1086 FunctionKind kind() const { return FunctionKind::kNormalFunction; }
1086 1087
1087 int position() const { return RelocInfo::kNoPosition; } 1088 int position() const { return RelocInfo::kNoPosition; }
1088 void set_function_token_position(int position) {} 1089 void set_function_token_position(int position) {}
1089 1090
1090 private: 1091 private:
1091 enum Type { 1092 enum Type {
1092 kExpression, 1093 kExpression,
1093 kIdentifierExpression, 1094 kIdentifierExpression,
1094 kStringLiteralExpression, 1095 kStringLiteralExpression,
1095 kBinaryOperationExpression, 1096 kBinaryOperationExpression,
(...skipping 2176 matching lines...) Expand 10 before | Expand all | Expand 10 after
3272 pos = position(); 3273 pos = position();
3273 } else { 3274 } else {
3274 // For other kinds of calls we record position of the parenthesis as 3275 // For other kinds of calls we record position of the parenthesis as
3275 // position of the call. Note that this is extremely important for 3276 // position of the call. Note that this is extremely important for
3276 // expressions of the form function(){...}() for which call position 3277 // expressions of the form function(){...}() for which call position
3277 // should not point to the closing brace otherwise it will intersect 3278 // should not point to the closing brace otherwise it will intersect
3278 // with positions recorded for function literal and confuse debugger. 3279 // with positions recorded for function literal and confuse debugger.
3279 pos = peek_position(); 3280 pos = peek_position();
3280 // Also the trailing parenthesis are a hint that the function will 3281 // Also the trailing parenthesis are a hint that the function will
3281 // be called immediately. If we happen to have parsed a preceding 3282 // be called immediately. If we happen to have parsed a preceding
3282 // function literal eagerly, we can also compile it eagerly. 3283 // function literal eagerly, we can also compile it eagerly (unless
3283 if (result->IsFunctionLiteral() && mode() == PARSE_EAGERLY) { 3284 // that literal was an arrow function, in which case we always
3285 // compile lazily in order to get scoping right for its parameters,
3286 // see https://code.google.com/p/v8/issues/detail?id=4395).
3287 if (result->IsFunctionLiteral() && mode() == PARSE_EAGERLY &&
3288 !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
3284 result->AsFunctionLiteral()->set_should_eager_compile(); 3289 result->AsFunctionLiteral()->set_should_eager_compile();
3285 } 3290 }
3286 } 3291 }
3287 Scanner::Location spread_pos; 3292 Scanner::Location spread_pos;
3288 typename Traits::Type::ExpressionList args = 3293 typename Traits::Type::ExpressionList args =
3289 ParseArguments(&spread_pos, classifier, CHECK_OK); 3294 ParseArguments(&spread_pos, classifier, CHECK_OK);
3290 3295
3291 // Keep track of eval() calls since they disable all local variable 3296 // Keep track of eval() calls since they disable all local variable
3292 // optimizations. 3297 // optimizations.
3293 // The calls that need special treatment are the 3298 // The calls that need special treatment are the
(...skipping 884 matching lines...) Expand 10 before | Expand all | Expand 10 after
4178 *ok = false; 4183 *ok = false;
4179 return; 4184 return;
4180 } 4185 }
4181 has_seen_constructor_ = true; 4186 has_seen_constructor_ = true;
4182 return; 4187 return;
4183 } 4188 }
4184 } 4189 }
4185 } } // v8::internal 4190 } } // v8::internal
4186 4191
4187 #endif // V8_PREPARSER_H 4192 #endif // V8_PREPARSER_H
OLDNEW
« 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