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
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
syumai
December 11, 2024
Programming
540
3
Share
StarlingMonkeyを触ってみた話 - 2024冬
新宿御苑.wasm #2024.12.11 の発表資料です
https://shinjukugyoen.connpass.com/event/338017/
syumai
December 11, 2024
More Decks by syumai
See All by syumai
『[入門] Cloudflare Workers』本はなぜ誕生したのか
syumai
0
270
tsgolintはいかにしてtypescript-goの非公開APIを呼び出しているのか
syumai
9
2.9k
知られているようで知られていない JavaScriptの仕様 4選
syumai
3
1.2k
CloudflareのSandbox SDKを試してみた
syumai
0
750
実践AIチャットボットUI実装入門
syumai
9
4k
ProxyによるWindow間RPC機構の構築
syumai
3
1.5k
CloudflareのChat Agent Starter Kitで簡単!AIチャットボット構築
syumai
2
1.1k
Go製CLIツールをnpmで配布するには
syumai
3
1.9k
MCPで実現できる、Webサービス利用体験について
syumai
7
3k
Other Decks in Programming
See All in Programming
Coding as Prompting Since 2025
ragingwind
0
820
Kubernetes上でAgentを動かすための最新動向と押さえるべき概念まとめ
sotamaki0421
3
490
「話せることがない」を乗り越える 〜日常業務から登壇テーマをつくる思考法〜
shoheimitani
4
760
mruby on C#: From VM Implementation to Game (RubyKaigi 2026)Scripting
hadashia
1
160
Vibe NLP for Applied NLP
inesmontani
PRO
0
390
ハーネスエンジニアリングにどう向き合うか 〜ルールファイルを超えて開発プロセスを設計する〜 / How to approach harness engineering
rkaga
20
8.6k
「Linuxサーバー構築標準教科書」を読んでみた #ツナギメオフライン.7
akase244
0
1.4k
「効かない!」依存性注入(DI)を活用したAPI Platformのエラーハンドリング奮闘記
mkmk884
1
330
ふりがな Deep Dive try! Swift Tokyo 2026
watura
0
200
How We Benchmarked Quarkus: Patterns and anti-patterns
hollycummins
1
120
夢の無限スパゲッティ製造機 -実装篇- #phpstudy
o0h
PRO
0
210
VueエンジニアがReactを触って感じた_設計の違い
koukimiura
0
170
Featured
See All Featured
Data-driven link building: lessons from a $708K investment (BrightonSEO talk)
szymonslowik
1
1k
Testing 201, or: Great Expectations
jmmastey
46
8.1k
Claude Code のすすめ
schroneko
67
220k
Designing for Performance
lara
611
70k
How Software Deployment tools have changed in the past 20 years
geshan
0
33k
More Than Pixels: Becoming A User Experience Designer
marktimemedia
3
380
Leadership Guide Workshop - DevTernity 2021
reverentgeek
1
260
GraphQLの誤解/rethinking-graphql
sonatard
75
12k
職位にかかわらず全員がリーダーシップを発揮するチーム作り / Building a team where everyone can demonstrate leadership regardless of position
madoxten
62
53k
The Hidden Cost of Media on the Web [PixelPalooza 2025]
tammyeverts
2
270
Large-scale JavaScript Application Architecture
addyosmani
515
110k
HDC tutorial
michielstock
2
620
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++ を読み書きできるようになりたい!
ご清聴ありがとうございました!