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

[atomics] Remove the deprecated Atomics.wake

The Intent to Deprecate and Remove was sent in March 2019:
https://groups.google.com/a/chromium.org/forum/#!topic/blink-dev/_zPuM7ETNSE

Current use of Atomics.wake is at <0.0002% of page loads:
https://chromestatus.com/metrics/feature/timeline/popularity/2556

Bug: v8:7883
Change-Id: I4534df6cb88e0afbeae655254d6ce48ad7b462e7
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2333349
Commit-Queue: Shu-yu Guo <syg@chromium.org>
Reviewed-by: 's avatarBen Smith <binji@chromium.org>
Reviewed-by: 's avatarAdam Klein <adamk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#69317}
parent ff503fd4
...@@ -8438,8 +8438,8 @@ class V8_EXPORT Isolate { ...@@ -8438,8 +8438,8 @@ class V8_EXPORT Isolate {
kFunctionTokenOffsetTooLongForToString = 49, kFunctionTokenOffsetTooLongForToString = 49,
kWasmSharedMemory = 50, kWasmSharedMemory = 50,
kWasmThreadOpcodes = 51, kWasmThreadOpcodes = 51,
kAtomicsNotify = 52, kAtomicsNotify = 52, // Unused.
kAtomicsWake = 53, kAtomicsWake = 53, // Unused.
kCollator = 54, kCollator = 54,
kNumberFormat = 55, kNumberFormat = 55,
kDateTimeFormat = 56, kDateTimeFormat = 56,
......
...@@ -736,7 +736,6 @@ namespace internal { ...@@ -736,7 +736,6 @@ namespace internal {
CPP(AtomicsIsLockFree) \ CPP(AtomicsIsLockFree) \
CPP(AtomicsWait) \ CPP(AtomicsWait) \
CPP(AtomicsWaitAsync) \ CPP(AtomicsWaitAsync) \
CPP(AtomicsWake) \
\ \
/* String */ \ /* String */ \
/* ES #sec-string.fromcodepoint */ \ /* ES #sec-string.fromcodepoint */ \
......
...@@ -110,71 +110,49 @@ inline size_t GetAddress32(size_t index, size_t byte_offset) { ...@@ -110,71 +110,49 @@ inline size_t GetAddress32(size_t index, size_t byte_offset) {
return (index << 2) + byte_offset; return (index << 2) + byte_offset;
} }
MaybeHandle<Object> AtomicsWake(Isolate* isolate, Handle<Object> array, } // namespace
Handle<Object> index, Handle<Object> count) {
// ES #sec-atomics.notify
// Atomics.notify( typedArray, index, count )
BUILTIN(AtomicsNotify) {
HandleScope scope(isolate);
Handle<Object> array = args.atOrUndefined(isolate, 1);
Handle<Object> index = args.atOrUndefined(isolate, 2);
Handle<Object> count = args.atOrUndefined(isolate, 3);
Handle<JSTypedArray> sta; Handle<JSTypedArray> sta;
ASSIGN_RETURN_ON_EXCEPTION( ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, sta, ValidateSharedIntegerTypedArray(isolate, array, true), isolate, sta, ValidateSharedIntegerTypedArray(isolate, array, true));
Object);
Maybe<size_t> maybe_index = ValidateAtomicAccess(isolate, sta, index); Maybe<size_t> maybe_index = ValidateAtomicAccess(isolate, sta, index);
MAYBE_RETURN_NULL(maybe_index); if (maybe_index.IsNothing()) return ReadOnlyRoots(isolate).exception();
size_t i = maybe_index.FromJust(); size_t i = maybe_index.FromJust();
uint32_t c; uint32_t c;
if (count->IsUndefined(isolate)) { if (count->IsUndefined(isolate)) {
c = kMaxUInt32; c = kMaxUInt32;
} else { } else {
ASSIGN_RETURN_ON_EXCEPTION(isolate, count, ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, count,
Object::ToInteger(isolate, count), Object); Object::ToInteger(isolate, count));
double count_double = count->Number(); double count_double = count->Number();
if (count_double < 0) if (count_double < 0) {
count_double = 0; count_double = 0;
else if (count_double > kMaxUInt32) } else if (count_double > kMaxUInt32) {
count_double = kMaxUInt32; count_double = kMaxUInt32;
}
c = static_cast<uint32_t>(count_double); c = static_cast<uint32_t>(count_double);
} }
Handle<JSArrayBuffer> array_buffer = sta->GetBuffer(); Handle<JSArrayBuffer> array_buffer = sta->GetBuffer();
size_t wake_addr;
if (sta->type() == kExternalBigInt64Array) { if (sta->type() == kExternalBigInt64Array) {
return Handle<Object>( wake_addr = GetAddress64(i, sta->byte_offset());
FutexEmulation::Wake(array_buffer, GetAddress64(i, sta->byte_offset()),
c),
isolate);
} else { } else {
DCHECK(sta->type() == kExternalInt32Array); DCHECK(sta->type() == kExternalInt32Array);
return Handle<Object>( wake_addr = GetAddress32(i, sta->byte_offset());
FutexEmulation::Wake(array_buffer, GetAddress32(i, sta->byte_offset()),
c),
isolate);
} }
} return FutexEmulation::Wake(array_buffer, wake_addr, c);
} // namespace
// ES #sec-atomics.wake
// Atomics.wake( typedArray, index, count )
BUILTIN(AtomicsWake) {
HandleScope scope(isolate);
Handle<Object> array = args.atOrUndefined(isolate, 1);
Handle<Object> index = args.atOrUndefined(isolate, 2);
Handle<Object> count = args.atOrUndefined(isolate, 3);
isolate->CountUsage(v8::Isolate::UseCounterFeature::kAtomicsWake);
RETURN_RESULT_OR_FAILURE(isolate, AtomicsWake(isolate, array, index, count));
}
// ES #sec-atomics.notify
// Atomics.notify( typedArray, index, count )
BUILTIN(AtomicsNotify) {
HandleScope scope(isolate);
Handle<Object> array = args.atOrUndefined(isolate, 1);
Handle<Object> index = args.atOrUndefined(isolate, 2);
Handle<Object> count = args.atOrUndefined(isolate, 3);
isolate->CountUsage(v8::Isolate::UseCounterFeature::kAtomicsNotify);
RETURN_RESULT_OR_FAILURE(isolate, AtomicsWake(isolate, array, index, count));
} }
Object DoWait(Isolate* isolate, FutexEmulation::WaitMode mode, Object DoWait(Isolate* isolate, FutexEmulation::WaitMode mode,
......
...@@ -3120,8 +3120,6 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object, ...@@ -3120,8 +3120,6 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
Builtins::kAtomicsIsLockFree, 1, true); Builtins::kAtomicsIsLockFree, 1, true);
SimpleInstallFunction(isolate_, atomics_object, "wait", SimpleInstallFunction(isolate_, atomics_object, "wait",
Builtins::kAtomicsWait, 4, true); Builtins::kAtomicsWait, 4, true);
SimpleInstallFunction(isolate_, atomics_object, "wake",
Builtins::kAtomicsWake, 3, true);
SimpleInstallFunction(isolate_, atomics_object, "notify", SimpleInstallFunction(isolate_, atomics_object, "notify",
Builtins::kAtomicsNotify, 3, true); Builtins::kAtomicsNotify, 3, true);
} }
......
...@@ -60,27 +60,6 @@ TEST(AssigmentExpressionLHSIsCall) { ...@@ -60,27 +60,6 @@ TEST(AssigmentExpressionLHSIsCall) {
use_counts[v8::Isolate::kAssigmentExpressionLHSIsCallInStrict] = 0; use_counts[v8::Isolate::kAssigmentExpressionLHSIsCallInStrict] = 0;
} }
TEST(AtomicsWakeAndAtomicsNotify) {
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope scope(isolate);
LocalContext env;
int use_counts[v8::Isolate::kUseCounterFeatureCount] = {};
global_use_counts = use_counts;
i::FLAG_harmony_sharedarraybuffer = true;
CcTest::isolate()->SetUseCounterCallback(MockUseCounterCallback);
CompileRun("Atomics.wake(new Int32Array(new SharedArrayBuffer(16)), 0);");
CHECK_EQ(1, use_counts[v8::Isolate::kAtomicsWake]);
CHECK_EQ(0, use_counts[v8::Isolate::kAtomicsNotify]);
use_counts[v8::Isolate::kAtomicsWake] = 0;
use_counts[v8::Isolate::kAtomicsNotify] = 0;
CompileRun("Atomics.notify(new Int32Array(new SharedArrayBuffer(16)), 0);");
CHECK_EQ(0, use_counts[v8::Isolate::kAtomicsWake]);
CHECK_EQ(1, use_counts[v8::Isolate::kAtomicsNotify]);
}
TEST(RegExpMatchIsTrueishOnNonJSRegExp) { TEST(RegExpMatchIsTrueishOnNonJSRegExp) {
v8::Isolate* isolate = CcTest::isolate(); v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope scope(isolate); v8::HandleScope scope(isolate);
......
// Copyright 2018 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: --allow-natives-syntax --harmony-sharedarraybuffer
// This test needs to be killed if we remove Atomics.wake.
assertNotSame(Atomics.wake, Atomics.notify);
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
[i8a, i16a, i32a, ui8a, ui8ca, ui16a, ui32a, f32a, f64a].forEach(function( [i8a, i16a, i32a, ui8a, ui8ca, ui16a, ui32a, f32a, f64a].forEach(function(
ta) { ta) {
assertThrows(function() { Atomics.wait(ta, 0, 0); }); assertThrows(function() { Atomics.wait(ta, 0, 0); });
assertThrows(function() { Atomics.wake(ta, 0, 1); }); assertThrows(function() { Atomics.notify(ta, 0, 1); });
}); });
})(); })();
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
[i8a, i16a, ui8a, ui8ca, ui16a, ui32a, f32a, f64a].forEach(function( [i8a, i16a, ui8a, ui8ca, ui16a, ui32a, f32a, f64a].forEach(function(
ta) { ta) {
assertThrows(function() { Atomics.wait(ta, 0, 0); }); assertThrows(function() { Atomics.wait(ta, 0, 0); });
assertThrows(function() { Atomics.wake(ta, 0, 1); }); assertThrows(function() { Atomics.notify(ta, 0, 1); });
}); });
})(); })();
...@@ -53,7 +53,7 @@ ...@@ -53,7 +53,7 @@
Atomics.wait(i32a, invalidIndex, 0); Atomics.wait(i32a, invalidIndex, 0);
}, RangeError); }, RangeError);
assertThrows(function() { assertThrows(function() {
Atomics.wake(i32a, invalidIndex, 0); Atomics.notify(i32a, invalidIndex, 0);
}, RangeError); }, RangeError);
var validIndex = 0; var validIndex = 0;
}); });
...@@ -64,7 +64,7 @@ ...@@ -64,7 +64,7 @@
Atomics.wait(i32a, invalidIndex, 0); Atomics.wait(i32a, invalidIndex, 0);
}, RangeError); }, RangeError);
assertThrows(function() { assertThrows(function() {
Atomics.wake(i32a, invalidIndex, 0); Atomics.notify(i32a, invalidIndex, 0);
}, RangeError); }, RangeError);
var validIndex = 0; var validIndex = 0;
}); });
...@@ -106,7 +106,6 @@ ...@@ -106,7 +106,6 @@
(function TestWakePositiveInfinity() { (function TestWakePositiveInfinity() {
var i32a = new Int32Array(new SharedArrayBuffer(16)); var i32a = new Int32Array(new SharedArrayBuffer(16));
Atomics.wake(i32a, 0, Number.POSITIVE_INFINITY);
Atomics.notify(i32a, 0, Number.POSITIVE_INFINITY); Atomics.notify(i32a, 0, Number.POSITIVE_INFINITY);
})(); })();
...@@ -168,9 +167,6 @@ if (this.Worker) { ...@@ -168,9 +167,6 @@ if (this.Worker) {
}; };
// Test various infinite timeouts // Test various infinite timeouts
TestWaitWithTimeout(Atomics.wake, undefined);
TestWaitWithTimeout(Atomics.wake, NaN);
TestWaitWithTimeout(Atomics.wake, Infinity);
TestWaitWithTimeout(Atomics.notify, undefined); TestWaitWithTimeout(Atomics.notify, undefined);
TestWaitWithTimeout(Atomics.notify, NaN); TestWaitWithTimeout(Atomics.notify, NaN);
TestWaitWithTimeout(Atomics.notify, Infinity); TestWaitWithTimeout(Atomics.notify, Infinity);
...@@ -243,8 +239,5 @@ if (this.Worker) { ...@@ -243,8 +239,5 @@ if (this.Worker) {
}; };
TestWakeMulti(Atomics.wake); TestWakeMulti(Atomics.notify);
// TODO(binji): This is hitting d8's max worker count when run with multiple
// isolates. Re-enable when workers are cleaned up after termination.
// TestWakeMulti(Atomics.notify);
} }
...@@ -42,7 +42,7 @@ let shared = ` ...@@ -42,7 +42,7 @@ let shared = `
} }
function wake(memory, index) { function wake(memory, index) {
var result = Atomics.wake(memory, index, 1); var result = Atomics.notify(memory, index, 1);
if (result != 0 && result != 1) { if (result != 0 && result != 1) {
postMessage('Error: bad result from wake: ' + result); postMessage('Error: bad result from wake: ' + result);
} }
......
...@@ -282,12 +282,12 @@ if (this.Worker) { ...@@ -282,12 +282,12 @@ if (this.Worker) {
if (num >= numWorkers) { if (num >= numWorkers) {
// if numWorkers or more is passed to wake, numWorkers workers should be // if numWorkers or more is passed to wake, numWorkers workers should be
// woken. // woken.
assertEquals(numWorkers, Atomics.wake(i32a, indexJs, num)); assertEquals(numWorkers, Atomics.notify(i32a, indexJs, num));
} else { } else {
// if num < numWorkers is passed to wake, num workers should be woken. // if num < numWorkers is passed to wake, num workers should be woken.
// Then the remaining workers are woken for the next part // Then the remaining workers are woken for the next part
assertEquals(num, Atomics.wake(i32a, indexJs, num)); assertEquals(num, Atomics.notify(i32a, indexJs, num));
assertEquals(numWorkers-num, Atomics.wake(i32a, indexJs, numWorkers)); assertEquals(numWorkers-num, Atomics.notify(i32a, indexJs, numWorkers));
} }
for (let id = 0; id < numWorkers; id++) { for (let id = 0; id < numWorkers; id++) {
assertEquals(msg, workers[id].getMessage()); assertEquals(msg, workers[id].getMessage());
......
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