Inline the ParseInfo structure as parameters to the Parser constructor.
R=mstarzinger@chromium.org BUG= Review URL: https://codereview.chromium.org/913183005 Cr-Commit-Position: refs/heads/master@{#26606}
This commit is contained in:
parent
bd61a85faf
commit
d9790bc7ed
@ -45,13 +45,14 @@ void BackgroundParsingTask::Run() {
|
||||
source_->info->SetCachedData(&script_data, options_);
|
||||
}
|
||||
|
||||
uintptr_t limit = reinterpret_cast<uintptr_t>(&limit) - stack_size_ * KB;
|
||||
Parser::ParseInfo parse_info = {limit, source_->hash_seed,
|
||||
&source_->unicode_cache};
|
||||
uintptr_t stack_limit =
|
||||
reinterpret_cast<uintptr_t>(&stack_limit) - stack_size_ * KB;
|
||||
|
||||
// Parser needs to stay alive for finalizing the parsing on the main
|
||||
// thread. Passing &parse_info is OK because Parser doesn't store it.
|
||||
source_->parser.Reset(new Parser(source_->info.get(), &parse_info));
|
||||
source_->parser.Reset(new Parser(source_->info.get(), stack_limit,
|
||||
source_->hash_seed,
|
||||
&source_->unicode_cache));
|
||||
source_->parser->set_allow_lazy(source_->allow_lazy);
|
||||
source_->parser->ParseOnBackground();
|
||||
|
||||
|
@ -788,11 +788,12 @@ ClassLiteral* ParserTraits::ParseClassLiteral(
|
||||
}
|
||||
|
||||
|
||||
Parser::Parser(CompilationInfo* info, ParseInfo* parse_info)
|
||||
Parser::Parser(CompilationInfo* info, uintptr_t stack_limit, uint32_t hash_seed,
|
||||
UnicodeCache* unicode_cache)
|
||||
: ParserBase<ParserTraits>(info->isolate(), info->zone(), &scanner_,
|
||||
parse_info->stack_limit, info->extension(),
|
||||
stack_limit, info->extension(),
|
||||
info->ast_value_factory(), NULL, this),
|
||||
scanner_(parse_info->unicode_cache),
|
||||
scanner_(unicode_cache),
|
||||
reusable_preparser_(NULL),
|
||||
original_scope_(NULL),
|
||||
target_stack_(NULL),
|
||||
@ -827,8 +828,7 @@ Parser::Parser(CompilationInfo* info, ParseInfo* parse_info)
|
||||
}
|
||||
if (info->ast_value_factory() == NULL) {
|
||||
// info takes ownership of AstValueFactory.
|
||||
info->SetAstValueFactory(
|
||||
new AstValueFactory(zone(), parse_info->hash_seed));
|
||||
info->SetAstValueFactory(new AstValueFactory(zone(), hash_seed));
|
||||
ast_value_factory_ = info->ast_value_factory();
|
||||
}
|
||||
}
|
||||
@ -5251,6 +5251,19 @@ bool RegExpParser::ParseRegExp(Isolate* isolate, Zone* zone,
|
||||
}
|
||||
|
||||
|
||||
bool Parser::Parse(CompilationInfo* info, bool allow_lazy) {
|
||||
Parser parser(info, info->isolate()->stack_guard()->real_climit(),
|
||||
info->isolate()->heap()->HashSeed(),
|
||||
info->isolate()->unicode_cache());
|
||||
parser.set_allow_lazy(allow_lazy);
|
||||
if (parser.Parse()) {
|
||||
info->SetLanguageMode(info->function()->language_mode());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool Parser::Parse() {
|
||||
DCHECK(info()->function() == NULL);
|
||||
FunctionLiteral* result = NULL;
|
||||
|
26
src/parser.h
26
src/parser.h
@ -635,16 +635,8 @@ class ParserTraits {
|
||||
|
||||
class Parser : public ParserBase<ParserTraits> {
|
||||
public:
|
||||
// Note that the hash seed in ParseInfo must be the hash seed from the
|
||||
// Isolate's heap, otherwise the heap will be in an inconsistent state once
|
||||
// the strings created by the Parser are internalized.
|
||||
struct ParseInfo {
|
||||
uintptr_t stack_limit;
|
||||
uint32_t hash_seed;
|
||||
UnicodeCache* unicode_cache;
|
||||
};
|
||||
|
||||
Parser(CompilationInfo* info, ParseInfo* parse_info);
|
||||
Parser(CompilationInfo* info, uintptr_t stack_limit, uint32_t hash_seed,
|
||||
UnicodeCache* unicode_cache);
|
||||
~Parser() {
|
||||
delete reusable_preparser_;
|
||||
reusable_preparser_ = NULL;
|
||||
@ -655,19 +647,7 @@ class Parser : public ParserBase<ParserTraits> {
|
||||
// Parses the source code represented by the compilation info and sets its
|
||||
// function literal. Returns false (and deallocates any allocated AST
|
||||
// nodes) if parsing failed.
|
||||
static bool Parse(CompilationInfo* info,
|
||||
bool allow_lazy = false) {
|
||||
ParseInfo parse_info = {info->isolate()->stack_guard()->real_climit(),
|
||||
info->isolate()->heap()->HashSeed(),
|
||||
info->isolate()->unicode_cache()};
|
||||
Parser parser(info, &parse_info);
|
||||
parser.set_allow_lazy(allow_lazy);
|
||||
if (parser.Parse()) {
|
||||
info->SetLanguageMode(info->function()->language_mode());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
static bool Parse(CompilationInfo* info, bool allow_lazy = false);
|
||||
bool Parse();
|
||||
void ParseOnBackground();
|
||||
|
||||
|
@ -1054,10 +1054,8 @@ TEST(ScopeUsesArgumentsSuperThis) {
|
||||
.ToHandleChecked();
|
||||
i::Handle<i::Script> script = factory->NewScript(source);
|
||||
i::CompilationInfoWithZone info(script);
|
||||
i::Parser::ParseInfo parse_info = {isolate->stack_guard()->real_climit(),
|
||||
isolate->heap()->HashSeed(),
|
||||
isolate->unicode_cache()};
|
||||
i::Parser parser(&info, &parse_info);
|
||||
i::Parser parser(&info, isolate->stack_guard()->real_climit(),
|
||||
isolate->heap()->HashSeed(), isolate->unicode_cache());
|
||||
parser.set_allow_harmony_arrow_functions(true);
|
||||
parser.set_allow_harmony_classes(true);
|
||||
parser.set_allow_harmony_object_literals(true);
|
||||
@ -1312,10 +1310,8 @@ TEST(ScopePositions) {
|
||||
CHECK_EQ(source->length(), kProgramSize);
|
||||
i::Handle<i::Script> script = factory->NewScript(source);
|
||||
i::CompilationInfoWithZone info(script);
|
||||
i::Parser::ParseInfo parse_info = {isolate->stack_guard()->real_climit(),
|
||||
isolate->heap()->HashSeed(),
|
||||
isolate->unicode_cache()};
|
||||
i::Parser parser(&info, &parse_info);
|
||||
i::Parser parser(&info, isolate->stack_guard()->real_climit(),
|
||||
isolate->heap()->HashSeed(), isolate->unicode_cache());
|
||||
parser.set_allow_lazy(true);
|
||||
parser.set_allow_harmony_scoping(true);
|
||||
parser.set_allow_harmony_arrow_functions(true);
|
||||
@ -1473,10 +1469,8 @@ void TestParserSyncWithFlags(i::Handle<i::String> source,
|
||||
{
|
||||
i::Handle<i::Script> script = factory->NewScript(source);
|
||||
i::CompilationInfoWithZone info(script);
|
||||
i::Parser::ParseInfo parse_info = {isolate->stack_guard()->real_climit(),
|
||||
isolate->heap()->HashSeed(),
|
||||
isolate->unicode_cache()};
|
||||
i::Parser parser(&info, &parse_info);
|
||||
i::Parser parser(&info, isolate->stack_guard()->real_climit(),
|
||||
isolate->heap()->HashSeed(), isolate->unicode_cache());
|
||||
SetParserFlags(&parser, flags);
|
||||
info.MarkAsGlobal();
|
||||
parser.Parse();
|
||||
@ -3439,10 +3433,9 @@ TEST(InnerAssignment) {
|
||||
|
||||
i::Handle<i::Script> script = factory->NewScript(source);
|
||||
i::CompilationInfoWithZone info(script);
|
||||
i::Parser::ParseInfo parse_info = {
|
||||
isolate->stack_guard()->real_climit(),
|
||||
isolate->heap()->HashSeed(), isolate->unicode_cache()};
|
||||
i::Parser parser(&info, &parse_info);
|
||||
i::Parser parser(&info, isolate->stack_guard()->real_climit(),
|
||||
isolate->heap()->HashSeed(),
|
||||
isolate->unicode_cache());
|
||||
parser.set_allow_harmony_scoping(true);
|
||||
CHECK(parser.Parse());
|
||||
CHECK(i::Compiler::Analyze(&info));
|
||||
@ -5052,10 +5045,8 @@ TEST(BasicImportExportParsing) {
|
||||
{
|
||||
i::Handle<i::Script> script = factory->NewScript(source);
|
||||
i::CompilationInfoWithZone info(script);
|
||||
i::Parser::ParseInfo parse_info = {isolate->stack_guard()->real_climit(),
|
||||
isolate->heap()->HashSeed(),
|
||||
isolate->unicode_cache()};
|
||||
i::Parser parser(&info, &parse_info);
|
||||
i::Parser parser(&info, isolate->stack_guard()->real_climit(),
|
||||
isolate->heap()->HashSeed(), isolate->unicode_cache());
|
||||
parser.set_allow_harmony_classes(true);
|
||||
parser.set_allow_harmony_modules(true);
|
||||
parser.set_allow_harmony_scoping(true);
|
||||
@ -5082,10 +5073,8 @@ TEST(BasicImportExportParsing) {
|
||||
{
|
||||
i::Handle<i::Script> script = factory->NewScript(source);
|
||||
i::CompilationInfoWithZone info(script);
|
||||
i::Parser::ParseInfo parse_info = {isolate->stack_guard()->real_climit(),
|
||||
isolate->heap()->HashSeed(),
|
||||
isolate->unicode_cache()};
|
||||
i::Parser parser(&info, &parse_info);
|
||||
i::Parser parser(&info, isolate->stack_guard()->real_climit(),
|
||||
isolate->heap()->HashSeed(), isolate->unicode_cache());
|
||||
parser.set_allow_harmony_classes(true);
|
||||
parser.set_allow_harmony_modules(true);
|
||||
parser.set_allow_harmony_scoping(true);
|
||||
@ -5174,10 +5163,8 @@ TEST(ImportExportParsingErrors) {
|
||||
|
||||
i::Handle<i::Script> script = factory->NewScript(source);
|
||||
i::CompilationInfoWithZone info(script);
|
||||
i::Parser::ParseInfo parse_info = {isolate->stack_guard()->real_climit(),
|
||||
isolate->heap()->HashSeed(),
|
||||
isolate->unicode_cache()};
|
||||
i::Parser parser(&info, &parse_info);
|
||||
i::Parser parser(&info, isolate->stack_guard()->real_climit(),
|
||||
isolate->heap()->HashSeed(), isolate->unicode_cache());
|
||||
parser.set_allow_harmony_classes(true);
|
||||
parser.set_allow_harmony_modules(true);
|
||||
parser.set_allow_harmony_scoping(true);
|
||||
@ -5270,10 +5257,8 @@ void TestLanguageMode(const char* source,
|
||||
i::Handle<i::Script> script =
|
||||
factory->NewScript(factory->NewStringFromAsciiChecked(source));
|
||||
i::CompilationInfoWithZone info(script);
|
||||
i::Parser::ParseInfo parse_info = {isolate->stack_guard()->real_climit(),
|
||||
isolate->heap()->HashSeed(),
|
||||
isolate->unicode_cache()};
|
||||
i::Parser parser(&info, &parse_info);
|
||||
i::Parser parser(&info, isolate->stack_guard()->real_climit(),
|
||||
isolate->heap()->HashSeed(), isolate->unicode_cache());
|
||||
parser.set_allow_strong_mode(true);
|
||||
info.MarkAsGlobal();
|
||||
parser.Parse();
|
||||
|
Loading…
Reference in New Issue
Block a user