Commit 040755ec authored by peria's avatar peria Committed by Commit bot

Use SetNativeDataProperty to install features dynamically on instances

This CL replace DefineOwnProperty with SetNativeDataProperty in
InstallAttributeInternal<v8::Object>() not to create function
templates or instances on feature installations.

This change enables us to use the function for all data properties
and it improves performance of preparing origin-trial features
and dynamic installs of runtime enabled features.

BUG=617892

Review-Url: https://codereview.chromium.org/2815453005
Cr-Commit-Position: refs/heads/master@{#467260}
parent 9e289b3d
......@@ -91,41 +91,33 @@ void InstallAttributeInternal(
v8::Isolate* isolate,
v8::Local<v8::Object> instance,
v8::Local<v8::Object> prototype,
const V8DOMConfiguration::AttributeConfiguration& attribute,
const V8DOMConfiguration::AttributeConfiguration& config,
const DOMWrapperWorld& world) {
if (!WorldConfigurationApplies(attribute, world))
if (!WorldConfigurationApplies(config, world))
return;
v8::Local<v8::Name> name = V8AtomicString(isolate, attribute.name);
// This method is only being used for installing interfaces which are
// enabled through origin trials. Assert here that it is being called with
// an attribute configuration for a constructor.
// TODO(iclelland): Relax this constraint and allow arbitrary data-type
// properties to be added here.
DCHECK_EQ(&V8ConstructorAttributeGetter, attribute.getter);
V8PerContextData* per_context_data =
V8PerContextData::From(isolate->GetCurrentContext());
v8::Local<v8::Function> data =
per_context_data->ConstructorForType(attribute.data);
v8::Local<v8::Name> name = V8AtomicString(isolate, config.name);
v8::AccessorNameGetterCallback getter = config.getter;
v8::AccessorNameSetterCallback setter = config.setter;
v8::Local<v8::Value> data =
v8::External::New(isolate, const_cast<WrapperTypeInfo*>(config.data));
v8::PropertyAttribute attribute =
static_cast<v8::PropertyAttribute>(config.attribute);
unsigned location = config.property_location_configuration;
DCHECK(attribute.property_location_configuration);
if (attribute.property_location_configuration &
V8DOMConfiguration::kOnInstance)
DCHECK(location);
v8::Local<v8::Context> context = isolate->GetCurrentContext();
if (location & V8DOMConfiguration::kOnInstance) {
instance
->DefineOwnProperty(
isolate->GetCurrentContext(), name, data,
static_cast<v8::PropertyAttribute>(attribute.attribute))
->SetNativeDataProperty(context, name, getter, setter, data, attribute)
.ToChecked();
if (attribute.property_location_configuration &
V8DOMConfiguration::kOnPrototype)
}
if (location & V8DOMConfiguration::kOnPrototype) {
prototype
->DefineOwnProperty(
isolate->GetCurrentContext(), name, data,
static_cast<v8::PropertyAttribute>(attribute.attribute))
->SetNativeDataProperty(context, name, getter, setter, data, attribute)
.ToChecked();
if (attribute.property_location_configuration &
V8DOMConfiguration::kOnInterface)
}
if (location & V8DOMConfiguration::kOnInterface)
NOTREACHED();
}
......
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