Commit feb78771 authored by verwaest's avatar verwaest Committed by Commit bot

Move allow_lazy from ParserBase to Parser and remove accessors

BUG=

Review-Url: https://codereview.chromium.org/2506613002
Cr-Commit-Position: refs/heads/master@{#41031}
parent d49cd530
...@@ -207,7 +207,6 @@ class ParserBase { ...@@ -207,7 +207,6 @@ class ParserBase {
scanner_(scanner), scanner_(scanner),
stack_overflow_(false), stack_overflow_(false),
default_eager_compile_hint_(FunctionLiteral::kShouldLazyCompile), default_eager_compile_hint_(FunctionLiteral::kShouldLazyCompile),
allow_lazy_(false),
allow_natives_(false), allow_natives_(false),
allow_tailcalls_(false), allow_tailcalls_(false),
allow_harmony_do_expressions_(false), allow_harmony_do_expressions_(false),
...@@ -221,7 +220,6 @@ class ParserBase { ...@@ -221,7 +220,6 @@ class ParserBase {
bool allow_##name() const { return allow_##name##_; } \ bool allow_##name() const { return allow_##name##_; } \
void set_allow_##name(bool allow) { allow_##name##_ = allow; } void set_allow_##name(bool allow) { allow_##name##_ = allow; }
ALLOW_ACCESSORS(lazy);
ALLOW_ACCESSORS(natives); ALLOW_ACCESSORS(natives);
ALLOW_ACCESSORS(tailcalls); ALLOW_ACCESSORS(tailcalls);
ALLOW_ACCESSORS(harmony_do_expressions); ALLOW_ACCESSORS(harmony_do_expressions);
...@@ -1437,7 +1435,6 @@ class ParserBase { ...@@ -1437,7 +1435,6 @@ class ParserBase {
FunctionLiteral::EagerCompileHint default_eager_compile_hint_; FunctionLiteral::EagerCompileHint default_eager_compile_hint_;
bool allow_lazy_;
bool allow_natives_; bool allow_natives_;
bool allow_tailcalls_; bool allow_tailcalls_;
bool allow_harmony_do_expressions_; bool allow_harmony_do_expressions_;
......
...@@ -615,9 +615,8 @@ Parser::Parser(ParseInfo* info) ...@@ -615,9 +615,8 @@ Parser::Parser(ParseInfo* info)
set_default_eager_compile_hint(can_compile_lazily set_default_eager_compile_hint(can_compile_lazily
? FunctionLiteral::kShouldLazyCompile ? FunctionLiteral::kShouldLazyCompile
: FunctionLiteral::kShouldEagerCompile); : FunctionLiteral::kShouldEagerCompile);
set_allow_lazy(FLAG_lazy && info->allow_lazy_parsing() && allow_lazy_ = FLAG_lazy && info->allow_lazy_parsing() && !info->is_native() &&
!info->is_native() && info->extension() == nullptr && info->extension() == nullptr && can_compile_lazily;
can_compile_lazily);
set_allow_natives(FLAG_allow_natives_syntax || info->is_native()); set_allow_natives(FLAG_allow_natives_syntax || info->is_native());
set_allow_tailcalls(FLAG_harmony_tailcalls && !info->is_native() && set_allow_tailcalls(FLAG_harmony_tailcalls && !info->is_native() &&
info->isolate()->is_tail_call_elimination_enabled()); info->isolate()->is_tail_call_elimination_enabled());
...@@ -730,7 +729,7 @@ FunctionLiteral* Parser::DoParseProgram(ParseInfo* info) { ...@@ -730,7 +729,7 @@ FunctionLiteral* Parser::DoParseProgram(ParseInfo* info) {
DCHECK_NULL(scope_state_); DCHECK_NULL(scope_state_);
DCHECK_NULL(target_stack_); DCHECK_NULL(target_stack_);
ParsingModeScope mode(this, allow_lazy() ? PARSE_LAZILY : PARSE_EAGERLY); ParsingModeScope mode(this, allow_lazy_ ? PARSE_LAZILY : PARSE_EAGERLY);
FunctionLiteral* result = NULL; FunctionLiteral* result = NULL;
{ {
...@@ -2569,7 +2568,7 @@ FunctionLiteral* Parser::ParseFunctionLiteral( ...@@ -2569,7 +2568,7 @@ FunctionLiteral* Parser::ParseFunctionLiteral(
// immediately). bar can be parsed lazily, but we need to parse it in a mode // immediately). bar can be parsed lazily, but we need to parse it in a mode
// that tracks unresolved variables. // that tracks unresolved variables.
DCHECK_IMPLIES(parse_lazily(), FLAG_lazy); DCHECK_IMPLIES(parse_lazily(), FLAG_lazy);
DCHECK_IMPLIES(parse_lazily(), allow_lazy()); DCHECK_IMPLIES(parse_lazily(), allow_lazy_);
DCHECK_IMPLIES(parse_lazily(), extension_ == nullptr); DCHECK_IMPLIES(parse_lazily(), extension_ == nullptr);
bool can_preparse = parse_lazily() && bool can_preparse = parse_lazily() &&
...@@ -2604,7 +2603,7 @@ FunctionLiteral* Parser::ParseFunctionLiteral( ...@@ -2604,7 +2603,7 @@ FunctionLiteral* Parser::ParseFunctionLiteral(
(FLAG_lazy_inner_functions (FLAG_lazy_inner_functions
? can_preparse ? can_preparse
: (is_lazy_top_level_function || : (is_lazy_top_level_function ||
(allow_lazy() && function_type == FunctionLiteral::kDeclaration && (allow_lazy_ && function_type == FunctionLiteral::kDeclaration &&
eager_compile_hint == FunctionLiteral::kShouldLazyCompile))) && eager_compile_hint == FunctionLiteral::kShouldLazyCompile))) &&
!(FLAG_validate_asm && scope()->IsAsmModule()); !(FLAG_validate_asm && scope()->IsAsmModule());
bool is_lazy_inner_function = bool is_lazy_inner_function =
...@@ -2791,7 +2790,6 @@ Parser::LazyParsingResult Parser::SkipFunction( ...@@ -2791,7 +2790,6 @@ Parser::LazyParsingResult Parser::SkipFunction(
reusable_preparser_ = new PreParser(zone(), &scanner_, ast_value_factory(), reusable_preparser_ = new PreParser(zone(), &scanner_, ast_value_factory(),
&pending_error_handler_, &pending_error_handler_,
runtime_call_stats_, stack_limit_); runtime_call_stats_, stack_limit_);
reusable_preparser_->set_allow_lazy(true);
#define SET_ALLOW(name) reusable_preparser_->set_allow_##name(allow_##name()); #define SET_ALLOW(name) reusable_preparser_->set_allow_##name(allow_##name());
SET_ALLOW(natives); SET_ALLOW(natives);
SET_ALLOW(harmony_do_expressions); SET_ALLOW(harmony_do_expressions);
...@@ -3160,7 +3158,7 @@ ZoneList<Statement*>* Parser::ParseEagerFunctionBody( ...@@ -3160,7 +3158,7 @@ ZoneList<Statement*>* Parser::ParseEagerFunctionBody(
const AstRawString* function_name, int pos, const AstRawString* function_name, int pos,
const ParserFormalParameters& parameters, FunctionKind kind, const ParserFormalParameters& parameters, FunctionKind kind,
FunctionLiteral::FunctionType function_type, bool* ok) { FunctionLiteral::FunctionType function_type, bool* ok) {
ParsingModeScope mode(this, allow_lazy() ? PARSE_LAZILY : PARSE_EAGERLY); ParsingModeScope mode(this, allow_lazy_ ? PARSE_LAZILY : PARSE_EAGERLY);
ZoneList<Statement*>* result = new(zone()) ZoneList<Statement*>(8, zone()); ZoneList<Statement*>* result = new(zone()) ZoneList<Statement*>(8, zone());
static const int kFunctionNameAssignmentIndex = 0; static const int kFunctionNameAssignmentIndex = 0;
......
...@@ -290,11 +290,11 @@ class V8_EXPORT_PRIVATE Parser : public NON_EXPORTED_BASE(ParserBase<Parser>) { ...@@ -290,11 +290,11 @@ class V8_EXPORT_PRIVATE Parser : public NON_EXPORTED_BASE(ParserBase<Parser>) {
return compile_options_; return compile_options_;
} }
bool consume_cached_parse_data() const { bool consume_cached_parse_data() const {
return allow_lazy() && return allow_lazy_ &&
compile_options_ == ScriptCompiler::kConsumeParserCache; compile_options_ == ScriptCompiler::kConsumeParserCache;
} }
bool produce_cached_parse_data() const { bool produce_cached_parse_data() const {
return allow_lazy() && return allow_lazy_ &&
compile_options_ == ScriptCompiler::kProduceParserCache; compile_options_ == ScriptCompiler::kProduceParserCache;
} }
...@@ -1146,6 +1146,7 @@ class V8_EXPORT_PRIVATE Parser : public NON_EXPORTED_BASE(ParserBase<Parser>) { ...@@ -1146,6 +1146,7 @@ class V8_EXPORT_PRIVATE Parser : public NON_EXPORTED_BASE(ParserBase<Parser>) {
int use_counts_[v8::Isolate::kUseCounterFeatureCount]; int use_counts_[v8::Isolate::kUseCounterFeatureCount];
int total_preparse_skipped_; int total_preparse_skipped_;
bool parsing_on_main_thread_; bool parsing_on_main_thread_;
bool allow_lazy_;
ParserLogger* log_; ParserLogger* log_;
}; };
......
...@@ -177,7 +177,6 @@ TEST(ScanHTMLEndComments) { ...@@ -177,7 +177,6 @@ TEST(ScanHTMLEndComments) {
i::PreParser preparser( i::PreParser preparser(
&zone, &scanner, &ast_value_factory, &pending_error_handler, &zone, &scanner, &ast_value_factory, &pending_error_handler,
CcTest::i_isolate()->counters()->runtime_call_stats(), stack_limit); CcTest::i_isolate()->counters()->runtime_call_stats(), stack_limit);
preparser.set_allow_lazy(true);
i::PreParser::PreParseResult result = preparser.PreParseProgram(); i::PreParser::PreParseResult result = preparser.PreParseProgram();
CHECK_EQ(i::PreParser::kPreParseSuccess, result); CHECK_EQ(i::PreParser::kPreParseSuccess, result);
CHECK(!pending_error_handler.has_pending_error()); CHECK(!pending_error_handler.has_pending_error());
...@@ -195,7 +194,6 @@ TEST(ScanHTMLEndComments) { ...@@ -195,7 +194,6 @@ TEST(ScanHTMLEndComments) {
i::PreParser preparser( i::PreParser preparser(
&zone, &scanner, &ast_value_factory, &pending_error_handler, &zone, &scanner, &ast_value_factory, &pending_error_handler,
CcTest::i_isolate()->counters()->runtime_call_stats(), stack_limit); CcTest::i_isolate()->counters()->runtime_call_stats(), stack_limit);
preparser.set_allow_lazy(true);
i::PreParser::PreParseResult result = preparser.PreParseProgram(); i::PreParser::PreParseResult result = preparser.PreParseProgram();
// Even in the case of a syntax error, kPreParseSuccess is returned. // Even in the case of a syntax error, kPreParseSuccess is returned.
CHECK_EQ(i::PreParser::kPreParseSuccess, result); CHECK_EQ(i::PreParser::kPreParseSuccess, result);
...@@ -370,7 +368,6 @@ TEST(StandAlonePreParser) { ...@@ -370,7 +368,6 @@ TEST(StandAlonePreParser) {
i::PreParser preparser( i::PreParser preparser(
&zone, &scanner, &ast_value_factory, &pending_error_handler, &zone, &scanner, &ast_value_factory, &pending_error_handler,
CcTest::i_isolate()->counters()->runtime_call_stats(), stack_limit); CcTest::i_isolate()->counters()->runtime_call_stats(), stack_limit);
preparser.set_allow_lazy(true);
preparser.set_allow_natives(true); preparser.set_allow_natives(true);
i::PreParser::PreParseResult result = preparser.PreParseProgram(); i::PreParser::PreParseResult result = preparser.PreParseProgram();
CHECK_EQ(i::PreParser::kPreParseSuccess, result); CHECK_EQ(i::PreParser::kPreParseSuccess, result);
...@@ -406,7 +403,6 @@ TEST(StandAlonePreParserNoNatives) { ...@@ -406,7 +403,6 @@ TEST(StandAlonePreParserNoNatives) {
i::PreParser preparser( i::PreParser preparser(
&zone, &scanner, &ast_value_factory, &pending_error_handler, &zone, &scanner, &ast_value_factory, &pending_error_handler,
isolate->counters()->runtime_call_stats(), stack_limit); isolate->counters()->runtime_call_stats(), stack_limit);
preparser.set_allow_lazy(true);
i::PreParser::PreParseResult result = preparser.PreParseProgram(); i::PreParser::PreParseResult result = preparser.PreParseProgram();
CHECK_EQ(i::PreParser::kPreParseSuccess, result); CHECK_EQ(i::PreParser::kPreParseSuccess, result);
CHECK(pending_error_handler.has_pending_error()); CHECK(pending_error_handler.has_pending_error());
...@@ -475,7 +471,6 @@ TEST(RegressChromium62639) { ...@@ -475,7 +471,6 @@ TEST(RegressChromium62639) {
&pending_error_handler, &pending_error_handler,
isolate->counters()->runtime_call_stats(), isolate->counters()->runtime_call_stats(),
CcTest::i_isolate()->stack_guard()->real_climit()); CcTest::i_isolate()->stack_guard()->real_climit());
preparser.set_allow_lazy(true);
i::PreParser::PreParseResult result = preparser.PreParseProgram(); i::PreParser::PreParseResult result = preparser.PreParseProgram();
// Even in the case of a syntax error, kPreParseSuccess is returned. // Even in the case of a syntax error, kPreParseSuccess is returned.
CHECK_EQ(i::PreParser::kPreParseSuccess, result); CHECK_EQ(i::PreParser::kPreParseSuccess, result);
...@@ -551,7 +546,6 @@ TEST(PreParseOverflow) { ...@@ -551,7 +546,6 @@ TEST(PreParseOverflow) {
i::PreParser preparser( i::PreParser preparser(
&zone, &scanner, &ast_value_factory, &pending_error_handler, &zone, &scanner, &ast_value_factory, &pending_error_handler,
isolate->counters()->runtime_call_stats(), stack_limit); isolate->counters()->runtime_call_stats(), stack_limit);
preparser.set_allow_lazy(true);
i::PreParser::PreParseResult result = preparser.PreParseProgram(); i::PreParser::PreParseResult result = preparser.PreParseProgram();
CHECK_EQ(i::PreParser::kPreParseStackOverflow, result); CHECK_EQ(i::PreParser::kPreParseStackOverflow, result);
} }
...@@ -1180,10 +1174,10 @@ TEST(ScopePositions) { ...@@ -1180,10 +1174,10 @@ TEST(ScopePositions) {
i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME); i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME);
i::ParseInfo info(&zone, script); i::ParseInfo info(&zone, script);
i::Parser parser(&info); i::Parser parser(&info);
parser.set_allow_lazy(true);
info.set_language_mode(source_data[i].language_mode); info.set_language_mode(source_data[i].language_mode);
info.set_allow_lazy_parsing();
parser.Parse(&info); parser.Parse(&info);
CHECK(info.literal() != NULL); CHECK_NOT_NULL(info.literal());
// Check scope types and positions. // Check scope types and positions.
i::Scope* scope = info.literal()->scope(); i::Scope* scope = info.literal()->scope();
...@@ -1298,7 +1292,6 @@ enum ParserSyncTestResult { ...@@ -1298,7 +1292,6 @@ enum ParserSyncTestResult {
template <typename Traits> template <typename Traits>
void SetParserFlags(i::ParserBase<Traits>* parser, void SetParserFlags(i::ParserBase<Traits>* parser,
i::EnumSet<ParserFlag> flags) { i::EnumSet<ParserFlag> flags) {
parser->set_allow_lazy(flags.Contains(kAllowLazy));
parser->set_allow_natives(flags.Contains(kAllowNatives)); parser->set_allow_natives(flags.Contains(kAllowNatives));
parser->set_allow_harmony_function_sent( parser->set_allow_harmony_function_sent(
flags.Contains(kAllowHarmonyFunctionSent)); flags.Contains(kAllowHarmonyFunctionSent));
...@@ -1350,6 +1343,7 @@ void TestParserSyncWithFlags(i::Handle<i::String> source, ...@@ -1350,6 +1343,7 @@ void TestParserSyncWithFlags(i::Handle<i::String> source,
i::Handle<i::Script> script = factory->NewScript(source); i::Handle<i::Script> script = factory->NewScript(source);
i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME); i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME);
i::ParseInfo info(&zone, script); i::ParseInfo info(&zone, script);
info.set_allow_lazy_parsing(flags.Contains(kAllowLazy));
i::Parser parser(&info); i::Parser parser(&info);
SetParserFlags(&parser, flags); SetParserFlags(&parser, flags);
if (is_module) info.set_module(); if (is_module) info.set_module();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment