d1070e417f
Instead of forcing GC right away, the function now post a task and performance GC from the task with an empty stack to avoid false positive pointers in conservative stack scanning. Bug: chromium:1098187 Change-Id: I88864845a1e395056c5d5f6e867ad774b87dbb6a Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2307217 Commit-Queue: Ulan Degenbaev <ulan@chromium.org> Reviewed-by: Simon Zünd <szuend@chromium.org> Reviewed-by: Peter Marshall <petermarshall@chromium.org> Cr-Commit-Position: refs/heads/master@{#69444}
31 lines
1022 B
JavaScript
31 lines
1022 B
JavaScript
// Copyright 2020 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: --no-stress-incremental-marking
|
|
|
|
let {session, contextGroup, Protocol} = InspectorTest.start(
|
|
'Tests collectGarbage.');
|
|
|
|
contextGroup.addScript(`
|
|
function createWeakRef() {
|
|
globalThis.weak_ref = new WeakRef(new Array(1000).fill(0));
|
|
}
|
|
function getWeakRef() {
|
|
if (!globalThis.weak_ref.deref()) return 'WeakRef is cleared after GC.';
|
|
return 'WeakRef is not cleared. GC did not happen?'
|
|
}
|
|
//# sourceURL=test.js`);
|
|
|
|
Protocol.Debugger.enable();
|
|
Protocol.HeapProfiler.enable();
|
|
|
|
InspectorTest.runAsyncTestSuite([
|
|
async function testCollectGarbage() {
|
|
await Protocol.Runtime.evaluate({ expression: 'createWeakRef()' });
|
|
await Protocol.HeapProfiler.collectGarbage();
|
|
let weak_ref = await Protocol.Runtime.evaluate({ expression: 'getWeakRef()' });
|
|
InspectorTest.log(`WeakRef state: ${weak_ref.result.result.value}`);
|
|
}
|
|
]);
|