Upgrade to Pro — share decks privately, control downloads, hide ads and more …

A PoC-ish Trick: LLVM IR Generation with Ruby

remore
November 11, 2016

A PoC-ish Trick: LLVM IR Generation with Ruby

A Lightning Talk at RubyConf 2016

remore

November 11, 2016
Tweet

More Decks by remore

Other Decks in Technology

Transcript

  1. A PoC-ish Trick: LLVM IR Generation with Ruby A Lightning

    Talk at RubyConf 2016 Kei Sawada (@remore)
  2. Julia is 4 years old young Good performance, as fast

    as C Dynamic typing Julia has Capability to call C functions directly without wrappers or special APIs a compiler that used LLVM to translate Julia programs into ef cient executable code
  3. debussy:~ guest$ julia _ _ _ _(_)_ | A fresh

    approach to technical computin (_) | (_) (_) | Documentation: http://docs.julialang.o _ _ _| |_ __ _ | Type "?help" for help. | | | | | | |/ _` | | | | |_| | | | (_| | | Version 0.4.6 (2016-06-19 17:16 UTC) _/ |\__'_|_|_|\__'_| | |__/ | x86_64-apple-darwin15.5.0 julia>
  4. debussy:~ guest$ julia _ _ _ _(_)_ | A fresh

    approach to technical computin (_) | (_) (_) | Documentation: http://docs.julialang.o _ _ _| |_ __ _ | Type "?help" for help. | | | | | | |/ _` | | | | |_| | | | (_| | | Version 0.4.6 (2016-06-19 17:16 UTC) _/ |\__'_|_|_|\__'_| | |__/ | x86_64-apple-darwin15.5.0 julia> function hello() "rubyconf" end hello (generic function with 1 method) julia>
  5. debussy:~ guest$ julia _ _ _ _(_)_ | A fresh

    approach to technical computin (_) | (_) (_) | Documentation: http://docs.julialang.o _ _ _| |_ __ _ | Type "?help" for help. | | | | | | |/ _` | | | | |_| | | | (_| | | Version 0.4.6 (2016-06-19 17:16 UTC) _/ |\__'_|_|_|\__'_| | |__/ | x86_64-apple-darwin15.5.0 julia> function hello() "rubyconf" end hello (generic function with 1 method) julia> hello() "rubyconf" julia>
  6. julia> code_llvm(hello, ()) define %jl_value_t* @julia_hello_21549() { top: ret %jl_value_t*

    inttoptr (i64 4447575696 to %jl_value_t*) } julia> code_native(hello, ()) .section __TEXT,__text,regular,pure_instructions Filename: none Source line: 2 pushq %rbp movq %rsp, %rbp movabsq $4447575696, %rax ## imm = 0x109189E90 Source line: 2 popq %rbp ret julia>
  7. You can write some Ruby code which can be translated

    into Julia where you can get LLVM IR easily?