Last active
August 29, 2017 19:03
-
-
Save henninglive/adb28728a5fac8e42e7880175dc20e07 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
| Diff of https://github.com/brayniac/mpmc/blob/master/src/lib.rs | |
| --- a/src/lib.rs | |
| +++ b/src/lib.rs | |
| @@ -102,7 +102,7 @@ impl<T: Send> State<T> { | |
| let mask = self.mask; | |
| let mut pos = self.enqueue_pos.load(Relaxed); | |
| loop { | |
| - let node = &self.buffer[pos & mask]; | |
| + let node = unsafe { self.buffer.get_unchecked(pos & mask) }; | |
| let seq = unsafe { (*node.get()).sequence.load(Acquire) }; | |
| let diff: isize = seq as isize - pos as isize; | |
| @@ -110,7 +110,7 @@ impl<T: Send> State<T> { | |
| let enqueue_pos = self.enqueue_pos.compare_and_swap(pos, pos + 1, Relaxed); | |
| if enqueue_pos == pos { | |
| unsafe { | |
| - (*node.get()).value = Some(value); | |
| + std::ptr::write(&mut (*node.get()).value, Some(value)); | |
| (*node.get()).sequence.store(pos + 1, Release); | |
| } | |
| break; | |
| @@ -130,7 +130,7 @@ impl<T: Send> State<T> { | |
| let mask = self.mask; | |
| let mut pos = self.dequeue_pos.load(Relaxed); | |
| loop { | |
| - let node = &self.buffer[pos & mask]; | |
| + let node = unsafe { self.buffer.get_unchecked(pos & mask) }; | |
| let seq = unsafe { (*node.get()).sequence.load(Acquire) }; | |
| let diff: isize = seq as isize - (pos + 1) as isize; | |
| if diff == 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
| .text:0000000000401860 ; mpmc::pop::h29d8331838a0b0ef | |
| .text:0000000000401860 _ZN4mpmc3pop17h29d8331838a0b0efE proc near | |
| .text:0000000000401860 ; CODE XREF: mpmc::main::hcfb95620f7244563+27Fp | |
| .text:0000000000401860 ; DATA XREF: .pdata:000000000048C084o | |
| .text:0000000000401860 push rsi | |
| .text:0000000000401861 push rdi | |
| .text:0000000000401862 mov r9, [rcx+28h] | |
| .text:0000000000401866 lea r10, [rcx+38h] | |
| .text:000000000040186A xor r8d, r8d | |
| .text:000000000040186D | |
| .text:000000000040186D loc_40186D: ; CODE XREF: mpmc::pop::h29d8331838a0b0ef+43j | |
| .text:000000000040186D mov rax, [r10] | |
| .text:0000000000401870 | |
| .text:0000000000401870 loc_401870: ; CODE XREF: mpmc::pop::h29d8331838a0b0ef+36j | |
| .text:0000000000401870 mov rdx, rax | |
| .text:0000000000401873 mov r11, [rcx+10h] | |
| .text:0000000000401877 mov rsi, rdx | |
| .text:000000000040187A and rsi, r9 | |
| .text:000000000040187D shl rsi, 4 | |
| .text:0000000000401881 mov rax, [r11+rsi] | |
| .text:0000000000401885 lea rdi, [rdx+1] | |
| .text:0000000000401889 sub rax, rdi | |
| .text:000000000040188C jnz short loc_4018A0 | |
| .text:000000000040188E mov rax, rdx | |
| .text:0000000000401891 lock cmpxchg [r10], rdi | |
| .text:0000000000401896 jnz short loc_401870 | |
| .text:0000000000401898 jmp short loc_4018A9 | |
| .text:0000000000401898 ; --------------------------------------------------------------------------- | |
| .text:000000000040189A align 20h | |
| .text:00000000004018A0 | |
| .text:00000000004018A0 loc_4018A0: ; CODE XREF: mpmc::pop::h29d8331838a0b0ef+2Cj | |
| .text:00000000004018A0 test rax, rax | |
| .text:00000000004018A3 jns short loc_40186D | |
| .text:00000000004018A5 xor eax, eax | |
| .text:00000000004018A7 jmp short loc_4018D2 | |
| .text:00000000004018A9 ; --------------------------------------------------------------------------- | |
| .text:00000000004018A9 | |
| .text:00000000004018A9 loc_4018A9: ; CODE XREF: mpmc::pop::h29d8331838a0b0ef+38j | |
| .text:00000000004018A9 lea rax, [r11+rsi] | |
| .text:00000000004018AD mov rcx, [r11+rsi+8] | |
| .text:00000000004018B2 mov qword ptr [r11+rsi+8], 0 | |
| .text:00000000004018BB mov r8, 0FFFFFFFF00000000h | |
| .text:00000000004018C5 and r8, rcx | |
| .text:00000000004018C8 lea rdx, [r9+rdx+1] | |
| .text:00000000004018CD mov [rax], rdx | |
| .text:00000000004018D0 mov eax, ecx | |
| .text:00000000004018D2 | |
| .text:00000000004018D2 loc_4018D2: ; CODE XREF: mpmc::pop::h29d8331838a0b0ef+47j | |
| .text:00000000004018D2 or r8, rax | |
| .text:00000000004018D5 mov rax, r8 | |
| .text:00000000004018D8 pop rdi | |
| .text:00000000004018D9 pop rsi | |
| .text:00000000004018DA retn | |
| .text:00000000004018DA _ZN4mpmc3pop17h29d8331838a0b0efE endp |
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
| .text:0000000000401940 ; mpmc::pop::h29d8331838a0b0ef | |
| .text:0000000000401940 _ZN4mpmc3pop17h29d8331838a0b0efE proc near | |
| .text:0000000000401940 ; CODE XREF: mpmc::main::hcfb95620f7244563+27Fp | |
| .text:0000000000401940 ; DATA XREF: .pdata:000000000048C084o | |
| .text:0000000000401940 push rsi | |
| .text:0000000000401941 push rdi | |
| .text:0000000000401942 push rbx | |
| .text:0000000000401943 sub rsp, 20h | |
| .text:0000000000401947 mov r11, [rcx+28h] | |
| .text:000000000040194B lea rbx, [rcx+38h] | |
| .text:000000000040194F xor r10d, r10d | |
| .text:0000000000401952 | |
| .text:0000000000401952 loc_401952: ; CODE XREF: mpmc::pop::h29d8331838a0b0ef+63j | |
| .text:0000000000401952 mov rax, [rbx] | |
| .text:0000000000401955 db 66h, 66h, 2Eh | |
| .text:0000000000401955 nop word ptr [rax+rax+00000000h] | |
| .text:0000000000401960 | |
| .text:0000000000401960 loc_401960: ; CODE XREF: mpmc::pop::h29d8331838a0b0ef+4Fj | |
| .text:0000000000401960 mov r9, rax | |
| .text:0000000000401963 mov rdx, r9 | |
| .text:0000000000401966 and rdx, r11 | |
| .text:0000000000401969 mov r8, [rcx+20h] | |
| .text:000000000040196D cmp r8, rdx | |
| .text:0000000000401970 jbe short loc_4019E0 | |
| .text:0000000000401972 mov rsi, [rcx+10h] | |
| .text:0000000000401976 shl rdx, 4 | |
| .text:000000000040197A mov rax, [rsi+rdx] | |
| .text:000000000040197E lea rdi, [r9+1] | |
| .text:0000000000401982 sub rax, rdi | |
| .text:0000000000401985 jnz short loc_4019A0 | |
| .text:0000000000401987 mov rax, r9 | |
| .text:000000000040198A lock cmpxchg [rbx], rdi | |
| .text:000000000040198F jnz short loc_401960 | |
| .text:0000000000401991 jmp short loc_4019A9 | |
| .text:0000000000401991 ; --------------------------------------------------------------------------- | |
| .text:0000000000401993 align 20h | |
| .text:00000000004019A0 | |
| .text:00000000004019A0 loc_4019A0: ; CODE XREF: mpmc::pop::h29d8331838a0b0ef+45j | |
| .text:00000000004019A0 test rax, rax | |
| .text:00000000004019A3 jns short loc_401952 | |
| .text:00000000004019A5 xor eax, eax | |
| .text:00000000004019A7 jmp short loc_4019D2 | |
| .text:00000000004019A9 ; --------------------------------------------------------------------------- | |
| .text:00000000004019A9 | |
| .text:00000000004019A9 loc_4019A9: ; CODE XREF: mpmc::pop::h29d8331838a0b0ef+51j | |
| .text:00000000004019A9 lea rax, [rsi+rdx] | |
| .text:00000000004019AD mov rcx, [rsi+rdx+8] | |
| .text:00000000004019B2 mov qword ptr [rsi+rdx+8], 0 | |
| .text:00000000004019BB mov r10, 0FFFFFFFF00000000h | |
| .text:00000000004019C5 and r10, rcx | |
| .text:00000000004019C8 lea rdx, [r11+r9+1] | |
| .text:00000000004019CD mov [rax], rdx | |
| .text:00000000004019D0 mov eax, ecx | |
| .text:00000000004019D2 | |
| .text:00000000004019D2 loc_4019D2: ; CODE XREF: mpmc::pop::h29d8331838a0b0ef+67j | |
| .text:00000000004019D2 or r10, rax | |
| .text:00000000004019D5 mov rax, r10 | |
| .text:00000000004019D8 add rsp, 20h | |
| .text:00000000004019DC pop rbx | |
| .text:00000000004019DD pop rdi | |
| .text:00000000004019DE pop rsi | |
| .text:00000000004019DF retn | |
| .text:00000000004019E0 ; --------------------------------------------------------------------------- | |
| .text:00000000004019E0 | |
| .text:00000000004019E0 loc_4019E0: ; CODE XREF: mpmc::pop::h29d8331838a0b0ef+30j | |
| .text:00000000004019E0 lea rcx, panic_bounds_check_loc_e | |
| .text:00000000004019E7 call _ZN4core9panicking18panic_bounds_check17hc1b5ea060cf92e68E ; core::panicking::panic_bounds_check::hc1b5ea060cf92e68 | |
| .text:00000000004019E7 _ZN4mpmc3pop17h29d8331838a0b0efE endp |
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
| .text:00000000004017E0 ; mpmc::push::h1c388de128fb76ed | |
| .text:00000000004017E0 _ZN4mpmc4push17h1c388de128fb76edE proc near | |
| .text:00000000004017E0 ; CODE XREF: mpmc::main::hcfb95620f7244563+230p | |
| .text:00000000004017E0 ; DATA XREF: .pdata:000000000048C078o | |
| .text:00000000004017E0 push rsi | |
| .text:00000000004017E1 push rdi | |
| .text:00000000004017E2 mov r10, [rcx+28h] | |
| .text:00000000004017E6 lea r11, [rcx+30h] | |
| .text:00000000004017EA mov r9, 6400000000h | |
| .text:00000000004017F4 mov r8d, 1 | |
| .text:00000000004017FA | |
| .text:00000000004017FA loc_4017FA: ; CODE XREF: mpmc::push::h1c388de128fb76ed+53j | |
| .text:00000000004017FA mov rax, [r11] | |
| .text:00000000004017FD nop dword ptr [rax] | |
| .text:0000000000401800 | |
| .text:0000000000401800 loc_401800: ; CODE XREF: mpmc::push::h1c388de128fb76ed+40j | |
| .text:0000000000401800 mov rdx, [rcx+10h] | |
| .text:0000000000401804 mov rsi, rax | |
| .text:0000000000401807 and rsi, r10 | |
| .text:000000000040180A shl rsi, 4 | |
| .text:000000000040180E mov rdi, [rdx+rsi] | |
| .text:0000000000401812 sub rdi, rax | |
| .text:0000000000401815 jnz short loc_401830 | |
| .text:0000000000401817 lea rdi, [rax+1] | |
| .text:000000000040181B lock cmpxchg [r11], rdi | |
| .text:0000000000401820 jnz short loc_401800 | |
| .text:0000000000401822 jmp short loc_401837 | |
| .text:0000000000401822 ; --------------------------------------------------------------------------- | |
| .text:0000000000401824 align 10h | |
| .text:0000000000401830 | |
| .text:0000000000401830 loc_401830: ; CODE XREF: mpmc::push::h1c388de128fb76ed+35j | |
| .text:0000000000401830 test rdi, rdi | |
| .text:0000000000401833 jns short loc_4017FA | |
| .text:0000000000401835 jmp short loc_40184C | |
| .text:0000000000401837 ; --------------------------------------------------------------------------- | |
| .text:0000000000401837 | |
| .text:0000000000401837 loc_401837: ; CODE XREF: mpmc::push::h1c388de128fb76ed+42j | |
| .text:0000000000401837 lea rax, [rdx+rsi] | |
| .text:000000000040183B inc r9 | |
| .text:000000000040183E mov [rdx+rsi+8], r9 | |
| .text:0000000000401843 mov [rax], rdi | |
| .text:0000000000401846 xor r9d, r9d | |
| .text:0000000000401849 xor r8d, r8d | |
| .text:000000000040184C | |
| .text:000000000040184C loc_40184C: ; CODE XREF: mpmc::push::h1c388de128fb76ed+55j | |
| .text:000000000040184C or r9, r8 | |
| .text:000000000040184F mov rax, r9 | |
| .text:0000000000401852 pop rdi | |
| .text:0000000000401853 pop rsi | |
| .text:0000000000401854 retn | |
| .text:0000000000401854 _ZN4mpmc4push17h1c388de128fb76edE endp |
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
| .text:00000000004017A0 ; mpmc::push::h1c388de128fb76ed | |
| .text:00000000004017A0 _ZN4mpmc4push17h1c388de128fb76edE proc near | |
| .text:00000000004017A0 ; CODE XREF: mpmc::main::hcfb95620f7244563+22Ap | |
| .text:00000000004017A0 ; DATA XREF: .pdata:000000000048C084o | |
| .text:00000000004017A0 push r15 | |
| .text:00000000004017A2 push r14 | |
| .text:00000000004017A4 push rsi | |
| .text:00000000004017A5 push rdi | |
| .text:00000000004017A6 push rbx | |
| .text:00000000004017A7 sub rsp, 20h | |
| .text:00000000004017AB mov r9, [rcx+28h] | |
| .text:00000000004017AF lea rdx, [rcx+30h] | |
| .text:00000000004017B3 mov r14, 6400000001h | |
| .text:00000000004017BD | |
| .text:00000000004017BD loc_4017BD: ; CODE XREF: mpmc::push::h1c388de128fb76ed+53j | |
| .text:00000000004017BD mov rax, [rdx] | |
| .text:00000000004017C0 | |
| .text:00000000004017C0 loc_4017C0: ; CODE XREF: mpmc::push::h1c388de128fb76ed+49j | |
| .text:00000000004017C0 mov rdi, rax | |
| .text:00000000004017C3 and rdi, r9 | |
| .text:00000000004017C6 mov r8, [rcx+20h] | |
| .text:00000000004017CA cmp r8, rdi | |
| .text:00000000004017CD jbe short loc_401830 | |
| .text:00000000004017CF mov rbx, [rcx+10h] | |
| .text:00000000004017D3 shl rdi, 4 | |
| .text:00000000004017D7 mov rsi, [rbx+rdi] | |
| .text:00000000004017DB sub rsi, rax | |
| .text:00000000004017DE jnz short loc_4017F0 | |
| .text:00000000004017E0 lea rsi, [rax+1] | |
| .text:00000000004017E4 lock cmpxchg [rdx], rsi | |
| .text:00000000004017E9 jnz short loc_4017C0 | |
| .text:00000000004017EB jmp short loc_4017FF | |
| .text:00000000004017EB ; --------------------------------------------------------------------------- | |
| .text:00000000004017ED align 10h | |
| .text:00000000004017F0 | |
| .text:00000000004017F0 loc_4017F0: ; CODE XREF: mpmc::push::h1c388de128fb76ed+3Ej | |
| .text:00000000004017F0 test rsi, rsi | |
| .text:00000000004017F3 jns short loc_4017BD | |
| .text:00000000004017F5 dec r14 | |
| .text:00000000004017F8 mov eax, 1 | |
| .text:00000000004017FD jmp short loc_40181E | |
| .text:00000000004017FF ; --------------------------------------------------------------------------- | |
| .text:00000000004017FF | |
| .text:00000000004017FF loc_4017FF: ; CODE XREF: mpmc::push::h1c388de128fb76ed+4Bj | |
| .text:00000000004017FF lea r15, [rbx+rdi+8] | |
| .text:0000000000401804 cmp dword ptr [rbx+rdi+8], 0 | |
| .text:0000000000401809 jz short loc_401810 | |
| .text:000000000040180B call _ZN58_$LT$mpmc__Dropper$LT$T$GT$$u20$as$u20$core__ops__Drop$GT$4drop17h26557bbf80445939E ; _$LT$mpmc..Dropper$LT$T$GT$$u20$as$u20$core..ops..Drop$GT$::drop::h26557bbf80445939 | |
| .text:0000000000401810 | |
| .text:0000000000401810 loc_401810: ; CODE XREF: mpmc::push::h1c388de128fb76ed+69j | |
| .text:0000000000401810 add rbx, rdi | |
| .text:0000000000401813 mov [r15], r14 | |
| .text:0000000000401816 mov [rbx], rsi | |
| .text:0000000000401819 xor r14d, r14d | |
| .text:000000000040181C xor eax, eax | |
| .text:000000000040181E | |
| .text:000000000040181E loc_40181E: ; CODE XREF: mpmc::push::h1c388de128fb76ed+5Dj | |
| .text:000000000040181E or r14, rax | |
| .text:0000000000401821 mov rax, r14 | |
| .text:0000000000401824 add rsp, 20h | |
| .text:0000000000401828 pop rbx | |
| .text:0000000000401829 pop rdi | |
| .text:000000000040182A pop rsi | |
| .text:000000000040182B pop r14 | |
| .text:000000000040182D pop r15 | |
| .text:000000000040182F retn | |
| .text:0000000000401830 ; --------------------------------------------------------------------------- | |
| .text:0000000000401830 | |
| .text:0000000000401830 loc_401830: ; CODE XREF: mpmc::push::h1c388de128fb76ed+2Dj | |
| .text:0000000000401830 lea rcx, panic_bounds_check_loc_e | |
| .text:0000000000401837 mov rdx, rdi | |
| .text:000000000040183A call _ZN4core9panicking18panic_bounds_check17hc1b5ea060cf92e68E ; core::panicking::panic_bounds_check::hc1b5ea060cf92e68 | |
| .text:000000000040183F ; --------------------------------------------------------------------------- | |
| .text:000000000040183F ud2 | |
| .text:0000000000401841 ; --------------------------------------------------------------------------- | |
| .text:0000000000401841 mov rdi, rax | |
| .text:0000000000401844 call _ZN58_$LT$mpmc__Dropper$LT$T$GT$$u20$as$u20$core__ops__Drop$GT$4drop17h26557bbf80445939E ; _$LT$mpmc..Dropper$LT$T$GT$$u20$as$u20$core..ops..Drop$GT$::drop::h26557bbf80445939 | |
| .text:0000000000401849 jmp short loc_401851 | |
| .text:000000000040184B ; --------------------------------------------------------------------------- | |
| .text:000000000040184B mov rdi, rax | |
| .text:000000000040184E mov [r15], r14 | |
| .text:0000000000401851 | |
| .text:0000000000401851 loc_401851: ; CODE XREF: mpmc::push::h1c388de128fb76ed+A9j | |
| .text:0000000000401851 mov rcx, rdi | |
| .text:0000000000401854 call rust_eh_unwind_resume | |
| .text:0000000000401859 ; --------------------------------------------------------------------------- | |
| .text:0000000000401859 ud2 | |
| .text:000000000040185B ; --------------------------------------------------------------------------- | |
| .text:000000000040185B mov rcx, rax | |
| .text:000000000040185E call rust_eh_unwind_resume | |
| .text:0000000000401863 ; --------------------------------------------------------------------------- | |
| .text:0000000000401863 ud2 | |
| .text:0000000000401863 _ZN4mpmc4push17h1c388de128fb76edE endp |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment