01Chapter 1: From Source Text to Bytecode: The Engine PipelineA JavaScript engine never runs your source text directly. It turns the text into something it can execute in several steps, and each step leaves behind data that later optimizations depend on. This chapter follows that path in V8, from the moment a script's characters arrive to the moment bytecode e6 min read
02Chapter 2: Running Bytecode in an InterpreterThis chapter assumes you can write JavaScript functions and loops, run scripts with Node.js from the command line, and know roughly how compiled code differs from interpreted code. It also builds on the previous chapter: the engine has parsed your source and produced bytecode. Here we look at what h5 min read
03Chapter 3: What Just-in-Time Compilation MeansThis chapter assumes you can write and run JavaScript with Node.js. You should know the basic difference between a compiler, which translates a whole program to machine code before it runs, and an interpreter, which executes a program step by step. You should also have read the previous chapters: V86 min read
04Chapter 4: Tiered Compilation: Trading Startup Time for Peak SpeedThis chapter assumes you know how the engine turns source text into bytecode, how an interpreter such as Ignition executes that bytecode, and what just-in-time (JIT) compilation means in general. You should also be comfortable running scripts with Node.js from the command line. Hidden classes, inlin6 min read
05Chapter 5: Hidden Classes: Giving Dynamic Objects a Fixed LayoutThis chapter assumes you can write JavaScript constructors, classes, and object literals, and that you can run a script with Node.js from the command line. It builds on the earlier chapters about the engine pipeline and the interpreter. Those chapters covered how code gets executed. This one covers 5 min read
06Chapter 6: Shape Transitions and Why Property Order MattersThe previous chapter showed that V8 gives every object a hidden class, which V8 calls a map. The map describes the object's layout: which properties it has and the offset where each value lives. JavaScript lets you add properties at any time, though, so a map cannot stay fixed for an object's whol6 min read
07Chapter 7: Dictionary Mode: When Objects Fall Off the Fast PathThis chapter assumes you have read the previous chapters on hidden classes and shape transitions. You should know that V8 calls a hidden class a map, and that adding a property moves an object along a transition chain from one map to the next. You will also need Node.js on your machine to run the 6 min read
08Chapter 8: Inline Caches: Remembering Where Properties LiveThis chapter assumes you already know three things from earlier chapters. V8 compiles functions to bytecode and runs them in the Ignition interpreter. Every object has a hidden class, called a map in V8, that records which properties it has and where each one sits in memory. Adding properties moves 6 min read
09Chapter 9: Monomorphic, Polymorphic, and Megamorphic Call SitesThis chapter assumes you already know what a hidden class (a V8 map) is, how adding properties creates shape transitions, and how an inline cache stores a map-to-offset pair at a property access site. The question here is narrower: what happens to that cache when a single site sees more than one sha5 min read
10Chapter 10: Type Feedback: How the Engine Learns From Running CodeEarlier chapters showed that inline caches remember which hidden classes reached a property access, and that tiered compilation moves hot functions into faster tiers. This chapter covers the part that connects them: type feedback. Type feedback is the record of what actually happened while code 5 min read
11Chapter 11: Speculative Optimization: Betting on Past BehaviorThis chapter assumes you already know three ideas from earlier chapters. V8 runs code through tiers: Ignition, Sparkplug, Maglev, and TurboFan. Objects have hidden classes, which V8 calls maps. Inline caches record type feedback in a function's feedback vector. This chapter explains how the optimizi5 min read
12Chapter 12: Deoptimization: When the Bet FailsThe previous chapter showed how the optimizing compiler bets on past behavior. It reads type feedback, assumes the same types and shapes will keep showing up, and produces machine code that only works while those assumptions hold. This chapter covers what happens when an assumption turns out to be w6 min read
13Chapter 13: Array Elements Kinds and Fast ArraysThis chapter assumes you know how hidden classes describe object shapes and how inline caches use those shapes. It also assumes you can run Node.js with V8 flags such as --allow-natives-syntax. Hidden classes cover an object's named properties, such as point.x. Arrays raise a different question:6 min read
14Chapter 14: Inside the Optimizing Compiler: Inlining and Escape AnalysisThis chapter assumes you already know how speculative optimization works: TurboFan reads type feedback, compiles code that assumes that feedback still holds, and deoptimizes when it stops holding. It also assumes you can run Node.js with --allow-natives-syntax. Two transformations explain much of 5 min read
15Chapter 15: Watching the Engine Work With V8 Flags and Native SyntaxEarlier chapters described hidden classes, inline caches, type feedback, and deoptimization as models. This chapter shows you how to check those models against a real engine. You will run Node.js with V8 flags that print what the engine decides, and use V8's native syntax to ask direct questions abo5 min read
16Chapter 16: Writing Engine-Friendly JavaScript Without Micro-OptimizingThis chapter assumes you have read the earlier chapters on hidden classes, inline caches, type feedback, deoptimization, and elements kinds. It also assumes you can run Node.js scripts with flags. Here we turn those mechanisms into a small set of habits. We also cover when to apply them, which in mo5 min read
17Chapter 17: Beyond V8: SpiderMonkey and JavaScriptCoreEvery earlier chapter used V8 as its example. Firefox runs on SpiderMonkey, and Safari, along with every browser on iOS, runs on JavaScriptCore (JSC). This chapter assumes you already know V8's tiers (Ignition, Sparkplug, Maglev, TurboFan), hidden classes, inline caches, type feedback, and deoptimiz6 min read