Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/node_external_reference.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ namespace node {
using CFunctionCallbackWithOneByteString =
uint32_t (*)(v8::Local<v8::Value>, const v8::FastOneByteString&);
using CFunctionCallback = void (*)(v8::Local<v8::Value> receiver);
using CFunctionCallbackReturnVoid = void (*)(v8::Local<v8::Object> receiver);
using CFunctionCallbackReturnDouble =
double (*)(v8::Local<v8::Object> receiver);
using CFunctionCallbackValueReturnDouble =
Expand All @@ -39,6 +40,7 @@ class ExternalReferenceRegistry {
#define ALLOWED_EXTERNAL_REFERENCE_TYPES(V) \
V(CFunctionCallback) \
V(CFunctionCallbackWithOneByteString) \
V(CFunctionCallbackReturnVoid) \
V(CFunctionCallbackReturnDouble) \
V(CFunctionCallbackValueReturnDouble) \
V(CFunctionCallbackWithInt64) \
Expand Down
13 changes: 12 additions & 1 deletion src/node_task_queue.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
namespace node {

using errors::TryCatchScope;
using v8::CFunction;
using v8::Context;
using v8::Function;
using v8::FunctionCallbackInfo;
Expand Down Expand Up @@ -142,6 +143,13 @@ static void RunMicrotasks(const FunctionCallbackInfo<Value>& args) {
env->context()->GetMicrotaskQueue()->PerformCheckpoint(env->isolate());
}

static void FastRunMicrotasks(Local<Object> recv) {
Environment* env = Environment::GetCurrent(recv->GetCreationContextChecked());
env->context()->GetMicrotaskQueue()->PerformCheckpoint(env->isolate());
}

static CFunction fast_run_microtasks_(CFunction::Make(FastRunMicrotasks));

static void SetTickCallback(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args);
CHECK(args[0]->IsFunction());
Expand All @@ -165,7 +173,8 @@ static void Initialize(Local<Object> target,

SetMethod(context, target, "enqueueMicrotask", EnqueueMicrotask);
SetMethod(context, target, "setTickCallback", SetTickCallback);
SetMethod(context, target, "runMicrotasks", RunMicrotasks);
SetFastMethod(
context, target, "runMicrotasks", RunMicrotasks, &fast_run_microtasks_);
target->Set(env->context(),
FIXED_ONE_BYTE_STRING(isolate, "tickInfo"),
env->tick_info()->fields().GetJSArray()).Check();
Expand All @@ -187,6 +196,8 @@ void RegisterExternalReferences(ExternalReferenceRegistry* registry) {
registry->Register(EnqueueMicrotask);
registry->Register(SetTickCallback);
registry->Register(RunMicrotasks);
registry->Register(FastRunMicrotasks);
registry->Register(fast_run_microtasks_.GetTypeInfo());
registry->Register(SetPromiseRejectCallback);
}

Expand Down