Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 12280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 12291 for (; !it.Done() && n < index; it.Next()) { | 12291 for (; !it.Done() && n < index; it.Next()) { |
| 12292 n++; | 12292 n++; |
| 12293 } | 12293 } |
| 12294 if (it.Done()) { | 12294 if (it.Done()) { |
| 12295 return isolate->heap()->undefined_value(); | 12295 return isolate->heap()->undefined_value(); |
| 12296 } | 12296 } |
| 12297 return MaterializeScopeDetails(isolate, &it); | 12297 return MaterializeScopeDetails(isolate, &it); |
| 12298 } | 12298 } |
| 12299 | 12299 |
| 12300 | 12300 |
| 12301 // Return an array of scope details | |
| 12302 // args[0]: number: break id | |
| 12303 // args[1]: number: frame index | |
| 12304 // args[2]: number: inlined frame index | |
| 12305 // | |
| 12306 // The array returned contains arrays with the following information: | |
| 12307 // 0: Scope type | |
| 12308 // 1: Scope object | |
|
Yang
2014/03/04 11:31:35
Now this seems just a broader case of %GetScopeDet
| |
| 12309 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetAllScopesDetails) { | |
| 12310 HandleScope scope(isolate); | |
| 12311 ASSERT(args.length() == 3); | |
| 12312 | |
| 12313 // Check arguments. | |
| 12314 Object* check; | |
| 12315 { MaybeObject* maybe_check = Runtime_CheckExecutionState( | |
| 12316 RUNTIME_ARGUMENTS(isolate, args)); | |
| 12317 if (!maybe_check->ToObject(&check)) return maybe_check; | |
| 12318 } | |
| 12319 CONVERT_SMI_ARG_CHECKED(wrapped_id, 1); | |
| 12320 CONVERT_NUMBER_CHECKED(int, inlined_jsframe_index, Int32, args[2]); | |
| 12321 | |
| 12322 // Get the frame where the debugging is performed. | |
| 12323 StackFrame::Id id = UnwrapFrameId(wrapped_id); | |
| 12324 JavaScriptFrameIterator frame_it(isolate, id); | |
| 12325 JavaScriptFrame* frame = frame_it.frame(); | |
| 12326 | |
| 12327 List<Handle<Object> > result(4); | |
| 12328 ScopeIterator it(isolate, frame, inlined_jsframe_index); | |
|
ulan
2014/03/04 10:41:59
This code seems to work, but it is fragile because
aandrey
2014/03/04 11:04:19
You mean the JavaScriptFrame* pointer?
I'm not an
ulan
2014/03/04 11:28:15
That pointer should be fine. This code works, but
Yang
2014/03/04 11:31:35
Seems fine to me.
| |
| 12329 for (; !it.Done(); it.Next()) { | |
| 12330 MaybeObject* maybe_object = MaterializeScopeDetails(isolate, &it); | |
|
ulan
2014/03/04 10:41:59
MaterializeScopeDetails looks already handlified,
aandrey
2014/03/04 11:04:19
As far as I understand, it may return a Failure wh
ulan
2014/03/04 11:28:15
Something like this:
Handle<Object> MaterializeSc
Yang
2014/03/04 11:31:35
I suggest changing MaterializedScopeDetails to ret
aandrey
2014/03/04 12:39:07
Done.
| |
| 12331 if (maybe_object->IsFailure()) return maybe_object; | |
| 12332 result.Add(handle(maybe_object->ToObjectUnchecked(), isolate)); | |
| 12333 } | |
| 12334 | |
| 12335 Handle<FixedArray> array = isolate->factory()->NewFixedArray(result.length()); | |
| 12336 for (int i = 0; i < result.length(); ++i) { | |
| 12337 array->set(i, *result[i]); | |
| 12338 } | |
| 12339 return *isolate->factory()->NewJSArrayWithElements(array); | |
| 12340 } | |
| 12341 | |
| 12342 | |
| 12301 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetFunctionScopeCount) { | 12343 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetFunctionScopeCount) { |
| 12302 HandleScope scope(isolate); | 12344 HandleScope scope(isolate); |
| 12303 ASSERT(args.length() == 1); | 12345 ASSERT(args.length() == 1); |
| 12304 | 12346 |
| 12305 // Check arguments. | 12347 // Check arguments. |
| 12306 CONVERT_ARG_HANDLE_CHECKED(JSFunction, fun, 0); | 12348 CONVERT_ARG_HANDLE_CHECKED(JSFunction, fun, 0); |
| 12307 | 12349 |
| 12308 // Count the visible scopes. | 12350 // Count the visible scopes. |
| 12309 int n = 0; | 12351 int n = 0; |
| 12310 for (ScopeIterator it(isolate, fun); !it.Done(); it.Next()) { | 12352 for (ScopeIterator it(isolate, fun); !it.Done(); it.Next()) { |
| (...skipping 2654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 14965 // Handle last resort GC and make sure to allow future allocations | 15007 // Handle last resort GC and make sure to allow future allocations |
| 14966 // to grow the heap without causing GCs (if possible). | 15008 // to grow the heap without causing GCs (if possible). |
| 14967 isolate->counters()->gc_last_resort_from_js()->Increment(); | 15009 isolate->counters()->gc_last_resort_from_js()->Increment(); |
| 14968 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, | 15010 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, |
| 14969 "Runtime::PerformGC"); | 15011 "Runtime::PerformGC"); |
| 14970 } | 15012 } |
| 14971 } | 15013 } |
| 14972 | 15014 |
| 14973 | 15015 |
| 14974 } } // namespace v8::internal | 15016 } } // namespace v8::internal |
| OLD | NEW |