| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/runtime/runtime-utils.h" | 5 #include "src/runtime/runtime-utils.h" |
| 6 | 6 |
| 7 #include "src/arguments.h" | 7 #include "src/arguments.h" |
| 8 #include "src/debug/debug.h" | 8 #include "src/debug/debug.h" |
| 9 #include "src/debug/debug-evaluate.h" | 9 #include "src/debug/debug-evaluate.h" |
| 10 #include "src/debug/debug-frames.h" | 10 #include "src/debug/debug-frames.h" |
| (...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 521 Handle<Object> frame_id(DebugFrameHelper::WrapFrameId(it.frame()->id()), | 521 Handle<Object> frame_id(DebugFrameHelper::WrapFrameId(it.frame()->id()), |
| 522 isolate); | 522 isolate); |
| 523 | 523 |
| 524 // Find source position in unoptimized code. | 524 // Find source position in unoptimized code. |
| 525 int position = frame_inspector.GetSourcePosition(); | 525 int position = frame_inspector.GetSourcePosition(); |
| 526 | 526 |
| 527 // Check for constructor frame. | 527 // Check for constructor frame. |
| 528 bool constructor = frame_inspector.IsConstructor(); | 528 bool constructor = frame_inspector.IsConstructor(); |
| 529 | 529 |
| 530 // Get scope info and read from it for local variable information. | 530 // Get scope info and read from it for local variable information. |
| 531 Handle<JSFunction> function(JSFunction::cast(frame_inspector.GetFunction())); | 531 Handle<JSFunction> function = |
| 532 Handle<JSFunction>::cast(frame_inspector.GetFunction()); |
| 532 RUNTIME_ASSERT(function->shared()->IsSubjectToDebugging()); | 533 RUNTIME_ASSERT(function->shared()->IsSubjectToDebugging()); |
| 533 Handle<SharedFunctionInfo> shared(function->shared()); | 534 Handle<SharedFunctionInfo> shared(function->shared()); |
| 534 Handle<ScopeInfo> scope_info(shared->scope_info()); | 535 Handle<ScopeInfo> scope_info(shared->scope_info()); |
| 535 DCHECK(*scope_info != ScopeInfo::Empty(isolate)); | 536 DCHECK(*scope_info != ScopeInfo::Empty(isolate)); |
| 536 | 537 |
| 537 // Get the locals names and values into a temporary array. | 538 // Get the locals names and values into a temporary array. |
| 538 int local_count = scope_info->LocalCount(); | 539 int local_count = scope_info->LocalCount(); |
| 539 for (int slot = 0; slot < scope_info->LocalCount(); ++slot) { | 540 for (int slot = 0; slot < scope_info->LocalCount(); ++slot) { |
| 540 // Hide compiler-introduced temporary variables, whether on the stack or on | 541 // Hide compiler-introduced temporary variables, whether on the stack or on |
| 541 // the context. | 542 // the context. |
| 542 if (scope_info->LocalIsSynthetic(slot)) local_count--; | 543 if (scope_info->LocalIsSynthetic(slot)) local_count--; |
| 543 } | 544 } |
| 544 | 545 |
| 545 Handle<FixedArray> locals = | 546 Handle<FixedArray> locals = |
| 546 isolate->factory()->NewFixedArray(local_count * 2); | 547 isolate->factory()->NewFixedArray(local_count * 2); |
| 547 | 548 |
| 548 // Fill in the values of the locals. | 549 // Fill in the values of the locals. |
| 549 int local = 0; | 550 int local = 0; |
| 550 int i = 0; | 551 int i = 0; |
| 551 for (; i < scope_info->StackLocalCount(); ++i) { | 552 for (; i < scope_info->StackLocalCount(); ++i) { |
| 552 // Use the value from the stack. | 553 // Use the value from the stack. |
| 553 if (scope_info->LocalIsSynthetic(i)) continue; | 554 if (scope_info->LocalIsSynthetic(i)) continue; |
| 554 locals->set(local * 2, scope_info->LocalName(i)); | 555 locals->set(local * 2, scope_info->LocalName(i)); |
| 555 locals->set(local * 2 + 1, frame_inspector.GetExpression(i)); | 556 locals->set(local * 2 + 1, *(frame_inspector.GetExpression(i))); |
| 556 local++; | 557 local++; |
| 557 } | 558 } |
| 558 if (local < local_count) { | 559 if (local < local_count) { |
| 559 // Get the context containing declarations. | 560 // Get the context containing declarations. |
| 560 Handle<Context> context( | 561 Handle<Context> context( |
| 561 Context::cast(frame_inspector.GetContext())->closure_context()); | 562 Handle<Context>::cast(frame_inspector.GetContext())->closure_context()); |
| 562 for (; i < scope_info->LocalCount(); ++i) { | 563 for (; i < scope_info->LocalCount(); ++i) { |
| 563 if (scope_info->LocalIsSynthetic(i)) continue; | 564 if (scope_info->LocalIsSynthetic(i)) continue; |
| 564 Handle<String> name(scope_info->LocalName(i)); | 565 Handle<String> name(scope_info->LocalName(i)); |
| 565 VariableMode mode; | 566 VariableMode mode; |
| 566 InitializationFlag init_flag; | 567 InitializationFlag init_flag; |
| 567 MaybeAssignedFlag maybe_assigned_flag; | 568 MaybeAssignedFlag maybe_assigned_flag; |
| 568 locals->set(local * 2, *name); | 569 locals->set(local * 2, *name); |
| 569 int context_slot_index = ScopeInfo::ContextSlotIndex( | 570 int context_slot_index = ScopeInfo::ContextSlotIndex( |
| 570 scope_info, name, &mode, &init_flag, &maybe_assigned_flag); | 571 scope_info, name, &mode, &init_flag, &maybe_assigned_flag); |
| 571 Object* value = context->get(context_slot_index); | 572 Object* value = context->get(context_slot_index); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 630 | 631 |
| 631 // Calculate the size of the result. | 632 // Calculate the size of the result. |
| 632 int details_size = kFrameDetailsFirstDynamicIndex + | 633 int details_size = kFrameDetailsFirstDynamicIndex + |
| 633 2 * (argument_count + local_count) + (at_return ? 1 : 0); | 634 2 * (argument_count + local_count) + (at_return ? 1 : 0); |
| 634 Handle<FixedArray> details = isolate->factory()->NewFixedArray(details_size); | 635 Handle<FixedArray> details = isolate->factory()->NewFixedArray(details_size); |
| 635 | 636 |
| 636 // Add the frame id. | 637 // Add the frame id. |
| 637 details->set(kFrameDetailsFrameIdIndex, *frame_id); | 638 details->set(kFrameDetailsFrameIdIndex, *frame_id); |
| 638 | 639 |
| 639 // Add the function (same as in function frame). | 640 // Add the function (same as in function frame). |
| 640 details->set(kFrameDetailsFunctionIndex, frame_inspector.GetFunction()); | 641 details->set(kFrameDetailsFunctionIndex, *(frame_inspector.GetFunction())); |
| 641 | 642 |
| 642 // Add the arguments count. | 643 // Add the arguments count. |
| 643 details->set(kFrameDetailsArgumentCountIndex, Smi::FromInt(argument_count)); | 644 details->set(kFrameDetailsArgumentCountIndex, Smi::FromInt(argument_count)); |
| 644 | 645 |
| 645 // Add the locals count | 646 // Add the locals count |
| 646 details->set(kFrameDetailsLocalCountIndex, Smi::FromInt(local_count)); | 647 details->set(kFrameDetailsLocalCountIndex, Smi::FromInt(local_count)); |
| 647 | 648 |
| 648 // Add the source position. | 649 // Add the source position. |
| 649 if (position != RelocInfo::kNoPosition) { | 650 if (position != RelocInfo::kNoPosition) { |
| 650 details->set(kFrameDetailsSourcePositionIndex, Smi::FromInt(position)); | 651 details->set(kFrameDetailsSourcePositionIndex, Smi::FromInt(position)); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 680 // Name of the argument. | 681 // Name of the argument. |
| 681 if (i < scope_info->ParameterCount()) { | 682 if (i < scope_info->ParameterCount()) { |
| 682 details->set(details_index++, scope_info->ParameterName(i)); | 683 details->set(details_index++, scope_info->ParameterName(i)); |
| 683 } else { | 684 } else { |
| 684 details->set(details_index++, heap->undefined_value()); | 685 details->set(details_index++, heap->undefined_value()); |
| 685 } | 686 } |
| 686 | 687 |
| 687 // Parameter value. | 688 // Parameter value. |
| 688 if (i < frame_inspector.GetParametersCount()) { | 689 if (i < frame_inspector.GetParametersCount()) { |
| 689 // Get the value from the stack. | 690 // Get the value from the stack. |
| 690 details->set(details_index++, frame_inspector.GetParameter(i)); | 691 details->set(details_index++, *(frame_inspector.GetParameter(i))); |
| 691 } else { | 692 } else { |
| 692 details->set(details_index++, heap->undefined_value()); | 693 details->set(details_index++, heap->undefined_value()); |
| 693 } | 694 } |
| 694 } | 695 } |
| 695 | 696 |
| 696 // Add locals name and value from the temporary copy from the function frame. | 697 // Add locals name and value from the temporary copy from the function frame. |
| 697 for (int i = 0; i < local_count * 2; i++) { | 698 for (int i = 0; i < local_count * 2; i++) { |
| 698 details->set(details_index++, locals->get(i)); | 699 details->set(details_index++, locals->get(i)); |
| 699 } | 700 } |
| 700 | 701 |
| (...skipping 972 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1673 return Smi::FromInt(isolate->debug()->is_active()); | 1674 return Smi::FromInt(isolate->debug()->is_active()); |
| 1674 } | 1675 } |
| 1675 | 1676 |
| 1676 | 1677 |
| 1677 RUNTIME_FUNCTION(Runtime_DebugBreakInOptimizedCode) { | 1678 RUNTIME_FUNCTION(Runtime_DebugBreakInOptimizedCode) { |
| 1678 UNIMPLEMENTED(); | 1679 UNIMPLEMENTED(); |
| 1679 return NULL; | 1680 return NULL; |
| 1680 } | 1681 } |
| 1681 } // namespace internal | 1682 } // namespace internal |
| 1682 } // namespace v8 | 1683 } // namespace v8 |
| OLD | NEW |