877dcdfc3a
Previously we'd hold on to Script objects strongly after they are considered unreachable by V8 itself, and keep them around for the V8DebuggerAgent cache (whose upper limit can be controlled with a parameter to `Debugger.enable`). This CL changes that to instead copy out the script source and the WebAssembly bytecode (depending on whether it's JavaScript or Wasm) to the C++ heap and keep it cached there. Fixed: chromium:1295659 Bug: chromium:1246884 Change-Id: Idfcd7172715eafca6b011826ae03a573d58803f2 Doc: https://bit.ly/v8-inspector-script-caching Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3472082 Reviewed-by: Jaroslav Sevcik <jarin@chromium.org> Reviewed-by: Michael Lippautz <mlippautz@chromium.org> Commit-Queue: Benedikt Meurer <bmeurer@chromium.org> Cr-Commit-Position: refs/heads/main@{#79217}
58 lines
1.9 KiB
JavaScript
58 lines
1.9 KiB
JavaScript
// Copyright 2021 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: --allow-natives-syntax
|
|
|
|
let {session, contextGroup, Protocol} = InspectorTest.start(
|
|
'Checks if we keep alive breakpoint information for top-level functions when calling getPossibleBreakpoints.');
|
|
|
|
session.setupScriptMap();
|
|
var executionContextId;
|
|
|
|
const callGarbageCollector = `
|
|
%CollectGarbage("");
|
|
%CollectGarbage("");
|
|
%CollectGarbage("");
|
|
%CollectGarbage("");
|
|
`;
|
|
|
|
const moduleFunction =
|
|
`function testFunc() { console.log('This is a module function') }`;
|
|
let mixedFunctions = ` function A() {}
|
|
console.log('This is a top level function');
|
|
`;
|
|
|
|
Protocol.Debugger.enable().then(onDebuggerEnabled);
|
|
|
|
function onDebuggerEnabled() {
|
|
Protocol.Runtime.enable();
|
|
Protocol.Runtime.onExecutionContextCreated(onExecutionContextCreated);
|
|
}
|
|
|
|
async function onExecutionContextCreated(messageObject) {
|
|
executionContextId = messageObject.params.context.id;
|
|
await testGetPossibleBreakpoints(
|
|
executionContextId, moduleFunction, 'moduleFunc.js');
|
|
await testGetPossibleBreakpoints(
|
|
executionContextId, mixedFunctions, 'mixedFunctions.js');
|
|
InspectorTest.completeTest();
|
|
}
|
|
|
|
async function testGetPossibleBreakpoints(executionContextId, func, url) {
|
|
const obj = await Protocol.Runtime.compileScript({
|
|
expression: func,
|
|
sourceURL: url,
|
|
persistScript: true,
|
|
executionContextId: executionContextId
|
|
});
|
|
const scriptId = obj.result.scriptId;
|
|
const location = {start: {lineNumber: 0, columnNumber: 0, scriptId}};
|
|
await Protocol.Runtime.runScript({scriptId});
|
|
await Protocol.Runtime.evaluate({expression: `${callGarbageCollector}`});
|
|
const {result: {locations}} =
|
|
await Protocol.Debugger.getPossibleBreakpoints(location);
|
|
InspectorTest.log(`Result of get possible breakpoints in ${url}`);
|
|
InspectorTest.log(JSON.stringify(locations));
|
|
}
|