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

Unified Diff: src/parsing/parser-base.h

Issue 2399833002: Teach Scopes whether they will end up being lazily compiled or not (Closed)
Patch Set: Created 4 years, 2 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/parsing/parser-base.h
diff --git a/src/parsing/parser-base.h b/src/parsing/parser-base.h
index 1ebbee4959e8f22f230a563e7e32716264f24561..04fb448f40a077b8ab402b8804da019df3cf37ec 100644
--- a/src/parsing/parser-base.h
+++ b/src/parsing/parser-base.h
@@ -200,7 +200,10 @@ class ParserBase {
allow_harmony_async_await_(false),
allow_harmony_restrictive_generators_(false),
allow_harmony_trailing_commas_(false),
- allow_harmony_class_fields_(false) {}
+ allow_harmony_class_fields_(false),
+ will_serialize_(false),
+ serializer_enabled_(false),
+ is_debug_(false) {}
#define ALLOW_ACCESSORS(name) \
bool allow_##name() const { return allow_##name##_; } \
@@ -224,26 +227,30 @@ class ParserBase {
void set_stack_limit(uintptr_t stack_limit) { stack_limit_ = stack_limit; }
+ bool will_serialize() const { return will_serialize_; }
+ void set_will_serialize(bool will_serialize) {
+ will_serialize_ = will_serialize;
+ }
+ bool serializer_enabled() const { return serializer_enabled_; }
+ void set_serializer_enabled(bool serializer_enabled) {
+ serializer_enabled_ = serializer_enabled;
+ }
+ bool is_debug() const { return is_debug_; }
+ void set_is_debug(bool is_debug) { is_debug_ = is_debug; }
+
Zone* zone() const { return zone_; }
protected:
friend class v8::internal::ExpressionClassifier<ParserTypes<Impl>>;
- // clang-format off
jochen (gone - plz use gerrit) 2016/10/06 11:30:15 we shouldn't randomly disable clang-format, but st
enum AllowRestrictedIdentifiers {
kAllowRestrictedIdentifiers,
kDontAllowRestrictedIdentifiers
};
- enum Mode {
- PARSE_LAZILY,
- PARSE_EAGERLY
- };
+ enum Mode { PARSE_LAZILY, PARSE_EAGERLY };
- enum LazyParsingResult {
- kLazyParsingComplete,
- kLazyParsingAborted
- };
+ enum LazyParsingResult { kLazyParsingComplete, kLazyParsingAborted };
enum VariableDeclarationContext {
kStatementListItem,
@@ -251,11 +258,7 @@ class ParserBase {
kForStatement
};
- enum class FunctionBodyType {
- kNormal,
- kSingleExpression
- };
- // clang-format on
+ enum class FunctionBodyType { kNormal, kSingleExpression };
class Checkpoint;
class ClassLiteralChecker;
@@ -1456,6 +1459,10 @@ class ParserBase {
bool allow_harmony_trailing_commas_;
bool allow_harmony_class_fields_;
+ bool will_serialize_;
+ bool serializer_enabled_;
marja 2016/10/06 11:53:06 Seems unnecessary to need these bools in ParserBas
jochen (gone - plz use gerrit) 2016/10/06 15:05:04 allow_lazy is for native scripts for example - we
+ bool is_debug_;
+
friend class DiscardableZoneScope;
};
@@ -2291,6 +2298,9 @@ ParserBase<Impl>::ParseClassFieldForInitializer(bool has_initializer,
FunctionLiteral::kAnonymousExpression,
FunctionLiteral::kShouldLazyCompile, initializer_scope->start_position());
function_literal->set_is_class_field_initializer(true);
+ if (impl()->ShouldCompileLazily(function_literal)) {
+ initializer_scope->SetShouldCompileLazily(true);
+ }
return function_literal;
}
@@ -4043,6 +4053,10 @@ ParserBase<Impl>::ParseArrowFunctionLiteral(
impl()->AddFunctionForNameInference(function_literal);
+ if (impl()->ShouldCompileLazily(function_literal)) {
+ formal_parameters.scope->SetShouldCompileLazily(true);
+ }
+
return function_literal;
}
@@ -4693,7 +4707,7 @@ ParserBase<Impl>::ParseExpressionOrLabelledStatement(
// Identifier ':' Statement
//
// ExpressionStatement[Yield] :
- // [lookahead ∉ {{, function, class, let [}] Expression[In, ?Yield] ;
+ // [lookahead notin {{, function, class, let [}] Expression[In, ?Yield] ;
jochen (gone - plz use gerrit) 2016/10/06 11:30:14 clang-format.py can't deal with this character..
int pos = peek_position();
« src/parsing/parser.cc ('K') | « src/parsing/parser.cc ('k') | src/parsing/preparser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698