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 11181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11192 // Check for constructor frame. | 11192 // Check for constructor frame. |
11193 bool constructor = frame_inspector.IsConstructor(); | 11193 bool constructor = frame_inspector.IsConstructor(); |
11194 | 11194 |
11195 // Get scope info and read from it for local variable information. | 11195 // Get scope info and read from it for local variable information. |
11196 Handle<JSFunction> function(JSFunction::cast(frame_inspector.GetFunction())); | 11196 Handle<JSFunction> function(JSFunction::cast(frame_inspector.GetFunction())); |
11197 Handle<SharedFunctionInfo> shared(function->shared()); | 11197 Handle<SharedFunctionInfo> shared(function->shared()); |
11198 Handle<ScopeInfo> scope_info(shared->scope_info()); | 11198 Handle<ScopeInfo> scope_info(shared->scope_info()); |
11199 ASSERT(*scope_info != ScopeInfo::Empty(isolate)); | 11199 ASSERT(*scope_info != ScopeInfo::Empty(isolate)); |
11200 | 11200 |
11201 // Get the locals names and values into a temporary array. | 11201 // Get the locals names and values into a temporary array. |
11202 // | 11202 int local_count = scope_info->LocalCount(); |
11203 // TODO(1240907): Hide compiler-introduced stack variables | 11203 for (int slot = 0; slot < scope_info->LocalCount(); ++slot) { |
11204 // (e.g. .result)? For users of the debugger, they will probably be | 11204 // Hide compiler-introduced temporary variables, whether on the stack or on |
11205 // confusing. | 11205 // the context. |
| 11206 if (scope_info->LocalIsSynthetic(slot)) |
| 11207 local_count--; |
| 11208 } |
| 11209 |
11206 Handle<FixedArray> locals = | 11210 Handle<FixedArray> locals = |
11207 isolate->factory()->NewFixedArray(scope_info->LocalCount() * 2); | 11211 isolate->factory()->NewFixedArray(local_count * 2); |
11208 | 11212 |
11209 // Fill in the values of the locals. | 11213 // Fill in the values of the locals. |
| 11214 int local = 0; |
11210 int i = 0; | 11215 int i = 0; |
11211 for (; i < scope_info->StackLocalCount(); ++i) { | 11216 for (; i < scope_info->StackLocalCount(); ++i) { |
11212 // Use the value from the stack. | 11217 // Use the value from the stack. |
11213 locals->set(i * 2, scope_info->LocalName(i)); | 11218 if (scope_info->LocalIsSynthetic(i)) |
11214 locals->set(i * 2 + 1, frame_inspector.GetExpression(i)); | 11219 continue; |
| 11220 locals->set(local * 2, scope_info->LocalName(i)); |
| 11221 locals->set(local * 2 + 1, frame_inspector.GetExpression(i)); |
| 11222 local++; |
11215 } | 11223 } |
11216 if (i < scope_info->LocalCount()) { | 11224 if (local < local_count) { |
11217 // Get the context containing declarations. | 11225 // Get the context containing declarations. |
11218 Handle<Context> context( | 11226 Handle<Context> context( |
11219 Context::cast(it.frame()->context())->declaration_context()); | 11227 Context::cast(it.frame()->context())->declaration_context()); |
11220 for (; i < scope_info->LocalCount(); ++i) { | 11228 for (; i < scope_info->LocalCount(); ++i) { |
| 11229 if (scope_info->LocalIsSynthetic(i)) |
| 11230 continue; |
11221 Handle<String> name(scope_info->LocalName(i)); | 11231 Handle<String> name(scope_info->LocalName(i)); |
11222 VariableMode mode; | 11232 VariableMode mode; |
11223 InitializationFlag init_flag; | 11233 InitializationFlag init_flag; |
11224 locals->set(i * 2, *name); | 11234 locals->set(local * 2, *name); |
11225 int context_slot_index = | 11235 int context_slot_index = |
11226 scope_info->ContextSlotIndex(*name, &mode, &init_flag); | 11236 scope_info->ContextSlotIndex(*name, &mode, &init_flag); |
11227 Object* value = context->get(context_slot_index); | 11237 Object* value = context->get(context_slot_index); |
11228 locals->set(i * 2 + 1, value); | 11238 locals->set(local * 2 + 1, value); |
| 11239 local++; |
11229 } | 11240 } |
11230 } | 11241 } |
11231 | 11242 |
11232 // Check whether this frame is positioned at return. If not top | 11243 // Check whether this frame is positioned at return. If not top |
11233 // frame or if the frame is optimized it cannot be at a return. | 11244 // frame or if the frame is optimized it cannot be at a return. |
11234 bool at_return = false; | 11245 bool at_return = false; |
11235 if (!is_optimized && index == 0) { | 11246 if (!is_optimized && index == 0) { |
11236 at_return = isolate->debug()->IsBreakAtReturn(it.frame()); | 11247 at_return = isolate->debug()->IsBreakAtReturn(it.frame()); |
11237 } | 11248 } |
11238 | 11249 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11279 | 11290 |
11280 // Find the number of arguments to fill. At least fill the number of | 11291 // Find the number of arguments to fill. At least fill the number of |
11281 // parameters for the function and fill more if more parameters are provided. | 11292 // parameters for the function and fill more if more parameters are provided. |
11282 int argument_count = scope_info->ParameterCount(); | 11293 int argument_count = scope_info->ParameterCount(); |
11283 if (argument_count < frame_inspector.GetParametersCount()) { | 11294 if (argument_count < frame_inspector.GetParametersCount()) { |
11284 argument_count = frame_inspector.GetParametersCount(); | 11295 argument_count = frame_inspector.GetParametersCount(); |
11285 } | 11296 } |
11286 | 11297 |
11287 // Calculate the size of the result. | 11298 // Calculate the size of the result. |
11288 int details_size = kFrameDetailsFirstDynamicIndex + | 11299 int details_size = kFrameDetailsFirstDynamicIndex + |
11289 2 * (argument_count + scope_info->LocalCount()) + | 11300 2 * (argument_count + local_count) + |
11290 (at_return ? 1 : 0); | 11301 (at_return ? 1 : 0); |
11291 Handle<FixedArray> details = isolate->factory()->NewFixedArray(details_size); | 11302 Handle<FixedArray> details = isolate->factory()->NewFixedArray(details_size); |
11292 | 11303 |
11293 // Add the frame id. | 11304 // Add the frame id. |
11294 details->set(kFrameDetailsFrameIdIndex, *frame_id); | 11305 details->set(kFrameDetailsFrameIdIndex, *frame_id); |
11295 | 11306 |
11296 // Add the function (same as in function frame). | 11307 // Add the function (same as in function frame). |
11297 details->set(kFrameDetailsFunctionIndex, frame_inspector.GetFunction()); | 11308 details->set(kFrameDetailsFunctionIndex, frame_inspector.GetFunction()); |
11298 | 11309 |
11299 // Add the arguments count. | 11310 // Add the arguments count. |
11300 details->set(kFrameDetailsArgumentCountIndex, Smi::FromInt(argument_count)); | 11311 details->set(kFrameDetailsArgumentCountIndex, Smi::FromInt(argument_count)); |
11301 | 11312 |
11302 // Add the locals count | 11313 // Add the locals count |
11303 details->set(kFrameDetailsLocalCountIndex, | 11314 details->set(kFrameDetailsLocalCountIndex, |
11304 Smi::FromInt(scope_info->LocalCount())); | 11315 Smi::FromInt(local_count)); |
11305 | 11316 |
11306 // Add the source position. | 11317 // Add the source position. |
11307 if (position != RelocInfo::kNoPosition) { | 11318 if (position != RelocInfo::kNoPosition) { |
11308 details->set(kFrameDetailsSourcePositionIndex, Smi::FromInt(position)); | 11319 details->set(kFrameDetailsSourcePositionIndex, Smi::FromInt(position)); |
11309 } else { | 11320 } else { |
11310 details->set(kFrameDetailsSourcePositionIndex, heap->undefined_value()); | 11321 details->set(kFrameDetailsSourcePositionIndex, heap->undefined_value()); |
11311 } | 11322 } |
11312 | 11323 |
11313 // Add the constructor information. | 11324 // Add the constructor information. |
11314 details->set(kFrameDetailsConstructCallIndex, heap->ToBoolean(constructor)); | 11325 details->set(kFrameDetailsConstructCallIndex, heap->ToBoolean(constructor)); |
(...skipping 30 matching lines...) Expand all Loading... |
11345 // Parameter value. | 11356 // Parameter value. |
11346 if (i < frame_inspector.GetParametersCount()) { | 11357 if (i < frame_inspector.GetParametersCount()) { |
11347 // Get the value from the stack. | 11358 // Get the value from the stack. |
11348 details->set(details_index++, frame_inspector.GetParameter(i)); | 11359 details->set(details_index++, frame_inspector.GetParameter(i)); |
11349 } else { | 11360 } else { |
11350 details->set(details_index++, heap->undefined_value()); | 11361 details->set(details_index++, heap->undefined_value()); |
11351 } | 11362 } |
11352 } | 11363 } |
11353 | 11364 |
11354 // Add locals name and value from the temporary copy from the function frame. | 11365 // Add locals name and value from the temporary copy from the function frame. |
11355 for (int i = 0; i < scope_info->LocalCount() * 2; i++) { | 11366 for (int i = 0; i < local_count * 2; i++) { |
11356 details->set(details_index++, locals->get(i)); | 11367 details->set(details_index++, locals->get(i)); |
11357 } | 11368 } |
11358 | 11369 |
11359 // Add the value being returned. | 11370 // Add the value being returned. |
11360 if (at_return) { | 11371 if (at_return) { |
11361 details->set(details_index++, *return_value); | 11372 details->set(details_index++, *return_value); |
11362 } | 11373 } |
11363 | 11374 |
11364 // Add the receiver (same as in function frame). | 11375 // Add the receiver (same as in function frame). |
11365 // THIS MUST BE DONE LAST SINCE WE MIGHT ADVANCE | 11376 // THIS MUST BE DONE LAST SINCE WE MIGHT ADVANCE |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11426 Handle<String> name(scope_info->ParameterName(i)); | 11437 Handle<String> name(scope_info->ParameterName(i)); |
11427 | 11438 |
11428 RETURN_ON_EXCEPTION( | 11439 RETURN_ON_EXCEPTION( |
11429 isolate, | 11440 isolate, |
11430 Runtime::SetObjectProperty(isolate, target, name, value, NONE, SLOPPY), | 11441 Runtime::SetObjectProperty(isolate, target, name, value, NONE, SLOPPY), |
11431 JSObject); | 11442 JSObject); |
11432 } | 11443 } |
11433 | 11444 |
11434 // Second fill all stack locals. | 11445 // Second fill all stack locals. |
11435 for (int i = 0; i < scope_info->StackLocalCount(); ++i) { | 11446 for (int i = 0; i < scope_info->StackLocalCount(); ++i) { |
| 11447 if (scope_info->LocalIsSynthetic(i)) continue; |
11436 Handle<String> name(scope_info->StackLocalName(i)); | 11448 Handle<String> name(scope_info->StackLocalName(i)); |
11437 Handle<Object> value(frame_inspector->GetExpression(i), isolate); | 11449 Handle<Object> value(frame_inspector->GetExpression(i), isolate); |
11438 if (value->IsTheHole()) continue; | 11450 if (value->IsTheHole()) continue; |
11439 | 11451 |
11440 RETURN_ON_EXCEPTION( | 11452 RETURN_ON_EXCEPTION( |
11441 isolate, | 11453 isolate, |
11442 Runtime::SetObjectProperty(isolate, target, name, value, NONE, SLOPPY), | 11454 Runtime::SetObjectProperty(isolate, target, name, value, NONE, SLOPPY), |
11443 JSObject); | 11455 JSObject); |
11444 } | 11456 } |
11445 | 11457 |
(...skipping 24 matching lines...) Expand all Loading... |
11470 ASSERT(!frame->GetParameter(i)->IsTheHole()); | 11482 ASSERT(!frame->GetParameter(i)->IsTheHole()); |
11471 HandleScope scope(isolate); | 11483 HandleScope scope(isolate); |
11472 Handle<String> name(scope_info->ParameterName(i)); | 11484 Handle<String> name(scope_info->ParameterName(i)); |
11473 Handle<Object> value = | 11485 Handle<Object> value = |
11474 Object::GetPropertyOrElement(target, name).ToHandleChecked(); | 11486 Object::GetPropertyOrElement(target, name).ToHandleChecked(); |
11475 frame->SetParameterValue(i, *value); | 11487 frame->SetParameterValue(i, *value); |
11476 } | 11488 } |
11477 | 11489 |
11478 // Stack locals. | 11490 // Stack locals. |
11479 for (int i = 0; i < scope_info->StackLocalCount(); ++i) { | 11491 for (int i = 0; i < scope_info->StackLocalCount(); ++i) { |
| 11492 if (scope_info->LocalIsSynthetic(i)) continue; |
11480 if (frame->GetExpression(i)->IsTheHole()) continue; | 11493 if (frame->GetExpression(i)->IsTheHole()) continue; |
11481 HandleScope scope(isolate); | 11494 HandleScope scope(isolate); |
11482 Handle<Object> value = Object::GetPropertyOrElement( | 11495 Handle<Object> value = Object::GetPropertyOrElement( |
11483 target, | 11496 target, |
11484 handle(scope_info->StackLocalName(i), isolate)).ToHandleChecked(); | 11497 handle(scope_info->StackLocalName(i), isolate)).ToHandleChecked(); |
11485 frame->SetExpression(i, *value); | 11498 frame->SetExpression(i, *value); |
11486 } | 11499 } |
11487 } | 11500 } |
11488 | 11501 |
11489 | 11502 |
(...skipping 3641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15131 } | 15144 } |
15132 } | 15145 } |
15133 | 15146 |
15134 | 15147 |
15135 void Runtime::OutOfMemory() { | 15148 void Runtime::OutOfMemory() { |
15136 Heap::FatalProcessOutOfMemory("CALL_AND_RETRY_LAST", true); | 15149 Heap::FatalProcessOutOfMemory("CALL_AND_RETRY_LAST", true); |
15137 UNREACHABLE(); | 15150 UNREACHABLE(); |
15138 } | 15151 } |
15139 | 15152 |
15140 } } // namespace v8::internal | 15153 } } // namespace v8::internal |
OLD | NEW |