The hooks to access V8 internals—including GC and statistics—are different across the supported versions of V8, therefore NAN provides its own hooks that call the appropriate V8 methods.
NAN_GC_CALLBACK()
Nan::AddGCEpilogueCallback()
Nan::RemoveGCEpilogueCallback()
Nan::AddGCPrologueCallback()
Nan::RemoveGCPrologueCallback()
Nan::GetHeapStatistics()
Nan::SetCounterFunction()
Nan::SetCreateHistogramFunction()
Nan::SetAddHistogramSampleFunction()
Nan::IdleNotification()
Nan::LowMemoryNotification()
Nan::ContextDisposedNotification()
Nan::GetInternalFieldPointer()
Nan::SetInternalFieldPointer()
Nan::AdjustExternalMemory()
Use NAN_GC_CALLBACK
to declare your callbacks for Nan::AddGCPrologueCallback()
and Nan::AddGCEpilogueCallback()
. Your new method receives the arguments v8::GCType type
and v8::GCCallbackFlags flags
.
static Nan::Persistent<Function> callback; NAN_GC_CALLBACK(gcPrologueCallback) { v8::Local<Value> argv[] = { Nan::New("prologue").ToLocalChecked() }; Nan::MakeCallback(Nan::GetCurrentContext()->Global(), Nan::New(callback), 1, argv); } NAN_METHOD(Hook) { callback.Reset(To<Function>(args[0]).ToLocalChecked()); Nan::AddGCPrologueCallback(gcPrologueCallback); info.GetReturnValue().Set(info.Holder()); }
Signature:
void Nan::AddGCEpilogueCallback(v8::Isolate::GCEpilogueCallback callback, v8::GCType gc_type_filter = v8::kGCTypeAll)
Calls V8's AddGCEpilogueCallback()
.
Signature:
void Nan::RemoveGCEpilogueCallback(v8::Isolate::GCEpilogueCallback callback)
Calls V8's RemoveGCEpilogueCallback()
.
Signature:
void Nan::AddGCPrologueCallback(v8::Isolate::GCPrologueCallback, v8::GCType gc_type_filter callback)
Calls V8's AddGCPrologueCallback()
.
Signature:
void Nan::RemoveGCPrologueCallback(v8::Isolate::GCPrologueCallback callback)
Calls V8's RemoveGCPrologueCallback()
.
Signature:
void Nan::GetHeapStatistics(v8::HeapStatistics *heap_statistics)
Calls V8's GetHeapStatistics()
.
Signature:
void Nan::SetCounterFunction(v8::CounterLookupCallback cb)
Calls V8's SetCounterFunction()
.
Signature:
void Nan::SetCreateHistogramFunction(v8::CreateHistogramCallback cb)
Calls V8's SetCreateHistogramFunction()
.
Signature:
void Nan::SetAddHistogramSampleFunction(v8::AddHistogramSampleCallback cb)
Calls V8's SetAddHistogramSampleFunction()
.
Signature:
bool Nan::IdleNotification(int idle_time_in_ms)
Calls V8's IdleNotification()
or IdleNotificationDeadline()
depending on V8 version.
Signature:
void Nan::LowMemoryNotification()
Calls V8's LowMemoryNotification()
.
Signature:
void Nan::ContextDisposedNotification()
Calls V8's ContextDisposedNotification()
.
Gets a pointer to the internal field with at index
from a V8 Object
handle.
Signature:
void* Nan::GetInternalFieldPointer(v8::Local<v8::Object> object, int index)
Calls the Object's GetAlignedPointerFromInternalField()
or GetPointerFromInternalField()
depending on the version of V8.
Sets the value of the internal field at index
on a V8 Object
handle.
Signature:
void Nan::SetInternalFieldPointer(v8::Local<v8::Object> object, int index, void* value)
Calls the Object's SetAlignedPointerInInternalField()
or SetPointerInInternalField()
depending on the version of V8.
Signature:
int Nan::AdjustExternalMemory(int bytesChange)
Calls V8's AdjustAmountOfExternalAllocatedMemory()
.