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
Node.js x WebAssembly
Search
Yosuke Furukawa
PRO
March 31, 2017
Programming
4
1.1k
Node.js x WebAssembly
Node学園24時限目で発表した Node.js と WebAssembly のデモですー。
Yosuke Furukawa
PRO
March 31, 2017
Tweet
Share
More Decks by Yosuke Furukawa
See All by Yosuke Furukawa
tc39 x jsconf.jp Panel Discussion 2024
yosuke_furukawa
PRO
0
150
Removing Corepack
yosuke_furukawa
PRO
9
1.3k
JavaScript Runtime とはなにか
yosuke_furukawa
PRO
15
2.5k
Strip Types と Storage
yosuke_furukawa
PRO
4
330
Module Harmony について
yosuke_furukawa
PRO
3
1.5k
LTのやり方
yosuke_furukawa
PRO
16
2.1k
AppRouter Panel Talk
yosuke_furukawa
PRO
3
700
Node.js v22 で変わること
yosuke_furukawa
PRO
13
5.2k
リアーキテクトと開発生産性について
yosuke_furukawa
PRO
25
9.6k
Other Decks in Programming
See All in Programming
【Kaigi on Rails 2024】YOUTRUST スポンサーLT
krpk1900
1
320
What’s New in Compose Multiplatform - A Live Tour (droidcon London 2024)
zsmb
1
460
AI時代におけるSRE、 あるいはエンジニアの生存戦略
pyama86
4
1.1k
型付き API リクエストを実現するいくつかの手法とその選択 / Typed API Request
euxn23
4
1.5k
Why Jakarta EE Matters to Spring - and Vice Versa
ivargrimstad
0
770
Ethereum_.pdf
nekomatu
0
420
とにかくAWS GameDay!AWSは世界の共通言語! / Anyway, AWS GameDay! AWS is the world's lingua franca!
seike460
PRO
1
800
Amazon Qを使ってIaCを触ろう!
maruto
0
380
TypeScript Graph でコードレビューの心理的障壁を乗り越える
ysk8hori
1
190
レガシーシステムにどう立ち向かうか 複雑さと理想と現実/vs-legacy
suzukihoge
14
2.1k
2024/11/8 関西Kaggler会 2024 #3 / Kaggle Kernel で Gemma 2 × vLLM を動かす。
kohecchi
4
780
From Subtype Polymorphism To Typeclass-based Ad hoc Polymorphism- An Example
philipschwarz
PRO
0
200
Featured
See All Featured
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
226
22k
We Have a Design System, Now What?
morganepeng
50
7.2k
Testing 201, or: Great Expectations
jmmastey
38
7.1k
Thoughts on Productivity
jonyablonski
67
4.3k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
33
1.8k
Visualization
eitanlees
145
15k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
280
13k
Documentation Writing (for coders)
carmenintech
65
4.4k
Imperfection Machines: The Place of Print at Facebook
scottboms
264
13k
Optimising Largest Contentful Paint
csswizardry
33
2.9k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
48k
Building a Scalable Design System with Sketch
lauravandoore
459
33k
Transcript
Node x WebAssembly 2017, Mar, 31th @ NodeֶԂ 24࣌ݶ in
FiNC
Twitter: @yosuke_furukawa Github: yosuke-furukawa
WebAssembly
WebAssembly Goals • ϙʔλϒϧ͔ͭϩʔυޮ͕ྑ͍όΠφϦϑΥʔϚο τΛ࡞Δ͜ͱ • ϋʔυΣΞ(mobile, IoT ؚΉ)ͷೳྗΛϑϧʹ׆͔ ͯ͠nativeͷͱಉͷ࣮ߦ࣌ؒͰܭࢉ͢Δ͜ͱ
• طଘͷϓϥοτϑΥʔϜ(web)ͱͷੑΛߴ͘͠ ͯɺ౷߹͘͢͢͠Δ͜ͱ http://webassembly.org/docs/high-level-goals/
WebAssembly UseCases
WebAssembly UseCase (1) • ωΠςΟϒϞδϡʔϧΛϒϥβͰಡΈࠐΉ
WebAssembly UseCase (1) • ωΠςΟϒϞδϡʔϧΛϒϥβͰಡΈࠐΉ
WebAssembly UseCase (2) • Game
WebAssembly Use Cases • BrowserϢʔεέʔε • CC++(Rust)Ͱॻ͔ΕͨωΠςΟϒϞ δϡʔϧΛϒϥβ͔ΒಡΈࠐΊΔΑ͏ʹ ͢Δ •
Game / ը૾ೝࣝ / ҉߸Խ / ѹॖ֦ு etc etc http://webassembly.org/docs/use-cases/
WebAssembly Use Cases • BrowerҎ֎ͷϢʔεέʔε • Server Side application •
Native Apps on mobile devices http://webassembly.org/docs/use-cases/
WebAssembly͕Ͳ͏ΘΕΔ ͜ͱΛఆ͢Δ͔ʁ • શମͷίʔυϕʔεΛWebAssemblyԽ͞ΕΔ ͜ͱΛظ • ͱ͍͑ɺWeb UIͷϨΠϠHTML/JSͷ·· • ͻͱ·ͣϝΠϯλʔήοτCC++Ͱॻ͔Ε
͍ͯΔطଘίʔυΛJSͰݺΔΑ͏ʹ͢Δ http://webassembly.org/docs/use-cases/
Node.js x Native Modules
Node.js x Native Module • NAN Ͱ࡞ͬͯϞδϡʔϧΛϥοϓ͢Δ • node-ffi Ͱ
FFI ݺͼग़͠ʹ͢Δ • emscriptenͰasm.jsʹ͢Δ • emscriptenͰwasmʹ͢Δ
Node.js x Native Module • NAN Ͱ࡞ͬͯϞδϡʔϧΛϥοϓ͢Δ
Node.js x Native Module • NAN Ͱ࡞ͬͯϞδϡʔϧΛϥοϓ͢Δ • V8ͷAPIόʔδϣϯมΘΔͱେମյΕΔ •
ͦΕʹґଘ͍ͯ͠ΔNative Moduleେମյ ΕΔ • ͦͷAPIΛநԽͯ͠ٵऩ͢Δͷ͕NAN
Node.js x Native Module • NAN Ͱ࡞ͬͯϞδϡʔϧΛϥοϓ͢Δ • ࣗ༝͕ߴ͍ •
ͦͷΘΓbindingͷͨΊͷίʔυΛ৭ʑ֤ ඞཁ͕͋Δ
Node.js x Native Module • node-ffi Ͱ FFI ݺͼग़͠ʹ͢Δ
Node.js x Native Module • node-ffi Ͱ FFI ݺͼग़͠ʹ͢Δ •
Foreign Function Interface (ݴޠ͕༻ҙͯ͠ ͘Ε͍ͯΔಛ༗ͷ֎෦ݺͼग़͠ػೳ) • libffi Λ library ͱͯ͠ϩʔυ͍ͯ͠ΔͷͰC C++ͷίʔυͰ͋Εಈ͘
Node.js x Native Module • node-ffi Ͱ FFI ݺͼग़͠ʹ͢Δ •
؆୯ • ͨͩ͠ɺ֎෦ݺͼग़͠ʹͳΔͨΊFFI͍
Node.js x Native Module • emscriptenͰasm.jsʹ͢Δ
Node.js x Native Module • emscriptenͰasm.jsʹ͢Δ • emscriptenͷఏڙ͢ΔίϯύΠϥͰasm.jsԽ͢ Δ •
asm.jsMozilla͕ఏএɺChrome/Edgeα ϙʔτ༧ఆͰwasmͷpolyfillͱͯ͠ಈ͘Մೳ ੑ͋Γ
Node.js x Native Module • emscriptenͰasm.jsʹ͢Δ • ؆୯ʢ͚ͩͲɺҙ֎ͱಈ͔ͳ͔ͬͨΓ͢Δʣ • શͯJavaScriptʹͳΓɺϑΝΠϧαΠζ͕ڊେʹ
ͳΔ • ࣮ࡍNode.jsͷཪͷv8asm.jsΛϑϧαϙʔτ ͯ͠ͳ͔ͬͨΓͰ͋·Γ͘ͳ͍
Node.js x Native Module • emscriptenͰwasmʹ͢Δ (NEW!!)
Node.js x Native Module • emscriptenͰwasmʹ͢Δ • asm.jsͱಉ͡؆୯͞ • v8ͷ࠷৽ͩͱwasmରԠࡁΈͳͷͰී௨ʹಈ͘
• ·ͩ·ͩʢJSJIT͕ޮ͘ͷͰ୯७ͳܭ ࢉͩͱ JS > WebAssemblyʹͳΔ͜ͱ͋Δʣ
͞Βʹ࠷ۙͰ
Node.js ʹ stable module ABI ͷ PR͕Ճ͞ΕͯΔ • https://github.com/nodejs/node/pull/11975
Node.js ʹ stable module ABI ͷ PR͕Ճ͞ΕͯΔ • ͳͷͰɺ5ͭ: stable
module ABIͰ࡞Δ • ͍উखతʹNANͱҰॹ • ৽͍͠APIͳͷͰதʢ·ͩࢼͯ͠ͳ͍ʣ
ͳͷͰ
Node.js x Native Module • NAN Ͱ࡞ͬͯϞδϡʔϧΛϥοϓ͢Δ • node-ffi Ͱ
FFI ݺͼग़͠ʹ͢Δ • emscriptenͰasm.jsʹ͢Δ • emscriptenͰwasmʹ͢Δ (new!!! node v8 Ͱ༗ޮʹ) • stable module ABI ʹ͢Δ (new!!! node v8 Ͱ༗ޮʹ)
WebAssembly DEMO
butteraugly DEMO
Node.js x WebAssembly • ࢥ৭ʑ͋ΕͲ໘ന͍ • WebAssemblyʹͨ͠΄͏͕ϒϥβͰ Ͱ͖Δ͜ͱ͕ଟ͘ͳΔͱࢥΘΕΔ • ࠓ·ͩΈΜͳ৭ʑτϥΠͯ͠νΣοΫͯ͠
Δ࠷த