]> git.lizzy.rs Git - rust.git/commit
Use fewer instructions for `fail!`
authorBrian Anderson <banderson@mozilla.com>
Mon, 21 Jul 2014 20:48:19 +0000 (13:48 -0700)
committerBrian Anderson <banderson@mozilla.com>
Mon, 21 Jul 2014 20:50:12 +0000 (13:50 -0700)
commitc61f9763e2e03afbe62445877ceb3ed15e22e123
tree9cdcb715f5e00ca9b82d34ba1db9984b565d7819
parentf15d6d28396e8700b6c3f2704204a2769e710403
Use fewer instructions for `fail!`

Adds a special-case fail function, rustrt::unwind::begin_unwind_no_time_to_explain,
that encapsulates the printing of the words "explicit failure".

The before/after optimized assembly:

```
        leaq    "str\"str\"(1369)"(%rip), %rax
        movq    %rax, 8(%rsp)
        movq    $19, 16(%rsp)
        leaq    8(%rsp), %rdi
        movl    $11, %esi
        callq   _ZN6unwind31begin_unwind_no_time_to_explain20hd1c720cdde6a116480dE@PLT
```

```
        leaq    "str\"str\"(1412)"(%rip), %rax
        movq    %rax, 24(%rsp)
        movq    $16, 32(%rsp)
        leaq    "str\"str\"(1413)"(%rip), %rax
        movq    %rax, 8(%rsp)
        movq    $19, 16(%rsp)
        leaq    24(%rsp), %rdi
        leaq    8(%rsp), %rsi
        movl    $11, %edx
        callq   _ZN6unwind12begin_unwind21h15836560661922107792E
```

Before/after filesizes:

rwxrwxr-x 1 brian brian 21479503 Jul 20 22:09 stage2-old/lib/librustc-4e7c5e5c.so
rwxrwxr-x 1 brian brian 21475415 Jul 20 22:30 x86_64-unknown-linux-gnu/stage2/lib/librustc-4e7c5e5c.so
src/librustrt/lib.rs
src/librustrt/unwind.rs
src/libstd/macros.rs
src/libstd/rt/mod.rs