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( ...@@ -8968,13 +8968,21 @@ void DebugInterface::GetLoadedScripts(
PersistentValueVector<DebugInterface::Script>& scripts) { PersistentValueVector<DebugInterface::Script>& scripts) {
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
ENTER_V8(isolate); ENTER_V8(isolate);
i::HandleScope handle_scope(isolate); // TODO(kozyatinskiy): remove this GC once tests are dealt with.
i::Handle<i::FixedArray> instances = isolate->debug()->GetLoadedScripts(); isolate->heap()->CollectAllGarbage(i::Heap::kFinalizeIncrementalMarkingMask,
for (int i = 0; i < instances->length(); i++) { i::GarbageCollectionReason::kDebugger);
i::Handle<i::Script> script = {
i::Handle<i::Script>(i::Script::cast(instances->get(i))); 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->type() != i::Script::TYPE_NORMAL) continue;
scripts.Append(ToApiHandle<Script>(script)); 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 ...@@ -661,4 +661,4 @@ scriptParsed
startLine : 0 startLine : 0
url : url :
} }
Run gc and then Debugger.enable().. Remove script references and re-enable debugger.
// Copyright 2016 the V8 project authors. All rights reserved. // Copyright 2016 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// Flags: --expose_gc
print("Checks that inspector correctly process compiled scripts"); print("Checks that inspector correctly process compiled scripts");
...@@ -49,9 +48,10 @@ addScripts() ...@@ -49,9 +48,10 @@ addScripts()
.then(() => Protocol.Debugger.enable()) .then(() => Protocol.Debugger.enable())
.then(addScripts) .then(addScripts)
.then(() => Protocol.Debugger.disable()) .then(() => Protocol.Debugger.disable())
.then(() => InspectorTest.log("Remove script references and re-enable debugger."))
.then(() => InspectorTest.log("Run gc and then Debugger.enable()..")) .then(() => Protocol.Runtime.evaluate(
.then(() => Protocol.Runtime.evaluate({ expression: "for (let i = 1; i < 20; ++i) eval(`foo${i} = undefined`); gc();" })) { expression: "for (let i = 1; i < 20; ++i) eval(`foo${i} = undefined`);" }))
.then(() => Protocol.HeapProfiler.collectGarbage())
.then(() => Protocol.Debugger.enable()) .then(() => Protocol.Debugger.enable())
.then(InspectorTest.completeTest); .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