summaryrefslogtreecommitdiff
path: root/src/api
AgeCommit message (Collapse)Author
2019-11-28src: cleanup unused headersAlexandre Ferrando
Node codebase has evolved a lot in the more than 10 years of its existence. As more features (and code) have been added, changed, removed, it's sometimes hard to keep track of what gets used and what not. This commits attempts to clean some of those potentially left-over headers using suggestions from include-what-you-use Refs: https://github.com/nodejs/node/issues/27531 PR-URL: https://github.com/nodejs/node/pull/30328 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
2019-11-08src: remove custom tracking for SharedArrayBuffersAnna Henningsen
Remove custom tracking for `SharedArrayBuffer`s and their allocators and instead let V8 do the tracking of both. This is required starting in V8 7.9, because lifetime management for `ArrayBuffer::Allocator`s differs from what was performed previously (i.e. it is no longer easily possible for one Isolate to release an `ArrayBuffer` and another to accept it into its own allocator), and the alternative would have been adapting the `SharedArrayBuffer` tracking logic to also apply to regular `ArrayBuffer` instances. Refs: https://github.com/nodejs/node/pull/30044 PR-URL: https://github.com/nodejs/node/pull/30020 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Jiawen Geng <technicalcute@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2019-11-07src: allow adding linked bindings to EnvironmentAnna Henningsen
This allows manually adding linked bindings to an `Environment` instance, without having to register modules at program load in a global namespace. PR-URL: https://github.com/nodejs/node/pull/30274 Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2019-11-07src: do not use `std::function` for `OnScopeLeave`Anna Henningsen
Using `std::function` adds an extra layer of indirection, and in particular, heap allocations that are not necessary in our use case here. PR-URL: https://github.com/nodejs/node/pull/30134 Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
2019-11-06src: run RunBeforeExitCallbacks as part of EmitBeforeExitAnna Henningsen
This is part of a series of changes to make embedding easier, by requiring fewer internal methods to build a fully functioning Node.js instance. This also aligns the worker_threads code with the main thread code. PR-URL: https://github.com/nodejs/node/pull/30229 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Shelley Vohr <codebytere@gmail.com>
2019-11-06src: remove AsyncScope and AsyncCallbackScopeAnna Henningsen
Reduce the number of different scopes we use for async callbacks. PR-URL: https://github.com/nodejs/node/pull/30236 Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
2019-11-06src: use callback scope for main scriptAnna Henningsen
This allows removing custom code for setting the current async ids and running nextTicks. PR-URL: https://github.com/nodejs/node/pull/30236 Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
2019-11-01src: expose granular SetIsolateUpForNodeShelley Vohr
This PR exposes a new embedder-focused API: SetIsolateUpForNode. It maintains previous behavior for the single-param version of SetIsolateUpForNode and changes no defaults, but was designed to be flexible by allowing for embedders to conditionally override all callbacks and flags set by the previous two-param version of SetIsolateUpForNode. PR-URL: https://github.com/nodejs/node/pull/30150 Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com> Reviewed-By: David Carlier <devnexen@gmail.com>
2019-10-29src: split up InitializeContextShelley Vohr
This splits out code from InitializeContext into a new function InitializeContextForSnapshot and moves the callsite of InitializeContextRuntime from NewContext to InitializeContext - embedders don't necessarily call NewContext and so need to be able to guarantee these functions are called regardless. PR-URL: https://github.com/nodejs/node/pull/30067 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2019-10-13src: implement v8 host weakref hooksGus Caplan
PR-URL: https://github.com/nodejs/node/pull/29874 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2019-09-18src: re-delete Atomics.wakeGus Caplan
PR-URL: https://github.com/nodejs/node/pull/29586 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: David Carlier <devnexen@gmail.com>
2019-09-05src: check microtasks before running themShelley Vohr
PR-URL: https://github.com/nodejs/node/pull/29434 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Minwoo Jung <minwoo@nodesource.com>
2019-08-26src: expose MaybeInitializeContext to allow existing contextsSamuel Attard
Splits the node.js specific tweak intialization of NewContext into a new helper MaybeInitializeContext so that embedders with existing contexts can still use them in a Node.js Environment now that primordials are initialized and required so early. Update MaybeInitializeContext to return MaybeLocal, PR-URL: https://github.com/nodejs/node/pull/28544 Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
2019-07-15build: remove broken intel vtune supportBen Noordhuis
Support for VTune profiling was added in commit a881b53 from November 2015 but has since bitrotted. Remove it. Fixes: https://github.com/nodejs/node/issues/28310 Refs: https://github.com/nodejs/node/pull/3785 PR-URL: https://github.com/nodejs/node/pull/28522 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2019-07-05src: remove unused using declarations in src/apiDaniel Bevenius
PR-URL: https://github.com/nodejs/node/pull/28506 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Jiawen Geng <technicalcute@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2019-07-03src: configure v8 isolate with uv_get_constrained_memoryKelvin Jin
This change adds the ability to set the memory ceiling for a Node.js process according to a memory limit set by cgroups (via uv_get_constrained_memory), which is used by docker containers to set resource constraints. Previously we would use the physical memory size to estimate the necessary V8 heap sizes, but the physical memory size is not necessarily the correct limit, e.g. if the process is running inside a docker container or is otherwise constrained. Non-Linux systems shouldn't be affected. PR-URL: https://github.com/nodejs/node/pull/27508 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ali Ijaz Sheikh <ofrobots@google.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
2019-06-19src: refactor uncaught exception handlingJoyee Cheung
The C++ land `node::FatalException()` is not in fact fatal anymore. It gives the user a chance to handle the uncaught exception globally by listening to the `uncaughtException` event. This patch renames it to `TriggerUncaughtException` in C++ to avoid the confusion. In addition rename the JS land handler to `onGlobalUncaughtException` to reflect its purpose - we have to keep the alias `process._fatalException` and use that for now since it has been monkey-patchable in the user land. This patch also - Adds more comments to the global uncaught exception handling routine - Puts a few other C++ error handling functions into the `errors` namespace - Moves error-handling-related bindings to the `errors` binding. Refs: https://github.com/nodejs/node/commit/2b252acea47af3ebeac3d7e68277f015667264cc PR-URL: https://github.com/nodejs/node/pull/28257 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
2019-06-03src: split `RunBootstrapping()`Joyee Cheung
Split `RunBootstrapping()` into `BootstrapInternalLoaders()` and `BootstrapNode()` from so the two can be snapshotted incrementally. PR-URL: https://github.com/nodejs/node/pull/27539 Reviewed-By: Anna Henningsen <anna@addaleax.net>
2019-06-03src: inline ProcessCliArgs in the Environment constructorJoyee Cheung
Inline `ProcessCliArgs()` in the `Environment` constructor, and emit the `Environment` creation trace events with the arguments earlier. Remove the unused arguments passed to `CreateProcessObject()` since these are now attached to process in `PatchProcessObject()` during pre-execution instead. PR-URL: https://github.com/nodejs/node/pull/27539 Reviewed-By: Anna Henningsen <anna@addaleax.net>
2019-05-26src: move DiagnosticFilename inlines into a -inl.hSam Roberts
DiagnosticFilename's constructor default values use inlines from env-inl.h, causing the many users of node_internals.h to include env-inl.h, even if they never use DiagnosticFilename. PR-URL: https://github.com/nodejs/node/pull/27839 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-05-23src: remove env-inl.h from header filesSam Roberts
Inline headers should only be included into the .cc files that use them. PR-URL: https://github.com/nodejs/node/pull/27755 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
2019-05-21src, lib: take control of prepareStackTraceGus Caplan
Refs https://crbug.com/v8/7848 PR-URL: https://github.com/nodejs/node/pull/23926 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
2019-05-13src: remove util-inl.h from header filesSam Roberts
Its intended that *-inl.h header files are only included into the src files that call the inline methods. Explicitly include it into the files that need it. PR-URL: https://github.com/nodejs/node/pull/27631 Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2019-04-26src: move OnMessage to node_errors.ccJoyee Cheung
Rename the per-isolate message listener to `PerIsolateMessageListener` and move it to `node_errors.cc` since it's part of the error handling process. It also creates an external reference so it needs to be exposed in `node_errors.h` for a snapshot builder to know. PR-URL: https://github.com/nodejs/node/pull/27304 Reviewed-By: Anna Henningsen <anna@addaleax.net>
2019-04-24src: do not require JS Context for `~AsyncResoure()`Anna Henningsen
Allow the destructor to be called during GC, which is a common use case. PR-URL: https://github.com/nodejs/node/pull/27255 Fixes: https://github.com/nodejs/node/issues/27218 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
2019-04-24src: add `Environment` overload of `EmitAsyncDestroy`Anna Henningsen
This can be necessary for being able to call the function when no JS Context is on the stack, e.g. during GC. Refs: https://github.com/nodejs/node/issues/27218 PR-URL: https://github.com/nodejs/node/pull/27255 Fixes: https://github.com/nodejs/node/issues/27218 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
2019-04-23src: allow creating NodeMainInstance that does not own the isolateJoyee Cheung
Allows instantiating a NodeMainInstance with an isolate whose initialization and disposal are controlled by the caller. PR-URL: https://github.com/nodejs/node/pull/27321 Refs: https://github.com/nodejs/node/issues/17058 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2019-04-17src: use RAII to manage the main isolate dataJoyee Cheung
This patch encapsulates the main isolate management into a NodeMainInstance class that manages the resources with RAII and controls the Isolate::CreateParams (which is necessary for deserializing snapshots with external references) PR-URL: https://github.com/nodejs/node/pull/27220 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2019-04-14src: fix check for accepting Buffers into Node’s allocatorAnna Henningsen
This condition was incorrect. We currently take the fallback path in default Node builds, which always works, but may come with some overhead, whereas the intention was that we use the fast path in this condition. This is causing issues for embedders, because we would erroneously try to take the fast path when they don’t provide a Node.js-style `ArrayBufferAlloactor`, and crash as a consequence of that. This also requires us to relax the check in the debugging ArrayBuffer allocator a bit, because since d117e41e50667d7a36, 0-sized ArrayBuffers may actually point to allocations of size 1. Previously, that wasn’t caught because the fallback path circumvented our ArrayBufferAllocator. Refs: https://github.com/nodejs/node/commit/84e02b178ad14fae0df2a514e8a39bfa50ffdc2d#r33116006 PR-URL: https://github.com/nodejs/node/pull/27174 Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gus Caplan <me@gus.host>
2019-04-13lib: create primordials in every contextJoyee Cheung
This allows us to use primordials in other per-context scripts. PR-URL: https://github.com/nodejs/node/pull/27171 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
2019-04-13src: make a Environment-independent proxy class for NativeModuleLoaderJoyee Cheung
This patch splits `NativeModuleLoader` into two parts - a singleton that only relies on v8 and `node::Mutex` and a proxy class for the singleton (`NativeModuleEnv`) that provides limited access to the singleton as well as C++ bindings for the Node.js binary. `NativeModuleLoader` is then no longer aware of `Environment`. PR-URL: https://github.com/nodejs/node/pull/27160 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2019-04-12src: replace FromJust() with Check() when possibleSam Roberts
FromJust() is often used not for its return value, but for its side-effects. In these cases, Check() exists, and is more clear as to the intent. From its comment: To be used, where the actual value of the Maybe is not needed, like Object::Set. See: https://github.com/nodejs/node/pull/26929/files#r269256335 PR-URL: https://github.com/nodejs/node/pull/27162 Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
2019-04-04src: move AsyncResource impl out of public headerBen Noordhuis
Implementing the methods out-of-line (i.e., not inline) means we can fix bugs and have already compiled add-ons pick up the fixes automatically, something that doesn't work when the methods are inline because then they get compiled into the add-on instead of the node binary. PR-URL: https://github.com/nodejs/node/pull/26348 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
2019-04-03process: run RunBootstrapping in CreateEnvironmentJoyee Cheung
Also creates `CreateMainEnvironment` to encapsulate the code creating the main environment from the provided Isolate data and arguments. PR-URL: https://github.com/nodejs/node/pull/26788 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Refael Ackermann <refack@gmail.com>
2019-04-02src: replace c-style castgengjiawen
PR-URL: https://github.com/nodejs/node/pull/26888 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
2019-03-28src: fix data type when using uv_get_total_memory()gengjiawen
PR-URL: https://github.com/nodejs/node/pull/26886 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2019-03-27src: move TickInfo out of EnvironmentJoyee Cheung
PR-URL: https://github.com/nodejs/node/pull/26824 Refs: https://github.com/nodejs/node/issues/26776 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
2019-03-27src: move AsyncCallbackScope out of EnvironmentJoyee Cheung
PR-URL: https://github.com/nodejs/node/pull/26824 Refs: https://github.com/nodejs/node/issues/26776 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
2019-03-27src: move AsyncHooks out of EnvironmentJoyee Cheung
PR-URL: https://github.com/nodejs/node/pull/26824 Refs: https://github.com/nodejs/node/issues/26776 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
2019-03-22src: only open HandleScope when necessaryAnna Henningsen
PR-URL: https://github.com/nodejs/node/pull/26734 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
2019-03-21src: remove `AddPromiseHook()`Anna Henningsen
Remove this, as the underlying `Isolate::SetPromiseHook()` may be removed as well in its current form in the future, and `async_hooks` also serves this use case. Refs: https://docs.google.com/document/d/1g8OrG5lMIUhRn1zbkutgY83MiTSMx-0NHDs8Bf-nXxM/ Refs: https://github.com/nodejs/node/pull/26529 PR-URL: https://github.com/nodejs/node/pull/26574 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ali Ijaz Sheikh <ofrobots@google.com>
2019-03-18src,win: fix usage of deprecated v8::Object::SetMichaël Zasso
PR-URL: https://github.com/nodejs/node/pull/26735 Refs: https://github.com/nodejs/node/issues/26733 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2019-03-16src: shutdown node in-flightGireesh Punathil
This commit introduces a `node::Stop()` API. An identified use case for embedders is their ability to tear down Node while it is still running (event loop contain pending events) Here the assumptions are that (i) embedders do not wish to resort to JS routines to initiate shutdown (ii) embedders have the Environment handle handy. (iii) embedders stop Node through a second thread. Fixes: https://github.com/nodejs/node/issues/19365 Refs: https://github.com/nodejs/user-feedback/issues/51 PR-URL: https://github.com/nodejs/node/pull/21283 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Michael Dawson <Michael_Dawson@ca.ibm.com>
2019-03-15src,lib: make DOMException available in all ContextsAnna Henningsen
This allows using `DOMException` from Node.js code for any `vm.Context`. PR-URL: https://github.com/nodejs/node/pull/26497 Reviewed-By: James M Snell <jasnell@gmail.com>
2019-03-15src,lib: allow running multiple per-context filesAnna Henningsen
Create an `lib/internal/per_context/` directory that can host multiple files which we execute for each context. PR-URL: https://github.com/nodejs/node/pull/26497 Reviewed-By: James M Snell <jasnell@gmail.com>
2019-03-13embedding: make `NewIsolate()` API more flexibleAnna Henningsen
Split the API up into its essential parts, namely setting up the creation parameters for the Isolate, creating it, and performing Node.js-specific customization afterwards. PR-URL: https://github.com/nodejs/node/pull/26525 Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
2019-03-13embedding: refactor public `ArrayBufferAllocator` APIAnna Henningsen
Use a RAII approach by default, and make it possible for embedders to use the `ArrayBufferAllocator` directly as a V8 `ArrayBuffer::Allocator`, e.g. when passing to `Isolate::CreateParams` manually. PR-URL: https://github.com/nodejs/node/pull/26525 Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
2019-03-12src: rename Init and Start overloads to something more distinctiveJoyee Cheung
In addition, move the `--help` and `--v8-help` processing out of `StartNodeWithLoopAndArgs()` and process them earlier - right after `InitializeNodeWithArgs()`, similar to how they are handled in the legacy `Init()`. PR-URL: https://github.com/nodejs/node/pull/26499 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Refael Ackermann <refack@gmail.com>
2019-03-09src: merge debug-only `SealHandleScope`sAnna Henningsen
Instead of repeating the same `#ifdef DEBUG` + `SealHandleScope` pattern over and over, create an utility that does this for us. PR-URL: https://github.com/nodejs/node/pull/26459 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
2019-03-05src: refactor `Environment::GetCurrent(isolate)` usageAnna Henningsen
Do not require an explicit `HandleScope`, or the ability to create one, when using `Environment::GetCurrent()`. `isolate->InContext()` is used as an indicator that it is probably okay to create a `HandleScope`, see also the short discussion in https://github.com/nodejs/node/pull/25775#pullrequestreview-197371049. PR-URL: https://github.com/nodejs/node/pull/26376 Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>