about summary refs log tree commit diff
path: root/src/test/rustdoc-ui/coverage/json.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2020-03-13 22:43:06 +0000
committerbors <bors@rust-lang.org>2020-03-13 22:43:06 +0000
commitbe055d96c4c223a5ad49a0181f0b43bc46781708 (patch)
tree72cda37978123f3dff36d9c24f599837097df9db /src/test/rustdoc-ui/coverage/json.rs
parent1572c433eed495d0ade41511ae106b180e02851d (diff)
parent9f3679fe4485aa4be4a0de9abc8aca938c60db36 (diff)
downloadrust-be055d96c4c223a5ad49a0181f0b43bc46781708.tar.gz
rust-be055d96c4c223a5ad49a0181f0b43bc46781708.zip
Auto merge of #67502 - Mark-Simulacrum:opt-catch, r=Mark-Simulacrum
Optimize catch_unwind to match C++ try/catch

This refactors the implementation of catching unwinds to allow LLVM to inline the "try" closure directly into the happy path, avoiding indirection. This means that the catch_unwind implementation is (after this PR) zero-cost unless a panic is thrown.

https://rust.godbolt.org/z/cZcUSB is an example of the current codegen in a simple case. Notably, the codegen is *exactly the same* if `-Cpanic=abort` is passed, which is clearly not great.

This PR, on the other hand, generates the following assembly:

```asm
# -Cpanic=unwind:
	push   rbx
	mov    ebx,0x2a
	call   QWORD PTR [rip+0x1c53c]        # <happy>
	mov    eax,ebx
	pop    rbx
	ret
	mov    rdi,rax
	call   QWORD PTR [rip+0x1c537]        # cleanup function call
	call   QWORD PTR [rip+0x1c539]        # <unfortunate>
	mov    ebx,0xd
	mov    eax,ebx
	pop    rbx
	ret

# -Cpanic=abort:
	push   rax
	call   QWORD PTR [rip+0x20a1]        # <happy>
	mov    eax,0x2a
	pop    rcx
	ret
```

Fixes #64224, and resolves #64222.
Diffstat (limited to 'src/test/rustdoc-ui/coverage/json.rs')
0 files changed, 0 insertions, 0 deletions