Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src/api
AgeCommit message (Collapse)Author
2022-04-28lib,src: implement WebAssembly Web APITobias Nießen
Refs: https://github.com/nodejs/node/pull/41749 Fixes: https://github.com/nodejs/node/issues/21130 PR-URL: https://github.com/nodejs/node/pull/42701 Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
2022-03-23src: suppress false coverity warningMichael Dawson
Signed-off-by: Michael Dawson <mdawson@devrus.com> PR-URL: https://github.com/nodejs/node/pull/42284 Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
2022-02-24src: allow preventing InitializeInspector in envShelley Vohr
PR-URL: https://github.com/nodejs/node/pull/35025 Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
2022-01-01src: guard slightly costly check in MakeCallback more stronglyAnna Henningsen
PR-URL: https://github.com/nodejs/node/pull/41331 Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Darshan Sen <raisinten@gmail.com>
2021-11-10src: add and fix some preprocessor commentsTobias Nießen
PR-URL: https://github.com/nodejs/node/pull/40701 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
2021-08-21src: call overload ctor from the original ctorDarshan Sen
Call the new constructor overload from the original constructor to reduce code duplication. Signed-off-by: Darshan Sen <darshan.sen@postman.com> PR-URL: https://github.com/nodejs/node/pull/39768 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
2021-08-21src: add a constructor overload for CallbackScopeDarshan Sen
This overload accepts the current Environment* as an argument, unlike the other constructor, which accepts an Isolate*. This is useful because we can pass the current Environment* directly instead of recomputing it from the Isolate* inside the constructor. Signed-off-by: Darshan Sen <darshan.sen@postman.com> PR-URL: https://github.com/nodejs/node/pull/39768 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
2021-08-12src: return Maybe<bool> from InitializeContextRuntime()Darshan Sen
Signed-off-by: Darshan Sen <darshan.sen@postman.com> PR-URL: https://github.com/nodejs/node/pull/39695 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
2021-08-06src: return Maybe from a couple of functionsDarshan Sen
Functions affected: * InitializeContext() * InitializeContextForSnapshot() * InitializePrimordials() Signed-off-by: Darshan Sen <darshan.sen@postman.com> PR-URL: https://github.com/nodejs/node/pull/39603 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
2021-06-14src: fix multiple AddLinkedBinding() callsAnna Henningsen
Singly-linked lists are extended at their tail, not their head. This fixes using more than 2 linked addons at a time. PR-URL: https://github.com/nodejs/node/pull/39012 Reviewed-By: Shelley Vohr <codebytere@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Richard Lau <rlau@redhat.com>
2021-06-01src: cache necessary isolate & context in api/*XadillaX
Refs: https://github.com/nodejs/node/pull/37473 PR-URL: https://github.com/nodejs/node/pull/38366 Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
2021-05-25src: use SPrintF in ProcessEmitWarningDarshan Sen
PR-URL: https://github.com/nodejs/node/pull/38758 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
2021-04-30src: allow custom PageAllocator in NodePlatformShelley Vohr
For certain embedder use cases there are more complex memory allocation requirements that the default V8 page allocator does not handle. For example, using MAP_JIT when running under a hardened runtime environment on macOS. This allows embedders like Electron to provide their own allocator that does handle these cases. PR-URL: https://github.com/nodejs/node/pull/38362 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Rich Trott <rtrott@gmail.com>
2021-04-08bootstrap: print information for snapshot at environment exit in debugJoyee Cheung
Print information relevant to snapshot building at the environment exit when NODE_DEBUG_NATIVE is set to include mksnapshot. This helps us understand what need to be fixed to build a snapshot when a script is run to completion. PR-URL: https://github.com/nodejs/node/pull/37967 Refs: https://github.com/nodejs/node/issues/37476 Reviewed-By: Chengzhong Wu <legendecas@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
2021-03-25src: report idle time correctlyStephen Belanger
With this change, the V8 profiler will attribute any time between prepare and check cycles, except any entrances to InternalCallbackScope, to be "idle" time. All callbacks, microtasks, and timers will be marked as not idle. The one exception is native modules which don't use the MakeCallback helper, but those are already broken anyway for async context tracking so we should just encourage broken modules to be fixed. PR-URL: https://github.com/nodejs/node/pull/37868 Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Michael Dawson <midawson@redhat.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
2021-03-15src: use non-deprecated GetCreationContext from V8Michaël Zasso
Fixes: https://github.com/nodejs/node-v8/issues/193 PR-URL: https://github.com/nodejs/node/pull/37587 Reviewed-By: Jiawen Geng <technicalcute@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Myles Borins <myles.borins@gmail.com>
2021-01-24src: mark internally exported functions as explicitly internalTyler Ang-Wanek
PR-URL: https://github.com/nodejs/node/pull/37000 Fixes: https://github.com/nodejs/node/issues/36349 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
2021-01-24src: inline AsyncCleanupHookHandle in headersTyler Ang-Wanek
Fixes: https://github.com/nodejs/node/issues/36349 PR-URL: https://github.com/nodejs/node/pull/37000 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
2021-01-18buffer: add base64url encoding optionFilip Skokan
PR-URL: https://github.com/nodejs/node/pull/36952 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
2020-12-21src: use correct microtask queue for checkpointsAnna Henningsen
I missed in c6c8337402 that we should not just use that queue for enqueuing microtasks, but also for running them. Refs: https://github.com/nodejs/node/pull/36482 PR-URL: https://github.com/nodejs/node/pull/36581 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Gus Caplan <me@gus.host>
2020-12-13src: add way to get IsolateData and allocator from EnvironmentAnna Henningsen
Add a way to get the current `IsolateData*` and, from it, the current Node.js `ArrayBufferAllocator` if there is one. This can be useful for re-using either one of these structures as an embedder. PR-URL: https://github.com/nodejs/node/pull/36441 Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Richard Lau <rlau@redhat.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
2020-12-12src: allow preventing SetPrepareStackTraceCallbackShelley Vohr
Node.js sets a stack trace handler specific to the v8::Context corresponding to the current Environment. When Electron is running in a non-Node.js v8::Context (e.g in the renderer process with contextIsolation enabled), there will be no correspondent Environment - we therefore need to prevent this handler being set so that Blink falls back to its default handling and displays the correct stacktrace. PR-URL: https://github.com/nodejs/node/pull/36447 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Rich Trott <rtrott@gmail.com>
2020-12-11src: introduce convenience node::MakeSyncCallback()Nicolai Stange
There are situations where one wants to invoke a JS callback's ->Call() from C++ and in particular retain any existing async_context state, but where it's not obvious that a plain ->Call() would be safe at the point in question. Such callsites usually resort to node::MakeCallback(..., async_context{0, 0}), which unconditionally pushes the async_context{0, 0} and takes the required provisions for the ->Call() itself such as triggering the tick after its return, if needed. An example would be the PerformanceObserver invocation from PerformanceEntry::Notify(): this can get called when coming from JS through e.g. perf_hooks.performance.mark() and alike, but perhaps also from nghttp2 (c.f. EmitStatistics() in node_http2.cc). In the former case, a plain ->Call() would be safe and it would be desirable to retain the current async_context so that PerformanceObservers can access it resp. the associated AsyncLocalStorage. However, in the second case the additional provisions taken by node::MakeCallback() might potentially be strictly required. So PerformanceEntry::Notify() bites the bullet and invokes the PerformanceObservers through node::MakeCallback() unconditionally, thereby always rendering any possibly preexisting async_context inaccessible. Introduce the convenience node::MakeSyncCallback() for such usecases, which would basically forward to ->Call() if safe and to node::MakeCallback(..., async_context{0, 0}) otherwise. Co-Authored-By: ZauberNerd <zaubernerd@zaubernerd.de> PR-URL: https://github.com/nodejs/node/pull/36343 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Rich Trott <rtrott@gmail.com>
2020-11-02src: clean up embedder APIAnna Henningsen
Remove deprecated APIs (and deprecate one legacy API). PR-URL: https://github.com/nodejs/node/pull/35897 Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
2020-10-14src: add embedding helpers to reduce boilerplate codeAnna Henningsen
Provide helpers for a) spinning the event loop and b) setting up and tearing down the objects involved in a single Node.js instance, as they would typically be used. The former helper is also usable inside Node.js itself, for both Worker and main threads. PR-URL: https://github.com/nodejs/node/pull/35597 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Denys Otrishko <shishugi@gmail.com>
2020-10-11src: add maybe versions of EmitExit and EmitBeforeExitAnna Henningsen
This addresses a TODO comment, and removes invalid `.ToLocalChecked()` calls from our code base. PR-URL: https://github.com/nodejs/node/pull/35486 Reviewed-By: James M Snell <jasnell@gmail.com>
2020-10-08src: expose v8::Isolate setup callbacksShelley Vohr
PR-URL: https://github.com/nodejs/node/pull/35512 Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Rich Trott <rtrott@gmail.com>
2020-10-03src: remove invalid ToLocalChecked in EmitBeforeExitAnna Henningsen
This call can fail, we should not use `.ToLocalChecked()` here. In the long run, we should use variants of `EmitExit()` and `EmitBeforeExit()` that avoid this problem by properly propagating empty `MaybeLocal`s. Example failure: 21:07:17 not ok 2564 parallel/test-worker-terminate-source-map 21:07:17 --- 21:07:17 duration_ms: 0.385 21:07:17 severity: crashed 21:07:17 exitcode: -6 21:07:17 stack: |- 21:07:17 FATAL ERROR: v8::ToLocalChecked Empty MaybeLocal. 21:07:17 1: 0x1012f04a5 node::Abort() (.cold.1) [/Users/iojs/build/workspace/node-test-commit-osx/nodes/osx1015/out/Release/node] 21:07:17 2: 0x1000b52d9 node::Abort() [/Users/iojs/build/workspace/node-test-commit-osx/nodes/osx1015/out/Release/node] 21:07:17 3: 0x1000b543f node::OnFatalError(char const*, char const*) [/Users/iojs/build/workspace/node-test-commit-osx/nodes/osx1015/out/Release/node] 21:07:17 4: 0x1001ffd70 v8::V8::ToLocalEmpty() [/Users/iojs/build/workspace/node-test-commit-osx/nodes/osx1015/out/Release/node] 21:07:17 5: 0x1000079b8 node::EmitBeforeExit(node::Environment*) [/Users/iojs/build/workspace/node-test-commit-osx/nodes/osx1015/out/Release/node] 21:07:17 6: 0x100156fea node::worker::Worker::Run() [/Users/iojs/build/workspace/node-test-commit-osx/nodes/osx1015/out/Release/node] 21:07:17 7: 0x10015a4d2 node::worker::Worker::StartThread(v8::FunctionCallbackInfo<v8::Value> const&)::$_3::__invoke(void*) [/Users/iojs/build/workspace/node-test-commit-osx/nodes/osx1015/out/Release/node] 21:07:17 8: 0x7fff72fe7109 _pthread_start [/usr/lib/system/libsystem_pthread.dylib] 21:07:17 9: 0x7fff72fe2b8b thread_start [/usr/lib/system/libsystem_pthread.dylib] 21:07:17 ... PR-URL: https://github.com/nodejs/node/pull/35484 Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Richard Lau <rlau@redhat.com>
2020-10-03src: make MakeCallback() check can_call_into_js before getting methodAnna Henningsen
There is a check for this in the inner `MakeCallback()` function called by it, but since the `Get()` call here can also result in a call into JS, we should ideally check the flag before that. PR-URL: https://github.com/nodejs/node/pull/35424 Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Denys Otrishko <shishugi@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Andrey Pechkurov <apechkurov@gmail.com> Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de> Reviewed-By: Rich Trott <rtrott@gmail.com>
2020-09-26src: allow N-API addon in `AddLinkedBinding()`Anna Henningsen
`AddLinkedBinding()` can be used to load old-style Node.js addons, but currently not N-API addons. There’s no good reason not to support N-API addons as well, so add that. PR-URL: https://github.com/nodejs/node/pull/35301 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Michael Dawson <midawson@redhat.com> Reviewed-By: Zeyu Yang <himself65@outlook.com>
2020-09-06src: shutdown libuv before exit()Anna Henningsen
This ensures that no operations will be running on the libuv threadpool, which is important because they may run into race conditions with the global destructors being triggered from `exit()`, such as in the added test example here. PR-URL: https://github.com/nodejs/node/pull/35021 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: Zeyu Yang <himself65@outlook.com> Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de> Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
2020-08-12worker: fix --abort-on-uncaught-exception handlingAnna Henningsen
The `set_abort_on_uncaught_exception(false)` line was supposed to prevent aborting when running Workers in `--abort-on-uncaught-exception` mode, but it was incorrectly set and not checked properly in the should-abort callback. PR-URL: https://github.com/nodejs/node/pull/34724 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Mary Marchini <oss@mmarchini.me>
2020-08-07src: fix linter failuresAnna Henningsen
Fix linter failures when running the linter on all source files. PR-URL: https://github.com/nodejs/node/pull/34582 Refs: https://github.com/nodejs/node/pull/34565 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2020-08-07n-api,src: provide asynchronous cleanup hooksAnna Henningsen
Sometimes addons need to perform cleanup actions, for example closing libuv handles or waiting for requests to finish, that cannot be performed synchronously. Add C++ API and N-API functions that allow providing such asynchronous cleanup hooks. Fixes: https://github.com/nodejs/node/issues/34567 PR-URL: https://github.com/nodejs/node/pull/34572 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com>
2020-07-21src: allow preventing SetPromiseRejectCallbackShelley Vohr
PR-URL: https://github.com/nodejs/node/pull/34387 Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de>
2020-07-18src: snapshot Environment upon instantiationJoyee Cheung
This includes the initial Environment (without running bootstrap scripts) into the builtin snapshot PR-URL: https://github.com/nodejs/node/pull/32984 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
2020-07-18src: split the main context initialization from Environemnt ctorJoyee Cheung
So that it's possible to create an Environment not yet attached to any V8 context. We'll use this to deserialize the V8 context before attaching an Environment to it. PR-URL: https://github.com/nodejs/node/pull/32984 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
2020-07-14src,doc,test: remove String::New default parameterAnna Henningsen
`kNormal` has been the implicit default for a while now (since V8 7.6). Refs: https://github.com/v8/v8/commit/e0d7f816990ada28ebe1281ca9431236ef8c6e4f PR-URL: https://github.com/nodejs/node/pull/34248 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: James M Snell <jasnell@gmail.com>
2020-07-14async_hooks: improve resource stack performanceAnna Henningsen
Removes some of the performance overhead that came with `executionAsyncResource()` by using the JS resource array only as a cache for the values provided by C++. The fact that we now use an entry trampoline is used to pass the resource without requiring extra C++/JS boundary crossings, and the direct accesses to the JS resource array from C++ are removed in all fast paths. This particularly improves performance when async hooks are not being used. This is a continuation of https://github.com/nodejs/node/pull/33575 and shares some of its code with it. ./node benchmark/compare.js --new ./node --old ./node-master --runs 30 --filter messageport worker | Rscript benchmark/compare.R [00:06:14|% 100| 1/1 files | 60/60 runs | 2/2 configs]: Done confidence improvement accuracy (*) (**) (***) worker/messageport.js n=1000000 payload='object' ** 12.64 % ±7.30% ±9.72% ±12.65% worker/messageport.js n=1000000 payload='string' * 11.08 % ±9.00% ±11.98% ±15.59% ./node benchmark/compare.js --new ./node --old ./node-master --runs 20 --filter async-resource-vs-destroy async_hooks | Rscript benchmark/compare.R [00:22:35|% 100| 1/1 files | 40/40 runs | 6/6 configs]: Done confidence improvement accuracy (*) async_hooks/async-resource-vs-destroy.js n=1000000 duration=5 connections=500 path='/' asyncMethod='async' type='async-local-storage' benchmarker='autocannon' 1.60 % ±7.35% async_hooks/async-resource-vs-destroy.js n=1000000 duration=5 connections=500 path='/' asyncMethod='async' type='async-resource' benchmarker='autocannon' 6.05 % ±6.57% async_hooks/async-resource-vs-destroy.js n=1000000 duration=5 connections=500 path='/' asyncMethod='async' type='destroy' benchmarker='autocannon' * 8.27 % ±7.50% async_hooks/async-resource-vs-destroy.js n=1000000 duration=5 connections=500 path='/' asyncMethod='callbacks' type='async-local-storage' benchmarker='autocannon' 7.42 % ±8.22% async_hooks/async-resource-vs-destroy.js n=1000000 duration=5 connections=500 path='/' asyncMethod='callbacks' type='async-resource' benchmarker='autocannon' 4.33 % ±7.84% async_hooks/async-resource-vs-destroy.js n=1000000 duration=5 connections=500 path='/' asyncMethod='callbacks' type='destroy' benchmarker='autocannon' 5.96 % ±7.15% (**) (***) async_hooks/async-resource-vs-destroy.js n=1000000 duration=5 connections=500 path='/' asyncMethod='async' type='async-local-storage' benchmarker='autocannon' ±9.84% ±12.94% async_hooks/async-resource-vs-destroy.js n=1000000 duration=5 connections=500 path='/' asyncMethod='async' type='async-resource' benchmarker='autocannon' ±8.81% ±11.60% async_hooks/async-resource-vs-destroy.js n=1000000 duration=5 connections=500 path='/' asyncMethod='async' type='destroy' benchmarker='autocannon' ±10.07% ±13.28% async_hooks/async-resource-vs-destroy.js n=1000000 duration=5 connections=500 path='/' asyncMethod='callbacks' type='async-local-storage' benchmarker='autocannon' ±11.01% ±14.48% async_hooks/async-resource-vs-destroy.js n=1000000 duration=5 connections=500 path='/' asyncMethod='callbacks' type='async-resource' benchmarker='autocannon' ±10.50% ±13.81% async_hooks/async-resource-vs-destroy.js n=1000000 duration=5 connections=500 path='/' asyncMethod='callbacks' type='destroy' benchmarker='autocannon' ±9.58% ±12.62% Refs: https://github.com/nodejs/node/pull/33575 PR-URL: https://github.com/nodejs/node/pull/34319 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de> Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
2020-06-25lib,src: remove cpu profiler idle notifierBen Noordhuis
I added it in commit 57231d5286 ("src: notify V8 profiler when we're idle") from October 2013 as a stop-gap measure to measure CPU time rather than wall clock time, otherwise processes that spend a lot of time sleeping in system calls give a false impression of being very busy. That fix is not without drawbacks because the idle flag is set before libuv makes I/O callbacks and cleared again after. I/O callbacks can result into calls into JS code and executing JS code is as non-idle as you can get. In commit 96ffcb9a21 ("src: reduce cpu profiler overhead") from January 2015, I made Node.js block off the SIGPROF signal that V8's CPU profiler uses before Node.js goes to sleep. The goal of that commit is to reduce the overhead from EINTR system call wakeups but it also has the pleasant side effect of fixing what the idle notifier tried to fix. This commit removes the idle notifier and turns the JS process object methods into no-ops. Fixes: https://github.com/nodejs/node/issues/19009 Refs: https://github.com/nodejs/node/pull/33138 PR-URL: https://github.com/nodejs/node/pull/34010 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
2020-06-25src: fix ParseEncodingsapics
"utf-16LE" was parsed "UNKNOWN", this fixes to "UCS2" "utf-buffer" was parsed "BUFFER", this fixes to "UNKNOWN" "utf-16leNOT" was parsed "UCS2", this fixes to "UNKNOWN" PR-URL: https://github.com/nodejs/node/pull/33957 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
2020-06-25src: disallow JS execution inside FreeEnvironmentAnna Henningsen
This addresses a TODO comment, and aligns the behavior between worker threads and the main thread. The primary motivation for this change is to more strictly enforce the invariant that no JS runs after the `'exit'` event is emitted. PR-URL: https://github.com/nodejs/node/pull/33874 Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Shelley Vohr <codebytere@gmail.com>
2020-06-19domain: remove native domain codeStephen Belanger
With the async_hooks callback trampoline, domains no longer need any native code. With this, domains can exist in pure JavaScript. PR-URL: https://github.com/nodejs/node/pull/33801 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Vladimir de Turckheim <vlad2t@hotmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Andrey Pechkurov <apechkurov@gmail.com> Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
2020-06-19async_hooks: callback trampoline for MakeCallbackStephen Belanger
PR-URL: https://github.com/nodejs/node/pull/33801 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Vladimir de Turckheim <vlad2t@hotmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Andrey Pechkurov <apechkurov@gmail.com> Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
2020-06-08src: use Check() instead of FromJust in environmentDaniel Bevenius
This commit replaces FromJust() calls with Check() in places where the value that FromJust() returns is not used. PR-URL: https://github.com/nodejs/node/pull/33706 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: David Carlier <devnexen@gmail.com>
2020-06-06process: use v8 fast api calls for hrtimeGus Caplan
Refs: https://github.com/nodejs/node/issues/33374 PR-URL: https://github.com/nodejs/node/pull/33600 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2020-05-28src: use MaybeLocal.ToLocal instead of IsEmptyDaniel Bevenius
This commit suggest using MaybeLocal.ToLocal and passing in the Local<Function> fn. The motivation for doing this is that the following MaybeLocal.ToLocalChecked call can then be avoided. PR-URL: https://github.com/nodejs/node/pull/33554 Reviewed-By: Zeyu Yang <himself65@outlook.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
2020-05-25src: use MaybeLocal::FromMaybe to return exceptionDaniel Bevenius
This commit suggests using MaybeLocal::FromMaybe to return the exception string, passing in a default value (an empty Local<Value>) which will be used if the exception object is empty. PR-URL: https://github.com/nodejs/node/pull/33514 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2020-05-23wasi,worker: handle termination exceptionBen Noordhuis
Be careful when emitting the 'beforeExit' event. It's not allowed to call into the runtime when a termination exception is pending. Fixes: https://github.com/nodejs/node/issues/33377 PR-URL: https://github.com/nodejs/node/pull/33386 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
2020-05-23src: remove BeforeExit callback listBen Noordhuis
It obscures the fact that there is only a single BeforeExit action. Just call that statically from `EmitBeforeExit()`. PR-URL: https://github.com/nodejs/node/pull/33386 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>