Commit 138ac70f authored by Shu-yu Guo's avatar Shu-yu Guo Committed by Commit Bot

[weakrefs] Add test to stress enqueuing of dirty FinalizationRegistries

Bug: v8:8179, chromium:1074621
Change-Id: I26e2e2cef7ae2b1e43526c4cfc2592cc0f6d688f
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2169412
Auto-Submit: Shu-yu Guo <syg@chromium.org>
Commit-Queue: Ulan Degenbaev <ulan@chromium.org>
Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#67417}
parent b369e89f
// 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: --stress-compaction --expose-gc
// Test that the dirty FinalizationRegistries that are enqueued during GC have
// their slots correctly recorded by the GC.
// 1) Create many JSFinalizationRegistry objects so that they span several pages
// (page size is 256kb).
let registries = [];
for (let i = 0; i < 1024 * 8; i++) {
registries.push(new FinalizationRegistry(() => {}));
}
// 2) Force two GCs to ensure that JSFinalizatonRegistry objects are tenured.
gc();
gc();
// 3) In a function: create a dummy target and register it in all
// JSFinalizatonRegistry objects.
(function() {
let garbage = {};
registries.forEach((fr) => {
fr.register(garbage, 42);
});
garbage = null;
})();
// 4) Outside the function where the target is unreachable: force GC to collect
// the object.
gc();
// 5) Force another GC to test that the slot was correctly updated.
gc();
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