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
Wasm 101
Search
Polina Gurtovaya
March 19, 2020
Programming
510
2
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Wasm 101
WebAssembly с нуля :)
Polina Gurtovaya
March 19, 2020
More Decks by Polina Gurtovaya
See All by Polina Gurtovaya
Не учите алгоритмы
hellsquirrel
1
1k
Давайте все заблокируем
hellsquirrel
0
360
Wasmысле?
hellsquirrel
0
270
Магия декларативныx схем.
hellsquirrel
0
390
ML for HolyJS
hellsquirrel
0
190
Идеальный способ заблюрить белочку
hellsquirrel
0
190
ML/DL на фронте
hellsquirrel
0
240
InsertableStreams
hellsquirrel
0
120
WebRTC-404
hellsquirrel
0
570
Other Decks in Programming
See All in Programming
代数的データ型って何が嬉しいの? #frontend_phpcon_do
kajitack
8
3.3k
Hunting Vulnerabilities in Symfony with LLMs
vinceamstoutz
0
530
dRuby over BLE
makicamel
2
330
セキュリティの専門家じゃなくてもできる。「セキュリティ意識」をアップデートして サプライチェーン攻撃への耐性を高めよう。
tk3fftk
5
690
エージェンティックRAGにAWSで入門しよう!
har1101
8
1.4k
軽量Java基盤の設計 DIコンテナに頼らない、長期保守と1秒起動の実現 JJUG CCC 2026 Spring
macha64
0
490
「AIで開発し、AIを届ける」をEvalでつなぐ 〜AIネイティブに始めるプロダクト開発の実践〜 / Connecting "Develop with AI, deliver AI" with Eval
rkaga
4
4.9k
These Five Tricks Can Make Your Apps Greener, Cheaper, & Nicer
hollycummins
0
280
コンテキストの使い捨てをやめる — ビジネスルール駆動開発と miko —
ioki
0
180
メソッドのジェネリクスでGoの夢は広がるか? / Kyoto.go #65
utgwkk
3
660
ふつうのFeature Flag実践入門
irof
7
3.7k
さぁV100、メモリをお食べ・・・
nilpe
0
130
Featured
See All Featured
Information Architects: The Missing Link in Design Systems
soysaucechin
0
960
The Straight Up "How To Draw Better" Workshop
denniskardys
239
140k
Mind Mapping
helmedeiros
PRO
1
240
Scaling GitHub
holman
464
140k
Conquering PDFs: document understanding beyond plain text
inesmontani
PRO
4
2.8k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
250
1.3M
30 Presentation Tips
portentint
PRO
1
320
Ecommerce SEO: The Keys for Success Now & Beyond - #SERPConf2024
aleyda
1
2k
Lightning talk: Run Django tests with GitHub Actions
sabderemane
0
200
What's in a price? How to price your products and services
michaelherold
247
13k
What Being in a Rock Band Can Teach Us About Real World SEO
427marketing
0
250
Leo the Paperboy
mayatellez
7
1.8k
Transcript
Wasm 101
2
3
4
5 Ссылка на слайды и прочие материалы будет в конце
доклада
Wasm 101
7 Wasm можно использовать везде кроме IE
8 WebAssembly Core
9 WebAssembly is a binary instruction format for a stack-based
virtual machine.
10 (func (export "add") (param i32) (param i32) (result i32)
local.get 0 local.get 1 i32.add) add(1, 2) Module Memory Function Instruction Table
11 .wasm и .wat У WebAssembly есть текстовое представление
12 (module (func $i (import "imports" "logger") (param i32)) (memory
(import "imports" "importedMemory") 1) (func (export "exportedFunc") i32.const 42 call $i) (func (export "add") (param i32 i32) (result i32) local.get 0 local.get 1 i32.add) (data (i32.const 0) "Fifty"))
Embeddings 13
Wasm и JavaScript — лучшие друзья 14 (module (func $i
(import "imports" "logger") (param i32)) (memory (import "imports" "importedMemory") 1) (func (export "exportedFunc") i32.const 42 call $i) (func (export "add") (param i32 i32) (result i32) local.get 0 local.get 1 i32.add) (data (i32.const 0) "tver.io")) const importedMemory = new WebAssembly.Memory({ initial: 1, maximum: 10 }); WebAssembly.instantiateStreaming(fetch("simple.wasm"), { imports: { logger: function(arg) { console.log("first function call", arg); }, importedMemory } }).then(obj => { obj.instance.exports.exportedFunc(); const three = obj.instance.exports.add(1, 2); console.log("1 + 2 =", three); var memoryArray = new Uint32Array(importedMemory.buffer, 0, 10); console.log( "reading from memory", new TextDecoder("utf8").decode(memoryArray) ); });
Мы поняли, что: Wasm = IR Wasm легко парсить Wasm
= легкий формат Wasm = песочница 15
Portability в примерах Pyodide Squoosh Unity 16
17 WebAssembly embeddings
18 Wasm это технология для Web?
19 Да: пилится под Web
20 Wasm design principles Модульность из коробки Живет в песочнице
Работает быстро Не ломает Web
21 Нет: может быть любой embedder
22 C/C++ wasm (emscripten)
23 JS vs. asm.js vs. wasm
Hello world на 300Кб 24
25 emcc -O3 \ -s ENVIRONMENT="web" \ -s EXTRA_EXPORTED_RUNTIME_METHODS='["cwrap"]' \
-I libwebp libwebp/src/{dec,dsp,demux,enc,mux,utils}/*.c \ -o encoder.js encoder.c Вот так можно скомпилировать libwebp в wasm
26 Что насчет других языков? wasm-pack Assembly Script
27 Performance
28 Скорость wasm зависит окружения
29 V8
30 V8
31 Чтобы все было быстро, делайте так: WebAssembly.instantiateStreaming Content-Type: application/wasm
32 Что планируется дальше? Status: MVP SIMD Threads
33 Wasm и webpack { test: /\.wasm$/, type: "javascript/auto", loader:
"file-loader" },
34 Как дебажить?
35 Как дебажить?
36 Wasm дополняет JS-экосистему Wasm = predictable performance Фууух, почти
все :)
37 Спасибо! @polina_gurtovaya @pgurtovaya
[email protected]
37 @evilmartians @evilmartians_ru evilmartians.com github.com/HellSquirrel/wasm-101-talk