A PoC-ish Trick: LLVM IR Generation with Ruby

Fbe207d1bece86feb799fbc1841ce735?s=47 remore
November 11, 2016

A PoC-ish Trick: LLVM IR Generation with Ruby

A Lightning Talk at RubyConf 2016

Fbe207d1bece86feb799fbc1841ce735?s=128

remore

November 11, 2016
Tweet

Transcript

  1. 1.

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

    Talk at RubyConf 2016 Kei Sawada (@remore)
  2. 2.
  3. 4.

    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
  4. 7.

    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>
  5. 8.

    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>
  6. 9.

    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>
  7. 11.

    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>
  8. 13.
  9. 14.
  10. 15.

    You can write some Ruby code which can be translated

    into Julia where you can get LLVM IR easily?
  11. 17.