Commit 581614ee authored by yangguo's avatar yangguo Committed by Commit bot

[debugger] simplify fetching scripts for inspector.

The old code path is going to be removed with the debug context api.

R=kozyatinskiy@chromium.org

Review-Url: https://codereview.chromium.org/2465833002
Cr-Commit-Position: refs/heads/master@{#40768}
parent 586e4a89
......@@ -8968,13 +8968,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));
}
}
}
}
......
......@@ -661,4 +661,4 @@ scriptParsed
startLine : 0
url :
}
Run gc and then Debugger.enable()..
Remove script references and re-enable debugger.
// Copyright 2016 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --expose_gc
print("Checks that inspector correctly process compiled scripts");
......@@ -49,9 +48,10 @@ addScripts()
.then(() => Protocol.Debugger.enable())
.then(addScripts)
.then(() => Protocol.Debugger.disable())
.then(() => InspectorTest.log("Run gc and then Debugger.enable().."))
.then(() => Protocol.Runtime.evaluate({ expression: "for (let i = 1; i < 20; ++i) eval(`foo${i} = undefined`); gc();" }))
.then(() => InspectorTest.log("Remove script references and re-enable debugger."))
.then(() => Protocol.Runtime.evaluate(
{ expression: "for (let i = 1; i < 20; ++i) eval(`foo${i} = undefined`);" }))
.then(() => Protocol.HeapProfiler.collectGarbage())
.then(() => Protocol.Debugger.enable())
.then(InspectorTest.completeTest);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment