Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a526b4e

Browse filesBrowse files
devsnektargos
authored andcommitted
atomis: add notify alias
PR-URL: #21413 Refs: #21219 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 5d72189 commit a526b4e
Copy full SHA for a526b4e

File tree

Expand file treeCollapse file tree

3 files changed

+34
-2
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

3 files changed

+34
-2
lines changed
Open diff view settings
Collapse file

‎.eslintrc.js‎

Copy file name to clipboardExpand all lines: .eslintrc.js
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ module.exports = {
243243
'node-core/no-unescaped-regexp-dot': 'error',
244244
},
245245
globals: {
246+
Atomics: false,
246247
BigInt: false,
247248
BigInt64Array: false,
248249
BigUint64Array: false,
Collapse file

‎src/node.cc‎

Copy file name to clipboardExpand all lines: src/node.cc
+23-2Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4031,16 +4031,37 @@ Local<Context> NewContext(Isolate* isolate,
40314031
auto context = Context::New(isolate, nullptr, object_template);
40324032
if (context.IsEmpty()) return context;
40334033
HandleScope handle_scope(isolate);
4034-
auto intl_key = FIXED_ONE_BYTE_STRING(isolate, "Intl");
4035-
auto break_iter_key = FIXED_ONE_BYTE_STRING(isolate, "v8BreakIterator");
40364034
context->SetEmbedderData(
40374035
ContextEmbedderIndex::kAllowWasmCodeGeneration, True(isolate));
4036+
4037+
auto intl_key = FIXED_ONE_BYTE_STRING(isolate, "Intl");
4038+
auto break_iter_key = FIXED_ONE_BYTE_STRING(isolate, "v8BreakIterator");
40384039
Local<Value> intl_v;
40394040
if (context->Global()->Get(context, intl_key).ToLocal(&intl_v) &&
40404041
intl_v->IsObject()) {
40414042
Local<Object> intl = intl_v.As<Object>();
40424043
intl->Delete(context, break_iter_key).FromJust();
40434044
}
4045+
4046+
// https://github.com/nodejs/node/issues/21219
4047+
// TODO(devsnek): remove when v8 supports Atomics.notify
4048+
auto atomics_key = FIXED_ONE_BYTE_STRING(isolate, "Atomics");
4049+
Local<Value> atomics_v;
4050+
if (context->Global()->Get(context, atomics_key).ToLocal(&atomics_v) &&
4051+
atomics_v->IsObject()) {
4052+
Local<Object> atomics = atomics_v.As<Object>();
4053+
auto wake_key = FIXED_ONE_BYTE_STRING(isolate, "wake");
4054+
4055+
Local<Value> wake = atomics->Get(context, wake_key).ToLocalChecked();
4056+
auto notify_key = FIXED_ONE_BYTE_STRING(isolate, "notify");
4057+
4058+
v8::PropertyDescriptor desc(wake, true);
4059+
desc.set_enumerable(false);
4060+
desc.set_configurable(true);
4061+
4062+
atomics->DefineProperty(context, notify_key, desc).ToChecked();
4063+
}
4064+
40444065
return context;
40454066
}
40464067

Collapse file
+10Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
'use strict';
2+
3+
require('../common');
4+
5+
const assert = require('assert');
6+
const { runInNewContext } = require('vm');
7+
8+
assert.strictEqual(Atomics.wake, Atomics.notify);
9+
10+
assert(runInNewContext('Atomics.wake === Atomics.notify'));

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.