Commit 6fef6e45 authored by sanjoy@chromium.org's avatar sanjoy@chromium.org

Unbreak bleeding_edge by getting the Parser to work with a CompilationInfo...

Unbreak bleeding_edge by getting the Parser to work with a CompilationInfo instead of a Handle<Script> and a Zone.  This should have been fixed in the initial patch itself but escaped my attention.

BUG=
TEST=

Review URL: https://chromiumcodereview.appspot.com/10583031

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@11878 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 9e4fbb45
...@@ -532,14 +532,13 @@ Parser::FunctionState::~FunctionState() { ...@@ -532,14 +532,13 @@ Parser::FunctionState::~FunctionState() {
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// Implementation of Parser // Implementation of Parser
Parser::Parser(Handle<Script> script, Parser::Parser(CompilationInfo* info,
int parser_flags, int parser_flags,
v8::Extension* extension, v8::Extension* extension,
ScriptDataImpl* pre_data, ScriptDataImpl* pre_data)
Zone* zone) : isolate_(info->isolate()),
: isolate_(script->GetIsolate()), symbol_cache_(pre_data ? pre_data->symbol_count() : 0, info->zone()),
symbol_cache_(pre_data ? pre_data->symbol_count() : 0, zone), script_(info->script()),
script_(script),
scanner_(isolate_->unicode_cache()), scanner_(isolate_->unicode_cache()),
reusable_preparser_(NULL), reusable_preparser_(NULL),
top_scope_(NULL), top_scope_(NULL),
...@@ -553,7 +552,9 @@ Parser::Parser(Handle<Script> script, ...@@ -553,7 +552,9 @@ Parser::Parser(Handle<Script> script,
allow_modules_((parser_flags & kAllowModules) != 0), allow_modules_((parser_flags & kAllowModules) != 0),
stack_overflow_(false), stack_overflow_(false),
parenthesized_function_(false), parenthesized_function_(false),
zone_(zone) { zone_(info->zone()),
info_(info) {
ASSERT(!script_.is_null());
isolate_->set_ast_node_id(0); isolate_->set_ast_node_id(0);
if ((parser_flags & kLanguageModeMask) == EXTENDED_MODE) { if ((parser_flags & kLanguageModeMask) == EXTENDED_MODE) {
scanner().SetHarmonyScoping(true); scanner().SetHarmonyScoping(true);
...@@ -564,8 +565,8 @@ Parser::Parser(Handle<Script> script, ...@@ -564,8 +565,8 @@ Parser::Parser(Handle<Script> script,
} }
FunctionLiteral* Parser::ParseProgram(CompilationInfo* info) { FunctionLiteral* Parser::ParseProgram() {
ZoneScope zone_scope(info->zone(), DONT_DELETE_ON_EXIT); ZoneScope zone_scope(zone(), DONT_DELETE_ON_EXIT);
HistogramTimerScope timer(isolate()->counters()->parse()); HistogramTimerScope timer(isolate()->counters()->parse());
Handle<String> source(String::cast(script_->source())); Handle<String> source(String::cast(script_->source()));
...@@ -581,11 +582,11 @@ FunctionLiteral* Parser::ParseProgram(CompilationInfo* info) { ...@@ -581,11 +582,11 @@ FunctionLiteral* Parser::ParseProgram(CompilationInfo* info) {
ExternalTwoByteStringUtf16CharacterStream stream( ExternalTwoByteStringUtf16CharacterStream stream(
Handle<ExternalTwoByteString>::cast(source), 0, source->length()); Handle<ExternalTwoByteString>::cast(source), 0, source->length());
scanner_.Initialize(&stream); scanner_.Initialize(&stream);
return DoParseProgram(info, source, &zone_scope); return DoParseProgram(info(), source, &zone_scope);
} else { } else {
GenericStringUtf16CharacterStream stream(source, 0, source->length()); GenericStringUtf16CharacterStream stream(source, 0, source->length());
scanner_.Initialize(&stream); scanner_.Initialize(&stream);
return DoParseProgram(info, source, &zone_scope); return DoParseProgram(info(), source, &zone_scope);
} }
} }
...@@ -662,13 +663,13 @@ FunctionLiteral* Parser::DoParseProgram(CompilationInfo* info, ...@@ -662,13 +663,13 @@ FunctionLiteral* Parser::DoParseProgram(CompilationInfo* info,
} }
FunctionLiteral* Parser::ParseLazy(CompilationInfo* info) { FunctionLiteral* Parser::ParseLazy() {
ZoneScope zone_scope(info->zone(), DONT_DELETE_ON_EXIT); ZoneScope zone_scope(zone(), DONT_DELETE_ON_EXIT);
HistogramTimerScope timer(isolate()->counters()->parse_lazy()); HistogramTimerScope timer(isolate()->counters()->parse_lazy());
Handle<String> source(String::cast(script_->source())); Handle<String> source(String::cast(script_->source()));
isolate()->counters()->total_parse_size()->Increment(source->length()); isolate()->counters()->total_parse_size()->Increment(source->length());
Handle<SharedFunctionInfo> shared_info = info->shared_info(); Handle<SharedFunctionInfo> shared_info = info()->shared_info();
// Initialize parser state. // Initialize parser state.
source->TryFlatten(); source->TryFlatten();
if (source->IsExternalTwoByteString()) { if (source->IsExternalTwoByteString()) {
...@@ -676,22 +677,21 @@ FunctionLiteral* Parser::ParseLazy(CompilationInfo* info) { ...@@ -676,22 +677,21 @@ FunctionLiteral* Parser::ParseLazy(CompilationInfo* info) {
Handle<ExternalTwoByteString>::cast(source), Handle<ExternalTwoByteString>::cast(source),
shared_info->start_position(), shared_info->start_position(),
shared_info->end_position()); shared_info->end_position());
FunctionLiteral* result = ParseLazy(info, &stream, &zone_scope); FunctionLiteral* result = ParseLazy(&stream, &zone_scope);
return result; return result;
} else { } else {
GenericStringUtf16CharacterStream stream(source, GenericStringUtf16CharacterStream stream(source,
shared_info->start_position(), shared_info->start_position(),
shared_info->end_position()); shared_info->end_position());
FunctionLiteral* result = ParseLazy(info, &stream, &zone_scope); FunctionLiteral* result = ParseLazy(&stream, &zone_scope);
return result; return result;
} }
} }
FunctionLiteral* Parser::ParseLazy(CompilationInfo* info, FunctionLiteral* Parser::ParseLazy(Utf16CharacterStream* source,
Utf16CharacterStream* source,
ZoneScope* zone_scope) { ZoneScope* zone_scope) {
Handle<SharedFunctionInfo> shared_info = info->shared_info(); Handle<SharedFunctionInfo> shared_info = info()->shared_info();
scanner_.Initialize(source); scanner_.Initialize(source);
ASSERT(top_scope_ == NULL); ASSERT(top_scope_ == NULL);
ASSERT(target_stack_ == NULL); ASSERT(target_stack_ == NULL);
...@@ -708,16 +708,16 @@ FunctionLiteral* Parser::ParseLazy(CompilationInfo* info, ...@@ -708,16 +708,16 @@ FunctionLiteral* Parser::ParseLazy(CompilationInfo* info,
{ {
// Parse the function literal. // Parse the function literal.
Scope* scope = NewScope(top_scope_, GLOBAL_SCOPE); Scope* scope = NewScope(top_scope_, GLOBAL_SCOPE);
info->SetGlobalScope(scope); info()->SetGlobalScope(scope);
if (!info->closure().is_null()) { if (!info()->closure().is_null()) {
scope = Scope::DeserializeScopeChain(info->closure()->context(), scope, scope = Scope::DeserializeScopeChain(info()->closure()->context(), scope,
zone()); zone());
} }
FunctionState function_state(this, scope, isolate()); FunctionState function_state(this, scope, isolate());
ASSERT(scope->language_mode() != STRICT_MODE || !info->is_classic_mode()); ASSERT(scope->language_mode() != STRICT_MODE || !info()->is_classic_mode());
ASSERT(scope->language_mode() != EXTENDED_MODE || ASSERT(scope->language_mode() != EXTENDED_MODE ||
info->is_extended_mode()); info()->is_extended_mode());
ASSERT(info->language_mode() == shared_info->language_mode()); ASSERT(info()->language_mode() == shared_info->language_mode());
scope->SetLanguageMode(shared_info->language_mode()); scope->SetLanguageMode(shared_info->language_mode());
FunctionLiteral::Type type = shared_info->is_expression() FunctionLiteral::Type type = shared_info->is_expression()
? (shared_info->is_anonymous() ? (shared_info->is_anonymous()
...@@ -6041,16 +6041,15 @@ bool ParserApi::Parse(CompilationInfo* info, int parsing_flags) { ...@@ -6041,16 +6041,15 @@ bool ParserApi::Parse(CompilationInfo* info, int parsing_flags) {
} }
if (info->is_lazy()) { if (info->is_lazy()) {
ASSERT(!info->is_eval()); ASSERT(!info->is_eval());
Parser parser(script, parsing_flags, NULL, NULL, info->zone()); Parser parser(info, parsing_flags, NULL, NULL);
if (info->shared_info()->is_function()) { if (info->shared_info()->is_function()) {
result = parser.ParseLazy(info); result = parser.ParseLazy();
} else { } else {
result = parser.ParseProgram(info); result = parser.ParseProgram();
} }
} else { } else {
ScriptDataImpl* pre_data = info->pre_parse_data(); ScriptDataImpl* pre_data = info->pre_parse_data();
Parser parser(script, parsing_flags, info->extension(), pre_data, Parser parser(info, parsing_flags, info->extension(), pre_data);
info->zone());
if (pre_data != NULL && pre_data->has_error()) { if (pre_data != NULL && pre_data->has_error()) {
Scanner::Location loc = pre_data->MessageLocation(); Scanner::Location loc = pre_data->MessageLocation();
const char* message = pre_data->BuildMessage(); const char* message = pre_data->BuildMessage();
...@@ -6063,7 +6062,7 @@ bool ParserApi::Parse(CompilationInfo* info, int parsing_flags) { ...@@ -6063,7 +6062,7 @@ bool ParserApi::Parse(CompilationInfo* info, int parsing_flags) {
DeleteArray(args.start()); DeleteArray(args.start());
ASSERT(info->isolate()->has_pending_exception()); ASSERT(info->isolate()->has_pending_exception());
} else { } else {
result = parser.ParseProgram(info); result = parser.ParseProgram();
} }
} }
info->SetFunction(result); info->SetFunction(result);
......
...@@ -434,19 +434,18 @@ class SingletonLogger; ...@@ -434,19 +434,18 @@ class SingletonLogger;
class Parser { class Parser {
public: public:
Parser(Handle<Script> script, Parser(CompilationInfo* info,
int parsing_flags, // Combination of ParsingFlags int parsing_flags, // Combination of ParsingFlags
v8::Extension* extension, v8::Extension* extension,
ScriptDataImpl* pre_data, ScriptDataImpl* pre_data);
Zone* zone);
virtual ~Parser() { virtual ~Parser() {
delete reusable_preparser_; delete reusable_preparser_;
reusable_preparser_ = NULL; reusable_preparser_ = NULL;
} }
// Returns NULL if parsing failed. // Returns NULL if parsing failed.
FunctionLiteral* ParseProgram(CompilationInfo* info); FunctionLiteral* ParseProgram();
FunctionLiteral* ParseLazy(CompilationInfo* info); FunctionLiteral* ParseLazy();
void ReportMessageAt(Scanner::Location loc, void ReportMessageAt(Scanner::Location loc,
const char* message, const char* message,
...@@ -546,12 +545,12 @@ class Parser { ...@@ -546,12 +545,12 @@ class Parser {
FunctionLiteral* ParseLazy(CompilationInfo* info, FunctionLiteral* ParseLazy(Utf16CharacterStream* source,
Utf16CharacterStream* source,
ZoneScope* zone_scope); ZoneScope* zone_scope);
Isolate* isolate() { return isolate_; } Isolate* isolate() { return isolate_; }
Zone* zone() const { return zone_; } Zone* zone() const { return zone_; }
CompilationInfo* info() const { return info_; }
// Called by ParseProgram after setting up the scanner. // Called by ParseProgram after setting up the scanner.
FunctionLiteral* DoParseProgram(CompilationInfo* info, FunctionLiteral* DoParseProgram(CompilationInfo* info,
...@@ -840,6 +839,7 @@ class Parser { ...@@ -840,6 +839,7 @@ class Parser {
bool parenthesized_function_; bool parenthesized_function_;
Zone* zone_; Zone* zone_;
CompilationInfo* info_;
friend class BlockState; friend class BlockState;
friend class FunctionState; friend class FunctionState;
}; };
......
...@@ -1016,12 +1016,11 @@ TEST(ScopePositions) { ...@@ -1016,12 +1016,11 @@ TEST(ScopePositions) {
FACTORY->NewStringFromUtf8(i::CStrVector(program.start()))); FACTORY->NewStringFromUtf8(i::CStrVector(program.start())));
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::Parser parser(script, i::kAllowLazy | i::EXTENDED_MODE, NULL, NULL,
i::Isolate::Current()->runtime_zone());
i::CompilationInfoWithZone info(script); i::CompilationInfoWithZone info(script);
i::Parser parser(&info, i::kAllowLazy | i::EXTENDED_MODE, NULL, NULL);
info.MarkAsGlobal(); info.MarkAsGlobal();
info.SetLanguageMode(source_data[i].language_mode); info.SetLanguageMode(source_data[i].language_mode);
i::FunctionLiteral* function = parser.ParseProgram(&info); i::FunctionLiteral* function = parser.ParseProgram();
CHECK(function != NULL); CHECK(function != NULL);
// Check scope types and positions. // Check scope types and positions.
...@@ -1061,11 +1060,10 @@ void TestParserSync(i::Handle<i::String> source, int flags) { ...@@ -1061,11 +1060,10 @@ void TestParserSync(i::Handle<i::String> source, int flags) {
i::Handle<i::Script> script = FACTORY->NewScript(source); i::Handle<i::Script> script = FACTORY->NewScript(source);
bool save_harmony_scoping = i::FLAG_harmony_scoping; bool save_harmony_scoping = i::FLAG_harmony_scoping;
i::FLAG_harmony_scoping = harmony_scoping; i::FLAG_harmony_scoping = harmony_scoping;
i::Parser parser(script, flags, NULL, NULL,
i::Isolate::Current()->runtime_zone());
i::CompilationInfoWithZone info(script); i::CompilationInfoWithZone info(script);
i::Parser parser(&info, flags, NULL, NULL);
info.MarkAsGlobal(); info.MarkAsGlobal();
i::FunctionLiteral* function = parser.ParseProgram(&info); i::FunctionLiteral* function = parser.ParseProgram();
i::FLAG_harmony_scoping = save_harmony_scoping; i::FLAG_harmony_scoping = save_harmony_scoping;
i::String* type_string = NULL; i::String* type_string = NULL;
......
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