Commit 5a663fd9 authored by Camillo Bruni's avatar Camillo Bruni Committed by V8 LUCI CQ

[api] Speed up MakeAccessorInfo

Avoid a few handle derefs for this semi-hot startup function.

Change-Id: Id61135d6031905d2bee07cadc1396b144b43df9a
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3306428Reviewed-by: 's avatarMarja Hölttä <marja@chromium.org>
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Cr-Commit-Position: refs/heads/main@{#78150}
parent 05da6708
...@@ -1493,23 +1493,27 @@ i::Handle<i::AccessorInfo> MakeAccessorInfo( ...@@ -1493,23 +1493,27 @@ i::Handle<i::AccessorInfo> MakeAccessorInfo(
if (redirected != i::kNullAddress) { if (redirected != i::kNullAddress) {
SET_FIELD_WRAPPED(isolate, obj, set_js_getter, redirected); SET_FIELD_WRAPPED(isolate, obj, set_js_getter, redirected);
} }
if (data.IsEmpty()) {
data = v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate));
}
obj->set_data(*Utils::OpenHandle(*data));
obj->set_is_special_data_property(is_special_data_property);
obj->set_replace_on_access(replace_on_access);
i::Handle<i::Name> accessor_name = Utils::OpenHandle(*name); i::Handle<i::Name> accessor_name = Utils::OpenHandle(*name);
if (!accessor_name->IsUniqueName()) { if (!accessor_name->IsUniqueName()) {
accessor_name = isolate->factory()->InternalizeString( accessor_name = isolate->factory()->InternalizeString(
i::Handle<i::String>::cast(accessor_name)); i::Handle<i::String>::cast(accessor_name));
} }
obj->set_name(*accessor_name); i::DisallowGarbageCollection no_gc;
if (settings & ALL_CAN_READ) obj->set_all_can_read(true); i::AccessorInfo raw_obj = *obj;
if (settings & ALL_CAN_WRITE) obj->set_all_can_write(true); if (data.IsEmpty()) {
obj->set_initial_property_attributes(i::NONE); raw_obj.set_data(i::ReadOnlyRoots(isolate).undefined_value());
} else {
raw_obj.set_data(*Utils::OpenHandle(*data));
}
raw_obj.set_name(*accessor_name);
raw_obj.set_is_special_data_property(is_special_data_property);
raw_obj.set_replace_on_access(replace_on_access);
if (settings & ALL_CAN_READ) raw_obj.set_all_can_read(true);
if (settings & ALL_CAN_WRITE) raw_obj.set_all_can_write(true);
raw_obj.set_initial_property_attributes(i::NONE);
if (!signature.IsEmpty()) { if (!signature.IsEmpty()) {
obj->set_expected_receiver_type(*Utils::OpenHandle(*signature)); raw_obj.set_expected_receiver_type(*Utils::OpenHandle(*signature));
} }
return obj; return obj;
} }
...@@ -1642,10 +1646,14 @@ static void TemplateSetAccessor( ...@@ -1642,10 +1646,14 @@ static void TemplateSetAccessor(
i::Handle<i::AccessorInfo> accessor_info = i::Handle<i::AccessorInfo> accessor_info =
MakeAccessorInfo(isolate, name, getter, setter, data, settings, signature, MakeAccessorInfo(isolate, name, getter, setter, data, settings, signature,
is_special_data_property, replace_on_access); is_special_data_property, replace_on_access);
accessor_info->set_initial_property_attributes( {
i::DisallowGarbageCollection no_gc;
i::AccessorInfo raw = *accessor_info;
raw.set_initial_property_attributes(
static_cast<i::PropertyAttributes>(attribute)); static_cast<i::PropertyAttributes>(attribute));
accessor_info->set_getter_side_effect_type(getter_side_effect_type); raw.set_getter_side_effect_type(getter_side_effect_type);
accessor_info->set_setter_side_effect_type(setter_side_effect_type); raw.set_setter_side_effect_type(setter_side_effect_type);
}
i::ApiNatives::AddNativeDataProperty(isolate, info, accessor_info); i::ApiNatives::AddNativeDataProperty(isolate, info, accessor_info);
} }
......
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