fafd7c5d22
It's been enabled everywhere since Chrome 88, and the related Chromium flag was removed in https://crrev.com/c/2886421. Bug: v8:6532 Change-Id: I987a5761f9453d4e7d77d16199e8f0b3a659c70a Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3956131 Commit-Queue: Adam Klein <adamk@chromium.org> Reviewed-by: Clemens Backes <clemensb@chromium.org> Reviewed-by: Deepti Gandluri <gdeepti@chromium.org> Auto-Submit: Adam Klein <adamk@chromium.org> Cr-Commit-Position: refs/heads/main@{#83809}
86 lines
2.1 KiB
JavaScript
86 lines
2.1 KiB
JavaScript
// Copyright 2019 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: --expose-gc
|
|
|
|
const kNumIterations = 10;
|
|
|
|
function NewWorker() {
|
|
let script =
|
|
`onmessage = (msg) => {
|
|
if (msg.memory) postMessage("ack");
|
|
if (msg.quit) postMessage("bye");
|
|
gc();
|
|
}`;
|
|
return new Worker(script, {type: 'string'});
|
|
}
|
|
|
|
function PingWorker(worker, memory) {
|
|
worker.postMessage({memory: memory});
|
|
assertEquals("ack", worker.getMessage());
|
|
worker.postMessage({quit: true});
|
|
assertEquals("bye", worker.getMessage());
|
|
}
|
|
|
|
function AllocMemory() {
|
|
let pages = 1, max = 1;
|
|
return new WebAssembly.Memory({initial : pages, maximum : max, shared : true});
|
|
}
|
|
|
|
function RunSingleWorkerSingleMemoryTest() {
|
|
print(arguments.callee.name);
|
|
let worker = NewWorker();
|
|
let first = AllocMemory();
|
|
for (let i = 0; i < kNumIterations; i++) {
|
|
print(`iteration ${i}`);
|
|
PingWorker(worker, first);
|
|
gc();
|
|
}
|
|
worker.terminate();
|
|
}
|
|
|
|
function RunSingleWorkerTwoMemoryTest() {
|
|
print(arguments.callee.name);
|
|
let worker = NewWorker();
|
|
let first = AllocMemory(), second = AllocMemory();
|
|
for (let i = 0; i < kNumIterations; i++) {
|
|
print(`iteration ${i}`);
|
|
PingWorker(worker, first);
|
|
PingWorker(worker, second);
|
|
gc();
|
|
}
|
|
worker.terminate();
|
|
}
|
|
|
|
function RunSingleWorkerMultipleMemoryTest() {
|
|
print(arguments.callee.name);
|
|
let worker = NewWorker();
|
|
let first = AllocMemory();
|
|
for (let i = 0; i < kNumIterations; i++) {
|
|
print(`iteration ${i}`);
|
|
PingWorker(worker, first);
|
|
PingWorker(worker, AllocMemory());
|
|
gc();
|
|
}
|
|
worker.terminate();
|
|
}
|
|
|
|
function RunMultipleWorkerMultipleMemoryTest() {
|
|
print(arguments.callee.name);
|
|
let first = AllocMemory();
|
|
for (let i = 0; i < kNumIterations; i++) {
|
|
print(`iteration ${i}`);
|
|
let worker = NewWorker();
|
|
PingWorker(worker, first);
|
|
PingWorker(worker, AllocMemory());
|
|
worker.terminate();
|
|
gc();
|
|
}
|
|
}
|
|
|
|
RunSingleWorkerSingleMemoryTest();
|
|
RunSingleWorkerTwoMemoryTest();
|
|
RunSingleWorkerMultipleMemoryTest();
|
|
RunMultipleWorkerMultipleMemoryTest();
|