Bug 229898 - [JSC] Make EnumeratorNextUpdateIndexAndMode clobberizing rule precise
Summary: [JSC] Make EnumeratorNextUpdateIndexAndMode clobberizing rule precise
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
: 229842 (view as bug list)
Depends on:
Blocks:
 
Reported: 2021-09-03 15:00 PDT by Yusuke Suzuki
Modified: 2022-02-12 20:31 PST (History)
8 users (show)

See Also:


Attachments
Patch (5.88 KB, patch)
2021-09-03 15:02 PDT, Yusuke Suzuki
saam: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Yusuke Suzuki 2021-09-03 15:00:44 PDT
[JSC] Make EnumeratorNextUpdateIndexAndMode clobberizing rule precise
Comment 1 Yusuke Suzuki 2021-09-03 15:02:52 PDT
Created attachment 437319 [details]
Patch
Comment 2 Yusuke Suzuki 2021-09-03 15:02:54 PDT
<rdar://problem/82714439>
Comment 3 Mark Lam 2021-09-03 17:38:06 PDT
Comment on attachment 437319 [details]
Patch

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

> Source/JavaScriptCore/dfg/DFGClobberize.h:374
> -            if (mode.isSaneChain()) {
> +            if (mode.isInBounds()) {

After this change (and the ones below), all this code is identical to the case for HasIndexedProperty.  Why not just make the EnumeratorNextUpdateIndexAndMode case do this instead?

    case EnumeratorNextUpdateIndexAndMode: {
        if (node->enumeratorMetadata() == JSPropertyNameEnumerator::OwnStructureMode && graph.varArgChild(node, 0).useKind() == CellUse) {
            read(JSObject_butterfly);
            read(NamedProperties);
            read(JSCell_structureID);
            return;
        }

        if (node->enumeratorMetadata() != JSPropertyNameEnumerator::IndexedMode) {
            read(JSObject_butterfly);
            clobberTop();
            return;
        }

        FALLTHROUGH;
    }

    case HasIndexedProperty: {
        ...
Comment 4 Saam Barati 2021-09-03 17:49:34 PDT
Comment on attachment 437319 [details]
Patch

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

>> Source/JavaScriptCore/dfg/DFGClobberize.h:374
>> +            if (mode.isInBounds()) {
> 
> After this change (and the ones below), all this code is identical to the case for HasIndexedProperty.  Why not just make the EnumeratorNextUpdateIndexAndMode case do this instead?
> 
>     case EnumeratorNextUpdateIndexAndMode: {
>         if (node->enumeratorMetadata() == JSPropertyNameEnumerator::OwnStructureMode && graph.varArgChild(node, 0).useKind() == CellUse) {
>             read(JSObject_butterfly);
>             read(NamedProperties);
>             read(JSCell_structureID);
>             return;
>         }
> 
>         if (node->enumeratorMetadata() != JSPropertyNameEnumerator::IndexedMode) {
>             read(JSObject_butterfly);
>             clobberTop();
>             return;
>         }
> 
>         FALLTHROUGH;
>     }
> 
>     case HasIndexedProperty: {
>         ...

Or write a shared helper.
Comment 5 Mark Lam 2021-09-03 18:02:24 PDT
Comment on attachment 437319 [details]
Patch

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

> Source/JavaScriptCore/dfg/DFGAbstractInterpreterInlines.h:4303
> +        if (node->enumeratorMetadata() != JSPropertyNameEnumerator::OwnStructureMode || m_graph.varArgChild(node, 0).useKind() != CellUse) {
> +            if (node->enumeratorMetadata() != JSPropertyNameEnumerator::IndexedMode)
> +                clobberWorld();
> +            else {
> +                switch (arrayMode.type()) {
> +                case Array::Int32:
> +                case Array::Double:
> +                case Array::Contiguous:
> +                case Array::ArrayStorage: {
> +                    if (arrayMode.isInBounds())
> +                        break;
> +                    FALLTHROUGH;
> +                }
> +                default: {
> +                    clobberWorld();
> +                    break;
> +                }
> +                }
> +            }
> +        }
>          setNonCellTypeForNode(node, SpecBytecodeNumber);

Can't you also express this in a similar way as the implementation in clobberize() so that it's more obvious that this is meant to match that, and as so that you can re-use the code for HasIndexedProperty either via FALLTHROUGH, or via a helper function?
Comment 6 Yusuke Suzuki 2021-09-03 20:10:40 PDT
Comment on attachment 437319 [details]
Patch

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

>> Source/JavaScriptCore/dfg/DFGAbstractInterpreterInlines.h:4303
>>          setNonCellTypeForNode(node, SpecBytecodeNumber);
> 
> Can't you also express this in a similar way as the implementation in clobberize() so that it's more obvious that this is meant to match that, and as so that you can re-use the code for HasIndexedProperty either via FALLTHROUGH, or via a helper function?

A bit aligned it to the clobberizing's one.

>>> Source/JavaScriptCore/dfg/DFGClobberize.h:374
>>> +            if (mode.isInBounds()) {
>> 
>> After this change (and the ones below), all this code is identical to the case for HasIndexedProperty.  Why not just make the EnumeratorNextUpdateIndexAndMode case do this instead?
>> 
>>     case EnumeratorNextUpdateIndexAndMode: {
>>         if (node->enumeratorMetadata() == JSPropertyNameEnumerator::OwnStructureMode && graph.varArgChild(node, 0).useKind() == CellUse) {
>>             read(JSObject_butterfly);
>>             read(NamedProperties);
>>             read(JSCell_structureID);
>>             return;
>>         }
>> 
>>         if (node->enumeratorMetadata() != JSPropertyNameEnumerator::IndexedMode) {
>>             read(JSObject_butterfly);
>>             clobberTop();
>>             return;
>>         }
>> 
>>         FALLTHROUGH;
>>     }
>> 
>>     case HasIndexedProperty: {
>>         ...
> 
> Or write a shared helper.

Merged both clauses into one.
Comment 7 Yusuke Suzuki 2021-09-03 20:24:25 PDT
Committed r282042 (241342@main): <https://commits.webkit.org/241342@main>
Comment 8 Brent Fulgham 2022-02-12 20:31:24 PST
*** Bug 229842 has been marked as a duplicate of this bug. ***