Commit c79206b3 authored by Ben Smith's avatar Ben Smith Committed by Commit Bot

Add Atomics.notify as alias for Atomics.wake

At the May 2018 TC39 meeting, they decided to rename Atomics.wake to
Atomics.notify. This change adds Atomics.notify as an alias, but does
not remove Atomics.wake, which will be removed later.

This allows for embedders to use either name to prevent
breaking tests. When the tests are switched over, we can remove
Atomics.wake.

Bug: v8:7883
Change-Id: If057ebff162bde975c6e1b60d83a4662f144e81f
Reviewed-on: https://chromium-review.googlesource.com/1142290
Commit-Queue: Ben Smith <binji@chromium.org>
Reviewed-by: 's avatarAdam Klein <adamk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54534}
parent e06c2c85
......@@ -3028,6 +3028,8 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
Builtins::kAtomicsWait, 4, true);
SimpleInstallFunction(isolate_, atomics_object, "wake",
Builtins::kAtomicsWake, 3, true);
SimpleInstallFunction(isolate_, atomics_object, "notify",
Builtins::kAtomicsWake, 3, true);
}
{ // -- T y p e d A r r a y
......
......@@ -107,6 +107,7 @@
(function TestWakePositiveInfinity() {
var i32a = new Int32Array(new SharedArrayBuffer(16));
Atomics.wake(i32a, 0, Number.POSITIVE_INFINITY);
Atomics.notify(i32a, 0, Number.POSITIVE_INFINITY);
})();
// In a previous version, this test caused a check failure
......@@ -121,7 +122,7 @@
if (this.Worker) {
var TestWaitWithTimeout = function(timeout) {
var TestWaitWithTimeout = function(notify, timeout) {
var sab = new SharedArrayBuffer(16);
var i32a = new Int32Array(sab);
......@@ -138,7 +139,7 @@ if (this.Worker) {
// Spin until the worker is waiting on the futex.
while (%AtomicsNumWaitersForTesting(i32a, 0) != 1) {}
Atomics.wake(i32a, 0, 1);
notify(i32a, 0, 1);
assertEquals("ok", worker.getMessage());
worker.terminate();
......@@ -149,7 +150,7 @@ if (this.Worker) {
// Spin until the worker is waiting on the futex.
while (%AtomicsNumWaitersForTesting(i32a2, 0) != 1) {}
Atomics.wake(i32a2, 0, 1);
notify(i32a2, 0, 1);
assertEquals("ok", worker2.getMessage());
worker2.terminate();
......@@ -161,18 +162,20 @@ if (this.Worker) {
// Spin until the worker is waiting on the futex.
while (%AtomicsNumWaitersForTesting(i32a2, 1) != 1) {}
Atomics.wake(i32a2, 1, 1);
notify(i32a2, 1, 1);
assertEquals("ok", worker3.getMessage());
worker3.terminate();
};
// Test various infinite timeouts
TestWaitWithTimeout(undefined);
TestWaitWithTimeout(NaN);
TestWaitWithTimeout(Infinity);
(function TestWakeMulti() {
TestWaitWithTimeout(Atomics.wake, undefined);
TestWaitWithTimeout(Atomics.wake, NaN);
TestWaitWithTimeout(Atomics.wake, Infinity);
TestWaitWithTimeout(Atomics.notify, undefined);
TestWaitWithTimeout(Atomics.notify, NaN);
TestWaitWithTimeout(Atomics.notify, Infinity);
var TestWakeMulti = function(notify) {
var sab = new SharedArrayBuffer(20);
var i32a = new Int32Array(sab);
......@@ -210,7 +213,7 @@ if (this.Worker) {
while (%AtomicsNumWaitersForTesting(i32a, 4) != 4) {}
// Wake up three waiters.
assertEquals(3, Atomics.wake(i32a, 4, 3));
assertEquals(3, notify(i32a, 4, 3));
var wokenCount = 0;
var waitingId = 0 + 1 + 2 + 3;
......@@ -232,12 +235,14 @@ if (this.Worker) {
assertEquals(1, %AtomicsNumWaitersForTesting(i32a, 4));
// Finally wake the last waiter.
assertEquals(1, Atomics.wake(i32a, 4, 1));
assertEquals(1, notify(i32a, 4, 1));
assertEquals("ok", workers[waitingId].getMessage());
workers[waitingId].terminate();
assertEquals(0, %AtomicsNumWaitersForTesting(i32a, 4));
})();
};
TestWakeMulti(Atomics.wake);
TestWakeMulti(Atomics.notify);
}
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