Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
A PoC-ish Trick: LLVM IR Generation with Ruby
Search
remore
November 11, 2016
Technology
1
1.2k
A PoC-ish Trick: LLVM IR Generation with Ruby
A Lightning Talk at RubyConf 2016
remore
November 11, 2016
Tweet
Share
More Decks by remore
See All by remore
Turning CDN edge into a Rack web server with ruby.wasm
remore
0
360
Prototyping Kubernetes CRI With Ruby and gRPC
remore
3
1k
How I made a pure-Ruby word2vec program more than 3x faster
remore
3
2.8k
Code, Arguments and Startups
remore
0
1.6k
詳解🔍Burn🔥
remore
4
5.3k
DockerCon 2015 Quick Recap
remore
0
410
dockerfileview: A Dockerfile viewer to trace ancestry of the base image
remore
2
420
Burn: 8-Bit Game Development With Ruby
remore
3
850
Other Decks in Technology
See All in Technology
やってやろうじゃないかメカアジャイル! / Let's do it, mechanical agile!
psj59129
1
680
持続可能なソフトウェア開発を支える『GitHub CI/CD実践ガイド』
tmknom
8
1.4k
PDF Viewer作成の今までとこれから
hunachi
0
480
開発者の定量・定性データを組み合わせて開発者体験を把握するための取り組み
ham0215
1
140
株式会社EventHub・エンジニア採用資料
eventhub
0
3k
Next.js のページ遷移を全力で止める
ypresto
8
3.4k
不動産 x AIことはじめ~データの真価を拓くために
estie
0
120
『GRANBLUE FANTASY: Relink』最高の「没入感」を実現するカットシーン制作手法とそれを支える技術
cygames
1
140
サプライチェーン攻撃に備える
ryunen344
0
290
たった1人からはじめる【Agile Community of Practice】~ソース原理とFearless Changeを添えて~
ktc_corporate_it
1
500
プログラム検証入門
riru
6
880
Creative UIs with Compose: DroidKaigi 2024
chrishorner
1
590
Featured
See All Featured
Faster Mobile Websites
deanohume
304
30k
Put a Button on it: Removing Barriers to Going Fast.
kastner
58
3.4k
Music & Morning Musume
bryan
46
6k
Learning to Love Humans: Emotional Interface Design
aarron
270
40k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
663
120k
Building Flexible Design Systems
yeseniaperezcruz
325
38k
Infographics Made Easy
chrislema
239
18k
Rails Girls Zürich Keynote
gr2m
93
13k
Agile that works and the tools we love
rasmusluckow
327
20k
GraphQLとの向き合い方2022年版
quramy
43
13k
Why You Should Never Use an ORM
jnunemaker
PRO
53
8.9k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
8.9k
Transcript
A PoC-ish Trick: LLVM IR Generation with Ruby A Lightning
Talk at RubyConf 2016 Kei Sawada (@remore)
None
a modern, fast, and open source language for data science
and technical computing
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
In short,
Write some Julia code then you will get LLVM IR
without hassle
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>
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>
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>
julia> code_llvm(hello, ()) define %jl_value_t* @julia_hello_21549() { top: ret %jl_value_t*
inttoptr (i64 4447575696 to %jl_value_t*) } julia>
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>
OK Julia is a thing But we are in
None
What if
You can write some Ruby code which can be translated
into Julia where you can get LLVM IR easily?
Ruby -> Julia -> LLVM IR
None
Julializer Allow you to convert your arbitrary Ruby code into
Julia code
Time to DEMO!
For more examples and attempts, check out: github.com/remore/julializer github.com/remore/virtual_module Thanks!