File size: 1,371 Bytes
b27bfb3
 
 
 
1
2
3
4
5
{"type": "session", "harness": "opencode", "id": "lang-0012", "name": "Firefox SpiderMonkey Engine"}
{"type": "message", "message": {"role": "system", "content": "You are an expert software engineer."}}
{"type": "message", "message": {"role": "user", "content": "How does Firefox's SpiderMonkey JavaScript engine work?"}}
{"type": "message", "message": {"role": "assistant", "content": "SpiderMonkey is Mozilla's JS engine, oldest surviving JS engine.\n\nCompilation tiers:\n1. Bytecode emission: source -> bytecode (BaselineCompiler)\n2. BaselineInterpreter: interpreter with IC (inline caches)\n3. BaselineCompiler: JIT baseline compilation\n4. Warp: optimizing JIT (replaced IonMonkey)\n5. Wasm: WebAssembly compilation (same pipeline)\n\nIonMonkey/Warp optimization:\n- MIR (Mid-level IR): SSA-form intermediate representation\n- LICM (Loop Invariant Code Motion)\n- GVN (Global Value Numbering)\n- Escape analysis\n- Range analysis and bounds check elimination\n\nGarbage collection:\n- Nursery: young generation (copy collector)\n- Tenured: old generation (incremental marking, sweep)\n- CC (Cycle Collector): reference cycle detection\n- Per-compartment GC: isolates global objects\n\nMemory: compartments for isolation (each iframe/window).\nBaselineInterpreter: fast startup, no compilation overhead.\nBaselineCompiler: adds IC, method JIT for hot loops."}}