Bug 213041 - [JSC] JSCallbackObject::deleteProperty should redirect to Parent::deletePropertyByIndex if propertyName is index
Summary: [JSC] JSCallbackObject::deleteProperty should redirect to Parent::deletePrope...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Yusuke Suzuki
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2020-06-10 12:17 PDT by Yusuke Suzuki
Modified: 2020-06-10 16:15 PDT (History)
8 users (show)

See Also:


Attachments
Patch (4.08 KB, patch)
2020-06-10 12:19 PDT, Yusuke Suzuki
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Yusuke Suzuki 2020-06-10 12:17:34 PDT
[JSC] JSCallbackObject::deleteProperty should redirect to Parent::deletePropertyByIndex if propertyName is index
Comment 1 Yusuke Suzuki 2020-06-10 12:19:37 PDT
Created attachment 401567 [details]
Patch
Comment 2 Yusuke Suzuki 2020-06-10 12:19:39 PDT
<rdar://problem/64204300>
Comment 3 Darin Adler 2020-06-10 12:28:04 PDT
Comment on attachment 401567 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=401567&action=review

> Source/JavaScriptCore/API/JSCallbackObjectFunctions.h:424
> +    static_assert(std::is_final_v<JSCallbackObject<Parent>>, "Ensure no derived classes have custom deletePropertyByIndex implementation");
> +    if (Optional<uint32_t> index = parseIndex(propertyName))
> +        return Parent::deletePropertyByIndex(thisObject, globalObject, index.value());
>      return Parent::deleteProperty(thisObject, globalObject, propertyName, slot);

Seems like we have a small design problem here.

Here we call parseIndex and determine something is not an index, but then call through to the parent without transmitting that information. Then, it also has to call parseIndex.

Seems like there should be one function that doesn’t know if the property name is an index or not, another one that knows it’s an index, and a third that knows it’s not an index.

Wouldn’t we like to make a design so that parsing to see if a property name is an index happens exactly once?
Comment 4 Yusuke Suzuki 2020-06-10 13:45:17 PDT
Comment on attachment 401567 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=401567&action=review

>> Source/JavaScriptCore/API/JSCallbackObjectFunctions.h:424
>>      return Parent::deleteProperty(thisObject, globalObject, propertyName, slot);
> 
> Seems like we have a small design problem here.
> 
> Here we call parseIndex and determine something is not an index, but then call through to the parent without transmitting that information. Then, it also has to call parseIndex.
> 
> Seems like there should be one function that doesn’t know if the property name is an index or not, another one that knows it’s an index, and a third that knows it’s not an index.
> 
> Wouldn’t we like to make a design so that parsing to see if a property name is an index happens exactly once?

Yeah, agree. I think we eventually need to refactor these functions. Currently, deleteProperty accepts index and non-index. We should consider separating this into two functions.
However, we need to be extra careful when doing that, otherwise, we accidentally introduce additional indirect calls which do not exist before.
Comment 5 Darin Adler 2020-06-10 14:36:17 PDT
Comment on attachment 401567 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=401567&action=review

>>> Source/JavaScriptCore/API/JSCallbackObjectFunctions.h:424
>>>      return Parent::deleteProperty(thisObject, globalObject, propertyName, slot);
>> 
>> Seems like we have a small design problem here.
>> 
>> Here we call parseIndex and determine something is not an index, but then call through to the parent without transmitting that information. Then, it also has to call parseIndex.
>> 
>> Seems like there should be one function that doesn’t know if the property name is an index or not, another one that knows it’s an index, and a third that knows it’s not an index.
>> 
>> Wouldn’t we like to make a design so that parsing to see if a property name is an index happens exactly once?
> 
> Yeah, agree. I think we eventually need to refactor these functions. Currently, deleteProperty accepts index and non-index. We should consider separating this into two functions.
> However, we need to be extra careful when doing that, otherwise, we accidentally introduce additional indirect calls which do not exist before.

I agree with you, too. There’s danger of too many levels of function calls, other types of repeated work, and poor performance if this isn’t done right. It also offends my sensibilities to parse the same string twice.
Comment 6 Yusuke Suzuki 2020-06-10 15:35:20 PDT
In EWS, only imported/w3c/web-platform-tests/css/css-grid/grid-items/grid-items-minimum-height-orthogonal-001.html is failing, but we know that this is failing without this patch. Landing.
Comment 7 EWS 2020-06-10 16:15:47 PDT
Committed r262872: <https://trac.webkit.org/changeset/262872>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 401567 [details].