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

Node.js x WebAssembly

Node.js x WebAssembly

Node学園24時限目で発表した Node.js と WebAssembly のデモですー。

Yosuke Furukawa

March 31, 2017
Tweet

More Decks by Yosuke Furukawa

Other Decks in Programming

Transcript

  1. WebAssembly Use Cases • BrowerҎ֎ͷϢʔεέʔε • Server Side application •

    Native Apps on mobile devices http://webassembly.org/docs/use-cases/
  2. Node.js x Native Module • NAN Ͱ࡞ͬͯϞδϡʔϧΛϥοϓ͢Δ • node-ffi Ͱ

    FFI ݺͼग़͠ʹ͢Δ • emscriptenͰasm.jsʹ͢Δ • emscriptenͰwasmʹ͢Δ
  3. Node.js x Native Module • NAN Ͱ࡞ͬͯϞδϡʔϧΛϥοϓ͢Δ • V8ͷAPI͸όʔδϣϯมΘΔͱେମյΕΔ •

    ͦΕʹґଘ͍ͯ͠ΔNative Module΋େମյ ΕΔ • ͦͷAPIΛந৅Խͯ͠ٵऩ͢Δͷ͕NAN
  4. Node.js x Native Module • node-ffi Ͱ FFI ݺͼग़͠ʹ͢Δ •

    Foreign Function Interface (ݴޠ͕༻ҙͯ͠ ͘Ε͍ͯΔಛ༗ͷ֎෦ݺͼग़͠ػೳ) • libffi Λ library ͱͯ͠ϩʔυ͍ͯ͠ΔͷͰC ΍C++ͷίʔυͰ͋Ε͹ಈ͘
  5. Node.js x Native Module • node-ffi Ͱ FFI ݺͼग़͠ʹ͢Δ •

    ؆୯ • ͨͩ͠ɺ֎෦ݺͼग़͠ʹͳΔͨΊFFI͸஗͍
  6. Node.js x Native Module • emscriptenͰasm.jsʹ͢Δ • emscriptenͷఏڙ͢ΔίϯύΠϥͰasm.jsԽ͢ Δ •

    asm.js͸Mozilla͕ఏএɺChrome/Edge΋α ϙʔτ༧ఆͰwasmͷpolyfillͱͯ͠΋ಈ͘Մೳ ੑ͋Γ
  7. Node.js x Native Module • emscriptenͰwasmʹ͢Δ • asm.jsͱಉ͡؆୯͞ • v8ͷ࠷৽ͩͱwasmରԠࡁΈͳͷͰී௨ʹಈ͘

    • ଎౓͸·ͩ·ͩʢJS͸JIT͕ޮ͘ͷͰ୯७ͳܭ ࢉͩͱ JS > WebAssemblyʹͳΔ͜ͱ΋͋Δʣ
  8. Node.js ʹ stable module ABI ͷ PR͕௥Ճ͞ΕͯΔ • ͳͷͰɺ5ͭ໨: stable

    module ABIͰ࡞Δ • ࢖͍উखతʹ͸NANͱҰॹ • ৽͍͠APIͳͷͰ஫໨தʢ·ͩࢼͯ͠ͳ͍ʣ
  9. Node.js x Native Module • NAN Ͱ࡞ͬͯϞδϡʔϧΛϥοϓ͢Δ • node-ffi Ͱ

    FFI ݺͼग़͠ʹ͢Δ • emscriptenͰasm.jsʹ͢Δ • emscriptenͰwasmʹ͢Δ (new!!! node v8 Ͱ͸༗ޮʹ) • stable module ABI ʹ͢Δ (new!!! node v8 Ͱ͸༗ޮʹ)