v8-jit
V8 JIT optimization patterns for writing high-performance JavaScript in Next.js server internals.
Skill by evgeshniyzik-dev
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/evgeshniyzik-dev-v8-jit
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Use cases: frontend, backend, writing
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions
What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.
- Tools
- No tools found
- Secrets
- None asked for
- Install scripts
- None found
Network hosts it talks to 1
codeload.github.com· found in install command
Files it touches
~/.claude/skills/v8-jit
What's inside
- Skill name
v8-jit- Description
- 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.
- License
- MIT
- Instructions
- 430 lines in SKILL.md · view on GitHub
Files (1)
- SKILL.md
SKILL.md (first lines)
# 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
```ts
// GOOD — consistent shape, single hidden class transition chain
class RequestContext {
url: string
method: string
headers: Record<string, string>
startTime: number
cached: boolean
constructor(url: string, method: string, headers: Record<string, string>) {
this.url = url
this.method = method
this.headers = headers
this.startTime = performance.now()
this.cached = false // always initialize, even defaults
}
}
```
```ts
// BAD — conditional property addition creates multiple hidden classes
class RequestContext {
constructor(url, method, headers, options) {
this.url = url
this.method = method
if (options.timing) {
this.startTime = performance.now() // shape fork!
}
if (options.cache) {
this.cached = false // another shape fork!
}
this.headers = headers
}
}
```
**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.
```ts
// GOOD — same key order, shares hidden class
const a = { type: 'static', value: 1 }
const b = { type: 'dynamic', value: 2 }
// BAD — different key order, different hidden classes
const a = { type: 'static', value: 1 }
const b = { value: 2, type: 'dynamic' }
```
### Real Codebase Example
`Span` in `src/trace/trace.ts` initializes all fields in the constructor in a
fixed order — `name`, `parentId`, `attrs`, `status`, `id`, `_start`, `now`.
This ensures all `Span` instances share one hidden class.
## Monomorphic vs Polymorphic vs Megamorphic
V8's inline caches (ICs) track the types/shapes seen at each call site or
property access:
| IC State | Shapes Seen | Speed |
| --------------- | ----------- | ------------------------------------- |
| **Monomorphic** | 1 | Fastest — single direct check |
| **Polymorphic** | 2–4 | Fast — linear search through cases |
| **Megamorphic** | 5+ | Slow — hash-table lookup, no inlining |
Once an IC goes megamorphic it does NOT recover (until the function is
re-compiled). Megamorphic ICs also **prevent Turbofan from inlining** the
function.
### Keep Hot Call Sites Monomorphic
```ts
// GOOD — always called with the same argument shape
function processChunk(chunk: Uint8Array): void {From evgeshniyzik-dev/nextjs, MIT.
More from evgeshniyzik-dev/nextjs
- 0.409score
dce-edge
evgeshniyzik-dev
DCE-safe require() patterns and edge runtime constraints.
SkillDFreshness: DClaude Code +9 - 0.409score
flags
evgeshniyzik-dev
How to add or modify Next.js experimental feature flags end-to-end.
SkillDFreshness: DClaude Code +9 - 0.409score
react-vendoring
evgeshniyzik-dev
React vendoring and react-server layer boundaries.
SkillDFreshness: DClaude Code +9 - 0.409score
router-act
evgeshniyzik-dev
How to write end-to-end tests using createRouterAct and LinkAccordion.
SkillDFreshness: DClaude Code +9 - 0.409score
write-guide
evgeshniyzik-dev
Generates technical guides that teach real-world use cases through progressive examples.
SkillDFreshness: DClaude Code +9 - 0.409score
runtime-debug
evgeshniyzik-dev
Debug and verification workflow for runtime-bundle and module-resolution regressions.
SkillDFreshness: DClaude Code +9 - 0.409score
write-api-reference
evgeshniyzik-dev
Produces API reference documentation for Next.js APIs: functions, components, file conventions, directives, and config options.
SkillDFreshness: DClaude Code +9 - 0.406score
next-compile
evgeshniyzik-dev
Check Next.js compilation errors via a running dev server.
SkillDFreshness: DClaude Code +9 - 0.390score
update-docs
evgeshniyzik-dev
This skill should be used when the user asks to "update documentation for my changes", "check docs for this PR", "what docs need updating", "sync docs with…
SkillDFreshness: DClaude Code +9
Signals
- Stars
- 0
- Forks
- 0
- Open issues
- 0
- Last commit (this folder)
- Mar 19, 2026 (7 months ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- MIT
- Repository
- github.com/evgeshniyzik-dev/nextjs
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
More from evgeshniyzik-dev
- 0.409score
dce-edge
evgeshniyzik-dev
DCE-safe require() patterns and edge runtime constraints.
SkillDFreshness: DClaude Code +9 - 0.409score
flags
evgeshniyzik-dev
How to add or modify Next.js experimental feature flags end-to-end.
SkillDFreshness: DClaude Code +9 - 0.409score
react-vendoring
evgeshniyzik-dev
React vendoring and react-server layer boundaries.
SkillDFreshness: DClaude Code +9 - 0.409score
router-act
evgeshniyzik-dev
How to write end-to-end tests using createRouterAct and LinkAccordion.
SkillDFreshness: DClaude Code +9 - 0.409score
write-guide
evgeshniyzik-dev
Generates technical guides that teach real-world use cases through progressive examples.
SkillDFreshness: DClaude Code +9 - 0.409score
runtime-debug
evgeshniyzik-dev
Debug and verification workflow for runtime-bundle and module-resolution regressions.
SkillDFreshness: DClaude Code +9
Cite this page
v8-jit skill. Agent Mart. https://agentmart.dev/skills/evgeshniyzik-dev-v8-jit (last updated 2026-10-24)