Skip to content

Commit 5ec5d0a

Browse files
bnoordhuisrvagg
authored andcommitted
src: internalize binding function property names
Internalized strings are created in the old space and that is where they eventually would end up anyway when created as normal strings. PR-URL: #3060 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Trevor Norris <[email protected]>
1 parent c8175fc commit 5ec5d0a

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/env-inl.h

+12-3
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,10 @@ inline void Environment::SetMethod(v8::Local<v8::Object> that,
478478
v8::FunctionCallback callback) {
479479
v8::Local<v8::Function> function =
480480
NewFunctionTemplate(callback)->GetFunction();
481-
v8::Local<v8::String> name_string = v8::String::NewFromUtf8(isolate(), name);
481+
// kInternalized strings are created in the old space.
482+
const v8::NewStringType type = v8::NewStringType::kInternalized;
483+
v8::Local<v8::String> name_string =
484+
v8::String::NewFromUtf8(isolate(), name, type).ToLocalChecked();
482485
that->Set(name_string, function);
483486
function->SetName(name_string); // NODE_SET_METHOD() compatibility.
484487
}
@@ -489,7 +492,10 @@ inline void Environment::SetProtoMethod(v8::Local<v8::FunctionTemplate> that,
489492
v8::Local<v8::Signature> signature = v8::Signature::New(isolate(), that);
490493
v8::Local<v8::Function> function =
491494
NewFunctionTemplate(callback, signature)->GetFunction();
492-
v8::Local<v8::String> name_string = v8::String::NewFromUtf8(isolate(), name);
495+
// kInternalized strings are created in the old space.
496+
const v8::NewStringType type = v8::NewStringType::kInternalized;
497+
v8::Local<v8::String> name_string =
498+
v8::String::NewFromUtf8(isolate(), name, type).ToLocalChecked();
493499
that->PrototypeTemplate()->Set(name_string, function);
494500
function->SetName(name_string); // NODE_SET_PROTOTYPE_METHOD() compatibility.
495501
}
@@ -499,7 +505,10 @@ inline void Environment::SetTemplateMethod(v8::Local<v8::FunctionTemplate> that,
499505
v8::FunctionCallback callback) {
500506
v8::Local<v8::Function> function =
501507
NewFunctionTemplate(callback)->GetFunction();
502-
v8::Local<v8::String> name_string = v8::String::NewFromUtf8(isolate(), name);
508+
// kInternalized strings are created in the old space.
509+
const v8::NewStringType type = v8::NewStringType::kInternalized;
510+
v8::Local<v8::String> name_string =
511+
v8::String::NewFromUtf8(isolate(), name, type).ToLocalChecked();
503512
that->Set(name_string, function);
504513
function->SetName(name_string); // NODE_SET_METHOD() compatibility.
505514
}

0 commit comments

Comments
 (0)