Commit bd9078bd authored by Sathya Gunasekaran's avatar Sathya Gunasekaran Committed by Chromium LUCI CQ

[extensions] Create FunctionTemplate with the correct ConstructorBehavior

Instead of using the default arguments of
v8::ConstructorBehavior::kAllow and then immediately calling
FunctionTemplate::RemovePrototype, this patch changes the
FunctionTemplateInfo::New to pass in the correct value for
v8::ConstructorBehavior.

There is no change in observable behavior with this patch.

In the future, this change will allow v8 to correctly cache only the
instantiable templates (crbug.com/v8/11284) improving performance of
this template cache.

Bug: v8:11288
Change-Id: I0392fd83fbeeb5a0363d75742bcae9a5239ac715
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2616412Reviewed-by: default avatarJochen Eisinger <jochen@chromium.org>
Commit-Queue: Sathya Gunasekaran  <gsathya@chromium.org>
Cr-Commit-Position: refs/heads/master@{#842618}
parent a3d965b0
...@@ -96,8 +96,8 @@ v8::Local<v8::Object> AsV8Object(v8::Isolate* isolate) { ...@@ -96,8 +96,8 @@ v8::Local<v8::Object> AsV8Object(v8::Isolate* isolate) {
for (const auto& method : methods) { for (const auto& method : methods) {
v8::Local<v8::FunctionTemplate> function = v8::FunctionTemplate::New( v8::Local<v8::FunctionTemplate> function = v8::FunctionTemplate::New(
isolate, BoundLogMethodCallback, isolate, BoundLogMethodCallback,
v8::Integer::New(isolate, static_cast<int>(method.level))); v8::Integer::New(isolate, static_cast<int>(method.level)),
function->RemovePrototype(); v8::Local<v8::Signature>(), 0, v8::ConstructorBehavior::kThrow);
templ->Set(gin::StringToSymbol(isolate, method.name), function); templ->Set(gin::StringToSymbol(isolate, method.name), function);
} }
data->SetObjectTemplate(&kWrapperInfo, templ); data->SetObjectTemplate(&kWrapperInfo, templ);
......
...@@ -730,9 +730,8 @@ v8::Local<v8::Value> ModuleSystem::LoadModuleWithNativeAPIBridge( ...@@ -730,9 +730,8 @@ v8::Local<v8::Value> ModuleSystem::LoadModuleWithNativeAPIBridge(
v8::Local<v8::Object> exports = v8::Object::New(GetIsolate()); v8::Local<v8::Object> exports = v8::Object::New(GetIsolate());
v8::Local<v8::FunctionTemplate> tmpl = v8::FunctionTemplate::New( v8::Local<v8::FunctionTemplate> tmpl = v8::FunctionTemplate::New(
GetIsolate(), GetIsolate(), &SetExportsProperty, v8::Local<v8::Value>(),
&SetExportsProperty); v8::Local<v8::Signature>(), 0, v8::ConstructorBehavior::kThrow);
tmpl->RemovePrototype();
v8::Local<v8::String> v8_key; v8::Local<v8::String> v8_key;
if (!ToV8String(GetIsolate(), "$set", &v8_key)) { if (!ToV8String(GetIsolate(), "$set", &v8_key)) {
NOTREACHED(); NOTREACHED();
......
...@@ -144,9 +144,9 @@ void ObjectBackedNativeHandler::RouteHandlerFunction( ...@@ -144,9 +144,9 @@ void ObjectBackedNativeHandler::RouteHandlerFunction(
<< feature_name; << feature_name;
SetPrivate(data, kFeatureName, SetPrivate(data, kFeatureName,
v8_helpers::ToV8StringUnsafe(isolate, feature_name)); v8_helpers::ToV8StringUnsafe(isolate, feature_name));
v8::Local<v8::FunctionTemplate> function_template = v8::Local<v8::FunctionTemplate> function_template = v8::FunctionTemplate::New(
v8::FunctionTemplate::New(isolate, Router, data); isolate, Router, data, v8::Local<v8::Signature>(), 0,
function_template->RemovePrototype(); v8::ConstructorBehavior::kThrow);
v8::Local<v8::ObjectTemplate>::New(isolate, object_template_) v8::Local<v8::ObjectTemplate>::New(isolate, object_template_)
->Set(isolate, name.c_str(), function_template); ->Set(isolate, name.c_str(), function_template);
router_data_.Append(data); router_data_.Append(data);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment