| Index: src/runtime.cc
|
| diff --git a/src/runtime.cc b/src/runtime.cc
|
| index 62c38aa57f3b6aa3e80e78baf7f99dc38d0c184f..c65d31f226f7ab4173aa73e04788d8e36eb5ed75 100644
|
| --- a/src/runtime.cc
|
| +++ b/src/runtime.cc
|
| @@ -11224,22 +11224,23 @@ class ScopeIterator {
|
| return;
|
| }
|
|
|
| - // Check whether we are in global code or function code. If there is a stack
|
| - // slot for .result then this function has been created for evaluating
|
| - // global code and it is not a real function.
|
| - // Checking for the existence of .result seems fragile, but the scope info
|
| - // saved with the code object does not otherwise have that information.
|
| - int index = shared_info->scope_info()->
|
| - StackSlotIndex(isolate_->heap()->result_symbol());
|
| -
|
| // Reparse the code and analyze the scopes.
|
| ZoneScope zone_scope(isolate, DELETE_ON_EXIT);
|
| Handle<Script> script(Script::cast(shared_info->script()));
|
| Scope* scope;
|
| - if (index >= 0) {
|
| - // Global code
|
| +
|
| + // Check whether we are in global, eval or function code.
|
| + Handle<ScopeInfo> scope_info(shared_info->scope_info());
|
| + if (scope_info->Type() != FUNCTION_SCOPE) {
|
| + // Global or eval code.
|
| CompilationInfo info(script);
|
| - info.MarkAsGlobal();
|
| + if (scope_info->Type() == GLOBAL_SCOPE) {
|
| + info.MarkAsGlobal();
|
| + } else {
|
| + ASSERT(scope_info->Type() == EVAL_SCOPE);
|
| + info.MarkAsEval();
|
| + info.SetCallingContext(Handle<Context>(function_->context()));
|
| + }
|
| CHECK(ParserApi::Parse(&info));
|
| CHECK(Scope::Analyze(&info));
|
| scope = info.function()->scope();
|
| @@ -11252,9 +11253,8 @@ class ScopeIterator {
|
| }
|
|
|
| // Retrieve the scope chain for the current position.
|
| - int statement_position =
|
| - shared_info->code()->SourceStatementPosition(frame_->pc());
|
| - scope->GetNestedScopeChain(&nested_scope_chain_, statement_position);
|
| + source_position_ = shared_info->code()->SourceStatementPosition(frame_->pc());
|
| + scope->GetNestedScopeChain(&nested_scope_chain_, source_position_);
|
| }
|
|
|
| // More scopes?
|
| @@ -11430,6 +11430,7 @@ class ScopeIterator {
|
| Handle<JSFunction> function_;
|
| Handle<Context> context_;
|
| List<Handle<ScopeInfo> > nested_scope_chain_;
|
| + int source_position_;
|
|
|
| DISALLOW_IMPLICIT_CONSTRUCTORS(ScopeIterator);
|
| };
|
|
|