Commit 49b9ef26 authored by bmeurer@chromium.org's avatar bmeurer@chromium.org

Remove useless ZoneScopes from Parser.

R=danno@chromium.org
BUG=

Review URL: https://codereview.chromium.org/17817003

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@15330 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent a92d2379
...@@ -566,7 +566,6 @@ Parser::Parser(CompilationInfo* info) ...@@ -566,7 +566,6 @@ Parser::Parser(CompilationInfo* info)
FunctionLiteral* Parser::ParseProgram() { FunctionLiteral* Parser::ParseProgram() {
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()));
isolate()->counters()->total_parse_size()->Increment(source->length()); isolate()->counters()->total_parse_size()->Increment(source->length());
...@@ -583,11 +582,11 @@ FunctionLiteral* Parser::ParseProgram() { ...@@ -583,11 +582,11 @@ FunctionLiteral* Parser::ParseProgram() {
ExternalTwoByteStringUtf16CharacterStream stream( ExternalTwoByteStringUtf16CharacterStream stream(
Handle<ExternalTwoByteString>::cast(source), 0, source->length()); Handle<ExternalTwoByteString>::cast(source), 0, source->length());
scanner_.Initialize(&stream); scanner_.Initialize(&stream);
result = DoParseProgram(info(), source, &zone_scope); result = DoParseProgram(info(), source);
} else { } else {
GenericStringUtf16CharacterStream stream(source, 0, source->length()); GenericStringUtf16CharacterStream stream(source, 0, source->length());
scanner_.Initialize(&stream); scanner_.Initialize(&stream);
result = DoParseProgram(info(), source, &zone_scope); result = DoParseProgram(info(), source);
} }
if (FLAG_trace_parse && result != NULL) { if (FLAG_trace_parse && result != NULL) {
...@@ -608,8 +607,7 @@ FunctionLiteral* Parser::ParseProgram() { ...@@ -608,8 +607,7 @@ FunctionLiteral* Parser::ParseProgram() {
FunctionLiteral* Parser::DoParseProgram(CompilationInfo* info, FunctionLiteral* Parser::DoParseProgram(CompilationInfo* info,
Handle<String> source, Handle<String> source) {
ZoneScope* zone_scope) {
ASSERT(top_scope_ == NULL); ASSERT(top_scope_ == NULL);
ASSERT(target_stack_ == NULL); ASSERT(target_stack_ == NULL);
if (pre_parse_data_ != NULL) pre_parse_data_->Initialize(); if (pre_parse_data_ != NULL) pre_parse_data_->Initialize();
...@@ -690,15 +688,11 @@ FunctionLiteral* Parser::DoParseProgram(CompilationInfo* info, ...@@ -690,15 +688,11 @@ FunctionLiteral* Parser::DoParseProgram(CompilationInfo* info,
// Make sure the target stack is empty. // Make sure the target stack is empty.
ASSERT(target_stack_ == NULL); ASSERT(target_stack_ == NULL);
// If there was a syntax error we have to get rid of the AST
// and it is not safe to do so before the scope has been deleted.
if (result == NULL) zone_scope->DeleteOnExit();
return result; return result;
} }
FunctionLiteral* Parser::ParseLazy() { FunctionLiteral* Parser::ParseLazy() {
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());
...@@ -713,12 +707,12 @@ FunctionLiteral* Parser::ParseLazy() { ...@@ -713,12 +707,12 @@ FunctionLiteral* Parser::ParseLazy() {
Handle<ExternalTwoByteString>::cast(source), Handle<ExternalTwoByteString>::cast(source),
shared_info->start_position(), shared_info->start_position(),
shared_info->end_position()); shared_info->end_position());
result = ParseLazy(&stream, &zone_scope); result = ParseLazy(&stream);
} else { } else {
GenericStringUtf16CharacterStream stream(source, GenericStringUtf16CharacterStream stream(source,
shared_info->start_position(), shared_info->start_position(),
shared_info->end_position()); shared_info->end_position());
result = ParseLazy(&stream, &zone_scope); result = ParseLazy(&stream);
} }
if (FLAG_trace_parse && result != NULL) { if (FLAG_trace_parse && result != NULL) {
...@@ -730,8 +724,7 @@ FunctionLiteral* Parser::ParseLazy() { ...@@ -730,8 +724,7 @@ FunctionLiteral* Parser::ParseLazy() {
} }
FunctionLiteral* Parser::ParseLazy(Utf16CharacterStream* source, FunctionLiteral* Parser::ParseLazy(Utf16CharacterStream* source) {
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);
...@@ -779,10 +772,7 @@ FunctionLiteral* Parser::ParseLazy(Utf16CharacterStream* source, ...@@ -779,10 +772,7 @@ FunctionLiteral* Parser::ParseLazy(Utf16CharacterStream* source,
// Make sure the target stack is empty. // Make sure the target stack is empty.
ASSERT(target_stack_ == NULL); ASSERT(target_stack_ == NULL);
// If there was a stack overflow we have to get rid of AST and it is
// not safe to do before scope has been deleted.
if (result == NULL) { if (result == NULL) {
zone_scope->DeleteOnExit();
if (stack_overflow_) isolate()->StackOverflow(); if (stack_overflow_) isolate()->StackOverflow();
} else { } else {
Handle<String> inferred_name(shared_info->inferred_name()); Handle<String> inferred_name(shared_info->inferred_name());
......
...@@ -562,8 +562,7 @@ class Parser BASE_EMBEDDED { ...@@ -562,8 +562,7 @@ class Parser BASE_EMBEDDED {
}; };
FunctionLiteral* ParseLazy(); FunctionLiteral* ParseLazy();
FunctionLiteral* ParseLazy(Utf16CharacterStream* source, FunctionLiteral* ParseLazy(Utf16CharacterStream* source);
ZoneScope* zone_scope);
Isolate* isolate() { return isolate_; } Isolate* isolate() { return isolate_; }
Zone* zone() const { return zone_; } Zone* zone() const { return zone_; }
...@@ -571,8 +570,7 @@ class Parser BASE_EMBEDDED { ...@@ -571,8 +570,7 @@ class Parser BASE_EMBEDDED {
// Called by ParseProgram after setting up the scanner. // Called by ParseProgram after setting up the scanner.
FunctionLiteral* DoParseProgram(CompilationInfo* info, FunctionLiteral* DoParseProgram(CompilationInfo* info,
Handle<String> source, Handle<String> source);
ZoneScope* zone_scope);
// Report syntax error // Report syntax error
void ReportUnexpectedToken(Token::Value token); void ReportUnexpectedToken(Token::Value token);
......
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