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}
This commit is contained in:
verwaest 2016-11-16 04:40:16 -08:00 committed by Commit bot
parent d49cd5307b
commit feb787714c
4 changed files with 12 additions and 22 deletions

View File

@ -207,7 +207,6 @@ class ParserBase {
scanner_(scanner),
stack_overflow_(false),
default_eager_compile_hint_(FunctionLiteral::kShouldLazyCompile),
allow_lazy_(false),
allow_natives_(false),
allow_tailcalls_(false),
allow_harmony_do_expressions_(false),
@ -221,7 +220,6 @@ class ParserBase {
bool allow_##name() const { return allow_##name##_; } \
void set_allow_##name(bool allow) { allow_##name##_ = allow; }
ALLOW_ACCESSORS(lazy);
ALLOW_ACCESSORS(natives);
ALLOW_ACCESSORS(tailcalls);
ALLOW_ACCESSORS(harmony_do_expressions);
@ -1437,7 +1435,6 @@ class ParserBase {
FunctionLiteral::EagerCompileHint default_eager_compile_hint_;
bool allow_lazy_;
bool allow_natives_;
bool allow_tailcalls_;
bool allow_harmony_do_expressions_;

View File

@ -615,9 +615,8 @@ Parser::Parser(ParseInfo* info)
set_default_eager_compile_hint(can_compile_lazily
? FunctionLiteral::kShouldLazyCompile
: FunctionLiteral::kShouldEagerCompile);
set_allow_lazy(FLAG_lazy && info->allow_lazy_parsing() &&
!info->is_native() && info->extension() == nullptr &&
can_compile_lazily);
allow_lazy_ = FLAG_lazy && info->allow_lazy_parsing() && !info->is_native() &&
info->extension() == nullptr && can_compile_lazily;
set_allow_natives(FLAG_allow_natives_syntax || info->is_native());
set_allow_tailcalls(FLAG_harmony_tailcalls && !info->is_native() &&
info->isolate()->is_tail_call_elimination_enabled());
@ -730,7 +729,7 @@ FunctionLiteral* Parser::DoParseProgram(ParseInfo* info) {
DCHECK_NULL(scope_state_);
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;
{
@ -2569,7 +2568,7 @@ FunctionLiteral* Parser::ParseFunctionLiteral(
// immediately). bar can be parsed lazily, but we need to parse it in a mode
// that tracks unresolved variables.
DCHECK_IMPLIES(parse_lazily(), FLAG_lazy);
DCHECK_IMPLIES(parse_lazily(), allow_lazy());
DCHECK_IMPLIES(parse_lazily(), allow_lazy_);
DCHECK_IMPLIES(parse_lazily(), extension_ == nullptr);
bool can_preparse = parse_lazily() &&
@ -2604,7 +2603,7 @@ FunctionLiteral* Parser::ParseFunctionLiteral(
(FLAG_lazy_inner_functions
? can_preparse
: (is_lazy_top_level_function ||
(allow_lazy() && function_type == FunctionLiteral::kDeclaration &&
(allow_lazy_ && function_type == FunctionLiteral::kDeclaration &&
eager_compile_hint == FunctionLiteral::kShouldLazyCompile))) &&
!(FLAG_validate_asm && scope()->IsAsmModule());
bool is_lazy_inner_function =
@ -2791,7 +2790,6 @@ Parser::LazyParsingResult Parser::SkipFunction(
reusable_preparser_ = new PreParser(zone(), &scanner_, ast_value_factory(),
&pending_error_handler_,
runtime_call_stats_, stack_limit_);
reusable_preparser_->set_allow_lazy(true);
#define SET_ALLOW(name) reusable_preparser_->set_allow_##name(allow_##name());
SET_ALLOW(natives);
SET_ALLOW(harmony_do_expressions);
@ -3160,7 +3158,7 @@ ZoneList<Statement*>* Parser::ParseEagerFunctionBody(
const AstRawString* function_name, int pos,
const ParserFormalParameters& parameters, FunctionKind kind,
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());
static const int kFunctionNameAssignmentIndex = 0;

View File

@ -290,11 +290,11 @@ class V8_EXPORT_PRIVATE Parser : public NON_EXPORTED_BASE(ParserBase<Parser>) {
return compile_options_;
}
bool consume_cached_parse_data() const {
return allow_lazy() &&
return allow_lazy_ &&
compile_options_ == ScriptCompiler::kConsumeParserCache;
}
bool produce_cached_parse_data() const {
return allow_lazy() &&
return allow_lazy_ &&
compile_options_ == ScriptCompiler::kProduceParserCache;
}
@ -1146,6 +1146,7 @@ class V8_EXPORT_PRIVATE Parser : public NON_EXPORTED_BASE(ParserBase<Parser>) {
int use_counts_[v8::Isolate::kUseCounterFeatureCount];
int total_preparse_skipped_;
bool parsing_on_main_thread_;
bool allow_lazy_;
ParserLogger* log_;
};

View File

@ -177,7 +177,6 @@ TEST(ScanHTMLEndComments) {
i::PreParser preparser(
&zone, &scanner, &ast_value_factory, &pending_error_handler,
CcTest::i_isolate()->counters()->runtime_call_stats(), stack_limit);
preparser.set_allow_lazy(true);
i::PreParser::PreParseResult result = preparser.PreParseProgram();
CHECK_EQ(i::PreParser::kPreParseSuccess, result);
CHECK(!pending_error_handler.has_pending_error());
@ -195,7 +194,6 @@ TEST(ScanHTMLEndComments) {
i::PreParser preparser(
&zone, &scanner, &ast_value_factory, &pending_error_handler,
CcTest::i_isolate()->counters()->runtime_call_stats(), stack_limit);
preparser.set_allow_lazy(true);
i::PreParser::PreParseResult result = preparser.PreParseProgram();
// Even in the case of a syntax error, kPreParseSuccess is returned.
CHECK_EQ(i::PreParser::kPreParseSuccess, result);
@ -370,7 +368,6 @@ TEST(StandAlonePreParser) {
i::PreParser preparser(
&zone, &scanner, &ast_value_factory, &pending_error_handler,
CcTest::i_isolate()->counters()->runtime_call_stats(), stack_limit);
preparser.set_allow_lazy(true);
preparser.set_allow_natives(true);
i::PreParser::PreParseResult result = preparser.PreParseProgram();
CHECK_EQ(i::PreParser::kPreParseSuccess, result);
@ -406,7 +403,6 @@ TEST(StandAlonePreParserNoNatives) {
i::PreParser preparser(
&zone, &scanner, &ast_value_factory, &pending_error_handler,
isolate->counters()->runtime_call_stats(), stack_limit);
preparser.set_allow_lazy(true);
i::PreParser::PreParseResult result = preparser.PreParseProgram();
CHECK_EQ(i::PreParser::kPreParseSuccess, result);
CHECK(pending_error_handler.has_pending_error());
@ -475,7 +471,6 @@ TEST(RegressChromium62639) {
&pending_error_handler,
isolate->counters()->runtime_call_stats(),
CcTest::i_isolate()->stack_guard()->real_climit());
preparser.set_allow_lazy(true);
i::PreParser::PreParseResult result = preparser.PreParseProgram();
// Even in the case of a syntax error, kPreParseSuccess is returned.
CHECK_EQ(i::PreParser::kPreParseSuccess, result);
@ -551,7 +546,6 @@ TEST(PreParseOverflow) {
i::PreParser preparser(
&zone, &scanner, &ast_value_factory, &pending_error_handler,
isolate->counters()->runtime_call_stats(), stack_limit);
preparser.set_allow_lazy(true);
i::PreParser::PreParseResult result = preparser.PreParseProgram();
CHECK_EQ(i::PreParser::kPreParseStackOverflow, result);
}
@ -1180,10 +1174,10 @@ TEST(ScopePositions) {
i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME);
i::ParseInfo info(&zone, script);
i::Parser parser(&info);
parser.set_allow_lazy(true);
info.set_language_mode(source_data[i].language_mode);
info.set_allow_lazy_parsing();
parser.Parse(&info);
CHECK(info.literal() != NULL);
CHECK_NOT_NULL(info.literal());
// Check scope types and positions.
i::Scope* scope = info.literal()->scope();
@ -1298,7 +1292,6 @@ enum ParserSyncTestResult {
template <typename Traits>
void SetParserFlags(i::ParserBase<Traits>* parser,
i::EnumSet<ParserFlag> flags) {
parser->set_allow_lazy(flags.Contains(kAllowLazy));
parser->set_allow_natives(flags.Contains(kAllowNatives));
parser->set_allow_harmony_function_sent(
flags.Contains(kAllowHarmonyFunctionSent));
@ -1350,6 +1343,7 @@ void TestParserSyncWithFlags(i::Handle<i::String> source,
i::Handle<i::Script> script = factory->NewScript(source);
i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME);
i::ParseInfo info(&zone, script);
info.set_allow_lazy_parsing(flags.Contains(kAllowLazy));
i::Parser parser(&info);
SetParserFlags(&parser, flags);
if (is_module) info.set_module();