@@ -1808,6 +1808,8 @@ export function compileCall(
1808
1808
: ConversionKind . IMPLICIT ,
1809
1809
WrapMode . NONE
1810
1810
) ;
1811
+
1812
+ let type : Type ;
1811
1813
if (
1812
1814
typeArguments [ 0 ] . is ( TypeFlags . INTEGER ) &&
1813
1815
(
@@ -1822,7 +1824,11 @@ export function compileCall(
1822
1824
WrapMode . NONE , // still clears garbage bits
1823
1825
operands [ 1 ]
1824
1826
) ;
1827
+ type = typeArguments [ 0 ] ;
1828
+ } else {
1829
+ type = compiler . currentType ;
1825
1830
}
1831
+
1826
1832
let offset = operands . length == 3 ? evaluateConstantOffset ( compiler , operands [ 2 ] ) : 0 ; // reports
1827
1833
if ( offset < 0 ) { // reported in evaluateConstantOffset
1828
1834
return module . createUnreachable ( ) ;
@@ -1839,11 +1845,8 @@ export function compileCall(
1839
1845
compiler . currentType = typeArguments [ 0 ] ;
1840
1846
if ( RMWOp !== null ) {
1841
1847
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
+ ) ;
1847
1850
} else {
1848
1851
compiler . error (
1849
1852
DiagnosticCode . Operation_not_supported ,
@@ -1902,6 +1905,8 @@ export function compileCall(
1902
1905
: ConversionKind . IMPLICIT ,
1903
1906
WrapMode . NONE
1904
1907
) ;
1908
+
1909
+ let type : Type ;
1905
1910
if (
1906
1911
typeArguments [ 0 ] . is ( TypeFlags . INTEGER ) &&
1907
1912
(
@@ -1923,17 +1928,18 @@ export function compileCall(
1923
1928
WrapMode . NONE , // still clears garbage bits
1924
1929
operands [ 2 ]
1925
1930
) ;
1931
+ type = typeArguments [ 0 ] ;
1932
+ } else {
1933
+ type = compiler . currentType ;
1926
1934
}
1935
+
1927
1936
let offset = operands . length == 4 ? evaluateConstantOffset ( compiler , operands [ 3 ] ) : 0 ; // reports
1928
1937
if ( offset < 0 ) { // reported in evaluateConstantOffset
1929
1938
return module . createUnreachable ( ) ;
1930
1939
}
1931
1940
compiler . currentType = typeArguments [ 0 ] ;
1932
1941
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 ( )
1937
1943
) ;
1938
1944
}
1939
1945
case "sizeof" : { // sizeof<T!>() -> usize
0 commit comments