i have no idea what is happening here.  please can someone explain why 
these give such different results?  thanks, andrew

> cat Memory.jl

immutable Fast{U<:Unsigned} 
    i::U
end
+{U<:Unsigned}(a::Fast{U}, b::Fast{U}) = Fast{U}(a.i $ b.i)

immutable Slow{I<:Unsigned}  
    i::I
end
for (name, op) in ((:+, $),)
    @eval $name{U<:Unsigned}(a::Slow{U}, b::Slow{U}) = Slow{U}($op(a.i, b.i
))
end

> julia
               _
   _       _ _(_)_     |  A fresh approach to technical computing
  (_)     | (_) (_)    |  Documentation: http://docs.julialang.org
   _ _   _| |_  __ _   |  Type "help()" to list help topics
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 0.3.0-prerelease+1998 (2014-03-13 01:20 
UTC)
 _/ |\__'_|_|_|\__'_|  |  Commit 9e0e3bd* (2 days old master)
|__/                   |  x86_64-suse-linux

julia> using Memory
Warning: requiring "Memory" did not define a corresponding module.

julia> code_native(+, (Fast{Uint8}, Fast{Uint8}))
        .text
Filename: /home/andrew/.julia/v0.3/IntModN/src/Memory.jl
Source line: 5
        push    RBP
        mov     RBP, RSP
        xor     EDI, ESI
Source line: 5
        mov     AL, DIL
        pop     RBP
        ret

julia> code_native(+, (Slow{Uint8}, Slow{Uint8}))
        .text
Filename: /home/andrew/.julia/v0.3/IntModN/src/Memory.jl
Source line: 11
        push    RBP
        mov     RBP, RSP
        push    RBX
        sub     RSP, 40
        mov     QWORD PTR [RBP - 40], 4
Source line: 11
        movabs  RBX, 139916932623568
        mov     RAX, QWORD PTR [RBX]
        mov     QWORD PTR [RBP - 32], RAX
        lea     RAX, QWORD PTR [RBP - 40]
        mov     QWORD PTR [RBX], RAX
        mov     QWORD PTR [RBP - 16], 0
Source line: 11
        mov     QWORD PTR [RBP - 24], 13308928
        movabs  RAX, 139916939396576
        call    RAX
        movabs  RCX, 139916917454832
        movzx   EDI, AL
        call    RCX
Source line: 11
        lea     RSI, QWORD PTR [RBP - 24]
Source line: 11
        movabs  RCX, 139916917189328
        mov     QWORD PTR [RBP - 16], RAX
        mov     EDI, 29726432
        mov     EDX, 2
        call    RCX
        mov     AL, BYTE PTR [RAX + 8]
        mov     RCX, QWORD PTR [RBP - 32]
        mov     QWORD PTR [RBX], RCX
        add     RSP, 40
        pop     RBX
        pop     RBP
        ret



Reply via email to