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
380
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
技術記事、AIに書かせるか、自分で書くか? 〜それでも私が自分の手で書く理由〜 / #QiitaConference
jnchito
2
1.4k
Make SRE Operations Easier with Azure SRE Agent
kkamegawa
0
6.4k
ADKを使って簡単にAIエージェントを作ってみよう
k1mu21
0
270
Language Server 使ってる? 〜VSCode と Zed の場合〜 / Are you using a Language Server? ~For VS Code and Zed~
handlename
0
790
Lessons from Spec-Driven Development
simas
PRO
0
210
Developing with AI Agents — Codex, Claude Code & Cowork Practical Guide
x5gtrn
PRO
0
1.3k
Spring Security 実践 ─ GraphQL APIで実務に役立つ 認証・認可 を学ぶ
wagyu
0
240
Semantic Version 単位で戦略を柔軟に変えて、パッケージアップデートを自動化する
daitasu
1
240
IBM Bobを活用したレガシーアプリの最新化
oniak3ibm
PRO
1
200
依存関係から依存物へ―Dependencyという言葉の歴史をひも解く
j_lee
0
120
AI 時代のソフトウェア設計の学び方
masuda220
PRO
29
13k
Creating Composable Callables in Contemporary C++
rollbear
0
140
Featured
See All Featured
Crafting Experiences
bethany
1
180
Making the Leap to Tech Lead
cromwellryan
135
9.9k
Lightning talk: Run Django tests with GitHub Actions
sabderemane
0
200
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
2.9k
Practical Orchestrator
shlominoach
191
11k
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
340
Paper Plane (Part 1)
katiecoart
PRO
0
9.1k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.5k
Tips & Tricks on How to Get Your First Job In Tech
honzajavorek
1
540
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
12
1.2k
The SEO identity crisis: Don't let AI make you average
varn
0
490
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++ を読み書きできるようになりたい!
ご清聴ありがとうございました!