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
580
3
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
StarlingMonkeyを触ってみた話 - 2024冬
新宿御苑.wasm #2024.12.11 の発表資料です
https://shinjukugyoen.connpass.com/event/338017/
syumai
December 11, 2024
More Decks by syumai
See All by syumai
作って学ぶ、 JSX (TSX) ランタイムの基本
syumai
7
1.6k
Oxlintのカスタムルールの現況
syumai
6
1.1k
Oxlintはいかにしてtsgolintのlint ruleを呼び出しているのか
syumai
2
1.2k
『[入門] Cloudflare Workers』本はなぜ誕生したのか
syumai
0
390
tsgolintはいかにしてtypescript-goの非公開APIを呼び出しているのか
syumai
9
3.1k
知られているようで知られていない JavaScriptの仕様 4選
syumai
3
1.2k
CloudflareのSandbox SDKを試してみた
syumai
0
870
実践AIチャットボットUI実装入門
syumai
9
4.2k
ProxyによるWindow間RPC機構の構築
syumai
3
1.5k
Other Decks in Programming
See All in Programming
気づいたらRubyで100作品 ー クリエイティブコーディングが生活の一部になるまで / 100 Ruby Sketches Later: How Creative Coding Became Part of My Life
chobishiba
3
590
正しくソフトウェアを作る、前提を疑うための認知の視点 / doubt-premise
minodriven
21
6.7k
[2026年度第1回ORセミナー] 計画最適化ベンチャーと競技プログラミング人材
terryu16
0
270
The ROI of Quarkus for Spring Boot Applications
hollycummins
0
120
Hunting Vulnerabilities in Symfony with LLMs
vinceamstoutz
0
550
LLMによるContent Moderationの本番運用の裏側と品質担保への挑戦
suikabar
3
710
Signal Forms: Details & Live Coding @enterJS 2026 in Mannheim
manfredsteyer
PRO
0
160
例外の正しい扱い方 そのエラー try-catchして大丈夫?
jinwatanabe
0
260
JJUG CCC 2026 Spring: JSpecify で実現する Kotlin フレンドリーな Java API 設計
ternbusty
1
180
AIとASP.NET Coreで雑Webアプリを作った話
mayuki
0
660
Dataformのリポジトリを立ち上げるときにまずやること / dataform-day0-2026
snhryt
0
170
さぁV100、メモリをお食べ・・・
nilpe
0
150
Featured
See All Featured
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
38
2.9k
Bridging the Design Gap: How Collaborative Modelling removes blockers to flow between stakeholders and teams @FastFlow conf
baasie
0
590
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
8.2k
The Illustrated Guide to Node.js - THAT Conference 2024
reverentgeek
1
390
A Modern Web Designer's Workflow
chriscoyier
698
190k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
128
56k
RailsConf 2023
tenderlove
30
1.5k
How to Think Like a Performance Engineer
csswizardry
28
2.7k
Designing for Timeless Needs
cassininazir
1
260
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
The Power of CSS Pseudo Elements
geoffreycrofte
82
6.3k
First, design no harm
axbom
PRO
2
1.2k
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++ を読み書きできるようになりたい!
ご清聴ありがとうございました!