summaryrefslogtreecommitdiff
path: root/src/node.h
diff options
context:
space:
mode:
authorShelley Vohr <shelley.vohr@gmail.com>2019-10-25 21:14:36 -0700
committerShelley Vohr <shelley.vohr@gmail.com>2019-11-01 10:22:37 -0700
commitfc02cf586a4b146195a5f09a21fb34269657c484 (patch)
treeae6c1bc391aa720b4ad7bb765dc219d6ecfcc15f /src/node.h
parent75dc8938a40100a53323ed87159a1ab2f149ceca (diff)
downloadandroid-node-v8-fc02cf586a4b146195a5f09a21fb34269657c484.tar.gz
android-node-v8-fc02cf586a4b146195a5f09a21fb34269657c484.tar.bz2
android-node-v8-fc02cf586a4b146195a5f09a21fb34269657c484.zip
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.h31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/node.h b/src/node.h
index cae0673a37..240399d1ed 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(),