Skip to content

Commit 9d7a8c9

Browse files
committed
Shared memory tests fixed.
1 parent 0ce39e4 commit 9d7a8c9

File tree

3 files changed

+557
-813
lines changed

3 files changed

+557
-813
lines changed

src/builtins.ts

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1808,6 +1808,8 @@ export function compileCall(
18081808
: ConversionKind.IMPLICIT,
18091809
WrapMode.NONE
18101810
);
1811+
1812+
let type: Type;
18111813
if (
18121814
typeArguments[0].is(TypeFlags.INTEGER) &&
18131815
(
@@ -1822,7 +1824,11 @@ export function compileCall(
18221824
WrapMode.NONE, // still clears garbage bits
18231825
operands[1]
18241826
);
1827+
type = typeArguments[0];
1828+
} else {
1829+
type = compiler.currentType;
18251830
}
1831+
18261832
let offset = operands.length == 3 ? evaluateConstantOffset(compiler, operands[2]) : 0; // reports
18271833
if (offset < 0) { // reported in evaluateConstantOffset
18281834
return module.createUnreachable();
@@ -1839,11 +1845,8 @@ export function compileCall(
18391845
compiler.currentType = typeArguments[0];
18401846
if (RMWOp !== null) {
18411847
return module.createAtomicRMW(
1842-
RMWOp, typeArguments[0].byteSize, offset, arg0, arg1,
1843-
contextualType.size > typeArguments[0].size
1844-
? (compiler.currentType = contextualType).toNativeType()
1845-
: (compiler.currentType = typeArguments[0]).toNativeType(),
1846-
);
1848+
RMWOp, typeArguments[0].byteSize, offset, arg0, arg1, type.toNativeType()
1849+
);
18471850
} else {
18481851
compiler.error(
18491852
DiagnosticCode.Operation_not_supported,
@@ -1902,6 +1905,8 @@ export function compileCall(
19021905
: ConversionKind.IMPLICIT,
19031906
WrapMode.NONE
19041907
);
1908+
1909+
let type: Type;
19051910
if (
19061911
typeArguments[0].is(TypeFlags.INTEGER) &&
19071912
(
@@ -1923,17 +1928,18 @@ export function compileCall(
19231928
WrapMode.NONE, // still clears garbage bits
19241929
operands[2]
19251930
);
1931+
type = typeArguments[0];
1932+
} else {
1933+
type = compiler.currentType;
19261934
}
1935+
19271936
let offset = operands.length == 4 ? evaluateConstantOffset(compiler, operands[3]) : 0; // reports
19281937
if (offset < 0) { // reported in evaluateConstantOffset
19291938
return module.createUnreachable();
19301939
}
19311940
compiler.currentType = typeArguments[0];
19321941
return module.createAtomicCmpxchg(
1933-
typeArguments[0].byteSize, offset, arg0, arg1, arg2,
1934-
contextualType.size > typeArguments[0].size
1935-
? (compiler.currentType = contextualType).toNativeType()
1936-
: (compiler.currentType = typeArguments[0]).toNativeType(),
1942+
typeArguments[0].byteSize, offset, arg0, arg1, arg2, type.toNativeType()
19371943
);
19381944
}
19391945
case "sizeof": { // sizeof<T!>() -> usize

0 commit comments

Comments
 (0)