Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(236)

Side by Side Diff: src/runtime.cc

Issue 9265004: Support inlining at call-sites with mismatched number of arguments. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: finished implementation, extended tests, ported to x64&arm Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 8108 matching lines...) Expand 10 before | Expand all | Expand 10 after
8119 // prefixed by a number of empty handles). 8119 // prefixed by a number of empty handles).
8120 static SmartArrayPointer<Handle<Object> > GetCallerArguments( 8120 static SmartArrayPointer<Handle<Object> > GetCallerArguments(
8121 int prefix_argc, 8121 int prefix_argc,
8122 int* total_argc) { 8122 int* total_argc) {
8123 // Find frame containing arguments passed to the caller. 8123 // Find frame containing arguments passed to the caller.
8124 JavaScriptFrameIterator it; 8124 JavaScriptFrameIterator it;
8125 JavaScriptFrame* frame = it.frame(); 8125 JavaScriptFrame* frame = it.frame();
8126 List<JSFunction*> functions(2); 8126 List<JSFunction*> functions(2);
8127 frame->GetFunctions(&functions); 8127 frame->GetFunctions(&functions);
8128 if (functions.length() > 1) { 8128 if (functions.length() > 1) {
8129 int inlined_frame_index = functions.length() - 1; 8129 int inlined_jsframe_index = functions.length() - 1;
8130 JSFunction* inlined_function = functions[inlined_frame_index]; 8130 JSFunction* inlined_function = functions[inlined_jsframe_index];
8131 int args_count = inlined_function->shared()->formal_parameter_count(); 8131 Vector<SlotRef> args_slots =
8132 ScopedVector<SlotRef> args_slots(args_count); 8132 SlotRef::ComputeSlotMappingForArguments(
8133 SlotRef::ComputeSlotMappingForArguments(frame, 8133 frame,
8134 inlined_frame_index, 8134 inlined_jsframe_index,
8135 &args_slots); 8135 inlined_function->shared()->formal_parameter_count());
8136
8137 int args_count = args_slots.length();
8136 8138
8137 *total_argc = prefix_argc + args_count; 8139 *total_argc = prefix_argc + args_count;
8138 SmartArrayPointer<Handle<Object> > param_data( 8140 SmartArrayPointer<Handle<Object> > param_data(
8139 NewArray<Handle<Object> >(*total_argc)); 8141 NewArray<Handle<Object> >(*total_argc));
8140 for (int i = 0; i < args_count; i++) { 8142 for (int i = 0; i < args_count; i++) {
8141 Handle<Object> val = args_slots[i].GetValue(); 8143 Handle<Object> val = args_slots[i].GetValue();
8142 param_data[prefix_argc + i] = val; 8144 param_data[prefix_argc + i] = val;
8143 } 8145 }
8146
8147 args_slots.Dispose();
8148
8144 return param_data; 8149 return param_data;
8145 } else { 8150 } else {
8146 it.AdvanceToArgumentsFrame(); 8151 it.AdvanceToArgumentsFrame();
8147 frame = it.frame(); 8152 frame = it.frame();
8148 int args_count = frame->ComputeParametersCount(); 8153 int args_count = frame->ComputeParametersCount();
8149 8154
8150 *total_argc = prefix_argc + args_count; 8155 *total_argc = prefix_argc + args_count;
8151 SmartArrayPointer<Handle<Object> > param_data( 8156 SmartArrayPointer<Handle<Object> > param_data(
8152 NewArray<Handle<Object> >(*total_argc)); 8157 NewArray<Handle<Object> >(*total_argc));
8153 for (int i = 0; i < args_count; i++) { 8158 for (int i = 0; i < args_count; i++) {
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
8479 8484
8480 8485
8481 RUNTIME_FUNCTION(MaybeObject*, Runtime_NotifyDeoptimized) { 8486 RUNTIME_FUNCTION(MaybeObject*, Runtime_NotifyDeoptimized) {
8482 HandleScope scope(isolate); 8487 HandleScope scope(isolate);
8483 ASSERT(args.length() == 1); 8488 ASSERT(args.length() == 1);
8484 RUNTIME_ASSERT(args[0]->IsSmi()); 8489 RUNTIME_ASSERT(args[0]->IsSmi());
8485 Deoptimizer::BailoutType type = 8490 Deoptimizer::BailoutType type =
8486 static_cast<Deoptimizer::BailoutType>(args.smi_at(0)); 8491 static_cast<Deoptimizer::BailoutType>(args.smi_at(0));
8487 Deoptimizer* deoptimizer = Deoptimizer::Grab(isolate); 8492 Deoptimizer* deoptimizer = Deoptimizer::Grab(isolate);
8488 ASSERT(isolate->heap()->IsAllocationAllowed()); 8493 ASSERT(isolate->heap()->IsAllocationAllowed());
8489 int frames = deoptimizer->output_count(); 8494 int jsframes = deoptimizer->jsframe_count();
8490 8495
8491 deoptimizer->MaterializeHeapNumbers(); 8496 deoptimizer->MaterializeHeapNumbers();
8492 delete deoptimizer; 8497 delete deoptimizer;
8493 8498
8494 JavaScriptFrameIterator it(isolate); 8499 JavaScriptFrameIterator it(isolate);
8495 JavaScriptFrame* frame = NULL; 8500 JavaScriptFrame* frame = NULL;
8496 for (int i = 0; i < frames - 1; i++) it.Advance(); 8501 for (int i = 0; i < jsframes - 1; i++) it.Advance();
8497 frame = it.frame(); 8502 frame = it.frame();
8498 8503
8499 RUNTIME_ASSERT(frame->function()->IsJSFunction()); 8504 RUNTIME_ASSERT(frame->function()->IsJSFunction());
8500 Handle<JSFunction> function(JSFunction::cast(frame->function()), isolate); 8505 Handle<JSFunction> function(JSFunction::cast(frame->function()), isolate);
8501 Handle<Object> arguments; 8506 Handle<Object> arguments;
8502 for (int i = frame->ComputeExpressionsCount() - 1; i >= 0; --i) { 8507 for (int i = frame->ComputeExpressionsCount() - 1; i >= 0; --i) {
8503 if (frame->GetExpression(i) == isolate->heap()->arguments_marker()) { 8508 if (frame->GetExpression(i) == isolate->heap()->arguments_marker()) {
8504 if (arguments.is_null()) { 8509 if (arguments.is_null()) {
8505 // FunctionGetArguments can't throw an exception, so cast away the 8510 // FunctionGetArguments can't throw an exception, so cast away the
8506 // doubt with an assert. 8511 // doubt with an assert.
(...skipping 2189 matching lines...) Expand 10 before | Expand all | Expand 10 after
10696 for (JavaScriptFrameIterator it(isolate, id); !it.done(); it.Advance()) { 10701 for (JavaScriptFrameIterator it(isolate, id); !it.done(); it.Advance()) {
10697 n += it.frame()->GetInlineCount(); 10702 n += it.frame()->GetInlineCount();
10698 } 10703 }
10699 return Smi::FromInt(n); 10704 return Smi::FromInt(n);
10700 } 10705 }
10701 10706
10702 10707
10703 class FrameInspector { 10708 class FrameInspector {
10704 public: 10709 public:
10705 FrameInspector(JavaScriptFrame* frame, 10710 FrameInspector(JavaScriptFrame* frame,
10706 int inlined_frame_index, 10711 int inlined_jsframe_index,
10707 Isolate* isolate) 10712 Isolate* isolate)
10708 : frame_(frame), deoptimized_frame_(NULL), isolate_(isolate) { 10713 : frame_(frame), deoptimized_frame_(NULL), isolate_(isolate) {
10709 // Calculate the deoptimized frame. 10714 // Calculate the deoptimized frame.
10710 if (frame->is_optimized()) { 10715 if (frame->is_optimized()) {
10711 deoptimized_frame_ = Deoptimizer::DebuggerInspectableFrame( 10716 deoptimized_frame_ = Deoptimizer::DebuggerInspectableFrame(
10712 frame, inlined_frame_index, isolate); 10717 frame, inlined_jsframe_index, isolate);
10713 } 10718 }
10714 has_adapted_arguments_ = frame_->has_adapted_arguments(); 10719 has_adapted_arguments_ = frame_->has_adapted_arguments();
10715 is_optimized_ = frame_->is_optimized(); 10720 is_optimized_ = frame_->is_optimized();
10716 } 10721 }
10717 10722
10718 ~FrameInspector() { 10723 ~FrameInspector() {
10719 // Get rid of the calculated deoptimized frame if any. 10724 // Get rid of the calculated deoptimized frame if any.
10720 if (deoptimized_frame_ != NULL) { 10725 if (deoptimized_frame_ != NULL) {
10721 Deoptimizer::DeleteDebuggerInspectableFrame(deoptimized_frame_, 10726 Deoptimizer::DeleteDebuggerInspectableFrame(deoptimized_frame_,
10722 isolate_); 10727 isolate_);
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
10818 CONVERT_NUMBER_CHECKED(int, index, Int32, args[1]); 10823 CONVERT_NUMBER_CHECKED(int, index, Int32, args[1]);
10819 Heap* heap = isolate->heap(); 10824 Heap* heap = isolate->heap();
10820 10825
10821 // Find the relevant frame with the requested index. 10826 // Find the relevant frame with the requested index.
10822 StackFrame::Id id = isolate->debug()->break_frame_id(); 10827 StackFrame::Id id = isolate->debug()->break_frame_id();
10823 if (id == StackFrame::NO_ID) { 10828 if (id == StackFrame::NO_ID) {
10824 // If there are no JavaScript stack frames return undefined. 10829 // If there are no JavaScript stack frames return undefined.
10825 return heap->undefined_value(); 10830 return heap->undefined_value();
10826 } 10831 }
10827 10832
10828 int inlined_frame_index = 0; // Inlined frame index in optimized frame.
10829
10830 int count = 0; 10833 int count = 0;
10831 JavaScriptFrameIterator it(isolate, id); 10834 JavaScriptFrameIterator it(isolate, id);
10832 for (; !it.done(); it.Advance()) { 10835 for (; !it.done(); it.Advance()) {
10833 if (index < count + it.frame()->GetInlineCount()) break; 10836 if (index < count + it.frame()->GetInlineCount()) break;
10834 count += it.frame()->GetInlineCount(); 10837 count += it.frame()->GetInlineCount();
10835 } 10838 }
10836 if (it.done()) return heap->undefined_value(); 10839 if (it.done()) return heap->undefined_value();
10837 10840
10838 if (it.frame()->is_optimized()) { 10841 bool is_optimized = it.frame()->is_optimized();
10839 inlined_frame_index = 10842
10843 int inlined_jsframe_index = 0; // Inlined frame index in optimized frame.
10844 if (is_optimized) {
10845 inlined_jsframe_index =
10840 it.frame()->GetInlineCount() - (index - count) - 1; 10846 it.frame()->GetInlineCount() - (index - count) - 1;
10841 } 10847 }
10842 FrameInspector frame_inspector(it.frame(), inlined_frame_index, isolate); 10848 FrameInspector frame_inspector(it.frame(), inlined_jsframe_index, isolate);
10843 10849
10844 // Traverse the saved contexts chain to find the active context for the 10850 // Traverse the saved contexts chain to find the active context for the
10845 // selected frame. 10851 // selected frame.
10846 SaveContext* save = FindSavedContextForFrame(isolate, it.frame()); 10852 SaveContext* save = FindSavedContextForFrame(isolate, it.frame());
10847 10853
10848 // Get the frame id. 10854 // Get the frame id.
10849 Handle<Object> frame_id(WrapFrameId(it.frame()->id()), isolate); 10855 Handle<Object> frame_id(WrapFrameId(it.frame()->id()), isolate);
10850 10856
10851 // Find source position. 10857 // Find source position.
10852 int position = 10858 int position =
10853 it.frame()->LookupCode()->SourcePosition(it.frame()->pc()); 10859 it.frame()->LookupCode()->SourcePosition(it.frame()->pc());
10854 10860
10855 // Check for constructor frame. Inlined frames cannot be construct calls. 10861 // Check for constructor frame. Inlined frames cannot be construct calls.
10856 bool inlined_frame = 10862 bool inlined_frame = is_optimized && inlined_jsframe_index != 0;
10857 it.frame()->is_optimized() && inlined_frame_index != 0;
10858 bool constructor = !inlined_frame && it.frame()->IsConstructor(); 10863 bool constructor = !inlined_frame && it.frame()->IsConstructor();
10859 10864
10860 // Get scope info and read from it for local variable information. 10865 // Get scope info and read from it for local variable information.
10861 Handle<JSFunction> function(JSFunction::cast(it.frame()->function())); 10866 Handle<JSFunction> function(JSFunction::cast(frame_inspector.GetFunction()));
10862 Handle<SharedFunctionInfo> shared(function->shared()); 10867 Handle<SharedFunctionInfo> shared(function->shared());
10863 Handle<ScopeInfo> scope_info(shared->scope_info()); 10868 Handle<ScopeInfo> scope_info(shared->scope_info());
10864 ASSERT(*scope_info != ScopeInfo::Empty()); 10869 ASSERT(*scope_info != ScopeInfo::Empty());
10865 10870
10866 // Get the locals names and values into a temporary array. 10871 // Get the locals names and values into a temporary array.
10867 // 10872 //
10868 // TODO(1240907): Hide compiler-introduced stack variables 10873 // TODO(1240907): Hide compiler-introduced stack variables
10869 // (e.g. .result)? For users of the debugger, they will probably be 10874 // (e.g. .result)? For users of the debugger, they will probably be
10870 // confusing. 10875 // confusing.
10871 Handle<FixedArray> locals = 10876 Handle<FixedArray> locals =
(...skipping 16 matching lines...) Expand all
10888 InitializationFlag init_flag; 10893 InitializationFlag init_flag;
10889 locals->set(i * 2, *name); 10894 locals->set(i * 2, *name);
10890 locals->set(i * 2 + 1, context->get( 10895 locals->set(i * 2 + 1, context->get(
10891 scope_info->ContextSlotIndex(*name, &mode, &init_flag))); 10896 scope_info->ContextSlotIndex(*name, &mode, &init_flag)));
10892 } 10897 }
10893 } 10898 }
10894 10899
10895 // Check whether this frame is positioned at return. If not top 10900 // Check whether this frame is positioned at return. If not top
10896 // frame or if the frame is optimized it cannot be at a return. 10901 // frame or if the frame is optimized it cannot be at a return.
10897 bool at_return = false; 10902 bool at_return = false;
10898 if (!it.frame()->is_optimized() && index == 0) { 10903 if (!is_optimized && index == 0) {
10899 at_return = isolate->debug()->IsBreakAtReturn(it.frame()); 10904 at_return = isolate->debug()->IsBreakAtReturn(it.frame());
10900 } 10905 }
10901 10906
10902 // If positioned just before return find the value to be returned and add it 10907 // If positioned just before return find the value to be returned and add it
10903 // to the frame information. 10908 // to the frame information.
10904 Handle<Object> return_value = isolate->factory()->undefined_value(); 10909 Handle<Object> return_value = isolate->factory()->undefined_value();
10905 if (at_return) { 10910 if (at_return) {
10906 StackFrameIterator it2(isolate); 10911 StackFrameIterator it2(isolate);
10907 Address internal_frame_sp = NULL; 10912 Address internal_frame_sp = NULL;
10908 while (!it2.done()) { 10913 while (!it2.done()) {
(...skipping 19 matching lines...) Expand all
10928 internal_frame_sp = NULL; 10933 internal_frame_sp = NULL;
10929 } 10934 }
10930 it2.Advance(); 10935 it2.Advance();
10931 } 10936 }
10932 } 10937 }
10933 10938
10934 // Now advance to the arguments adapter frame (if any). It contains all 10939 // Now advance to the arguments adapter frame (if any). It contains all
10935 // the provided parameters whereas the function frame always have the number 10940 // the provided parameters whereas the function frame always have the number
10936 // of arguments matching the functions parameters. The rest of the 10941 // of arguments matching the functions parameters. The rest of the
10937 // information (except for what is collected above) is the same. 10942 // information (except for what is collected above) is the same.
10938 if (it.frame()->has_adapted_arguments()) { 10943 if ((inlined_jsframe_index == 0) && it.frame()->has_adapted_arguments()) {
10939 it.AdvanceToArgumentsFrame(); 10944 it.AdvanceToArgumentsFrame();
10940 frame_inspector.SetArgumentsFrame(it.frame()); 10945 frame_inspector.SetArgumentsFrame(it.frame());
10941 } 10946 }
10942 10947
10943 // Find the number of arguments to fill. At least fill the number of 10948 // Find the number of arguments to fill. At least fill the number of
10944 // parameters for the function and fill more if more parameters are provided. 10949 // parameters for the function and fill more if more parameters are provided.
10945 int argument_count = scope_info->ParameterCount(); 10950 int argument_count = scope_info->ParameterCount();
10946 if (argument_count < frame_inspector.GetParametersCount()) { 10951 if (argument_count < frame_inspector.GetParametersCount()) {
10947 argument_count = frame_inspector.GetParametersCount(); 10952 argument_count = frame_inspector.GetParametersCount();
10948 } 10953 }
10949 #ifdef DEBUG
10950 if (it.frame()->is_optimized()) {
10951 ASSERT_EQ(argument_count, frame_inspector.GetParametersCount());
10952 }
10953 #endif
10954 10954
10955 // Calculate the size of the result. 10955 // Calculate the size of the result.
10956 int details_size = kFrameDetailsFirstDynamicIndex + 10956 int details_size = kFrameDetailsFirstDynamicIndex +
10957 2 * (argument_count + scope_info->LocalCount()) + 10957 2 * (argument_count + scope_info->LocalCount()) +
10958 (at_return ? 1 : 0); 10958 (at_return ? 1 : 0);
10959 Handle<FixedArray> details = isolate->factory()->NewFixedArray(details_size); 10959 Handle<FixedArray> details = isolate->factory()->NewFixedArray(details_size);
10960 10960
10961 // Add the frame id. 10961 // Add the frame id.
10962 details->set(kFrameDetailsFrameIdIndex, *frame_id); 10962 details->set(kFrameDetailsFrameIdIndex, *frame_id);
10963 10963
(...skipping 21 matching lines...) Expand all
10985 details->set(kFrameDetailsAtReturnIndex, heap->ToBoolean(at_return)); 10985 details->set(kFrameDetailsAtReturnIndex, heap->ToBoolean(at_return));
10986 10986
10987 // Add flags to indicate information on whether this frame is 10987 // Add flags to indicate information on whether this frame is
10988 // bit 0: invoked in the debugger context. 10988 // bit 0: invoked in the debugger context.
10989 // bit 1: optimized frame. 10989 // bit 1: optimized frame.
10990 // bit 2: inlined in optimized frame 10990 // bit 2: inlined in optimized frame
10991 int flags = 0; 10991 int flags = 0;
10992 if (*save->context() == *isolate->debug()->debug_context()) { 10992 if (*save->context() == *isolate->debug()->debug_context()) {
10993 flags |= 1 << 0; 10993 flags |= 1 << 0;
10994 } 10994 }
10995 if (it.frame()->is_optimized()) { 10995 if (is_optimized) {
10996 flags |= 1 << 1; 10996 flags |= 1 << 1;
10997 flags |= inlined_frame_index << 2; 10997 flags |= inlined_jsframe_index << 2;
10998 } 10998 }
10999 details->set(kFrameDetailsFlagsIndex, Smi::FromInt(flags)); 10999 details->set(kFrameDetailsFlagsIndex, Smi::FromInt(flags));
11000 11000
11001 // Fill the dynamic part. 11001 // Fill the dynamic part.
11002 int details_index = kFrameDetailsFirstDynamicIndex; 11002 int details_index = kFrameDetailsFirstDynamicIndex;
11003 11003
11004 // Add arguments name and value. 11004 // Add arguments name and value.
11005 for (int i = 0; i < argument_count; i++) { 11005 for (int i = 0; i < argument_count; i++) {
11006 // Name of the argument. 11006 // Name of the argument.
11007 if (i < scope_info->ParameterCount()) { 11007 if (i < scope_info->ParameterCount()) {
11008 details->set(details_index++, scope_info->ParameterName(i)); 11008 details->set(details_index++, scope_info->ParameterName(i));
11009 } else { 11009 } else {
11010 details->set(details_index++, heap->undefined_value()); 11010 details->set(details_index++, heap->undefined_value());
11011 } 11011 }
11012 11012
11013 // Parameter value. 11013 // Parameter value.
11014 if (i < it.frame()->ComputeParametersCount()) { 11014 if (i < frame_inspector.GetParametersCount()) {
11015 // Get the value from the stack. 11015 // Get the value from the stack.
11016 details->set(details_index++, frame_inspector.GetParameter(i)); 11016 details->set(details_index++, frame_inspector.GetParameter(i));
11017 } else { 11017 } else {
11018 details->set(details_index++, heap->undefined_value()); 11018 details->set(details_index++, heap->undefined_value());
11019 } 11019 }
11020 } 11020 }
11021 11021
11022 // Add locals name and value from the temporary copy from the function frame. 11022 // Add locals name and value from the temporary copy from the function frame.
11023 for (int i = 0; i < scope_info->LocalCount() * 2; i++) { 11023 for (int i = 0; i < scope_info->LocalCount() * 2; i++) {
11024 details->set(details_index++, locals->get(i)); 11024 details->set(details_index++, locals->get(i));
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
11077 kNonStrictMode), 11077 kNonStrictMode),
11078 false); 11078 false);
11079 } 11079 }
11080 11080
11081 return true; 11081 return true;
11082 } 11082 }
11083 11083
11084 11084
11085 // Create a plain JSObject which materializes the local scope for the specified 11085 // Create a plain JSObject which materializes the local scope for the specified
11086 // frame. 11086 // frame.
11087 static Handle<JSObject> MaterializeLocalScope( 11087 static Handle<JSObject> MaterializeLocalScopeWithFrameInspector(
11088 Isolate* isolate, 11088 Isolate* isolate,
11089 JavaScriptFrame* frame, 11089 JavaScriptFrame* frame,
11090 int inlined_frame_index) { 11090 FrameInspector* frame_inspector) {
11091 Handle<JSFunction> function(JSFunction::cast(frame->function())); 11091 Handle<JSFunction> function(JSFunction::cast(frame_inspector->GetFunction()));
11092 Handle<SharedFunctionInfo> shared(function->shared()); 11092 Handle<SharedFunctionInfo> shared(function->shared());
11093 Handle<ScopeInfo> scope_info(shared->scope_info()); 11093 Handle<ScopeInfo> scope_info(shared->scope_info());
11094 FrameInspector frame_inspector(frame, inlined_frame_index, isolate);
11095 11094
11096 // Allocate and initialize a JSObject with all the arguments, stack locals 11095 // Allocate and initialize a JSObject with all the arguments, stack locals
11097 // heap locals and extension properties of the debugged function. 11096 // heap locals and extension properties of the debugged function.
11098 Handle<JSObject> local_scope = 11097 Handle<JSObject> local_scope =
11099 isolate->factory()->NewJSObject(isolate->object_function()); 11098 isolate->factory()->NewJSObject(isolate->object_function());
11100 11099
11101 // First fill all parameters. 11100 // First fill all parameters.
11102 for (int i = 0; i < scope_info->ParameterCount(); ++i) { 11101 for (int i = 0; i < scope_info->ParameterCount(); ++i) {
11102 Handle<Object> value(
11103 i < frame_inspector->GetParametersCount() ?
11104 frame_inspector->GetParameter(i) : isolate->heap()->undefined_value());
11105
11103 RETURN_IF_EMPTY_HANDLE_VALUE( 11106 RETURN_IF_EMPTY_HANDLE_VALUE(
11104 isolate, 11107 isolate,
11105 SetProperty(local_scope, 11108 SetProperty(local_scope,
11106 Handle<String>(scope_info->ParameterName(i)), 11109 Handle<String>(scope_info->ParameterName(i)),
11107 Handle<Object>(frame_inspector.GetParameter(i)), 11110 value,
11108 NONE, 11111 NONE,
11109 kNonStrictMode), 11112 kNonStrictMode),
11110 Handle<JSObject>()); 11113 Handle<JSObject>());
11111 } 11114 }
11112 11115
11113 // Second fill all stack locals. 11116 // Second fill all stack locals.
11114 for (int i = 0; i < scope_info->StackLocalCount(); ++i) { 11117 for (int i = 0; i < scope_info->StackLocalCount(); ++i) {
11115 RETURN_IF_EMPTY_HANDLE_VALUE( 11118 RETURN_IF_EMPTY_HANDLE_VALUE(
11116 isolate, 11119 isolate,
11117 SetProperty(local_scope, 11120 SetProperty(local_scope,
11118 Handle<String>(scope_info->StackLocalName(i)), 11121 Handle<String>(scope_info->StackLocalName(i)),
11119 Handle<Object>(frame_inspector.GetExpression(i)), 11122 Handle<Object>(frame_inspector->GetExpression(i)),
11120 NONE, 11123 NONE,
11121 kNonStrictMode), 11124 kNonStrictMode),
11122 Handle<JSObject>()); 11125 Handle<JSObject>());
11123 } 11126 }
11124 11127
11125 if (scope_info->HasContext()) { 11128 if (scope_info->HasContext()) {
11126 // Third fill all context locals. 11129 // Third fill all context locals.
11127 Handle<Context> frame_context(Context::cast(frame->context())); 11130 Handle<Context> frame_context(Context::cast(frame->context()));
11128 Handle<Context> function_context(frame_context->declaration_context()); 11131 Handle<Context> function_context(frame_context->declaration_context());
11129 if (!CopyContextLocalsToScopeObject( 11132 if (!CopyContextLocalsToScopeObject(
(...skipping 26 matching lines...) Expand all
11156 Handle<JSObject>()); 11159 Handle<JSObject>());
11157 } 11160 }
11158 } 11161 }
11159 } 11162 }
11160 } 11163 }
11161 11164
11162 return local_scope; 11165 return local_scope;
11163 } 11166 }
11164 11167
11165 11168
11169 static Handle<JSObject> MaterializeLocalScope(
11170 Isolate* isolate,
11171 JavaScriptFrame* frame,
11172 int inlined_jsframe_index) {
11173 FrameInspector frame_inspector(frame, inlined_jsframe_index, isolate);
11174 return MaterializeLocalScopeWithFrameInspector(isolate,
11175 frame,
11176 &frame_inspector);
11177 }
11178
11179
11166 // Create a plain JSObject which materializes the closure content for the 11180 // Create a plain JSObject which materializes the closure content for the
11167 // context. 11181 // context.
11168 static Handle<JSObject> MaterializeClosure(Isolate* isolate, 11182 static Handle<JSObject> MaterializeClosure(Isolate* isolate,
11169 Handle<Context> context) { 11183 Handle<Context> context) {
11170 ASSERT(context->IsFunctionContext()); 11184 ASSERT(context->IsFunctionContext());
11171 11185
11172 Handle<SharedFunctionInfo> shared(context->closure()->shared()); 11186 Handle<SharedFunctionInfo> shared(context->closure()->shared());
11173 Handle<ScopeInfo> scope_info(shared->scope_info()); 11187 Handle<ScopeInfo> scope_info(shared->scope_info());
11174 11188
11175 // Allocate and initialize a JSObject with all the content of this function 11189 // Allocate and initialize a JSObject with all the content of this function
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
11261 ScopeTypeGlobal = 0, 11275 ScopeTypeGlobal = 0,
11262 ScopeTypeLocal, 11276 ScopeTypeLocal,
11263 ScopeTypeWith, 11277 ScopeTypeWith,
11264 ScopeTypeClosure, 11278 ScopeTypeClosure,
11265 ScopeTypeCatch, 11279 ScopeTypeCatch,
11266 ScopeTypeBlock 11280 ScopeTypeBlock
11267 }; 11281 };
11268 11282
11269 ScopeIterator(Isolate* isolate, 11283 ScopeIterator(Isolate* isolate,
11270 JavaScriptFrame* frame, 11284 JavaScriptFrame* frame,
11271 int inlined_frame_index) 11285 int inlined_jsframe_index)
11272 : isolate_(isolate), 11286 : isolate_(isolate),
11273 frame_(frame), 11287 frame_(frame),
11274 inlined_frame_index_(inlined_frame_index), 11288 inlined_jsframe_index_(inlined_jsframe_index),
11275 function_(JSFunction::cast(frame->function())), 11289 function_(JSFunction::cast(frame->function())),
11276 context_(Context::cast(frame->context())), 11290 context_(Context::cast(frame->context())),
11277 nested_scope_chain_(4) { 11291 nested_scope_chain_(4) {
11278 11292
11279 // Catch the case when the debugger stops in an internal function. 11293 // Catch the case when the debugger stops in an internal function.
11280 Handle<SharedFunctionInfo> shared_info(function_->shared()); 11294 Handle<SharedFunctionInfo> shared_info(function_->shared());
11281 Handle<ScopeInfo> scope_info(shared_info->scope_info()); 11295 Handle<ScopeInfo> scope_info(shared_info->scope_info());
11282 if (shared_info->script() == isolate->heap()->undefined_value()) { 11296 if (shared_info->script() == isolate->heap()->undefined_value()) {
11283 while (context_->closure() == *function_) { 11297 while (context_->closure() == *function_) {
11284 context_ = Handle<Context>(context_->previous(), isolate_); 11298 context_ = Handle<Context>(context_->previous(), isolate_);
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
11421 } 11435 }
11422 11436
11423 // Return the JavaScript object with the content of the current scope. 11437 // Return the JavaScript object with the content of the current scope.
11424 Handle<JSObject> ScopeObject() { 11438 Handle<JSObject> ScopeObject() {
11425 switch (Type()) { 11439 switch (Type()) {
11426 case ScopeIterator::ScopeTypeGlobal: 11440 case ScopeIterator::ScopeTypeGlobal:
11427 return Handle<JSObject>(CurrentContext()->global()); 11441 return Handle<JSObject>(CurrentContext()->global());
11428 case ScopeIterator::ScopeTypeLocal: 11442 case ScopeIterator::ScopeTypeLocal:
11429 // Materialize the content of the local scope into a JSObject. 11443 // Materialize the content of the local scope into a JSObject.
11430 ASSERT(nested_scope_chain_.length() == 1); 11444 ASSERT(nested_scope_chain_.length() == 1);
11431 return MaterializeLocalScope(isolate_, frame_, inlined_frame_index_); 11445 return MaterializeLocalScope(isolate_, frame_, inlined_jsframe_index_);
11432 case ScopeIterator::ScopeTypeWith: 11446 case ScopeIterator::ScopeTypeWith:
11433 // Return the with object. 11447 // Return the with object.
11434 return Handle<JSObject>(JSObject::cast(CurrentContext()->extension())); 11448 return Handle<JSObject>(JSObject::cast(CurrentContext()->extension()));
11435 case ScopeIterator::ScopeTypeCatch: 11449 case ScopeIterator::ScopeTypeCatch:
11436 return MaterializeCatchScope(isolate_, CurrentContext()); 11450 return MaterializeCatchScope(isolate_, CurrentContext());
11437 case ScopeIterator::ScopeTypeClosure: 11451 case ScopeIterator::ScopeTypeClosure:
11438 // Materialize the content of the closure scope into a JSObject. 11452 // Materialize the content of the closure scope into a JSObject.
11439 return MaterializeClosure(isolate_, CurrentContext()); 11453 return MaterializeClosure(isolate_, CurrentContext());
11440 case ScopeIterator::ScopeTypeBlock: 11454 case ScopeIterator::ScopeTypeBlock:
11441 return MaterializeBlockScope(isolate_, CurrentContext()); 11455 return MaterializeBlockScope(isolate_, CurrentContext());
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
11517 default: 11531 default:
11518 UNREACHABLE(); 11532 UNREACHABLE();
11519 } 11533 }
11520 PrintF("\n"); 11534 PrintF("\n");
11521 } 11535 }
11522 #endif 11536 #endif
11523 11537
11524 private: 11538 private:
11525 Isolate* isolate_; 11539 Isolate* isolate_;
11526 JavaScriptFrame* frame_; 11540 JavaScriptFrame* frame_;
11527 int inlined_frame_index_; 11541 int inlined_jsframe_index_;
11528 Handle<JSFunction> function_; 11542 Handle<JSFunction> function_;
11529 Handle<Context> context_; 11543 Handle<Context> context_;
11530 List<Handle<ScopeInfo> > nested_scope_chain_; 11544 List<Handle<ScopeInfo> > nested_scope_chain_;
11531 11545
11532 DISALLOW_IMPLICIT_CONSTRUCTORS(ScopeIterator); 11546 DISALLOW_IMPLICIT_CONSTRUCTORS(ScopeIterator);
11533 }; 11547 };
11534 11548
11535 11549
11536 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetScopeCount) { 11550 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetScopeCount) {
11537 HandleScope scope(isolate); 11551 HandleScope scope(isolate);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
11579 HandleScope scope(isolate); 11593 HandleScope scope(isolate);
11580 ASSERT(args.length() == 4); 11594 ASSERT(args.length() == 4);
11581 11595
11582 // Check arguments. 11596 // Check arguments.
11583 Object* check; 11597 Object* check;
11584 { MaybeObject* maybe_check = Runtime_CheckExecutionState( 11598 { MaybeObject* maybe_check = Runtime_CheckExecutionState(
11585 RUNTIME_ARGUMENTS(isolate, args)); 11599 RUNTIME_ARGUMENTS(isolate, args));
11586 if (!maybe_check->ToObject(&check)) return maybe_check; 11600 if (!maybe_check->ToObject(&check)) return maybe_check;
11587 } 11601 }
11588 CONVERT_CHECKED(Smi, wrapped_id, args[1]); 11602 CONVERT_CHECKED(Smi, wrapped_id, args[1]);
11589 CONVERT_NUMBER_CHECKED(int, inlined_frame_index, Int32, args[2]); 11603 CONVERT_NUMBER_CHECKED(int, inlined_jsframe_index, Int32, args[2]);
11590 CONVERT_NUMBER_CHECKED(int, index, Int32, args[3]); 11604 CONVERT_NUMBER_CHECKED(int, index, Int32, args[3]);
11591 11605
11592 // Get the frame where the debugging is performed. 11606 // Get the frame where the debugging is performed.
11593 StackFrame::Id id = UnwrapFrameId(wrapped_id); 11607 StackFrame::Id id = UnwrapFrameId(wrapped_id);
11594 JavaScriptFrameIterator frame_it(isolate, id); 11608 JavaScriptFrameIterator frame_it(isolate, id);
11595 JavaScriptFrame* frame = frame_it.frame(); 11609 JavaScriptFrame* frame = frame_it.frame();
11596 11610
11597 // Find the requested scope. 11611 // Find the requested scope.
11598 int n = 0; 11612 int n = 0;
11599 ScopeIterator it(isolate, frame, inlined_frame_index); 11613 ScopeIterator it(isolate, frame, inlined_jsframe_index);
11600 for (; !it.Done() && n < index; it.Next()) { 11614 for (; !it.Done() && n < index; it.Next()) {
11601 n++; 11615 n++;
11602 } 11616 }
11603 if (it.Done()) { 11617 if (it.Done()) {
11604 return isolate->heap()->undefined_value(); 11618 return isolate->heap()->undefined_value();
11605 } 11619 }
11606 11620
11607 // Calculate the size of the result. 11621 // Calculate the size of the result.
11608 int details_size = kScopeDetailsSize; 11622 int details_size = kScopeDetailsSize;
11609 Handle<FixedArray> details = isolate->factory()->NewFixedArray(details_size); 11623 Handle<FixedArray> details = isolate->factory()->NewFixedArray(details_size);
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
11987 return isolate->heap()->undefined_value(); 12001 return isolate->heap()->undefined_value();
11988 } 12002 }
11989 12003
11990 12004
11991 // Creates a copy of the with context chain. The copy of the context chain is 12005 // Creates a copy of the with context chain. The copy of the context chain is
11992 // is linked to the function context supplied. 12006 // is linked to the function context supplied.
11993 static Handle<Context> CopyNestedScopeContextChain(Isolate* isolate, 12007 static Handle<Context> CopyNestedScopeContextChain(Isolate* isolate,
11994 Handle<JSFunction> function, 12008 Handle<JSFunction> function,
11995 Handle<Context> base, 12009 Handle<Context> base,
11996 JavaScriptFrame* frame, 12010 JavaScriptFrame* frame,
11997 int inlined_frame_index) { 12011 int inlined_jsframe_index) {
11998 HandleScope scope(isolate); 12012 HandleScope scope(isolate);
11999 List<Handle<ScopeInfo> > scope_chain; 12013 List<Handle<ScopeInfo> > scope_chain;
12000 List<Handle<Context> > context_chain; 12014 List<Handle<Context> > context_chain;
12001 12015
12002 ScopeIterator it(isolate, frame, inlined_frame_index); 12016 ScopeIterator it(isolate, frame, inlined_jsframe_index);
12003 for (; it.Type() != ScopeIterator::ScopeTypeGlobal && 12017 for (; it.Type() != ScopeIterator::ScopeTypeGlobal &&
12004 it.Type() != ScopeIterator::ScopeTypeLocal ; it.Next()) { 12018 it.Type() != ScopeIterator::ScopeTypeLocal ; it.Next()) {
12005 ASSERT(!it.Done()); 12019 ASSERT(!it.Done());
12006 scope_chain.Add(it.CurrentScopeInfo()); 12020 scope_chain.Add(it.CurrentScopeInfo());
12007 context_chain.Add(it.CurrentContext()); 12021 context_chain.Add(it.CurrentContext());
12008 } 12022 }
12009 12023
12010 // At the end of the chain. Return the base context to link to. 12024 // At the end of the chain. Return the base context to link to.
12011 Handle<Context> context = base; 12025 Handle<Context> context = base;
12012 12026
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
12049 } 12063 }
12050 12064
12051 return scope.CloseAndEscape(context); 12065 return scope.CloseAndEscape(context);
12052 } 12066 }
12053 12067
12054 12068
12055 // Helper function to find or create the arguments object for 12069 // Helper function to find or create the arguments object for
12056 // Runtime_DebugEvaluate. 12070 // Runtime_DebugEvaluate.
12057 static Handle<Object> GetArgumentsObject(Isolate* isolate, 12071 static Handle<Object> GetArgumentsObject(Isolate* isolate,
12058 JavaScriptFrame* frame, 12072 JavaScriptFrame* frame,
12059 int inlined_frame_index, 12073 FrameInspector* frame_inspector,
12060 Handle<JSFunction> function,
12061 Handle<ScopeInfo> scope_info, 12074 Handle<ScopeInfo> scope_info,
12062 Handle<Context> function_context) { 12075 Handle<Context> function_context) {
12063 // Try to find the value of 'arguments' to pass as parameter. If it is not 12076 // Try to find the value of 'arguments' to pass as parameter. If it is not
12064 // found (that is the debugged function does not reference 'arguments' and 12077 // found (that is the debugged function does not reference 'arguments' and
12065 // does not support eval) then create an 'arguments' object. 12078 // does not support eval) then create an 'arguments' object.
12066 int index; 12079 int index;
12067 if (scope_info->StackLocalCount() > 0) { 12080 if (scope_info->StackLocalCount() > 0) {
12068 index = scope_info->StackSlotIndex(isolate->heap()->arguments_symbol()); 12081 index = scope_info->StackSlotIndex(isolate->heap()->arguments_symbol());
12069 if (index != -1) { 12082 if (index != -1) {
12070 return Handle<Object>(frame->GetExpression(index), isolate); 12083 return Handle<Object>(frame->GetExpression(index), isolate);
12071 } 12084 }
12072 } 12085 }
12073 12086
12074 if (scope_info->HasHeapAllocatedLocals()) { 12087 if (scope_info->HasHeapAllocatedLocals()) {
12075 VariableMode mode; 12088 VariableMode mode;
12076 InitializationFlag init_flag; 12089 InitializationFlag init_flag;
12077 index = scope_info->ContextSlotIndex( 12090 index = scope_info->ContextSlotIndex(
12078 isolate->heap()->arguments_symbol(), &mode, &init_flag); 12091 isolate->heap()->arguments_symbol(), &mode, &init_flag);
12079 if (index != -1) { 12092 if (index != -1) {
12080 return Handle<Object>(function_context->get(index), isolate); 12093 return Handle<Object>(function_context->get(index), isolate);
12081 } 12094 }
12082 } 12095 }
12083 12096
12084 FrameInspector frame_inspector(frame, inlined_frame_index, isolate); 12097 Handle<JSFunction> function(JSFunction::cast(frame_inspector->GetFunction()));
12085 12098 int length = frame_inspector->GetParametersCount();
12086 int length = frame_inspector.GetParametersCount();
12087 Handle<JSObject> arguments = 12099 Handle<JSObject> arguments =
12088 isolate->factory()->NewArgumentsObject(function, length); 12100 isolate->factory()->NewArgumentsObject(function, length);
12089 Handle<FixedArray> array = isolate->factory()->NewFixedArray(length); 12101 Handle<FixedArray> array = isolate->factory()->NewFixedArray(length);
12090 12102
12091 AssertNoAllocation no_gc; 12103 AssertNoAllocation no_gc;
12092 WriteBarrierMode mode = array->GetWriteBarrierMode(no_gc); 12104 WriteBarrierMode mode = array->GetWriteBarrierMode(no_gc);
12093 for (int i = 0; i < length; i++) { 12105 for (int i = 0; i < length; i++) {
12094 array->set(i, frame_inspector.GetParameter(i), mode); 12106 array->set(i, frame_inspector->GetParameter(i), mode);
12095 } 12107 }
12096 arguments->set_elements(*array); 12108 arguments->set_elements(*array);
12097 return arguments; 12109 return arguments;
12098 } 12110 }
12099 12111
12100 12112
12101 static const char kSourceStr[] = 12113 static const char kSourceStr[] =
12102 "(function(arguments,__source__){return eval(__source__);})"; 12114 "(function(arguments,__source__){return eval(__source__);})";
12103 12115
12104 12116
(...skipping 15 matching lines...) Expand all
12120 // evaluated. 12132 // evaluated.
12121 ASSERT(args.length() == 6); 12133 ASSERT(args.length() == 6);
12122 Object* check_result; 12134 Object* check_result;
12123 { MaybeObject* maybe_check_result = Runtime_CheckExecutionState( 12135 { MaybeObject* maybe_check_result = Runtime_CheckExecutionState(
12124 RUNTIME_ARGUMENTS(isolate, args)); 12136 RUNTIME_ARGUMENTS(isolate, args));
12125 if (!maybe_check_result->ToObject(&check_result)) { 12137 if (!maybe_check_result->ToObject(&check_result)) {
12126 return maybe_check_result; 12138 return maybe_check_result;
12127 } 12139 }
12128 } 12140 }
12129 CONVERT_CHECKED(Smi, wrapped_id, args[1]); 12141 CONVERT_CHECKED(Smi, wrapped_id, args[1]);
12130 CONVERT_NUMBER_CHECKED(int, inlined_frame_index, Int32, args[2]); 12142 CONVERT_NUMBER_CHECKED(int, inlined_jsframe_index, Int32, args[2]);
12131 CONVERT_ARG_CHECKED(String, source, 3); 12143 CONVERT_ARG_CHECKED(String, source, 3);
12132 CONVERT_BOOLEAN_CHECKED(disable_break, args[4]); 12144 CONVERT_BOOLEAN_CHECKED(disable_break, args[4]);
12133 Handle<Object> additional_context(args[5]); 12145 Handle<Object> additional_context(args[5]);
12134 12146
12135 // Handle the processing of break. 12147 // Handle the processing of break.
12136 DisableBreak disable_break_save(disable_break); 12148 DisableBreak disable_break_save(disable_break);
12137 12149
12138 // Get the frame where the debugging is performed. 12150 // Get the frame where the debugging is performed.
12139 StackFrame::Id id = UnwrapFrameId(wrapped_id); 12151 StackFrame::Id id = UnwrapFrameId(wrapped_id);
12140 JavaScriptFrameIterator it(isolate, id); 12152 JavaScriptFrameIterator it(isolate, id);
12141 JavaScriptFrame* frame = it.frame(); 12153 JavaScriptFrame* frame = it.frame();
12142 Handle<JSFunction> function(JSFunction::cast(frame->function())); 12154 FrameInspector frame_inspector(frame, inlined_jsframe_index, isolate);
12155 Handle<JSFunction> function(JSFunction::cast(frame_inspector.GetFunction()));
12143 Handle<ScopeInfo> scope_info(function->shared()->scope_info()); 12156 Handle<ScopeInfo> scope_info(function->shared()->scope_info());
12144 12157
12145 // Traverse the saved contexts chain to find the active context for the 12158 // Traverse the saved contexts chain to find the active context for the
12146 // selected frame. 12159 // selected frame.
12147 SaveContext* save = FindSavedContextForFrame(isolate, frame); 12160 SaveContext* save = FindSavedContextForFrame(isolate, frame);
12148 12161
12149 SaveContext savex(isolate); 12162 SaveContext savex(isolate);
12150 isolate->set_context(*(save->context())); 12163 isolate->set_context(*(save->context()));
12151 12164
12152 // Create the (empty) function replacing the function on the stack frame for 12165 // Create the (empty) function replacing the function on the stack frame for
12153 // the purpose of evaluating in the context created below. It is important 12166 // the purpose of evaluating in the context created below. It is important
12154 // that this function does not describe any parameters and local variables 12167 // that this function does not describe any parameters and local variables
12155 // in the context. If it does then this will cause problems with the lookup 12168 // in the context. If it does then this will cause problems with the lookup
12156 // in Context::Lookup, where context slots for parameters and local variables 12169 // in Context::Lookup, where context slots for parameters and local variables
12157 // are looked at before the extension object. 12170 // are looked at before the extension object.
12158 Handle<JSFunction> go_between = 12171 Handle<JSFunction> go_between =
12159 isolate->factory()->NewFunction(isolate->factory()->empty_string(), 12172 isolate->factory()->NewFunction(isolate->factory()->empty_string(),
12160 isolate->factory()->undefined_value()); 12173 isolate->factory()->undefined_value());
12161 go_between->set_context(function->context()); 12174 go_between->set_context(function->context());
12162 #ifdef DEBUG 12175 #ifdef DEBUG
12163 Handle<ScopeInfo> go_between_scope_info(go_between->shared()->scope_info()); 12176 Handle<ScopeInfo> go_between_scope_info(go_between->shared()->scope_info());
12164 ASSERT(go_between_scope_info->ParameterCount() == 0); 12177 ASSERT(go_between_scope_info->ParameterCount() == 0);
12165 ASSERT(go_between_scope_info->ContextLocalCount() == 0); 12178 ASSERT(go_between_scope_info->ContextLocalCount() == 0);
12166 #endif 12179 #endif
12167 12180
12168 // Materialize the content of the local scope into a JSObject. 12181 // Materialize the content of the local scope into a JSObject.
12169 Handle<JSObject> local_scope = MaterializeLocalScope( 12182 Handle<JSObject> local_scope = MaterializeLocalScopeWithFrameInspector(
12170 isolate, frame, inlined_frame_index); 12183 isolate, frame, &frame_inspector);
12171 RETURN_IF_EMPTY_HANDLE(isolate, local_scope); 12184 RETURN_IF_EMPTY_HANDLE(isolate, local_scope);
12172 12185
12173 // Allocate a new context for the debug evaluation and set the extension 12186 // Allocate a new context for the debug evaluation and set the extension
12174 // object build. 12187 // object build.
12175 Handle<Context> context = 12188 Handle<Context> context =
12176 isolate->factory()->NewFunctionContext(Context::MIN_CONTEXT_SLOTS, 12189 isolate->factory()->NewFunctionContext(Context::MIN_CONTEXT_SLOTS,
12177 go_between); 12190 go_between);
12178 context->set_extension(*local_scope); 12191 context->set_extension(*local_scope);
12179 // Copy any with contexts present and chain them in front of this context. 12192 // Copy any with contexts present and chain them in front of this context.
12180 Handle<Context> frame_context(Context::cast(frame->context())); 12193 Handle<Context> frame_context(Context::cast(frame->context()));
12181 Handle<Context> function_context; 12194 Handle<Context> function_context;
12182 // Get the function's context if it has one. 12195 // Get the function's context if it has one.
12183 if (scope_info->HasContext()) { 12196 if (scope_info->HasContext()) {
12184 function_context = Handle<Context>(frame_context->declaration_context()); 12197 function_context = Handle<Context>(frame_context->declaration_context());
12185 } 12198 }
12186 context = CopyNestedScopeContextChain(isolate, 12199 context = CopyNestedScopeContextChain(isolate,
12187 go_between, 12200 go_between,
12188 context, 12201 context,
12189 frame, 12202 frame,
12190 inlined_frame_index); 12203 inlined_jsframe_index);
12191 12204
12192 if (additional_context->IsJSObject()) { 12205 if (additional_context->IsJSObject()) {
12193 Handle<JSObject> extension = Handle<JSObject>::cast(additional_context); 12206 Handle<JSObject> extension = Handle<JSObject>::cast(additional_context);
12194 context = 12207 context =
12195 isolate->factory()->NewWithContext(go_between, context, extension); 12208 isolate->factory()->NewWithContext(go_between, context, extension);
12196 } 12209 }
12197 12210
12198 // Wrap the evaluation statement in a new function compiled in the newly 12211 // Wrap the evaluation statement in a new function compiled in the newly
12199 // created context. The function has one parameter which has to be called 12212 // created context. The function has one parameter which has to be called
12200 // 'arguments'. This it to have access to what would have been 'arguments' in 12213 // 'arguments'. This it to have access to what would have been 'arguments' in
(...skipping 19 matching lines...) Expand all
12220 // Invoke the result of the compilation to get the evaluation function. 12233 // Invoke the result of the compilation to get the evaluation function.
12221 bool has_pending_exception; 12234 bool has_pending_exception;
12222 Handle<Object> receiver(frame->receiver(), isolate); 12235 Handle<Object> receiver(frame->receiver(), isolate);
12223 Handle<Object> evaluation_function = 12236 Handle<Object> evaluation_function =
12224 Execution::Call(compiled_function, receiver, 0, NULL, 12237 Execution::Call(compiled_function, receiver, 0, NULL,
12225 &has_pending_exception); 12238 &has_pending_exception);
12226 if (has_pending_exception) return Failure::Exception(); 12239 if (has_pending_exception) return Failure::Exception();
12227 12240
12228 Handle<Object> arguments = GetArgumentsObject(isolate, 12241 Handle<Object> arguments = GetArgumentsObject(isolate,
12229 frame, 12242 frame,
12230 inlined_frame_index, 12243 &frame_inspector,
12231 function,
12232 scope_info, 12244 scope_info,
12233 function_context); 12245 function_context);
12234 12246
12235 // Invoke the evaluation function and return the result. 12247 // Invoke the evaluation function and return the result.
12236 Handle<Object> argv[] = { arguments, source }; 12248 Handle<Object> argv[] = { arguments, source };
12237 Handle<Object> result = 12249 Handle<Object> result =
12238 Execution::Call(Handle<JSFunction>::cast(evaluation_function), 12250 Execution::Call(Handle<JSFunction>::cast(evaluation_function),
12239 receiver, 12251 receiver,
12240 ARRAY_SIZE(argv), 12252 ARRAY_SIZE(argv),
12241 argv, 12253 argv,
(...skipping 1393 matching lines...) Expand 10 before | Expand all | Expand 10 after
13635 } else { 13647 } else {
13636 // Handle last resort GC and make sure to allow future allocations 13648 // Handle last resort GC and make sure to allow future allocations
13637 // to grow the heap without causing GCs (if possible). 13649 // to grow the heap without causing GCs (if possible).
13638 isolate->counters()->gc_last_resort_from_js()->Increment(); 13650 isolate->counters()->gc_last_resort_from_js()->Increment();
13639 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags); 13651 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags);
13640 } 13652 }
13641 } 13653 }
13642 13654
13643 13655
13644 } } // namespace v8::internal 13656 } } // namespace v8::internal
OLDNEW
« src/ia32/frames-ia32.h ('K') | « src/objects.cc ('k') | src/x64/builtins-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698