⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 280895 in webkit


Ignore:
Timestamp:
Aug 11, 2021, 3:16:12 AM (5 years ago)
Author:
Adrian Perez de Castro
Message:

Merge r274539 - Object allocation sinking phase should prioritize materializations with no dependencies before materializations with no reverse dependencies
https://bugs.webkit.org/show_bug.cgi?id=221069
<rdar://problem/73686589>

Reviewed by Yusuke Suzuki.

JSTests:

  • stress/allocation-sinking-scope-materialization-order.js: Added.

(var3.var2.x):
(var3):

Source/JavaScriptCore:

Suppose we have two scope objects, A and B. Let's say A points to B, so B is
A's parent scope. A then depends on B. B has no dependencies here. When deciding
an order to materialize scope objects, we should always do it in reverse dependency
order. So above, we should materialize B, then A.

Inside object allocation sinking phase, when at an object materialization
site, we do track both dependencies and reverse dependencies. In the above
object graph, we'd attempt to materialize the objects in the right order,
always picking things with no dependencies first (and updating the list of
dependencies as we materialzed objects).

The code was using an std::list to track things to materialize, and it had
notions for materializing something first, and materializing something last.
However, there was a bug in how the code managed to insert things when
it first inserted last followed by inserting first. This patch simplifies
the code and makes it do the right thing.

  • dfg/DFGObjectAllocationSinkingPhase.cpp:
Location:
releases/WebKitGTK/webkit-2.32
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • releases/WebKitGTK/webkit-2.32/JSTests/ChangeLog

    r280235 r280895  
     12021-03-16  Saam Barati  <sbarati@apple.com>
     2
     3        Object allocation sinking phase should prioritize materializations with no dependencies before materializations with no reverse dependencies
     4        https://bugs.webkit.org/show_bug.cgi?id=221069
     5        <rdar://problem/73686589>
     6
     7        Reviewed by Yusuke Suzuki.
     8
     9        * stress/allocation-sinking-scope-materialization-order.js: Added.
     10        (var3.var2.x):
     11        (var3):
     12
    1132021-06-13  Saam Barati  <sbarati@apple.com>
    214
  • releases/WebKitGTK/webkit-2.32/Source/JavaScriptCore/ChangeLog

    r280805 r280895  
     12021-03-16  Saam Barati  <sbarati@apple.com>
     2
     3        Object allocation sinking phase should prioritize materializations with no dependencies before materializations with no reverse dependencies
     4        https://bugs.webkit.org/show_bug.cgi?id=221069
     5        <rdar://problem/73686589>
     6
     7        Reviewed by Yusuke Suzuki.
     8
     9        Suppose we have two scope objects, A and B. Let's say A points to B, so B is
     10        A's parent scope. A then depends on B. B has no dependencies here. When deciding
     11        an order to materialize scope objects, we should always do it in reverse dependency
     12        order. So above, we should materialize B, then A.
     13       
     14        Inside object allocation sinking phase, when at an object materialization
     15        site, we do track both dependencies and reverse dependencies. In the above
     16        object graph, we'd attempt to materialize the objects in the right order,
     17        always picking things with no dependencies first (and updating the list of
     18        dependencies as we materialzed objects).
     19       
     20        The code was using an std::list to track things to materialize, and it had
     21        notions for materializing something first, and materializing something last.
     22        However, there was a bug in how the code managed to insert things when
     23        it first inserted last followed by inserting first. This patch simplifies
     24        the code and makes it do the right thing.
     25
     26        * dfg/DFGObjectAllocationSinkingPhase.cpp:
     27
    1282021-08-09  Michael Catanzaro  <mcatanzaro@gnome.org>
    229
  • releases/WebKitGTK/webkit-2.32/Source/JavaScriptCore/dfg/DFGObjectAllocationSinkingPhase.cpp

    r272580 r280895  
    15801580        // materialized first - amongst the remaining unmaterialized
    15811581        // nodes
    1582         StdList<Allocation> toMaterialize;
    1583         auto firstPos = toMaterialize.begin();
     1582        Vector<Allocation> toMaterialize;
     1583        toMaterialize.resize(escapees.size());
     1584        size_t firstIndex = 0;
     1585        size_t lastIndex = toMaterialize.size();
    15841586        auto materializeFirst = [&] (Allocation&& allocation) {
     1587            RELEASE_ASSERT(firstIndex < lastIndex);
    15851588            materialize(allocation.identifier());
    1586             // We need to insert *after* the current position
    1587             if (firstPos != toMaterialize.end())
    1588                 ++firstPos;
    1589             firstPos = toMaterialize.insert(firstPos, WTFMove(allocation));
     1589            toMaterialize[firstIndex] = WTFMove(allocation);
     1590            ++firstIndex;
    15901591        };
    15911592
     
    15931594        // materialized last - amongst the remaining unmaterialized
    15941595        // nodes
    1595         auto lastPos = toMaterialize.end();
    15961596        auto materializeLast = [&] (Allocation&& allocation) {
    15971597            materialize(allocation.identifier());
    1598             lastPos = toMaterialize.insert(lastPos, WTFMove(allocation));
     1598            RELEASE_ASSERT(firstIndex < lastIndex);
     1599            RELEASE_ASSERT(lastIndex);
     1600            --lastIndex;
     1601            toMaterialize[lastIndex] = WTFMove(allocation);
    15991602        };
    16001603
     
    16541657                escapees.remove(identifier);
    16551658        }
     1659
     1660        RELEASE_ASSERT(firstIndex == lastIndex);
    16561661
    16571662        materialized.clear();
Note: See TracChangeset for help on using the changeset viewer.