Skip to content
Merged
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
5 changes: 3 additions & 2 deletions src/node_process_methods.cc
Original file line number Diff line number Diff line change
Expand Up @@ -481,8 +481,9 @@ v8::CFunction BindingData::fast_bigint_(v8::CFunction::Make(FastBigInt));

void BindingData::AddMethods() {
Local<Context> ctx = env()->context();
SetFastMethod(ctx, object(), "hrtime", SlowNumber, &fast_number_);
SetFastMethod(ctx, object(), "hrtimeBigInt", SlowBigInt, &fast_bigint_);
SetFastMethodNoSideEffect(ctx, object(), "hrtime", SlowNumber, &fast_number_);
SetFastMethodNoSideEffect(
ctx, object(), "hrtimeBigInt", SlowBigInt, &fast_bigint_);
}

void BindingData::RegisterExternalReferences(
Expand Down
21 changes: 21 additions & 0 deletions src/util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,27 @@ void SetFastMethod(Local<v8::Context> context,
v8::FunctionCallback slow_callback,
const v8::CFunction* c_function) {
Isolate* isolate = context->GetIsolate();
Local<v8::Function> function =
NewFunctionTemplate(isolate,
slow_callback,
Local<v8::Signature>(),
v8::ConstructorBehavior::kThrow,
v8::SideEffectType::kHasSideEffect,
c_function)
->GetFunction(context)
.ToLocalChecked();
const v8::NewStringType type = v8::NewStringType::kInternalized;
Local<v8::String> name_string =
v8::String::NewFromUtf8(isolate, name, type).ToLocalChecked();
that->Set(context, name_string, function).Check();
}

void SetFastMethodNoSideEffect(Local<v8::Context> context,
Local<v8::Object> that,
const char* name,
v8::FunctionCallback slow_callback,
const v8::CFunction* c_function) {
Isolate* isolate = context->GetIsolate();
Local<v8::Function> function =
NewFunctionTemplate(isolate,
slow_callback,
Expand Down
5 changes: 5 additions & 0 deletions src/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -894,6 +894,11 @@ void SetFastMethod(v8::Local<v8::Context> context,
const char* name,
v8::FunctionCallback slow_callback,
const v8::CFunction* c_function);
void SetFastMethodNoSideEffect(v8::Local<v8::Context> context,
v8::Local<v8::Object> that,
const char* name,
v8::FunctionCallback slow_callback,
const v8::CFunction* c_function);

void SetProtoMethod(v8::Isolate* isolate,
v8::Local<v8::FunctionTemplate> that,
Expand Down