Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit dec004f

Browse filesBrowse files
codebytereMylesBorins
authored andcommitted
src: expose v8::Isolate setup callbacks
PR-URL: #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>
1 parent 5faaa60 commit dec004f
Copy full SHA for dec004f

File tree

Expand file treeCollapse file tree

4 files changed

+37
-32
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

4 files changed

+37
-32
lines changed
Open diff view settings
Collapse file

‎src/api/environment.cc‎

Copy file name to clipboardExpand all lines: src/api/environment.cc
+7-7Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@ using v8::PropertyDescriptor;
3131
using v8::String;
3232
using v8::Value;
3333

34-
static bool AllowWasmCodeGenerationCallback(Local<Context> context,
35-
Local<String>) {
34+
bool AllowWasmCodeGenerationCallback(Local<Context> context,
35+
Local<String>) {
3636
Local<Value> wasm_code_gen =
3737
context->GetEmbedderData(ContextEmbedderIndex::kAllowWasmCodeGeneration);
3838
return wasm_code_gen->IsUndefined() || wasm_code_gen->IsTrue();
3939
}
4040

41-
static bool ShouldAbortOnUncaughtException(Isolate* isolate) {
41+
bool ShouldAbortOnUncaughtException(Isolate* isolate) {
4242
DebugSealHandleScope scope(isolate);
4343
Environment* env = Environment::GetCurrent(isolate);
4444
return env != nullptr &&
@@ -48,9 +48,9 @@ static bool ShouldAbortOnUncaughtException(Isolate* isolate) {
4848
!env->inside_should_not_abort_on_uncaught_scope();
4949
}
5050

51-
static MaybeLocal<Value> PrepareStackTraceCallback(Local<Context> context,
52-
Local<Value> exception,
53-
Local<Array> trace) {
51+
MaybeLocal<Value> PrepareStackTraceCallback(Local<Context> context,
52+
Local<Value> exception,
53+
Local<Array> trace) {
5454
Environment* env = Environment::GetCurrent(context);
5555
if (env == nullptr) {
5656
return exception->ToString(context).FromMaybe(Local<Value>());
@@ -252,7 +252,7 @@ void SetIsolateMiscHandlers(v8::Isolate* isolate, const IsolateSettings& s) {
252252

253253
if ((s.flags & SHOULD_NOT_SET_PROMISE_REJECTION_CALLBACK) == 0) {
254254
auto* promise_reject_cb = s.promise_reject_callback ?
255-
s.promise_reject_callback : task_queue::PromiseRejectCallback;
255+
s.promise_reject_callback : PromiseRejectCallback;
256256
isolate->SetPromiseRejectCallback(promise_reject_cb);
257257
}
258258

Collapse file

‎src/node.h‎

Copy file name to clipboardExpand all lines: src/node.h
+10Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,16 @@ NODE_EXTERN void DefaultProcessExitHandler(Environment* env, int exit_code);
479479
// This may return nullptr if context is not associated with a Node instance.
480480
NODE_EXTERN Environment* GetCurrentEnvironment(v8::Local<v8::Context> context);
481481

482+
NODE_EXTERN void OnFatalError(const char* location, const char* message);
483+
NODE_EXTERN void PromiseRejectCallback(v8::PromiseRejectMessage message);
484+
NODE_EXTERN bool AllowWasmCodeGenerationCallback(v8::Local<v8::Context> context,
485+
v8::Local<v8::String>);
486+
NODE_EXTERN bool ShouldAbortOnUncaughtException(v8::Isolate* isolate);
487+
NODE_EXTERN v8::MaybeLocal<v8::Value> PrepareStackTraceCallback(
488+
v8::Local<v8::Context> context,
489+
v8::Local<v8::Value> exception,
490+
v8::Local<v8::Array> trace);
491+
482492
// This returns the MultiIsolatePlatform used in the main thread of Node.js.
483493
// If NODE_USE_V8_PLATFORM has not been defined when Node.js was built,
484494
// it returns nullptr.
Collapse file

‎src/node_internals.h‎

Copy file name to clipboardExpand all lines: src/node_internals.h
-4Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,6 @@ std::string GetHumanReadableProcessName();
104104
void InitializeContextRuntime(v8::Local<v8::Context>);
105105
bool InitializePrimordials(v8::Local<v8::Context> context);
106106

107-
namespace task_queue {
108-
void PromiseRejectCallback(v8::PromiseRejectMessage message);
109-
} // namespace task_queue
110-
111107
class NodeArrayBufferAllocator : public ArrayBufferAllocator {
112108
public:
113109
inline uint32_t* zero_fill_field() { return &zero_fill_field_; }
Collapse file

‎src/node_task_queue.cc‎

Copy file name to clipboardExpand all lines: src/node_task_queue.cc
+20-21Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -28,27 +28,6 @@ using v8::PromiseRejectEvent;
2828
using v8::PromiseRejectMessage;
2929
using v8::Value;
3030

31-
namespace task_queue {
32-
33-
static void EnqueueMicrotask(const FunctionCallbackInfo<Value>& args) {
34-
Environment* env = Environment::GetCurrent(args);
35-
Isolate* isolate = env->isolate();
36-
37-
CHECK(args[0]->IsFunction());
38-
39-
isolate->EnqueueMicrotask(args[0].As<Function>());
40-
}
41-
42-
static void RunMicrotasks(const FunctionCallbackInfo<Value>& args) {
43-
MicrotasksScope::PerformCheckpoint(args.GetIsolate());
44-
}
45-
46-
static void SetTickCallback(const FunctionCallbackInfo<Value>& args) {
47-
Environment* env = Environment::GetCurrent(args);
48-
CHECK(args[0]->IsFunction());
49-
env->set_tick_callback_function(args[0].As<Function>());
50-
}
51-
5231
void PromiseRejectCallback(PromiseRejectMessage message) {
5332
static std::atomic<uint64_t> unhandledRejections{0};
5433
static std::atomic<uint64_t> rejectionsHandledAfter{0};
@@ -108,6 +87,26 @@ void PromiseRejectCallback(PromiseRejectMessage message) {
10887
PrintCaughtException(isolate, env->context(), try_catch);
10988
}
11089
}
90+
namespace task_queue {
91+
92+
static void EnqueueMicrotask(const FunctionCallbackInfo<Value>& args) {
93+
Environment* env = Environment::GetCurrent(args);
94+
Isolate* isolate = env->isolate();
95+
96+
CHECK(args[0]->IsFunction());
97+
98+
isolate->EnqueueMicrotask(args[0].As<Function>());
99+
}
100+
101+
static void RunMicrotasks(const FunctionCallbackInfo<Value>& args) {
102+
MicrotasksScope::PerformCheckpoint(args.GetIsolate());
103+
}
104+
105+
static void SetTickCallback(const FunctionCallbackInfo<Value>& args) {
106+
Environment* env = Environment::GetCurrent(args);
107+
CHECK(args[0]->IsFunction());
108+
env->set_tick_callback_function(args[0].As<Function>());
109+
}
111110

112111
static void SetPromiseRejectCallback(
113112
const FunctionCallbackInfo<Value>& args) {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.