GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — src: add SetFastMethodNoSideEffect() · nodejs/node@7fb32b4

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • src
    • node_process_methods.cc
    • util.cc
    • util.h
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/node_process_methods.cc‎

Copy file name to clipboardExpand all lines: src/node_process_methods.cc
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -476,8 +476,9 @@ v8::CFunction BindingData::fast_bigint_(v8::CFunction::Make(FastBigInt));
476476

477477
void BindingData::AddMethods() {
478478
Local<Context> ctx = env()->context();
479-
SetFastMethod(ctx, object(), "hrtime", SlowNumber, &fast_number_);
480-
SetFastMethod(ctx, object(), "hrtimeBigInt", SlowBigInt, &fast_bigint_);
479+
SetFastMethodNoSideEffect(ctx, object(), "hrtime", SlowNumber, &fast_number_);
480+
SetFastMethodNoSideEffect(
481+
ctx, object(), "hrtimeBigInt", SlowBigInt, &fast_bigint_);
481482
}
482483

483484
void BindingData::RegisterExternalReferences(
Collapse file

‎src/util.cc‎

Copy file name to clipboardExpand all lines: src/util.cc
+21Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,27 @@ void SetFastMethod(Local<v8::Context> context,
362362
v8::FunctionCallback slow_callback,
363363
const v8::CFunction* c_function) {
364364
Isolate* isolate = context->GetIsolate();
365+
Local<v8::Function> function =
366+
NewFunctionTemplate(isolate,
367+
slow_callback,
368+
Local<v8::Signature>(),
369+
v8::ConstructorBehavior::kThrow,
370+
v8::SideEffectType::kHasSideEffect,
371+
c_function)
372+
->GetFunction(context)
373+
.ToLocalChecked();
374+
const v8::NewStringType type = v8::NewStringType::kInternalized;
375+
Local<v8::String> name_string =
376+
v8::String::NewFromUtf8(isolate, name, type).ToLocalChecked();
377+
that->Set(context, name_string, function).Check();
378+
}
379+
380+
void SetFastMethodNoSideEffect(Local<v8::Context> context,
381+
Local<v8::Object> that,
382+
const char* name,
383+
v8::FunctionCallback slow_callback,
384+
const v8::CFunction* c_function) {
385+
Isolate* isolate = context->GetIsolate();
365386
Local<v8::Function> function =
366387
NewFunctionTemplate(isolate,
367388
slow_callback,
Collapse file

‎src/util.h‎

Copy file name to clipboardExpand all lines: src/util.h
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -886,6 +886,11 @@ void SetFastMethod(v8::Local<v8::Context> context,
886886
const char* name,
887887
v8::FunctionCallback slow_callback,
888888
const v8::CFunction* c_function);
889+
void SetFastMethodNoSideEffect(v8::Local<v8::Context> context,
890+
v8::Local<v8::Object> that,
891+
const char* name,
892+
v8::FunctionCallback slow_callback,
893+
const v8::CFunction* c_function);
889894

890895
void SetProtoMethod(v8::Isolate* isolate,
891896
v8::Local<v8::FunctionTemplate> that,

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.