Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v15.2.0 proposal #36055

Merged
merged 66 commits into from
Nov 10, 2020
Merged
Changes from 1 commit
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
efbfeff
doc: fix incorrect heading level
700software Nov 4, 2020
6968b0f
doc: fix release-schedule link in backport guide
watilde Nov 2, 2020
1b277d9
src: remove ERR prefix in crypto status enums
danbev Oct 29, 2020
9b6512f
n-api: unlink reference during its destructor
Nov 2, 2020
4c6de85
benchmark: remove modules that require intl
richardlau Nov 4, 2020
acd3617
doc: option --prof documentation help added
Krank2me Aug 30, 2020
8bd364a
doc: add new wordings to the API description
PoojaDurgad Oct 10, 2020
23f0d0c
test: fix error in test/internet/test-dns.js
Trott Nov 4, 2020
6d56ba0
doc: update benchmark CI test indicator in README
Trott Nov 3, 2020
dc4936b
crypto: fix comment in ByteSource
tniessen Nov 4, 2020
9757b47
console: use more primordials
aduh95 Oct 21, 2020
b700900
lib: refactor to use more primordials
aduh95 Oct 29, 2020
d83e253
errors: refactor to use more primordials
aduh95 Nov 3, 2020
92bdfd1
fs: add support for AbortSignal in readFile
benjamingr Nov 1, 2020
76332a0
events: port some wpt tests
benjamingr May 28, 2020
a7d0c76
events: support emit on nodeeventtarget
benjamingr Oct 28, 2020
77d33c9
doc: update core-validate-commit link in guide
watilde Nov 3, 2020
01129a7
doc: revise v8.getHeapSnapshot()
Trott Oct 28, 2020
cb6f0d3
test: update old comment style test_util.cc
RaisinTen Oct 30, 2020
1dd744a
http2: fix error stream write followed by destroy
davedoesdev Nov 4, 2020
8d76db8
module: refactor to use iterable-weak-map
bcoe Nov 3, 2020
9d26c4d
domain: refactor to use more primordials
aduh95 Oct 30, 2020
da3c2ab
tools,doc: enable ecmaVersion 2021 in acorn parser
aduh95 Nov 6, 2020
9d9a044
benchmark: ignore build artifacts for napi addons
richardlau Nov 4, 2020
6011bfd
fs: remove unused assignment
Trott Oct 30, 2020
1f27214
tools: add new ESLint rule: prefer-primordials
Leko Sep 29, 2020
a7350b3
tools: don't print gold linker warning w/o flag
MylesBorins Nov 4, 2020
7a2edea
win, build: fix build time on Windows
bzoz Nov 2, 2020
33e2ee5
events: define event handler as enumerable
benjamingr Nov 2, 2020
ab0eb4f
events: support event handlers on prototypes
benjamingr Nov 2, 2020
ff59fcd
events: define abort on prototype
benjamingr Nov 2, 2020
9e67372
events: fire handlers in correct oder
benjamingr Nov 6, 2020
ccbe267
fs: remove unnecessary Function#bind() in fs/promises
bnoordhuis Sep 15, 2020
9c4b360
doc,crypto: added sign/verify method changes about dsaEncoding
panva Oct 12, 2020
06cc400
doc: fix crypto doc linter errors
aduh95 Nov 8, 2020
429113e
http2: move events to the JSStreamSocket
mmomtchev Oct 23, 2020
28ed7d0
http2: centralise socket event binding in Http2Session
mmomtchev Oct 24, 2020
b7aa5e2
stream: remove isPromise utility function
aduh95 Nov 2, 2020
567f8d8
events: getEventListeners static
benjamingr Nov 6, 2020
77e4f19
timers: cleanup abort listener on awaitable timers
jasnell Nov 6, 2020
af2a560
lib: add %TypedArray% abstract constructor to primordials
ExE-Boss Nov 7, 2020
7cb5c09
deps: cherry-pick 9a49b22 from V8 upstream
danbev Nov 3, 2020
4b03670
dns: fix trace_events name for resolveCaa()
Trott Nov 5, 2020
eea7e3b
tools,lib: tighten prefer-primordials rules for Error statics
aduh95 Nov 7, 2020
85cf305
doc,fs: document value of stats.isDirectory on symbolic links
coderaiser Apr 25, 2019
99cb362
doc: advise users to import the full set of trusted release keys
haqer1 Apr 4, 2020
d6bd78f
doc,net: document socket.timeout
kobelb Jul 28, 2020
71fa9c6
doc: add note regarding file structure in src/README.md
lundibundi Aug 31, 2020
11f5924
http2: add has method to proxySocketHandler
masx200 Sep 14, 2020
36c20d9
doc,stream: write(chunk, encoding, cb) encoding can be null
dev-script Sep 27, 2020
f73b8d8
test: improve error message for policy failures
bmeck Oct 13, 2020
292915a
bootstrap: refactor to use more primordials
aduh95 Nov 6, 2020
0a4c96a
test: use global.EventTarget instead of internals
aduh95 Nov 6, 2020
7ef9c70
fs: replace finally with PromisePrototypeFinally
baruchiro Nov 6, 2020
7a37590
module: refactor to use more primordials
aduh95 Nov 7, 2020
f8098c3
tools,lib: recommend using safe primordials
aduh95 Nov 7, 2020
10c9ea7
build: fix zlib inlining for IA-32
RaisinTen Oct 16, 2020
0d74226
crypto: refactor to use more primordials
aduh95 Nov 6, 2020
359a659
stream: writableNeedDrain
ronag Sep 25, 2020
6ac9c8f
build, tools: look for local installation of NASM
richardlau Nov 7, 2020
923276c
doc: move v8.getHeapCodeStatistics()
Trott Nov 7, 2020
fdae9ad
test: fix races in test-performance-eventlooputil
Flarna Nov 7, 2020
dcb2760
doc: escape asterisk in cctest gtest-filter
RaisinTen Nov 8, 2020
ccf9f0e
fs: support abortsignal in writeFile
benjamingr Nov 6, 2020
9774b4c
stream: fix thrown object reference
kanongil Nov 10, 2020
5ecd1c9
2020-11-10, Version 15.2.0 (Current)
danielleadams Nov 9, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
domain: refactor to use more primordials
PR-URL: #35885
Reviewed-By: Rich Trott <rtrott@gmail.com>
  • Loading branch information
aduh95 authored and danielleadams committed Nov 9, 2020
commit 9d26c4d496840c65cc1f1c91a8d6c7c065eadf2a
65 changes: 23 additions & 42 deletions lib/domain.js
Original file line number Diff line number Diff line change
@@ -27,11 +27,17 @@
// unless they address existing, critical bugs.

const {
Array,
ArrayPrototypeEvery,
ArrayPrototypeIndexOf,
ArrayPrototypeLastIndexOf,
ArrayPrototypePush,
ArrayPrototypeSlice,
ArrayPrototypeSplice,
Error,
Map,
FunctionPrototypeCall,
ObjectDefineProperty,
ReflectApply,
SafeMap,
Symbol,
} = primordials;

@@ -61,7 +67,7 @@ ObjectDefineProperty(process, 'domain', {
}
});

const pairing = new Map();
const pairing = new SafeMap();
const asyncHook = createHook({
init(asyncId, type, triggerAsyncId, resource) {
if (process.domain !== null && process.domain !== undefined) {
@@ -149,7 +155,8 @@ exports._stack = stack;
useDomainTrampoline(topLevelDomainCallback);

function updateExceptionCapture() {
if (stack.every((domain) => domain.listenerCount('error') === 0)) {
if (ArrayPrototypeEvery(stack,
(domain) => domain.listenerCount('error') === 0)) {
setUncaughtExceptionCaptureCallback(null);
} else {
setUncaughtExceptionCaptureCallback(null);
@@ -296,18 +303,18 @@ Domain.prototype.enter = function() {
// Note that this might be a no-op, but we still need
// to push it onto the stack so that we can pop it later.
exports.active = process.domain = this;
stack.push(this);
ArrayPrototypePush(stack, this);
updateExceptionCapture();
};


Domain.prototype.exit = function() {
// Don't do anything if this domain is not on the stack.
const index = stack.lastIndexOf(this);
const index = ArrayPrototypeLastIndexOf(stack, this);
if (index === -1) return;

// Exit all domains until this one.
stack.splice(index);
ArrayPrototypeSplice(stack, index);

exports.active = stack[stack.length - 1];
process.domain = exports.active;
@@ -346,33 +353,21 @@ Domain.prototype.add = function(ee) {
value: this,
writable: true
});
this.members.push(ee);
ArrayPrototypePush(this.members, ee);
};


Domain.prototype.remove = function(ee) {
ee.domain = null;
const index = this.members.indexOf(ee);
const index = ArrayPrototypeIndexOf(this.members, ee);
if (index !== -1)
this.members.splice(index, 1);
ArrayPrototypeSplice(this.members, index, 1);
};


Domain.prototype.run = function(fn) {
let ret;

this.enter();
if (arguments.length >= 2) {
const len = arguments.length;
const args = new Array(len - 1);

for (let i = 1; i < len; i++)
args[i - 1] = arguments[i];

ret = fn.apply(this, args);
} else {
ret = fn.call(this);
}
const ret = ReflectApply(fn, this, ArrayPrototypeSlice(arguments, 1));
this.exit();

return ret;
@@ -394,17 +389,8 @@ function intercepted(_this, self, cb, fnargs) {
return;
}

const args = [];
let ret;

self.enter();
if (fnargs.length > 1) {
for (let i = 1; i < fnargs.length; i++)
args.push(fnargs[i]);
ret = cb.apply(_this, args);
} else {
ret = cb.call(_this);
}
const ret = ReflectApply(cb, _this, ArrayPrototypeSlice(fnargs, 1));
self.exit();

return ret;
@@ -423,13 +409,8 @@ Domain.prototype.intercept = function(cb) {


function bound(_this, self, cb, fnargs) {
let ret;

self.enter();
if (fnargs.length > 0)
ret = cb.apply(_this, fnargs);
else
ret = cb.call(_this);
const ret = ReflectApply(cb, _this, fnargs);
self.exit();

return ret;
@@ -468,7 +449,7 @@ EventEmitter.init = function() {
this.domain = exports.active;
}

return eventInit.call(this);
return FunctionPrototypeCall(eventInit, this);
};

const eventEmit = EventEmitter.prototype.emit;
@@ -506,7 +487,7 @@ EventEmitter.prototype.emit = function(...args) {
// handler doesn't run in its own context. This prevents any event emitter
// created or any exception thrown in that error handler from recursively
// executing that error handler.
const origDomainsStack = stack.slice();
const origDomainsStack = ArrayPrototypeSlice(stack);
const origActiveDomain = process.domain;

// Travel the domains stack from top to bottom to find the first domain
@@ -521,7 +502,7 @@ EventEmitter.prototype.emit = function(...args) {
if (idx < 0) {
stack.length = 0;
} else {
stack.splice(idx + 1);
ArrayPrototypeSplice(stack, idx + 1);
}

// Change the current active domain