Skip to content

Commit

Permalink
src: internalize binding function property names
Browse files Browse the repository at this point in the history
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 <jasnell@gmail.com>
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
  • Loading branch information
bnoordhuis authored and rvagg committed Sep 30, 2015
1 parent c8175fc commit 5ec5d0a
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/env-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,10 @@ inline void Environment::SetMethod(v8::Local<v8::Object> that,
v8::FunctionCallback callback) {
v8::Local<v8::Function> function =
NewFunctionTemplate(callback)->GetFunction();
v8::Local<v8::String> name_string = v8::String::NewFromUtf8(isolate(), name);
// kInternalized strings are created in the old space.
const v8::NewStringType type = v8::NewStringType::kInternalized;
v8::Local<v8::String> name_string =
v8::String::NewFromUtf8(isolate(), name, type).ToLocalChecked();
that->Set(name_string, function);
function->SetName(name_string); // NODE_SET_METHOD() compatibility.
}
Expand All @@ -489,7 +492,10 @@ inline void Environment::SetProtoMethod(v8::Local<v8::FunctionTemplate> that,
v8::Local<v8::Signature> signature = v8::Signature::New(isolate(), that);
v8::Local<v8::Function> function =
NewFunctionTemplate(callback, signature)->GetFunction();
v8::Local<v8::String> name_string = v8::String::NewFromUtf8(isolate(), name);
// kInternalized strings are created in the old space.
const v8::NewStringType type = v8::NewStringType::kInternalized;
v8::Local<v8::String> name_string =
v8::String::NewFromUtf8(isolate(), name, type).ToLocalChecked();
that->PrototypeTemplate()->Set(name_string, function);
function->SetName(name_string); // NODE_SET_PROTOTYPE_METHOD() compatibility.
}
Expand All @@ -499,7 +505,10 @@ inline void Environment::SetTemplateMethod(v8::Local<v8::FunctionTemplate> that,
v8::FunctionCallback callback) {
v8::Local<v8::Function> function =
NewFunctionTemplate(callback)->GetFunction();
v8::Local<v8::String> name_string = v8::String::NewFromUtf8(isolate(), name);
// kInternalized strings are created in the old space.
const v8::NewStringType type = v8::NewStringType::kInternalized;
v8::Local<v8::String> name_string =
v8::String::NewFromUtf8(isolate(), name, type).ToLocalChecked();
that->Set(name_string, function);
function->SetName(name_string); // NODE_SET_METHOD() compatibility.
}
Expand Down

0 comments on commit 5ec5d0a

Please sign in to comment.