Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions JSTests/stress/array-sort-inline-int32-double-comparator.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
function shouldBe(actual, expected) {
if (actual !== expected)
throw new Error("bad value: " + actual + " expected: " + expected);
}

// Double arithmetic on the comparator's first parameter must not make the inlined sort store its pivot
// back into the Int32 array as a double.
function test(a, b, c, d) {
return [a, b, c, d].sort((x, y) => (x + 0.5) - (y + 0.5));
}
noInline(test);

for (var i = 0; i < testLoopCount; ++i)
shouldBe(test(17, 8, 1, 1).join(), "1,1,8,17");
10 changes: 10 additions & 0 deletions Source/JavaScriptCore/dfg/DFGPredictionPropagationPhase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -932,6 +932,16 @@ class PredictionPropagationPhase : public Phase {
break;
}

case PutCellButterflySlot: {
// The inlined sort reads the scratch of an Int32 array back with no check, and ArraySortCommit
// copies it into the array as is. A pivot in the double format would be stored as a boxed double.
m_graph.voteChildren(node, VoteValue, weight);
Node* value = node->child3().node();
if (value->op() == GetLocal)
value->variableAccessData()->mergeDoubleFormatState(CantUseDoubleFormat);
break;
}

case DataViewSet: {
DataViewData data = node->dataViewData();
if (data.isFloatingPoint)
Expand Down
Loading