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

WebAssembly - post MVP features and goals

WebAssembly - post MVP features and goals

Slides for a talk presented at ParisJS meetup, link to the talk: https://www.youtube.com/watch?v=nOG0lHpRxQ8

Topics:
- WebAssembly working group
- Threads
- WebAssembly runtime performance
- WebAssembly load perfomrnace
- High-level language features

9682f6f8a447d952b412de9d42860130?s=128

Elia Maino

June 26, 2019
Tweet

Transcript

  1. WebAssembly post MVP features and goals

  2. Elia Maino Software Engineer @eliamain

  3. WASM MVP 2017

  4. emscripten C/C++ code JS (asm.js)

  5. Any code Agnostic Compile target For a virtual machine

  6. WASM

  7. WASM Fast Browser security Memory management execution load

  8. WASM MVP

  9. WASM MVP Was it the final version? Is it feature

    complete?
  10. WASM MVP Works fine for some application Not enough for

    other ones
  11. We need more https://github.com/WebAssembly/design/blob/master/FutureFeatures.md https://github.com/WebAssembly/design

  12. None
  13. Features proposals

  14. The mission of the WebAssembly Working Group is to standardize

    a size- and load-time-efficient format and execution environment, allowing compilation to the web with consistent behavior across a variety of implementations.
  15. Features proposals WebAssembly W3C process https://github.com/WebAssembly/meetings/blob/master/process/phases.md “ A feature is

    a substantial change to WebAssembly, such that it for example requires additional opcodes, types, tests, or module sections. ”
  16. WebAssembly W3C process https://github.com/WebAssembly/meetings/blob/master/process/phases.md Pre-proposal Feature proposal Proposed Spec Text

    Available Implementation Phase Standardize the feature Feature is standardized
  17. Performance

  18. Performance MULTI THREADING Take advantage of multi cores architectures https://github.com/WebAssembly/threads

    Status: Proposed spec text available
  19. Performance MULTI THREADING Status: Proposed spec text available Experimental feature

    https://developers.google.com/web/updates/2018/10/wasm-threads Security issues with SharedArrayBuffer https://github.com/emscripten-core/emscripten/wiki/Pthreads-with-WebAssembly https://blog.mozilla.org/security/2018/01/03/mitigations-landing-new-class-timing- attack/
  20. https://web.dev/earth-webassembly/

  21. https://github.com/rhysd/vim.wasm

  22. Please access from desktop Chrome, Firefox, Safari or Chromium based

    browsers since this project uses SharedArrayBuffer and Atomics. On Firefox or Safari, feature flags (javascript.options.shared_memory for Firefox) must be enabled for now.
  23. None
  24. Performance SIMD Single Instruction Multiple Data: process things in parallel

    https://github.com/WebAssembly/simd/blob/master/proposals/simd/SIMD.md Status: Feature proposal
  25. VS data parallelism concurrency (multithreading) (SIMD)

  26. data parallelism concurrency

  27. Performance 64-bit addressing Remove the artificial limitation of addressable space

    From WebAssembly https://github.com/WebAssembly/design/blob/master/FutureFeatures.md#linear- memory-bigger-than-4-gib Status: Pre-proposal
  28. Language Features FRAMEWORKS COMPILE TO-JS

  29. Language Features GARBAGE COLLECTOR EXCEPTION HANDLING DEBUGGING TAIL CALLS

  30. Language Features GARBAGE COLLECTOR Add an integration with the browser

    garbage collector JS needs a way to describe an object fixed structure Typed objects: https://github.com/tschneidereit/proposal-typed-objects WebAssembly GC: https://github.com/WebAssembly/gc Status: Feature proposal
  31. Language Features EXCEPTION HANDLING Proper support for languages exceptions By

    default disabled in WebAssembly when compiling (there’s an heavy polyfill) Hard to handle the case when WASM calls some JS code which throws an exception :/
  32. Language Features EXCEPTION HANDLING Proper support for languages exceptions Status:

    Feature proposal https://github.com/WebAssembly/exception-handling
  33. Language Features DEBUGGING DevTools for JS debugging are great Support

    a similar level of debugging for WebAssembly https://github.com/WebAssembly/debugging
  34. Loadtime ⏳

  35. Why is that even needed?

  36. Why is that even needed? PREDICTABLE PERFORMANCE CODE IS COMPILED

    AHEAD OF TIME
  37. Loadtime STREAMING COMPILATION Compile a WebAssembly file while it’s still

    being downloaded
  38. Loadtime STREAMING COMPILATION Compile a WebAssembly file while it’s still

    being downloaded .wasm browser compiler
  39. Loadtime STREAMING COMPILATION Compile a WebAssembly file while it’s still

    being downloaded browser compiler
  40. Loadtime STREAMING COMPILATION Compile a WebAssembly file while it’s still

    being downloaded browser compiler
  41. Loadtime STREAMING COMPILATION Compile a WebAssembly file while it’s still

    being downloaded browser compiler
  42. Loadtime STREAMING COMPILATION Compile a WebAssembly file while it’s still

    being downloaded browser compiler
  43. Loadtime STREAMING COMPILATION Compile a WebAssembly file while it’s still

    being downloaded browser compiler
  44. Loadtime STREAMING COMPILATION Compile a WebAssembly file while it’s still

    being downloaded browser compiler
  45. Loadtime STREAMING COMPILATION Compile a WebAssembly file while it’s still

    being downloaded .wasm browser compiler
  46. Loadtime STREAMING COMPILATION Compile a WebAssembly file while it’s still

    being downloaded browser compiler
  47. Loadtime STREAMING COMPILATION Compile a WebAssembly file while it’s still

    being downloaded browser compiler
  48. Loadtime STREAMING COMPILATION Compile a WebAssembly file while it’s still

    being downloaded browser compiler
  49. Loadtime STREAMING COMPILATION Compile a WebAssembly file while it’s still

    being downloaded browser compiler
  50. Loadtime STREAMING COMPILATION Compile a WebAssembly file while it’s still

    being downloaded Status: Shipped (depends on the browser)
  51. Loadtime STREAMING COMPILATION Status: Shipped (depends on the browser) https://v8.dev/blog/v8-release-65

    Shipped https://hacks.mozilla.org/2018/01/making-webassembly-even-faster-firefoxs-new- streaming-and-tiering-compiler/ Shipped
  52. Loadtime TIERED COMPILATION Having more than one compiler in action

  53. Loadtime TIERED COMPILATION Having more than one compiler in action

    .wasm browser compiler
  54. Loadtime TIERED COMPILATION Having more than one compiler in action

    browser compiler
  55. Loadtime TIERED COMPILATION Having more than one compiler in action

    browser compiler
  56. Loadtime TIERED COMPILATION Having more than one compiler in action

    browser basic compiler optimizing compiler
  57. Loadtime TIERED COMPILATION Having more than one compiler in action

    browser basic compiler optimizing compiler ✨
  58. Loadtime TIERED COMPILATION Having more than one compiler in action

    browser optimizing compiler ✨ basic compiler
  59. Loadtime TIERED COMPILATION Having more than one compiler in action

    Status: Shipped (depends on the browser)
  60. Loadtime TIERED COMPILATION Status: Shipped (depends on the browser) https://v8.dev/blog/liftoff

    https://hacks.mozilla.org/2018/01/making-webassembly-even-faster-firefoxs-new- streaming-and-tiering-compiler/ https://github.com/CraneStation/cranelift https://webkit.org/blog/7691/webassembly/ (OMG! BBQ!)
  61. Loadtime Implicit HTTP caching Take advantage of WebAssembly predictable compilation

    output Using the already compiled machine code Instead of the .wasm file Status: Work in progress
  62. Loadtime Implicit HTTP caching Status: Work in progress https://v8.dev/blog/wasm-code-caching Work

    in progress https://bugzilla.mozilla.org/show_bug.cgi?id=1487113 Shipped
  63. Modules

  64. Modules Calls between JS and WASM Calls between the two

    environments where working in the MVP But weren’t optimized to be fast https://hacks.mozilla.org/2018/10/calls-between-javascript-and-webassembly-are-finally-fast- %f0%9f%8e%89/ Status: Shipped (in )
  65. None
  66. Modules Data exchange between JS and WASM WASM only understands

    numbers, add a way to pass/ reference objects too https://github.com/WebAssembly/reference-types/blob/master/proposals/reference-types/ Overview.md Status: Implementation Phase
  67. Modules ES Modules integration Load WebAssembly from a JavaScript import

    statement, or a <script type=module> tag https://github.com/WebAssembly/esm-integration/tree/master/proposals/esm- integration Status: Feature proposal
  68. None
  69. is WebAssembly only useful in the browser?

  70. browsers portability security

  71. None
  72. portability security

  73. None
  74. WebAssembly System Interface https://wasi.dev/ https://hacks.mozilla.org/2019/03/standardizing-wasi-a-webassembly-system-interface/ https://github.com/WebAssembly/WASI

  75. Threads GC SIMD Modules Tiered compilation Exceptions Debugging ✨

  76. Thank you! @eliamain