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

An introduction to WebAssembly

An introduction to WebAssembly

吉祥寺.pm8 で発表した資料
http://kichijojipm.connpass.com/event/34598/

Pine Mizune

July 29, 2016
Tweet

More Decks by Pine Mizune

Other Decks in Programming

Transcript

  1. Pine Mizune
    Jul 29, 2016 / Kichijoji.pm #8
    An introduction to
    WebAssembly

    View full-size slide

  2. 1SPGJMF
    o (JU)VC !QJOF
    o 5XJUUFS!QJOF
    o ޷͖ͳݴޠ +BWB4DSJQU
    o ࢓ࣄͰॻ͍͍ͯΔݴޠ1FSM+4
    o .PCJMF'BDUPSZ *OD

    View full-size slide

  3. 8FC"TTFNCMZ ͱ͸
    8FC"TTFNCMZ ͷ࠷ۙͷಈ޲
    8FC"TTFNCMZ ͷϝϦοτ
    8FC"TTFNCMZ ͷར༻ϑϩʔ
    σϞ
    5BCMFPGDPOUFOUT

    View full-size slide

  4. ϒϥ΢β޲͚ ࣮ߦՄೳόΠφϦϑΥʔϚοτ
    • +BWB4DSJQUͷ୅ସͰ͸ͳ͍
    • --7.ܥݴޠ͔ΒίϯύΠϧՄೳ
    • $ISPNF'JSFGPY /JHIUMZ
    Ͱ࣮૷ࡁΈ
    8FC"TTFNCMZͱ͸
    C/C++/Rust WebAssembly
    LLVM compiler

    View full-size slide

  5. C/C++/Rust
    WebAssembly
    Compiler
    94࢖͑͹$$Ͱڞ௨Մೳ
    • [MJCD ͳͲ΋ಈ͘Α
    Perl / XS
    1FSMͱ૊Έ߹Θͤͯ࢖͏ͳΒ

    View full-size slide

  6. n $ISPNFɺ8FC,JUɺ'JSFGPYɺ.JDSPTPGU&EHFɺ--7
    .ɺ6OJUZΒ͕αϙʔτΛද໌

    IUUQXXXQVCMJDLFZKQCMPHXFCBTTFNCMZIUNM
    n 7ɺ'JSFGPYɺ.JDSPTPGU&EHF͕ʮ8FC"TTFNCMZʯ
    ͷ࣮૷Λൃද ʢ

    IUUQXXXQVCMJDLFZKQCMPHWGJSFGPYNJDSPTPGU@FEHFXFC
    BTTFNCMZXFCIUNM
    8FC"TTFNCMZͷ࠷ۙͷಈ޲

    View full-size slide

  7. 8FC"TTFNCMZ ͷϝϦοτ
    ߴ଎࣮ߦͱলϑΝΠϧαΠζ
    • ϒϥ΢βԋࢉॲཧͷߴ଎Խ ήʔϜ ը૾ॲཧ FUD

    – ߴ଎ 8FC"TTFNCMZ BTNKT +BWB4DSJQU௿଎
    – ˞BTNKT .P[JMMB։ൃͷ +4ʹ੩తղੳ৘ใΛ෇༩ͨ͠αϒηοτ
    • సૹϑΝΠϧ༰ྔͷ࡟ݮ
    – BTNKT ͸ߴ଎ʹ࣮ߦͰ͖Δ͕ϑΝΠϧαΠζ͕ωοΫ
    – όΠφϦϑΥʔϚοτʹ͢Δ͜ͱͰղܾ

    View full-size slide

  8. 8FC"TTFNCMZ ͷར༻ϑϩʔ

    ソースコード
    .ll
    .s
    .wast
    .wasm
    .c/.cpp
    LLVM IR (中間表現)
    WebAssembly のアセンブラ
    wasm のテキスト形式 (S式)
    wast をシリアライズしたもの

    View full-size slide

  9. 8FC"TTFNCMZ XBTU ܗࣜྫ
    (module
    (memory 1
    (segment 8 "¥00¥00¥00¥00")
    )
    (export "memory" memory)
    (export "count" $count)
    (func $count (result i32)
    (local $$0 i32)
    (i32.store offset=8
    (i32.const 0)
    (i32.add
    (set_local $$0

    View full-size slide

  10. 8FC"TTFNCMZ ͷར༻ϑϩʔ

    ソースコード
    .ll
    .s
    .wast
    .wasm
    .c/.cpp
    wast をシリアライズしたもの
    ★ 簡単に試すなら Emscripten がオススメ

    View full-size slide

  11. QJOFNEXBTNFYBNQMF
    IUUQTHJUIVCDPNQJOFNEXBTNFYBNQMF
    σϞ

    View full-size slide