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 9958 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9969 return Smi::FromInt(0); | 9969 return Smi::FromInt(0); |
9970 } | 9970 } |
9971 | 9971 |
9972 for (JavaScriptFrameIterator it(isolate, id); !it.done(); it.Advance()) { | 9972 for (JavaScriptFrameIterator it(isolate, id); !it.done(); it.Advance()) { |
9973 n += it.frame()->GetInlineCount(); | 9973 n += it.frame()->GetInlineCount(); |
9974 } | 9974 } |
9975 return Smi::FromInt(n); | 9975 return Smi::FromInt(n); |
9976 } | 9976 } |
9977 | 9977 |
9978 | 9978 |
| 9979 class FrameInspector { |
| 9980 public: |
| 9981 FrameInspector(JavaScriptFrame* frame, |
| 9982 int inlined_frame_index, |
| 9983 Isolate* isolate) |
| 9984 : frame_(frame), deoptimized_frame_(NULL), isolate_(isolate) { |
| 9985 // Calculate the deoptimized frame. |
| 9986 if (frame->is_optimized()) { |
| 9987 deoptimized_frame_ = Deoptimizer::DebuggerInspectableFrame( |
| 9988 frame, inlined_frame_index, isolate); |
| 9989 } |
| 9990 has_adapted_arguments_ = frame_->has_adapted_arguments(); |
| 9991 is_optimized_ = frame_->is_optimized(); |
| 9992 } |
| 9993 |
| 9994 ~FrameInspector() { |
| 9995 // Get rid of the calculated deoptimized frame if any. |
| 9996 if (deoptimized_frame_ != NULL) { |
| 9997 Deoptimizer::DeleteDebuggerInspectableFrame(deoptimized_frame_, |
| 9998 isolate_); |
| 9999 } |
| 10000 } |
| 10001 |
| 10002 int GetParametersCount() { |
| 10003 return is_optimized_ |
| 10004 ? deoptimized_frame_->parameters_count() |
| 10005 : frame_->ComputeParametersCount(); |
| 10006 } |
| 10007 int expression_count() { return deoptimized_frame_->expression_count(); } |
| 10008 Object* GetFunction() { |
| 10009 return is_optimized_ |
| 10010 ? deoptimized_frame_->GetFunction() |
| 10011 : frame_->function(); |
| 10012 } |
| 10013 Object* GetParameter(int index) { |
| 10014 return is_optimized_ |
| 10015 ? deoptimized_frame_->GetParameter(index) |
| 10016 : frame_->GetParameter(index); |
| 10017 } |
| 10018 Object* GetExpression(int index) { |
| 10019 return is_optimized_ |
| 10020 ? deoptimized_frame_->GetExpression(index) |
| 10021 : frame_->GetExpression(index); |
| 10022 } |
| 10023 |
| 10024 // To inspect all the provided arguments the frame might need to be |
| 10025 // replaced with the arguments frame. |
| 10026 void SetArgumentsFrame(JavaScriptFrame* frame) { |
| 10027 ASSERT(has_adapted_arguments_); |
| 10028 frame_ = frame; |
| 10029 is_optimized_ = frame_->is_optimized(); |
| 10030 ASSERT(!is_optimized_); |
| 10031 } |
| 10032 |
| 10033 private: |
| 10034 JavaScriptFrame* frame_; |
| 10035 DeoptimizedFrameInfo* deoptimized_frame_; |
| 10036 Isolate* isolate_; |
| 10037 bool is_optimized_; |
| 10038 bool has_adapted_arguments_; |
| 10039 |
| 10040 DISALLOW_COPY_AND_ASSIGN(FrameInspector); |
| 10041 }; |
| 10042 |
| 10043 |
9979 static const int kFrameDetailsFrameIdIndex = 0; | 10044 static const int kFrameDetailsFrameIdIndex = 0; |
9980 static const int kFrameDetailsReceiverIndex = 1; | 10045 static const int kFrameDetailsReceiverIndex = 1; |
9981 static const int kFrameDetailsFunctionIndex = 2; | 10046 static const int kFrameDetailsFunctionIndex = 2; |
9982 static const int kFrameDetailsArgumentCountIndex = 3; | 10047 static const int kFrameDetailsArgumentCountIndex = 3; |
9983 static const int kFrameDetailsLocalCountIndex = 4; | 10048 static const int kFrameDetailsLocalCountIndex = 4; |
9984 static const int kFrameDetailsSourcePositionIndex = 5; | 10049 static const int kFrameDetailsSourcePositionIndex = 5; |
9985 static const int kFrameDetailsConstructCallIndex = 6; | 10050 static const int kFrameDetailsConstructCallIndex = 6; |
9986 static const int kFrameDetailsAtReturnIndex = 7; | 10051 static const int kFrameDetailsAtReturnIndex = 7; |
9987 static const int kFrameDetailsFlagsIndex = 8; | 10052 static const int kFrameDetailsFlagsIndex = 8; |
9988 static const int kFrameDetailsFirstDynamicIndex = 9; | 10053 static const int kFrameDetailsFirstDynamicIndex = 9; |
(...skipping 28 matching lines...) Expand all Loading... |
10017 CONVERT_NUMBER_CHECKED(int, index, Int32, args[1]); | 10082 CONVERT_NUMBER_CHECKED(int, index, Int32, args[1]); |
10018 Heap* heap = isolate->heap(); | 10083 Heap* heap = isolate->heap(); |
10019 | 10084 |
10020 // Find the relevant frame with the requested index. | 10085 // Find the relevant frame with the requested index. |
10021 StackFrame::Id id = isolate->debug()->break_frame_id(); | 10086 StackFrame::Id id = isolate->debug()->break_frame_id(); |
10022 if (id == StackFrame::NO_ID) { | 10087 if (id == StackFrame::NO_ID) { |
10023 // If there are no JavaScript stack frames return undefined. | 10088 // If there are no JavaScript stack frames return undefined. |
10024 return heap->undefined_value(); | 10089 return heap->undefined_value(); |
10025 } | 10090 } |
10026 | 10091 |
10027 int deoptimized_frame_index = -1; // Frame index in optimized frame. | 10092 int inlined_frame_index = 0; // Inlined frame index in optimized frame. |
10028 DeoptimizedFrameInfo* deoptimized_frame = NULL; | |
10029 | 10093 |
10030 int count = 0; | 10094 int count = 0; |
10031 JavaScriptFrameIterator it(isolate, id); | 10095 JavaScriptFrameIterator it(isolate, id); |
10032 for (; !it.done(); it.Advance()) { | 10096 for (; !it.done(); it.Advance()) { |
10033 if (index < count + it.frame()->GetInlineCount()) break; | 10097 if (index < count + it.frame()->GetInlineCount()) break; |
10034 count += it.frame()->GetInlineCount(); | 10098 count += it.frame()->GetInlineCount(); |
10035 } | 10099 } |
10036 if (it.done()) return heap->undefined_value(); | 10100 if (it.done()) return heap->undefined_value(); |
10037 | 10101 |
10038 if (it.frame()->is_optimized()) { | 10102 if (it.frame()->is_optimized()) { |
10039 deoptimized_frame_index = | 10103 inlined_frame_index = |
10040 it.frame()->GetInlineCount() - (index - count) - 1; | 10104 it.frame()->GetInlineCount() - (index - count) - 1; |
10041 deoptimized_frame = Deoptimizer::DebuggerInspectableFrame( | |
10042 it.frame(), | |
10043 deoptimized_frame_index, | |
10044 isolate); | |
10045 } | 10105 } |
| 10106 FrameInspector frame_inspector(it.frame(), inlined_frame_index, isolate); |
10046 | 10107 |
10047 // Traverse the saved contexts chain to find the active context for the | 10108 // Traverse the saved contexts chain to find the active context for the |
10048 // selected frame. | 10109 // selected frame. |
10049 SaveContext* save = isolate->save_context(); | 10110 SaveContext* save = isolate->save_context(); |
10050 while (save != NULL && !save->below(it.frame())) { | 10111 while (save != NULL && !save->below(it.frame())) { |
10051 save = save->prev(); | 10112 save = save->prev(); |
10052 } | 10113 } |
10053 ASSERT(save != NULL); | 10114 ASSERT(save != NULL); |
10054 | 10115 |
10055 // Get the frame id. | 10116 // Get the frame id. |
10056 Handle<Object> frame_id(WrapFrameId(it.frame()->id()), isolate); | 10117 Handle<Object> frame_id(WrapFrameId(it.frame()->id()), isolate); |
10057 | 10118 |
10058 // Find source position. | 10119 // Find source position. |
10059 int position = | 10120 int position = |
10060 it.frame()->LookupCode()->SourcePosition(it.frame()->pc()); | 10121 it.frame()->LookupCode()->SourcePosition(it.frame()->pc()); |
10061 | 10122 |
10062 // Check for constructor frame. Inlined frames cannot be construct calls. | 10123 // Check for constructor frame. Inlined frames cannot be construct calls. |
10063 bool inlined_frame = | 10124 bool inlined_frame = |
10064 it.frame()->is_optimized() && deoptimized_frame_index != 0; | 10125 it.frame()->is_optimized() && inlined_frame_index != 0; |
10065 bool constructor = !inlined_frame && it.frame()->IsConstructor(); | 10126 bool constructor = !inlined_frame && it.frame()->IsConstructor(); |
10066 | 10127 |
10067 // Get scope info and read from it for local variable information. | 10128 // Get scope info and read from it for local variable information. |
10068 Handle<JSFunction> function(JSFunction::cast(it.frame()->function())); | 10129 Handle<JSFunction> function(JSFunction::cast(it.frame()->function())); |
10069 Handle<SerializedScopeInfo> scope_info(function->shared()->scope_info()); | 10130 Handle<SerializedScopeInfo> scope_info(function->shared()->scope_info()); |
10070 ASSERT(*scope_info != SerializedScopeInfo::Empty()); | 10131 ASSERT(*scope_info != SerializedScopeInfo::Empty()); |
10071 ScopeInfo<> info(*scope_info); | 10132 ScopeInfo<> info(*scope_info); |
10072 | 10133 |
10073 // Get the locals names and values into a temporary array. | 10134 // Get the locals names and values into a temporary array. |
10074 // | 10135 // |
10075 // TODO(1240907): Hide compiler-introduced stack variables | 10136 // TODO(1240907): Hide compiler-introduced stack variables |
10076 // (e.g. .result)? For users of the debugger, they will probably be | 10137 // (e.g. .result)? For users of the debugger, they will probably be |
10077 // confusing. | 10138 // confusing. |
10078 Handle<FixedArray> locals = | 10139 Handle<FixedArray> locals = |
10079 isolate->factory()->NewFixedArray(info.NumberOfLocals() * 2); | 10140 isolate->factory()->NewFixedArray(info.NumberOfLocals() * 2); |
10080 | 10141 |
10081 // Fill in the values of the locals. | 10142 // Fill in the values of the locals. |
10082 int i = 0; | 10143 int i = 0; |
10083 for (; i < info.number_of_stack_slots(); ++i) { | 10144 for (; i < info.number_of_stack_slots(); ++i) { |
10084 // Use the value from the stack. | 10145 // Use the value from the stack. |
10085 locals->set(i * 2, *info.LocalName(i)); | 10146 locals->set(i * 2, *info.LocalName(i)); |
10086 if (it.frame()->is_optimized()) { | 10147 locals->set(i * 2 + 1, frame_inspector.GetExpression(i)); |
10087 // Get the value from the deoptimized frame. | |
10088 locals->set(i * 2 + 1, | |
10089 deoptimized_frame->GetExpression(i)); | |
10090 } else { | |
10091 // Get the value from the stack. | |
10092 locals->set(i * 2 + 1, it.frame()->GetExpression(i)); | |
10093 } | |
10094 } | 10148 } |
10095 if (i < info.NumberOfLocals()) { | 10149 if (i < info.NumberOfLocals()) { |
10096 // Get the context containing declarations. | 10150 // Get the context containing declarations. |
10097 Handle<Context> context( | 10151 Handle<Context> context( |
10098 Context::cast(it.frame()->context())->declaration_context()); | 10152 Context::cast(it.frame()->context())->declaration_context()); |
10099 for (; i < info.NumberOfLocals(); ++i) { | 10153 for (; i < info.NumberOfLocals(); ++i) { |
10100 Handle<String> name = info.LocalName(i); | 10154 Handle<String> name = info.LocalName(i); |
10101 locals->set(i * 2, *name); | 10155 locals->set(i * 2, *name); |
10102 locals->set(i * 2 + 1, | 10156 locals->set(i * 2 + 1, |
10103 context->get(scope_info->ContextSlotIndex(*name, NULL))); | 10157 context->get(scope_info->ContextSlotIndex(*name, NULL))); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10140 internal_frame_sp = NULL; | 10194 internal_frame_sp = NULL; |
10141 } | 10195 } |
10142 it2.Advance(); | 10196 it2.Advance(); |
10143 } | 10197 } |
10144 } | 10198 } |
10145 | 10199 |
10146 // Now advance to the arguments adapter frame (if any). It contains all | 10200 // Now advance to the arguments adapter frame (if any). It contains all |
10147 // the provided parameters whereas the function frame always have the number | 10201 // the provided parameters whereas the function frame always have the number |
10148 // of arguments matching the functions parameters. The rest of the | 10202 // of arguments matching the functions parameters. The rest of the |
10149 // information (except for what is collected above) is the same. | 10203 // information (except for what is collected above) is the same. |
10150 it.AdvanceToArgumentsFrame(); | 10204 if (it.frame()->has_adapted_arguments()) { |
| 10205 it.AdvanceToArgumentsFrame(); |
| 10206 frame_inspector.SetArgumentsFrame(it.frame()); |
| 10207 } |
10151 | 10208 |
10152 // Find the number of arguments to fill. At least fill the number of | 10209 // Find the number of arguments to fill. At least fill the number of |
10153 // parameters for the function and fill more if more parameters are provided. | 10210 // parameters for the function and fill more if more parameters are provided. |
10154 int argument_count = info.number_of_parameters(); | 10211 int argument_count = info.number_of_parameters(); |
| 10212 if (argument_count < frame_inspector.GetParametersCount()) { |
| 10213 argument_count = frame_inspector.GetParametersCount(); |
| 10214 } |
| 10215 #ifdef DEBUG |
10155 if (it.frame()->is_optimized()) { | 10216 if (it.frame()->is_optimized()) { |
10156 ASSERT_EQ(argument_count, deoptimized_frame->parameters_count()); | 10217 ASSERT_EQ(argument_count, frame_inspector.GetParametersCount()); |
10157 } else { | |
10158 if (argument_count < it.frame()->ComputeParametersCount()) { | |
10159 argument_count = it.frame()->ComputeParametersCount(); | |
10160 } | |
10161 } | 10218 } |
| 10219 #endif |
10162 | 10220 |
10163 // Calculate the size of the result. | 10221 // Calculate the size of the result. |
10164 int details_size = kFrameDetailsFirstDynamicIndex + | 10222 int details_size = kFrameDetailsFirstDynamicIndex + |
10165 2 * (argument_count + info.NumberOfLocals()) + | 10223 2 * (argument_count + info.NumberOfLocals()) + |
10166 (at_return ? 1 : 0); | 10224 (at_return ? 1 : 0); |
10167 Handle<FixedArray> details = isolate->factory()->NewFixedArray(details_size); | 10225 Handle<FixedArray> details = isolate->factory()->NewFixedArray(details_size); |
10168 | 10226 |
10169 // Add the frame id. | 10227 // Add the frame id. |
10170 details->set(kFrameDetailsFrameIdIndex, *frame_id); | 10228 details->set(kFrameDetailsFrameIdIndex, *frame_id); |
10171 | 10229 |
10172 // Add the function (same as in function frame). | 10230 // Add the function (same as in function frame). |
10173 if (it.frame()->is_optimized()) { | 10231 details->set(kFrameDetailsFunctionIndex, frame_inspector.GetFunction()); |
10174 // Get the function from the deoptimized frame. | |
10175 details->set(kFrameDetailsFunctionIndex, deoptimized_frame->GetFunction()); | |
10176 } else { | |
10177 // Get the function from the stack. | |
10178 details->set(kFrameDetailsFunctionIndex, it.frame()->function()); | |
10179 } | |
10180 | 10232 |
10181 // Add the arguments count. | 10233 // Add the arguments count. |
10182 details->set(kFrameDetailsArgumentCountIndex, Smi::FromInt(argument_count)); | 10234 details->set(kFrameDetailsArgumentCountIndex, Smi::FromInt(argument_count)); |
10183 | 10235 |
10184 // Add the locals count | 10236 // Add the locals count |
10185 details->set(kFrameDetailsLocalCountIndex, | 10237 details->set(kFrameDetailsLocalCountIndex, |
10186 Smi::FromInt(info.NumberOfLocals())); | 10238 Smi::FromInt(info.NumberOfLocals())); |
10187 | 10239 |
10188 // Add the source position. | 10240 // Add the source position. |
10189 if (position != RelocInfo::kNoPosition) { | 10241 if (position != RelocInfo::kNoPosition) { |
(...skipping 11 matching lines...) Expand all Loading... |
10201 // Add flags to indicate information on whether this frame is | 10253 // Add flags to indicate information on whether this frame is |
10202 // bit 0: invoked in the debugger context. | 10254 // bit 0: invoked in the debugger context. |
10203 // bit 1: optimized frame. | 10255 // bit 1: optimized frame. |
10204 // bit 2: inlined in optimized frame | 10256 // bit 2: inlined in optimized frame |
10205 int flags = 0; | 10257 int flags = 0; |
10206 if (*save->context() == *isolate->debug()->debug_context()) { | 10258 if (*save->context() == *isolate->debug()->debug_context()) { |
10207 flags |= 1 << 0; | 10259 flags |= 1 << 0; |
10208 } | 10260 } |
10209 if (it.frame()->is_optimized()) { | 10261 if (it.frame()->is_optimized()) { |
10210 flags |= 1 << 1; | 10262 flags |= 1 << 1; |
10211 if (deoptimized_frame_index > 0) { | 10263 flags |= inlined_frame_index << 2; |
10212 flags |= 1 << 2; | |
10213 } | |
10214 } | 10264 } |
10215 details->set(kFrameDetailsFlagsIndex, Smi::FromInt(flags)); | 10265 details->set(kFrameDetailsFlagsIndex, Smi::FromInt(flags)); |
10216 | 10266 |
10217 // Fill the dynamic part. | 10267 // Fill the dynamic part. |
10218 int details_index = kFrameDetailsFirstDynamicIndex; | 10268 int details_index = kFrameDetailsFirstDynamicIndex; |
10219 | 10269 |
10220 // Add arguments name and value. | 10270 // Add arguments name and value. |
10221 for (int i = 0; i < argument_count; i++) { | 10271 for (int i = 0; i < argument_count; i++) { |
10222 // Name of the argument. | 10272 // Name of the argument. |
10223 if (i < info.number_of_parameters()) { | 10273 if (i < info.number_of_parameters()) { |
10224 details->set(details_index++, *info.parameter_name(i)); | 10274 details->set(details_index++, *info.parameter_name(i)); |
10225 } else { | 10275 } else { |
10226 details->set(details_index++, heap->undefined_value()); | 10276 details->set(details_index++, heap->undefined_value()); |
10227 } | 10277 } |
10228 | 10278 |
10229 // Parameter value. | 10279 // Parameter value. |
10230 if (it.frame()->is_optimized()) { | 10280 if (i < it.frame()->ComputeParametersCount()) { |
10231 // Get the value from the deoptimized frame. | 10281 // Get the value from the stack. |
10232 details->set(details_index++, deoptimized_frame->GetParameter(i)); | 10282 details->set(details_index++, frame_inspector.GetParameter(i)); |
10233 } else { | 10283 } else { |
10234 if (i < it.frame()->ComputeParametersCount()) { | 10284 details->set(details_index++, heap->undefined_value()); |
10235 // Get the value from the stack. | |
10236 details->set(details_index++, it.frame()->GetParameter(i)); | |
10237 } else { | |
10238 details->set(details_index++, heap->undefined_value()); | |
10239 } | |
10240 } | 10285 } |
10241 } | 10286 } |
10242 | 10287 |
10243 // Add locals name and value from the temporary copy from the function frame. | 10288 // Add locals name and value from the temporary copy from the function frame. |
10244 for (int i = 0; i < info.NumberOfLocals() * 2; i++) { | 10289 for (int i = 0; i < info.NumberOfLocals() * 2; i++) { |
10245 details->set(details_index++, locals->get(i)); | 10290 details->set(details_index++, locals->get(i)); |
10246 } | 10291 } |
10247 | 10292 |
10248 // Add the value being returned. | 10293 // Add the value being returned. |
10249 if (at_return) { | 10294 if (at_return) { |
(...skipping 11 matching lines...) Expand all Loading... |
10261 // by creating correct wrapper object based on the calling frame's | 10306 // by creating correct wrapper object based on the calling frame's |
10262 // global context. | 10307 // global context. |
10263 it.Advance(); | 10308 it.Advance(); |
10264 Handle<Context> calling_frames_global_context( | 10309 Handle<Context> calling_frames_global_context( |
10265 Context::cast(Context::cast(it.frame()->context())->global_context())); | 10310 Context::cast(Context::cast(it.frame()->context())->global_context())); |
10266 receiver = | 10311 receiver = |
10267 isolate->factory()->ToObject(receiver, calling_frames_global_context); | 10312 isolate->factory()->ToObject(receiver, calling_frames_global_context); |
10268 } | 10313 } |
10269 details->set(kFrameDetailsReceiverIndex, *receiver); | 10314 details->set(kFrameDetailsReceiverIndex, *receiver); |
10270 | 10315 |
10271 // Get rid of the calculated deoptimized frame if any. | |
10272 if (deoptimized_frame != NULL) { | |
10273 Deoptimizer::DeleteDebuggerInspectableFrame(deoptimized_frame, | |
10274 isolate); | |
10275 } | |
10276 | |
10277 ASSERT_EQ(details_size, details_index); | 10316 ASSERT_EQ(details_size, details_index); |
10278 return *isolate->factory()->NewJSArrayWithElements(details); | 10317 return *isolate->factory()->NewJSArrayWithElements(details); |
10279 } | 10318 } |
10280 | 10319 |
10281 | 10320 |
10282 // Copy all the context locals into an object used to materialize a scope. | 10321 // Copy all the context locals into an object used to materialize a scope. |
10283 static bool CopyContextLocalsToScopeObject( | 10322 static bool CopyContextLocalsToScopeObject( |
10284 Isolate* isolate, | 10323 Isolate* isolate, |
10285 Handle<SerializedScopeInfo> serialized_scope_info, | 10324 Handle<SerializedScopeInfo> serialized_scope_info, |
10286 ScopeInfo<>& scope_info, | 10325 ScopeInfo<>& scope_info, |
(...skipping 15 matching lines...) Expand all Loading... |
10302 kNonStrictMode), | 10341 kNonStrictMode), |
10303 false); | 10342 false); |
10304 } | 10343 } |
10305 | 10344 |
10306 return true; | 10345 return true; |
10307 } | 10346 } |
10308 | 10347 |
10309 | 10348 |
10310 // Create a plain JSObject which materializes the local scope for the specified | 10349 // Create a plain JSObject which materializes the local scope for the specified |
10311 // frame. | 10350 // frame. |
10312 static Handle<JSObject> MaterializeLocalScope(Isolate* isolate, | 10351 static Handle<JSObject> MaterializeLocalScope( |
10313 JavaScriptFrame* frame) { | 10352 Isolate* isolate, |
| 10353 JavaScriptFrame* frame, |
| 10354 int inlined_frame_index) { |
10314 Handle<JSFunction> function(JSFunction::cast(frame->function())); | 10355 Handle<JSFunction> function(JSFunction::cast(frame->function())); |
10315 Handle<SharedFunctionInfo> shared(function->shared()); | 10356 Handle<SharedFunctionInfo> shared(function->shared()); |
10316 Handle<SerializedScopeInfo> serialized_scope_info(shared->scope_info()); | 10357 Handle<SerializedScopeInfo> serialized_scope_info(shared->scope_info()); |
10317 ScopeInfo<> scope_info(*serialized_scope_info); | 10358 ScopeInfo<> scope_info(*serialized_scope_info); |
| 10359 FrameInspector frame_inspector(frame, inlined_frame_index, isolate); |
10318 | 10360 |
10319 // Allocate and initialize a JSObject with all the arguments, stack locals | 10361 // Allocate and initialize a JSObject with all the arguments, stack locals |
10320 // heap locals and extension properties of the debugged function. | 10362 // heap locals and extension properties of the debugged function. |
10321 Handle<JSObject> local_scope = | 10363 Handle<JSObject> local_scope = |
10322 isolate->factory()->NewJSObject(isolate->object_function()); | 10364 isolate->factory()->NewJSObject(isolate->object_function()); |
10323 | 10365 |
10324 // First fill all parameters. | 10366 // First fill all parameters. |
10325 for (int i = 0; i < scope_info.number_of_parameters(); ++i) { | 10367 for (int i = 0; i < scope_info.number_of_parameters(); ++i) { |
10326 RETURN_IF_EMPTY_HANDLE_VALUE( | 10368 RETURN_IF_EMPTY_HANDLE_VALUE( |
10327 isolate, | 10369 isolate, |
10328 SetProperty(local_scope, | 10370 SetProperty(local_scope, |
10329 scope_info.parameter_name(i), | 10371 scope_info.parameter_name(i), |
10330 Handle<Object>(frame->GetParameter(i), isolate), | 10372 Handle<Object>(frame_inspector.GetParameter(i)), |
10331 NONE, | 10373 NONE, |
10332 kNonStrictMode), | 10374 kNonStrictMode), |
10333 Handle<JSObject>()); | 10375 Handle<JSObject>()); |
10334 } | 10376 } |
10335 | 10377 |
10336 // Second fill all stack locals. | 10378 // Second fill all stack locals. |
10337 for (int i = 0; i < scope_info.number_of_stack_slots(); ++i) { | 10379 for (int i = 0; i < scope_info.number_of_stack_slots(); ++i) { |
10338 RETURN_IF_EMPTY_HANDLE_VALUE( | 10380 RETURN_IF_EMPTY_HANDLE_VALUE( |
10339 isolate, | 10381 isolate, |
10340 SetProperty(local_scope, | 10382 SetProperty(local_scope, |
10341 scope_info.stack_slot_name(i), | 10383 scope_info.stack_slot_name(i), |
10342 Handle<Object>(frame->GetExpression(i), isolate), | 10384 Handle<Object>(frame_inspector.GetExpression(i)), |
10343 NONE, | 10385 NONE, |
10344 kNonStrictMode), | 10386 kNonStrictMode), |
10345 Handle<JSObject>()); | 10387 Handle<JSObject>()); |
10346 } | 10388 } |
10347 | 10389 |
10348 if (scope_info.number_of_context_slots() > Context::MIN_CONTEXT_SLOTS) { | 10390 if (scope_info.number_of_context_slots() > Context::MIN_CONTEXT_SLOTS) { |
10349 // Third fill all context locals. | 10391 // Third fill all context locals. |
10350 Handle<Context> frame_context(Context::cast(frame->context())); | 10392 Handle<Context> frame_context(Context::cast(frame->context())); |
10351 Handle<Context> function_context(frame_context->declaration_context()); | 10393 Handle<Context> function_context(frame_context->declaration_context()); |
10352 if (!CopyContextLocalsToScopeObject(isolate, | 10394 if (!CopyContextLocalsToScopeObject(isolate, |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10452 class ScopeIterator { | 10494 class ScopeIterator { |
10453 public: | 10495 public: |
10454 enum ScopeType { | 10496 enum ScopeType { |
10455 ScopeTypeGlobal = 0, | 10497 ScopeTypeGlobal = 0, |
10456 ScopeTypeLocal, | 10498 ScopeTypeLocal, |
10457 ScopeTypeWith, | 10499 ScopeTypeWith, |
10458 ScopeTypeClosure, | 10500 ScopeTypeClosure, |
10459 ScopeTypeCatch | 10501 ScopeTypeCatch |
10460 }; | 10502 }; |
10461 | 10503 |
10462 ScopeIterator(Isolate* isolate, JavaScriptFrame* frame) | 10504 ScopeIterator(Isolate* isolate, |
| 10505 JavaScriptFrame* frame, |
| 10506 int inlined_frame_index) |
10463 : isolate_(isolate), | 10507 : isolate_(isolate), |
10464 frame_(frame), | 10508 frame_(frame), |
| 10509 inlined_frame_index_(inlined_frame_index), |
10465 function_(JSFunction::cast(frame->function())), | 10510 function_(JSFunction::cast(frame->function())), |
10466 context_(Context::cast(frame->context())), | 10511 context_(Context::cast(frame->context())), |
10467 local_done_(false), | 10512 local_done_(false), |
10468 at_local_(false) { | 10513 at_local_(false) { |
10469 | 10514 |
10470 // Check whether the first scope is actually a local scope. | 10515 // Check whether the first scope is actually a local scope. |
10471 if (context_->IsGlobalContext()) { | 10516 if (context_->IsGlobalContext()) { |
10472 // If there is a stack slot for .result then this local scope has been | 10517 // If there is a stack slot for .result then this local scope has been |
10473 // created for evaluating top level code and it is not a real local scope. | 10518 // created for evaluating top level code and it is not a real local scope. |
10474 // Checking for the existence of .result seems fragile, but the scope info | 10519 // Checking for the existence of .result seems fragile, but the scope info |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10539 return ScopeTypeWith; | 10584 return ScopeTypeWith; |
10540 } | 10585 } |
10541 | 10586 |
10542 // Return the JavaScript object with the content of the current scope. | 10587 // Return the JavaScript object with the content of the current scope. |
10543 Handle<JSObject> ScopeObject() { | 10588 Handle<JSObject> ScopeObject() { |
10544 switch (Type()) { | 10589 switch (Type()) { |
10545 case ScopeIterator::ScopeTypeGlobal: | 10590 case ScopeIterator::ScopeTypeGlobal: |
10546 return Handle<JSObject>(CurrentContext()->global()); | 10591 return Handle<JSObject>(CurrentContext()->global()); |
10547 case ScopeIterator::ScopeTypeLocal: | 10592 case ScopeIterator::ScopeTypeLocal: |
10548 // Materialize the content of the local scope into a JSObject. | 10593 // Materialize the content of the local scope into a JSObject. |
10549 return MaterializeLocalScope(isolate_, frame_); | 10594 return MaterializeLocalScope(isolate_, frame_, inlined_frame_index_); |
10550 case ScopeIterator::ScopeTypeWith: | 10595 case ScopeIterator::ScopeTypeWith: |
10551 // Return the with object. | 10596 // Return the with object. |
10552 return Handle<JSObject>(JSObject::cast(CurrentContext()->extension())); | 10597 return Handle<JSObject>(JSObject::cast(CurrentContext()->extension())); |
10553 case ScopeIterator::ScopeTypeCatch: | 10598 case ScopeIterator::ScopeTypeCatch: |
10554 return MaterializeCatchScope(isolate_, CurrentContext()); | 10599 return MaterializeCatchScope(isolate_, CurrentContext()); |
10555 case ScopeIterator::ScopeTypeClosure: | 10600 case ScopeIterator::ScopeTypeClosure: |
10556 // Materialize the content of the closure scope into a JSObject. | 10601 // Materialize the content of the closure scope into a JSObject. |
10557 return MaterializeClosure(isolate_, CurrentContext()); | 10602 return MaterializeClosure(isolate_, CurrentContext()); |
10558 } | 10603 } |
10559 UNREACHABLE(); | 10604 UNREACHABLE(); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10619 default: | 10664 default: |
10620 UNREACHABLE(); | 10665 UNREACHABLE(); |
10621 } | 10666 } |
10622 PrintF("\n"); | 10667 PrintF("\n"); |
10623 } | 10668 } |
10624 #endif | 10669 #endif |
10625 | 10670 |
10626 private: | 10671 private: |
10627 Isolate* isolate_; | 10672 Isolate* isolate_; |
10628 JavaScriptFrame* frame_; | 10673 JavaScriptFrame* frame_; |
| 10674 int inlined_frame_index_; |
10629 Handle<JSFunction> function_; | 10675 Handle<JSFunction> function_; |
10630 Handle<Context> context_; | 10676 Handle<Context> context_; |
10631 bool local_done_; | 10677 bool local_done_; |
10632 bool at_local_; | 10678 bool at_local_; |
10633 | 10679 |
10634 DISALLOW_IMPLICIT_CONSTRUCTORS(ScopeIterator); | 10680 DISALLOW_IMPLICIT_CONSTRUCTORS(ScopeIterator); |
10635 }; | 10681 }; |
10636 | 10682 |
10637 | 10683 |
10638 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetScopeCount) { | 10684 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetScopeCount) { |
10639 HandleScope scope(isolate); | 10685 HandleScope scope(isolate); |
10640 ASSERT(args.length() == 2); | 10686 ASSERT(args.length() == 2); |
10641 | 10687 |
10642 // Check arguments. | 10688 // Check arguments. |
10643 Object* check; | 10689 Object* check; |
10644 { MaybeObject* maybe_check = Runtime_CheckExecutionState( | 10690 { MaybeObject* maybe_check = Runtime_CheckExecutionState( |
10645 RUNTIME_ARGUMENTS(isolate, args)); | 10691 RUNTIME_ARGUMENTS(isolate, args)); |
10646 if (!maybe_check->ToObject(&check)) return maybe_check; | 10692 if (!maybe_check->ToObject(&check)) return maybe_check; |
10647 } | 10693 } |
10648 CONVERT_CHECKED(Smi, wrapped_id, args[1]); | 10694 CONVERT_CHECKED(Smi, wrapped_id, args[1]); |
10649 | 10695 |
10650 // Get the frame where the debugging is performed. | 10696 // Get the frame where the debugging is performed. |
10651 StackFrame::Id id = UnwrapFrameId(wrapped_id); | 10697 StackFrame::Id id = UnwrapFrameId(wrapped_id); |
10652 JavaScriptFrameIterator it(isolate, id); | 10698 JavaScriptFrameIterator it(isolate, id); |
10653 JavaScriptFrame* frame = it.frame(); | 10699 JavaScriptFrame* frame = it.frame(); |
10654 | 10700 |
10655 // Count the visible scopes. | 10701 // Count the visible scopes. |
10656 int n = 0; | 10702 int n = 0; |
10657 for (ScopeIterator it(isolate, frame); !it.Done(); it.Next()) { | 10703 for (ScopeIterator it(isolate, frame, 0); |
| 10704 !it.Done(); |
| 10705 it.Next()) { |
10658 n++; | 10706 n++; |
10659 } | 10707 } |
10660 | 10708 |
10661 return Smi::FromInt(n); | 10709 return Smi::FromInt(n); |
10662 } | 10710 } |
10663 | 10711 |
10664 | 10712 |
10665 static const int kScopeDetailsTypeIndex = 0; | 10713 static const int kScopeDetailsTypeIndex = 0; |
10666 static const int kScopeDetailsObjectIndex = 1; | 10714 static const int kScopeDetailsObjectIndex = 1; |
10667 static const int kScopeDetailsSize = 2; | 10715 static const int kScopeDetailsSize = 2; |
10668 | 10716 |
10669 // Return an array with scope details | 10717 // Return an array with scope details |
10670 // args[0]: number: break id | 10718 // args[0]: number: break id |
10671 // args[1]: number: frame index | 10719 // args[1]: number: frame index |
10672 // args[2]: number: scope index | 10720 // args[2]: number: inlined frame index |
| 10721 // args[3]: number: scope index |
10673 // | 10722 // |
10674 // The array returned contains the following information: | 10723 // The array returned contains the following information: |
10675 // 0: Scope type | 10724 // 0: Scope type |
10676 // 1: Scope object | 10725 // 1: Scope object |
10677 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetScopeDetails) { | 10726 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetScopeDetails) { |
10678 HandleScope scope(isolate); | 10727 HandleScope scope(isolate); |
10679 ASSERT(args.length() == 3); | 10728 ASSERT(args.length() == 4); |
10680 | 10729 |
10681 // Check arguments. | 10730 // Check arguments. |
10682 Object* check; | 10731 Object* check; |
10683 { MaybeObject* maybe_check = Runtime_CheckExecutionState( | 10732 { MaybeObject* maybe_check = Runtime_CheckExecutionState( |
10684 RUNTIME_ARGUMENTS(isolate, args)); | 10733 RUNTIME_ARGUMENTS(isolate, args)); |
10685 if (!maybe_check->ToObject(&check)) return maybe_check; | 10734 if (!maybe_check->ToObject(&check)) return maybe_check; |
10686 } | 10735 } |
10687 CONVERT_CHECKED(Smi, wrapped_id, args[1]); | 10736 CONVERT_CHECKED(Smi, wrapped_id, args[1]); |
10688 CONVERT_NUMBER_CHECKED(int, index, Int32, args[2]); | 10737 CONVERT_NUMBER_CHECKED(int, inlined_frame_index, Int32, args[2]); |
| 10738 CONVERT_NUMBER_CHECKED(int, index, Int32, args[3]); |
10689 | 10739 |
10690 // Get the frame where the debugging is performed. | 10740 // Get the frame where the debugging is performed. |
10691 StackFrame::Id id = UnwrapFrameId(wrapped_id); | 10741 StackFrame::Id id = UnwrapFrameId(wrapped_id); |
10692 JavaScriptFrameIterator frame_it(isolate, id); | 10742 JavaScriptFrameIterator frame_it(isolate, id); |
10693 JavaScriptFrame* frame = frame_it.frame(); | 10743 JavaScriptFrame* frame = frame_it.frame(); |
10694 | 10744 |
10695 // Find the requested scope. | 10745 // Find the requested scope. |
10696 int n = 0; | 10746 int n = 0; |
10697 ScopeIterator it(isolate, frame); | 10747 ScopeIterator it(isolate, frame, inlined_frame_index); |
10698 for (; !it.Done() && n < index; it.Next()) { | 10748 for (; !it.Done() && n < index; it.Next()) { |
10699 n++; | 10749 n++; |
10700 } | 10750 } |
10701 if (it.Done()) { | 10751 if (it.Done()) { |
10702 return isolate->heap()->undefined_value(); | 10752 return isolate->heap()->undefined_value(); |
10703 } | 10753 } |
10704 | 10754 |
10705 // Calculate the size of the result. | 10755 // Calculate the size of the result. |
10706 int details_size = kScopeDetailsSize; | 10756 int details_size = kScopeDetailsSize; |
10707 Handle<FixedArray> details = isolate->factory()->NewFixedArray(details_size); | 10757 Handle<FixedArray> details = isolate->factory()->NewFixedArray(details_size); |
10708 | 10758 |
10709 // Fill in scope details. | 10759 // Fill in scope details. |
10710 details->set(kScopeDetailsTypeIndex, Smi::FromInt(it.Type())); | 10760 details->set(kScopeDetailsTypeIndex, Smi::FromInt(it.Type())); |
10711 Handle<JSObject> scope_object = it.ScopeObject(); | 10761 Handle<JSObject> scope_object = it.ScopeObject(); |
10712 RETURN_IF_EMPTY_HANDLE(isolate, scope_object); | 10762 RETURN_IF_EMPTY_HANDLE(isolate, scope_object); |
10713 details->set(kScopeDetailsObjectIndex, *scope_object); | 10763 details->set(kScopeDetailsObjectIndex, *scope_object); |
10714 | 10764 |
10715 return *isolate->factory()->NewJSArrayWithElements(details); | 10765 return *isolate->factory()->NewJSArrayWithElements(details); |
10716 } | 10766 } |
10717 | 10767 |
10718 | 10768 |
10719 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugPrintScopes) { | 10769 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugPrintScopes) { |
10720 HandleScope scope(isolate); | 10770 HandleScope scope(isolate); |
10721 ASSERT(args.length() == 0); | 10771 ASSERT(args.length() == 0); |
10722 | 10772 |
10723 #ifdef DEBUG | 10773 #ifdef DEBUG |
10724 // Print the scopes for the top frame. | 10774 // Print the scopes for the top frame. |
10725 StackFrameLocator locator; | 10775 StackFrameLocator locator; |
10726 JavaScriptFrame* frame = locator.FindJavaScriptFrame(0); | 10776 JavaScriptFrame* frame = locator.FindJavaScriptFrame(0); |
10727 for (ScopeIterator it(isolate, frame); !it.Done(); it.Next()) { | 10777 for (ScopeIterator it(isolate, frame, 0); |
| 10778 !it.Done(); |
| 10779 it.Next()) { |
10728 it.DebugPrint(); | 10780 it.DebugPrint(); |
10729 } | 10781 } |
10730 #endif | 10782 #endif |
10731 return isolate->heap()->undefined_value(); | 10783 return isolate->heap()->undefined_value(); |
10732 } | 10784 } |
10733 | 10785 |
10734 | 10786 |
10735 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetThreadCount) { | 10787 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetThreadCount) { |
10736 HandleScope scope(isolate); | 10788 HandleScope scope(isolate); |
10737 ASSERT(args.length() == 1); | 10789 ASSERT(args.length() == 1); |
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11110 isolate->factory()->NewWithContext(function, new_previous, extension); | 11162 isolate->factory()->NewWithContext(function, new_previous, extension); |
11111 } | 11163 } |
11112 return scope.CloseAndEscape(new_current); | 11164 return scope.CloseAndEscape(new_current); |
11113 } | 11165 } |
11114 | 11166 |
11115 | 11167 |
11116 // Helper function to find or create the arguments object for | 11168 // Helper function to find or create the arguments object for |
11117 // Runtime_DebugEvaluate. | 11169 // Runtime_DebugEvaluate. |
11118 static Handle<Object> GetArgumentsObject(Isolate* isolate, | 11170 static Handle<Object> GetArgumentsObject(Isolate* isolate, |
11119 JavaScriptFrame* frame, | 11171 JavaScriptFrame* frame, |
| 11172 int inlined_frame_index, |
11120 Handle<JSFunction> function, | 11173 Handle<JSFunction> function, |
11121 Handle<SerializedScopeInfo> scope_info, | 11174 Handle<SerializedScopeInfo> scope_info, |
11122 const ScopeInfo<>* sinfo, | 11175 const ScopeInfo<>* sinfo, |
11123 Handle<Context> function_context) { | 11176 Handle<Context> function_context) { |
11124 // Try to find the value of 'arguments' to pass as parameter. If it is not | 11177 // Try to find the value of 'arguments' to pass as parameter. If it is not |
11125 // found (that is the debugged function does not reference 'arguments' and | 11178 // found (that is the debugged function does not reference 'arguments' and |
11126 // does not support eval) then create an 'arguments' object. | 11179 // does not support eval) then create an 'arguments' object. |
11127 int index; | 11180 int index; |
11128 if (sinfo->number_of_stack_slots() > 0) { | 11181 if (sinfo->number_of_stack_slots() > 0) { |
11129 index = scope_info->StackSlotIndex(isolate->heap()->arguments_symbol()); | 11182 index = scope_info->StackSlotIndex(isolate->heap()->arguments_symbol()); |
11130 if (index != -1) { | 11183 if (index != -1) { |
| 11184 CHECK(false); |
11131 return Handle<Object>(frame->GetExpression(index), isolate); | 11185 return Handle<Object>(frame->GetExpression(index), isolate); |
11132 } | 11186 } |
11133 } | 11187 } |
11134 | 11188 |
11135 if (sinfo->number_of_context_slots() > Context::MIN_CONTEXT_SLOTS) { | 11189 if (sinfo->number_of_context_slots() > Context::MIN_CONTEXT_SLOTS) { |
11136 index = scope_info->ContextSlotIndex(isolate->heap()->arguments_symbol(), | 11190 index = scope_info->ContextSlotIndex(isolate->heap()->arguments_symbol(), |
11137 NULL); | 11191 NULL); |
11138 if (index != -1) { | 11192 if (index != -1) { |
11139 return Handle<Object>(function_context->get(index), isolate); | 11193 return Handle<Object>(function_context->get(index), isolate); |
11140 } | 11194 } |
11141 } | 11195 } |
11142 | 11196 |
11143 const int length = frame->ComputeParametersCount(); | 11197 FrameInspector frame_inspector(frame, inlined_frame_index, isolate); |
| 11198 |
| 11199 int length = frame_inspector.GetParametersCount(); |
11144 Handle<JSObject> arguments = | 11200 Handle<JSObject> arguments = |
11145 isolate->factory()->NewArgumentsObject(function, length); | 11201 isolate->factory()->NewArgumentsObject(function, length); |
11146 Handle<FixedArray> array = isolate->factory()->NewFixedArray(length); | 11202 Handle<FixedArray> array = isolate->factory()->NewFixedArray(length); |
11147 | 11203 |
11148 AssertNoAllocation no_gc; | 11204 AssertNoAllocation no_gc; |
11149 WriteBarrierMode mode = array->GetWriteBarrierMode(no_gc); | 11205 WriteBarrierMode mode = array->GetWriteBarrierMode(no_gc); |
11150 for (int i = 0; i < length; i++) { | 11206 for (int i = 0; i < length; i++) { |
11151 array->set(i, frame->GetParameter(i), mode); | 11207 array->set(i, frame_inspector.GetParameter(i), mode); |
11152 } | 11208 } |
11153 arguments->set_elements(*array); | 11209 arguments->set_elements(*array); |
11154 return arguments; | 11210 return arguments; |
11155 } | 11211 } |
11156 | 11212 |
11157 | 11213 |
11158 static const char kSourceStr[] = | 11214 static const char kSourceStr[] = |
11159 "(function(arguments,__source__){return eval(__source__);})"; | 11215 "(function(arguments,__source__){return eval(__source__);})"; |
11160 | 11216 |
11161 | 11217 |
11162 // Evaluate a piece of JavaScript in the context of a stack frame for | 11218 // Evaluate a piece of JavaScript in the context of a stack frame for |
11163 // debugging. This is accomplished by creating a new context which in its | 11219 // debugging. This is accomplished by creating a new context which in its |
11164 // extension part has all the parameters and locals of the function on the | 11220 // extension part has all the parameters and locals of the function on the |
11165 // stack frame. A function which calls eval with the code to evaluate is then | 11221 // stack frame. A function which calls eval with the code to evaluate is then |
11166 // compiled in this context and called in this context. As this context | 11222 // compiled in this context and called in this context. As this context |
11167 // replaces the context of the function on the stack frame a new (empty) | 11223 // replaces the context of the function on the stack frame a new (empty) |
11168 // function is created as well to be used as the closure for the context. | 11224 // function is created as well to be used as the closure for the context. |
11169 // This function and the context acts as replacements for the function on the | 11225 // This function and the context acts as replacements for the function on the |
11170 // stack frame presenting the same view of the values of parameters and | 11226 // stack frame presenting the same view of the values of parameters and |
11171 // local variables as if the piece of JavaScript was evaluated at the point | 11227 // local variables as if the piece of JavaScript was evaluated at the point |
11172 // where the function on the stack frame is currently stopped. | 11228 // where the function on the stack frame is currently stopped. |
11173 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugEvaluate) { | 11229 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugEvaluate) { |
11174 HandleScope scope(isolate); | 11230 HandleScope scope(isolate); |
11175 | 11231 |
11176 // Check the execution state and decode arguments frame and source to be | 11232 // Check the execution state and decode arguments frame and source to be |
11177 // evaluated. | 11233 // evaluated. |
11178 ASSERT(args.length() == 5); | 11234 ASSERT(args.length() == 6); |
11179 Object* check_result; | 11235 Object* check_result; |
11180 { MaybeObject* maybe_check_result = Runtime_CheckExecutionState( | 11236 { MaybeObject* maybe_check_result = Runtime_CheckExecutionState( |
11181 RUNTIME_ARGUMENTS(isolate, args)); | 11237 RUNTIME_ARGUMENTS(isolate, args)); |
11182 if (!maybe_check_result->ToObject(&check_result)) { | 11238 if (!maybe_check_result->ToObject(&check_result)) { |
11183 return maybe_check_result; | 11239 return maybe_check_result; |
11184 } | 11240 } |
11185 } | 11241 } |
11186 CONVERT_CHECKED(Smi, wrapped_id, args[1]); | 11242 CONVERT_CHECKED(Smi, wrapped_id, args[1]); |
11187 CONVERT_ARG_CHECKED(String, source, 2); | 11243 CONVERT_NUMBER_CHECKED(int, inlined_frame_index, Int32, args[2]); |
11188 CONVERT_BOOLEAN_CHECKED(disable_break, args[3]); | 11244 CONVERT_ARG_CHECKED(String, source, 3); |
11189 Handle<Object> additional_context(args[4]); | 11245 CONVERT_BOOLEAN_CHECKED(disable_break, args[4]); |
| 11246 Handle<Object> additional_context(args[5]); |
11190 | 11247 |
11191 // Handle the processing of break. | 11248 // Handle the processing of break. |
11192 DisableBreak disable_break_save(disable_break); | 11249 DisableBreak disable_break_save(disable_break); |
11193 | 11250 |
11194 // Get the frame where the debugging is performed. | 11251 // Get the frame where the debugging is performed. |
11195 StackFrame::Id id = UnwrapFrameId(wrapped_id); | 11252 StackFrame::Id id = UnwrapFrameId(wrapped_id); |
11196 JavaScriptFrameIterator it(isolate, id); | 11253 JavaScriptFrameIterator it(isolate, id); |
11197 JavaScriptFrame* frame = it.frame(); | 11254 JavaScriptFrame* frame = it.frame(); |
11198 Handle<JSFunction> function(JSFunction::cast(frame->function())); | 11255 Handle<JSFunction> function(JSFunction::cast(frame->function())); |
11199 Handle<SerializedScopeInfo> scope_info(function->shared()->scope_info()); | 11256 Handle<SerializedScopeInfo> scope_info(function->shared()->scope_info()); |
(...skipping 19 matching lines...) Expand all Loading... |
11219 isolate->factory()->NewFunction(isolate->factory()->empty_string(), | 11276 isolate->factory()->NewFunction(isolate->factory()->empty_string(), |
11220 isolate->factory()->undefined_value()); | 11277 isolate->factory()->undefined_value()); |
11221 go_between->set_context(function->context()); | 11278 go_between->set_context(function->context()); |
11222 #ifdef DEBUG | 11279 #ifdef DEBUG |
11223 ScopeInfo<> go_between_sinfo(go_between->shared()->scope_info()); | 11280 ScopeInfo<> go_between_sinfo(go_between->shared()->scope_info()); |
11224 ASSERT(go_between_sinfo.number_of_parameters() == 0); | 11281 ASSERT(go_between_sinfo.number_of_parameters() == 0); |
11225 ASSERT(go_between_sinfo.number_of_context_slots() == 0); | 11282 ASSERT(go_between_sinfo.number_of_context_slots() == 0); |
11226 #endif | 11283 #endif |
11227 | 11284 |
11228 // Materialize the content of the local scope into a JSObject. | 11285 // Materialize the content of the local scope into a JSObject. |
11229 Handle<JSObject> local_scope = MaterializeLocalScope(isolate, frame); | 11286 Handle<JSObject> local_scope = MaterializeLocalScope( |
| 11287 isolate, frame, inlined_frame_index); |
11230 RETURN_IF_EMPTY_HANDLE(isolate, local_scope); | 11288 RETURN_IF_EMPTY_HANDLE(isolate, local_scope); |
11231 | 11289 |
11232 // Allocate a new context for the debug evaluation and set the extension | 11290 // Allocate a new context for the debug evaluation and set the extension |
11233 // object build. | 11291 // object build. |
11234 Handle<Context> context = | 11292 Handle<Context> context = |
11235 isolate->factory()->NewFunctionContext(Context::MIN_CONTEXT_SLOTS, | 11293 isolate->factory()->NewFunctionContext(Context::MIN_CONTEXT_SLOTS, |
11236 go_between); | 11294 go_between); |
11237 context->set_extension(*local_scope); | 11295 context->set_extension(*local_scope); |
11238 // Copy any with contexts present and chain them in front of this context. | 11296 // Copy any with contexts present and chain them in front of this context. |
11239 Handle<Context> frame_context(Context::cast(frame->context())); | 11297 Handle<Context> frame_context(Context::cast(frame->context())); |
(...skipping 28 matching lines...) Expand all Loading... |
11268 isolate->factory()->NewFunctionFromSharedFunctionInfo(shared, context); | 11326 isolate->factory()->NewFunctionFromSharedFunctionInfo(shared, context); |
11269 | 11327 |
11270 // Invoke the result of the compilation to get the evaluation function. | 11328 // Invoke the result of the compilation to get the evaluation function. |
11271 bool has_pending_exception; | 11329 bool has_pending_exception; |
11272 Handle<Object> receiver(frame->receiver(), isolate); | 11330 Handle<Object> receiver(frame->receiver(), isolate); |
11273 Handle<Object> evaluation_function = | 11331 Handle<Object> evaluation_function = |
11274 Execution::Call(compiled_function, receiver, 0, NULL, | 11332 Execution::Call(compiled_function, receiver, 0, NULL, |
11275 &has_pending_exception); | 11333 &has_pending_exception); |
11276 if (has_pending_exception) return Failure::Exception(); | 11334 if (has_pending_exception) return Failure::Exception(); |
11277 | 11335 |
11278 Handle<Object> arguments = GetArgumentsObject(isolate, frame, | 11336 Handle<Object> arguments = GetArgumentsObject(isolate, |
| 11337 frame, inlined_frame_index, |
11279 function, scope_info, | 11338 function, scope_info, |
11280 &sinfo, function_context); | 11339 &sinfo, function_context); |
11281 | 11340 |
11282 // Invoke the evaluation function and return the result. | 11341 // Invoke the evaluation function and return the result. |
11283 const int argc = 2; | 11342 const int argc = 2; |
11284 Object** argv[argc] = { arguments.location(), | 11343 Object** argv[argc] = { arguments.location(), |
11285 Handle<Object>::cast(source).location() }; | 11344 Handle<Object>::cast(source).location() }; |
11286 Handle<Object> result = | 11345 Handle<Object> result = |
11287 Execution::Call(Handle<JSFunction>::cast(evaluation_function), receiver, | 11346 Execution::Call(Handle<JSFunction>::cast(evaluation_function), receiver, |
11288 argc, argv, &has_pending_exception); | 11347 argc, argv, &has_pending_exception); |
(...skipping 1323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12612 } else { | 12671 } else { |
12613 // Handle last resort GC and make sure to allow future allocations | 12672 // Handle last resort GC and make sure to allow future allocations |
12614 // to grow the heap without causing GCs (if possible). | 12673 // to grow the heap without causing GCs (if possible). |
12615 isolate->counters()->gc_last_resort_from_js()->Increment(); | 12674 isolate->counters()->gc_last_resort_from_js()->Increment(); |
12616 isolate->heap()->CollectAllGarbage(false); | 12675 isolate->heap()->CollectAllGarbage(false); |
12617 } | 12676 } |
12618 } | 12677 } |
12619 | 12678 |
12620 | 12679 |
12621 } } // namespace v8::internal | 12680 } } // namespace v8::internal |
OLD | NEW |