|
@ -703,38 +703,40 @@ FunctionLiteral* Parser::DoParseProgram(Handle<String> source, |
|
|
return result; |
|
|
return result; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
FunctionLiteral* Parser::ParseLazy(Handle<SharedFunctionInfo> info) { |
|
|
FunctionLiteral* Parser::ParseLazy(CompilationInfo* info) { |
|
|
CompilationZoneScope zone_scope(DONT_DELETE_ON_EXIT); |
|
|
CompilationZoneScope zone_scope(DONT_DELETE_ON_EXIT); |
|
|
HistogramTimerScope timer(&Counters::parse_lazy); |
|
|
HistogramTimerScope timer(&Counters::parse_lazy); |
|
|
Handle<String> source(String::cast(script_->source())); |
|
|
Handle<String> source(String::cast(script_->source())); |
|
|
Counters::total_parse_size.Increment(source->length()); |
|
|
Counters::total_parse_size.Increment(source->length()); |
|
|
|
|
|
|
|
|
|
|
|
Handle<SharedFunctionInfo> shared_info = info->shared_info(); |
|
|
// Initialize parser state.
|
|
|
// Initialize parser state.
|
|
|
source->TryFlatten(); |
|
|
source->TryFlatten(); |
|
|
if (source->IsExternalTwoByteString()) { |
|
|
if (source->IsExternalTwoByteString()) { |
|
|
ExternalTwoByteStringUC16CharacterStream stream( |
|
|
ExternalTwoByteStringUC16CharacterStream stream( |
|
|
Handle<ExternalTwoByteString>::cast(source), |
|
|
Handle<ExternalTwoByteString>::cast(source), |
|
|
info->start_position(), |
|
|
shared_info->start_position(), |
|
|
info->end_position()); |
|
|
shared_info->end_position()); |
|
|
FunctionLiteral* result = ParseLazy(info, &stream, &zone_scope); |
|
|
FunctionLiteral* result = ParseLazy(info, &stream, &zone_scope); |
|
|
return result; |
|
|
return result; |
|
|
} else { |
|
|
} else { |
|
|
GenericStringUC16CharacterStream stream(source, |
|
|
GenericStringUC16CharacterStream stream(source, |
|
|
info->start_position(), |
|
|
shared_info->start_position(), |
|
|
info->end_position()); |
|
|
shared_info->end_position()); |
|
|
FunctionLiteral* result = ParseLazy(info, &stream, &zone_scope); |
|
|
FunctionLiteral* result = ParseLazy(info, &stream, &zone_scope); |
|
|
return result; |
|
|
return result; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FunctionLiteral* Parser::ParseLazy(Handle<SharedFunctionInfo> info, |
|
|
FunctionLiteral* Parser::ParseLazy(CompilationInfo* info, |
|
|
UC16CharacterStream* source, |
|
|
UC16CharacterStream* source, |
|
|
ZoneScope* zone_scope) { |
|
|
ZoneScope* zone_scope) { |
|
|
|
|
|
Handle<SharedFunctionInfo> shared_info = info->shared_info(); |
|
|
scanner_.Initialize(source); |
|
|
scanner_.Initialize(source); |
|
|
ASSERT(target_stack_ == NULL); |
|
|
ASSERT(target_stack_ == NULL); |
|
|
|
|
|
|
|
|
Handle<String> name(String::cast(info->name())); |
|
|
Handle<String> name(String::cast(shared_info->name())); |
|
|
fni_ = new FuncNameInferrer(); |
|
|
fni_ = new FuncNameInferrer(); |
|
|
fni_->PushEnclosingName(name); |
|
|
fni_->PushEnclosingName(name); |
|
|
|
|
|
|
|
@ -746,18 +748,20 @@ FunctionLiteral* Parser::ParseLazy(Handle<SharedFunctionInfo> info, |
|
|
{ |
|
|
{ |
|
|
// Parse the function literal.
|
|
|
// Parse the function literal.
|
|
|
Handle<String> no_name = Factory::empty_symbol(); |
|
|
Handle<String> no_name = Factory::empty_symbol(); |
|
|
Scope* scope = |
|
|
Scope* scope = NewScope(top_scope_, Scope::GLOBAL_SCOPE, inside_with()); |
|
|
NewScope(top_scope_, Scope::GLOBAL_SCOPE, inside_with()); |
|
|
if (!info->closure().is_null()) { |
|
|
|
|
|
scope = Scope::DeserializeScopeChain(info, scope); |
|
|
|
|
|
} |
|
|
LexicalScope lexical_scope(&this->top_scope_, &this->with_nesting_level_, |
|
|
LexicalScope lexical_scope(&this->top_scope_, &this->with_nesting_level_, |
|
|
scope); |
|
|
scope); |
|
|
TemporaryScope temp_scope(&this->temp_scope_); |
|
|
TemporaryScope temp_scope(&this->temp_scope_); |
|
|
|
|
|
|
|
|
if (info->strict_mode()) { |
|
|
if (shared_info->strict_mode()) { |
|
|
temp_scope.EnableStrictMode(); |
|
|
temp_scope.EnableStrictMode(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
FunctionLiteralType type = |
|
|
FunctionLiteralType type = |
|
|
info->is_expression() ? EXPRESSION : DECLARATION; |
|
|
shared_info->is_expression() ? EXPRESSION : DECLARATION; |
|
|
bool ok = true; |
|
|
bool ok = true; |
|
|
result = ParseFunctionLiteral(name, |
|
|
result = ParseFunctionLiteral(name, |
|
|
false, // Strict mode name already checked.
|
|
|
false, // Strict mode name already checked.
|
|
@ -775,7 +779,7 @@ FunctionLiteral* Parser::ParseLazy(Handle<SharedFunctionInfo> info, |
|
|
zone_scope->DeleteOnExit(); |
|
|
zone_scope->DeleteOnExit(); |
|
|
if (stack_overflow_) Top::StackOverflow(); |
|
|
if (stack_overflow_) Top::StackOverflow(); |
|
|
} else { |
|
|
} else { |
|
|
Handle<String> inferred_name(info->inferred_name()); |
|
|
Handle<String> inferred_name(shared_info->inferred_name()); |
|
|
result->set_inferred_name(inferred_name); |
|
|
result->set_inferred_name(inferred_name); |
|
|
} |
|
|
} |
|
|
return result; |
|
|
return result; |
|
@ -5133,7 +5137,7 @@ bool ParserApi::Parse(CompilationInfo* info) { |
|
|
Handle<Script> script = info->script(); |
|
|
Handle<Script> script = info->script(); |
|
|
if (info->is_lazy()) { |
|
|
if (info->is_lazy()) { |
|
|
Parser parser(script, true, NULL, NULL); |
|
|
Parser parser(script, true, NULL, NULL); |
|
|
result = parser.ParseLazy(info->shared_info()); |
|
|
result = parser.ParseLazy(info); |
|
|
} else { |
|
|
} else { |
|
|
bool allow_natives_syntax = |
|
|
bool allow_natives_syntax = |
|
|
FLAG_allow_natives_syntax || Bootstrapper::IsActive(); |
|
|
FLAG_allow_natives_syntax || Bootstrapper::IsActive(); |
|
|