Created
June 4, 2018 06:07
-
-
Save sugar700/d970facb89c5e76add50698da44d8ec8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| struct X { | |
| int x[100]; | |
| }; | |
| X hi() { | |
| return {0}; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| hi(): | |
| mov rdx, rdi | |
| mov QWORD PTR [rdi], 0 | |
| lea rdi, [rdi+8] | |
| xor eax, eax | |
| mov QWORD PTR [rdi+384], 0 | |
| mov rcx, rdx | |
| and rdi, -8 | |
| sub rcx, rdi | |
| add ecx, 400 | |
| shr ecx, 3 | |
| rep stosq | |
| mov rax, rdx | |
| ret |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| pub fn hi() -> [i32; 100] { | |
| [0; 100] | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| example::hi: | |
| push rbx | |
| mov rbx, rdi | |
| xor esi, esi | |
| mov edx, 400 | |
| call memset@PLT | |
| mov rax, rbx | |
| pop rbx | |
| ret |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
C++ strictly follows the calling convention when returning huge objects
not the case for Rust
where the function is transformed into something like
void hi(int *p);