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
520
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
1.1k
Давайте все заблокируем
hellsquirrel
0
370
Wasmысле?
hellsquirrel
0
280
Магия декларативныx схем.
hellsquirrel
0
400
ML for HolyJS
hellsquirrel
0
200
Идеальный способ заблюрить белочку
hellsquirrel
0
190
ML/DL на фронте
hellsquirrel
0
250
InsertableStreams
hellsquirrel
0
120
WebRTC-404
hellsquirrel
0
580
Other Decks in Programming
See All in Programming
tsc.rip を支える技術 / Kyoto.なんか #8
susisu
0
4.3k
FastAPI の並行処理モデルを完全に理解する
hoto17296
9
3.8k
XP祭りでしか伝わらないフリップネタ #xpjug
murabayashi
0
110
XHTMLが残したもの
yosuke_furukawa
PRO
1
420
型解析で実現する Go の言語内 DSL / Conference に Go! タイムテーブルの歩き方 for Gophers
mazrean
0
130
AIは賢い。でも実行環境は? CLIおじさんがAI時代に伝えたいこと ~ CLIおじさんがAI時代に伝えたいこと ~
curekoshimizu
1
160
AWS DevOps Agentで インシデント対応をAIに任せたい
honmarkhunt
6
2.4k
typoなんかねぇよ
raspython3
0
670
AWS Step Functions 大規模並列の壁を越える / jaws-sonic-2026-niigata-step-functions
kasacchiful
PRO
0
380
Can LLMs Replicate 4 Years of Compose Migration? Exploring the boundaries of automation with 279 XML files from a real product
makun
0
130
ALB ログから Trace を気合で繋げる技術
fohte
7
880
AI駆動開発にグラフDBを重ねてみた
satoshi256kbyte
2
750
Featured
See All Featured
How to build a perfect <img>
jonoalderson
1
6k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
3k
コードの90%をAIが書く世界で何が待っているのか / What awaits us in a world where 90% of the code is written by AI
rkaga
63
45k
Navigating Algorithm Shifts & AI Overviews - #SMXNext
aleyda
1
1.6k
Neural Spatial Audio Processing for Sound Field Analysis and Control
skoyamalab
0
470
HTML-Aware ERB: The Path to Reactive Rendering @ RubyCon 2026, Rimini, Italy
marcoroth
4
590
Building a A Zero-Code AI SEO Workflow
portentint
PRO
0
710
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.9k
Optimizing for Happiness
mojombo
378
71k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k
Learning to Love Humans: Emotional Interface Design
aarron
275
41k
Paper Plane (Part 1)
katiecoart
PRO
1
11k
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