Commit a8159e6a authored by Marina Sakai's avatar Marina Sakai Committed by Commit Bot

Replace GetSymbol using void* with new GetSymbol using SymbolKey for [CachedAttribute]

This CL replaces the old GetSymbol, which uses void* as a key, with the new GetSymbol, which uses an instance of SymbolKey created in CL1877490 as a key, for [CachedAttribute].

Bug: 715418
Change-Id: I97e0d374c6d331b3a249aeeb4ee6cbf0ca8514b8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1880238Reviewed-by: default avatarYuki Shiino <yukishiino@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Reviewed-by: default avatarHitoshi Yoshida <peria@chromium.org>
Commit-Queue: Marina Sakai <marinasakai@google.com>
Cr-Commit-Position: refs/heads/master@{#709361}
parent bab6dacb
...@@ -278,7 +278,7 @@ def attribute_context(interface, attribute, interfaces, component_info): ...@@ -278,7 +278,7 @@ def attribute_context(interface, attribute, interfaces, component_info):
def create_private_property_key_name(attribute): def create_private_property_key_name(attribute):
return NameStyleConverter(attribute.name + '_private_property_key').to_snake_case() return NameStyleConverter(attribute.name + '_key').to_snake_case()
def runtime_call_stats_context(interface, attribute, context): def runtime_call_stats_context(interface, attribute, context):
......
...@@ -80,13 +80,13 @@ const v8::FunctionCallbackInfo<v8::Value>& info ...@@ -80,13 +80,13 @@ const v8::FunctionCallbackInfo<v8::Value>& info
V8PrivateProperty::GetHistoryStateSymbol(info.GetIsolate()); V8PrivateProperty::GetHistoryStateSymbol(info.GetIsolate());
{% else %} {% else %}
{% if not attribute.private_property_is_shared_between_getter_and_setter %} {% if not attribute.private_property_is_shared_between_getter_and_setter %}
static int {{attribute.private_property_key_name}}; static const V8PrivateProperty::SymbolKey
{{attribute.private_property_key_name}}("{{cpp_class}}#{{attribute.camel_case_name}}");
{% endif %} {% endif %}
V8PrivateProperty::Symbol property_symbol = V8PrivateProperty::Symbol property_symbol =
V8PrivateProperty::GetSymbol(info.GetIsolate(), V8PrivateProperty::GetSymbol(info.GetIsolate(),
&{{attribute.private_property_key_name}}, {{attribute.private_property_key_name}});
"{{cpp_class}}#{{attribute.camel_case_name}}");
{% endif %} {% endif %}
if (!static_cast<const {{cpp_class}}*>(impl)->{{attribute.cached_attribute_validation_method}}()) { if (!static_cast<const {{cpp_class}}*>(impl)->{{attribute.cached_attribute_validation_method}}()) {
v8::Local<v8::Value> v8_value; v8::Local<v8::Value> v8_value;
...@@ -478,8 +478,7 @@ static void {{attribute.camel_case_name}}AttributeSetter{{world_suffix}}( ...@@ -478,8 +478,7 @@ static void {{attribute.camel_case_name}}AttributeSetter{{world_suffix}}(
// Invalidate the cached value. // Invalidate the cached value.
V8PrivateProperty::GetSymbol( V8PrivateProperty::GetSymbol(
isolate, isolate,
&{{attribute.private_property_key_name}}, {{attribute.private_property_key_name}})
"{{cpp_class}}#{{attribute.camel_case_name}}")
.DeleteProperty(holder, v8::Undefined(isolate)); .DeleteProperty(holder, v8::Undefined(isolate));
{% endif %} {% endif %}
{% endif %}{# attribute.is_put_forwards #} {% endif %}{# attribute.is_put_forwards #}
......
...@@ -92,7 +92,8 @@ static void (*{{method.name}}MethodForPartialInterface)(const v8::FunctionCallba ...@@ -92,7 +92,8 @@ static void (*{{method.name}}MethodForPartialInterface)(const v8::FunctionCallba
{% for world_suffix in attribute.world_suffixes %} {% for world_suffix in attribute.world_suffixes %}
{% if attribute.private_property_is_shared_between_getter_and_setter %} {% if attribute.private_property_is_shared_between_getter_and_setter %}
// Define a private property key shared between getter and setter. // Define a private property key shared between getter and setter.
static int {{attribute.private_property_key_name}}; static const V8PrivateProperty::SymbolKey
{{attribute.private_property_key_name}}("{{cpp_class}}#{{attribute.camel_case_name}}");
{% endif %} {% endif %}
{% if attribute.does_generate_getter %} {% if attribute.does_generate_getter %}
......
...@@ -1993,7 +1993,8 @@ static void ActivityLoggingSetterForAllWorldsLongAttributeAttributeSetter( ...@@ -1993,7 +1993,8 @@ static void ActivityLoggingSetterForAllWorldsLongAttributeAttributeSetter(
} }
// Define a private property key shared between getter and setter. // Define a private property key shared between getter and setter.
static int cached_attribute_any_attribute_private_property_key; static const V8PrivateProperty::SymbolKey
cached_attribute_any_attribute_key("TestObject#CachedAttributeAnyAttribute");
static void CachedAttributeAnyAttributeAttributeGetter(const v8::FunctionCallbackInfo<v8::Value>& info) { static void CachedAttributeAnyAttributeAttributeGetter(const v8::FunctionCallbackInfo<v8::Value>& info) {
v8::Local<v8::Object> holder = info.Holder(); v8::Local<v8::Object> holder = info.Holder();
...@@ -2003,8 +2004,7 @@ static void CachedAttributeAnyAttributeAttributeGetter(const v8::FunctionCallbac ...@@ -2003,8 +2004,7 @@ static void CachedAttributeAnyAttributeAttributeGetter(const v8::FunctionCallbac
// [CachedAttribute] // [CachedAttribute]
V8PrivateProperty::Symbol property_symbol = V8PrivateProperty::Symbol property_symbol =
V8PrivateProperty::GetSymbol(info.GetIsolate(), V8PrivateProperty::GetSymbol(info.GetIsolate(),
&cached_attribute_any_attribute_private_property_key, cached_attribute_any_attribute_key);
"TestObject#CachedAttributeAnyAttribute");
if (!static_cast<const TestObject*>(impl)->isValueDirty()) { if (!static_cast<const TestObject*>(impl)->isValueDirty()) {
v8::Local<v8::Value> v8_value; v8::Local<v8::Value> v8_value;
if (property_symbol.GetOrUndefined(holder).ToLocal(&v8_value) && !v8_value->IsUndefined()) { if (property_symbol.GetOrUndefined(holder).ToLocal(&v8_value) && !v8_value->IsUndefined()) {
...@@ -2041,13 +2041,13 @@ static void CachedAttributeAnyAttributeAttributeSetter( ...@@ -2041,13 +2041,13 @@ static void CachedAttributeAnyAttributeAttributeSetter(
// Invalidate the cached value. // Invalidate the cached value.
V8PrivateProperty::GetSymbol( V8PrivateProperty::GetSymbol(
isolate, isolate,
&cached_attribute_any_attribute_private_property_key, cached_attribute_any_attribute_key)
"TestObject#CachedAttributeAnyAttribute")
.DeleteProperty(holder, v8::Undefined(isolate)); .DeleteProperty(holder, v8::Undefined(isolate));
} }
// Define a private property key shared between getter and setter. // Define a private property key shared between getter and setter.
static int cached_array_attribute_private_property_key; static const V8PrivateProperty::SymbolKey
cached_array_attribute_key("TestObject#CachedArrayAttribute");
static void CachedArrayAttributeAttributeGetter(const v8::FunctionCallbackInfo<v8::Value>& info) { static void CachedArrayAttributeAttributeGetter(const v8::FunctionCallbackInfo<v8::Value>& info) {
v8::Local<v8::Object> holder = info.Holder(); v8::Local<v8::Object> holder = info.Holder();
...@@ -2057,8 +2057,7 @@ static void CachedArrayAttributeAttributeGetter(const v8::FunctionCallbackInfo<v ...@@ -2057,8 +2057,7 @@ static void CachedArrayAttributeAttributeGetter(const v8::FunctionCallbackInfo<v
// [CachedAttribute] // [CachedAttribute]
V8PrivateProperty::Symbol property_symbol = V8PrivateProperty::Symbol property_symbol =
V8PrivateProperty::GetSymbol(info.GetIsolate(), V8PrivateProperty::GetSymbol(info.GetIsolate(),
&cached_array_attribute_private_property_key, cached_array_attribute_key);
"TestObject#CachedArrayAttribute");
if (!static_cast<const TestObject*>(impl)->isFrozenArrayDirty()) { if (!static_cast<const TestObject*>(impl)->isFrozenArrayDirty()) {
v8::Local<v8::Value> v8_value; v8::Local<v8::Value> v8_value;
if (property_symbol.GetOrUndefined(holder).ToLocal(&v8_value) && !v8_value->IsUndefined()) { if (property_symbol.GetOrUndefined(holder).ToLocal(&v8_value) && !v8_value->IsUndefined()) {
...@@ -2099,8 +2098,7 @@ static void CachedArrayAttributeAttributeSetter( ...@@ -2099,8 +2098,7 @@ static void CachedArrayAttributeAttributeSetter(
// Invalidate the cached value. // Invalidate the cached value.
V8PrivateProperty::GetSymbol( V8PrivateProperty::GetSymbol(
isolate, isolate,
&cached_array_attribute_private_property_key, cached_array_attribute_key)
"TestObject#CachedArrayAttribute")
.DeleteProperty(holder, v8::Undefined(isolate)); .DeleteProperty(holder, v8::Undefined(isolate));
} }
...@@ -2110,12 +2108,12 @@ static void ReadonlyCachedAttributeAttributeGetter(const v8::FunctionCallbackInf ...@@ -2110,12 +2108,12 @@ static void ReadonlyCachedAttributeAttributeGetter(const v8::FunctionCallbackInf
TestObject* impl = V8TestObject::ToImpl(holder); TestObject* impl = V8TestObject::ToImpl(holder);
// [CachedAttribute] // [CachedAttribute]
static int readonly_cached_attribute_private_property_key; static const V8PrivateProperty::SymbolKey
readonly_cached_attribute_key("TestObject#ReadonlyCachedAttribute");
V8PrivateProperty::Symbol property_symbol = V8PrivateProperty::Symbol property_symbol =
V8PrivateProperty::GetSymbol(info.GetIsolate(), V8PrivateProperty::GetSymbol(info.GetIsolate(),
&readonly_cached_attribute_private_property_key, readonly_cached_attribute_key);
"TestObject#ReadonlyCachedAttribute");
if (!static_cast<const TestObject*>(impl)->isStringDirty()) { if (!static_cast<const TestObject*>(impl)->isStringDirty()) {
v8::Local<v8::Value> v8_value; v8::Local<v8::Value> v8_value;
if (property_symbol.GetOrUndefined(holder).ToLocal(&v8_value) && !v8_value->IsUndefined()) { if (property_symbol.GetOrUndefined(holder).ToLocal(&v8_value) && !v8_value->IsUndefined()) {
...@@ -2134,7 +2132,8 @@ static void ReadonlyCachedAttributeAttributeGetter(const v8::FunctionCallbackInf ...@@ -2134,7 +2132,8 @@ static void ReadonlyCachedAttributeAttributeGetter(const v8::FunctionCallbackInf
} }
// Define a private property key shared between getter and setter. // Define a private property key shared between getter and setter.
static int cached_string_or_none_attribute_private_property_key; static const V8PrivateProperty::SymbolKey
cached_string_or_none_attribute_key("TestObject#CachedStringOrNoneAttribute");
static void CachedStringOrNoneAttributeAttributeGetter(const v8::FunctionCallbackInfo<v8::Value>& info) { static void CachedStringOrNoneAttributeAttributeGetter(const v8::FunctionCallbackInfo<v8::Value>& info) {
v8::Local<v8::Object> holder = info.Holder(); v8::Local<v8::Object> holder = info.Holder();
...@@ -2144,8 +2143,7 @@ static void CachedStringOrNoneAttributeAttributeGetter(const v8::FunctionCallbac ...@@ -2144,8 +2143,7 @@ static void CachedStringOrNoneAttributeAttributeGetter(const v8::FunctionCallbac
// [CachedAttribute] // [CachedAttribute]
V8PrivateProperty::Symbol property_symbol = V8PrivateProperty::Symbol property_symbol =
V8PrivateProperty::GetSymbol(info.GetIsolate(), V8PrivateProperty::GetSymbol(info.GetIsolate(),
&cached_string_or_none_attribute_private_property_key, cached_string_or_none_attribute_key);
"TestObject#CachedStringOrNoneAttribute");
if (!static_cast<const TestObject*>(impl)->isStringDirty()) { if (!static_cast<const TestObject*>(impl)->isStringDirty()) {
v8::Local<v8::Value> v8_value; v8::Local<v8::Value> v8_value;
if (property_symbol.GetOrUndefined(holder).ToLocal(&v8_value) && !v8_value->IsUndefined()) { if (property_symbol.GetOrUndefined(holder).ToLocal(&v8_value) && !v8_value->IsUndefined()) {
...@@ -2184,8 +2182,7 @@ static void CachedStringOrNoneAttributeAttributeSetter( ...@@ -2184,8 +2182,7 @@ static void CachedStringOrNoneAttributeAttributeSetter(
// Invalidate the cached value. // Invalidate the cached value.
V8PrivateProperty::GetSymbol( V8PrivateProperty::GetSymbol(
isolate, isolate,
&cached_string_or_none_attribute_private_property_key, cached_string_or_none_attribute_key)
"TestObject#CachedStringOrNoneAttribute")
.DeleteProperty(holder, v8::Undefined(isolate)); .DeleteProperty(holder, v8::Undefined(isolate));
} }
...@@ -3148,7 +3145,8 @@ static void RaisesExceptionTestInterfaceEmptyAttributeAttributeSetter( ...@@ -3148,7 +3145,8 @@ static void RaisesExceptionTestInterfaceEmptyAttributeAttributeSetter(
} }
// Define a private property key shared between getter and setter. // Define a private property key shared between getter and setter.
static int cached_attribute_raises_exception_getter_any_attribute_private_property_key; static const V8PrivateProperty::SymbolKey
cached_attribute_raises_exception_getter_any_attribute_key("TestObject#CachedAttributeRaisesExceptionGetterAnyAttribute");
static void CachedAttributeRaisesExceptionGetterAnyAttributeAttributeGetter(const v8::FunctionCallbackInfo<v8::Value>& info) { static void CachedAttributeRaisesExceptionGetterAnyAttributeAttributeGetter(const v8::FunctionCallbackInfo<v8::Value>& info) {
v8::Local<v8::Object> holder = info.Holder(); v8::Local<v8::Object> holder = info.Holder();
...@@ -3158,8 +3156,7 @@ static void CachedAttributeRaisesExceptionGetterAnyAttributeAttributeGetter(cons ...@@ -3158,8 +3156,7 @@ static void CachedAttributeRaisesExceptionGetterAnyAttributeAttributeGetter(cons
// [CachedAttribute] // [CachedAttribute]
V8PrivateProperty::Symbol property_symbol = V8PrivateProperty::Symbol property_symbol =
V8PrivateProperty::GetSymbol(info.GetIsolate(), V8PrivateProperty::GetSymbol(info.GetIsolate(),
&cached_attribute_raises_exception_getter_any_attribute_private_property_key, cached_attribute_raises_exception_getter_any_attribute_key);
"TestObject#CachedAttributeRaisesExceptionGetterAnyAttribute");
if (!static_cast<const TestObject*>(impl)->isValueDirty()) { if (!static_cast<const TestObject*>(impl)->isValueDirty()) {
v8::Local<v8::Value> v8_value; v8::Local<v8::Value> v8_value;
if (property_symbol.GetOrUndefined(holder).ToLocal(&v8_value) && !v8_value->IsUndefined()) { if (property_symbol.GetOrUndefined(holder).ToLocal(&v8_value) && !v8_value->IsUndefined()) {
...@@ -3203,8 +3200,7 @@ static void CachedAttributeRaisesExceptionGetterAnyAttributeAttributeSetter( ...@@ -3203,8 +3200,7 @@ static void CachedAttributeRaisesExceptionGetterAnyAttributeAttributeSetter(
// Invalidate the cached value. // Invalidate the cached value.
V8PrivateProperty::GetSymbol( V8PrivateProperty::GetSymbol(
isolate, isolate,
&cached_attribute_raises_exception_getter_any_attribute_private_property_key, cached_attribute_raises_exception_getter_any_attribute_key)
"TestObject#CachedAttributeRaisesExceptionGetterAnyAttribute")
.DeleteProperty(holder, v8::Undefined(isolate)); .DeleteProperty(holder, v8::Undefined(isolate));
} }
......
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