 Chromium Code Reviews
 Chromium Code Reviews Issue 207153004:
  Fix DebugEvaluate for generators.  (Closed) 
  Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
    
  
    Issue 207153004:
  Fix DebugEvaluate for generators.  (Closed) 
  Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge| 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( | 
| 
Michael Starzinger
2014/03/24 10:57:07
nit: Should fit into one line again now.
 | |
| 11444 isolate, target, name, value, NONE, SLOPPY), | |
| 11437 Handle<JSObject>()); | 11445 Handle<JSObject>()); | 
| 11438 } | 11446 } | 
| 11439 | 11447 | 
| 11440 // Second fill all stack locals. | 11448 // Second fill all stack locals. | 
| 11441 for (int i = 0; i < scope_info->StackLocalCount(); ++i) { | 11449 for (int i = 0; i < scope_info->StackLocalCount(); ++i) { | 
| 11442 Handle<String> name(scope_info->StackLocalName(i)); | 11450 Handle<String> name(scope_info->StackLocalName(i)); | 
| 11443 Handle<Object> value(frame_inspector->GetExpression(i), isolate); | 11451 Handle<Object> value(frame_inspector->GetExpression(i), isolate); | 
| 11444 if (value->IsTheHole()) continue; | 11452 if (value->IsTheHole()) continue; | 
| 11445 | 11453 | 
| 11446 RETURN_IF_EMPTY_HANDLE_VALUE( | 11454 RETURN_IF_EMPTY_HANDLE_VALUE( | 
| (...skipping 16 matching lines...) Expand all Loading... | |
| 11463 // TODO(yangguo): make sure all code deoptimized when debugger is active | 11471 // TODO(yangguo): make sure all code deoptimized when debugger is active | 
| 11464 // and assert that this cannot happen. | 11472 // and assert that this cannot happen. | 
| 11465 return; | 11473 return; | 
| 11466 } | 11474 } | 
| 11467 | 11475 | 
| 11468 Handle<SharedFunctionInfo> shared(function->shared()); | 11476 Handle<SharedFunctionInfo> shared(function->shared()); | 
| 11469 Handle<ScopeInfo> scope_info(shared->scope_info()); | 11477 Handle<ScopeInfo> scope_info(shared->scope_info()); | 
| 11470 | 11478 | 
| 11471 // Parameters. | 11479 // Parameters. | 
| 11472 for (int i = 0; i < scope_info->ParameterCount(); ++i) { | 11480 for (int i = 0; i < scope_info->ParameterCount(); ++i) { | 
| 11481 // Shadowed parameters were not materialized. | |
| 11482 if (ParameterIsShadowedByContextLocal(scope_info, i)) continue; | |
| 11483 | |
| 11473 ASSERT(!frame->GetParameter(i)->IsTheHole()); | 11484 ASSERT(!frame->GetParameter(i)->IsTheHole()); | 
| 11474 HandleScope scope(isolate); | 11485 HandleScope scope(isolate); | 
| 11475 Handle<Object> value = GetProperty( | 11486 Handle<String> name(scope_info->ParameterName(i)); | 
| 11476 isolate, target, Handle<String>(scope_info->ParameterName(i))); | 11487 Handle<Object> value = GetProperty(isolate, target, name); | 
| 11477 frame->SetParameterValue(i, *value); | 11488 frame->SetParameterValue(i, *value); | 
| 11478 } | 11489 } | 
| 11479 | 11490 | 
| 11480 // Stack locals. | 11491 // Stack locals. | 
| 11481 for (int i = 0; i < scope_info->StackLocalCount(); ++i) { | 11492 for (int i = 0; i < scope_info->StackLocalCount(); ++i) { | 
| 11482 if (frame->GetExpression(i)->IsTheHole()) continue; | 11493 if (frame->GetExpression(i)->IsTheHole()) continue; | 
| 11483 HandleScope scope(isolate); | 11494 HandleScope scope(isolate); | 
| 11484 Handle<Object> value = GetProperty( | 11495 Handle<Object> value = GetProperty( | 
| 11485 isolate, target, Handle<String>(scope_info->StackLocalName(i))); | 11496 isolate, target, Handle<String>(scope_info->StackLocalName(i))); | 
| 11486 frame->SetExpression(i, *value); | 11497 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 | 15071 // Handle last resort GC and make sure to allow future allocations | 
| 15061 // to grow the heap without causing GCs (if possible). | 15072 // to grow the heap without causing GCs (if possible). | 
| 15062 isolate->counters()->gc_last_resort_from_js()->Increment(); | 15073 isolate->counters()->gc_last_resort_from_js()->Increment(); | 
| 15063 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, | 15074 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, | 
| 15064 "Runtime::PerformGC"); | 15075 "Runtime::PerformGC"); | 
| 15065 } | 15076 } | 
| 15066 } | 15077 } | 
| 15067 | 15078 | 
| 15068 | 15079 | 
| 15069 } } // namespace v8::internal | 15080 } } // namespace v8::internal | 
| OLD | NEW |