| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent fe318dd commit 7fb32b4
3 files changed
| 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( | |
| 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, | |
| 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, | |
| Back | FazBrowse Home | New Git URL |
0 commit comments