Skip to content

Commit

Permalink
Cherry-pick 263909@main (52fe95e). https://bugs.webkit.org/show_bug.c…
Browse files Browse the repository at this point in the history
…gi?id=256567

    EnumeratorNextUpdateIndexAndMode and HasIndexedProperty should have different heap location kinds
    https://bugs.webkit.org/show_bug.cgi?id=256567
    rdar://109089013

    Reviewed by Yusuke Suzuki.

    EnumeratorNextUpdateIndexAndMode and HasIndexedProperty are different DFG nodes. However,
    they might introduce the same heap location kind in DFGClobberize.h which might lead to
    hash collision. We should introduce a new locationn kind for EnumeratorNextUpdateIndexAndMode.

    * JSTests/stress/heap-location-collision-dfg-clobberize.js: Added.
    (foo):
    * Source/JavaScriptCore/dfg/DFGClobberize.h:
    (JSC::DFG::clobberize):
    * Source/JavaScriptCore/dfg/DFGHeapLocation.cpp:
    (WTF::printInternal):
    * Source/JavaScriptCore/dfg/DFGHeapLocation.h:

    Canonical link: https://commits.webkit.org/263909@main

Canonical link: https://commits.webkit.org/260527.376@webkitglib/2.40
  • Loading branch information
hyjorc1 authored and mcatanzaro committed Jun 22, 2023
1 parent a941dd0 commit ebefb9e
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 3 deletions.
12 changes: 12 additions & 0 deletions JSTests/stress/heap-location-collision-dfg-clobberize.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//@ runDefault("--watchdog=300", "--watchdog-exception-ok")
const arr = [0];

function foo() {
for (let _ in arr) {
0 in arr;
while(1);
}
}


foo();
7 changes: 4 additions & 3 deletions Source/JavaScriptCore/dfg/DFGClobberize.h
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,7 @@ void clobberize(Graph& graph, Node* node, const ReadFunctor& read, const WriteFu

read(JSObject_butterfly);
ArrayMode mode = node->arrayMode();
LocationKind locationKind = node->op() == EnumeratorNextUpdateIndexAndMode ? EnumeratorNextUpdateIndexAndModeLoc : HasIndexedPropertyLoc;
switch (mode.type()) {
case Array::ForceExit: {
write(SideState);
Expand All @@ -392,7 +393,7 @@ void clobberize(Graph& graph, Node* node, const ReadFunctor& read, const WriteFu
if (mode.isInBounds()) {
read(Butterfly_publicLength);
read(IndexedInt32Properties);
def(HeapLocation(HasIndexedPropertyLoc, IndexedInt32Properties, graph.varArgChild(node, 0), graph.varArgChild(node, 1)), LazyNode(node));
def(HeapLocation(locationKind, IndexedInt32Properties, graph.varArgChild(node, 0), graph.varArgChild(node, 1)), LazyNode(node));
return;
}
break;
Expand All @@ -402,7 +403,7 @@ void clobberize(Graph& graph, Node* node, const ReadFunctor& read, const WriteFu
if (mode.isInBounds()) {
read(Butterfly_publicLength);
read(IndexedDoubleProperties);
def(HeapLocation(HasIndexedPropertyLoc, IndexedDoubleProperties, graph.varArgChild(node, 0), graph.varArgChild(node, 1)), LazyNode(node));
def(HeapLocation(locationKind, IndexedDoubleProperties, graph.varArgChild(node, 0), graph.varArgChild(node, 1)), LazyNode(node));
return;
}
break;
Expand All @@ -412,7 +413,7 @@ void clobberize(Graph& graph, Node* node, const ReadFunctor& read, const WriteFu
if (mode.isInBounds()) {
read(Butterfly_publicLength);
read(IndexedContiguousProperties);
def(HeapLocation(HasIndexedPropertyLoc, IndexedContiguousProperties, graph.varArgChild(node, 0), graph.varArgChild(node, 1)), LazyNode(node));
def(HeapLocation(locationKind, IndexedContiguousProperties, graph.varArgChild(node, 0), graph.varArgChild(node, 1)), LazyNode(node));
return;
}
break;
Expand Down
4 changes: 4 additions & 0 deletions Source/JavaScriptCore/dfg/DFGHeapLocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,10 @@ void printInternal(PrintStream& out, LocationKind kind)
out.print("HasIndexedPorpertyLoc");
return;

case EnumeratorNextUpdateIndexAndModeLoc:
out.print("EnumeratorNextUpdateIndexAndModeLoc");
return;

case IndexedPropertyDoubleLoc:
out.print("IndexedPropertyDoubleLoc");
return;
Expand Down
1 change: 1 addition & 0 deletions Source/JavaScriptCore/dfg/DFGHeapLocation.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ enum LocationKind {
DirectArgumentsLoc,
GetterLoc,
GlobalVariableLoc,
EnumeratorNextUpdateIndexAndModeLoc,
HasIndexedPropertyLoc,
IndexedPropertyDoubleLoc,
IndexedPropertyDoubleSaneChainLoc,
Expand Down

0 comments on commit ebefb9e

Please sign in to comment.