v8/test/inspector/debugger/not-hold-promises.js
Ulan Degenbaev d1070e417f [inspector] Make collectGarbage of HeapProfiler precise
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}
2020-08-18 07:24:14 +00:00

39 lines
1.5 KiB
JavaScript

// Copyright 2017 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 that we don\'t hold promises.');
(async function test() {
Protocol.Runtime.enable();
Protocol.Debugger.enable();
Protocol.Debugger.setAsyncCallStackDepth({maxDepth: 128});
Protocol.HeapProfiler.enable();
// Force inspector internal scripts compilation.
await Protocol.Runtime.evaluate({expression: ''});
let snapshot = '';
Protocol.HeapProfiler.onAddHeapSnapshotChunk(msg => snapshot += msg.params.chunk);
await Protocol.HeapProfiler.collectGarbage();
await Protocol.HeapProfiler.takeHeapSnapshot();
let initial_node_count = JSON.parse(snapshot).snapshot.node_count;
await Protocol.Runtime.evaluate({
expression: `for (let i = 0; i < ${initial_node_count / 4}; ++i) Promise.resolve()`});
snapshot = '';
Protocol.HeapProfiler.onAddHeapSnapshotChunk(msg => snapshot += msg.params.chunk);
await Protocol.HeapProfiler.collectGarbage();
await Protocol.HeapProfiler.takeHeapSnapshot();
let without_storing_node_count = JSON.parse(snapshot).snapshot.node_count;
let diff_without_storing = (without_storing_node_count - initial_node_count);
if (diff_without_storing < initial_node_count / 4) {
InspectorTest.log('SUCCESS');
} else {
InspectorTest.log('FAILED: looks like all promises were not collected.');
}
InspectorTest.completeTest();
})();