Agent skill · software engineering · vercel

v8-jit

V8 JIT optimization patterns for writing high-performance JavaScript in Next.js server internals. Use when writing or reviewing hot-path code in app-render, stream-utils, routing, caching, or any per-request code path. Covers hidden classes / shapes, monomorphic call sites, inline caches, megamorphic deopt, closure allocation, array packing, and profiling with --trace-opt / --trace-deopt.

Why this skill is useful

Adds specific optimization patterns and techniques for V8 JIT that enhance performance in Next.js server internals, which the AI wouldn't generate on its own.

What it needs

About 8k tokens when loaded. Last updated 2026-08-07. 141,663 stars on the source repository.

What this skill does

V8 JIT Optimization Use this skill when writing or optimizing performance-critical code paths in Next.js server internals — especially per-request hot paths like rendering, streaming, routing, and caching. Background: V8's Tiered Compilation V8 compiles JavaScript through multiple tiers: 1. Ignition (interpreter) — executes bytecode immediately. 2. Sparkplug — fast baseline compiler (no optimization). 3. Maglev — mid-tier optimizing compiler. 4. Turbofan — full optimizing compiler (speculative, type-feedback-driven). Code starts in Ignition and is promoted to higher tiers based on execution frequency and collected type feedback. Turbofan produces the fastest machine code but bails out (deopts) when assumptions are violated at runtime. The key principle: help V8 make correct speculative assumptions by keeping types, shapes, and control flow predictable. Hidden Classes (Shapes / Maps) Every JavaScript object has an internal "hidden class" (V8 calls it a Map, the spec calls it a Shape). Objects that share the same property names, added in the same order, share the same hidden class. This enables fast property access via inline caches. Initialize All Properties in Constructors Rules: Assign every property in the constructor, in the same order, for every instance. Use null / undefined / false as default values rather than omitting the property. Prefer factory functions when constructing hot-path objects. A single factory makes it harder to accidentally fork shapes in different call sites. Never delete a property on a hot object — it forces a transition to dictionary mode (slow properties). Avoid adding properties after construction (obj.newProp = x) on objects used in hot paths. Object literals that flow into the same function should have keys in the same order: Use tuples for very small fixed-size records when names are not needed. Tuples avoid key-order pitfalls entirely. …

How to use it

Reference it in AdaL, Claude Code, Cursor or any coding agent — nothing to install:

@skills vercel/v8-jit

View the source on GitHub

Browse the @skills marketplace