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/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/accessors.h" | 7 #include "src/accessors.h" |
8 #include "src/arguments.h" | 8 #include "src/arguments.h" |
9 #include "src/compiler.h" | 9 #include "src/compiler.h" |
10 #include "src/debug.h" | 10 #include "src/debug.h" |
(...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
674 local++; | 674 local++; |
675 } | 675 } |
676 if (local < local_count) { | 676 if (local < local_count) { |
677 // Get the context containing declarations. | 677 // Get the context containing declarations. |
678 Handle<Context> context( | 678 Handle<Context> context( |
679 Context::cast(frame_inspector.GetContext())->declaration_context()); | 679 Context::cast(frame_inspector.GetContext())->declaration_context()); |
680 for (; i < scope_info->LocalCount(); ++i) { | 680 for (; i < scope_info->LocalCount(); ++i) { |
681 if (scope_info->LocalIsSynthetic(i)) continue; | 681 if (scope_info->LocalIsSynthetic(i)) continue; |
682 Handle<String> name(scope_info->LocalName(i)); | 682 Handle<String> name(scope_info->LocalName(i)); |
683 VariableMode mode; | 683 VariableMode mode; |
| 684 VariableLocation location; |
684 InitializationFlag init_flag; | 685 InitializationFlag init_flag; |
685 MaybeAssignedFlag maybe_assigned_flag; | 686 MaybeAssignedFlag maybe_assigned_flag; |
686 locals->set(local * 2, *name); | 687 locals->set(local * 2, *name); |
687 int context_slot_index = ScopeInfo::ContextSlotIndex( | 688 int context_slot_index = ScopeInfo::ContextSlotIndex( |
688 scope_info, name, &mode, &init_flag, &maybe_assigned_flag); | 689 scope_info, name, &mode, &location, &init_flag, &maybe_assigned_flag); |
| 690 DCHECK(VariableLocation::CONTEXT == location); |
689 Object* value = context->get(context_slot_index); | 691 Object* value = context->get(context_slot_index); |
690 locals->set(local * 2 + 1, value); | 692 locals->set(local * 2 + 1, value); |
691 local++; | 693 local++; |
692 } | 694 } |
693 } | 695 } |
694 | 696 |
695 // Check whether this frame is positioned at return. If not top | 697 // Check whether this frame is positioned at return. If not top |
696 // frame or if the frame is optimized it cannot be at a return. | 698 // frame or if the frame is optimized it cannot be at a return. |
697 bool at_return = false; | 699 bool at_return = false; |
698 if (!is_optimized && index == 0) { | 700 if (!is_optimized && index == 0) { |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
849 details->set(kFrameDetailsReceiverIndex, *receiver); | 851 details->set(kFrameDetailsReceiverIndex, *receiver); |
850 | 852 |
851 DCHECK_EQ(details_size, details_index); | 853 DCHECK_EQ(details_size, details_index); |
852 return *isolate->factory()->NewJSArrayWithElements(details); | 854 return *isolate->factory()->NewJSArrayWithElements(details); |
853 } | 855 } |
854 | 856 |
855 | 857 |
856 static bool ParameterIsShadowedByContextLocal(Handle<ScopeInfo> info, | 858 static bool ParameterIsShadowedByContextLocal(Handle<ScopeInfo> info, |
857 Handle<String> parameter_name) { | 859 Handle<String> parameter_name) { |
858 VariableMode mode; | 860 VariableMode mode; |
| 861 VariableLocation location; |
859 InitializationFlag init_flag; | 862 InitializationFlag init_flag; |
860 MaybeAssignedFlag maybe_assigned_flag; | 863 MaybeAssignedFlag maybe_assigned_flag; |
861 return ScopeInfo::ContextSlotIndex(info, parameter_name, &mode, &init_flag, | 864 return ScopeInfo::ContextSlotIndex(info, parameter_name, &mode, &location, |
862 &maybe_assigned_flag) != -1; | 865 &init_flag, &maybe_assigned_flag) != -1; |
863 } | 866 } |
864 | 867 |
865 | 868 |
866 static Handle<Context> MaterializeReceiver(Isolate* isolate, | 869 static Handle<Context> MaterializeReceiver(Isolate* isolate, |
867 Handle<Context> target, | 870 Handle<Context> target, |
868 Handle<JSFunction> function, | 871 Handle<JSFunction> function, |
869 JavaScriptFrame* frame) { | 872 JavaScriptFrame* frame) { |
870 Handle<SharedFunctionInfo> shared(function->shared()); | 873 Handle<SharedFunctionInfo> shared(function->shared()); |
871 Handle<ScopeInfo> scope_info(shared->scope_info()); | 874 Handle<ScopeInfo> scope_info(shared->scope_info()); |
872 Handle<Object> receiver; | 875 Handle<Object> receiver; |
873 switch (scope_info->scope_type()) { | 876 switch (scope_info->scope_type()) { |
874 case FUNCTION_SCOPE: { | 877 case FUNCTION_SCOPE: { |
875 VariableMode variable_mode; | 878 VariableMode mode; |
| 879 VariableLocation location; |
876 InitializationFlag init_flag; | 880 InitializationFlag init_flag; |
877 MaybeAssignedFlag maybe_assigned_flag; | 881 MaybeAssignedFlag maybe_assigned_flag; |
878 | 882 |
879 // Don't bother creating a fake context node if "this" is in the context | 883 // Don't bother creating a fake context node if "this" is in the context |
880 // already. | 884 // already. |
881 if (ScopeInfo::ContextSlotIndex( | 885 if (ScopeInfo::ContextSlotIndex( |
882 scope_info, isolate->factory()->this_string(), &variable_mode, | 886 scope_info, isolate->factory()->this_string(), &mode, &location, |
883 &init_flag, &maybe_assigned_flag) >= 0) { | 887 &init_flag, &maybe_assigned_flag) >= 0) { |
884 return target; | 888 return target; |
885 } | 889 } |
886 receiver = handle(frame->receiver(), isolate); | 890 receiver = handle(frame->receiver(), isolate); |
887 break; | 891 break; |
888 } | 892 } |
889 case MODULE_SCOPE: | 893 case MODULE_SCOPE: |
890 receiver = isolate->factory()->undefined_value(); | 894 receiver = isolate->factory()->undefined_value(); |
891 break; | 895 break; |
892 case SCRIPT_SCOPE: | 896 case SCRIPT_SCOPE: |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1070 | 1074 |
1071 // Set the context local variable value. | 1075 // Set the context local variable value. |
1072 static bool SetContextLocalValue(Isolate* isolate, Handle<ScopeInfo> scope_info, | 1076 static bool SetContextLocalValue(Isolate* isolate, Handle<ScopeInfo> scope_info, |
1073 Handle<Context> context, | 1077 Handle<Context> context, |
1074 Handle<String> variable_name, | 1078 Handle<String> variable_name, |
1075 Handle<Object> new_value) { | 1079 Handle<Object> new_value) { |
1076 for (int i = 0; i < scope_info->ContextLocalCount(); i++) { | 1080 for (int i = 0; i < scope_info->ContextLocalCount(); i++) { |
1077 Handle<String> next_name(scope_info->ContextLocalName(i)); | 1081 Handle<String> next_name(scope_info->ContextLocalName(i)); |
1078 if (String::Equals(variable_name, next_name)) { | 1082 if (String::Equals(variable_name, next_name)) { |
1079 VariableMode mode; | 1083 VariableMode mode; |
| 1084 VariableLocation location; |
1080 InitializationFlag init_flag; | 1085 InitializationFlag init_flag; |
1081 MaybeAssignedFlag maybe_assigned_flag; | 1086 MaybeAssignedFlag maybe_assigned_flag; |
1082 int context_index = ScopeInfo::ContextSlotIndex( | 1087 int context_index = |
1083 scope_info, next_name, &mode, &init_flag, &maybe_assigned_flag); | 1088 ScopeInfo::ContextSlotIndex(scope_info, next_name, &mode, &location, |
| 1089 &init_flag, &maybe_assigned_flag); |
1084 context->set(context_index, *new_value); | 1090 context->set(context_index, *new_value); |
1085 return true; | 1091 return true; |
1086 } | 1092 } |
1087 } | 1093 } |
1088 | 1094 |
1089 return false; | 1095 return false; |
1090 } | 1096 } |
1091 | 1097 |
1092 | 1098 |
1093 static bool SetLocalVariableValue(Isolate* isolate, JavaScriptFrame* frame, | 1099 static bool SetLocalVariableValue(Isolate* isolate, JavaScriptFrame* frame, |
(...skipping 1570 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2664 isolate, context_builder.outer_info(), | 2670 isolate, context_builder.outer_info(), |
2665 context_builder.innermost_context(), context_extension, receiver, source); | 2671 context_builder.innermost_context(), context_extension, receiver, source); |
2666 | 2672 |
2667 Handle<Object> result; | 2673 Handle<Object> result; |
2668 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, maybe_result); | 2674 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, maybe_result); |
2669 context_builder.UpdateVariables(); | 2675 context_builder.UpdateVariables(); |
2670 return *result; | 2676 return *result; |
2671 } | 2677 } |
2672 | 2678 |
2673 | 2679 |
| 2680 static inline bool IsDebugContext(Isolate* isolate, Context* context) { |
| 2681 // Try to unwrap script context if it exist. |
| 2682 if (context->IsScriptContext()) context = context->previous(); |
| 2683 DCHECK_NOT_NULL(context); |
| 2684 return context == *isolate->debug()->debug_context(); |
| 2685 } |
| 2686 |
| 2687 |
2674 RUNTIME_FUNCTION(Runtime_DebugEvaluateGlobal) { | 2688 RUNTIME_FUNCTION(Runtime_DebugEvaluateGlobal) { |
2675 HandleScope scope(isolate); | 2689 HandleScope scope(isolate); |
2676 | 2690 |
2677 // Check the execution state and decode arguments frame and source to be | 2691 // Check the execution state and decode arguments frame and source to be |
2678 // evaluated. | 2692 // evaluated. |
2679 DCHECK(args.length() == 4); | 2693 DCHECK(args.length() == 4); |
2680 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); | 2694 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); |
2681 RUNTIME_ASSERT(isolate->debug()->CheckExecutionState(break_id)); | 2695 RUNTIME_ASSERT(isolate->debug()->CheckExecutionState(break_id)); |
2682 | 2696 |
2683 CONVERT_ARG_HANDLE_CHECKED(String, source, 1); | 2697 CONVERT_ARG_HANDLE_CHECKED(String, source, 1); |
2684 CONVERT_BOOLEAN_ARG_CHECKED(disable_break, 2); | 2698 CONVERT_BOOLEAN_ARG_CHECKED(disable_break, 2); |
2685 CONVERT_ARG_HANDLE_CHECKED(Object, context_extension, 3); | 2699 CONVERT_ARG_HANDLE_CHECKED(Object, context_extension, 3); |
2686 | 2700 |
2687 // Handle the processing of break. | 2701 // Handle the processing of break. |
2688 DisableBreak disable_break_scope(isolate->debug(), disable_break); | 2702 DisableBreak disable_break_scope(isolate->debug(), disable_break); |
2689 | 2703 |
2690 // Enter the top context from before the debugger was invoked. | 2704 // Enter the top context from before the debugger was invoked. |
2691 SaveContext save(isolate); | 2705 SaveContext save(isolate); |
2692 SaveContext* top = &save; | 2706 SaveContext* top = &save; |
2693 while (top != NULL && *top->context() == *isolate->debug()->debug_context()) { | 2707 while (top != NULL && IsDebugContext(isolate, *top->context())) { |
2694 top = top->prev(); | 2708 top = top->prev(); |
2695 } | 2709 } |
2696 if (top != NULL) { | 2710 if (top != NULL) { |
2697 isolate->set_context(*top->context()); | 2711 isolate->set_context(*top->context()); |
2698 } | 2712 } |
2699 | 2713 |
2700 // Get the native context now set to the top context from before the | 2714 // Get the native context now set to the top context from before the |
2701 // debugger was invoked. | 2715 // debugger was invoked. |
2702 Handle<Context> context = isolate->native_context(); | 2716 Handle<Context> context = isolate->native_context(); |
2703 Handle<JSObject> receiver(context->global_proxy()); | 2717 Handle<JSObject> receiver(context->global_proxy()); |
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3197 return Smi::FromInt(isolate->debug()->is_active()); | 3211 return Smi::FromInt(isolate->debug()->is_active()); |
3198 } | 3212 } |
3199 | 3213 |
3200 | 3214 |
3201 RUNTIME_FUNCTION(Runtime_DebugBreakInOptimizedCode) { | 3215 RUNTIME_FUNCTION(Runtime_DebugBreakInOptimizedCode) { |
3202 UNIMPLEMENTED(); | 3216 UNIMPLEMENTED(); |
3203 return NULL; | 3217 return NULL; |
3204 } | 3218 } |
3205 } // namespace internal | 3219 } // namespace internal |
3206 } // namespace v8 | 3220 } // namespace v8 |
OLD | NEW |