From 5c56665059891cbacf43f6efe483582029442f0b Mon Sep 17 00:00:00 2001 From: marja Date: Fri, 6 Feb 2015 07:58:36 -0800 Subject: [PATCH] PreParser / Parser consistency: Make PreParser aware of Zone and AstValueFactory. Previously it just had hacks to have NULLs instead of them and pretended to know nothing about Zone. The hacks provide no real benefit (probably historically based on some weird misconception about the relationship between Zone and Isolate), and make it harder for the PreParser to start to know more about variables and scoping. BUG= Review URL: https://codereview.chromium.org/909463003 Cr-Commit-Position: refs/heads/master@{#26494} --- src/parser.cc | 11 ++++++----- src/parser.h | 10 ---------- src/preparser.h | 45 ++++++++++++++++++++---------------------- test/cctest/test-parsing.cc | 48 +++++++++++++++++++++++++++++++++++++-------- 4 files changed, 67 insertions(+), 47 deletions(-) diff --git a/src/parser.cc b/src/parser.cc index d3fde9e..78039f6 100644 --- a/src/parser.cc +++ b/src/parser.cc @@ -671,7 +671,7 @@ const AstRawString* ParserTraits::GetNumberAsSymbol(Scanner* scanner) { char array[100]; const char* string = DoubleToCString(double_value, Vector(array, arraysize(array))); - return ast_value_factory()->GetOneByteString(string); + return parser_->ast_value_factory()->GetOneByteString(string); } @@ -794,8 +794,8 @@ ClassLiteral* ParserTraits::ParseClassLiteral( Parser::Parser(CompilationInfo* info, ParseInfo* parse_info) : ParserBase(info->isolate(), info->zone(), &scanner_, - parse_info->stack_limit, info->extension(), NULL, - this), + parse_info->stack_limit, info->extension(), + info->ast_value_factory(), NULL, this), scanner_(parse_info->unicode_cache), reusable_preparser_(NULL), original_scope_(NULL), @@ -833,6 +833,7 @@ Parser::Parser(CompilationInfo* info, ParseInfo* parse_info) // info takes ownership of AstValueFactory. info->SetAstValueFactory( new AstValueFactory(zone(), parse_info->hash_seed)); + ast_value_factory_ = info->ast_value_factory(); } } @@ -4037,8 +4038,8 @@ PreParser::PreParseResult Parser::ParseLazyFunctionBodyWithPreParser( DCHECK_EQ(Token::LBRACE, scanner()->current_token()); if (reusable_preparser_ == NULL) { - reusable_preparser_ = - new PreParser(isolate(), &scanner_, NULL, stack_limit_); + reusable_preparser_ = new PreParser( + isolate(), zone(), &scanner_, ast_value_factory(), NULL, stack_limit_); reusable_preparser_->set_allow_lazy(true); reusable_preparser_->set_allow_natives(allow_natives()); reusable_preparser_->set_allow_harmony_scoping(allow_harmony_scoping()); diff --git a/src/parser.h b/src/parser.h index d1d1d7c..9c2b056 100644 --- a/src/parser.h +++ b/src/parser.h @@ -364,7 +364,6 @@ class ParserTraits { inline static Scope* ptr_to_scope(ScopePtr scope) { return scope; } typedef Variable GeneratorVariable; - typedef v8::internal::Zone Zone; typedef v8::internal::AstProperties AstProperties; typedef Vector ParameterIdentifierVector; @@ -569,7 +568,6 @@ class ParserTraits { int DeclareArrowParametersFromExpression(Expression* expression, Scope* scope, Scanner::Location* dupe_loc, bool* ok); - V8_INLINE AstValueFactory* ast_value_factory(); // Temporary glue; these functions will move to ParserBase. Expression* ParseV8Intrinsic(bool* ok); @@ -716,9 +714,6 @@ class Parser : public ParserBase { Isolate* isolate() { return info_->isolate(); } CompilationInfo* info() const { return info_; } Handle