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

Unified Diff: src/runtime.cc

Issue 181063008: Introduce Runtime_GetAllScopesDetails to get all scopes at once for a frame. (Closed) Base URL: git://github.com/v8/v8.git@master
Patch Set: Created 6 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: src/runtime.cc
diff --git a/src/runtime.cc b/src/runtime.cc
index 0caaa47bd57f79ba52b8b46959a590c9fe918041..d8448d80322be527bdfa12c8ab058ceb5e6fdabb 100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -12298,6 +12298,48 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_GetScopeDetails) {
}
+// Return an array of scope details
+// args[0]: number: break id
+// args[1]: number: frame index
+// args[2]: number: inlined frame index
+//
+// The array returned contains arrays with the following information:
+// 0: Scope type
+// 1: Scope object
Yang 2014/03/04 11:31:35 Now this seems just a broader case of %GetScopeDet
+RUNTIME_FUNCTION(MaybeObject*, Runtime_GetAllScopesDetails) {
+ HandleScope scope(isolate);
+ ASSERT(args.length() == 3);
+
+ // Check arguments.
+ Object* check;
+ { MaybeObject* maybe_check = Runtime_CheckExecutionState(
+ RUNTIME_ARGUMENTS(isolate, args));
+ if (!maybe_check->ToObject(&check)) return maybe_check;
+ }
+ CONVERT_SMI_ARG_CHECKED(wrapped_id, 1);
+ CONVERT_NUMBER_CHECKED(int, inlined_jsframe_index, Int32, args[2]);
+
+ // Get the frame where the debugging is performed.
+ StackFrame::Id id = UnwrapFrameId(wrapped_id);
+ JavaScriptFrameIterator frame_it(isolate, id);
+ JavaScriptFrame* frame = frame_it.frame();
+
+ List<Handle<Object> > result(4);
+ 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.
+ for (; !it.Done(); it.Next()) {
+ 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.
+ if (maybe_object->IsFailure()) return maybe_object;
+ result.Add(handle(maybe_object->ToObjectUnchecked(), isolate));
+ }
+
+ Handle<FixedArray> array = isolate->factory()->NewFixedArray(result.length());
+ for (int i = 0; i < result.length(); ++i) {
+ array->set(i, *result[i]);
+ }
+ return *isolate->factory()->NewJSArrayWithElements(array);
+}
+
+
RUNTIME_FUNCTION(MaybeObject*, Runtime_GetFunctionScopeCount) {
HandleScope scope(isolate);
ASSERT(args.length() == 1);
« src/mirror-debugger.js ('K') | « src/runtime.h ('k') | test/mjsunit/debug-scopes.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698