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_);
|
source_->info->SetCachedData(&script_data, options_);
|
||||||
}
|
}
|
||||||
|
|
||||||
uintptr_t limit = reinterpret_cast<uintptr_t>(&limit) - stack_size_ * KB;
|
uintptr_t stack_limit =
|
||||||
Parser::ParseInfo parse_info = {limit, source_->hash_seed,
|
reinterpret_cast<uintptr_t>(&stack_limit) - stack_size_ * KB;
|
||||||
&source_->unicode_cache};
|
|
||||||
|
|
||||||
// Parser needs to stay alive for finalizing the parsing on the main
|
// Parser needs to stay alive for finalizing the parsing on the main
|
||||||
// thread. Passing &parse_info is OK because Parser doesn't store it.
|
// 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->set_allow_lazy(source_->allow_lazy);
|
||||||
source_->parser->ParseOnBackground();
|
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_,
|
: ParserBase<ParserTraits>(info->isolate(), info->zone(), &scanner_,
|
||||||
parse_info->stack_limit, info->extension(),
|
stack_limit, info->extension(),
|
||||||
info->ast_value_factory(), NULL, this),
|
info->ast_value_factory(), NULL, this),
|
||||||
scanner_(parse_info->unicode_cache),
|
scanner_(unicode_cache),
|
||||||
reusable_preparser_(NULL),
|
reusable_preparser_(NULL),
|
||||||
original_scope_(NULL),
|
original_scope_(NULL),
|
||||||
target_stack_(NULL),
|
target_stack_(NULL),
|
||||||
@ -827,8 +828,7 @@ Parser::Parser(CompilationInfo* info, ParseInfo* parse_info)
|
|||||||
}
|
}
|
||||||
if (info->ast_value_factory() == NULL) {
|
if (info->ast_value_factory() == NULL) {
|
||||||
// info takes ownership of AstValueFactory.
|
// info takes ownership of AstValueFactory.
|
||||||
info->SetAstValueFactory(
|
info->SetAstValueFactory(new AstValueFactory(zone(), hash_seed));
|
||||||
new AstValueFactory(zone(), parse_info->hash_seed));
|
|
||||||
ast_value_factory_ = info->ast_value_factory();
|
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() {
|
bool Parser::Parse() {
|
||||||
DCHECK(info()->function() == NULL);
|
DCHECK(info()->function() == NULL);
|
||||||
FunctionLiteral* result = NULL;
|
FunctionLiteral* result = NULL;
|
||||||
|
26
src/parser.h
26
src/parser.h
@ -635,16 +635,8 @@ class ParserTraits {
|
|||||||
|
|
||||||
class Parser : public ParserBase<ParserTraits> {
|
class Parser : public ParserBase<ParserTraits> {
|
||||||
public:
|
public:
|
||||||
// Note that the hash seed in ParseInfo must be the hash seed from the
|
Parser(CompilationInfo* info, uintptr_t stack_limit, uint32_t hash_seed,
|
||||||
// Isolate's heap, otherwise the heap will be in an inconsistent state once
|
UnicodeCache* unicode_cache);
|
||||||
// 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() {
|
~Parser() {
|
||||||
delete reusable_preparser_;
|
delete reusable_preparser_;
|
||||||
reusable_preparser_ = NULL;
|
reusable_preparser_ = NULL;
|
||||||
@ -655,19 +647,7 @@ class Parser : public ParserBase<ParserTraits> {
|
|||||||
// Parses the source code represented by the compilation info and sets its
|
// Parses the source code represented by the compilation info and sets its
|
||||||
// function literal. Returns false (and deallocates any allocated AST
|
// function literal. Returns false (and deallocates any allocated AST
|
||||||
// nodes) if parsing failed.
|
// nodes) if parsing failed.
|
||||||
static bool Parse(CompilationInfo* info,
|
static bool Parse(CompilationInfo* info, bool allow_lazy = false);
|
||||||
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;
|
|
||||||
}
|
|
||||||
bool Parse();
|
bool Parse();
|
||||||
void ParseOnBackground();
|
void ParseOnBackground();
|
||||||
|
|
||||||
|
@ -1054,10 +1054,8 @@ TEST(ScopeUsesArgumentsSuperThis) {
|
|||||||
.ToHandleChecked();
|
.ToHandleChecked();
|
||||||
i::Handle<i::Script> script = factory->NewScript(source);
|
i::Handle<i::Script> script = factory->NewScript(source);
|
||||||
i::CompilationInfoWithZone info(script);
|
i::CompilationInfoWithZone info(script);
|
||||||
i::Parser::ParseInfo parse_info = {isolate->stack_guard()->real_climit(),
|
i::Parser parser(&info, isolate->stack_guard()->real_climit(),
|
||||||
isolate->heap()->HashSeed(),
|
isolate->heap()->HashSeed(), isolate->unicode_cache());
|
||||||
isolate->unicode_cache()};
|
|
||||||
i::Parser parser(&info, &parse_info);
|
|
||||||
parser.set_allow_harmony_arrow_functions(true);
|
parser.set_allow_harmony_arrow_functions(true);
|
||||||
parser.set_allow_harmony_classes(true);
|
parser.set_allow_harmony_classes(true);
|
||||||
parser.set_allow_harmony_object_literals(true);
|
parser.set_allow_harmony_object_literals(true);
|
||||||
@ -1312,10 +1310,8 @@ TEST(ScopePositions) {
|
|||||||
CHECK_EQ(source->length(), kProgramSize);
|
CHECK_EQ(source->length(), kProgramSize);
|
||||||
i::Handle<i::Script> script = factory->NewScript(source);
|
i::Handle<i::Script> script = factory->NewScript(source);
|
||||||
i::CompilationInfoWithZone info(script);
|
i::CompilationInfoWithZone info(script);
|
||||||
i::Parser::ParseInfo parse_info = {isolate->stack_guard()->real_climit(),
|
i::Parser parser(&info, isolate->stack_guard()->real_climit(),
|
||||||
isolate->heap()->HashSeed(),
|
isolate->heap()->HashSeed(), isolate->unicode_cache());
|
||||||
isolate->unicode_cache()};
|
|
||||||
i::Parser parser(&info, &parse_info);
|
|
||||||
parser.set_allow_lazy(true);
|
parser.set_allow_lazy(true);
|
||||||
parser.set_allow_harmony_scoping(true);
|
parser.set_allow_harmony_scoping(true);
|
||||||
parser.set_allow_harmony_arrow_functions(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::Handle<i::Script> script = factory->NewScript(source);
|
||||||
i::CompilationInfoWithZone info(script);
|
i::CompilationInfoWithZone info(script);
|
||||||
i::Parser::ParseInfo parse_info = {isolate->stack_guard()->real_climit(),
|
i::Parser parser(&info, isolate->stack_guard()->real_climit(),
|
||||||
isolate->heap()->HashSeed(),
|
isolate->heap()->HashSeed(), isolate->unicode_cache());
|
||||||
isolate->unicode_cache()};
|
|
||||||
i::Parser parser(&info, &parse_info);
|
|
||||||
SetParserFlags(&parser, flags);
|
SetParserFlags(&parser, flags);
|
||||||
info.MarkAsGlobal();
|
info.MarkAsGlobal();
|
||||||
parser.Parse();
|
parser.Parse();
|
||||||
@ -3439,10 +3433,9 @@ TEST(InnerAssignment) {
|
|||||||
|
|
||||||
i::Handle<i::Script> script = factory->NewScript(source);
|
i::Handle<i::Script> script = factory->NewScript(source);
|
||||||
i::CompilationInfoWithZone info(script);
|
i::CompilationInfoWithZone info(script);
|
||||||
i::Parser::ParseInfo parse_info = {
|
i::Parser parser(&info, isolate->stack_guard()->real_climit(),
|
||||||
isolate->stack_guard()->real_climit(),
|
isolate->heap()->HashSeed(),
|
||||||
isolate->heap()->HashSeed(), isolate->unicode_cache()};
|
isolate->unicode_cache());
|
||||||
i::Parser parser(&info, &parse_info);
|
|
||||||
parser.set_allow_harmony_scoping(true);
|
parser.set_allow_harmony_scoping(true);
|
||||||
CHECK(parser.Parse());
|
CHECK(parser.Parse());
|
||||||
CHECK(i::Compiler::Analyze(&info));
|
CHECK(i::Compiler::Analyze(&info));
|
||||||
@ -5052,10 +5045,8 @@ TEST(BasicImportExportParsing) {
|
|||||||
{
|
{
|
||||||
i::Handle<i::Script> script = factory->NewScript(source);
|
i::Handle<i::Script> script = factory->NewScript(source);
|
||||||
i::CompilationInfoWithZone info(script);
|
i::CompilationInfoWithZone info(script);
|
||||||
i::Parser::ParseInfo parse_info = {isolate->stack_guard()->real_climit(),
|
i::Parser parser(&info, isolate->stack_guard()->real_climit(),
|
||||||
isolate->heap()->HashSeed(),
|
isolate->heap()->HashSeed(), isolate->unicode_cache());
|
||||||
isolate->unicode_cache()};
|
|
||||||
i::Parser parser(&info, &parse_info);
|
|
||||||
parser.set_allow_harmony_classes(true);
|
parser.set_allow_harmony_classes(true);
|
||||||
parser.set_allow_harmony_modules(true);
|
parser.set_allow_harmony_modules(true);
|
||||||
parser.set_allow_harmony_scoping(true);
|
parser.set_allow_harmony_scoping(true);
|
||||||
@ -5082,10 +5073,8 @@ TEST(BasicImportExportParsing) {
|
|||||||
{
|
{
|
||||||
i::Handle<i::Script> script = factory->NewScript(source);
|
i::Handle<i::Script> script = factory->NewScript(source);
|
||||||
i::CompilationInfoWithZone info(script);
|
i::CompilationInfoWithZone info(script);
|
||||||
i::Parser::ParseInfo parse_info = {isolate->stack_guard()->real_climit(),
|
i::Parser parser(&info, isolate->stack_guard()->real_climit(),
|
||||||
isolate->heap()->HashSeed(),
|
isolate->heap()->HashSeed(), isolate->unicode_cache());
|
||||||
isolate->unicode_cache()};
|
|
||||||
i::Parser parser(&info, &parse_info);
|
|
||||||
parser.set_allow_harmony_classes(true);
|
parser.set_allow_harmony_classes(true);
|
||||||
parser.set_allow_harmony_modules(true);
|
parser.set_allow_harmony_modules(true);
|
||||||
parser.set_allow_harmony_scoping(true);
|
parser.set_allow_harmony_scoping(true);
|
||||||
@ -5174,10 +5163,8 @@ TEST(ImportExportParsingErrors) {
|
|||||||
|
|
||||||
i::Handle<i::Script> script = factory->NewScript(source);
|
i::Handle<i::Script> script = factory->NewScript(source);
|
||||||
i::CompilationInfoWithZone info(script);
|
i::CompilationInfoWithZone info(script);
|
||||||
i::Parser::ParseInfo parse_info = {isolate->stack_guard()->real_climit(),
|
i::Parser parser(&info, isolate->stack_guard()->real_climit(),
|
||||||
isolate->heap()->HashSeed(),
|
isolate->heap()->HashSeed(), isolate->unicode_cache());
|
||||||
isolate->unicode_cache()};
|
|
||||||
i::Parser parser(&info, &parse_info);
|
|
||||||
parser.set_allow_harmony_classes(true);
|
parser.set_allow_harmony_classes(true);
|
||||||
parser.set_allow_harmony_modules(true);
|
parser.set_allow_harmony_modules(true);
|
||||||
parser.set_allow_harmony_scoping(true);
|
parser.set_allow_harmony_scoping(true);
|
||||||
@ -5270,10 +5257,8 @@ void TestLanguageMode(const char* source,
|
|||||||
i::Handle<i::Script> script =
|
i::Handle<i::Script> script =
|
||||||
factory->NewScript(factory->NewStringFromAsciiChecked(source));
|
factory->NewScript(factory->NewStringFromAsciiChecked(source));
|
||||||
i::CompilationInfoWithZone info(script);
|
i::CompilationInfoWithZone info(script);
|
||||||
i::Parser::ParseInfo parse_info = {isolate->stack_guard()->real_climit(),
|
i::Parser parser(&info, isolate->stack_guard()->real_climit(),
|
||||||
isolate->heap()->HashSeed(),
|
isolate->heap()->HashSeed(), isolate->unicode_cache());
|
||||||
isolate->unicode_cache()};
|
|
||||||
i::Parser parser(&info, &parse_info);
|
|
||||||
parser.set_allow_strong_mode(true);
|
parser.set_allow_strong_mode(true);
|
||||||
info.MarkAsGlobal();
|
info.MarkAsGlobal();
|
||||||
parser.Parse();
|
parser.Parse();
|
||||||
|
Loading…
Reference in New Issue
Block a user