0938188f85
All wasm code has an initial ref count of 1, in the expectation that it will be added to the code table. When the code is removed from that table, the ref count will be decremented. Stepping code (and also other code under special circumstances) will not be added to the code table though. Hence the ref count will never be decremented below 1, and the code will never be garbage-collected. This CL fixes this, by decrementing the ref count if the code is not added to the code table. Note that the code will only be collected if no isolate is currently using it, so it won't be collected while still in use for stepping. R=thibaudm@chromium.org Bug: chromium:1168564 Change-Id: I3047753591cbc52689ca019e9548ec58c237b835 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2649040 Commit-Queue: Clemens Backes <clemensb@chromium.org> Reviewed-by: Thibaud Michaud <thibaudm@chromium.org> Cr-Commit-Position: refs/heads/master@{#72354}
52 lines
1.7 KiB
JavaScript
52 lines
1.7 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.
|
|
|
|
utils.load('test/inspector/wasm-inspector-test.js');
|
|
|
|
const {session, contextGroup, Protocol} = InspectorTest.start(
|
|
'Tests repeated stepping through a large function (should not OOM)');
|
|
session.setupScriptMap();
|
|
|
|
const builder = new WasmModuleBuilder();
|
|
|
|
const body = [kExprLocalGet, 0];
|
|
// Stepping through a long function will repeatedly recreate stepping code, with
|
|
// corresponding side tables. This should not run OOM
|
|
// (https://crbug.com/1168564).
|
|
for (let i = 0; i < 2000; ++i) body.push(...wasmI32Const(i), kExprI32Add);
|
|
const func_test =
|
|
builder.addFunction('test', kSig_i_i).addBody(body).exportFunc();
|
|
const module_bytes = builder.toArray();
|
|
|
|
let paused = 0;
|
|
Protocol.Debugger.onPaused(msg => {
|
|
++paused;
|
|
if (paused % 500 == 0) InspectorTest.log(`Paused ${paused} and running...`);
|
|
Protocol.Debugger.stepOver();
|
|
});
|
|
|
|
InspectorTest.runAsyncTestSuite([
|
|
async function test() {
|
|
await Protocol.Debugger.enable();
|
|
InspectorTest.log('Setting up global instance variable.');
|
|
WasmInspectorTest.instantiate(module_bytes);
|
|
const [, {params: wasmScript}] = await Protocol.Debugger.onceScriptParsed(2);
|
|
|
|
InspectorTest.log('Got wasm script: ' + wasmScript.url);
|
|
|
|
InspectorTest.log('Setting breakpoint');
|
|
await Protocol.Debugger.setBreakpoint({
|
|
location: {
|
|
scriptId: wasmScript.scriptId,
|
|
lineNumber: 0,
|
|
columnNumber: func_test.body_offset
|
|
}
|
|
});
|
|
|
|
await Protocol.Runtime.evaluate({ expression: 'instance.exports.test()' });
|
|
InspectorTest.log('test function returned.');
|
|
InspectorTest.log(`Paused ${paused} times.`);
|
|
}
|
|
]);
|