OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 11183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11194 }; | 11194 }; |
11195 | 11195 |
11196 ScopeIterator(Isolate* isolate, | 11196 ScopeIterator(Isolate* isolate, |
11197 JavaScriptFrame* frame, | 11197 JavaScriptFrame* frame, |
11198 int inlined_frame_index) | 11198 int inlined_frame_index) |
11199 : isolate_(isolate), | 11199 : isolate_(isolate), |
11200 frame_(frame), | 11200 frame_(frame), |
11201 inlined_frame_index_(inlined_frame_index), | 11201 inlined_frame_index_(inlined_frame_index), |
11202 function_(JSFunction::cast(frame->function())), | 11202 function_(JSFunction::cast(frame->function())), |
11203 context_(Context::cast(frame->context())), | 11203 context_(Context::cast(frame->context())), |
11204 local_done_(false), | 11204 nested_scope_chain_(4) { |
11205 at_local_(false) { | |
11206 | 11205 |
11207 // Check whether the first scope is actually a local scope. | 11206 // Catch the case when the debugger stops in an internal function. |
11208 // If there is a stack slot for .result then this local scope has been | 11207 Handle<SharedFunctionInfo> shared_info(function_->shared()); |
11209 // created for evaluating top level code and it is not a real local scope. | 11208 Handle<ScopeInfo> scope_info(shared_info->scope_info()); |
11210 // Checking for the existence of .result seems fragile, but the scope info | 11209 if (shared_info->script() == isolate->heap()->undefined_value()) { |
11211 // saved with the code object does not otherwise have that information. | 11210 while (context_->closure() == *function_) { |
11212 int index = function_->shared()->scope_info()-> | 11211 context_ = Handle<Context>(context_->previous(), isolate_); |
11213 StackSlotIndex(isolate_->heap()->result_symbol()); | 11212 } |
11214 if (index >= 0) { | 11213 return; |
11215 local_done_ = true; | 11214 } |
11216 } else if (context_->IsGlobalContext() || | 11215 |
11217 context_->IsFunctionContext()) { | 11216 // Get the debug info (create it if it does not exist). |
11218 at_local_ = true; | 11217 if (!isolate->debug()->EnsureDebugInfo(shared_info)) { |
11219 } else if (context_->closure() != *function_) { | 11218 // Return if ensuring debug info failed. |
11220 // The context_ is a block or with or catch block from the outer function. | 11219 return; |
11221 ASSERT(context_->IsWithContext() || | 11220 } |
11222 context_->IsCatchContext() || | 11221 Handle<DebugInfo> debug_info = Debug::GetDebugInfo(shared_info); |
11223 context_->IsBlockContext()); | 11222 |
11224 at_local_ = true; | 11223 // Find the break point where execution has stopped. |
| 11224 BreakLocationIterator break_location_iterator(debug_info, |
| 11225 ALL_BREAK_LOCATIONS); |
| 11226 break_location_iterator.FindBreakLocationFromAddress(frame->pc()); |
| 11227 if (break_location_iterator.IsExit()) { |
| 11228 // We are within the return sequence. At the momemt it is not possible to |
| 11229 // get a source position which is consistent with the current scope chain. |
| 11230 // Thus all nested with, catch and block contexts are skipped and we only |
| 11231 // provide the function scope. |
| 11232 if (scope_info->HasContext()) { |
| 11233 context_ = Handle<Context>(context_->declaration_context(), isolate_); |
| 11234 } else { |
| 11235 while (context_->closure() == *function_) { |
| 11236 context_ = Handle<Context>(context_->previous(), isolate_); |
| 11237 } |
| 11238 } |
| 11239 if (scope_info->Type() != EVAL_SCOPE) nested_scope_chain_.Add(scope_info); |
| 11240 } else { |
| 11241 // Reparse the code and analyze the scopes. |
| 11242 ZoneScope zone_scope(isolate, DELETE_ON_EXIT); |
| 11243 Handle<Script> script(Script::cast(shared_info->script())); |
| 11244 Scope* scope = NULL; |
| 11245 |
| 11246 // Check whether we are in global, eval or function code. |
| 11247 Handle<ScopeInfo> scope_info(shared_info->scope_info()); |
| 11248 if (scope_info->Type() != FUNCTION_SCOPE) { |
| 11249 // Global or eval code. |
| 11250 CompilationInfo info(script); |
| 11251 if (scope_info->Type() == GLOBAL_SCOPE) { |
| 11252 info.MarkAsGlobal(); |
| 11253 } else { |
| 11254 ASSERT(scope_info->Type() == EVAL_SCOPE); |
| 11255 info.MarkAsEval(); |
| 11256 info.SetCallingContext(Handle<Context>(function_->context())); |
| 11257 } |
| 11258 if (ParserApi::Parse(&info, kNoParsingFlags) && Scope::Analyze(&info)) { |
| 11259 scope = info.function()->scope(); |
| 11260 } |
| 11261 } else { |
| 11262 // Function code |
| 11263 CompilationInfo info(shared_info); |
| 11264 if (ParserApi::Parse(&info, kNoParsingFlags) && Scope::Analyze(&info)) { |
| 11265 scope = info.function()->scope(); |
| 11266 } |
| 11267 } |
| 11268 |
| 11269 // Retrieve the scope chain for the current position. |
| 11270 if (scope != NULL) { |
| 11271 int source_position = shared_info->code()->SourcePosition(frame_->pc()); |
| 11272 scope->GetNestedScopeChain(&nested_scope_chain_, source_position); |
| 11273 } else { |
| 11274 // A failed reparse indicates that the preparser has diverged from the |
| 11275 // parser or that the preparse data given to the initial parse has been |
| 11276 // faulty. We fail in debug mode but in release mode we only provide the |
| 11277 // information we get from the context chain but nothing about |
| 11278 // completely stack allocated scopes or stack allocated locals. |
| 11279 UNREACHABLE(); |
| 11280 } |
11225 } | 11281 } |
11226 } | 11282 } |
11227 | 11283 |
11228 // More scopes? | 11284 // More scopes? |
11229 bool Done() { return context_.is_null(); } | 11285 bool Done() { return context_.is_null(); } |
11230 | 11286 |
11231 // Move to the next scope. | 11287 // Move to the next scope. |
11232 void Next() { | 11288 void Next() { |
11233 // If at a local scope mark the local scope as passed. | 11289 ScopeType scope_type = Type(); |
11234 if (at_local_) { | 11290 if (scope_type == ScopeTypeGlobal) { |
11235 at_local_ = false; | 11291 // The global scope is always the last in the chain. |
11236 local_done_ = true; | 11292 ASSERT(context_->IsGlobalContext()); |
11237 | |
11238 // If the current context is not associated with the local scope the | |
11239 // current context is the next real scope, so don't move to the next | |
11240 // context in this case. | |
11241 if (context_->closure() != *function_) { | |
11242 return; | |
11243 } | |
11244 } | |
11245 | |
11246 // The global scope is always the last in the chain. | |
11247 if (context_->IsGlobalContext()) { | |
11248 context_ = Handle<Context>(); | 11293 context_ = Handle<Context>(); |
11249 return; | 11294 return; |
11250 } | 11295 } |
11251 | 11296 if (nested_scope_chain_.is_empty()) { |
11252 // Move to the next context. | 11297 context_ = Handle<Context>(context_->previous(), isolate_); |
11253 context_ = Handle<Context>(context_->previous(), isolate_); | 11298 } else { |
11254 | 11299 if (nested_scope_chain_.last()->HasContext()) { |
11255 // If passing the local scope indicate that the current scope is now the | 11300 ASSERT(context_->previous() != NULL); |
11256 // local scope. | 11301 context_ = Handle<Context>(context_->previous(), isolate_); |
11257 if (!local_done_ && | 11302 } |
11258 (context_->IsGlobalContext() || context_->IsFunctionContext())) { | 11303 nested_scope_chain_.RemoveLast(); |
11259 at_local_ = true; | |
11260 } | 11304 } |
11261 } | 11305 } |
11262 | 11306 |
11263 // Return the type of the current scope. | 11307 // Return the type of the current scope. |
11264 ScopeType Type() { | 11308 ScopeType Type() { |
11265 if (at_local_) { | 11309 if (!nested_scope_chain_.is_empty()) { |
11266 return ScopeTypeLocal; | 11310 Handle<ScopeInfo> scope_info = nested_scope_chain_.last(); |
| 11311 switch (scope_info->Type()) { |
| 11312 case FUNCTION_SCOPE: |
| 11313 ASSERT(context_->IsFunctionContext() || |
| 11314 !scope_info->HasContext()); |
| 11315 return ScopeTypeLocal; |
| 11316 case GLOBAL_SCOPE: |
| 11317 ASSERT(context_->IsGlobalContext()); |
| 11318 return ScopeTypeGlobal; |
| 11319 case WITH_SCOPE: |
| 11320 ASSERT(context_->IsWithContext()); |
| 11321 return ScopeTypeWith; |
| 11322 case CATCH_SCOPE: |
| 11323 ASSERT(context_->IsCatchContext()); |
| 11324 return ScopeTypeCatch; |
| 11325 case BLOCK_SCOPE: |
| 11326 ASSERT(!scope_info->HasContext() || |
| 11327 context_->IsBlockContext()); |
| 11328 return ScopeTypeBlock; |
| 11329 case EVAL_SCOPE: |
| 11330 UNREACHABLE(); |
| 11331 } |
11267 } | 11332 } |
11268 if (context_->IsGlobalContext()) { | 11333 if (context_->IsGlobalContext()) { |
11269 ASSERT(context_->global()->IsGlobalObject()); | 11334 ASSERT(context_->global()->IsGlobalObject()); |
11270 return ScopeTypeGlobal; | 11335 return ScopeTypeGlobal; |
11271 } | 11336 } |
11272 if (context_->IsFunctionContext()) { | 11337 if (context_->IsFunctionContext()) { |
11273 return ScopeTypeClosure; | 11338 return ScopeTypeClosure; |
11274 } | 11339 } |
11275 if (context_->IsCatchContext()) { | 11340 if (context_->IsCatchContext()) { |
11276 return ScopeTypeCatch; | 11341 return ScopeTypeCatch; |
11277 } | 11342 } |
11278 if (context_->IsBlockContext()) { | 11343 if (context_->IsBlockContext()) { |
11279 return ScopeTypeBlock; | 11344 return ScopeTypeBlock; |
11280 } | 11345 } |
11281 ASSERT(context_->IsWithContext()); | 11346 ASSERT(context_->IsWithContext()); |
11282 return ScopeTypeWith; | 11347 return ScopeTypeWith; |
11283 } | 11348 } |
11284 | 11349 |
11285 // Return the JavaScript object with the content of the current scope. | 11350 // Return the JavaScript object with the content of the current scope. |
11286 Handle<JSObject> ScopeObject() { | 11351 Handle<JSObject> ScopeObject() { |
11287 switch (Type()) { | 11352 switch (Type()) { |
11288 case ScopeIterator::ScopeTypeGlobal: | 11353 case ScopeIterator::ScopeTypeGlobal: |
11289 return Handle<JSObject>(CurrentContext()->global()); | 11354 return Handle<JSObject>(CurrentContext()->global()); |
11290 case ScopeIterator::ScopeTypeLocal: | 11355 case ScopeIterator::ScopeTypeLocal: |
11291 // Materialize the content of the local scope into a JSObject. | 11356 // Materialize the content of the local scope into a JSObject. |
| 11357 ASSERT(nested_scope_chain_.length() == 1); |
11292 return MaterializeLocalScope(isolate_, frame_, inlined_frame_index_); | 11358 return MaterializeLocalScope(isolate_, frame_, inlined_frame_index_); |
11293 case ScopeIterator::ScopeTypeWith: | 11359 case ScopeIterator::ScopeTypeWith: |
11294 // Return the with object. | 11360 // Return the with object. |
11295 return Handle<JSObject>(JSObject::cast(CurrentContext()->extension())); | 11361 return Handle<JSObject>(JSObject::cast(CurrentContext()->extension())); |
11296 case ScopeIterator::ScopeTypeCatch: | 11362 case ScopeIterator::ScopeTypeCatch: |
11297 return MaterializeCatchScope(isolate_, CurrentContext()); | 11363 return MaterializeCatchScope(isolate_, CurrentContext()); |
11298 case ScopeIterator::ScopeTypeClosure: | 11364 case ScopeIterator::ScopeTypeClosure: |
11299 // Materialize the content of the closure scope into a JSObject. | 11365 // Materialize the content of the closure scope into a JSObject. |
11300 return MaterializeClosure(isolate_, CurrentContext()); | 11366 return MaterializeClosure(isolate_, CurrentContext()); |
11301 case ScopeIterator::ScopeTypeBlock: | 11367 case ScopeIterator::ScopeTypeBlock: |
11302 return MaterializeBlockScope(isolate_, CurrentContext()); | 11368 return MaterializeBlockScope(isolate_, CurrentContext()); |
11303 } | 11369 } |
11304 UNREACHABLE(); | 11370 UNREACHABLE(); |
11305 return Handle<JSObject>(); | 11371 return Handle<JSObject>(); |
11306 } | 11372 } |
11307 | 11373 |
| 11374 Handle<ScopeInfo> CurrentScopeInfo() { |
| 11375 if (!nested_scope_chain_.is_empty()) { |
| 11376 return nested_scope_chain_.last(); |
| 11377 } else if (context_->IsBlockContext()) { |
| 11378 return Handle<ScopeInfo>(ScopeInfo::cast(context_->extension())); |
| 11379 } else if (context_->IsFunctionContext()) { |
| 11380 return Handle<ScopeInfo>(context_->closure()->shared()->scope_info()); |
| 11381 } |
| 11382 return Handle<ScopeInfo>::null(); |
| 11383 } |
| 11384 |
11308 // Return the context for this scope. For the local context there might not | 11385 // Return the context for this scope. For the local context there might not |
11309 // be an actual context. | 11386 // be an actual context. |
11310 Handle<Context> CurrentContext() { | 11387 Handle<Context> CurrentContext() { |
11311 if (at_local_ && context_->closure() != *function_) { | 11388 if (Type() == ScopeTypeGlobal || |
| 11389 nested_scope_chain_.is_empty()) { |
| 11390 return context_; |
| 11391 } else if (nested_scope_chain_.last()->HasContext()) { |
| 11392 return context_; |
| 11393 } else { |
11312 return Handle<Context>(); | 11394 return Handle<Context>(); |
11313 } | 11395 } |
11314 return context_; | |
11315 } | 11396 } |
11316 | 11397 |
11317 #ifdef DEBUG | 11398 #ifdef DEBUG |
11318 // Debug print of the content of the current scope. | 11399 // Debug print of the content of the current scope. |
11319 void DebugPrint() { | 11400 void DebugPrint() { |
11320 switch (Type()) { | 11401 switch (Type()) { |
11321 case ScopeIterator::ScopeTypeGlobal: | 11402 case ScopeIterator::ScopeTypeGlobal: |
11322 PrintF("Global:\n"); | 11403 PrintF("Global:\n"); |
11323 CurrentContext()->Print(); | 11404 CurrentContext()->Print(); |
11324 break; | 11405 break; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11366 PrintF("\n"); | 11447 PrintF("\n"); |
11367 } | 11448 } |
11368 #endif | 11449 #endif |
11369 | 11450 |
11370 private: | 11451 private: |
11371 Isolate* isolate_; | 11452 Isolate* isolate_; |
11372 JavaScriptFrame* frame_; | 11453 JavaScriptFrame* frame_; |
11373 int inlined_frame_index_; | 11454 int inlined_frame_index_; |
11374 Handle<JSFunction> function_; | 11455 Handle<JSFunction> function_; |
11375 Handle<Context> context_; | 11456 Handle<Context> context_; |
11376 bool local_done_; | 11457 List<Handle<ScopeInfo> > nested_scope_chain_; |
11377 bool at_local_; | |
11378 | 11458 |
11379 DISALLOW_IMPLICIT_CONSTRUCTORS(ScopeIterator); | 11459 DISALLOW_IMPLICIT_CONSTRUCTORS(ScopeIterator); |
11380 }; | 11460 }; |
11381 | 11461 |
11382 | 11462 |
11383 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetScopeCount) { | 11463 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetScopeCount) { |
11384 HandleScope scope(isolate); | 11464 HandleScope scope(isolate); |
11385 ASSERT(args.length() == 2); | 11465 ASSERT(args.length() == 2); |
11386 | 11466 |
11387 // Check arguments. | 11467 // Check arguments. |
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11830 RUNTIME_FUNCTION(MaybeObject*, Runtime_ClearStepping) { | 11910 RUNTIME_FUNCTION(MaybeObject*, Runtime_ClearStepping) { |
11831 HandleScope scope(isolate); | 11911 HandleScope scope(isolate); |
11832 ASSERT(args.length() == 0); | 11912 ASSERT(args.length() == 0); |
11833 isolate->debug()->ClearStepping(); | 11913 isolate->debug()->ClearStepping(); |
11834 return isolate->heap()->undefined_value(); | 11914 return isolate->heap()->undefined_value(); |
11835 } | 11915 } |
11836 | 11916 |
11837 | 11917 |
11838 // Creates a copy of the with context chain. The copy of the context chain is | 11918 // Creates a copy of the with context chain. The copy of the context chain is |
11839 // is linked to the function context supplied. | 11919 // is linked to the function context supplied. |
11840 static Handle<Context> CopyWithContextChain(Isolate* isolate, | 11920 static Handle<Context> CopyNestedScopeContextChain(Isolate* isolate, |
11841 Handle<JSFunction> function, | 11921 Handle<JSFunction> function, |
11842 Handle<Context> current, | 11922 Handle<Context> base, |
11843 Handle<Context> base) { | 11923 JavaScriptFrame* frame, |
11844 // At the end of the chain. Return the base context to link to. | 11924 int inlined_frame_index) { |
11845 if (current->IsFunctionContext() || current->IsGlobalContext()) { | 11925 HandleScope scope(isolate); |
11846 return base; | 11926 List<Handle<ScopeInfo> > scope_chain; |
| 11927 List<Handle<Context> > context_chain; |
| 11928 |
| 11929 ScopeIterator it(isolate, frame, inlined_frame_index); |
| 11930 for (; it.Type() != ScopeIterator::ScopeTypeGlobal && |
| 11931 it.Type() != ScopeIterator::ScopeTypeLocal ; it.Next()) { |
| 11932 ASSERT(!it.Done()); |
| 11933 scope_chain.Add(it.CurrentScopeInfo()); |
| 11934 context_chain.Add(it.CurrentContext()); |
11847 } | 11935 } |
11848 | 11936 |
11849 // Recursively copy the with and catch contexts. | 11937 // At the end of the chain. Return the base context to link to. |
11850 HandleScope scope(isolate); | 11938 Handle<Context> context = base; |
11851 Handle<Context> previous(current->previous()); | 11939 |
11852 Handle<Context> new_previous = | 11940 // Iteratively copy and or materialize the nested contexts. |
11853 CopyWithContextChain(isolate, function, previous, base); | 11941 while (!scope_chain.is_empty()) { |
11854 Handle<Context> new_current; | 11942 Handle<ScopeInfo> scope_info = scope_chain.RemoveLast(); |
11855 if (current->IsCatchContext()) { | 11943 Handle<Context> current = context_chain.RemoveLast(); |
11856 Handle<String> name(String::cast(current->extension())); | 11944 ASSERT(!(scope_info->HasContext() & current.is_null())); |
11857 Handle<Object> thrown_object(current->get(Context::THROWN_OBJECT_INDEX)); | 11945 |
11858 new_current = | 11946 if (scope_info->Type() == CATCH_SCOPE) { |
11859 isolate->factory()->NewCatchContext(function, | 11947 Handle<String> name(String::cast(current->extension())); |
11860 new_previous, | 11948 Handle<Object> thrown_object(current->get(Context::THROWN_OBJECT_INDEX)); |
11861 name, | 11949 context = |
11862 thrown_object); | 11950 isolate->factory()->NewCatchContext(function, |
11863 } else if (current->IsBlockContext()) { | 11951 context, |
11864 Handle<ScopeInfo> scope_info(ScopeInfo::cast(current->extension())); | 11952 name, |
11865 new_current = | 11953 thrown_object); |
11866 isolate->factory()->NewBlockContext(function, new_previous, scope_info); | 11954 } else if (scope_info->Type() == BLOCK_SCOPE) { |
11867 // Copy context slots. | 11955 // Materialize the contents of the block scope into a JSObject. |
11868 int num_context_slots = scope_info->ContextLength(); | 11956 Handle<JSObject> block_scope_object = |
11869 for (int i = Context::MIN_CONTEXT_SLOTS; i < num_context_slots; ++i) { | 11957 MaterializeBlockScope(isolate, current); |
11870 new_current->set(i, current->get(i)); | 11958 if (block_scope_object.is_null()) { |
| 11959 return Handle<Context>::null(); |
| 11960 } |
| 11961 // Allocate a new function context for the debug evaluation and set the |
| 11962 // extension object. |
| 11963 Handle<Context> new_context = |
| 11964 isolate->factory()->NewFunctionContext(Context::MIN_CONTEXT_SLOTS, |
| 11965 function); |
| 11966 new_context->set_extension(*block_scope_object); |
| 11967 new_context->set_previous(*context); |
| 11968 context = new_context; |
| 11969 } else { |
| 11970 ASSERT(scope_info->Type() == WITH_SCOPE); |
| 11971 ASSERT(current->IsWithContext()); |
| 11972 Handle<JSObject> extension(JSObject::cast(current->extension())); |
| 11973 context = |
| 11974 isolate->factory()->NewWithContext(function, context, extension); |
11871 } | 11975 } |
11872 } else { | |
11873 ASSERT(current->IsWithContext()); | |
11874 Handle<JSObject> extension(JSObject::cast(current->extension())); | |
11875 new_current = | |
11876 isolate->factory()->NewWithContext(function, new_previous, extension); | |
11877 } | 11976 } |
11878 return scope.CloseAndEscape(new_current); | 11977 |
| 11978 return scope.CloseAndEscape(context); |
11879 } | 11979 } |
11880 | 11980 |
11881 | 11981 |
11882 // Helper function to find or create the arguments object for | 11982 // Helper function to find or create the arguments object for |
11883 // Runtime_DebugEvaluate. | 11983 // Runtime_DebugEvaluate. |
11884 static Handle<Object> GetArgumentsObject(Isolate* isolate, | 11984 static Handle<Object> GetArgumentsObject(Isolate* isolate, |
11885 JavaScriptFrame* frame, | 11985 JavaScriptFrame* frame, |
11886 int inlined_frame_index, | 11986 int inlined_frame_index, |
11887 Handle<JSFunction> function, | 11987 Handle<JSFunction> function, |
11888 Handle<ScopeInfo> scope_info, | 11988 Handle<ScopeInfo> scope_info, |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12003 isolate->factory()->NewFunctionContext(Context::MIN_CONTEXT_SLOTS, | 12103 isolate->factory()->NewFunctionContext(Context::MIN_CONTEXT_SLOTS, |
12004 go_between); | 12104 go_between); |
12005 context->set_extension(*local_scope); | 12105 context->set_extension(*local_scope); |
12006 // Copy any with contexts present and chain them in front of this context. | 12106 // Copy any with contexts present and chain them in front of this context. |
12007 Handle<Context> frame_context(Context::cast(frame->context())); | 12107 Handle<Context> frame_context(Context::cast(frame->context())); |
12008 Handle<Context> function_context; | 12108 Handle<Context> function_context; |
12009 // Get the function's context if it has one. | 12109 // Get the function's context if it has one. |
12010 if (scope_info->HasContext()) { | 12110 if (scope_info->HasContext()) { |
12011 function_context = Handle<Context>(frame_context->declaration_context()); | 12111 function_context = Handle<Context>(frame_context->declaration_context()); |
12012 } | 12112 } |
12013 context = CopyWithContextChain(isolate, go_between, frame_context, context); | 12113 context = CopyNestedScopeContextChain(isolate, |
| 12114 go_between, |
| 12115 context, |
| 12116 frame, |
| 12117 inlined_frame_index); |
12014 | 12118 |
12015 if (additional_context->IsJSObject()) { | 12119 if (additional_context->IsJSObject()) { |
12016 Handle<JSObject> extension = Handle<JSObject>::cast(additional_context); | 12120 Handle<JSObject> extension = Handle<JSObject>::cast(additional_context); |
12017 context = | 12121 context = |
12018 isolate->factory()->NewWithContext(go_between, context, extension); | 12122 isolate->factory()->NewWithContext(go_between, context, extension); |
12019 } | 12123 } |
12020 | 12124 |
12021 // Wrap the evaluation statement in a new function compiled in the newly | 12125 // Wrap the evaluation statement in a new function compiled in the newly |
12022 // created context. The function has one parameter which has to be called | 12126 // created context. The function has one parameter which has to be called |
12023 // 'arguments'. This it to have access to what would have been 'arguments' in | 12127 // 'arguments'. This it to have access to what would have been 'arguments' in |
(...skipping 1434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13458 } else { | 13562 } else { |
13459 // Handle last resort GC and make sure to allow future allocations | 13563 // Handle last resort GC and make sure to allow future allocations |
13460 // to grow the heap without causing GCs (if possible). | 13564 // to grow the heap without causing GCs (if possible). |
13461 isolate->counters()->gc_last_resort_from_js()->Increment(); | 13565 isolate->counters()->gc_last_resort_from_js()->Increment(); |
13462 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags); | 13566 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags); |
13463 } | 13567 } |
13464 } | 13568 } |
13465 | 13569 |
13466 | 13570 |
13467 } } // namespace v8::internal | 13571 } } // namespace v8::internal |
OLD | NEW |