Files
rust/library/std/src
Jubilee 1279830068 Rollup merge of #121438 - coolreader18:wasm32-panic-unwind, r=cuviper
std support for wasm32 panic=unwind

Tracking issue: #118168

This adds std support for `-Cpanic=unwind` on wasm, and with it slightly more fleshed out rustc support. Now, the stable default is still panic=abort without exception-handling, but if you `-Zbuild-std` with `RUSTFLAGS=-Cpanic=unwind`, you get wasm exception-handling try/catch blocks in the binary:

```rust
#[no_mangle]
pub fn foo_bar(x: bool) -> *mut u8 {
    let s = Box::<str>::from("hello");
    maybe_panic(x);
    Box::into_raw(s).cast()
}

#[inline(never)]
#[no_mangle]
fn maybe_panic(x: bool) {
    if x {
        panic!("AAAAA");
    }
}
```
```wat
;; snip...
(try $label$5
 (do
  (call $maybe_panic
   (local.get $0)
  )
  (br $label$1)
 )
 (catch_all
  (global.set $__stack_pointer
   (local.get $1)
  )
  (call $__rust_dealloc
   (local.get $2)
   (i32.const 5)
   (i32.const 1)
  )
  (rethrow $label$5)
 )
)
;; snip...
```
2024-03-11 09:29:34 -07:00
..
2023-12-10 10:56:22 +08:00
2023-12-10 10:56:22 +08:00
2023-08-13 13:07:53 -06:00
2024-02-27 19:27:09 -03:00
2023-12-22 11:01:42 +01:00
2024-03-06 18:01:09 +01:00
2024-01-11 11:30:12 -05:00
2023-12-10 10:56:22 +08:00
2023-05-03 22:09:33 -07:00
2024-02-29 14:28:47 -05:00
2023-11-26 09:25:07 +08:00
2023-12-12 18:12:23 +08:00
2024-01-27 16:38:57 +01:00
2024-02-28 14:56:36 -08:00
2023-12-15 16:17:28 +00:00
2024-03-07 07:49:22 +01:00