Skip to content

Commit b7a386c

Browse files
fix: Big-endian support does not work with optimizations (#25797)
While migrating to 4.0.19 I discovered that enabling optimizations removes `ParenthesizedExpression` node from AST causing the `littleEndianHeap` to not perform the transform correctly.
1 parent e1a0f02 commit b7a386c

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/lib/liblittle_endian_heap.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,11 @@ function LE_HEAP_UPDATE() {
109109
const res = order(Atomics.sub(heap, offset, order(value)));
110110
return heap.unsigned ? heap.unsigned(res) : res;
111111
},
112-
$LE_ATOMICS_WAIT: (heap, offset, value, timeout) => {
112+
$LE_ATOMICS_WAIT: (heap, offset, value, timeout = Infinity) => {
113113
const order = LE_ATOMICS_NATIVE_BYTE_ORDER[heap.BYTES_PER_ELEMENT - 1];
114114
return Atomics.wait(heap, offset, order(value), timeout);
115115
},
116-
$LE_ATOMICS_WAITASYNC: (heap, offset, value, timeout) => {
116+
$LE_ATOMICS_WAITASYNC: (heap, offset, value, timeout = Infinity) => {
117117
const order = LE_ATOMICS_NATIVE_BYTE_ORDER[heap.BYTES_PER_ELEMENT - 1];
118118
return Atomics.waitAsync(heap, offset, order(value), timeout);
119119
},

tools/acorn-optimizer.mjs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1219,9 +1219,10 @@ function isGrowHEAPAccess(node) {
12191219
if (
12201220
node.type !== 'MemberExpression' ||
12211221
!node.computed || // notice a[X] but not a.X
1222-
node.object.type !== 'ParenthesizedExpression')
1222+
(node.object.type !== 'ParenthesizedExpression' && node.object.type !== 'SequenceExpression')
1223+
)
12231224
return false;
1224-
const obj = node.object.expression;
1225+
const obj = node.object.type === 'ParenthesizedExpression' ? node.object.expression : node.object;
12251226
return (
12261227
obj.type === 'SequenceExpression' &&
12271228
obj.expressions.length === 2 &&

0 commit comments

Comments
 (0)