GeezerVison is showing github.com — src: add SetFastMethodNoSideEffect() · nodejs/node@7fb32b4
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: src/node_process_methods.cc +3-2Lines changed: 3 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -476,8 +476,9 @@ v8::CFunction BindingData::fast_bigint_(v8::CFunction::Make(FastBigInt)); | 476 | 476 |
| 477 | 477 | void BindingData::AddMethods() { | 478 | 478 | 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_); | 481 | 482 | } | 482 | 483 |
| 483 | 484 | void BindingData::RegisterExternalReferences( | |
Collapse file Copy file name to clipboardExpand all lines: src/util.cc +21Lines changed: 21 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -362,6 +362,27 @@ void SetFastMethod(Local<v8::Context> context, | 362 | 362 | v8::FunctionCallback slow_callback, | 363 | 363 | const v8::CFunction* c_function) { | 364 | 364 | 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(); | 365 | 386 | Local<v8::Function> function = | 366 | 387 | NewFunctionTemplate(isolate, | 367 | 388 | slow_callback, | |
Collapse file Copy file name to clipboardExpand all lines: src/util.h +5Lines changed: 5 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -886,6 +886,11 @@ void SetFastMethod(v8::Local<v8::Context> context, | 886 | 886 | const char* name, | 887 | 887 | v8::FunctionCallback slow_callback, | 888 | 888 | 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); | 889 | 894 |
| 890 | 895 | void SetProtoMethod(v8::Isolate* isolate, | 891 | 896 | v8::Local<v8::FunctionTemplate> that, | |
|