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 11389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11400 receiver = isolate->factory()->ToObject(receiver, native_context); | 11400 receiver = isolate->factory()->ToObject(receiver, native_context); |
11401 } | 11401 } |
11402 } | 11402 } |
11403 details->set(kFrameDetailsReceiverIndex, *receiver); | 11403 details->set(kFrameDetailsReceiverIndex, *receiver); |
11404 | 11404 |
11405 ASSERT_EQ(details_size, details_index); | 11405 ASSERT_EQ(details_size, details_index); |
11406 return *isolate->factory()->NewJSArrayWithElements(details); | 11406 return *isolate->factory()->NewJSArrayWithElements(details); |
11407 } | 11407 } |
11408 | 11408 |
11409 | 11409 |
| 11410 static bool ParameterIsShadowedByContextLocal(Handle<ScopeInfo> info, |
| 11411 int index) { |
| 11412 VariableMode mode; |
| 11413 InitializationFlag flag; |
| 11414 return info->ContextSlotIndex(info->ParameterName(index), &mode, &flag) != -1; |
| 11415 } |
| 11416 |
| 11417 |
11410 // Create a plain JSObject which materializes the local scope for the specified | 11418 // Create a plain JSObject which materializes the local scope for the specified |
11411 // frame. | 11419 // frame. |
11412 static Handle<JSObject> MaterializeStackLocalsWithFrameInspector( | 11420 static Handle<JSObject> MaterializeStackLocalsWithFrameInspector( |
11413 Isolate* isolate, | 11421 Isolate* isolate, |
11414 Handle<JSObject> target, | 11422 Handle<JSObject> target, |
11415 Handle<JSFunction> function, | 11423 Handle<JSFunction> function, |
11416 FrameInspector* frame_inspector) { | 11424 FrameInspector* frame_inspector) { |
11417 Handle<SharedFunctionInfo> shared(function->shared()); | 11425 Handle<SharedFunctionInfo> shared(function->shared()); |
11418 Handle<ScopeInfo> scope_info(shared->scope_info()); | 11426 Handle<ScopeInfo> scope_info(shared->scope_info()); |
11419 | 11427 |
11420 // First fill all parameters. | 11428 // First fill all parameters. |
11421 for (int i = 0; i < scope_info->ParameterCount(); ++i) { | 11429 for (int i = 0; i < scope_info->ParameterCount(); ++i) { |
11422 Handle<String> name(scope_info->ParameterName(i)); | |
11423 VariableMode mode; | |
11424 InitializationFlag init_flag; | |
11425 // Do not materialize the parameter if it is shadowed by a context local. | 11430 // Do not materialize the parameter if it is shadowed by a context local. |
11426 if (scope_info->ContextSlotIndex(*name, &mode, &init_flag) != -1) continue; | 11431 if (ParameterIsShadowedByContextLocal(scope_info, i)) continue; |
11427 | 11432 |
| 11433 HandleScope scope(isolate); |
11428 Handle<Object> value(i < frame_inspector->GetParametersCount() | 11434 Handle<Object> value(i < frame_inspector->GetParametersCount() |
11429 ? frame_inspector->GetParameter(i) | 11435 ? frame_inspector->GetParameter(i) |
11430 : isolate->heap()->undefined_value(), | 11436 : isolate->heap()->undefined_value(), |
11431 isolate); | 11437 isolate); |
11432 ASSERT(!value->IsTheHole()); | 11438 ASSERT(!value->IsTheHole()); |
| 11439 Handle<String> name(scope_info->ParameterName(i)); |
11433 | 11440 |
11434 RETURN_IF_EMPTY_HANDLE_VALUE( | 11441 RETURN_IF_EMPTY_HANDLE_VALUE( |
11435 isolate, | 11442 isolate, |
11436 Runtime::SetObjectProperty(isolate, target, name, value, NONE, SLOPPY), | 11443 Runtime::SetObjectProperty(isolate, target, name, value, NONE, SLOPPY), |
11437 Handle<JSObject>()); | 11444 Handle<JSObject>()); |
11438 } | 11445 } |
11439 | 11446 |
11440 // Second fill all stack locals. | 11447 // Second fill all stack locals. |
11441 for (int i = 0; i < scope_info->StackLocalCount(); ++i) { | 11448 for (int i = 0; i < scope_info->StackLocalCount(); ++i) { |
11442 Handle<String> name(scope_info->StackLocalName(i)); | 11449 Handle<String> name(scope_info->StackLocalName(i)); |
(...skipping 20 matching lines...) Expand all Loading... |
11463 // TODO(yangguo): make sure all code deoptimized when debugger is active | 11470 // TODO(yangguo): make sure all code deoptimized when debugger is active |
11464 // and assert that this cannot happen. | 11471 // and assert that this cannot happen. |
11465 return; | 11472 return; |
11466 } | 11473 } |
11467 | 11474 |
11468 Handle<SharedFunctionInfo> shared(function->shared()); | 11475 Handle<SharedFunctionInfo> shared(function->shared()); |
11469 Handle<ScopeInfo> scope_info(shared->scope_info()); | 11476 Handle<ScopeInfo> scope_info(shared->scope_info()); |
11470 | 11477 |
11471 // Parameters. | 11478 // Parameters. |
11472 for (int i = 0; i < scope_info->ParameterCount(); ++i) { | 11479 for (int i = 0; i < scope_info->ParameterCount(); ++i) { |
| 11480 // Shadowed parameters were not materialized. |
| 11481 if (ParameterIsShadowedByContextLocal(scope_info, i)) continue; |
| 11482 |
11473 ASSERT(!frame->GetParameter(i)->IsTheHole()); | 11483 ASSERT(!frame->GetParameter(i)->IsTheHole()); |
11474 HandleScope scope(isolate); | 11484 HandleScope scope(isolate); |
11475 Handle<Object> value = GetProperty( | 11485 Handle<String> name(scope_info->ParameterName(i)); |
11476 isolate, target, Handle<String>(scope_info->ParameterName(i))); | 11486 Handle<Object> value = GetProperty(isolate, target, name); |
11477 frame->SetParameterValue(i, *value); | 11487 frame->SetParameterValue(i, *value); |
11478 } | 11488 } |
11479 | 11489 |
11480 // Stack locals. | 11490 // Stack locals. |
11481 for (int i = 0; i < scope_info->StackLocalCount(); ++i) { | 11491 for (int i = 0; i < scope_info->StackLocalCount(); ++i) { |
11482 if (frame->GetExpression(i)->IsTheHole()) continue; | 11492 if (frame->GetExpression(i)->IsTheHole()) continue; |
11483 HandleScope scope(isolate); | 11493 HandleScope scope(isolate); |
11484 Handle<Object> value = GetProperty( | 11494 Handle<Object> value = GetProperty( |
11485 isolate, target, Handle<String>(scope_info->StackLocalName(i))); | 11495 isolate, target, Handle<String>(scope_info->StackLocalName(i))); |
11486 frame->SetExpression(i, *value); | 11496 frame->SetExpression(i, *value); |
(...skipping 3573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15060 // Handle last resort GC and make sure to allow future allocations | 15070 // Handle last resort GC and make sure to allow future allocations |
15061 // to grow the heap without causing GCs (if possible). | 15071 // to grow the heap without causing GCs (if possible). |
15062 isolate->counters()->gc_last_resort_from_js()->Increment(); | 15072 isolate->counters()->gc_last_resort_from_js()->Increment(); |
15063 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, | 15073 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, |
15064 "Runtime::PerformGC"); | 15074 "Runtime::PerformGC"); |
15065 } | 15075 } |
15066 } | 15076 } |
15067 | 15077 |
15068 | 15078 |
15069 } } // namespace v8::internal | 15079 } } // namespace v8::internal |
OLD | NEW |