|
55 | 55 | (else |
56 | 56 | (ref.i31 (i32.const 0))))) |
57 | 57 |
|
| 58 | + (func (export "caml_atomic_compare_exchange") |
| 59 | + (param $ref (ref eq)) (param $o (ref eq)) (param $n (ref eq)) |
| 60 | + (result (ref eq)) |
| 61 | + (local $b (ref $block)) |
| 62 | + (local $old (ref eq)) |
| 63 | + (local.set $b (ref.cast (ref $block) (local.get $ref))) |
| 64 | + (local.set $old (array.get $block (local.get $b) (i32.const 1))) |
| 65 | + (if (result (ref eq)) |
| 66 | + (ref.eq (local.get $old) (local.get $o)) |
| 67 | + (then |
| 68 | + (array.set $block (local.get $b) (i32.const 1) (local.get $n)) |
| 69 | + (local.get $old)) |
| 70 | + (else |
| 71 | + (local.get $old)))) |
| 72 | + |
58 | 73 | (func (export "caml_atomic_load") (param (ref eq)) (result (ref eq)) |
59 | 74 | (array.get $block (ref.cast (ref $block) (local.get 0)) (i32.const 1))) |
60 | 75 |
|
|
89 | 104 | (i31.get_s (ref.cast (ref i31) (local.get $n)))))) |
90 | 105 | (local.get $old)) |
91 | 106 |
|
| 107 | + (func (export "caml_atomic_add") |
| 108 | + (param $ref (ref eq)) (param $i (ref eq)) (result (ref eq)) |
| 109 | + (local $b (ref $block)) |
| 110 | + (local $old (ref eq)) |
| 111 | + (local.set $b (ref.cast (ref $block) (local.get $ref))) |
| 112 | + (local.set $old (array.get $block (local.get $b) (i32.const 1))) |
| 113 | + (array.set $block (local.get $b) (i32.const 1) |
| 114 | + (ref.i31 (i32.add (i31.get_s (ref.cast (ref i31) (local.get $old))) |
| 115 | + (i31.get_s (ref.cast (ref i31) (local.get $i)))))) |
| 116 | + (ref.i31 (i32.const 0))) |
| 117 | + |
| 118 | + (func (export "caml_atomic_sub") |
| 119 | + (param $ref (ref eq)) (param $i (ref eq)) (result (ref eq)) |
| 120 | + (local $b (ref $block)) |
| 121 | + (local $old (ref eq)) |
| 122 | + (local.set $b (ref.cast (ref $block) (local.get $ref))) |
| 123 | + (local.set $old (array.get $block (local.get $b) (i32.const 1))) |
| 124 | + (array.set $block (local.get $b) (i32.const 1) |
| 125 | + (ref.i31 (i32.sub (i31.get_s (ref.cast (ref i31) (local.get $old))) |
| 126 | + (i31.get_s (ref.cast (ref i31) (local.get $i)))))) |
| 127 | + (ref.i31 (i32.const 0))) |
| 128 | + |
| 129 | + (func (export "caml_atomic_land") |
| 130 | + (param $ref (ref eq)) (param $i (ref eq)) (result (ref eq)) |
| 131 | + (local $b (ref $block)) |
| 132 | + (local $old (ref eq)) |
| 133 | + (local.set $b (ref.cast (ref $block) (local.get $ref))) |
| 134 | + (local.set $old (array.get $block (local.get $b) (i32.const 1))) |
| 135 | + (array.set $block (local.get $b) (i32.const 1) |
| 136 | + (ref.i31 (i32.and (i31.get_s (ref.cast (ref i31) (local.get $old))) |
| 137 | + (i31.get_s (ref.cast (ref i31) (local.get $i)))))) |
| 138 | + (ref.i31 (i32.const 0))) |
| 139 | + |
| 140 | + (func (export "caml_atomic_lor") |
| 141 | + (param $ref (ref eq)) (param $i (ref eq)) (result (ref eq)) |
| 142 | + (local $b (ref $block)) |
| 143 | + (local $old (ref eq)) |
| 144 | + (local.set $b (ref.cast (ref $block) (local.get $ref))) |
| 145 | + (local.set $old (array.get $block (local.get $b) (i32.const 1))) |
| 146 | + (array.set $block (local.get $b) (i32.const 1) |
| 147 | + (ref.i31 (i32.or (i31.get_s (ref.cast (ref i31) (local.get $old))) |
| 148 | + (i31.get_s (ref.cast (ref i31) (local.get $i)))))) |
| 149 | + (ref.i31 (i32.const 0))) |
| 150 | + |
| 151 | + (func (export "caml_atomic_lxor") |
| 152 | + (param $ref (ref eq)) (param $i (ref eq)) (result (ref eq)) |
| 153 | + (local $b (ref $block)) |
| 154 | + (local $old (ref eq)) |
| 155 | + (local.set $b (ref.cast (ref $block) (local.get $ref))) |
| 156 | + (local.set $old (array.get $block (local.get $b) (i32.const 1))) |
| 157 | + (array.set $block (local.get $b) (i32.const 1) |
| 158 | + (ref.i31 (i32.xor (i31.get_s (ref.cast (ref i31) (local.get $old))) |
| 159 | + (i31.get_s (ref.cast (ref i31) (local.get $i)))))) |
| 160 | + (ref.i31 (i32.const 0))) |
| 161 | + |
92 | 162 | (func (export "caml_atomic_exchange") |
93 | 163 | (param $ref (ref eq)) (param $v (ref eq)) (result (ref eq)) |
94 | 164 | (local $b (ref $block)) |
|
111 | 181 | (array.set $block (local.get $b) (local.get $j) (local.get $v)) |
112 | 182 | (local.get $r)) |
113 | 183 |
|
| 184 | + (func (export "caml_atomic_set") |
| 185 | + (param $ref (ref eq)) (param $v (ref eq)) (result (ref eq)) |
| 186 | + (local $b (ref $block)) |
| 187 | + (local $r (ref eq)) |
| 188 | + (local.set $b (ref.cast (ref $block) (local.get $ref))) |
| 189 | + (local.set $r (array.get $block (local.get $b) (i32.const 1))) |
| 190 | + (array.set $block (local.get $b) (i32.const 1) (local.get $v)) |
| 191 | + (ref.i31 (i32.const 0))) |
| 192 | + |
114 | 193 | (func (export "caml_atomic_make_contended") |
115 | 194 | (param $v (ref eq)) (result (ref eq)) |
116 | 195 | (array.new_fixed $block 2 (ref.i31 (i32.const 0)) (local.get $v))) |
|
200 | 279 |
|
201 | 280 | (func (export "caml_ml_domain_cpu_relax") (param (ref eq)) (result (ref eq)) |
202 | 281 | (ref.i31 (i32.const 0))) |
| 282 | + |
| 283 | + (func (export "caml_atomic_add_field") |
| 284 | + (param $ref (ref eq)) (param $field (ref eq)) (param $i (ref eq)) |
| 285 | + (result (ref eq)) |
| 286 | + (local $b (ref $block)) |
| 287 | + (local $idx i32) |
| 288 | + (local $old (ref eq)) |
| 289 | + (local.set $b (ref.cast (ref $block) (local.get $ref))) |
| 290 | + (local.set $idx |
| 291 | + (i32.add (i31.get_s (ref.cast (ref i31) (local.get $field))) |
| 292 | + (i32.const 1))) |
| 293 | + (local.set $old (array.get $block (local.get $b) (local.get $idx))) |
| 294 | + (array.set $block (local.get $b) (local.get $idx) |
| 295 | + (ref.i31 (i32.add (i31.get_s (ref.cast (ref i31) (local.get $old))) |
| 296 | + (i31.get_s (ref.cast (ref i31) (local.get $i)))))) |
| 297 | + (ref.i31 (i32.const 0))) |
| 298 | + |
| 299 | + (func (export "caml_atomic_sub_field") |
| 300 | + (param $ref (ref eq)) (param $field (ref eq)) (param $i (ref eq)) |
| 301 | + (result (ref eq)) |
| 302 | + (local $b (ref $block)) |
| 303 | + (local $idx i32) |
| 304 | + (local $old (ref eq)) |
| 305 | + (local.set $b (ref.cast (ref $block) (local.get $ref))) |
| 306 | + (local.set $idx |
| 307 | + (i32.add (i31.get_s (ref.cast (ref i31) (local.get $field))) |
| 308 | + (i32.const 1))) |
| 309 | + (local.set $old (array.get $block (local.get $b) (local.get $idx))) |
| 310 | + (array.set $block (local.get $b) (local.get $idx) |
| 311 | + (ref.i31 (i32.sub (i31.get_s (ref.cast (ref i31) (local.get $old))) |
| 312 | + (i31.get_s (ref.cast (ref i31) (local.get $i)))))) |
| 313 | + (ref.i31 (i32.const 0))) |
| 314 | + |
| 315 | + (func (export "caml_atomic_land_field") |
| 316 | + (param $ref (ref eq)) (param $field (ref eq)) (param $i (ref eq)) |
| 317 | + (result (ref eq)) |
| 318 | + (local $b (ref $block)) |
| 319 | + (local $idx i32) |
| 320 | + (local $old (ref eq)) |
| 321 | + (local.set $b (ref.cast (ref $block) (local.get $ref))) |
| 322 | + (local.set $idx |
| 323 | + (i32.add (i31.get_s (ref.cast (ref i31) (local.get $field))) |
| 324 | + (i32.const 1))) |
| 325 | + (local.set $old (array.get $block (local.get $b) (local.get $idx))) |
| 326 | + (array.set $block (local.get $b) (local.get $idx) |
| 327 | + (ref.i31 (i32.and (i31.get_s (ref.cast (ref i31) (local.get $old))) |
| 328 | + (i31.get_s (ref.cast (ref i31) (local.get $i)))))) |
| 329 | + (ref.i31 (i32.const 0))) |
| 330 | + |
| 331 | + (func (export "caml_atomic_lor_field") |
| 332 | + (param $ref (ref eq)) (param $field (ref eq)) (param $i (ref eq)) |
| 333 | + (result (ref eq)) |
| 334 | + (local $b (ref $block)) |
| 335 | + (local $idx i32) |
| 336 | + (local $old (ref eq)) |
| 337 | + (local.set $b (ref.cast (ref $block) (local.get $ref))) |
| 338 | + (local.set $idx |
| 339 | + (i32.add (i31.get_s (ref.cast (ref i31) (local.get $field))) |
| 340 | + (i32.const 1))) |
| 341 | + (local.set $old (array.get $block (local.get $b) (local.get $idx))) |
| 342 | + (array.set $block (local.get $b) (local.get $idx) |
| 343 | + (ref.i31 (i32.or (i31.get_s (ref.cast (ref i31) (local.get $old))) |
| 344 | + (i31.get_s (ref.cast (ref i31) (local.get $i)))))) |
| 345 | + (ref.i31 (i32.const 0))) |
| 346 | + |
| 347 | + (func (export "caml_atomic_lxor_field") |
| 348 | + (param $ref (ref eq)) (param $field (ref eq)) (param $i (ref eq)) |
| 349 | + (result (ref eq)) |
| 350 | + (local $b (ref $block)) |
| 351 | + (local $idx i32) |
| 352 | + (local $old (ref eq)) |
| 353 | + (local.set $b (ref.cast (ref $block) (local.get $ref))) |
| 354 | + (local.set $idx |
| 355 | + (i32.add (i31.get_s (ref.cast (ref i31) (local.get $field))) |
| 356 | + (i32.const 1))) |
| 357 | + (local.set $old (array.get $block (local.get $b) (local.get $idx))) |
| 358 | + (array.set $block (local.get $b) (local.get $idx) |
| 359 | + (ref.i31 (i32.xor (i31.get_s (ref.cast (ref i31) (local.get $old))) |
| 360 | + (i31.get_s (ref.cast (ref i31) (local.get $i)))))) |
| 361 | + (ref.i31 (i32.const 0))) |
| 362 | + |
| 363 | + (func (export "caml_atomic_compare_exchange_field") |
| 364 | + (param $ref (ref eq)) (param $field (ref eq)) (param $o (ref eq)) |
| 365 | + (param $n (ref eq)) (result (ref eq)) |
| 366 | + (local $b (ref $block)) |
| 367 | + (local $idx i32) |
| 368 | + (local $old (ref eq)) |
| 369 | + (local.set $b (ref.cast (ref $block) (local.get $ref))) |
| 370 | + (local.set $idx |
| 371 | + (i32.add (i31.get_s (ref.cast (ref i31) (local.get $field))) |
| 372 | + (i32.const 1))) |
| 373 | + (local.set $old (array.get $block (local.get $b) (local.get $idx))) |
| 374 | + (if (ref.eq (local.get $old) (local.get $o)) |
| 375 | + (then |
| 376 | + (array.set $block (local.get $b) (local.get $idx) (local.get $n)))) |
| 377 | + (local.get $old)) |
| 378 | + |
| 379 | + (func (export "caml_atomic_set_field") |
| 380 | + (param $ref (ref eq)) (param $field (ref eq)) (param $v (ref eq)) |
| 381 | + (result (ref eq)) |
| 382 | + (local $b (ref $block)) |
| 383 | + (local $idx i32) |
| 384 | + (local.set $b (ref.cast (ref $block) (local.get $ref))) |
| 385 | + (local.set $idx |
| 386 | + (i32.add (i31.get_s (ref.cast (ref i31) (local.get $field))) |
| 387 | + (i32.const 1))) |
| 388 | + (array.set $block (local.get $b) (local.get $idx) (local.get $v)) |
| 389 | + (ref.i31 (i32.const 0))) |
203 | 390 | ) |
0 commit comments