Skip to content

Instantly share code, notes, and snippets.

@rprichard
Last active August 29, 2015 14:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rprichard/f0528270cd2f65ded875 to your computer and use it in GitHub Desktop.
Save rprichard/f0528270cd2f65ded875 to your computer and use it in GitHub Desktop.
Current libcore/libstd single-argument panic call overhead
libcore panic!("message")
-------------------------
12 bytes:
48 8d 3d 53 dc 3a 00 lea 0x3adc53(%rip),%rdi #_MSG_FILE_LINE
e8 ce d7 ff ff callq ba540 # core::panicking::panic
40 bytes excluding string bytes:
_MSG_FILE_LINE:
.quad str1034
.quad 7
.quad str1035
.quad 7
.long 6
.zero 4
.size _MSG_FILE_LINE, 40
str1034:
.ascii "message"
.size str1034, 7
str1035:
.ascii "test.rs"
.size str1035, 7
libstd panic!("message")
------------------------
27 bytes:
0f 10 05 d0 da 3a 00 movups 0x3adad0(%rip),%xmm0 # const12
0f 29 04 24 movaps %xmm0,(%rsp)
48 8d 35 d5 da 3a 00 lea 0x3adad5(%rip),%rsi # _FILE_LINE
48 8d 3c 24 lea (%rsp),%rdi
e8 0c 00 00 00 callq bceb0 # rt::unwind::begin_unwind
40 bytes excluding string bytes:
const12:
.quad str1105
.quad 7
.size const12, 16
_FILE_LINE:
.quad str1106
.quad 7
.quad 6
.size _FILE_LINE, 24
str1105:
.ascii "message"
.size str1105, 7
str1106:
.ascii "test.rs"
.size str1106, 7
libcore panic!("message",)
--------------------------
[The trailing comma forces the unoptimized panic_fmt code path. It should
presumably be rejected instead, as it is with libstd panic!.]
54 bytes on x86_64:
0f 10 05 00 db 3a 00 movups 0x3adb00(%rip),%xmm0 # _STATIC_FMTSTR
0f 29 04 24 movaps %xmm0,(%rsp)
0f 57 c0 xorps %xmm0,%xmm0
0f 29 44 24 10 movaps %xmm0,0x10(%rsp)
48 8d 44 24 30 lea 0x30(%rsp),%rax
48 89 44 24 20 mov %rax,0x20(%rsp)
48 c7 44 24 28 00 00 movq $0x0,0x28(%rsp)
00 00
48 8d 35 ea da 3a 00 lea 0x3adaea(%rip),%rsi # _FILE_LINE
48 8d 3c 24 lea (%rsp),%rdi
e8 e1 c0 ff ff callq b8f80 # core::panicking::panic_fmt
56 bytes excluding string bytes:
_STATIC_FMTSTR:
.quad ref35
.quad 1
.size _STATIC_FMTSTR, 16
ref35:
.quad str1133
.quad 7
.size ref35, 16
_FILE_LINE:
.quad str1134
.quad 7
.long 6
.zero 4
.size _FILE_LINE, 24
str1133:
.ascii "message"
.size str1133, 7
str1134:
.ascii "test.rs"
.size str1134, 7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment