OLD | NEW |
---|---|
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 11399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
11410 // Create a plain JSObject which materializes the local scope for the specified | 11410 // Create a plain JSObject which materializes the local scope for the specified |
11411 // frame. | 11411 // frame. |
11412 static Handle<JSObject> MaterializeStackLocalsWithFrameInspector( | 11412 static Handle<JSObject> MaterializeStackLocalsWithFrameInspector( |
11413 Isolate* isolate, | 11413 Isolate* isolate, |
11414 Handle<JSObject> target, | 11414 Handle<JSObject> target, |
11415 Handle<JSFunction> function, | 11415 Handle<JSFunction> function, |
11416 FrameInspector* frame_inspector) { | 11416 FrameInspector* frame_inspector) { |
11417 Handle<SharedFunctionInfo> shared(function->shared()); | 11417 Handle<SharedFunctionInfo> shared(function->shared()); |
11418 Handle<ScopeInfo> scope_info(shared->scope_info()); | 11418 Handle<ScopeInfo> scope_info(shared->scope_info()); |
11419 | 11419 |
11420 // First fill all parameters. | 11420 // First fill all parameters. Parameters in generators are context-allocated. |
11421 for (int i = 0; i < scope_info->ParameterCount(); ++i) { | 11421 if (!shared->is_generator()) { |
11422 Handle<String> name(scope_info->ParameterName(i)); | 11422 for (int i = 0; i < scope_info->ParameterCount(); ++i) { |
11423 VariableMode mode; | 11423 Handle<String> name(scope_info->ParameterName(i)); |
11424 InitializationFlag init_flag; | 11424 VariableMode mode; |
11425 // Do not materialize the parameter if it is shadowed by a context local. | 11425 InitializationFlag init_flag; |
11426 if (scope_info->ContextSlotIndex(*name, &mode, &init_flag) != -1) continue; | 11426 // Do not materialize the parameter if it is shadowed by a context local. |
11427 if (scope_info->ContextSlotIndex(*name, &mode, &init_flag) != -1) { | |
Michael Starzinger
2014/03/24 10:24:28
I am little bit confused here. For generators we s
| |
11428 continue; | |
11429 } | |
11427 | 11430 |
11428 Handle<Object> value(i < frame_inspector->GetParametersCount() | 11431 Handle<Object> value(i < frame_inspector->GetParametersCount() |
11429 ? frame_inspector->GetParameter(i) | 11432 ? frame_inspector->GetParameter(i) |
11430 : isolate->heap()->undefined_value(), | 11433 : isolate->heap()->undefined_value(), |
11431 isolate); | 11434 isolate); |
11432 ASSERT(!value->IsTheHole()); | 11435 ASSERT(!value->IsTheHole()); |
11433 | 11436 |
11434 RETURN_IF_EMPTY_HANDLE_VALUE( | 11437 RETURN_IF_EMPTY_HANDLE_VALUE( |
11435 isolate, | 11438 isolate, |
11436 Runtime::SetObjectProperty(isolate, target, name, value, NONE, SLOPPY), | 11439 Runtime::SetObjectProperty( |
11437 Handle<JSObject>()); | 11440 isolate, target, name, value, NONE, SLOPPY), |
11441 Handle<JSObject>()); | |
11442 } | |
11438 } | 11443 } |
11439 | 11444 |
11440 // Second fill all stack locals. | 11445 // Second fill all stack locals. |
11441 for (int i = 0; i < scope_info->StackLocalCount(); ++i) { | 11446 for (int i = 0; i < scope_info->StackLocalCount(); ++i) { |
11442 Handle<String> name(scope_info->StackLocalName(i)); | 11447 Handle<String> name(scope_info->StackLocalName(i)); |
11443 Handle<Object> value(frame_inspector->GetExpression(i), isolate); | 11448 Handle<Object> value(frame_inspector->GetExpression(i), isolate); |
11444 if (value->IsTheHole()) continue; | 11449 if (value->IsTheHole()) continue; |
11445 | 11450 |
11446 RETURN_IF_EMPTY_HANDLE_VALUE( | 11451 RETURN_IF_EMPTY_HANDLE_VALUE( |
11447 isolate, | 11452 isolate, |
(...skipping 13 matching lines...) Expand all Loading... | |
11461 if (inlined_jsframe_index != 0 || frame->is_optimized()) { | 11466 if (inlined_jsframe_index != 0 || frame->is_optimized()) { |
11462 // Optimized frames are not supported. | 11467 // Optimized frames are not supported. |
11463 // TODO(yangguo): make sure all code deoptimized when debugger is active | 11468 // TODO(yangguo): make sure all code deoptimized when debugger is active |
11464 // and assert that this cannot happen. | 11469 // and assert that this cannot happen. |
11465 return; | 11470 return; |
11466 } | 11471 } |
11467 | 11472 |
11468 Handle<SharedFunctionInfo> shared(function->shared()); | 11473 Handle<SharedFunctionInfo> shared(function->shared()); |
11469 Handle<ScopeInfo> scope_info(shared->scope_info()); | 11474 Handle<ScopeInfo> scope_info(shared->scope_info()); |
11470 | 11475 |
11471 // Parameters. | 11476 // Parameters. Parameters in generators are context-allocated. |
11472 for (int i = 0; i < scope_info->ParameterCount(); ++i) { | 11477 if (!shared->is_generator()) { |
11473 ASSERT(!frame->GetParameter(i)->IsTheHole()); | 11478 for (int i = 0; i < scope_info->ParameterCount(); ++i) { |
11474 HandleScope scope(isolate); | 11479 ASSERT(!frame->GetParameter(i)->IsTheHole()); |
Michael Starzinger
2014/03/24 10:24:28
Likewise, instead of baking in arbitrary special h
| |
11475 Handle<Object> value = GetProperty( | 11480 HandleScope scope(isolate); |
11476 isolate, target, Handle<String>(scope_info->ParameterName(i))); | 11481 Handle<Object> value = GetProperty( |
11477 frame->SetParameterValue(i, *value); | 11482 isolate, target, Handle<String>(scope_info->ParameterName(i))); |
11483 frame->SetParameterValue(i, *value); | |
11484 } | |
11478 } | 11485 } |
11479 | 11486 |
11480 // Stack locals. | 11487 // Stack locals. |
11481 for (int i = 0; i < scope_info->StackLocalCount(); ++i) { | 11488 for (int i = 0; i < scope_info->StackLocalCount(); ++i) { |
11482 if (frame->GetExpression(i)->IsTheHole()) continue; | 11489 if (frame->GetExpression(i)->IsTheHole()) continue; |
11483 HandleScope scope(isolate); | 11490 HandleScope scope(isolate); |
11484 Handle<Object> value = GetProperty( | 11491 Handle<Object> value = GetProperty( |
11485 isolate, target, Handle<String>(scope_info->StackLocalName(i))); | 11492 isolate, target, Handle<String>(scope_info->StackLocalName(i))); |
11486 frame->SetExpression(i, *value); | 11493 frame->SetExpression(i, *value); |
11487 } | 11494 } |
(...skipping 3572 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
15060 // Handle last resort GC and make sure to allow future allocations | 15067 // Handle last resort GC and make sure to allow future allocations |
15061 // to grow the heap without causing GCs (if possible). | 15068 // to grow the heap without causing GCs (if possible). |
15062 isolate->counters()->gc_last_resort_from_js()->Increment(); | 15069 isolate->counters()->gc_last_resort_from_js()->Increment(); |
15063 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, | 15070 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, |
15064 "Runtime::PerformGC"); | 15071 "Runtime::PerformGC"); |
15065 } | 15072 } |
15066 } | 15073 } |
15067 | 15074 |
15068 | 15075 |
15069 } } // namespace v8::internal | 15076 } } // namespace v8::internal |
OLD | NEW |