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

Unified Diff: src/api.cc

Issue 2465833002: [debugger] simplify fetching scripts for inspector. (Closed)
Patch Set: add comment Created 4 years, 1 month 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 | « no previous file | test/inspector/debugger/script-on-after-compile.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/api.cc
diff --git a/src/api.cc b/src/api.cc
index ad41d819b7f094ddda7834f5ca57377ae8184f03..ccc6266a98313b41501d7728c9c70328acf2c0f2 100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -8946,13 +8946,21 @@ void DebugInterface::GetLoadedScripts(
PersistentValueVector<DebugInterface::Script>& scripts) {
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
ENTER_V8(isolate);
- i::HandleScope handle_scope(isolate);
- i::Handle<i::FixedArray> instances = isolate->debug()->GetLoadedScripts();
- for (int i = 0; i < instances->length(); i++) {
- i::Handle<i::Script> script =
- i::Handle<i::Script>(i::Script::cast(instances->get(i)));
- if (script->type() != i::Script::TYPE_NORMAL) continue;
- scripts.Append(ToApiHandle<Script>(script));
+ // TODO(kozyatinskiy): remove this GC once tests are dealt with.
+ isolate->heap()->CollectAllGarbage(i::Heap::kFinalizeIncrementalMarkingMask,
+ i::GarbageCollectionReason::kDebugger);
+ {
+ i::DisallowHeapAllocation no_gc;
+ i::Script::Iterator iterator(isolate);
+ i::Script* script;
+ while ((script = iterator.Next())) {
+ if (script->type() != i::Script::TYPE_NORMAL) continue;
+ if (script->HasValidSource()) {
+ i::HandleScope handle_scope(isolate);
+ i::Handle<i::Script> script_handle(script, isolate);
+ scripts.Append(ToApiHandle<Script>(script_handle));
+ }
+ }
}
}
« no previous file with comments | « no previous file | test/inspector/debugger/script-on-after-compile.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698