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

Unified Diff: src/runtime/runtime-debug.cc

Issue 2228393002: Allow access to scopes of suspended generator objects (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Remove stale TODO comment Created 4 years, 4 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
« no previous file with comments | « src/runtime/runtime.h ('k') | test/mjsunit/debug-scopes-suspended-generators.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/runtime/runtime-debug.cc
diff --git a/src/runtime/runtime-debug.cc b/src/runtime/runtime-debug.cc
index a6ad0020c7552e876d866f9c6c444fae784368ae..a47e3215aae027c6c11f24483f7ba2019f34653e 100644
--- a/src/runtime/runtime-debug.cc
+++ b/src/runtime/runtime-debug.cc
@@ -919,6 +919,48 @@ RUNTIME_FUNCTION(Runtime_GetFunctionScopeDetails) {
RETURN_RESULT_OR_FAILURE(isolate, it.MaterializeScopeDetails());
}
+RUNTIME_FUNCTION(Runtime_GetGeneratorScopeCount) {
+ HandleScope scope(isolate);
+ DCHECK_EQ(1, args.length());
+
+ if (!args[0]->IsJSGeneratorObject()) return Smi::FromInt(0);
+
+ // Check arguments.
+ CONVERT_ARG_HANDLE_CHECKED(JSGeneratorObject, gen, 0);
+
+ // Count the visible scopes.
+ int n = 0;
+ for (ScopeIterator it(isolate, gen); !it.Done(); it.Next()) {
+ n++;
+ }
+
+ return Smi::FromInt(n);
+}
+
+RUNTIME_FUNCTION(Runtime_GetGeneratorScopeDetails) {
+ HandleScope scope(isolate);
+ DCHECK(args.length() == 2);
+
+ if (!args[0]->IsJSGeneratorObject()) {
+ return *isolate->factory()->undefined_value();
+ }
+
+ // Check arguments.
+ CONVERT_ARG_HANDLE_CHECKED(JSGeneratorObject, gen, 0);
+ CONVERT_NUMBER_CHECKED(int, index, Int32, args[1]);
+
+ // Find the requested scope.
+ int n = 0;
+ ScopeIterator it(isolate, gen);
+ for (; !it.Done() && n < index; it.Next()) {
+ n++;
+ }
+ if (it.Done()) {
+ return isolate->heap()->undefined_value();
+ }
+
+ RETURN_RESULT_OR_FAILURE(isolate, it.MaterializeScopeDetails());
+}
static bool SetScopeVariableValue(ScopeIterator* it, int index,
Handle<String> variable_name,
@@ -967,10 +1009,14 @@ RUNTIME_FUNCTION(Runtime_SetScopeVariableValue) {
ScopeIterator it(isolate, &frame_inspector);
res = SetScopeVariableValue(&it, index, variable_name, new_value);
- } else {
+ } else if (args[0]->IsJSFunction()) {
CONVERT_ARG_HANDLE_CHECKED(JSFunction, fun, 0);
ScopeIterator it(isolate, fun);
res = SetScopeVariableValue(&it, index, variable_name, new_value);
+ } else {
+ CONVERT_ARG_HANDLE_CHECKED(JSGeneratorObject, gen, 0);
+ ScopeIterator it(isolate, gen);
+ res = SetScopeVariableValue(&it, index, variable_name, new_value);
}
return isolate->heap()->ToBoolean(res);
« no previous file with comments | « src/runtime/runtime.h ('k') | test/mjsunit/debug-scopes-suspended-generators.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698