JavaScriptCore, often abbreviated JSC, is the JavaScript and WebAssembly engine built into WebKit, the rendering engine behind Safari and every browser on most Apple devices. Among browser technologies on the Web, it is one of the three major production engines, alongside V8 in Chromium and SpiderMonkey in Gecko, and it is responsible for parsing, compiling, executing and garbage collecting the scripts that power interactive pages.
JavaScriptCore is also shipped as a system framework on macOS and iOS, so native applications can embed a scripting runtime, and it powers several server-side runtimes outside the browser. Its design centers on a four-tier execution pipeline that balances fast startup against peak performance.
How JavaScriptCore executes code
JavaScriptCore executes code by first parsing source into an abstract syntax tree, then generating compact bytecode, and finally running that bytecode through progressively more optimizing tiers. Code starts in the cheapest tier and moves upward only when profiling shows it is hot, which keeps startup fast for the many functions that run once or rarely.
Each tier collects type profiles and execution counts. Higher tiers use that data to make speculative assumptions, for example that a variable always holds an integer or that an object always has the same shape. When an assumption fails, the engine performs an OSR exit (on-stack replacement exit) and resumes execution in a lower tier without losing program state.
The table below lists the four JavaScript execution tiers and the role each plays.
| Tier | Full name | Compile cost | Main purpose |
|---|---|---|---|
| LLInt | Low Level Interpreter | None | Fast startup and initial profiling |
| Baseline JIT | Baseline just-in-time compiler | Very low | Removes interpreter dispatch overhead |
| DFG JIT | Data Flow Graph compiler | Moderate | Speculative optimization of warm code |
| FTL JIT | Faster Than Light compiler | High | Maximum throughput for hot loops |
The FTL tier originally used the LLVM compiler infrastructure as its back end. WebKit engineers later replaced it with B3, the Bare Bones Backend, a purpose-built compiler that reduced compile times while keeping comparable code quality.
Objects, inline caches and memory management
JavaScriptCore represents object layouts with Structures, the equivalent of hidden classes in other engines. Objects created the same way share a Structure, which lets compiled code access properties by fixed offsets rather than dictionary lookups.
Inline caches record which Structures a given property access has seen. A monomorphic site that always sees one Structure is the fastest case; polymorphic and megamorphic sites fall back to slower generic paths. Writing code that keeps object shapes consistent therefore has a measurable effect on performance.
Memory is reclaimed by Riptide, a concurrent garbage collector that performs most marking work on helper threads while the application keeps running. Riptide is a non-moving mark-and-sweep collector with generational behavior, chosen to keep pause times short, which matters for smooth scrolling and animation on mobile devices.
The following table summarizes the main runtime mechanisms that shape JavaScriptCore performance.
| Mechanism | What it does | Effect on performance |
|---|---|---|
| Structure | Describes the shape of an object | Enables fixed-offset property access |
| Inline cache | Remembers shapes seen at an access site | Avoids repeated property lookups |
| Value profiling | Records observed types | Feeds speculation in DFG and FTL |
| OSR exit | Leaves optimized code safely | Preserves correctness after a failed guess |
| Riptide collector | Concurrent mark and sweep | Keeps pauses short on busy pages |
WebAssembly support in JavaScriptCore
JavaScriptCore runs WebAssembly through its own tiered pipeline, separate from the JavaScript tiers. Modules begin in an interpreter or a fast compiler named BBQ (Build Bytecode Quickly), and frequently executed functions are recompiled by OMG (Optimized Machine-code Generator), which reuses the B3 back end.
Because WebAssembly is statically typed, it needs far less speculation than JavaScript. The tiering exists mainly to shorten time to first execution for large modules such as game engines or image editors compiled from C++ or Rust.
JavaScriptCore compared with V8 and SpiderMonkey
All three major engines use the same broad strategy of interpretation plus speculative JIT compilation, but they differ in tier design, collector design and where they are deployed. The comparison below covers the points most relevant to web developers.
| Engine | Browser engine | Main browsers | Optimizing tiers |
|---|---|---|---|
| JavaScriptCore | WebKit | Safari and all iOS browsers | DFG and FTL |
| V8 | Blink | Chrome, Edge, Opera | Maglev and TurboFan |
| SpiderMonkey | Gecko | Firefox | Warp |
The practical consequence is that performance characteristics differ between engines. A pattern that V8 optimizes well may trigger repeated OSR exits in JavaScriptCore, so benchmarking in Safari remains necessary for sites with a large iPhone audience. Feature support also differs, which is why developers check Safari compatibility separately before relying on new language features.
Deployment beyond Safari and platform constraints
JavaScriptCore reaches far beyond the Safari window. On iOS and iPadOS, platform rules have long required third-party browsers to use WebKit and therefore JavaScriptCore, although regulatory changes in the European Union now allow alternative engines there under specific conditions.
- JavaScriptCore.framework lets native apps evaluate scripts and bridge objects between JavaScript and Swift or Objective-C.
- React Native historically used JavaScriptCore as its default engine before Hermes became the default.
- Bun, a server-side JavaScript runtime, is built on JavaScriptCore rather than V8.
- Lockdown Mode on Apple devices disables JIT compilation, so JavaScriptCore runs interpreter-only to reduce attack surface.
An important limitation is that apps embedding the framework directly, outside a web view, generally cannot use JIT compilation on iOS, because the operating system restricts writable executable memory. Such apps run only the interpreter, which can be several times slower for compute-heavy code.
The table below lists frequent problems developers encounter and their usual causes.
| Symptom | Likely cause | Typical fix |
|---|---|---|
| Code fast in Chrome but slow in Safari | Repeated deoptimization | Keep types and object shapes stable |
| Embedded script slow on iPhone | JIT unavailable outside web views | Move heavy work to native code |
| Feature works elsewhere but fails | Feature not yet shipped in WebKit | Check support and add a fallback |
| Memory grows during long sessions | References kept by closures or caches | Release references and profile the heap |
Understanding it simply
Every interactive website contains instructions written in JavaScript. A browser needs a component that reads those instructions and carries them out. In Safari and on iPhones, that component is JavaScriptCore.
It works like a translator who starts by translating sentence by sentence, then notices which phrases come up constantly and prepares polished translations of those in advance. Rarely used code is handled quickly and simply, while frequently used code gets optimized so it runs much faster. The key takeaway: JavaScriptCore is the part of Safari that makes web pages actually do things, and it keeps them responsive by spending effort only where it pays off.
Applied in practice
A front-end team at an online retailer notices that its product filter feels sluggish on iPhones, although it performs well in Chrome on desktop. Analytics show that about half of mobile visitors use Safari, so the team investigates using the Web Inspector timeline in Safari.
Profiling reveals that the filtering function receives product objects built in several different ways, some with optional fields added later. Property access sites become megamorphic, and the optimized code repeatedly exits back to lower tiers. The developers normalize every product object to the same property order at creation and replace a mixed array of numbers and strings with numbers only.
After the change, the filter function stays in the optimizing tiers, and filtering time on a mid-range iPhone drops from roughly 180 to 60 milliseconds. The outcome is a visibly smoother interface and a team rule to benchmark performance-critical code in Safari before each release.