Open LilithHafner opened 7 months ago
That's https://github.com/JuliaLang/julia/pull/41789; you can still access the old disassembling version by (rather crypticly) specifying dump_module=false
:
julia> @code_native dump_module=false rand(UInt)
.text
; ┌ @ Random.jl:261 within `rand`
push rbp
mov rbp, rsp
mov rax, qword ptr [r13 + 16]
mov rax, qword ptr [rax + 16]
mov rax, qword ptr [rax]
; │ @ Random.jl:261 within `rand` @ Random.jl:258 @ Xoshiro.jl:143
; │┌ @ task.jl:182 within `getproperty`
mov rcx, qword ptr [r13 - 56]
mov rsi, qword ptr [r13 - 32]
mov rdi, qword ptr [r13 - 40]
mov rdx, qword ptr [r13 - 48]
; │└
; │ @ Random.jl:261 within `rand` @ Random.jl:258 @ Xoshiro.jl:144
; │┌ @ int.jl:87 within `+`
lea rax, [rsi + rcx]
; │└
; │ @ Random.jl:261 within `rand` @ Random.jl:258 @ Xoshiro.jl:146
; │┌ @ int.jl:536 within `<<` @ int.jl:529
mov r8, rdx
shl r8, 17
; │└
; │ @ Random.jl:261 within `rand` @ Random.jl:258 @ Xoshiro.jl:147
; │┌ @ int.jl:373 within `xor`
xor rdi, rcx
; │└
; │ @ Random.jl:261 within `rand` @ Random.jl:258 @ Xoshiro.jl:148
; │┌ @ int.jl:373 within `xor`
xor rsi, rdx
; │└
; │ @ Random.jl:261 within `rand` @ Random.jl:258 @ Xoshiro.jl:145
; │┌ @ int.jl:372 within `|`
rorx rax, rax, 41
; │└
; │ @ Random.jl:261 within `rand` @ Random.jl:258 @ Xoshiro.jl:149
; │┌ @ int.jl:373 within `xor`
xor rdx, rdi
; │└
; │ @ Random.jl:261 within `rand` @ Random.jl:258 @ Xoshiro.jl:151
; │┌ @ int.jl:373 within `xor`
xor rdi, r8
; │└
; │ @ Random.jl:261 within `rand` @ Random.jl:258 @ Xoshiro.jl:145
; │┌ @ int.jl:87 within `+`
add rax, rcx
; │└
; │ @ Random.jl:261 within `rand` @ Random.jl:258 @ Xoshiro.jl:150
; │┌ @ int.jl:373 within `xor`
xor rcx, rsi
; │└
; │ @ Random.jl:261 within `rand` @ Random.jl:258 @ Xoshiro.jl:152
; │┌ @ int.jl:372 within `|`
rorx rsi, rsi, 19
; │└
; │ @ Random.jl:261 within `rand` @ Random.jl:258 @ Xoshiro.jl:153
; │┌ @ Base.jl:41 within `setproperty!`
mov qword ptr [r13 - 56], rcx
mov qword ptr [r13 - 48], rdx
mov qword ptr [r13 - 40], rdi
mov qword ptr [r13 - 32], rsi
; │└
; │ @ Random.jl:261 within `rand`
pop rbp
ret
; └
; ┌ @ Random.jl:261 within `<invalid>`
nop word ptr [rax + rax]
; └
cc @vtjnash
I don't know why is printing those long full paths there, though in general if you see a discrepancy with dump_module, it is because dump_module=false
is wrong, as that does significantly more unreliable transforms on the information before printing.
In addition to the long paths, some of the function prologue/epilogue could probably be omitted:
.text
.file "rand"
.globl julia_rand_5155 // -- Begin function julia_rand_5155
.p2align 2
.type julia_rand_5155,@function
julia_rand_5155: // @julia_rand_5155
; Function Signature: rand(Type{UInt64})
; ┌ @ /cache/build/builder-armageddon-4/julialang/julia-release-1-dot-11/usr/share/julia/stdlib/v1.11/Random/src/Random.jl:259 within `rand`
// %bb.0: // %top
stp x29, x30, [sp, #-16]! // 16-byte Folded Spill
mov x29, sp
//APP
mrs x8, TPIDR_EL0
//NO_APP
...
.Lfunc_end0:
.size julia_rand_5155, .Lfunc_end0-julia_rand_5155
; └└└
// -- End function
.section ".note.GNU-stack","",@progbits
Related #52173.
I recently wanted to see the assembly of
rand(UInt)
, and found this result somewhat disappointing:It's even worse with line wrapping enabled.
1.6 was more ineligible, though it's much longer because MerseneTwister took more instructions than the current RNG.