style fixes

This commit is contained in:
Laban Kimotho 2014-01-24 11:06:41 +02:00
parent 400b00aa87
commit c705d16a3e

View File

@ -659,13 +659,14 @@ fight(Lion("RAR"),Lion("brown","rarrr")) #=> prints The lions come to a tie
# Under the hood # Under the hood
# You can take a look at the llvm intermediate code and the assembly code generated. # You can take a look at the llvm and the assembly code generated.
square_area(l) = l * l # square_area (generic function with 1 method) square_area(l) = l * l # square_area (generic function with 1 method)
square_area(5) #25 square_area(5) #25
code_native(square_area, (Int32,)) # What happens when we feed square_area an integer? # What happens when we feed square_area an integer?
code_native(square_area, (Int32,))
# .section __TEXT,__text,regular,pure_instructions # .section __TEXT,__text,regular,pure_instructions
# Filename: none # Filename: none
# Source line: 1 # Prologue # Source line: 1 # Prologue
@ -673,7 +674,7 @@ code_native(square_area, (Int32,)) # What happens when we feed square_area an i
# mov RBP, RSP # mov RBP, RSP
# Source line: 1 # Source line: 1
# movsxd RAX, EDI # Fetch l from memory? # movsxd RAX, EDI # Fetch l from memory?
# imul RAX, RAX # 32bit square of l and store the result in RAX # imul RAX, RAX # Square l and store the result in RAX
# pop RBP # Restore old base pointer # pop RBP # Restore old base pointer
# ret # Result will still be in RAX # ret # Result will still be in RAX
@ -684,7 +685,7 @@ code_native(square_area, (Float32,))
# push RBP # push RBP
# mov RBP, RSP # mov RBP, RSP
# Source line: 1 # Source line: 1
# vmulss XMM0, XMM0, XMM0 # Scalar single precision multiplication (AVX) (in this case square the number) # vmulss XMM0, XMM0, XMM0 # Scalar single precision multiply (AVX)
# pop RBP # pop RBP
# ret # ret
@ -695,11 +696,12 @@ code_native(square_area, (Float64,))
# push RBP # push RBP
# mov RBP, RSP # mov RBP, RSP
# Source line: 1 # Source line: 1
# vmulsd XMM0, XMM0, XMM0 # Scalar double precision multiplacation (AVX) # vmulsd XMM0, XMM0, XMM0 # Scalar double precision multiply (AVX)
# pop RBP # pop RBP
# ret # ret
# #
# Note that julia will use floating point instructions if any of the arguements are floats. # Note that julia will use floating point instructions if any of the
# arguements are floats.
# Let's calculate the area of a circle # Let's calculate the area of a circle
circle_area(r) = pi * r * r # circle_area (generic function with 1 method) circle_area(r) = pi * r * r # circle_area (generic function with 1 method)
circle_area(5) # 78.53981633974483 circle_area(5) # 78.53981633974483