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
StarlingMonkeyを触ってみた話 - 2024冬
Search
syumai
December 11, 2024
Programming
3
450
StarlingMonkeyを触ってみた話 - 2024冬
新宿御苑.wasm #2024.12.11 の発表資料です
https://shinjukugyoen.connpass.com/event/338017/
syumai
December 11, 2024
Tweet
Share
More Decks by syumai
See All by syumai
ProxyによるWindow間RPC機構の構築
syumai
3
1.2k
CloudflareのChat Agent Starter Kitで簡単!AIチャットボット構築
syumai
2
510
Go製CLIツールをnpmで配布するには
syumai
2
1.4k
MCPで実現できる、Webサービス利用体験について
syumai
7
2.7k
GoのGenericsによるslice操作との付き合い方
syumai
3
890
GoのWebAssembly活用パターン紹介
syumai
3
11k
Cloudflare Workersで進めるリモートMCP活用
syumai
13
2.6k
Go 1.24でジェネリックになった型エイリアスの紹介
syumai
2
660
初めてDefinitelyTypedにPRを出した話
syumai
1
750
Other Decks in Programming
See All in Programming
Namespace and Its Future
tagomoris
6
710
個人軟體時代
ethanhuang13
0
330
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
420
JSONataを使ってみよう Step Functionsが楽しくなる実践テクニック #devio2025
dafujii
1
640
プロポーザル駆動学習 / Proposal-Driven Learning
mackey0225
2
1.3k
時間軸から考えるTerraformを使う理由と留意点
fufuhu
16
4.8k
AIでLINEスタンプを作ってみた
eycjur
1
230
デザイナーが Androidエンジニアに 挑戦してみた
874wokiite
0
550
testingを眺める
matumoto
1
140
複雑なドメインに挑む.pdf
yukisakai1225
5
1.2k
Swift Updates - Learn Languages 2025
koher
2
510
Oracle Database Technology Night 92 Database Connection control FAN-AC
oracle4engineer
PRO
1
470
Featured
See All Featured
Bootstrapping a Software Product
garrettdimon
PRO
307
110k
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
8
530
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
252
21k
Stop Working from a Prison Cell
hatefulcrawdad
271
21k
Building a Scalable Design System with Sketch
lauravandoore
462
33k
Visualization
eitanlees
148
16k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
285
14k
Docker and Python
trallard
46
3.6k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
26
3k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
131
19k
Intergalactic Javascript Robots from Outer Space
tanoku
272
27k
Git: the NoSQL Database
bkeepers
PRO
431
66k
Transcript
StarlingMonkey を触ってみた話 - 2024 冬 syumai 新宿御苑.wasm (2024/12/11)
自己紹介 syumai ECMAScript 仕様輪読会 / Asakusa.go 主催 株式会社ベースマキナで管理画面のSaaS を開発中 Go
でGraphQL サーバー (gqlgen) や TypeScript でフロント エンドを書いています Software Design 2023 年12 月号からCloudflare Workers の連載 をしてます Twitter ( 現𝕏): @__syumai Website: https://syum.ai
StarlingMonkey とは
StarlingMonkey とは Bytecode Alliance のOrganization 配下でメンテナンスされているSpiderMonkey のfork SpiderMonkey は言わずと知れた、Mozilla Firefox
のJS エンジン WebAssembly Component Model で使いやすくするための最適化が行われている
StarlingMonkey はどこで使われているのか? Fastly のjs-compute-runtime Fastly Compute はWasm を実行するランタイム JS を実行するには、JS
エンジンをWasm 化して組み込む必要がある ComponentizeJS JS のコードをWebAssembly Components として使えるように変換するツール StarlingMonkey をそのままWasm バイナリにバンドルする Fermyon のSpin JS SDK ComponentizeJS を組み込んだSDK なので、StarlingMonkey の利用は間接的 事情はFastly Compute に似ている Spin は、WebAssembly Component をデプロイできる基盤
StarlingMonkey の成り立ち ( 注) 完全に追っていた訳ではないので、断片的です! もともと、Fastly のjs-compute-runtime が内部で使用しているSpiderMonkey fork が
Bytecode Alliance 配下にあった 実はまだある: bytecodealliance/gecko-dev 別で、ComponentizeJS が独自にSpiderMonkey にpatch を当てていた ( 開発はほとんどFastly の@guybedford さんがやっている様子) → SpiderMonkey をWasm 化した上でアプリケーションに組み込むという同じ目的で、 複数のプロジェクトが独自に動いているという状況になった ここで、Fastly とFermyon のエンジニアが協働して、Bytecode Alliance 配下にWasm 最 適化を施したSpiderMonkey fork を置くようにした
Introducing our Next-Generation JavaScript SDK - Fermyon
Introducing our Next-Generation JavaScript SDK - Fermyon
StarlingMonkey を使う
StarlingMonkey のビルド README 通りに実行すればいいので簡単! https://github.com/bytecodealliance/StarlingMonkey cmake --build cmake-build-release (or debug)
でビルドすると、 starling- raw.wasm が得られる 生成されたディレクトリに入った componentize.sh を実行してWasm Component 化 されたStarlingMonkey が完成 cd cmake-build-release ./componentize.sh -o starling.wasm
ビルドしたStarlingMonkey の使用 wasmtime に突っ込んでJS の実行に使える WASI のHTTP のインタフェースを通じて実行する形式 $ wasmtime
-S http starling.wasm -e "console.log('hello world')" Log: hello world
StarlingMonkey を活用する
StarlingMonkey を活用する 自分の実力では、そのまま使うのは正直きつかった 生成されたStarlingMonkey のWasm Component に、cli とhttp のインタフェースし か実装されていない
JS 以外の言語から、 eval_JS みたいな関数呼び出し形式でJS を呼べたら便利そう だが、どうやったらこうできるかが想像できなかった http のインタフェースをうまく使ったらいける?
StarlingMonkey を活用する 参考: StarlingMonkey のWasm Component にjco を通した結果 (cli /
http がexport されている)
StarlingMonkey を活用する 結局ComponentizeJS を使うのが楽 JS のコードとStarlingMonkey を抱き合わせてWasm Component 化したものをあら ゆる言語上で簡単に動かせます
jco とComponentizeJS を使って作ったWasm Component をNode.js で動かすとこ ろまでは簡単にできました 見た感じ、ComponentizeJS にはStarlingMonkey にパッチを当ててるC++ のコード が結構含まれてそうな気配がしている(ちゃんと追えてない)
感想 C++ を読み書きできるようになりたい!
ご清聴ありがとうございました!