web assembly overview by mikhail sorokovsky

28
WebAssembly overview

Upload: valeriia-maliarenko

Post on 16-Jan-2017

145 views

Category:

Education


5 download

TRANSCRIPT

Page 1: Web assembly overview by Mikhail Sorokovsky

WebAssembly overview

Page 2: Web assembly overview by Mikhail Sorokovsky

• What is WebAsembly• What it is for?• WebAssembly Structure• Tools• How to use it• Roadmap

Agenda

Page 3: Web assembly overview by Mikhail Sorokovsky

• New Standard developed by Mozilla, Microsoft, Google and Apple

• Compact, portable binary format for web• Fast to load, runs safely• Near-native performance• Works on any device

What is WebAsembly

Page 4: Web assembly overview by Mikhail Sorokovsky

The Story• Key person: Brendan Eich• 1995 – Created JavaScript• 1995 - Leading SpiderMonkey• 1998 – Started Mozilla• 2009 – asm.js Mozilla experiment• 2013 – asm.js Published• 2013 – Spread asm.js idea to

Microsoft• 2014-15 – Make other browser

vendors to join WebAssembly W3C Group

Page 5: Web assembly overview by Mikhail Sorokovsky

• Intermediate language• Subset of Javascript• C/C++ compiles to asm.js• Very fast. Best result 1.5x native• Natively runs in Firefox, Edge, Chrome

asm.js

Page 6: Web assembly overview by Mikhail Sorokovsky
Page 7: Web assembly overview by Mikhail Sorokovsky
Page 8: Web assembly overview by Mikhail Sorokovsky

• Low-Level compiler target• Less Size• Less Cold Start • Readable textual representation• Convenient Debugger• Compile-time optimization• Bytecode instructions ~= CPU instructions

WebAssembly is asm.js Evolution

Page 9: Web assembly overview by Mikhail Sorokovsky

WebAssembly isbinary AST

• Small set of types• Basic operations• Control flows• Memory

management

Page 10: Web assembly overview by Mikhail Sorokovsky

• Fill gaps in JavaScript• Develop using language you like• Heavy calculation• Examples:

• P2P applications• Image / Video / Music editing• Live video augmentation• Platform simulation• CAD application

What it is for?

Page 12: Web assembly overview by Mikhail Sorokovsky

WebAssembly structure

WASM

MODULE A MODULE B

MODULE C

MODULE D

TYPE IMPORT FUNCTION

TABLE MEMORY EXPORT

START CODE DATA NAME

Page 13: Web assembly overview by Mikhail Sorokovsky

Operators Example

Operator CPU Description

i32.add addl Sign-agnostic addition

call call Call function directly

i32.load check + mov Load 4 bytes as i32

nop nop No operation

br_if je Conditional break / jump

Page 14: Web assembly overview by Mikhail Sorokovsky

• All tools are in develop!!!• Mostly unstable• Officially 2 ways to built wasm• wasm binary standard is in development too!!• Browser might not be able to process wasm in

the moment

TOOLS

Page 15: Web assembly overview by Mikhail Sorokovsky

BINARYEN

asm2wasm ./fibonacci.asm.js –o fibanacci.wast

wasm-as fibanacci.wast –o fibanacci.wasm

https://github.com/WebAssembly/binaryen

Page 16: Web assembly overview by Mikhail Sorokovsky

EMSCRIPTEN “incoming” branch

http://kripken.github.io/emscripten-site/Does not working right now

Try this for your own risk

http://floooh.github.io/fips/index.html

Page 17: Web assembly overview by Mikhail Sorokovsky

• WebAssembly playground• ilwasm - .NET CIL => WebAssembly

OTHER

Page 18: Web assembly overview by Mikhail Sorokovsky

• 15 March 2016 – Experimental support of WebAssembly

• FirefoxNightly• Microsoft Edge• Google Chrome• Chromium

How To Use

Page 19: Web assembly overview by Mikhail Sorokovsky

Execution

Page 20: Web assembly overview by Mikhail Sorokovsky

How To Use WebAssembly

Page 21: Web assembly overview by Mikhail Sorokovsky

How To Use WebAssembly: dependencies

Page 22: Web assembly overview by Mikhail Sorokovsky

How To Use WebAssembly: dependencies

Page 23: Web assembly overview by Mikhail Sorokovsky

Roadmap: MVP ~~~~ THIS YEAR

• Any asm.js => wasm• Validation• Execution• Module• Text / Binary format• Cross-browser support• Polyfill-able in JS

Page 24: Web assembly overview by Mikhail Sorokovsky

Roadmap: Soon After MVP

• Threads• Shared Memory• Dynamic Linking• Fixed-width SIMD• Zero-cost exceptions

Page 25: Web assembly overview by Mikhail Sorokovsky

Roadmap: Future priorities

• Fain-grained memory control• Large Page Support• GC/DOM integration• Memory > 4GiB• And much more

Page 26: Web assembly overview by Mikhail Sorokovsky

Conclusions

• Binary Executable format for web• New Web Standard – part of W3C• Developed by Key Players on the Web• Low-level compiler target• JavaScript brother• Developed for real computations in browser

Page 27: Web assembly overview by Mikhail Sorokovsky

Thank You!

Page 28: Web assembly overview by Mikhail Sorokovsky

Links• https://wasm.news/• http://blog.golovin.in/how-to-start-using-

webassembly-today/• https://callahad.github.io/tccc20-wasm/• https://github.com/WebAssembly/build-suite• https://github.com/kripken/emscripten/wiki/

Porting-Examples-and-Demos