OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 7953 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7964 | 7964 |
7965 // Loop over the actual parameters backwards. | 7965 // Loop over the actual parameters backwards. |
7966 int index = argument_count - 1; | 7966 int index = argument_count - 1; |
7967 while (index >= mapped_count) { | 7967 while (index >= mapped_count) { |
7968 // These go directly in the arguments array and have no | 7968 // These go directly in the arguments array and have no |
7969 // corresponding slot in the parameter map. | 7969 // corresponding slot in the parameter map. |
7970 arguments->set(index, *(parameters - index - 1)); | 7970 arguments->set(index, *(parameters - index - 1)); |
7971 --index; | 7971 --index; |
7972 } | 7972 } |
7973 | 7973 |
7974 ScopeInfo<> scope_info(callee->shared()->scope_info()); | 7974 Handle<ScopeInfo> scope_info(callee->shared()->scope_info()); |
7975 while (index >= 0) { | 7975 while (index >= 0) { |
7976 // Detect duplicate names to the right in the parameter list. | 7976 // Detect duplicate names to the right in the parameter list. |
7977 Handle<String> name = scope_info.parameter_name(index); | 7977 Handle<String> name = scope_info->parameter_name(index); |
7978 int context_slot_count = scope_info.number_of_context_slots(); | 7978 int context_local_count = scope_info->num_context_locals(); |
7979 bool duplicate = false; | 7979 bool duplicate = false; |
7980 for (int j = index + 1; j < parameter_count; ++j) { | 7980 for (int j = index + 1; j < parameter_count; ++j) { |
7981 if (scope_info.parameter_name(j).is_identical_to(name)) { | 7981 if (scope_info->parameter_name(j).is_identical_to(name)) { |
7982 duplicate = true; | 7982 duplicate = true; |
7983 break; | 7983 break; |
7984 } | 7984 } |
7985 } | 7985 } |
7986 | 7986 |
7987 if (duplicate) { | 7987 if (duplicate) { |
7988 // This goes directly in the arguments array with a hole in the | 7988 // This goes directly in the arguments array with a hole in the |
7989 // parameter map. | 7989 // parameter map. |
7990 arguments->set(index, *(parameters - index - 1)); | 7990 arguments->set(index, *(parameters - index - 1)); |
7991 parameter_map->set_the_hole(index + 2); | 7991 parameter_map->set_the_hole(index + 2); |
7992 } else { | 7992 } else { |
7993 // The context index goes in the parameter map with a hole in the | 7993 // The context index goes in the parameter map with a hole in the |
7994 // arguments array. | 7994 // arguments array. |
7995 int context_index = -1; | 7995 int context_index = -1; |
7996 for (int j = Context::MIN_CONTEXT_SLOTS; | 7996 for (int j = 0; j < context_local_count; ++j) { |
7997 j < context_slot_count; | 7997 if (scope_info->context_local_name(j).is_identical_to(name)) { |
7998 ++j) { | |
7999 if (scope_info.context_slot_name(j).is_identical_to(name)) { | |
8000 context_index = j; | 7998 context_index = j; |
8001 break; | 7999 break; |
8002 } | 8000 } |
8003 } | 8001 } |
8004 ASSERT(context_index >= 0); | 8002 ASSERT(context_index >= 0); |
8005 arguments->set_the_hole(index); | 8003 arguments->set_the_hole(index); |
8006 parameter_map->set(index + 2, Smi::FromInt(context_index)); | 8004 parameter_map->set(index + 2, Smi::FromInt( |
| 8005 Context::MIN_CONTEXT_SLOTS + context_index)); |
8007 } | 8006 } |
8008 | 8007 |
8009 --index; | 8008 --index; |
8010 } | 8009 } |
8011 } else { | 8010 } else { |
8012 // If there is no aliasing, the arguments object elements are not | 8011 // If there is no aliasing, the arguments object elements are not |
8013 // special in any way. | 8012 // special in any way. |
8014 Handle<FixedArray> elements = | 8013 Handle<FixedArray> elements = |
8015 isolate->factory()->NewFixedArray(argument_count, NOT_TENURED); | 8014 isolate->factory()->NewFixedArray(argument_count, NOT_TENURED); |
8016 result->set_elements(*elements); | 8015 result->set_elements(*elements); |
(...skipping 826 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8843 thrown_object); | 8842 thrown_object); |
8844 if (!maybe_context->To(&context)) return maybe_context; | 8843 if (!maybe_context->To(&context)) return maybe_context; |
8845 isolate->set_context(context); | 8844 isolate->set_context(context); |
8846 return context; | 8845 return context; |
8847 } | 8846 } |
8848 | 8847 |
8849 | 8848 |
8850 RUNTIME_FUNCTION(MaybeObject*, Runtime_PushBlockContext) { | 8849 RUNTIME_FUNCTION(MaybeObject*, Runtime_PushBlockContext) { |
8851 NoHandleAllocation ha; | 8850 NoHandleAllocation ha; |
8852 ASSERT(args.length() == 2); | 8851 ASSERT(args.length() == 2); |
8853 SerializedScopeInfo* scope_info = SerializedScopeInfo::cast(args[0]); | 8852 ScopeInfo* scope_info = ScopeInfo::cast(args[0]); |
8854 JSFunction* function; | 8853 JSFunction* function; |
8855 if (args[1]->IsSmi()) { | 8854 if (args[1]->IsSmi()) { |
8856 // A smi sentinel indicates a context nested inside global code rather | 8855 // A smi sentinel indicates a context nested inside global code rather |
8857 // than some function. There is a canonical empty function that can be | 8856 // than some function. There is a canonical empty function that can be |
8858 // gotten from the global context. | 8857 // gotten from the global context. |
8859 function = isolate->context()->global_context()->closure(); | 8858 function = isolate->context()->global_context()->closure(); |
8860 } else { | 8859 } else { |
8861 function = JSFunction::cast(args[1]); | 8860 function = JSFunction::cast(args[1]); |
8862 } | 8861 } |
8863 Context* context; | 8862 Context* context; |
(...skipping 1899 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10763 it.frame()->LookupCode()->SourcePosition(it.frame()->pc()); | 10762 it.frame()->LookupCode()->SourcePosition(it.frame()->pc()); |
10764 | 10763 |
10765 // Check for constructor frame. Inlined frames cannot be construct calls. | 10764 // Check for constructor frame. Inlined frames cannot be construct calls. |
10766 bool inlined_frame = | 10765 bool inlined_frame = |
10767 it.frame()->is_optimized() && inlined_frame_index != 0; | 10766 it.frame()->is_optimized() && inlined_frame_index != 0; |
10768 bool constructor = !inlined_frame && it.frame()->IsConstructor(); | 10767 bool constructor = !inlined_frame && it.frame()->IsConstructor(); |
10769 | 10768 |
10770 // Get scope info and read from it for local variable information. | 10769 // Get scope info and read from it for local variable information. |
10771 Handle<JSFunction> function(JSFunction::cast(it.frame()->function())); | 10770 Handle<JSFunction> function(JSFunction::cast(it.frame()->function())); |
10772 Handle<SharedFunctionInfo> shared(function->shared()); | 10771 Handle<SharedFunctionInfo> shared(function->shared()); |
10773 Handle<SerializedScopeInfo> scope_info(shared->scope_info()); | 10772 Handle<ScopeInfo> scope_info(shared->scope_info()); |
10774 ASSERT(*scope_info != SerializedScopeInfo::Empty()); | 10773 ASSERT(*scope_info != ScopeInfo::Empty()); |
10775 ScopeInfo<> info(*scope_info); | |
10776 | 10774 |
10777 // Get the locals names and values into a temporary array. | 10775 // Get the locals names and values into a temporary array. |
10778 // | 10776 // |
10779 // TODO(1240907): Hide compiler-introduced stack variables | 10777 // TODO(1240907): Hide compiler-introduced stack variables |
10780 // (e.g. .result)? For users of the debugger, they will probably be | 10778 // (e.g. .result)? For users of the debugger, they will probably be |
10781 // confusing. | 10779 // confusing. |
10782 Handle<FixedArray> locals = | 10780 Handle<FixedArray> locals = |
10783 isolate->factory()->NewFixedArray(info.NumberOfLocals() * 2); | 10781 isolate->factory()->NewFixedArray(scope_info->NumberOfLocals() * 2); |
10784 | 10782 |
10785 // Fill in the values of the locals. | 10783 // Fill in the values of the locals. |
10786 int i = 0; | 10784 int i = 0; |
10787 for (; i < info.number_of_stack_slots(); ++i) { | 10785 for (; i < scope_info->num_stack_locals(); ++i) { |
10788 // Use the value from the stack. | 10786 // Use the value from the stack. |
10789 locals->set(i * 2, *info.LocalName(i)); | 10787 locals->set(i * 2, *scope_info->local_name(i)); |
10790 locals->set(i * 2 + 1, frame_inspector.GetExpression(i)); | 10788 locals->set(i * 2 + 1, frame_inspector.GetExpression(i)); |
10791 } | 10789 } |
10792 if (i < info.NumberOfLocals()) { | 10790 if (i < scope_info->NumberOfLocals()) { |
10793 // Get the context containing declarations. | 10791 // Get the context containing declarations. |
10794 Handle<Context> context( | 10792 Handle<Context> context( |
10795 Context::cast(it.frame()->context())->declaration_context()); | 10793 Context::cast(it.frame()->context())->declaration_context()); |
10796 for (; i < info.NumberOfLocals(); ++i) { | 10794 for (; i < scope_info->NumberOfLocals(); ++i) { |
10797 Handle<String> name = info.LocalName(i); | 10795 Handle<String> name = scope_info->local_name(i); |
10798 locals->set(i * 2, *name); | 10796 locals->set(i * 2, *name); |
10799 locals->set(i * 2 + 1, | 10797 locals->set(i * 2 + 1, |
10800 context->get(scope_info->ContextSlotIndex(*name, NULL))); | 10798 context->get(scope_info->ContextSlotIndex(*name))); |
10801 } | 10799 } |
10802 } | 10800 } |
10803 | 10801 |
10804 // Check whether this frame is positioned at return. If not top | 10802 // Check whether this frame is positioned at return. If not top |
10805 // frame or if the frame is optimized it cannot be at a return. | 10803 // frame or if the frame is optimized it cannot be at a return. |
10806 bool at_return = false; | 10804 bool at_return = false; |
10807 if (!it.frame()->is_optimized() && index == 0) { | 10805 if (!it.frame()->is_optimized() && index == 0) { |
10808 at_return = isolate->debug()->IsBreakAtReturn(it.frame()); | 10806 at_return = isolate->debug()->IsBreakAtReturn(it.frame()); |
10809 } | 10807 } |
10810 | 10808 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10844 // the provided parameters whereas the function frame always have the number | 10842 // the provided parameters whereas the function frame always have the number |
10845 // of arguments matching the functions parameters. The rest of the | 10843 // of arguments matching the functions parameters. The rest of the |
10846 // information (except for what is collected above) is the same. | 10844 // information (except for what is collected above) is the same. |
10847 if (it.frame()->has_adapted_arguments()) { | 10845 if (it.frame()->has_adapted_arguments()) { |
10848 it.AdvanceToArgumentsFrame(); | 10846 it.AdvanceToArgumentsFrame(); |
10849 frame_inspector.SetArgumentsFrame(it.frame()); | 10847 frame_inspector.SetArgumentsFrame(it.frame()); |
10850 } | 10848 } |
10851 | 10849 |
10852 // Find the number of arguments to fill. At least fill the number of | 10850 // Find the number of arguments to fill. At least fill the number of |
10853 // parameters for the function and fill more if more parameters are provided. | 10851 // parameters for the function and fill more if more parameters are provided. |
10854 int argument_count = info.number_of_parameters(); | 10852 int argument_count = scope_info->num_parameters(); |
10855 if (argument_count < frame_inspector.GetParametersCount()) { | 10853 if (argument_count < frame_inspector.GetParametersCount()) { |
10856 argument_count = frame_inspector.GetParametersCount(); | 10854 argument_count = frame_inspector.GetParametersCount(); |
10857 } | 10855 } |
10858 #ifdef DEBUG | 10856 #ifdef DEBUG |
10859 if (it.frame()->is_optimized()) { | 10857 if (it.frame()->is_optimized()) { |
10860 ASSERT_EQ(argument_count, frame_inspector.GetParametersCount()); | 10858 ASSERT_EQ(argument_count, frame_inspector.GetParametersCount()); |
10861 } | 10859 } |
10862 #endif | 10860 #endif |
10863 | 10861 |
10864 // Calculate the size of the result. | 10862 // Calculate the size of the result. |
10865 int details_size = kFrameDetailsFirstDynamicIndex + | 10863 int details_size = kFrameDetailsFirstDynamicIndex + |
10866 2 * (argument_count + info.NumberOfLocals()) + | 10864 2 * (argument_count + scope_info->NumberOfLocals()) + |
10867 (at_return ? 1 : 0); | 10865 (at_return ? 1 : 0); |
10868 Handle<FixedArray> details = isolate->factory()->NewFixedArray(details_size); | 10866 Handle<FixedArray> details = isolate->factory()->NewFixedArray(details_size); |
10869 | 10867 |
10870 // Add the frame id. | 10868 // Add the frame id. |
10871 details->set(kFrameDetailsFrameIdIndex, *frame_id); | 10869 details->set(kFrameDetailsFrameIdIndex, *frame_id); |
10872 | 10870 |
10873 // Add the function (same as in function frame). | 10871 // Add the function (same as in function frame). |
10874 details->set(kFrameDetailsFunctionIndex, frame_inspector.GetFunction()); | 10872 details->set(kFrameDetailsFunctionIndex, frame_inspector.GetFunction()); |
10875 | 10873 |
10876 // Add the arguments count. | 10874 // Add the arguments count. |
10877 details->set(kFrameDetailsArgumentCountIndex, Smi::FromInt(argument_count)); | 10875 details->set(kFrameDetailsArgumentCountIndex, Smi::FromInt(argument_count)); |
10878 | 10876 |
10879 // Add the locals count | 10877 // Add the locals count |
10880 details->set(kFrameDetailsLocalCountIndex, | 10878 details->set(kFrameDetailsLocalCountIndex, |
10881 Smi::FromInt(info.NumberOfLocals())); | 10879 Smi::FromInt(scope_info->NumberOfLocals())); |
10882 | 10880 |
10883 // Add the source position. | 10881 // Add the source position. |
10884 if (position != RelocInfo::kNoPosition) { | 10882 if (position != RelocInfo::kNoPosition) { |
10885 details->set(kFrameDetailsSourcePositionIndex, Smi::FromInt(position)); | 10883 details->set(kFrameDetailsSourcePositionIndex, Smi::FromInt(position)); |
10886 } else { | 10884 } else { |
10887 details->set(kFrameDetailsSourcePositionIndex, heap->undefined_value()); | 10885 details->set(kFrameDetailsSourcePositionIndex, heap->undefined_value()); |
10888 } | 10886 } |
10889 | 10887 |
10890 // Add the constructor information. | 10888 // Add the constructor information. |
10891 details->set(kFrameDetailsConstructCallIndex, heap->ToBoolean(constructor)); | 10889 details->set(kFrameDetailsConstructCallIndex, heap->ToBoolean(constructor)); |
(...skipping 14 matching lines...) Expand all Loading... |
10906 flags |= inlined_frame_index << 2; | 10904 flags |= inlined_frame_index << 2; |
10907 } | 10905 } |
10908 details->set(kFrameDetailsFlagsIndex, Smi::FromInt(flags)); | 10906 details->set(kFrameDetailsFlagsIndex, Smi::FromInt(flags)); |
10909 | 10907 |
10910 // Fill the dynamic part. | 10908 // Fill the dynamic part. |
10911 int details_index = kFrameDetailsFirstDynamicIndex; | 10909 int details_index = kFrameDetailsFirstDynamicIndex; |
10912 | 10910 |
10913 // Add arguments name and value. | 10911 // Add arguments name and value. |
10914 for (int i = 0; i < argument_count; i++) { | 10912 for (int i = 0; i < argument_count; i++) { |
10915 // Name of the argument. | 10913 // Name of the argument. |
10916 if (i < info.number_of_parameters()) { | 10914 if (i < scope_info->num_parameters()) { |
10917 details->set(details_index++, *info.parameter_name(i)); | 10915 details->set(details_index++, *scope_info->parameter_name(i)); |
10918 } else { | 10916 } else { |
10919 details->set(details_index++, heap->undefined_value()); | 10917 details->set(details_index++, heap->undefined_value()); |
10920 } | 10918 } |
10921 | 10919 |
10922 // Parameter value. | 10920 // Parameter value. |
10923 if (i < it.frame()->ComputeParametersCount()) { | 10921 if (i < it.frame()->ComputeParametersCount()) { |
10924 // Get the value from the stack. | 10922 // Get the value from the stack. |
10925 details->set(details_index++, frame_inspector.GetParameter(i)); | 10923 details->set(details_index++, frame_inspector.GetParameter(i)); |
10926 } else { | 10924 } else { |
10927 details->set(details_index++, heap->undefined_value()); | 10925 details->set(details_index++, heap->undefined_value()); |
10928 } | 10926 } |
10929 } | 10927 } |
10930 | 10928 |
10931 // Add locals name and value from the temporary copy from the function frame. | 10929 // Add locals name and value from the temporary copy from the function frame. |
10932 for (int i = 0; i < info.NumberOfLocals() * 2; i++) { | 10930 for (int i = 0; i < scope_info->NumberOfLocals() * 2; i++) { |
10933 details->set(details_index++, locals->get(i)); | 10931 details->set(details_index++, locals->get(i)); |
10934 } | 10932 } |
10935 | 10933 |
10936 // Add the value being returned. | 10934 // Add the value being returned. |
10937 if (at_return) { | 10935 if (at_return) { |
10938 details->set(details_index++, *return_value); | 10936 details->set(details_index++, *return_value); |
10939 } | 10937 } |
10940 | 10938 |
10941 // Add the receiver (same as in function frame). | 10939 // Add the receiver (same as in function frame). |
10942 // THIS MUST BE DONE LAST SINCE WE MIGHT ADVANCE | 10940 // THIS MUST BE DONE LAST SINCE WE MIGHT ADVANCE |
(...skipping 15 matching lines...) Expand all Loading... |
10958 details->set(kFrameDetailsReceiverIndex, *receiver); | 10956 details->set(kFrameDetailsReceiverIndex, *receiver); |
10959 | 10957 |
10960 ASSERT_EQ(details_size, details_index); | 10958 ASSERT_EQ(details_size, details_index); |
10961 return *isolate->factory()->NewJSArrayWithElements(details); | 10959 return *isolate->factory()->NewJSArrayWithElements(details); |
10962 } | 10960 } |
10963 | 10961 |
10964 | 10962 |
10965 // Copy all the context locals into an object used to materialize a scope. | 10963 // Copy all the context locals into an object used to materialize a scope. |
10966 static bool CopyContextLocalsToScopeObject( | 10964 static bool CopyContextLocalsToScopeObject( |
10967 Isolate* isolate, | 10965 Isolate* isolate, |
10968 Handle<SerializedScopeInfo> serialized_scope_info, | 10966 Handle<ScopeInfo> scope_info, |
10969 ScopeInfo<>& scope_info, | |
10970 Handle<Context> context, | 10967 Handle<Context> context, |
10971 Handle<JSObject> scope_object) { | 10968 Handle<JSObject> scope_object) { |
10972 // Fill all context locals to the context extension. | 10969 // Fill all context locals to the context extension. |
10973 for (int i = Context::MIN_CONTEXT_SLOTS; | 10970 for (int i = 0; i < scope_info->num_context_locals(); i++) { |
10974 i < scope_info.number_of_context_slots(); | 10971 Handle<String> name = scope_info->context_local_name(i); |
10975 i++) { | 10972 int context_index = scope_info->ContextSlotIndex(*name); |
10976 int context_index = serialized_scope_info->ContextSlotIndex( | |
10977 *scope_info.context_slot_name(i), NULL); | |
10978 | 10973 |
10979 RETURN_IF_EMPTY_HANDLE_VALUE( | 10974 RETURN_IF_EMPTY_HANDLE_VALUE( |
10980 isolate, | 10975 isolate, |
10981 SetProperty(scope_object, | 10976 SetProperty(scope_object, |
10982 scope_info.context_slot_name(i), | 10977 scope_info->context_local_name(i), |
10983 Handle<Object>(context->get(context_index), isolate), | 10978 Handle<Object>(context->get(context_index), isolate), |
10984 NONE, | 10979 NONE, |
10985 kNonStrictMode), | 10980 kNonStrictMode), |
10986 false); | 10981 false); |
10987 } | 10982 } |
10988 | 10983 |
10989 return true; | 10984 return true; |
10990 } | 10985 } |
10991 | 10986 |
10992 | 10987 |
10993 // Create a plain JSObject which materializes the local scope for the specified | 10988 // Create a plain JSObject which materializes the local scope for the specified |
10994 // frame. | 10989 // frame. |
10995 static Handle<JSObject> MaterializeLocalScope( | 10990 static Handle<JSObject> MaterializeLocalScope( |
10996 Isolate* isolate, | 10991 Isolate* isolate, |
10997 JavaScriptFrame* frame, | 10992 JavaScriptFrame* frame, |
10998 int inlined_frame_index) { | 10993 int inlined_frame_index) { |
10999 Handle<JSFunction> function(JSFunction::cast(frame->function())); | 10994 Handle<JSFunction> function(JSFunction::cast(frame->function())); |
11000 Handle<SharedFunctionInfo> shared(function->shared()); | 10995 Handle<SharedFunctionInfo> shared(function->shared()); |
11001 Handle<SerializedScopeInfo> serialized_scope_info(shared->scope_info()); | 10996 Handle<ScopeInfo> scope_info(shared->scope_info()); |
11002 ScopeInfo<> scope_info(*serialized_scope_info); | |
11003 FrameInspector frame_inspector(frame, inlined_frame_index, isolate); | 10997 FrameInspector frame_inspector(frame, inlined_frame_index, isolate); |
11004 | 10998 |
11005 // Allocate and initialize a JSObject with all the arguments, stack locals | 10999 // Allocate and initialize a JSObject with all the arguments, stack locals |
11006 // heap locals and extension properties of the debugged function. | 11000 // heap locals and extension properties of the debugged function. |
11007 Handle<JSObject> local_scope = | 11001 Handle<JSObject> local_scope = |
11008 isolate->factory()->NewJSObject(isolate->object_function()); | 11002 isolate->factory()->NewJSObject(isolate->object_function()); |
11009 | 11003 |
11010 // First fill all parameters. | 11004 // First fill all parameters. |
11011 for (int i = 0; i < scope_info.number_of_parameters(); ++i) { | 11005 for (int i = 0; i < scope_info->num_parameters(); ++i) { |
11012 RETURN_IF_EMPTY_HANDLE_VALUE( | 11006 RETURN_IF_EMPTY_HANDLE_VALUE( |
11013 isolate, | 11007 isolate, |
11014 SetProperty(local_scope, | 11008 SetProperty(local_scope, |
11015 scope_info.parameter_name(i), | 11009 scope_info->parameter_name(i), |
11016 Handle<Object>(frame_inspector.GetParameter(i)), | 11010 Handle<Object>(frame_inspector.GetParameter(i)), |
11017 NONE, | 11011 NONE, |
11018 kNonStrictMode), | 11012 kNonStrictMode), |
11019 Handle<JSObject>()); | 11013 Handle<JSObject>()); |
11020 } | 11014 } |
11021 | 11015 |
11022 // Second fill all stack locals. | 11016 // Second fill all stack locals. |
11023 for (int i = 0; i < scope_info.number_of_stack_slots(); ++i) { | 11017 for (int i = 0; i < scope_info->num_stack_locals(); ++i) { |
11024 RETURN_IF_EMPTY_HANDLE_VALUE( | 11018 RETURN_IF_EMPTY_HANDLE_VALUE( |
11025 isolate, | 11019 isolate, |
11026 SetProperty(local_scope, | 11020 SetProperty(local_scope, |
11027 scope_info.stack_slot_name(i), | 11021 scope_info->stack_local_name(i), |
11028 Handle<Object>(frame_inspector.GetExpression(i)), | 11022 Handle<Object>(frame_inspector.GetExpression(i)), |
11029 NONE, | 11023 NONE, |
11030 kNonStrictMode), | 11024 kNonStrictMode), |
11031 Handle<JSObject>()); | 11025 Handle<JSObject>()); |
11032 } | 11026 } |
11033 | 11027 |
11034 if (scope_info.number_of_context_slots() > Context::MIN_CONTEXT_SLOTS) { | 11028 if (scope_info->HasContext()) { |
11035 // Third fill all context locals. | 11029 // Third fill all context locals. |
11036 Handle<Context> frame_context(Context::cast(frame->context())); | 11030 Handle<Context> frame_context(Context::cast(frame->context())); |
11037 Handle<Context> function_context(frame_context->declaration_context()); | 11031 Handle<Context> function_context(frame_context->declaration_context()); |
11038 if (!CopyContextLocalsToScopeObject(isolate, | 11032 if (!CopyContextLocalsToScopeObject( |
11039 serialized_scope_info, scope_info, | 11033 isolate, scope_info, function_context, local_scope)) { |
11040 function_context, local_scope)) { | |
11041 return Handle<JSObject>(); | 11034 return Handle<JSObject>(); |
11042 } | 11035 } |
11043 | 11036 |
11044 // Finally copy any properties from the function context extension. | 11037 // Finally copy any properties from the function context extension. |
11045 // These will be variables introduced by eval. | 11038 // These will be variables introduced by eval. |
11046 if (function_context->closure() == *function) { | 11039 if (function_context->closure() == *function) { |
11047 if (function_context->has_extension() && | 11040 if (function_context->has_extension() && |
11048 !function_context->IsGlobalContext()) { | 11041 !function_context->IsGlobalContext()) { |
11049 Handle<JSObject> ext(JSObject::cast(function_context->extension())); | 11042 Handle<JSObject> ext(JSObject::cast(function_context->extension())); |
11050 bool threw = false; | 11043 bool threw = false; |
(...skipping 22 matching lines...) Expand all Loading... |
11073 } | 11066 } |
11074 | 11067 |
11075 | 11068 |
11076 // Create a plain JSObject which materializes the closure content for the | 11069 // Create a plain JSObject which materializes the closure content for the |
11077 // context. | 11070 // context. |
11078 static Handle<JSObject> MaterializeClosure(Isolate* isolate, | 11071 static Handle<JSObject> MaterializeClosure(Isolate* isolate, |
11079 Handle<Context> context) { | 11072 Handle<Context> context) { |
11080 ASSERT(context->IsFunctionContext()); | 11073 ASSERT(context->IsFunctionContext()); |
11081 | 11074 |
11082 Handle<SharedFunctionInfo> shared(context->closure()->shared()); | 11075 Handle<SharedFunctionInfo> shared(context->closure()->shared()); |
11083 Handle<SerializedScopeInfo> serialized_scope_info(shared->scope_info()); | 11076 Handle<ScopeInfo> scope_info(shared->scope_info()); |
11084 ScopeInfo<> scope_info(*serialized_scope_info); | |
11085 | 11077 |
11086 // Allocate and initialize a JSObject with all the content of theis function | 11078 // Allocate and initialize a JSObject with all the content of theis function |
11087 // closure. | 11079 // closure. |
11088 Handle<JSObject> closure_scope = | 11080 Handle<JSObject> closure_scope = |
11089 isolate->factory()->NewJSObject(isolate->object_function()); | 11081 isolate->factory()->NewJSObject(isolate->object_function()); |
11090 | 11082 |
11091 // Fill all context locals to the context extension. | 11083 // Fill all context locals to the context extension. |
11092 if (!CopyContextLocalsToScopeObject(isolate, | 11084 if (!CopyContextLocalsToScopeObject( |
11093 serialized_scope_info, scope_info, | 11085 isolate, scope_info, context, closure_scope)) { |
11094 context, closure_scope)) { | |
11095 return Handle<JSObject>(); | 11086 return Handle<JSObject>(); |
11096 } | 11087 } |
11097 | 11088 |
11098 // Finally copy any properties from the function context extension. This will | 11089 // Finally copy any properties from the function context extension. This will |
11099 // be variables introduced by eval. | 11090 // be variables introduced by eval. |
11100 if (context->has_extension()) { | 11091 if (context->has_extension()) { |
11101 Handle<JSObject> ext(JSObject::cast(context->extension())); | 11092 Handle<JSObject> ext(JSObject::cast(context->extension())); |
11102 bool threw = false; | 11093 bool threw = false; |
11103 Handle<FixedArray> keys = | 11094 Handle<FixedArray> keys = |
11104 GetKeysInFixedArrayFor(ext, INCLUDE_PROTOS, &threw); | 11095 GetKeysInFixedArrayFor(ext, INCLUDE_PROTOS, &threw); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11139 return catch_scope; | 11130 return catch_scope; |
11140 } | 11131 } |
11141 | 11132 |
11142 | 11133 |
11143 // Create a plain JSObject which materializes the block scope for the specified | 11134 // Create a plain JSObject which materializes the block scope for the specified |
11144 // block context. | 11135 // block context. |
11145 static Handle<JSObject> MaterializeBlockScope( | 11136 static Handle<JSObject> MaterializeBlockScope( |
11146 Isolate* isolate, | 11137 Isolate* isolate, |
11147 Handle<Context> context) { | 11138 Handle<Context> context) { |
11148 ASSERT(context->IsBlockContext()); | 11139 ASSERT(context->IsBlockContext()); |
11149 Handle<SerializedScopeInfo> serialized_scope_info( | 11140 Handle<ScopeInfo> scope_info(ScopeInfo::cast(context->extension())); |
11150 SerializedScopeInfo::cast(context->extension())); | |
11151 ScopeInfo<> scope_info(*serialized_scope_info); | |
11152 | 11141 |
11153 // Allocate and initialize a JSObject with all the arguments, stack locals | 11142 // Allocate and initialize a JSObject with all the arguments, stack locals |
11154 // heap locals and extension properties of the debugged function. | 11143 // heap locals and extension properties of the debugged function. |
11155 Handle<JSObject> block_scope = | 11144 Handle<JSObject> block_scope = |
11156 isolate->factory()->NewJSObject(isolate->object_function()); | 11145 isolate->factory()->NewJSObject(isolate->object_function()); |
11157 | 11146 |
11158 // Fill all context locals. | 11147 // Fill all context locals. |
11159 if (scope_info.number_of_context_slots() > Context::MIN_CONTEXT_SLOTS) { | 11148 if (!CopyContextLocalsToScopeObject( |
11160 if (!CopyContextLocalsToScopeObject(isolate, | 11149 isolate, scope_info, context, block_scope)) { |
11161 serialized_scope_info, scope_info, | 11150 return Handle<JSObject>(); |
11162 context, block_scope)) { | |
11163 return Handle<JSObject>(); | |
11164 } | |
11165 } | 11151 } |
11166 | 11152 |
11167 return block_scope; | 11153 return block_scope; |
11168 } | 11154 } |
11169 | 11155 |
11170 | 11156 |
11171 // Iterate over the actual scopes visible from a stack frame. The iteration | 11157 // Iterate over the actual scopes visible from a stack frame. The iteration |
11172 // proceeds from the innermost visible nested scope outwards. All scopes are | 11158 // proceeds from the innermost visible nested scope outwards. All scopes are |
11173 // backed by an actual context except the local scope, which is inserted | 11159 // backed by an actual context except the local scope, which is inserted |
11174 // "artificially" in the context chain. | 11160 // "artificially" in the context chain. |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11257 if (nested_scope_chain_.last()->HasContext()) { | 11243 if (nested_scope_chain_.last()->HasContext()) { |
11258 context_ = Handle<Context>(context_->previous(), isolate_); | 11244 context_ = Handle<Context>(context_->previous(), isolate_); |
11259 } | 11245 } |
11260 nested_scope_chain_.RemoveLast(); | 11246 nested_scope_chain_.RemoveLast(); |
11261 } | 11247 } |
11262 } | 11248 } |
11263 | 11249 |
11264 // Return the type of the current scope. | 11250 // Return the type of the current scope. |
11265 ScopeType Type() { | 11251 ScopeType Type() { |
11266 if (!nested_scope_chain_.is_empty()) { | 11252 if (!nested_scope_chain_.is_empty()) { |
11267 Handle<SerializedScopeInfo> scope_info = nested_scope_chain_.last(); | 11253 Handle<ScopeInfo> scope_info = nested_scope_chain_.last(); |
11268 switch (scope_info->Type()) { | 11254 switch (scope_info->Type()) { |
11269 case FUNCTION_SCOPE: | 11255 case FUNCTION_SCOPE: |
11270 ASSERT(context_->IsFunctionContext() || | 11256 ASSERT(context_->IsFunctionContext() || |
11271 !scope_info->HasContext()); | 11257 !scope_info->HasContext()); |
11272 return ScopeTypeLocal; | 11258 return ScopeTypeLocal; |
11273 case GLOBAL_SCOPE: | 11259 case GLOBAL_SCOPE: |
11274 ASSERT(context_->IsGlobalContext()); | 11260 ASSERT(context_->IsGlobalContext()); |
11275 return ScopeTypeGlobal; | 11261 return ScopeTypeGlobal; |
11276 case WITH_SCOPE: | 11262 case WITH_SCOPE: |
11277 ASSERT(context_->IsWithContext()); | 11263 ASSERT(context_->IsWithContext()); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11321 case ScopeIterator::ScopeTypeClosure: | 11307 case ScopeIterator::ScopeTypeClosure: |
11322 // Materialize the content of the closure scope into a JSObject. | 11308 // Materialize the content of the closure scope into a JSObject. |
11323 return MaterializeClosure(isolate_, CurrentContext()); | 11309 return MaterializeClosure(isolate_, CurrentContext()); |
11324 case ScopeIterator::ScopeTypeBlock: | 11310 case ScopeIterator::ScopeTypeBlock: |
11325 return MaterializeBlockScope(isolate_, CurrentContext()); | 11311 return MaterializeBlockScope(isolate_, CurrentContext()); |
11326 } | 11312 } |
11327 UNREACHABLE(); | 11313 UNREACHABLE(); |
11328 return Handle<JSObject>(); | 11314 return Handle<JSObject>(); |
11329 } | 11315 } |
11330 | 11316 |
11331 Handle<SerializedScopeInfo> CurrentScopeInfo() { | 11317 Handle<ScopeInfo> CurrentScopeInfo() { |
11332 if (!nested_scope_chain_.is_empty()) { | 11318 if (!nested_scope_chain_.is_empty()) { |
11333 return nested_scope_chain_.last(); | 11319 return nested_scope_chain_.last(); |
11334 } else if (context_->IsBlockContext()) { | 11320 } else if (context_->IsBlockContext()) { |
11335 return Handle<SerializedScopeInfo>( | 11321 return Handle<ScopeInfo>(ScopeInfo::cast(context_->extension())); |
11336 SerializedScopeInfo::cast(context_->extension())); | |
11337 } else if (context_->IsFunctionContext()) { | 11322 } else if (context_->IsFunctionContext()) { |
11338 return Handle<SerializedScopeInfo>( | 11323 return Handle<ScopeInfo>(context_->closure()->shared()->scope_info()); |
11339 context_->closure()->shared()->scope_info()); | |
11340 } | 11324 } |
11341 return Handle<SerializedScopeInfo>::null(); | 11325 return Handle<ScopeInfo>::null(); |
11342 } | 11326 } |
11343 | 11327 |
11344 // Return the context for this scope. For the local context there might not | 11328 // Return the context for this scope. For the local context there might not |
11345 // be an actual context. | 11329 // be an actual context. |
11346 Handle<Context> CurrentContext() { | 11330 Handle<Context> CurrentContext() { |
11347 if (Type() == ScopeTypeGlobal || | 11331 if (Type() == ScopeTypeGlobal || |
11348 nested_scope_chain_.is_empty()) { | 11332 nested_scope_chain_.is_empty()) { |
11349 return context_; | 11333 return context_; |
11350 } else if (nested_scope_chain_.last()->HasContext()) { | 11334 } else if (nested_scope_chain_.last()->HasContext()) { |
11351 return context_; | 11335 return context_; |
11352 } else { | 11336 } else { |
11353 return Handle<Context>(); | 11337 return Handle<Context>(); |
11354 } | 11338 } |
11355 } | 11339 } |
11356 | 11340 |
11357 #ifdef DEBUG | 11341 #ifdef DEBUG |
11358 // Debug print of the content of the current scope. | 11342 // Debug print of the content of the current scope. |
11359 void DebugPrint() { | 11343 void DebugPrint() { |
11360 switch (Type()) { | 11344 switch (Type()) { |
11361 case ScopeIterator::ScopeTypeGlobal: | 11345 case ScopeIterator::ScopeTypeGlobal: |
11362 PrintF("Global:\n"); | 11346 PrintF("Global:\n"); |
11363 CurrentContext()->Print(); | 11347 CurrentContext()->Print(); |
11364 break; | 11348 break; |
11365 | 11349 |
11366 case ScopeIterator::ScopeTypeLocal: { | 11350 case ScopeIterator::ScopeTypeLocal: { |
11367 PrintF("Local:\n"); | 11351 PrintF("Local:\n"); |
11368 ScopeInfo<> scope_info(function_->shared()->scope_info()); | 11352 function_->shared()->scope_info()->Print(); |
11369 scope_info.Print(); | |
11370 if (!CurrentContext().is_null()) { | 11353 if (!CurrentContext().is_null()) { |
11371 CurrentContext()->Print(); | 11354 CurrentContext()->Print(); |
11372 if (CurrentContext()->has_extension()) { | 11355 if (CurrentContext()->has_extension()) { |
11373 Handle<Object> extension(CurrentContext()->extension()); | 11356 Handle<Object> extension(CurrentContext()->extension()); |
11374 if (extension->IsJSContextExtensionObject()) { | 11357 if (extension->IsJSContextExtensionObject()) { |
11375 extension->Print(); | 11358 extension->Print(); |
11376 } | 11359 } |
11377 } | 11360 } |
11378 } | 11361 } |
11379 break; | 11362 break; |
(...skipping 27 matching lines...) Expand all Loading... |
11407 PrintF("\n"); | 11390 PrintF("\n"); |
11408 } | 11391 } |
11409 #endif | 11392 #endif |
11410 | 11393 |
11411 private: | 11394 private: |
11412 Isolate* isolate_; | 11395 Isolate* isolate_; |
11413 JavaScriptFrame* frame_; | 11396 JavaScriptFrame* frame_; |
11414 int inlined_frame_index_; | 11397 int inlined_frame_index_; |
11415 Handle<JSFunction> function_; | 11398 Handle<JSFunction> function_; |
11416 Handle<Context> context_; | 11399 Handle<Context> context_; |
11417 List<Handle<SerializedScopeInfo> > nested_scope_chain_; | 11400 List<Handle<ScopeInfo> > nested_scope_chain_; |
11418 | 11401 |
11419 DISALLOW_IMPLICIT_CONSTRUCTORS(ScopeIterator); | 11402 DISALLOW_IMPLICIT_CONSTRUCTORS(ScopeIterator); |
11420 }; | 11403 }; |
11421 | 11404 |
11422 | 11405 |
11423 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetScopeCount) { | 11406 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetScopeCount) { |
11424 HandleScope scope(isolate); | 11407 HandleScope scope(isolate); |
11425 ASSERT(args.length() == 2); | 11408 ASSERT(args.length() == 2); |
11426 | 11409 |
11427 // Check arguments. | 11410 // Check arguments. |
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11876 | 11859 |
11877 | 11860 |
11878 // Creates a copy of the with context chain. The copy of the context chain is | 11861 // Creates a copy of the with context chain. The copy of the context chain is |
11879 // is linked to the function context supplied. | 11862 // is linked to the function context supplied. |
11880 static Handle<Context> CopyNestedScopeContextChain(Isolate* isolate, | 11863 static Handle<Context> CopyNestedScopeContextChain(Isolate* isolate, |
11881 Handle<JSFunction> function, | 11864 Handle<JSFunction> function, |
11882 Handle<Context> base, | 11865 Handle<Context> base, |
11883 JavaScriptFrame* frame, | 11866 JavaScriptFrame* frame, |
11884 int inlined_frame_index) { | 11867 int inlined_frame_index) { |
11885 HandleScope scope(isolate); | 11868 HandleScope scope(isolate); |
11886 List<Handle<SerializedScopeInfo> > scope_chain; | 11869 List<Handle<ScopeInfo> > scope_chain; |
11887 List<Handle<Context> > context_chain; | 11870 List<Handle<Context> > context_chain; |
11888 | 11871 |
11889 ScopeIterator it(isolate, frame, inlined_frame_index); | 11872 ScopeIterator it(isolate, frame, inlined_frame_index); |
11890 for (; it.Type() != ScopeIterator::ScopeTypeGlobal && | 11873 for (; it.Type() != ScopeIterator::ScopeTypeGlobal && |
11891 it.Type() != ScopeIterator::ScopeTypeLocal ; it.Next()) { | 11874 it.Type() != ScopeIterator::ScopeTypeLocal ; it.Next()) { |
11892 ASSERT(!it.Done()); | 11875 ASSERT(!it.Done()); |
11893 scope_chain.Add(it.CurrentScopeInfo()); | 11876 scope_chain.Add(it.CurrentScopeInfo()); |
11894 context_chain.Add(it.CurrentContext()); | 11877 context_chain.Add(it.CurrentContext()); |
11895 } | 11878 } |
11896 | 11879 |
11897 // At the end of the chain. Return the base context to link to. | 11880 // At the end of the chain. Return the base context to link to. |
11898 Handle<Context> context = base; | 11881 Handle<Context> context = base; |
11899 | 11882 |
11900 // Iteratively copy and or materialize the nested contexts. | 11883 // Iteratively copy and or materialize the nested contexts. |
11901 while (!scope_chain.is_empty()) { | 11884 while (!scope_chain.is_empty()) { |
11902 Handle<SerializedScopeInfo> scope_info = scope_chain.RemoveLast(); | 11885 Handle<ScopeInfo> scope_info = scope_chain.RemoveLast(); |
11903 Handle<Context> current = context_chain.RemoveLast(); | 11886 Handle<Context> current = context_chain.RemoveLast(); |
11904 ASSERT(!(scope_info->HasContext() & current.is_null())); | 11887 ASSERT(!(scope_info->HasContext() & current.is_null())); |
11905 | 11888 |
11906 if (scope_info->Type() == CATCH_SCOPE) { | 11889 if (scope_info->Type() == CATCH_SCOPE) { |
11907 Handle<String> name(String::cast(current->extension())); | 11890 Handle<String> name(String::cast(current->extension())); |
11908 Handle<Object> thrown_object(current->get(Context::THROWN_OBJECT_INDEX)); | 11891 Handle<Object> thrown_object(current->get(Context::THROWN_OBJECT_INDEX)); |
11909 context = | 11892 context = |
11910 isolate->factory()->NewCatchContext(function, | 11893 isolate->factory()->NewCatchContext(function, |
11911 context, | 11894 context, |
11912 name, | 11895 name, |
(...skipping 25 matching lines...) Expand all Loading... |
11938 return scope.CloseAndEscape(context); | 11921 return scope.CloseAndEscape(context); |
11939 } | 11922 } |
11940 | 11923 |
11941 | 11924 |
11942 // Helper function to find or create the arguments object for | 11925 // Helper function to find or create the arguments object for |
11943 // Runtime_DebugEvaluate. | 11926 // Runtime_DebugEvaluate. |
11944 static Handle<Object> GetArgumentsObject(Isolate* isolate, | 11927 static Handle<Object> GetArgumentsObject(Isolate* isolate, |
11945 JavaScriptFrame* frame, | 11928 JavaScriptFrame* frame, |
11946 int inlined_frame_index, | 11929 int inlined_frame_index, |
11947 Handle<JSFunction> function, | 11930 Handle<JSFunction> function, |
11948 Handle<SerializedScopeInfo> scope_info, | 11931 Handle<ScopeInfo> scope_info, |
11949 const ScopeInfo<>* sinfo, | |
11950 Handle<Context> function_context) { | 11932 Handle<Context> function_context) { |
11951 // Try to find the value of 'arguments' to pass as parameter. If it is not | 11933 // Try to find the value of 'arguments' to pass as parameter. If it is not |
11952 // found (that is the debugged function does not reference 'arguments' and | 11934 // found (that is the debugged function does not reference 'arguments' and |
11953 // does not support eval) then create an 'arguments' object. | 11935 // does not support eval) then create an 'arguments' object. |
11954 int index; | 11936 int index; |
11955 if (sinfo->number_of_stack_slots() > 0) { | 11937 if (scope_info->num_stack_locals() > 0) { |
11956 index = scope_info->StackSlotIndex(isolate->heap()->arguments_symbol()); | 11938 index = scope_info->StackSlotIndex(isolate->heap()->arguments_symbol()); |
11957 if (index != -1) { | 11939 if (index != -1) { |
11958 return Handle<Object>(frame->GetExpression(index), isolate); | 11940 return Handle<Object>(frame->GetExpression(index), isolate); |
11959 } | 11941 } |
11960 } | 11942 } |
11961 | 11943 |
11962 if (sinfo->number_of_context_slots() > Context::MIN_CONTEXT_SLOTS) { | 11944 if (scope_info->HasHeapAllocatedLocals()) { |
11963 index = scope_info->ContextSlotIndex(isolate->heap()->arguments_symbol(), | 11945 index = scope_info->ContextSlotIndex(isolate->heap()->arguments_symbol()); |
11964 NULL); | |
11965 if (index != -1) { | 11946 if (index != -1) { |
11966 return Handle<Object>(function_context->get(index), isolate); | 11947 return Handle<Object>(function_context->get(index), isolate); |
11967 } | 11948 } |
11968 } | 11949 } |
11969 | 11950 |
11970 FrameInspector frame_inspector(frame, inlined_frame_index, isolate); | 11951 FrameInspector frame_inspector(frame, inlined_frame_index, isolate); |
11971 | 11952 |
11972 int length = frame_inspector.GetParametersCount(); | 11953 int length = frame_inspector.GetParametersCount(); |
11973 Handle<JSObject> arguments = | 11954 Handle<JSObject> arguments = |
11974 isolate->factory()->NewArgumentsObject(function, length); | 11955 isolate->factory()->NewArgumentsObject(function, length); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12019 Handle<Object> additional_context(args[5]); | 12000 Handle<Object> additional_context(args[5]); |
12020 | 12001 |
12021 // Handle the processing of break. | 12002 // Handle the processing of break. |
12022 DisableBreak disable_break_save(disable_break); | 12003 DisableBreak disable_break_save(disable_break); |
12023 | 12004 |
12024 // Get the frame where the debugging is performed. | 12005 // Get the frame where the debugging is performed. |
12025 StackFrame::Id id = UnwrapFrameId(wrapped_id); | 12006 StackFrame::Id id = UnwrapFrameId(wrapped_id); |
12026 JavaScriptFrameIterator it(isolate, id); | 12007 JavaScriptFrameIterator it(isolate, id); |
12027 JavaScriptFrame* frame = it.frame(); | 12008 JavaScriptFrame* frame = it.frame(); |
12028 Handle<JSFunction> function(JSFunction::cast(frame->function())); | 12009 Handle<JSFunction> function(JSFunction::cast(frame->function())); |
12029 Handle<SerializedScopeInfo> scope_info(function->shared()->scope_info()); | 12010 Handle<ScopeInfo> scope_info(function->shared()->scope_info()); |
12030 ScopeInfo<> sinfo(*scope_info); | |
12031 | 12011 |
12032 // Traverse the saved contexts chain to find the active context for the | 12012 // Traverse the saved contexts chain to find the active context for the |
12033 // selected frame. | 12013 // selected frame. |
12034 SaveContext* save = FindSavedContextForFrame(isolate, frame); | 12014 SaveContext* save = FindSavedContextForFrame(isolate, frame); |
12035 | 12015 |
12036 SaveContext savex(isolate); | 12016 SaveContext savex(isolate); |
12037 isolate->set_context(*(save->context())); | 12017 isolate->set_context(*(save->context())); |
12038 | 12018 |
12039 // Create the (empty) function replacing the function on the stack frame for | 12019 // Create the (empty) function replacing the function on the stack frame for |
12040 // the purpose of evaluating in the context created below. It is important | 12020 // the purpose of evaluating in the context created below. It is important |
12041 // that this function does not describe any parameters and local variables | 12021 // that this function does not describe any parameters and local variables |
12042 // in the context. If it does then this will cause problems with the lookup | 12022 // in the context. If it does then this will cause problems with the lookup |
12043 // in Context::Lookup, where context slots for parameters and local variables | 12023 // in Context::Lookup, where context slots for parameters and local variables |
12044 // are looked at before the extension object. | 12024 // are looked at before the extension object. |
12045 Handle<JSFunction> go_between = | 12025 Handle<JSFunction> go_between = |
12046 isolate->factory()->NewFunction(isolate->factory()->empty_string(), | 12026 isolate->factory()->NewFunction(isolate->factory()->empty_string(), |
12047 isolate->factory()->undefined_value()); | 12027 isolate->factory()->undefined_value()); |
12048 go_between->set_context(function->context()); | 12028 go_between->set_context(function->context()); |
12049 #ifdef DEBUG | 12029 #ifdef DEBUG |
12050 ScopeInfo<> go_between_sinfo(go_between->shared()->scope_info()); | 12030 Handle<ScopeInfo> go_between_scope_info(go_between->shared()->scope_info()); |
12051 ASSERT(go_between_sinfo.number_of_parameters() == 0); | 12031 ASSERT(go_between_scope_info->num_parameters() == 0); |
12052 ASSERT(go_between_sinfo.number_of_context_slots() == 0); | 12032 ASSERT(go_between_scope_info->num_context_locals() == 0); |
12053 #endif | 12033 #endif |
12054 | 12034 |
12055 // Materialize the content of the local scope into a JSObject. | 12035 // Materialize the content of the local scope into a JSObject. |
12056 Handle<JSObject> local_scope = MaterializeLocalScope( | 12036 Handle<JSObject> local_scope = MaterializeLocalScope( |
12057 isolate, frame, inlined_frame_index); | 12037 isolate, frame, inlined_frame_index); |
12058 RETURN_IF_EMPTY_HANDLE(isolate, local_scope); | 12038 RETURN_IF_EMPTY_HANDLE(isolate, local_scope); |
12059 | 12039 |
12060 // Allocate a new context for the debug evaluation and set the extension | 12040 // Allocate a new context for the debug evaluation and set the extension |
12061 // object build. | 12041 // object build. |
12062 Handle<Context> context = | 12042 Handle<Context> context = |
12063 isolate->factory()->NewFunctionContext(Context::MIN_CONTEXT_SLOTS, | 12043 isolate->factory()->NewFunctionContext(Context::MIN_CONTEXT_SLOTS, |
12064 go_between); | 12044 go_between); |
12065 context->set_extension(*local_scope); | 12045 context->set_extension(*local_scope); |
12066 // Copy any with contexts present and chain them in front of this context. | 12046 // Copy any with contexts present and chain them in front of this context. |
12067 Handle<Context> frame_context(Context::cast(frame->context())); | 12047 Handle<Context> frame_context(Context::cast(frame->context())); |
12068 Handle<Context> function_context; | 12048 Handle<Context> function_context; |
12069 // Get the function's context if it has one. | 12049 // Get the function's context if it has one. |
12070 if (scope_info->HasHeapAllocatedLocals()) { | 12050 if (scope_info->HasContext()) { |
12071 function_context = Handle<Context>(frame_context->declaration_context()); | 12051 function_context = Handle<Context>(frame_context->declaration_context()); |
12072 } | 12052 } |
12073 context = CopyNestedScopeContextChain(isolate, | 12053 context = CopyNestedScopeContextChain(isolate, |
12074 go_between, | 12054 go_between, |
12075 context, | 12055 context, |
12076 frame, | 12056 frame, |
12077 inlined_frame_index); | 12057 inlined_frame_index); |
12078 | 12058 |
12079 if (additional_context->IsJSObject()) { | 12059 if (additional_context->IsJSObject()) { |
12080 Handle<JSObject> extension = Handle<JSObject>::cast(additional_context); | 12060 Handle<JSObject> extension = Handle<JSObject>::cast(additional_context); |
(...skipping 24 matching lines...) Expand all Loading... |
12105 | 12085 |
12106 // Invoke the result of the compilation to get the evaluation function. | 12086 // Invoke the result of the compilation to get the evaluation function. |
12107 bool has_pending_exception; | 12087 bool has_pending_exception; |
12108 Handle<Object> receiver(frame->receiver(), isolate); | 12088 Handle<Object> receiver(frame->receiver(), isolate); |
12109 Handle<Object> evaluation_function = | 12089 Handle<Object> evaluation_function = |
12110 Execution::Call(compiled_function, receiver, 0, NULL, | 12090 Execution::Call(compiled_function, receiver, 0, NULL, |
12111 &has_pending_exception); | 12091 &has_pending_exception); |
12112 if (has_pending_exception) return Failure::Exception(); | 12092 if (has_pending_exception) return Failure::Exception(); |
12113 | 12093 |
12114 Handle<Object> arguments = GetArgumentsObject(isolate, | 12094 Handle<Object> arguments = GetArgumentsObject(isolate, |
12115 frame, inlined_frame_index, | 12095 frame, |
12116 function, scope_info, | 12096 inlined_frame_index, |
12117 &sinfo, function_context); | 12097 function, |
| 12098 scope_info, |
| 12099 function_context); |
12118 | 12100 |
12119 // Invoke the evaluation function and return the result. | 12101 // Invoke the evaluation function and return the result. |
12120 Handle<Object> argv[] = { arguments, source }; | 12102 Handle<Object> argv[] = { arguments, source }; |
12121 Handle<Object> result = | 12103 Handle<Object> result = |
12122 Execution::Call(Handle<JSFunction>::cast(evaluation_function), | 12104 Execution::Call(Handle<JSFunction>::cast(evaluation_function), |
12123 receiver, | 12105 receiver, |
12124 ARRAY_SIZE(argv), | 12106 ARRAY_SIZE(argv), |
12125 argv, | 12107 argv, |
12126 &has_pending_exception); | 12108 &has_pending_exception); |
12127 if (has_pending_exception) return Failure::Exception(); | 12109 if (has_pending_exception) return Failure::Exception(); |
(...skipping 1390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13518 } else { | 13500 } else { |
13519 // Handle last resort GC and make sure to allow future allocations | 13501 // Handle last resort GC and make sure to allow future allocations |
13520 // to grow the heap without causing GCs (if possible). | 13502 // to grow the heap without causing GCs (if possible). |
13521 isolate->counters()->gc_last_resort_from_js()->Increment(); | 13503 isolate->counters()->gc_last_resort_from_js()->Increment(); |
13522 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags); | 13504 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags); |
13523 } | 13505 } |
13524 } | 13506 } |
13525 | 13507 |
13526 | 13508 |
13527 } } // namespace v8::internal | 13509 } } // namespace v8::internal |
OLD | NEW |