src: add per-isolate SetFastMethod and Set[Fast]MethodNoSideEffect

PR-URL: https://github.com/nodejs/node/pull/47768
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
This commit is contained in:
Joyee Cheung authored and Node.js GitHub Bot committed 2023-05-03 13:15:08 +00:00
1 parent 23975850e2
commit e57fa94d92
2 files changed
+69

No files matched your search

+55
View File
@@ -392,6 +392,25 @@ void SetMethod(v8::Isolate* isolate,
that->Set(name_string, t);
}
void SetFastMethod(Isolate* isolate,
Local<Template> that,
const char* name,
v8::FunctionCallback slow_callback,
const v8::CFunction* c_function) {
Local<v8::FunctionTemplate> t =
NewFunctionTemplate(isolate,
slow_callback,
Local<v8::Signature>(),
v8::ConstructorBehavior::kThrow,
v8::SideEffectType::kHasSideEffect,
c_function);
// kInternalized strings are created in the old space.
const v8::NewStringType type = v8::NewStringType::kInternalized;
Local<v8::String> name_string =
v8::String::NewFromUtf8(isolate, name, type).ToLocalChecked();
that->Set(name_string, t);
}
void SetFastMethod(Local<v8::Context> context,
Local<v8::Object> that,
const char* name,
@@ -434,6 +453,25 @@ void SetFastMethodNoSideEffect(Local<v8::Context> context,
that->Set(context, name_string, function).Check();
}
void SetFastMethodNoSideEffect(Isolate* isolate,
Local<Template> that,
const char* name,
v8::FunctionCallback slow_callback,
const v8::CFunction* c_function) {
Local<v8::FunctionTemplate> t =
NewFunctionTemplate(isolate,
slow_callback,
Local<v8::Signature>(),
v8::ConstructorBehavior::kThrow,
v8::SideEffectType::kHasNoSideEffect,
c_function);
// kInternalized strings are created in the old space.
const v8::NewStringType type = v8::NewStringType::kInternalized;
Local<v8::String> name_string =
v8::String::NewFromUtf8(isolate, name, type).ToLocalChecked();
that->Set(name_string, t);
}
void SetMethodNoSideEffect(Local<v8::Context> context,
Local<v8::Object> that,
const char* name,
@@ -455,6 +493,23 @@ void SetMethodNoSideEffect(Local<v8::Context> context,
function->SetName(name_string); // NODE_SET_METHOD() compatibility.
}
void SetMethodNoSideEffect(Isolate* isolate,
Local<v8::Template> that,
const char* name,
v8::FunctionCallback callback) {
Local<v8::FunctionTemplate> t =
NewFunctionTemplate(isolate,
callback,
Local<v8::Signature>(),
v8::ConstructorBehavior::kThrow,
v8::SideEffectType::kHasNoSideEffect);
// kInternalized strings are created in the old space.
const v8::NewStringType type = v8::NewStringType::kInternalized;
Local<v8::String> name_string =
v8::String::NewFromUtf8(isolate, name, type).ToLocalChecked();
that->Set(name_string, t);
}
void SetProtoMethod(v8::Isolate* isolate,
Local<v8::FunctionTemplate> that,
const char* name,
+14
View File
@@ -888,11 +888,21 @@ void SetMethod(v8::Isolate* isolate,
const char* name,
v8::FunctionCallback callback);
void SetFastMethod(v8::Isolate* isolate,
v8::Local<v8::Template> that,
const char* name,
v8::FunctionCallback slow_callback,
const v8::CFunction* c_function);
void SetFastMethod(v8::Local<v8::Context> context,
v8::Local<v8::Object> that,
const char* name,
v8::FunctionCallback slow_callback,
const v8::CFunction* c_function);
void SetFastMethodNoSideEffect(v8::Isolate* isolate,
v8::Local<v8::Template> that,
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,
@@ -918,6 +928,10 @@ void SetProtoMethodNoSideEffect(v8::Isolate* isolate,
v8::Local<v8::FunctionTemplate> that,
const char* name,
v8::FunctionCallback callback);
void SetMethodNoSideEffect(v8::Isolate* isolate,
v8::Local<v8::Template> that,
const char* name,
v8::FunctionCallback callback);
enum class SetConstructorFunctionFlag {
NONE,