diff options
author | Shelley Vohr <shelley.vohr@gmail.com> | 2019-10-26 07:14:36 +0300 |
---|---|---|
committer | Michaƫl Zasso <targos@protonmail.com> | 2019-11-05 12:10:42 +0300 |
commit | a0df91cce110ce7bef4bdc66aca60af04f6b0332 (patch) | |
tree | fd2d1918e47dc4112284547dfccebff95d0b8cb4 /src/node.h | |
parent | 050efebf249310a6fc12aee16dd4190846ff27f6 (diff) |
src: expose granular SetIsolateUpForNode
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>
Diffstat (limited to 'src/node.h')
-rw-r--r-- | src/node.h | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/node.h b/src/node.h index cae0673a37f..240399d1ed5 100644 --- a/src/node.h +++ b/src/node.h @@ -291,9 +291,40 @@ class NODE_EXTERN MultiIsolatePlatform : public v8::Platform { NODE_EXTERN void SetIsolateCreateParams(v8::Isolate::CreateParams* params, ArrayBufferAllocator* allocator = nullptr); + +enum IsolateSettingsFlags { + MESSAGE_LISTENER_WITH_ERROR_LEVEL = 1 << 0, + DETAILED_SOURCE_POSITIONS_FOR_PROFILING = 1 << 1 +}; + +struct IsolateSettings { + uint64_t flags = MESSAGE_LISTENER_WITH_ERROR_LEVEL | + DETAILED_SOURCE_POSITIONS_FOR_PROFILING; + v8::MicrotasksPolicy policy = v8::MicrotasksPolicy::kExplicit; + + // Error handling callbacks + v8::Isolate::AbortOnUncaughtExceptionCallback + should_abort_on_uncaught_exception_callback = nullptr; + v8::FatalErrorCallback fatal_error_callback = nullptr; + v8::PrepareStackTraceCallback prepare_stack_trace_callback = nullptr; + + // Miscellaneous callbacks + v8::PromiseRejectCallback promise_reject_callback = nullptr; + v8::AllowWasmCodeGenerationCallback + allow_wasm_code_generation_callback = nullptr; + v8::HostCleanupFinalizationGroupCallback + host_cleanup_finalization_group_callback = nullptr; +}; + +// Overriding IsolateSettings may produce unexpected behavior +// in Node.js core functionality, so proceed at your own risk. +NODE_EXTERN void SetIsolateUpForNode(v8::Isolate* isolate, + const IsolateSettings& settings); + // Set a number of callbacks for the `isolate`, in particular the Node.js // uncaught exception listener. NODE_EXTERN void SetIsolateUpForNode(v8::Isolate* isolate); + // Creates a new isolate with Node.js-specific settings. // This is a convenience method equivalent to using SetIsolateCreateParams(), // Isolate::Allocate(), MultiIsolatePlatform::RegisterIsolate(), |