From e5f5f7379215b9f6cad127d50983dd73b602580d Mon Sep 17 00:00:00 2001 From: Wink Saville Date: Fri, 2 Dec 2022 13:09:17 -0800 Subject: [PATCH] feat: Add MessageMf MessageMf has "Many fields" making it able to see how borrowed and owned scale differently. Added benchmarking creating default instances of Message and MessageMf. Removed the xxx_loop() variants as they don't add information just more noise. I would like to look at why xxx_idx_loop() is sometimes slower than xxx_iter_loop(). NOTE: I believe some of the noise is caused by code alignment changes as we tweak that where doing and change code. See: https://www.google.com/search?q=benchmark+sensitive+to+code+alignment and https://github.com/rust-lang/rust/issues/82232 --- Cargo.lock | 2 +- Cargo.toml | 2 +- README.md | 368 +++++++--------------- asm/invoke_message_borrowed.txt | 130 ++++---- asm/invoke_message_borrowed_idx_loop.txt | 111 ------- asm/invoke_message_borrowed_iter_loop.txt | 110 ------- asm/invoke_message_default.txt | 51 +++ asm/invoke_message_owned.txt | 113 +++---- asm/invoke_message_owned_idx_loop.txt | 145 --------- asm/invoke_message_owned_iter_loop.txt | 145 --------- asm/invoke_messagemf_borrowed.txt | 121 +++++++ asm/invoke_messagemf_default.txt | 51 +++ asm/invoke_messagemf_owned.txt | 152 +++++++++ asm/message_borrowed.txt | 12 +- asm/message_borrowed_idx_loop.txt | 141 --------- asm/message_borrowed_iter_loop.txt | 123 -------- asm/message_owned.txt | 8 +- asm/message_owned_idx_loop.txt | 147 --------- asm/message_owned_iter_loop.txt | 140 -------- asm/messagemf_borrowed.txt | 38 +++ asm/messagemf_owned.txt | 75 +++++ benches/bench.rs | 12 +- gen_asm.sh | 14 +- src/lib.rs | 122 +++---- src/main.rs | 12 +- 25 files changed, 816 insertions(+), 1529 deletions(-) delete mode 100644 asm/invoke_message_borrowed_idx_loop.txt delete mode 100644 asm/invoke_message_borrowed_iter_loop.txt create mode 100644 asm/invoke_message_default.txt delete mode 100644 asm/invoke_message_owned_idx_loop.txt delete mode 100644 asm/invoke_message_owned_iter_loop.txt create mode 100644 asm/invoke_messagemf_borrowed.txt create mode 100644 asm/invoke_messagemf_default.txt create mode 100644 asm/invoke_messagemf_owned.txt delete mode 100644 asm/message_borrowed_idx_loop.txt delete mode 100644 asm/message_borrowed_iter_loop.txt delete mode 100644 asm/message_owned_idx_loop.txt delete mode 100644 asm/message_owned_iter_loop.txt create mode 100644 asm/messagemf_borrowed.txt create mode 100644 asm/messagemf_owned.txt diff --git a/Cargo.lock b/Cargo.lock index 88a8b92..54d7f95 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -10,7 +10,7 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "exper-borrowed-vs-owned-parameters" -version = "0.2.0" +version = "0.3.0" dependencies = [ "iai", "rand", diff --git a/Cargo.toml b/Cargo.toml index dcc2ed9..a7b26ac 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ name = "exper-borrowed-vs-owned-parameters" authors = [ "Wink Saville , - 7 } - 8 - 9 #[inline(never)] - 10 fn message_borrowed(msg: &Message) -> u32 { - 11 msg.v[0] as u32 - 12 } - 13 - 14 #[inline(never)] - 15 fn message_borrowed_idx_loop(msg: &Message) -> u32 { - 16 let mut sum = 0u32; - 17 for i in 0..msg.v.len() { - 18 sum += msg.v[i] as u32 - 19 } - 20 sum - 21 } - 22 - 23 #[inline(never)] - 24 fn message_borrowed_iter_loop(msg: &Message) -> u32 { - 25 let mut sum = 0u32; - 26 for v in msg.v.iter() { - 27 sum += *v as u32 - 28 } - 29 sum - 30 } - 31 - 32 #[inline(never)] - 33 fn message_owned(msg: Message) -> (u32, Message) { - 34 (msg.v[0] as u32, msg) - 35 } - 36 - 37 #[inline(never)] - 38 fn message_owned_idx_loop(msg: Message) -> (u32, Message) { - 39 let mut sum = 0u32; - 40 for i in 0..msg.v.len() { - 41 sum += msg.v[i] as u32 - 42 } - 43 (sum, msg) - 44 } - 45 - 46 - 47 #[inline(never)] - 48 fn message_owned_iter_loop(msg: Message) -> (u32, Message) { - 49 let mut sum = 0u32; - 50 for v in msg.v.iter() { - 51 sum += *v as u32 - 52 } - 53 (sum, msg) - 54 } - 55 - 56 #[inline(never)] - 57 pub fn invoke_message_borrowed() { - 58 let msg = Message { v: vec![2] }; - 59 let r1 = message_borrowed(&msg); - 60 let r2 = message_borrowed(&msg); - 61 assert!(r1 == 2); - 62 assert!(r1 == r2); - 63 } - 64 - 65 #[inline(never)] - 66 pub fn invoke_message_borrowed_idx_loop() { - 67 let msg = Message { v: vec![2] }; - 68 let r1 = message_borrowed_idx_loop(&msg); - 69 let r2 = message_borrowed_idx_loop(&msg); - 70 assert!(r1 == 2); - 71 assert!(r1 == r2); - 72 } - 73 - 74 #[inline(never)] - 75 pub fn invoke_message_borrowed_iter_loop() { - 76 let msg = Message { v: vec![2] }; - 77 let r1 = message_borrowed_iter_loop(&msg); - 78 let r2 = message_borrowed_iter_loop(&msg); - 79 assert!(r1 == 2); - 80 assert!(r1 == r2); - 81 } - 82 - 83 #[inline(never)] - 84 pub fn invoke_message_owned() { - 85 let msg = Message { v: vec![3] }; - 86 let (r1, msg) = message_owned(msg); - 87 let (r2, _msg) = message_owned(msg); - 88 assert!(r1 == 3); - 89 assert!(r1 == r2); - 90 } - 91 - 92 #[inline(never)] - 93 pub fn invoke_message_owned_idx_loop() { - 94 let msg = Message { v: vec![3] }; - 95 let (r1, msg) = message_owned_idx_loop(msg); - 96 let (r2, _msg) = message_owned_idx_loop(msg); - 97 assert!(r1 == 3); - 98 assert!(r1 == r2); - 99 } - 100 - 101 #[inline(never)] - 102 pub fn invoke_message_owned_iter_loop() { - 103 let msg = Message { v: vec![3] }; - 104 let (r1, msg) = message_owned_iter_loop(msg); - 105 let (r2, _msg) = message_owned_iter_loop(msg); - 106 assert!(r1 == 3); - 107 assert!(r1 == r2); - 108 } -``` +Here is the library [lib.rs](/src/lib.rs) -Here is main.rs: -``` -wink@3900x 22-12-01T19:31:45.523Z:~/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters (wip-black-box) -$ cat -n src/main.rs - 1 use exper_borrowed_vs_owned_parameters::{ - 2 invoke_message_borrowed, - 3 invoke_message_borrowed_idx_loop, - 4 invoke_message_borrowed_iter_loop, - 5 invoke_message_owned, - 6 invoke_message_owned_idx_loop, - 7 invoke_message_owned_iter_loop, - 8 }; - 9 - 10 - 11 fn main() { - 12 invoke_message_borrowed(); - 13 invoke_message_borrowed_idx_loop(); - 14 invoke_message_borrowed_iter_loop(); - 15 invoke_message_owned(); - 16 invoke_message_owned_idx_loop(); - 17 invoke_message_owned_iter_loop(); - 18 } - -``` +Here is [main.rs](/src/main.rs): Here are some runs: ``` -wink@3900x 22-12-01T19:31:02.590Z:~/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters (wip-black-box) +wink@3900x 22-12-02T21:46:33.755Z:~/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters (add-messagemf-and-default) $ cargo run Finished dev [unoptimized + debuginfo] target(s) in 0.00s Running `target/debug/exper-borrowed-vs-owned-parameters` -wink@3900x 22-12-01T19:32:22.394Z:~/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters (wip-black-box) +wink@3900x 22-12-02T21:46:38.353Z:~/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters (add-messagemf-and-default) $ cargo run --release - Compiling exper-borrowed-vs-owned-parameters v0.1.0 (/home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters) - Finished release [optimized] target(s) in 0.21s + Finished release [optimized] target(s) in 0.00s Running `target/release/exper-borrowed-vs-owned-parameters` -wink@3900x 22-12-01T19:32:28.042Z:~/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters (wip-black-box) - +wink@3900x 22-12-02T21:46:40.902Z:~/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters (add-messagemf-and-default) ``` ## Benchmarks: -From the runs you can see `borrowed` is faster than `owned`. I was +From the runs you can see `borrowed` is significantly faster than `owned`. I was initially surprised because in my mind the `owned` would have just been passing "pointers"/"references" as `borrowed` is. But no, the -structs are actually "moves" via a shallow copy. +with `owned` items they are actually "moved" via a shallow copy. See [here](https://hashrust.com/blog/moves-copies-and-clones-in-rust/). -The xxx_idx_loop and xxx_iter_loop that iterators aren't always -faster. You can see that `message_owned_iter` is a tiny bit slower -than `message_owned_idx_loop` and for `Message { v: vec![0, 1, 2, 3] }` -I've seen that iter is always slower! This is nothing more than an -observation and I'm not sure how much we can trust the `iai` benchmark -tool, so I'm not making any hard assumptions, just presenting the -information and may look at it more closely in the future. +The invoke_message_default and invoke_messagefm_default times +can be subtracted from other times to see the effect of message +passing more directly. -Here is the bench.rs, which is almost exactly like main.rs: -``` -wink@3900x 22-12-01T19:33:00.715Z:~/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters (wip-black-box) -$ cat -n benches/bench.rs - 1 use exper_borrowed_vs_owned_parameters::{ - 2 invoke_message_borrowed, - 3 invoke_message_borrowed_idx_loop, - 4 invoke_message_borrowed_iter_loop, - 5 invoke_message_owned, - 6 invoke_message_owned_idx_loop, - 7 invoke_message_owned_iter_loop, - 8 }; - 9 - 10 iai::main!( - 11 invoke_message_borrowed, - 12 invoke_message_borrowed_idx_loop, - 13 invoke_message_borrowed_iter_loop, - 14 invoke_message_owned, - 15 invoke_message_owned_idx_loop, - 16 invoke_message_owned_iter_loop, - 17 ); +For example, borrowed parameters: -``` + * invoke_message_borrowed = 559 + * invoke_message_default = 375 + * difference 559 - 375 = 184 + + * invoke_messagemf_borrowed = 608 + * invoke_messagemf_default = 496 + * difference 608 - 496 = 112 + +we only see a small difference because pointers are small, +**NOT, this is an example where the benchmark being inconsistent. +Previously the difference was 116 - 112 = 4. +I'm thinking thsi might have to do with code alignment, see [this search](https://www.google.com/search?q=benchmark+sensitive+to+code+alignment) +and [rust 82232](https://github.com/rust-lang/rust/issues/82232)**: + * 184 - 112 = 72 + +But with owned parameters: + + * invoke_message_owned = 621 + * invoke_message_default = 375 + * difference 621 - 375 = 296 + + * invoke_messagemf_owned = 928 + * invoke_messagemf_default = 496 + * difference 928 - 496 = 432 + +a much larger difference is seen because "owned" parameters +are "moved" with a shallow copy and MessageMf is larger than +Message: + * 432 - 296 = 136 Benchmark runs: ``` -wink@3900x 22-12-02T01:39:58.821Z:~/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters (main) +wink@3900x 22-12-03T15:45:10.219Z:~/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters (add-messagemf-and-default) $ cargo clean -wink@3900x 22-12-02T01:40:02.836Z:~/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters (main) +wink@3900x 22-12-03T15:45:13.413Z:~/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters (add-messagemf-and-default) $ cargo bench Compiling libc v0.2.137 Compiling cfg-if v1.0.0 @@ -214,128 +81,129 @@ $ cargo bench Compiling rand_core v0.6.4 Compiling rand_chacha v0.3.1 Compiling rand v0.8.5 - Compiling exper-borrowed-vs-owned-parameters v0.2.0 (/home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters) - Finished bench [optimized] target(s) in 1.54s - Running unittests src/lib.rs (target/release/deps/exper_borrowed_vs_owned_parameters-9133e7cce954512a) + Compiling exper-borrowed-vs-owned-parameters v0.3.0 (/home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters) + Finished bench [optimized] target(s) in 1.49s + Running unittests src/lib.rs (target/release/deps/exper_borrowed_vs_owned_parameters-9795cb9e05f14e17) running 0 tests test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s - Running unittests src/main.rs (target/release/deps/exper_borrowed_vs_owned_parameters-689a3e8a4f5acab2) + Running unittests src/main.rs (target/release/deps/exper_borrowed_vs_owned_parameters-1ec3fc8c04023579) running 0 tests test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s - Running benches/bench.rs (target/release/deps/bench-64cc5dc6a48cc1fe) -invoke_message_borrowed - Instructions: 196 - L1 Accesses: 286 - L2 Accesses: 1 - RAM Accesses: 4 - Estimated Cycles: 431 + Running benches/bench.rs (target/release/deps/bench-bc224c1a1ab05086) +invoke_message_default + Instructions: 177 + L1 Accesses: 260 + L2 Accesses: 2 + RAM Accesses: 3 + Estimated Cycles: 375 -invoke_message_borrowed_idx_loop - Instructions: 210 - L1 Accesses: 293 +invoke_messagemf_default + Instructions: 187 + L1 Accesses: 276 L2 Accesses: 2 RAM Accesses: 6 - Estimated Cycles: 513 + Estimated Cycles: 496 -invoke_message_borrowed_iter_loop - Instructions: 190 - L1 Accesses: 270 +invoke_message_borrowed + Instructions: 208 + L1 Accesses: 304 L2 Accesses: 2 - RAM Accesses: 4 - Estimated Cycles: 420 + RAM Accesses: 7 + Estimated Cycles: 559 invoke_message_owned - Instructions: 228 - L1 Accesses: 348 - L2 Accesses: 1 - RAM Accesses: 6 - Estimated Cycles: 563 - -invoke_message_owned_idx_loop - Instructions: 234 - L1 Accesses: 343 + Instructions: 239 + L1 Accesses: 366 L2 Accesses: 2 - RAM Accesses: 6 - Estimated Cycles: 563 + RAM Accesses: 7 + Estimated Cycles: 621 -invoke_message_owned_iter_loop - Instructions: 238 - L1 Accesses: 349 +invoke_messagemf_borrowed + Instructions: 218 + L1 Accesses: 323 L2 Accesses: 1 - RAM Accesses: 5 - Estimated Cycles: 529 + RAM Accesses: 8 + Estimated Cycles: 608 -wink@3900x 22-12-02T01:40:11.370Z:~/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters (main) +invoke_messagemf_owned + Instructions: 293 + L1 Accesses: 468 + L2 Accesses: 1 + RAM Accesses: 13 + Estimated Cycles: 928 + +wink@3900x 22-12-03T15:45:20.595Z:~/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters (add-messagemf-and-default) $ cargo bench Finished bench [optimized] target(s) in 0.00s - Running unittests src/lib.rs (target/release/deps/exper_borrowed_vs_owned_parameters-9133e7cce954512a) + Running unittests src/lib.rs (target/release/deps/exper_borrowed_vs_owned_parameters-9795cb9e05f14e17) running 0 tests test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s - Running unittests src/main.rs (target/release/deps/exper_borrowed_vs_owned_parameters-689a3e8a4f5acab2) + Running unittests src/main.rs (target/release/deps/exper_borrowed_vs_owned_parameters-1ec3fc8c04023579) running 0 tests test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s - Running benches/bench.rs (target/release/deps/bench-64cc5dc6a48cc1fe) -invoke_message_borrowed - Instructions: 196 (No change) - L1 Accesses: 286 (No change) - L2 Accesses: 1 (No change) - RAM Accesses: 4 (No change) - Estimated Cycles: 431 (No change) + Running benches/bench.rs (target/release/deps/bench-bc224c1a1ab05086) +invoke_message_default + Instructions: 177 (No change) + L1 Accesses: 260 (No change) + L2 Accesses: 2 (No change) + RAM Accesses: 3 (No change) + Estimated Cycles: 375 (No change) -invoke_message_borrowed_idx_loop - Instructions: 210 (No change) - L1 Accesses: 293 (No change) +invoke_messagemf_default + Instructions: 187 (No change) + L1 Accesses: 276 (No change) L2 Accesses: 2 (No change) RAM Accesses: 6 (No change) - Estimated Cycles: 513 (No change) + Estimated Cycles: 496 (No change) -invoke_message_borrowed_iter_loop - Instructions: 190 (No change) - L1 Accesses: 270 (No change) +invoke_message_borrowed + Instructions: 208 (No change) + L1 Accesses: 304 (No change) L2 Accesses: 2 (No change) - RAM Accesses: 4 (No change) - Estimated Cycles: 420 (No change) + RAM Accesses: 7 (No change) + Estimated Cycles: 559 (No change) invoke_message_owned - Instructions: 228 (No change) - L1 Accesses: 348 (No change) - L2 Accesses: 1 (No change) - RAM Accesses: 6 (No change) - Estimated Cycles: 563 (No change) - -invoke_message_owned_idx_loop - Instructions: 234 (No change) - L1 Accesses: 343 (No change) + Instructions: 239 (No change) + L1 Accesses: 366 (No change) L2 Accesses: 2 (No change) - RAM Accesses: 6 (No change) - Estimated Cycles: 563 (No change) + RAM Accesses: 7 (No change) + Estimated Cycles: 621 (No change) + +invoke_messagemf_borrowed + Instructions: 218 (No change) + L1 Accesses: 323 (No change) + L2 Accesses: 1 (No change) + RAM Accesses: 8 (No change) + Estimated Cycles: 608 (No change) -invoke_message_owned_iter_loop - Instructions: 238 (No change) - L1 Accesses: 349 (No change) +invoke_messagemf_owned + Instructions: 293 (No change) + L1 Accesses: 468 (No change) L2 Accesses: 1 (No change) - RAM Accesses: 5 (No change) - Estimated Cycles: 529 (No change) + RAM Accesses: 13 (No change) + Estimated Cycles: 928 (No change) + +wink@3900x 22-12-03T15:45:24.543Z:~/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters (add-messagemf-and-default) ``` ## Asm code -The assembler code can be found at -[/asm](https://github.com/winksaville/exper-borrowed-vs-owned-parameters/tree/main/asm) -and is generated with `./gen_asm.sh`. +The assembler code can be found at [/asm](/asm) +and is generated with [`./gen_asm.sh`](/gen_asm.sh). ## License diff --git a/asm/invoke_message_borrowed.txt b/asm/invoke_message_borrowed.txt index 024495d..28e541f 100644 --- a/asm/invoke_message_borrowed.txt +++ b/asm/invoke_message_borrowed.txt @@ -4,108 +4,118 @@ .type exper_borrowed_vs_owned_parameters::invoke_message_borrowed,@function exper_borrowed_vs_owned_parameters::invoke_message_borrowed: - // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 57 + // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 82 pub fn invoke_message_borrowed() { .cfi_startproc .cfi_personality 155, DW.ref.rust_eh_personality - .cfi_lsda 27, .Lexception1 + .cfi_lsda 27, .Lexception2 push rbp .cfi_def_cfa_offset 16 - push rbx + push r14 .cfi_def_cfa_offset 24 - sub rsp, 24 - .cfi_def_cfa_offset 48 - .cfi_offset rbx, -24 + push rbx + .cfi_def_cfa_offset 32 + sub rsp, 32 + .cfi_def_cfa_offset 64 + .cfi_offset rbx, -32 + .cfi_offset r14, -24 .cfi_offset rbp, -16 + lea rdi, [rsp + 8] - // /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/alloc/src/alloc.rs : 95 - unsafe { __rust_alloc(layout.size(), layout.align()) } - mov edi, 1 - mov esi, 1 - call qword ptr [rip + __rust_alloc@GOTPCREL] + // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 83 + let msg = Message::default(); + call qword ptr [rip + ::default@GOTPCREL] - // /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/alloc/src/alloc.rs : 326 - match Global.allocate(layout) { - test rax, rax - je .LBB7_9 - - mov rbx, rax - // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 58 - let msg = Message { v: vec![2] }; - mov byte ptr [rax], 2 - mov qword ptr [rsp], rax - movaps xmm0, xmmword ptr [rip + .LCPI7_0] - movups xmmword ptr [rsp + 8], xmm0 - - // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 59 + // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 84 let r1 = message_borrowed(&msg); - mov esi, 1 - mov rdi, rax + mov r14, qword ptr [rsp + 8] + mov rbx, qword ptr [rsp + 24] + + mov rdi, r14 + mov rsi, rbx call exper_borrowed_vs_owned_parameters::message_borrowed mov ebp, eax - // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 60 + // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 85 let r2 = message_borrowed(&msg); - mov esi, 1 - mov rdi, rbx + mov rdi, r14 + mov rsi, rbx call exper_borrowed_vs_owned_parameters::message_borrowed - // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 61 + // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 86 assert!(r1 == 2); cmp ebp, 2 - jne .LBB7_4 + jne .LBB9_3 - // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 62 + // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 87 assert!(r1 == r2); cmp eax, 2 - jne .LBB7_6 + jne .LBB9_7 + + // /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/core/src/ptr/mod.rs : 490 + pub unsafe fn drop_in_place(to_drop: *mut T) { + mov rsi, qword ptr [rsp + 16] + + // /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/alloc/src/raw_vec.rs : 241 + if T::IS_ZST || self.cap == 0 { + test rsi, rsi + je .LBB9_9 + + // /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/core/src/alloc/layout.rs : 452 + if element_size != 0 && n > Layout::max_size_for_align(align) / element_size { + mov rdx, rsi + not rdx + shr rdx, 63 // /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/alloc/src/alloc.rs : 113 unsafe { __rust_dealloc(ptr, layout.size(), layout.align()) } - mov esi, 1 - mov edx, 1 - mov rdi, rbx - add rsp, 24 - .cfi_def_cfa_offset 24 + mov rdi, r14 + add rsp, 32 + .cfi_def_cfa_offset 32 pop rbx + .cfi_def_cfa_offset 24 + pop r14 .cfi_def_cfa_offset 16 pop rbp .cfi_def_cfa_offset 8 jmp qword ptr [rip + __rust_dealloc@GOTPCREL] -.LBB7_9: - .cfi_def_cfa_offset 48 - // /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/alloc/src/alloc.rs : 328 - Err(_) => handle_alloc_error(layout), - mov edi, 1 - mov esi, 1 - call qword ptr [rip + alloc::alloc::handle_alloc_error@GOTPCREL] - ud2 - -.LBB7_4: - lea rdx, [rip + .L__unnamed_3] - mov esi, 25 - lea rdi, [rip + .L__unnamed_4] - jmp .LBB7_7 -.LBB7_6: +.LBB9_9: + .cfi_def_cfa_offset 64 + // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 88 + } + add rsp, 32 + .cfi_def_cfa_offset 32 + pop rbx + .cfi_def_cfa_offset 24 + pop r14 + .cfi_def_cfa_offset 16 + pop rbp + .cfi_def_cfa_offset 8 + ret +.LBB9_3: + .cfi_def_cfa_offset 64 lea rdx, [rip + .L__unnamed_5] - mov esi, 26 + mov esi, 25 lea rdi, [rip + .L__unnamed_6] -.LBB7_7: + jmp .LBB9_4 +.LBB9_7: + lea rdx, [rip + .L__unnamed_7] + mov esi, 26 + lea rdi, [rip + .L__unnamed_8] +.LBB9_4: call qword ptr [rip + core::panicking::panic@GOTPCREL] ud2 mov rbx, rax - mov rdi, rsp - // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 63 - } + lea rdi, [rsp + 8] call core::ptr::drop_in_place mov rdi, rbx call _Unwind_Resume@PLT ud2 - .size exper_borrowed_vs_owned_parameters::invoke_message_borrowed, .Lfunc_end7-exper_borrowed_vs_owned_parameters::invoke_message_borrowed + .size exper_borrowed_vs_owned_parameters::invoke_message_borrowed, .Lfunc_end9-exper_borrowed_vs_owned_parameters::invoke_message_borrowed diff --git a/asm/invoke_message_borrowed_idx_loop.txt b/asm/invoke_message_borrowed_idx_loop.txt deleted file mode 100644 index 31e2444..0000000 --- a/asm/invoke_message_borrowed_idx_loop.txt +++ /dev/null @@ -1,111 +0,0 @@ -.section .text.exper_borrowed_vs_owned_parameters::invoke_message_borrowed_idx_loop,"ax",@progbits - .globl exper_borrowed_vs_owned_parameters::invoke_message_borrowed_idx_loop - .p2align 4, 0x90 - .type exper_borrowed_vs_owned_parameters::invoke_message_borrowed_idx_loop,@function -exper_borrowed_vs_owned_parameters::invoke_message_borrowed_idx_loop: - - // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 66 - pub fn invoke_message_borrowed_idx_loop() { - .cfi_startproc - .cfi_personality 155, DW.ref.rust_eh_personality - .cfi_lsda 27, .Lexception2 - push rbp - .cfi_def_cfa_offset 16 - push rbx - .cfi_def_cfa_offset 24 - sub rsp, 24 - .cfi_def_cfa_offset 48 - .cfi_offset rbx, -24 - .cfi_offset rbp, -16 - - // /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/alloc/src/alloc.rs : 95 - unsafe { __rust_alloc(layout.size(), layout.align()) } - mov edi, 1 - mov esi, 1 - call qword ptr [rip + __rust_alloc@GOTPCREL] - - // /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/alloc/src/alloc.rs : 326 - match Global.allocate(layout) { - test rax, rax - je .LBB8_9 - - mov rbx, rax - // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 67 - let msg = Message { v: vec![2] }; - mov byte ptr [rax], 2 - mov qword ptr [rsp], rax - movaps xmm0, xmmword ptr [rip + .LCPI8_0] - movups xmmword ptr [rsp + 8], xmm0 - - // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 68 - let r1 = message_borrowed_idx_loop(&msg); - mov esi, 1 - mov rdi, rax - call exper_borrowed_vs_owned_parameters::message_borrowed_idx_loop - - mov ebp, eax - - // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 69 - let r2 = message_borrowed_idx_loop(&msg); - mov esi, 1 - mov rdi, rbx - call exper_borrowed_vs_owned_parameters::message_borrowed_idx_loop - - // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 70 - assert!(r1 == 2); - cmp ebp, 2 - jne .LBB8_4 - - // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 71 - assert!(r1 == r2); - cmp eax, 2 - jne .LBB8_6 - - // /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/alloc/src/alloc.rs : 113 - unsafe { __rust_dealloc(ptr, layout.size(), layout.align()) } - mov esi, 1 - mov edx, 1 - mov rdi, rbx - add rsp, 24 - .cfi_def_cfa_offset 24 - pop rbx - - .cfi_def_cfa_offset 16 - pop rbp - .cfi_def_cfa_offset 8 - jmp qword ptr [rip + __rust_dealloc@GOTPCREL] - -.LBB8_9: - .cfi_def_cfa_offset 48 - // /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/alloc/src/alloc.rs : 328 - Err(_) => handle_alloc_error(layout), - mov edi, 1 - mov esi, 1 - call qword ptr [rip + alloc::alloc::handle_alloc_error@GOTPCREL] - ud2 - -.LBB8_4: - lea rdx, [rip + .L__unnamed_7] - mov esi, 25 - lea rdi, [rip + .L__unnamed_4] - jmp .LBB8_7 -.LBB8_6: - lea rdx, [rip + .L__unnamed_8] - mov esi, 26 - lea rdi, [rip + .L__unnamed_6] -.LBB8_7: - - call qword ptr [rip + core::panicking::panic@GOTPCREL] - - ud2 - - mov rbx, rax - mov rdi, rsp - // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 72 - } - call core::ptr::drop_in_place - mov rdi, rbx - call _Unwind_Resume@PLT - ud2 - - .size exper_borrowed_vs_owned_parameters::invoke_message_borrowed_idx_loop, .Lfunc_end8-exper_borrowed_vs_owned_parameters::invoke_message_borrowed_idx_loop diff --git a/asm/invoke_message_borrowed_iter_loop.txt b/asm/invoke_message_borrowed_iter_loop.txt deleted file mode 100644 index a535cb3..0000000 --- a/asm/invoke_message_borrowed_iter_loop.txt +++ /dev/null @@ -1,110 +0,0 @@ -.section .text.exper_borrowed_vs_owned_parameters::invoke_message_borrowed_iter_loop,"ax",@progbits - .globl exper_borrowed_vs_owned_parameters::invoke_message_borrowed_iter_loop - .p2align 4, 0x90 - .type exper_borrowed_vs_owned_parameters::invoke_message_borrowed_iter_loop,@function -exper_borrowed_vs_owned_parameters::invoke_message_borrowed_iter_loop: - - // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 75 - pub fn invoke_message_borrowed_iter_loop() { - .cfi_startproc - .cfi_personality 155, DW.ref.rust_eh_personality - .cfi_lsda 27, .Lexception3 - push rbp - .cfi_def_cfa_offset 16 - push rbx - .cfi_def_cfa_offset 24 - sub rsp, 24 - .cfi_def_cfa_offset 48 - .cfi_offset rbx, -24 - .cfi_offset rbp, -16 - - // /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/alloc/src/alloc.rs : 95 - unsafe { __rust_alloc(layout.size(), layout.align()) } - mov edi, 1 - mov esi, 1 - call qword ptr [rip + __rust_alloc@GOTPCREL] - - // /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/alloc/src/alloc.rs : 326 - match Global.allocate(layout) { - test rax, rax - je .LBB9_8 - - mov rbx, rax - // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 76 - let msg = Message { v: vec![2] }; - mov byte ptr [rax], 2 - mov qword ptr [rsp], rax - movaps xmm0, xmmword ptr [rip + .LCPI9_0] - movups xmmword ptr [rsp + 8], xmm0 - - // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 77 - let r1 = message_borrowed_iter_loop(&msg); - mov esi, 1 - mov rdi, rax - call exper_borrowed_vs_owned_parameters::message_borrowed_iter_loop - mov ebp, eax - - // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 78 - let r2 = message_borrowed_iter_loop(&msg); - mov esi, 1 - mov rdi, rbx - call exper_borrowed_vs_owned_parameters::message_borrowed_iter_loop - - // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 79 - assert!(r1 == 2); - cmp ebp, 2 - jne .LBB9_2 - - // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 80 - assert!(r1 == r2); - cmp eax, 2 - jne .LBB9_5 - - // /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/alloc/src/alloc.rs : 113 - unsafe { __rust_dealloc(ptr, layout.size(), layout.align()) } - mov esi, 1 - mov edx, 1 - mov rdi, rbx - add rsp, 24 - .cfi_def_cfa_offset 24 - pop rbx - - .cfi_def_cfa_offset 16 - pop rbp - .cfi_def_cfa_offset 8 - jmp qword ptr [rip + __rust_dealloc@GOTPCREL] - -.LBB9_8: - .cfi_def_cfa_offset 48 - // /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/alloc/src/alloc.rs : 328 - Err(_) => handle_alloc_error(layout), - mov edi, 1 - mov esi, 1 - call qword ptr [rip + alloc::alloc::handle_alloc_error@GOTPCREL] - ud2 - -.LBB9_2: - lea rdx, [rip + .L__unnamed_9] - mov esi, 25 - lea rdi, [rip + .L__unnamed_4] - jmp .LBB9_6 -.LBB9_5: - lea rdx, [rip + .L__unnamed_10] - mov esi, 26 - lea rdi, [rip + .L__unnamed_6] -.LBB9_6: - - call qword ptr [rip + core::panicking::panic@GOTPCREL] - - ud2 - - mov rbx, rax - mov rdi, rsp - // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 81 - } - call core::ptr::drop_in_place - mov rdi, rbx - call _Unwind_Resume@PLT - ud2 - - .size exper_borrowed_vs_owned_parameters::invoke_message_borrowed_iter_loop, .Lfunc_end9-exper_borrowed_vs_owned_parameters::invoke_message_borrowed_iter_loop diff --git a/asm/invoke_message_default.txt b/asm/invoke_message_default.txt new file mode 100644 index 0000000..a0f0ff2 --- /dev/null +++ b/asm/invoke_message_default.txt @@ -0,0 +1,51 @@ +.section .text.exper_borrowed_vs_owned_parameters::invoke_message_default,"ax",@progbits + .globl exper_borrowed_vs_owned_parameters::invoke_message_default + .p2align 4, 0x90 + .type exper_borrowed_vs_owned_parameters::invoke_message_default,@function +exper_borrowed_vs_owned_parameters::invoke_message_default: + + // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 72 + pub fn invoke_message_default() { + .cfi_startproc + sub rsp, 24 + .cfi_def_cfa_offset 32 + mov rdi, rsp + + // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 73 + Message::default(); + call qword ptr [rip + ::default@GOTPCREL] + + // /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/core/src/ptr/mod.rs : 490 + pub unsafe fn drop_in_place(to_drop: *mut T) { + mov rsi, qword ptr [rsp + 8] + + // /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/alloc/src/raw_vec.rs : 241 + if T::IS_ZST || self.cap == 0 { + test rsi, rsi + je .LBB7_1 + + // /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/core/src/ptr/mod.rs : 490 + pub unsafe fn drop_in_place(to_drop: *mut T) { + mov rdi, qword ptr [rsp] + + // /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/core/src/alloc/layout.rs : 452 + if element_size != 0 && n > Layout::max_size_for_align(align) / element_size { + mov rdx, rsi + not rdx + shr rdx, 63 + + // /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/alloc/src/alloc.rs : 113 + unsafe { __rust_dealloc(ptr, layout.size(), layout.align()) } + add rsp, 24 + .cfi_def_cfa_offset 8 + jmp qword ptr [rip + __rust_dealloc@GOTPCREL] + +.LBB7_1: + .cfi_def_cfa_offset 32 + // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 74 + } + add rsp, 24 + .cfi_def_cfa_offset 8 + ret + + .size exper_borrowed_vs_owned_parameters::invoke_message_default, .Lfunc_end7-exper_borrowed_vs_owned_parameters::invoke_message_default diff --git a/asm/invoke_message_owned.txt b/asm/invoke_message_owned.txt index 9a8cbe1..7af1f3e 100644 --- a/asm/invoke_message_owned.txt +++ b/asm/invoke_message_owned.txt @@ -4,71 +4,61 @@ .type exper_borrowed_vs_owned_parameters::invoke_message_owned,@function exper_borrowed_vs_owned_parameters::invoke_message_owned: - // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 84 + // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 91 pub fn invoke_message_owned() { .cfi_startproc .cfi_personality 155, DW.ref.rust_eh_personality - .cfi_lsda 27, .Lexception4 + .cfi_lsda 27, .Lexception3 push rbx .cfi_def_cfa_offset 16 - sub rsp, 96 - .cfi_def_cfa_offset 112 + sub rsp, 112 + .cfi_def_cfa_offset 128 .cfi_offset rbx, -16 + lea rdi, [rsp + 56] - // /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/alloc/src/alloc.rs : 95 - unsafe { __rust_alloc(layout.size(), layout.align()) } - mov edi, 1 - mov esi, 1 - call qword ptr [rip + __rust_alloc@GOTPCREL] + // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 92 + let msg = Message::default(); + call qword ptr [rip + ::default@GOTPCREL] - // /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/alloc/src/alloc.rs : 326 - match Global.allocate(layout) { - test rax, rax - je .LBB10_10 - - // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 85 - let msg = Message { v: vec![3] }; - mov byte ptr [rax], 3 - - // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 86 + // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 93 let (r1, msg) = message_owned(msg); - mov qword ptr [rsp], rax - movaps xmm0, xmmword ptr [rip + .LCPI10_0] - movups xmmword ptr [rsp + 8], xmm0 - lea rdi, [rsp + 32] + mov rax, qword ptr [rsp + 72] + mov qword ptr [rsp + 16], rax + movups xmm0, xmmword ptr [rsp + 56] + movaps xmmword ptr [rsp], xmm0 + lea rdi, [rsp + 24] mov rsi, rsp call exper_borrowed_vs_owned_parameters::message_owned + mov ebx, dword ptr [rsp + 24] - mov ebx, dword ptr [rsp + 32] - - mov rax, qword ptr [rsp + 56] - mov qword ptr [rsp + 80], rax - movups xmm0, xmmword ptr [rsp + 40] - movaps xmmword ptr [rsp + 64], xmm0 + mov rax, qword ptr [rsp + 48] + mov qword ptr [rsp + 96], rax + movups xmm0, xmmword ptr [rsp + 32] + movaps xmmword ptr [rsp + 80], xmm0 - // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 87 + // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 94 let (r2, _msg) = message_owned(msg); mov qword ptr [rsp + 16], rax movaps xmmword ptr [rsp], xmm0 - lea rdi, [rsp + 32] + lea rdi, [rsp + 24] mov rsi, rsp call exper_borrowed_vs_owned_parameters::message_owned - mov eax, dword ptr [rsp + 32] + mov eax, dword ptr [rsp + 24] - mov rcx, qword ptr [rsp + 56] + mov rcx, qword ptr [rsp + 48] mov qword ptr [rsp + 16], rcx - movups xmm0, xmmword ptr [rsp + 40] + movups xmm0, xmmword ptr [rsp + 32] movaps xmmword ptr [rsp], xmm0 - // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 88 - assert!(r1 == 3); - cmp ebx, 3 - jne .LBB10_2 + // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 95 + assert!(r1 == 2); + cmp ebx, 2 + jne .LBB10_1 - // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 89 + // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 96 assert!(r1 == r2); - cmp eax, 3 - jne .LBB10_6 + cmp eax, 2 + jne .LBB10_5 // /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/core/src/ptr/mod.rs : 490 pub unsafe fn drop_in_place(to_drop: *mut T) { @@ -77,7 +67,7 @@ exper_borrowed_vs_owned_parameters::invoke_message_owned: // /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/alloc/src/raw_vec.rs : 241 if T::IS_ZST || self.cap == 0 { test rsi, rsi - je .LBB10_9 + je .LBB10_8 // /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/core/src/ptr/mod.rs : 490 pub unsafe fn drop_in_place(to_drop: *mut T) { @@ -91,42 +81,33 @@ exper_borrowed_vs_owned_parameters::invoke_message_owned: // /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/alloc/src/alloc.rs : 113 unsafe { __rust_dealloc(ptr, layout.size(), layout.align()) } - add rsp, 96 + add rsp, 112 .cfi_def_cfa_offset 16 pop rbx .cfi_def_cfa_offset 8 jmp qword ptr [rip + __rust_dealloc@GOTPCREL] -.LBB10_9: - .cfi_def_cfa_offset 112 - // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 90 +.LBB10_8: + .cfi_def_cfa_offset 128 + // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 97 } - add rsp, 96 + add rsp, 112 .cfi_def_cfa_offset 16 pop rbx .cfi_def_cfa_offset 8 ret -.LBB10_10: - .cfi_def_cfa_offset 112 - - // /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/alloc/src/alloc.rs : 328 - Err(_) => handle_alloc_error(layout), - mov edi, 1 - mov esi, 1 - call qword ptr [rip + alloc::alloc::handle_alloc_error@GOTPCREL] - ud2 - -.LBB10_2: - lea rdx, [rip + .L__unnamed_11] +.LBB10_1: + .cfi_def_cfa_offset 128 + lea rdx, [rip + .L__unnamed_9] mov esi, 25 - lea rdi, [rip + .L__unnamed_12] - jmp .LBB10_3 -.LBB10_6: - lea rdx, [rip + .L__unnamed_13] - mov esi, 26 lea rdi, [rip + .L__unnamed_6] -.LBB10_3: + jmp .LBB10_2 +.LBB10_5: + lea rdx, [rip + .L__unnamed_10] + mov esi, 26 + lea rdi, [rip + .L__unnamed_8] +.LBB10_2: call qword ptr [rip + core::panicking::panic@GOTPCREL] @@ -135,8 +116,6 @@ exper_borrowed_vs_owned_parameters::invoke_message_owned: mov rbx, rax mov rdi, rsp - // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 90 - } call core::ptr::drop_in_place mov rdi, rbx call _Unwind_Resume@PLT diff --git a/asm/invoke_message_owned_idx_loop.txt b/asm/invoke_message_owned_idx_loop.txt deleted file mode 100644 index 3fdc9a7..0000000 --- a/asm/invoke_message_owned_idx_loop.txt +++ /dev/null @@ -1,145 +0,0 @@ -.section .text.exper_borrowed_vs_owned_parameters::invoke_message_owned_idx_loop,"ax",@progbits - .globl exper_borrowed_vs_owned_parameters::invoke_message_owned_idx_loop - .p2align 4, 0x90 - .type exper_borrowed_vs_owned_parameters::invoke_message_owned_idx_loop,@function -exper_borrowed_vs_owned_parameters::invoke_message_owned_idx_loop: - - // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 93 - pub fn invoke_message_owned_idx_loop() { - .cfi_startproc - .cfi_personality 155, DW.ref.rust_eh_personality - .cfi_lsda 27, .Lexception5 - push rbx - .cfi_def_cfa_offset 16 - sub rsp, 96 - .cfi_def_cfa_offset 112 - .cfi_offset rbx, -16 - - // /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/alloc/src/alloc.rs : 95 - unsafe { __rust_alloc(layout.size(), layout.align()) } - mov edi, 1 - mov esi, 1 - call qword ptr [rip + __rust_alloc@GOTPCREL] - - // /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/alloc/src/alloc.rs : 326 - match Global.allocate(layout) { - test rax, rax - je .LBB11_10 - - // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 94 - let msg = Message { v: vec![3] }; - mov byte ptr [rax], 3 - - // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 95 - let (r1, msg) = message_owned_idx_loop(msg); - mov qword ptr [rsp], rax - movaps xmm0, xmmword ptr [rip + .LCPI11_0] - movups xmmword ptr [rsp + 8], xmm0 - lea rdi, [rsp + 32] - mov rsi, rsp - call exper_borrowed_vs_owned_parameters::message_owned_idx_loop - - mov ebx, dword ptr [rsp + 32] - - mov rax, qword ptr [rsp + 56] - mov qword ptr [rsp + 80], rax - movups xmm0, xmmword ptr [rsp + 40] - movaps xmmword ptr [rsp + 64], xmm0 - - // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 96 - let (r2, _msg) = message_owned_idx_loop(msg); - mov qword ptr [rsp + 16], rax - movaps xmmword ptr [rsp], xmm0 - lea rdi, [rsp + 32] - mov rsi, rsp - call exper_borrowed_vs_owned_parameters::message_owned_idx_loop - mov eax, dword ptr [rsp + 32] - - mov rcx, qword ptr [rsp + 56] - mov qword ptr [rsp + 16], rcx - movups xmm0, xmmword ptr [rsp + 40] - movaps xmmword ptr [rsp], xmm0 - - // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 97 - assert!(r1 == 3); - cmp ebx, 3 - jne .LBB11_2 - - // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 98 - assert!(r1 == r2); - cmp eax, 3 - jne .LBB11_6 - - // /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/core/src/ptr/mod.rs : 490 - pub unsafe fn drop_in_place(to_drop: *mut T) { - mov rsi, qword ptr [rsp + 8] - - // /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/alloc/src/raw_vec.rs : 241 - if T::IS_ZST || self.cap == 0 { - test rsi, rsi - je .LBB11_9 - - // /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/core/src/ptr/mod.rs : 490 - pub unsafe fn drop_in_place(to_drop: *mut T) { - mov rdi, qword ptr [rsp] - - // /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/core/src/alloc/layout.rs : 452 - if element_size != 0 && n > Layout::max_size_for_align(align) / element_size { - mov rdx, rsi - not rdx - shr rdx, 63 - - // /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/alloc/src/alloc.rs : 113 - unsafe { __rust_dealloc(ptr, layout.size(), layout.align()) } - add rsp, 96 - .cfi_def_cfa_offset 16 - pop rbx - - .cfi_def_cfa_offset 8 - jmp qword ptr [rip + __rust_dealloc@GOTPCREL] - -.LBB11_9: - .cfi_def_cfa_offset 112 - // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 99 - } - add rsp, 96 - .cfi_def_cfa_offset 16 - pop rbx - .cfi_def_cfa_offset 8 - ret -.LBB11_10: - .cfi_def_cfa_offset 112 - - // /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/alloc/src/alloc.rs : 328 - Err(_) => handle_alloc_error(layout), - mov edi, 1 - mov esi, 1 - call qword ptr [rip + alloc::alloc::handle_alloc_error@GOTPCREL] - ud2 - -.LBB11_2: - lea rdx, [rip + .L__unnamed_14] - mov esi, 25 - lea rdi, [rip + .L__unnamed_12] - jmp .LBB11_3 -.LBB11_6: - lea rdx, [rip + .L__unnamed_15] - mov esi, 26 - lea rdi, [rip + .L__unnamed_6] -.LBB11_3: - - call qword ptr [rip + core::panicking::panic@GOTPCREL] - - ud2 - - mov rbx, rax - - mov rdi, rsp - // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 99 - } - call core::ptr::drop_in_place - mov rdi, rbx - call _Unwind_Resume@PLT - ud2 - - .size exper_borrowed_vs_owned_parameters::invoke_message_owned_idx_loop, .Lfunc_end11-exper_borrowed_vs_owned_parameters::invoke_message_owned_idx_loop diff --git a/asm/invoke_message_owned_iter_loop.txt b/asm/invoke_message_owned_iter_loop.txt deleted file mode 100644 index 8543eb7..0000000 --- a/asm/invoke_message_owned_iter_loop.txt +++ /dev/null @@ -1,145 +0,0 @@ -.section .text.exper_borrowed_vs_owned_parameters::invoke_message_owned_iter_loop,"ax",@progbits - .globl exper_borrowed_vs_owned_parameters::invoke_message_owned_iter_loop - .p2align 4, 0x90 - .type exper_borrowed_vs_owned_parameters::invoke_message_owned_iter_loop,@function -exper_borrowed_vs_owned_parameters::invoke_message_owned_iter_loop: - - // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 102 - pub fn invoke_message_owned_iter_loop() { - .cfi_startproc - .cfi_personality 155, DW.ref.rust_eh_personality - .cfi_lsda 27, .Lexception6 - push rbx - .cfi_def_cfa_offset 16 - sub rsp, 96 - .cfi_def_cfa_offset 112 - .cfi_offset rbx, -16 - - // /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/alloc/src/alloc.rs : 95 - unsafe { __rust_alloc(layout.size(), layout.align()) } - mov edi, 1 - mov esi, 1 - call qword ptr [rip + __rust_alloc@GOTPCREL] - - // /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/alloc/src/alloc.rs : 326 - match Global.allocate(layout) { - test rax, rax - je .LBB12_10 - - // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 103 - let msg = Message { v: vec![3] }; - mov byte ptr [rax], 3 - - // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 104 - let (r1, msg) = message_owned_iter_loop(msg); - mov qword ptr [rsp], rax - movaps xmm0, xmmword ptr [rip + .LCPI12_0] - movups xmmword ptr [rsp + 8], xmm0 - lea rdi, [rsp + 32] - mov rsi, rsp - call exper_borrowed_vs_owned_parameters::message_owned_iter_loop - - mov ebx, dword ptr [rsp + 32] - - mov rax, qword ptr [rsp + 56] - mov qword ptr [rsp + 80], rax - movups xmm0, xmmword ptr [rsp + 40] - movaps xmmword ptr [rsp + 64], xmm0 - - // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 105 - let (r2, _msg) = message_owned_iter_loop(msg); - mov qword ptr [rsp + 16], rax - movaps xmmword ptr [rsp], xmm0 - lea rdi, [rsp + 32] - mov rsi, rsp - call exper_borrowed_vs_owned_parameters::message_owned_iter_loop - mov eax, dword ptr [rsp + 32] - - mov rcx, qword ptr [rsp + 56] - mov qword ptr [rsp + 16], rcx - movups xmm0, xmmword ptr [rsp + 40] - movaps xmmword ptr [rsp], xmm0 - - // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 106 - assert!(r1 == 3); - cmp ebx, 3 - jne .LBB12_2 - - // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 107 - assert!(r1 == r2); - cmp eax, 3 - jne .LBB12_6 - - // /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/core/src/ptr/mod.rs : 490 - pub unsafe fn drop_in_place(to_drop: *mut T) { - mov rsi, qword ptr [rsp + 8] - - // /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/alloc/src/raw_vec.rs : 241 - if T::IS_ZST || self.cap == 0 { - test rsi, rsi - je .LBB12_9 - - // /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/core/src/ptr/mod.rs : 490 - pub unsafe fn drop_in_place(to_drop: *mut T) { - mov rdi, qword ptr [rsp] - - // /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/core/src/alloc/layout.rs : 452 - if element_size != 0 && n > Layout::max_size_for_align(align) / element_size { - mov rdx, rsi - not rdx - shr rdx, 63 - - // /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/alloc/src/alloc.rs : 113 - unsafe { __rust_dealloc(ptr, layout.size(), layout.align()) } - add rsp, 96 - .cfi_def_cfa_offset 16 - pop rbx - - .cfi_def_cfa_offset 8 - jmp qword ptr [rip + __rust_dealloc@GOTPCREL] - -.LBB12_9: - .cfi_def_cfa_offset 112 - // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 108 - } - add rsp, 96 - .cfi_def_cfa_offset 16 - pop rbx - .cfi_def_cfa_offset 8 - ret -.LBB12_10: - .cfi_def_cfa_offset 112 - - // /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/alloc/src/alloc.rs : 328 - Err(_) => handle_alloc_error(layout), - mov edi, 1 - mov esi, 1 - call qword ptr [rip + alloc::alloc::handle_alloc_error@GOTPCREL] - ud2 - -.LBB12_2: - lea rdx, [rip + .L__unnamed_16] - mov esi, 25 - lea rdi, [rip + .L__unnamed_12] - jmp .LBB12_3 -.LBB12_6: - lea rdx, [rip + .L__unnamed_17] - mov esi, 26 - lea rdi, [rip + .L__unnamed_6] -.LBB12_3: - - call qword ptr [rip + core::panicking::panic@GOTPCREL] - - ud2 - - mov rbx, rax - - mov rdi, rsp - // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 108 - } - call core::ptr::drop_in_place - mov rdi, rbx - call _Unwind_Resume@PLT - ud2 - - .size exper_borrowed_vs_owned_parameters::invoke_message_owned_iter_loop, .Lfunc_end12-exper_borrowed_vs_owned_parameters::invoke_message_owned_iter_loop diff --git a/asm/invoke_messagemf_borrowed.txt b/asm/invoke_messagemf_borrowed.txt new file mode 100644 index 0000000..8d649c7 --- /dev/null +++ b/asm/invoke_messagemf_borrowed.txt @@ -0,0 +1,121 @@ +.section .text.exper_borrowed_vs_owned_parameters::invoke_messagemf_borrowed,"ax",@progbits + .globl exper_borrowed_vs_owned_parameters::invoke_messagemf_borrowed + .p2align 4, 0x90 + .type exper_borrowed_vs_owned_parameters::invoke_messagemf_borrowed,@function +exper_borrowed_vs_owned_parameters::invoke_messagemf_borrowed: + + // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 99 + pub fn invoke_messagemf_borrowed() { + .cfi_startproc + .cfi_personality 155, DW.ref.rust_eh_personality + .cfi_lsda 27, .Lexception4 + push rbp + .cfi_def_cfa_offset 16 + push r14 + .cfi_def_cfa_offset 24 + push rbx + .cfi_def_cfa_offset 32 + sub rsp, 96 + .cfi_def_cfa_offset 128 + .cfi_offset rbx, -32 + .cfi_offset r14, -24 + .cfi_offset rbp, -16 + lea rdi, [rsp + 8] + + // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 100 + let msg = MessageMf::default(); + call qword ptr [rip + ::default@GOTPCREL] + + // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 101 + let r1 = messagemf_borrowed(&msg); + mov r14, qword ptr [rsp + 8] + mov rbx, qword ptr [rsp + 24] + + mov rdi, r14 + mov rsi, rbx + call exper_borrowed_vs_owned_parameters::messagemf_borrowed + + mov ebp, eax + + // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 102 + let r2 = messagemf_borrowed(&msg); + mov rdi, r14 + mov rsi, rbx + call exper_borrowed_vs_owned_parameters::messagemf_borrowed + + // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 103 + assert!(r1 == 2); + cmp ebp, 2 + jne .LBB11_3 + + // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 104 + assert!(r1 == r2); + cmp eax, 2 + jne .LBB11_7 + + // /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/core/src/ptr/mod.rs : 490 + pub unsafe fn drop_in_place(to_drop: *mut T) { + mov rsi, qword ptr [rsp + 16] + + // /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/alloc/src/raw_vec.rs : 241 + if T::IS_ZST || self.cap == 0 { + test rsi, rsi + je .LBB11_9 + + // /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/core/src/alloc/layout.rs : 452 + if element_size != 0 && n > Layout::max_size_for_align(align) / element_size { + mov rdx, rsi + not rdx + shr rdx, 63 + + // /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/alloc/src/alloc.rs : 113 + unsafe { __rust_dealloc(ptr, layout.size(), layout.align()) } + mov rdi, r14 + add rsp, 96 + .cfi_def_cfa_offset 32 + pop rbx + .cfi_def_cfa_offset 24 + pop r14 + + .cfi_def_cfa_offset 16 + pop rbp + .cfi_def_cfa_offset 8 + jmp qword ptr [rip + __rust_dealloc@GOTPCREL] + +.LBB11_9: + .cfi_def_cfa_offset 128 + // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 105 + } + add rsp, 96 + .cfi_def_cfa_offset 32 + pop rbx + .cfi_def_cfa_offset 24 + pop r14 + .cfi_def_cfa_offset 16 + pop rbp + .cfi_def_cfa_offset 8 + ret +.LBB11_3: + .cfi_def_cfa_offset 128 + lea rdx, [rip + .L__unnamed_11] + mov esi, 25 + lea rdi, [rip + .L__unnamed_6] + jmp .LBB11_4 +.LBB11_7: + lea rdx, [rip + .L__unnamed_12] + mov esi, 26 + lea rdi, [rip + .L__unnamed_8] +.LBB11_4: + + call qword ptr [rip + core::panicking::panic@GOTPCREL] + + ud2 + + mov rbx, rax + lea rdi, [rsp + 8] + call core::ptr::drop_in_place + mov rdi, rbx + call _Unwind_Resume@PLT + ud2 + + .size exper_borrowed_vs_owned_parameters::invoke_messagemf_borrowed, .Lfunc_end11-exper_borrowed_vs_owned_parameters::invoke_messagemf_borrowed diff --git a/asm/invoke_messagemf_default.txt b/asm/invoke_messagemf_default.txt new file mode 100644 index 0000000..8b3fed4 --- /dev/null +++ b/asm/invoke_messagemf_default.txt @@ -0,0 +1,51 @@ +.section .text.exper_borrowed_vs_owned_parameters::invoke_messagemf_default,"ax",@progbits + .globl exper_borrowed_vs_owned_parameters::invoke_messagemf_default + .p2align 4, 0x90 + .type exper_borrowed_vs_owned_parameters::invoke_messagemf_default,@function +exper_borrowed_vs_owned_parameters::invoke_messagemf_default: + + // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 77 + pub fn invoke_messagemf_default() { + .cfi_startproc + sub rsp, 88 + .cfi_def_cfa_offset 96 + mov rdi, rsp + + // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 78 + MessageMf::default(); + call qword ptr [rip + ::default@GOTPCREL] + + // /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/core/src/ptr/mod.rs : 490 + pub unsafe fn drop_in_place(to_drop: *mut T) { + mov rsi, qword ptr [rsp + 8] + + // /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/alloc/src/raw_vec.rs : 241 + if T::IS_ZST || self.cap == 0 { + test rsi, rsi + je .LBB8_1 + + // /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/core/src/ptr/mod.rs : 490 + pub unsafe fn drop_in_place(to_drop: *mut T) { + mov rdi, qword ptr [rsp] + + // /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/core/src/alloc/layout.rs : 452 + if element_size != 0 && n > Layout::max_size_for_align(align) / element_size { + mov rdx, rsi + not rdx + shr rdx, 63 + + // /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/alloc/src/alloc.rs : 113 + unsafe { __rust_dealloc(ptr, layout.size(), layout.align()) } + add rsp, 88 + .cfi_def_cfa_offset 8 + jmp qword ptr [rip + __rust_dealloc@GOTPCREL] + +.LBB8_1: + .cfi_def_cfa_offset 96 + // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 79 + } + add rsp, 88 + .cfi_def_cfa_offset 8 + ret + + .size exper_borrowed_vs_owned_parameters::invoke_messagemf_default, .Lfunc_end8-exper_borrowed_vs_owned_parameters::invoke_messagemf_default diff --git a/asm/invoke_messagemf_owned.txt b/asm/invoke_messagemf_owned.txt new file mode 100644 index 0000000..1f23b94 --- /dev/null +++ b/asm/invoke_messagemf_owned.txt @@ -0,0 +1,152 @@ +.section .text.exper_borrowed_vs_owned_parameters::invoke_messagemf_owned,"ax",@progbits + .globl exper_borrowed_vs_owned_parameters::invoke_messagemf_owned + .p2align 4, 0x90 + .type exper_borrowed_vs_owned_parameters::invoke_messagemf_owned,@function +exper_borrowed_vs_owned_parameters::invoke_messagemf_owned: + + // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 108 + pub fn invoke_messagemf_owned() { + .cfi_startproc + .cfi_personality 155, DW.ref.rust_eh_personality + .cfi_lsda 27, .Lexception5 + push rbx + .cfi_def_cfa_offset 16 + sub rsp, 368 + .cfi_def_cfa_offset 384 + .cfi_offset rbx, -16 + lea rdi, [rsp + 184] + + // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 109 + let msg = MessageMf::default(); + call qword ptr [rip + ::default@GOTPCREL] + + // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 110 + let (r1, msg) = messagemf_owned(msg); + mov rax, qword ptr [rsp + 264] + mov qword ptr [rsp + 80], rax + movups xmm0, xmmword ptr [rsp + 248] + movaps xmmword ptr [rsp + 64], xmm0 + movups xmm0, xmmword ptr [rsp + 184] + movups xmm1, xmmword ptr [rsp + 200] + movups xmm2, xmmword ptr [rsp + 216] + movups xmm3, xmmword ptr [rsp + 232] + movaps xmmword ptr [rsp + 48], xmm3 + movaps xmmword ptr [rsp + 32], xmm2 + movaps xmmword ptr [rsp + 16], xmm1 + movaps xmmword ptr [rsp], xmm0 + lea rdi, [rsp + 88] + mov rsi, rsp + call exper_borrowed_vs_owned_parameters::messagemf_owned + mov ebx, dword ptr [rsp + 88] + + mov rax, qword ptr [rsp + 176] + mov qword ptr [rsp + 352], rax + movups xmm0, xmmword ptr [rsp + 160] + movaps xmmword ptr [rsp + 336], xmm0 + movups xmm1, xmmword ptr [rsp + 144] + movaps xmmword ptr [rsp + 320], xmm1 + movups xmm2, xmmword ptr [rsp + 128] + movaps xmmword ptr [rsp + 304], xmm2 + movups xmm3, xmmword ptr [rsp + 112] + movaps xmmword ptr [rsp + 288], xmm3 + movups xmm4, xmmword ptr [rsp + 96] + movaps xmmword ptr [rsp + 272], xmm4 + + // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 111 + let (r2, _msg) = messagemf_owned(msg); + mov qword ptr [rsp + 80], rax + movaps xmmword ptr [rsp + 64], xmm0 + movaps xmmword ptr [rsp + 48], xmm1 + movaps xmmword ptr [rsp + 32], xmm2 + movaps xmmword ptr [rsp + 16], xmm3 + movaps xmmword ptr [rsp], xmm4 + lea rdi, [rsp + 88] + mov rsi, rsp + call exper_borrowed_vs_owned_parameters::messagemf_owned + mov eax, dword ptr [rsp + 88] + + mov rcx, qword ptr [rsp + 176] + mov qword ptr [rsp + 80], rcx + movups xmm0, xmmword ptr [rsp + 160] + movaps xmmword ptr [rsp + 64], xmm0 + movups xmm0, xmmword ptr [rsp + 144] + movaps xmmword ptr [rsp + 48], xmm0 + movups xmm0, xmmword ptr [rsp + 128] + movaps xmmword ptr [rsp + 32], xmm0 + movups xmm0, xmmword ptr [rsp + 112] + movaps xmmword ptr [rsp + 16], xmm0 + movups xmm0, xmmword ptr [rsp + 96] + movaps xmmword ptr [rsp], xmm0 + + // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 112 + assert!(r1 == 2); + cmp ebx, 2 + jne .LBB12_1 + + // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 113 + assert!(r1 == r2); + cmp eax, 2 + jne .LBB12_5 + + // /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/core/src/ptr/mod.rs : 490 + pub unsafe fn drop_in_place(to_drop: *mut T) { + mov rsi, qword ptr [rsp + 8] + + // /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/alloc/src/raw_vec.rs : 241 + if T::IS_ZST || self.cap == 0 { + test rsi, rsi + je .LBB12_8 + + // /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/core/src/ptr/mod.rs : 490 + pub unsafe fn drop_in_place(to_drop: *mut T) { + mov rdi, qword ptr [rsp] + + // /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/core/src/alloc/layout.rs : 452 + if element_size != 0 && n > Layout::max_size_for_align(align) / element_size { + mov rdx, rsi + not rdx + shr rdx, 63 + + // /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/alloc/src/alloc.rs : 113 + unsafe { __rust_dealloc(ptr, layout.size(), layout.align()) } + add rsp, 368 + .cfi_def_cfa_offset 16 + pop rbx + + .cfi_def_cfa_offset 8 + jmp qword ptr [rip + __rust_dealloc@GOTPCREL] + +.LBB12_8: + .cfi_def_cfa_offset 384 + // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 114 + } + add rsp, 368 + .cfi_def_cfa_offset 16 + pop rbx + .cfi_def_cfa_offset 8 + ret +.LBB12_1: + .cfi_def_cfa_offset 384 + lea rdx, [rip + .L__unnamed_13] + mov esi, 25 + lea rdi, [rip + .L__unnamed_6] + jmp .LBB12_2 +.LBB12_5: + lea rdx, [rip + .L__unnamed_14] + mov esi, 26 + lea rdi, [rip + .L__unnamed_8] +.LBB12_2: + + call qword ptr [rip + core::panicking::panic@GOTPCREL] + + ud2 + + mov rbx, rax + + mov rdi, rsp + call core::ptr::drop_in_place + mov rdi, rbx + call _Unwind_Resume@PLT + ud2 + + .size exper_borrowed_vs_owned_parameters::invoke_messagemf_owned, .Lfunc_end12-exper_borrowed_vs_owned_parameters::invoke_messagemf_owned diff --git a/asm/message_borrowed.txt b/asm/message_borrowed.txt index 6bcf64e..43b1bdd 100644 --- a/asm/message_borrowed.txt +++ b/asm/message_borrowed.txt @@ -3,7 +3,7 @@ .type exper_borrowed_vs_owned_parameters::message_borrowed,@function exper_borrowed_vs_owned_parameters::message_borrowed: - // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 10 + // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 52 fn message_borrowed(msg: &Message) -> u32 { .cfi_startproc push rax @@ -12,17 +12,17 @@ exper_borrowed_vs_owned_parameters::message_borrowed: // /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/core/src/slice/index.rs : 259 &(*slice)[self] test rsi, rsi - je .LBB1_1 + je .LBB3_1 - // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 11 + // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 53 msg.v[0] as u32 movzx eax, byte ptr [rdi] - // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 12 + // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 54 } pop rcx .cfi_def_cfa_offset 8 ret -.LBB1_1: +.LBB3_1: .cfi_def_cfa_offset 16 // /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/core/src/slice/index.rs : 259 @@ -35,4 +35,4 @@ exper_borrowed_vs_owned_parameters::message_borrowed: call qword ptr [rip + core::panicking::panic_bounds_check@GOTPCREL] ud2 - .size exper_borrowed_vs_owned_parameters::message_borrowed, .Lfunc_end1-exper_borrowed_vs_owned_parameters::message_borrowed + .size exper_borrowed_vs_owned_parameters::message_borrowed, .Lfunc_end3-exper_borrowed_vs_owned_parameters::message_borrowed diff --git a/asm/message_borrowed_idx_loop.txt b/asm/message_borrowed_idx_loop.txt deleted file mode 100644 index d3a2a63..0000000 --- a/asm/message_borrowed_idx_loop.txt +++ /dev/null @@ -1,141 +0,0 @@ -.section .text.exper_borrowed_vs_owned_parameters::message_borrowed_idx_loop,"ax",@progbits - .p2align 4, 0x90 - .type exper_borrowed_vs_owned_parameters::message_borrowed_idx_loop,@function -exper_borrowed_vs_owned_parameters::message_borrowed_idx_loop: - - // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 15 - fn message_borrowed_idx_loop(msg: &Message) -> u32 { - .cfi_startproc - // /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/core/src/cmp.rs : 1464 - fn lt(&self, other: &$t) -> bool { (*self) < (*other) } - test rsi, rsi - - // /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/core/src/iter/range.rs : 621 - if self.start < self.end { - je .LBB2_1 - - cmp rsi, 8 - jae .LBB2_4 - - xor eax, eax - xor ecx, ecx - jmp .LBB2_11 -.LBB2_1: - xor eax, eax - // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 21 - } - ret -.LBB2_4: - - // /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/core/src/iter/range.rs : 621 - if self.start < self.end { - mov rcx, rsi - and rcx, -8 - lea rax, [rcx - 8] - mov r8, rax - shr r8, 3 - inc r8 - test rax, rax - je .LBB2_5 - - mov rax, r8 - and rax, -2 - pxor xmm2, xmm2 - xor edx, edx - pxor xmm0, xmm0 - pxor xmm1, xmm1 - - .p2align 4, 0x90 -.LBB2_7: - // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 18 - sum += msg.v[i] as u32 - movd xmm3, dword ptr [rdi + rdx] - movd xmm4, dword ptr [rdi + rdx + 4] - punpcklbw xmm3, xmm2 - punpcklwd xmm3, xmm2 - paddd xmm3, xmm0 - punpcklbw xmm4, xmm2 - punpcklwd xmm4, xmm2 - paddd xmm4, xmm1 - movd xmm0, dword ptr [rdi + rdx + 8] - movd xmm1, dword ptr [rdi + rdx + 12] - punpcklbw xmm0, xmm2 - punpcklwd xmm0, xmm2 - paddd xmm0, xmm3 - punpcklbw xmm1, xmm2 - punpcklwd xmm1, xmm2 - paddd xmm1, xmm4 - - // /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/core/src/num/uint_macros.rs : 470 - unsafe { intrinsics::unchecked_add(self, rhs) } - add rdx, 16 - add rax, -2 - jne .LBB2_7 - - test r8b, 1 - je .LBB2_10 - -.LBB2_9: - // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 18 - sum += msg.v[i] as u32 - movd xmm2, dword ptr [rdi + rdx] - movd xmm3, dword ptr [rdi + rdx + 4] - pxor xmm4, xmm4 - punpcklbw xmm2, xmm4 - punpcklwd xmm2, xmm4 - paddd xmm0, xmm2 - punpcklbw xmm3, xmm4 - punpcklwd xmm3, xmm4 - paddd xmm1, xmm3 - -.LBB2_10: - // /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/core/src/iter/range.rs : 621 - if self.start < self.end { - paddd xmm0, xmm1 - pshufd xmm1, xmm0, 238 - paddd xmm1, xmm0 - pshufd xmm0, xmm1, 85 - paddd xmm0, xmm1 - movd eax, xmm0 - cmp rcx, rsi - je .LBB2_12 - - .p2align 4, 0x90 -.LBB2_11: - // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 18 - sum += msg.v[i] as u32 - movzx edx, byte ptr [rdi + rcx] - - // /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/core/src/num/uint_macros.rs : 470 - unsafe { intrinsics::unchecked_add(self, rhs) } - inc rcx - - // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 18 - sum += msg.v[i] as u32 - add eax, edx - - // /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/core/src/cmp.rs : 1464 - fn lt(&self, other: &$t) -> bool { (*self) < (*other) } - cmp rsi, rcx - - // /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/core/src/iter/range.rs : 621 - if self.start < self.end { - jne .LBB2_11 - -.LBB2_12: - // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 21 - } - ret -.LBB2_5: - - pxor xmm0, xmm0 - xor edx, edx - pxor xmm1, xmm1 - - // /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/core/src/num/uint_macros.rs : 470 - unsafe { intrinsics::unchecked_add(self, rhs) } - test r8b, 1 - jne .LBB2_9 - jmp .LBB2_10 - - .size exper_borrowed_vs_owned_parameters::message_borrowed_idx_loop, .Lfunc_end2-exper_borrowed_vs_owned_parameters::message_borrowed_idx_loop diff --git a/asm/message_borrowed_iter_loop.txt b/asm/message_borrowed_iter_loop.txt deleted file mode 100644 index 831385f..0000000 --- a/asm/message_borrowed_iter_loop.txt +++ /dev/null @@ -1,123 +0,0 @@ -.section .text.exper_borrowed_vs_owned_parameters::message_borrowed_iter_loop,"ax",@progbits - .p2align 4, 0x90 - .type exper_borrowed_vs_owned_parameters::message_borrowed_iter_loop,@function -exper_borrowed_vs_owned_parameters::message_borrowed_iter_loop: - - // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 24 - fn message_borrowed_iter_loop(msg: &Message) -> u32 { - .cfi_startproc - xor eax, eax - - // /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/core/src/slice/iter/macros.rs : 146 - if is_empty!(self) { - test rsi, rsi - je .LBB3_12 - - mov rcx, rdi - cmp rsi, 8 - jb .LBB3_10 - - mov rcx, rsi - and rcx, -8 - lea rax, [rcx - 8] - mov r8, rax - shr r8, 3 - inc r8 - test rax, rax - je .LBB3_3 - - mov rax, r8 - and rax, -2 - pxor xmm2, xmm2 - xor edx, edx - pxor xmm0, xmm0 - pxor xmm1, xmm1 - - .p2align 4, 0x90 -.LBB3_5: - // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 27 - sum += *v as u32 - movd xmm3, dword ptr [rdi + rdx] - movd xmm4, dword ptr [rdi + rdx + 4] - punpcklbw xmm3, xmm2 - punpcklwd xmm3, xmm2 - paddd xmm3, xmm0 - punpcklbw xmm4, xmm2 - punpcklwd xmm4, xmm2 - paddd xmm4, xmm1 - movd xmm0, dword ptr [rdi + rdx + 8] - movd xmm1, dword ptr [rdi + rdx + 12] - punpcklbw xmm0, xmm2 - punpcklwd xmm0, xmm2 - paddd xmm0, xmm3 - punpcklbw xmm1, xmm2 - punpcklwd xmm1, xmm2 - paddd xmm1, xmm4 - add rdx, 16 - add rax, -2 - jne .LBB3_5 - - test r8b, 1 - je .LBB3_8 - -.LBB3_7: - movd xmm2, dword ptr [rdi + rdx] - movd xmm3, dword ptr [rdi + rdx + 4] - pxor xmm4, xmm4 - punpcklbw xmm2, xmm4 - punpcklwd xmm2, xmm4 - paddd xmm0, xmm2 - punpcklbw xmm3, xmm4 - punpcklwd xmm3, xmm4 - paddd xmm1, xmm3 - -.LBB3_8: - // /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/core/src/slice/iter/macros.rs : 146 - if is_empty!(self) { - paddd xmm0, xmm1 - pshufd xmm1, xmm0, 238 - paddd xmm1, xmm0 - pshufd xmm0, xmm1, 85 - paddd xmm0, xmm1 - movd eax, xmm0 - cmp rcx, rsi - je .LBB3_12 - - add rcx, rdi - -.LBB3_10: - add rdi, rsi - - .p2align 4, 0x90 -.LBB3_11: - // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 27 - sum += *v as u32 - movzx edx, byte ptr [rcx] - - // /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/core/src/ptr/mut_ptr.rs : 485 - unsafe { intrinsics::offset(self, count) as *mut T } - inc rcx - - // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 27 - sum += *v as u32 - add eax, edx - - // /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/core/src/slice/iter/macros.rs : 146 - if is_empty!(self) { - cmp rcx, rdi - jne .LBB3_11 - -.LBB3_12: - // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 30 - } - ret - -.LBB3_3: - pxor xmm0, xmm0 - xor edx, edx - pxor xmm1, xmm1 - test r8b, 1 - jne .LBB3_7 - jmp .LBB3_8 - - .size exper_borrowed_vs_owned_parameters::message_borrowed_iter_loop, .Lfunc_end3-exper_borrowed_vs_owned_parameters::message_borrowed_iter_loop diff --git a/asm/message_owned.txt b/asm/message_owned.txt index 642b5e7..bf2b0d1 100644 --- a/asm/message_owned.txt +++ b/asm/message_owned.txt @@ -3,7 +3,7 @@ .type exper_borrowed_vs_owned_parameters::message_owned,@function exper_borrowed_vs_owned_parameters::message_owned: - // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 33 + // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 57 fn message_owned(msg: Message) -> (u32, Message) { .cfi_startproc .cfi_personality 155, DW.ref.rust_eh_personality @@ -23,7 +23,7 @@ exper_borrowed_vs_owned_parameters::message_owned: cmp qword ptr [rsi + 16], 0 je .LBB4_1 - // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 34 + // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 58 (msg.v[0] as u32, msg) mov rax, qword ptr [rbx] mov rcx, qword ptr [rbx + 16] @@ -32,7 +32,7 @@ exper_borrowed_vs_owned_parameters::message_owned: movups xmm0, xmmword ptr [rbx] movups xmmword ptr [rdi + 8], xmm0 mov dword ptr [rdi], eax - // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 35 + // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 59 } add rsp, 8 .cfi_def_cfa_offset 24 @@ -56,7 +56,7 @@ exper_borrowed_vs_owned_parameters::message_owned: ud2 mov r14, rax - // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 35 + // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 59 } mov rdi, rbx call core::ptr::drop_in_place diff --git a/asm/message_owned_idx_loop.txt b/asm/message_owned_idx_loop.txt deleted file mode 100644 index fd4f70e..0000000 --- a/asm/message_owned_idx_loop.txt +++ /dev/null @@ -1,147 +0,0 @@ -.section .text.exper_borrowed_vs_owned_parameters::message_owned_idx_loop,"ax",@progbits - .p2align 4, 0x90 - .type exper_borrowed_vs_owned_parameters::message_owned_idx_loop,@function -exper_borrowed_vs_owned_parameters::message_owned_idx_loop: - - // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 38 - fn message_owned_idx_loop(msg: Message) -> (u32, Message) { - .cfi_startproc - // /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/alloc/src/vec/mod.rs : 2056 - self.len - mov r9, qword ptr [rsi + 16] - - // /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/core/src/cmp.rs : 1464 - fn lt(&self, other: &$t) -> bool { (*self) < (*other) } - test r9, r9 - - // /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/core/src/iter/range.rs : 621 - if self.start < self.end { - je .LBB5_1 - - mov r10, qword ptr [rsi] - cmp r9, 8 - jae .LBB5_5 - - xor eax, eax - xor edx, edx - jmp .LBB5_4 - -.LBB5_1: - xor eax, eax - jmp .LBB5_13 - -.LBB5_5: - mov rdx, r9 - and rdx, -8 - lea rax, [rdx - 8] - mov r8, rax - shr r8, 3 - inc r8 - test rax, rax - je .LBB5_6 - - mov rcx, r8 - and rcx, -2 - pxor xmm2, xmm2 - xor eax, eax - pxor xmm0, xmm0 - pxor xmm1, xmm1 - - .p2align 4, 0x90 -.LBB5_8: - // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 41 - sum += msg.v[i] as u32 - movd xmm3, dword ptr [r10 + rax] - movd xmm4, dword ptr [r10 + rax + 4] - punpcklbw xmm3, xmm2 - punpcklwd xmm3, xmm2 - paddd xmm3, xmm0 - punpcklbw xmm4, xmm2 - punpcklwd xmm4, xmm2 - paddd xmm4, xmm1 - movd xmm0, dword ptr [r10 + rax + 8] - movd xmm1, dword ptr [r10 + rax + 12] - punpcklbw xmm0, xmm2 - punpcklwd xmm0, xmm2 - paddd xmm0, xmm3 - punpcklbw xmm1, xmm2 - punpcklwd xmm1, xmm2 - paddd xmm1, xmm4 - - // /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/core/src/num/uint_macros.rs : 470 - unsafe { intrinsics::unchecked_add(self, rhs) } - add rax, 16 - add rcx, -2 - jne .LBB5_8 - - test r8b, 1 - je .LBB5_11 - -.LBB5_10: - // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 41 - sum += msg.v[i] as u32 - movd xmm2, dword ptr [r10 + rax] - movd xmm3, dword ptr [r10 + rax + 4] - pxor xmm4, xmm4 - punpcklbw xmm2, xmm4 - punpcklwd xmm2, xmm4 - paddd xmm0, xmm2 - punpcklbw xmm3, xmm4 - punpcklwd xmm3, xmm4 - paddd xmm1, xmm3 - -.LBB5_11: - // /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/core/src/iter/range.rs : 621 - if self.start < self.end { - paddd xmm0, xmm1 - pshufd xmm1, xmm0, 238 - paddd xmm1, xmm0 - pshufd xmm0, xmm1, 85 - paddd xmm0, xmm1 - movd eax, xmm0 - jmp .LBB5_12 - -.LBB5_6: - pxor xmm0, xmm0 - xor eax, eax - pxor xmm1, xmm1 - - // /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/core/src/num/uint_macros.rs : 470 - unsafe { intrinsics::unchecked_add(self, rhs) } - test r8b, 1 - jne .LBB5_10 - jmp .LBB5_11 - -.LBB5_4: - // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 41 - sum += msg.v[i] as u32 - movzx ecx, byte ptr [r10 + rdx] - - // /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/core/src/num/uint_macros.rs : 470 - unsafe { intrinsics::unchecked_add(self, rhs) } - inc rdx - - // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 41 - sum += msg.v[i] as u32 - add eax, ecx - -.LBB5_12: - cmp r9, rdx - // /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/core/src/iter/range.rs : 621 - if self.start < self.end { - jne .LBB5_4 - -.LBB5_13: - // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 43 - (sum, msg) - mov rcx, qword ptr [rsi + 16] - mov qword ptr [rdi + 24], rcx - movups xmm0, xmmword ptr [rsi] - movups xmmword ptr [rdi + 8], xmm0 - mov dword ptr [rdi], eax - - // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 44 - } - ret - - .size exper_borrowed_vs_owned_parameters::message_owned_idx_loop, .Lfunc_end5-exper_borrowed_vs_owned_parameters::message_owned_idx_loop diff --git a/asm/message_owned_iter_loop.txt b/asm/message_owned_iter_loop.txt deleted file mode 100644 index 7f1ac9d..0000000 --- a/asm/message_owned_iter_loop.txt +++ /dev/null @@ -1,140 +0,0 @@ -.section .text.exper_borrowed_vs_owned_parameters::message_owned_iter_loop,"ax",@progbits - .p2align 4, 0x90 - .type exper_borrowed_vs_owned_parameters::message_owned_iter_loop,@function -exper_borrowed_vs_owned_parameters::message_owned_iter_loop: - - // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 48 - fn message_owned_iter_loop(msg: Message) -> (u32, Message) { - .cfi_startproc - // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 50 - for v in msg.v.iter() { - mov r9, qword ptr [rsi + 16] - - // /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/core/src/slice/iter/macros.rs : 146 - if is_empty!(self) { - test r9, r9 - je .LBB6_1 - - mov r10, qword ptr [rsi] - - xor eax, eax - mov rcx, r10 - cmp r9, 8 - jb .LBB6_11 - - mov rcx, r9 - and rcx, -8 - lea rax, [rcx - 8] - mov r8, rax - shr r8, 3 - inc r8 - test rax, rax - je .LBB6_4 - - mov rax, r8 - and rax, -2 - pxor xmm2, xmm2 - xor edx, edx - pxor xmm0, xmm0 - pxor xmm1, xmm1 - - .p2align 4, 0x90 -.LBB6_6: - // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 51 - sum += *v as u32 - movd xmm3, dword ptr [r10 + rdx] - movd xmm4, dword ptr [r10 + rdx + 4] - punpcklbw xmm3, xmm2 - punpcklwd xmm3, xmm2 - paddd xmm3, xmm0 - punpcklbw xmm4, xmm2 - punpcklwd xmm4, xmm2 - paddd xmm4, xmm1 - movd xmm0, dword ptr [r10 + rdx + 8] - movd xmm1, dword ptr [r10 + rdx + 12] - punpcklbw xmm0, xmm2 - punpcklwd xmm0, xmm2 - paddd xmm0, xmm3 - punpcklbw xmm1, xmm2 - punpcklwd xmm1, xmm2 - paddd xmm1, xmm4 - add rdx, 16 - add rax, -2 - jne .LBB6_6 - - test r8b, 1 - je .LBB6_9 - -.LBB6_8: - movd xmm2, dword ptr [r10 + rdx] - movd xmm3, dword ptr [r10 + rdx + 4] - pxor xmm4, xmm4 - punpcklbw xmm2, xmm4 - punpcklwd xmm2, xmm4 - paddd xmm0, xmm2 - punpcklbw xmm3, xmm4 - punpcklwd xmm3, xmm4 - paddd xmm1, xmm3 - -.LBB6_9: - // /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/core/src/slice/iter/macros.rs : 146 - if is_empty!(self) { - paddd xmm0, xmm1 - pshufd xmm1, xmm0, 238 - paddd xmm1, xmm0 - pshufd xmm0, xmm1, 85 - paddd xmm0, xmm1 - movd eax, xmm0 - cmp r9, rcx - je .LBB6_13 - - add rcx, r10 - -.LBB6_11: - add r10, r9 - - .p2align 4, 0x90 -.LBB6_12: - // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 51 - sum += *v as u32 - movzx edx, byte ptr [rcx] - - // /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/core/src/ptr/mut_ptr.rs : 485 - unsafe { intrinsics::offset(self, count) as *mut T } - inc rcx - - // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 51 - sum += *v as u32 - add eax, edx - - // /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/core/src/slice/iter/macros.rs : 146 - if is_empty!(self) { - cmp rcx, r10 - jne .LBB6_12 - jmp .LBB6_13 - -.LBB6_1: - xor eax, eax - -.LBB6_13: - // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 53 - (sum, msg) - mov rcx, qword ptr [rsi + 16] - mov qword ptr [rdi + 24], rcx - movups xmm0, xmmword ptr [rsi] - movups xmmword ptr [rdi + 8], xmm0 - mov dword ptr [rdi], eax - - // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 54 - } - ret - -.LBB6_4: - pxor xmm0, xmm0 - xor edx, edx - pxor xmm1, xmm1 - test r8b, 1 - jne .LBB6_8 - jmp .LBB6_9 - - .size exper_borrowed_vs_owned_parameters::message_owned_iter_loop, .Lfunc_end6-exper_borrowed_vs_owned_parameters::message_owned_iter_loop diff --git a/asm/messagemf_borrowed.txt b/asm/messagemf_borrowed.txt new file mode 100644 index 0000000..98bec0a --- /dev/null +++ b/asm/messagemf_borrowed.txt @@ -0,0 +1,38 @@ +.section .text.exper_borrowed_vs_owned_parameters::messagemf_borrowed,"ax",@progbits + .p2align 4, 0x90 + .type exper_borrowed_vs_owned_parameters::messagemf_borrowed,@function +exper_borrowed_vs_owned_parameters::messagemf_borrowed: + + // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 62 + fn messagemf_borrowed(msg: &MessageMf) -> u32 { + .cfi_startproc + push rax + .cfi_def_cfa_offset 16 + + // /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/core/src/slice/index.rs : 259 + &(*slice)[self] + test rsi, rsi + je .LBB5_1 + + // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 63 + msg.v[0] as u32 + movzx eax, byte ptr [rdi] + // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 64 + } + pop rcx + .cfi_def_cfa_offset 8 + ret +.LBB5_1: + .cfi_def_cfa_offset 16 + + // /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/core/src/slice/index.rs : 259 + &(*slice)[self] + lea rdx, [rip + .L__unnamed_3] + xor edi, edi + + xor esi, esi + + call qword ptr [rip + core::panicking::panic_bounds_check@GOTPCREL] + ud2 + + .size exper_borrowed_vs_owned_parameters::messagemf_borrowed, .Lfunc_end5-exper_borrowed_vs_owned_parameters::messagemf_borrowed diff --git a/asm/messagemf_owned.txt b/asm/messagemf_owned.txt new file mode 100644 index 0000000..450ee7f --- /dev/null +++ b/asm/messagemf_owned.txt @@ -0,0 +1,75 @@ +.section .text.exper_borrowed_vs_owned_parameters::messagemf_owned,"ax",@progbits + .p2align 4, 0x90 + .type exper_borrowed_vs_owned_parameters::messagemf_owned,@function +exper_borrowed_vs_owned_parameters::messagemf_owned: + + // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 67 + fn messagemf_owned(msg: MessageMf) -> (u32, MessageMf) { + .cfi_startproc + .cfi_personality 155, DW.ref.rust_eh_personality + .cfi_lsda 27, .Lexception1 + push r14 + .cfi_def_cfa_offset 16 + push rbx + .cfi_def_cfa_offset 24 + push rax + .cfi_def_cfa_offset 32 + .cfi_offset rbx, -24 + .cfi_offset r14, -16 + mov rbx, rsi + + // /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/core/src/slice/index.rs : 259 + &(*slice)[self] + cmp qword ptr [rsi + 16], 0 + je .LBB6_1 + + // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 68 + (msg.v[0] as u32, msg) + mov rax, qword ptr [rbx] + movzx eax, byte ptr [rax] + mov rcx, qword ptr [rbx + 80] + mov qword ptr [rdi + 88], rcx + movups xmm0, xmmword ptr [rbx + 64] + movups xmmword ptr [rdi + 72], xmm0 + movups xmm0, xmmword ptr [rbx] + movups xmm1, xmmword ptr [rbx + 16] + movups xmm2, xmmword ptr [rbx + 32] + movups xmm3, xmmword ptr [rbx + 48] + movups xmmword ptr [rdi + 56], xmm3 + movups xmmword ptr [rdi + 40], xmm2 + movups xmmword ptr [rdi + 24], xmm1 + movups xmmword ptr [rdi + 8], xmm0 + mov dword ptr [rdi], eax + // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 69 + } + add rsp, 8 + .cfi_def_cfa_offset 24 + pop rbx + + .cfi_def_cfa_offset 16 + pop r14 + .cfi_def_cfa_offset 8 + ret + +.LBB6_1: + .cfi_def_cfa_offset 32 + + // /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/core/src/slice/index.rs : 259 + &(*slice)[self] + lea rdx, [rip + .L__unnamed_4] + xor edi, edi + xor esi, esi + call qword ptr [rip + core::panicking::panic_bounds_check@GOTPCREL] + + ud2 + + mov r14, rax + // /home/wink/prgs/rust/myrepos/exper-borrowed-vs-owned-parameters/src/lib.rs : 69 + } + mov rdi, rbx + call core::ptr::drop_in_place + mov rdi, r14 + call _Unwind_Resume@PLT + ud2 + + .size exper_borrowed_vs_owned_parameters::messagemf_owned, .Lfunc_end6-exper_borrowed_vs_owned_parameters::messagemf_owned diff --git a/benches/bench.rs b/benches/bench.rs index 04ea8f1..79bcbf8 100644 --- a/benches/bench.rs +++ b/benches/bench.rs @@ -1,13 +1,13 @@ use exper_borrowed_vs_owned_parameters::{ - invoke_message_borrowed, invoke_message_borrowed_idx_loop, invoke_message_borrowed_iter_loop, - invoke_message_owned, invoke_message_owned_idx_loop, invoke_message_owned_iter_loop, + invoke_message_borrowed, invoke_message_default, invoke_message_owned, + invoke_messagemf_borrowed, invoke_messagemf_default, invoke_messagemf_owned, }; iai::main!( + invoke_message_default, + invoke_messagemf_default, invoke_message_borrowed, - invoke_message_borrowed_idx_loop, - invoke_message_borrowed_iter_loop, invoke_message_owned, - invoke_message_owned_idx_loop, - invoke_message_owned_iter_loop, + invoke_messagemf_borrowed, + invoke_messagemf_owned, ); diff --git a/gen_asm.sh b/gen_asm.sh index f348f87..27358ac 100755 --- a/gen_asm.sh +++ b/gen_asm.sh @@ -11,14 +11,12 @@ gen_asm () { } gen_asm "message_borrowed" -gen_asm "message_borrowed_idx_loop" -gen_asm "message_borrowed_iter_loop" gen_asm "message_owned" -gen_asm "message_owned_idx_loop" -gen_asm "message_owned_iter_loop" +gen_asm "messagemf_borrowed" +gen_asm "messagemf_owned" +gen_asm "invoke_message_default" +gen_asm "invoke_messagemf_default" gen_asm "invoke_message_borrowed" -gen_asm "invoke_message_borrowed_idx_loop" -gen_asm "invoke_message_borrowed_iter_loop" gen_asm "invoke_message_owned" -gen_asm "invoke_message_owned_idx_loop" -gen_asm "invoke_message_owned_iter_loop" +gen_asm "invoke_messagemf_borrowed" +gen_asm "invoke_messagemf_owned" diff --git a/src/lib.rs b/src/lib.rs index ac9110e..8f1bfad 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,32 +1,56 @@ /// Investigate the difference between borrowed and /// owned parameters to functions. - +// Message with one vector field struct Message { v: Vec, } -#[inline(never)] -fn message_borrowed(msg: &Message) -> u32 { - msg.v[0] as u32 +impl Default for Message { + #[inline(never)] + fn default() -> Self { + Self { v: vec![2] } + } } -#[inline(never)] -fn message_borrowed_idx_loop(msg: &Message) -> u32 { - let mut sum = 0u32; - for i in 0..msg.v.len() { - sum += msg.v[i] as u32 +// Message with many fields +#[allow(unused)] +struct MessageMf { + v: Vec, + fu128: u128, + fu64: u64, + fu32: u32, + fu16: u16, + fu8: u8, + fi128: i128, + fi64: i64, + fi32: i32, + fi16: i16, + fi8: i8, +} + +impl Default for MessageMf { + #[inline(never)] + fn default() -> Self { + Self { + v: vec![2], + fu128: 128, + fu64: 64, + fu32: 32, + fu16: 16, + fu8: 8, + fi128: 128, + fi64: 64, + fi32: 32, + fi16: 16, + fi8: 8, + } } - sum } #[inline(never)] -fn message_borrowed_iter_loop(msg: &Message) -> u32 { - let mut sum = 0u32; - for v in msg.v.iter() { - sum += *v as u32 - } - sum +fn message_borrowed(msg: &Message) -> u32 { + msg.v[0] as u32 } #[inline(never)] @@ -35,74 +59,56 @@ fn message_owned(msg: Message) -> (u32, Message) { } #[inline(never)] -fn message_owned_idx_loop(msg: Message) -> (u32, Message) { - let mut sum = 0u32; - for i in 0..msg.v.len() { - sum += msg.v[i] as u32 - } - (sum, msg) +fn messagemf_borrowed(msg: &MessageMf) -> u32 { + msg.v[0] as u32 } - #[inline(never)] -fn message_owned_iter_loop(msg: Message) -> (u32, Message) { - let mut sum = 0u32; - for v in msg.v.iter() { - sum += *v as u32 - } - (sum, msg) +fn messagemf_owned(msg: MessageMf) -> (u32, MessageMf) { + (msg.v[0] as u32, msg) } #[inline(never)] -pub fn invoke_message_borrowed() { - let msg = Message { v: vec![2] }; - let r1 = message_borrowed(&msg); - let r2 = message_borrowed(&msg); - assert!(r1 == 2); - assert!(r1 == r2); +pub fn invoke_message_default() { + Message::default(); } #[inline(never)] -pub fn invoke_message_borrowed_idx_loop() { - let msg = Message { v: vec![2] }; - let r1 = message_borrowed_idx_loop(&msg); - let r2 = message_borrowed_idx_loop(&msg); - assert!(r1 == 2); - assert!(r1 == r2); +pub fn invoke_messagemf_default() { + MessageMf::default(); } #[inline(never)] -pub fn invoke_message_borrowed_iter_loop() { - let msg = Message { v: vec![2] }; - let r1 = message_borrowed_iter_loop(&msg); - let r2 = message_borrowed_iter_loop(&msg); +pub fn invoke_message_borrowed() { + let msg = Message::default(); + let r1 = message_borrowed(&msg); + let r2 = message_borrowed(&msg); assert!(r1 == 2); assert!(r1 == r2); } #[inline(never)] pub fn invoke_message_owned() { - let msg = Message { v: vec![3] }; + let msg = Message::default(); let (r1, msg) = message_owned(msg); let (r2, _msg) = message_owned(msg); - assert!(r1 == 3); + assert!(r1 == 2); assert!(r1 == r2); } - #[inline(never)] -pub fn invoke_message_owned_idx_loop() { - let msg = Message { v: vec![3] }; - let (r1, msg) = message_owned_idx_loop(msg); - let (r2, _msg) = message_owned_idx_loop(msg); - assert!(r1 == 3); +pub fn invoke_messagemf_borrowed() { + let msg = MessageMf::default(); + let r1 = messagemf_borrowed(&msg); + let r2 = messagemf_borrowed(&msg); + assert!(r1 == 2); assert!(r1 == r2); } #[inline(never)] -pub fn invoke_message_owned_iter_loop() { - let msg = Message { v: vec![3] }; - let (r1, msg) = message_owned_iter_loop(msg); - let (r2, _msg) = message_owned_iter_loop(msg); - assert!(r1 == 3); +pub fn invoke_messagemf_owned() { + let msg = MessageMf::default(); + let (r1, msg) = messagemf_owned(msg); + let (r2, _msg) = messagemf_owned(msg); + assert!(r1 == 2); assert!(r1 == r2); } diff --git a/src/main.rs b/src/main.rs index 03c7580..cff3887 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,13 +1,13 @@ use exper_borrowed_vs_owned_parameters::{ - invoke_message_borrowed, invoke_message_borrowed_idx_loop, invoke_message_borrowed_iter_loop, - invoke_message_owned, invoke_message_owned_idx_loop, invoke_message_owned_iter_loop, + invoke_message_borrowed, invoke_message_default, invoke_message_owned, + invoke_messagemf_borrowed, invoke_messagemf_default, invoke_messagemf_owned, }; fn main() { + invoke_message_default(); + invoke_messagemf_default(); invoke_message_borrowed(); - invoke_message_borrowed_idx_loop(); - invoke_message_borrowed_iter_loop(); invoke_message_owned(); - invoke_message_owned_idx_loop(); - invoke_message_owned_iter_loop(); + invoke_messagemf_borrowed(); + invoke_messagemf_owned(); }