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

Side by Side Diff: src/runtime.cc

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

Powered by Google App Engine
This is Rietveld 408576698