本文へスキップ
Kitbay
スキル

v8-jit

MIT2026年11月11日 更新143,470GitHubスター

A maintainer skill in the Next.js repository on writing JavaScript that the V8 engine can optimise well, for per-request code in Next.js server internals such as rendering, streaming, routing and caching.

スキルの内容

A maintainer skill in the Next.js repository on writing JavaScript that the V8 engine can optimise well, for per-request code in Next.js server internals such as rendering, streaming, routing and caching. It explains V8's compiler tiers and why optimised code is thrown away when assumptions break, then sets rules: give objects the same shape by initialising all properties in a fixed order, keep call sites seeing one shape, move closures out of hot loops, keep arrays packed and single-typed, avoid the arguments object and for...in, hoist regular expressions and choose Map or Set for changing keys. Node flags for tracing optimisation and profiling are listed, and a checklist closes it for code review.

できること

  • Keep object shapes stable on hot paths
  • Avoid patterns that cause deoptimisation
  • Trace optimisation with Node flags
  • Review hot-path code against a checklist