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 {
kFunctionTokenOffsetTooLongForToString = 49,
kWasmSharedMemory = 50,
kWasmThreadOpcodes = 51,
kAtomicsNotify = 52,
kAtomicsWake = 53,
kAtomicsNotify = 52, // Unused.
kAtomicsWake = 53, // Unused.
kCollator = 54,
kNumberFormat = 55,
kDateTimeFormat = 56,
......
......@@ -736,7 +736,6 @@ namespace internal {
CPP(AtomicsIsLockFree) \
CPP(AtomicsWait) \
CPP(AtomicsWaitAsync) \
CPP(AtomicsWake) \
\
/* String */ \
/* ES #sec-string.fromcodepoint */ \
......
......@@ -110,71 +110,49 @@ inline size_t GetAddress32(size_t index, size_t byte_offset) {
return (index << 2) + byte_offset;
}
MaybeHandle<Object> AtomicsWake(Isolate* isolate, Handle<Object> array,
Handle<Object> index, Handle<Object> count) {
} // namespace
// 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;
ASSIGN_RETURN_ON_EXCEPTION(
isolate, sta, ValidateSharedIntegerTypedArray(isolate, array, true),
Object);
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, sta, ValidateSharedIntegerTypedArray(isolate, array, true));
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();
uint32_t c;
if (count->IsUndefined(isolate)) {
c = kMaxUInt32;
} else {
ASSIGN_RETURN_ON_EXCEPTION(isolate, count,
Object::ToInteger(isolate, count), Object);
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, count,
Object::ToInteger(isolate, count));
double count_double = count->Number();
if (count_double < 0)
if (count_double < 0) {
count_double = 0;
else if (count_double > kMaxUInt32)
} else if (count_double > kMaxUInt32) {
count_double = kMaxUInt32;
}
c = static_cast<uint32_t>(count_double);
}
Handle<JSArrayBuffer> array_buffer = sta->GetBuffer();
size_t wake_addr;
if (sta->type() == kExternalBigInt64Array) {
return Handle<Object>(
FutexEmulation::Wake(array_buffer, GetAddress64(i, sta->byte_offset()),
c),
isolate);
wake_addr = GetAddress64(i, sta->byte_offset());
} else {
DCHECK(sta->type() == kExternalInt32Array);
return Handle<Object>(
FutexEmulation::Wake(array_buffer, GetAddress32(i, sta->byte_offset()),
c),
isolate);
wake_addr = GetAddress32(i, sta->byte_offset());
}
}
} // 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));
return FutexEmulation::Wake(array_buffer, wake_addr, c);
}
Object DoWait(Isolate* isolate, FutexEmulation::WaitMode mode,
......
......@@ -3120,8 +3120,6 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
Builtins::kAtomicsIsLockFree, 1, true);
SimpleInstallFunction(isolate_, atomics_object, "wait",
Builtins::kAtomicsWait, 4, true);
SimpleInstallFunction(isolate_, atomics_object, "wake",
Builtins::kAtomicsWake, 3, true);
SimpleInstallFunction(isolate_, atomics_object, "notify",
Builtins::kAtomicsNotify, 3, true);
}
......
......@@ -60,27 +60,6 @@ TEST(AssigmentExpressionLHSIsCall) {
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) {
v8::Isolate* isolate = CcTest::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 @@
[i8a, i16a, i32a, ui8a, ui8ca, ui16a, ui32a, f32a, f64a].forEach(function(
ta) {
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 @@
[i8a, i16a, ui8a, ui8ca, ui16a, ui32a, f32a, f64a].forEach(function(
ta) {
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 @@
Atomics.wait(i32a, invalidIndex, 0);
}, RangeError);
assertThrows(function() {
Atomics.wake(i32a, invalidIndex, 0);
Atomics.notify(i32a, invalidIndex, 0);
}, RangeError);
var validIndex = 0;
});
......@@ -64,7 +64,7 @@
Atomics.wait(i32a, invalidIndex, 0);
}, RangeError);
assertThrows(function() {
Atomics.wake(i32a, invalidIndex, 0);
Atomics.notify(i32a, invalidIndex, 0);
}, RangeError);
var validIndex = 0;
});
......@@ -106,7 +106,6 @@
(function TestWakePositiveInfinity() {
var i32a = new Int32Array(new SharedArrayBuffer(16));
Atomics.wake(i32a, 0, Number.POSITIVE_INFINITY);
Atomics.notify(i32a, 0, Number.POSITIVE_INFINITY);
})();
......@@ -168,9 +167,6 @@ if (this.Worker) {
};
// Test various infinite timeouts
TestWaitWithTimeout(Atomics.wake, undefined);
TestWaitWithTimeout(Atomics.wake, NaN);
TestWaitWithTimeout(Atomics.wake, Infinity);
TestWaitWithTimeout(Atomics.notify, undefined);
TestWaitWithTimeout(Atomics.notify, NaN);
TestWaitWithTimeout(Atomics.notify, Infinity);
......@@ -243,8 +239,5 @@ if (this.Worker) {
};
TestWakeMulti(Atomics.wake);
// 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);
TestWakeMulti(Atomics.notify);
}
......@@ -42,7 +42,7 @@ let shared = `
}
function wake(memory, index) {
var result = Atomics.wake(memory, index, 1);
var result = Atomics.notify(memory, index, 1);
if (result != 0 && result != 1) {
postMessage('Error: bad result from wake: ' + result);
}
......
......@@ -282,12 +282,12 @@ if (this.Worker) {
if (num >= numWorkers) {
// if numWorkers or more is passed to wake, numWorkers workers should be
// woken.
assertEquals(numWorkers, Atomics.wake(i32a, indexJs, num));
assertEquals(numWorkers, Atomics.notify(i32a, indexJs, num));
} else {
// if num < numWorkers is passed to wake, num workers should be woken.
// Then the remaining workers are woken for the next part
assertEquals(num, Atomics.wake(i32a, indexJs, num));
assertEquals(numWorkers-num, Atomics.wake(i32a, indexJs, numWorkers));
assertEquals(num, Atomics.notify(i32a, indexJs, num));
assertEquals(numWorkers-num, Atomics.notify(i32a, indexJs, numWorkers));
}
for (let id = 0; id < numWorkers; id++) {
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