GeezerVison is showing github.com — src: add per-isolate SetFastMethod and Set[Fast]MethodNoSideEffect · nodejs/node@2952cc5
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/util.cc +55Lines changed: 55 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -392,6 +392,25 @@ void SetMethod(v8::Isolate* isolate, | 392 | 392 | that->Set(name_string, t); | 393 | 393 | } | 394 | 394 |
| | 395 | +void SetFastMethod(Isolate* isolate, | | 396 | + Local<Template> that, | | 397 | + const char* name, | | 398 | + v8::FunctionCallback slow_callback, | | 399 | + const v8::CFunction* c_function) { | | 400 | + Local<v8::FunctionTemplate> t = | | 401 | + NewFunctionTemplate(isolate, | | 402 | + slow_callback, | | 403 | + Local<v8::Signature>(), | | 404 | + v8::ConstructorBehavior::kThrow, | | 405 | + v8::SideEffectType::kHasSideEffect, | | 406 | + c_function); | | 407 | + // kInternalized strings are created in the old space. | | 408 | + const v8::NewStringType type = v8::NewStringType::kInternalized; | | 409 | + Local<v8::String> name_string = | | 410 | + v8::String::NewFromUtf8(isolate, name, type).ToLocalChecked(); | | 411 | + that->Set(name_string, t); | | 412 | +} | | 413 | + | 395 | 414 | void SetFastMethod(Local<v8::Context> context, | 396 | 415 | Local<v8::Object> that, | 397 | 416 | const char* name, | @@ -434,6 +453,25 @@ void SetFastMethodNoSideEffect(Local<v8::Context> context, | 434 | 453 | that->Set(context, name_string, function).Check(); | 435 | 454 | } | 436 | 455 |
| | 456 | +void SetFastMethodNoSideEffect(Isolate* isolate, | | 457 | + Local<Template> that, | | 458 | + const char* name, | | 459 | + v8::FunctionCallback slow_callback, | | 460 | + const v8::CFunction* c_function) { | | 461 | + Local<v8::FunctionTemplate> t = | | 462 | + NewFunctionTemplate(isolate, | | 463 | + slow_callback, | | 464 | + Local<v8::Signature>(), | | 465 | + v8::ConstructorBehavior::kThrow, | | 466 | + v8::SideEffectType::kHasNoSideEffect, | | 467 | + c_function); | | 468 | + // kInternalized strings are created in the old space. | | 469 | + const v8::NewStringType type = v8::NewStringType::kInternalized; | | 470 | + Local<v8::String> name_string = | | 471 | + v8::String::NewFromUtf8(isolate, name, type).ToLocalChecked(); | | 472 | + that->Set(name_string, t); | | 473 | +} | | 474 | + | 437 | 475 | void SetMethodNoSideEffect(Local<v8::Context> context, | 438 | 476 | Local<v8::Object> that, | 439 | 477 | const char* name, | @@ -455,6 +493,23 @@ void SetMethodNoSideEffect(Local<v8::Context> context, | 455 | 493 | function->SetName(name_string); // NODE_SET_METHOD() compatibility. | 456 | 494 | } | 457 | 495 |
| | 496 | +void SetMethodNoSideEffect(Isolate* isolate, | | 497 | + Local<v8::Template> that, | | 498 | + const char* name, | | 499 | + v8::FunctionCallback callback) { | | 500 | + Local<v8::FunctionTemplate> t = | | 501 | + NewFunctionTemplate(isolate, | | 502 | + callback, | | 503 | + Local<v8::Signature>(), | | 504 | + v8::ConstructorBehavior::kThrow, | | 505 | + v8::SideEffectType::kHasNoSideEffect); | | 506 | + // kInternalized strings are created in the old space. | | 507 | + const v8::NewStringType type = v8::NewStringType::kInternalized; | | 508 | + Local<v8::String> name_string = | | 509 | + v8::String::NewFromUtf8(isolate, name, type).ToLocalChecked(); | | 510 | + that->Set(name_string, t); | | 511 | +} | | 512 | + | 458 | 513 | void SetProtoMethod(v8::Isolate* isolate, | 459 | 514 | Local<v8::FunctionTemplate> that, | 460 | 515 | const char* name, | |
Collapse file Copy file name to clipboardExpand all lines: src/util.h +14Lines changed: 14 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -888,11 +888,21 @@ void SetMethod(v8::Isolate* isolate, | 888 | 888 | const char* name, | 889 | 889 | v8::FunctionCallback callback); | 890 | 890 |
| | 891 | +void SetFastMethod(v8::Isolate* isolate, | | 892 | + v8::Local<v8::Template> that, | | 893 | + const char* name, | | 894 | + v8::FunctionCallback slow_callback, | | 895 | + const v8::CFunction* c_function); | 891 | 896 | void SetFastMethod(v8::Local<v8::Context> context, | 892 | 897 | v8::Local<v8::Object> that, | 893 | 898 | const char* name, | 894 | 899 | v8::FunctionCallback slow_callback, | 895 | 900 | const v8::CFunction* c_function); | | 901 | +void SetFastMethodNoSideEffect(v8::Isolate* isolate, | | 902 | + v8::Local<v8::Template> that, | | 903 | + const char* name, | | 904 | + v8::FunctionCallback slow_callback, | | 905 | + const v8::CFunction* c_function); | 896 | 906 | void SetFastMethodNoSideEffect(v8::Local<v8::Context> context, | 897 | 907 | v8::Local<v8::Object> that, | 898 | 908 | const char* name, | @@ -918,6 +928,10 @@ void SetProtoMethodNoSideEffect(v8::Isolate* isolate, | 918 | 928 | v8::Local<v8::FunctionTemplate> that, | 919 | 929 | const char* name, | 920 | 930 | v8::FunctionCallback callback); | | 931 | +void SetMethodNoSideEffect(v8::Isolate* isolate, | | 932 | + v8::Local<v8::Template> that, | | 933 | + const char* name, | | 934 | + v8::FunctionCallback callback); | 921 | 935 |
| 922 | 936 | enum class SetConstructorFunctionFlag { | 923 | 937 | NONE, | |
|