Commit 7cfdd66a 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@{#40759}
parent 4125ba8b
......@@ -8949,13 +8949,18 @@ 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));
{
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