1
1
use crate :: {
2
- asm:: MissingMethodPatcher , cilnode:: MethodKind , cilroot:: BranchCond , BasicBlock , BinOp ,
2
+ asm:: MissingMethodPatcher , cilnode:: { ExtendKind , MethodKind , PtrCastRes } , cilroot:: BranchCond , BasicBlock , BinOp ,
3
3
CILNode , CILRoot , ClassRef , Const , Int , MethodImpl , MethodRef , Type ,
4
4
} ;
5
5
@@ -18,7 +18,7 @@ pub fn emulate_uint8_cmp_xchng(asm: &mut Assembly, patcher: &mut MissingMethodPa
18
18
// 1st, mask the previous value
19
19
let prev_mask = asm. alloc_node ( Const :: I32 ( 0xFFFF_FF00_u32 as i32 ) ) ;
20
20
let prev = asm. alloc_node ( CILNode :: BinOp ( prev, prev_mask, BinOp :: And ) ) ;
21
-
21
+ let arg = asm . alloc_node ( CILNode :: IntCast { input : arg , target : Int :: I32 , extend : ExtendKind :: ZeroExtend } ) ;
22
22
asm. alloc_node ( CILNode :: BinOp ( prev, arg, BinOp :: Or ) )
23
23
} ) ,
24
24
Int :: I32 ,
@@ -31,7 +31,7 @@ pub fn emulate_uint8_cmp_xchng(asm: &mut Assembly, patcher: &mut MissingMethodPa
31
31
// 1st, mask the previous value
32
32
let prev_mask = asm. alloc_node ( Const :: I32 ( 0xFFFF_0000_u32 as i32 ) ) ;
33
33
let prev = asm. alloc_node ( CILNode :: BinOp ( prev, prev_mask, BinOp :: And ) ) ;
34
-
34
+ let arg = asm . alloc_node ( CILNode :: IntCast { input : arg , target : Int :: I32 , extend : ExtendKind :: ZeroExtend } ) ;
35
35
asm. alloc_node ( CILNode :: BinOp ( prev, arg, BinOp :: Or ) )
36
36
} ) ,
37
37
Int :: I32 ,
@@ -74,10 +74,10 @@ pub fn compare_exchange(
74
74
match int. size ( ) . unwrap_or ( 8 ) {
75
75
// u16 is buggy :(. TODO: fix it.
76
76
1 | 2 => {
77
- let compare_exchange = asm. alloc_string ( "atomic_cmpxchng8_i32" ) ;
77
+ let compare_exchange = asm. alloc_string ( format ! ( "atomic_cmpxchng{}_i32" , int . size ( ) . unwrap_or ( 8 ) * 8 ) ) ;
78
78
79
79
let i32 = Type :: Int ( int) ;
80
- let i32_ref = asm. nref ( i32 ) ;
80
+ let i32_ref = asm. nref ( Type :: Int ( Int :: I32 ) ) ;
81
81
let cmpxchng_sig = asm. sig ( [ i32_ref, i32, i32] , i32) ;
82
82
let main_mod = asm. main_module ( ) ;
83
83
let mref = asm. alloc_methodref ( MethodRef :: new (
@@ -89,12 +89,12 @@ pub fn compare_exchange(
89
89
) ) ;
90
90
let cast_value = asm. alloc_node ( CILNode :: IntCast {
91
91
input : value,
92
- target : Int :: I32 ,
92
+ target : int ,
93
93
extend : crate :: cilnode:: ExtendKind :: ZeroExtend ,
94
94
} ) ;
95
95
let cast_comparand = asm. alloc_node ( CILNode :: IntCast {
96
96
input : comaprand,
97
- target : Int :: I32 ,
97
+ target : int ,
98
98
extend : crate :: cilnode:: ExtendKind :: ZeroExtend ,
99
99
} ) ;
100
100
let addr = asm. alloc_node ( CILNode :: RefToPtr ( addr) ) ;
0 commit comments