How facebook/hermes works
Hermes is a JavaScript engine optimized for React Native startup, combining ahead-of-time compilation and compact bytecode with a runtime that executes JavaScript. Its main user-to-result workflow is source compilation into optimized bytecode, followed by execution in an embedding application. The repository also exposes embedding APIs, debugging and profiling facilities, extensions, and alternate runtime interfaces. The README documents the high-level workflow; sampled source and the source index support selected internal relationships, while unsampled subsystems are represented without asserting unverified calls.
Main entry points: hermes.cpp Hermes VM · LoweringPipelines.cpp Bytecode generation · JSParserImpl.cpp Parser and diagnostics · Pipeline.cpp IR optimizer
Components 21
Compilation
- Parser and diagnostics
lib/Parser/JSParserImpl.cpp - IR optimizer
lib/Optimizer/PassManager/Pipeline.cpp - Bytecode generation
lib/BCGen/HBC/LoweringPipelines.cpp - String packing
lib/BCGen/HBC/ConsecutiveStringStorage.cpp
Execution runtime
- Hermes VM
API/hermes/hermes.cpp - Array storage
lib/VM/ArrayStorage.cpp - Heap storage provider
lib/VM/StorageProvider.cpp
Embedding interfaces
- JSI interface
API/jsi/jsi/jsi.cpp - Node API
API/napi/hermes_napi.cpp - C ABI wrapper
API/hermes_abi/HermesABIRuntimeWrapper.cpp - Sandbox runtime
API/hermes_sandbox/HermesSandboxRuntime.cpp
Debugging and tracing
- Inspector protocol
API/hermes/cdp/CDPAgent.cpp - Debugger API
API/hermes/DebuggerAPI.cpp - Tracing runtime
API/hermes/TracingRuntime.cpp
Runtime extensions
- Core extensions
API/hermes/extensions/Extensions.cpp - Contributed extensions
API/hermes/extensions/contrib/ContribExtensions.cpp
Other components
- Application developer
- JavaScript source
- Embedding application
- Compact bytecode
- JavaScript result
Connections 19
- Application developer → JavaScript source: provides source
README.md - JavaScript source → Parser and diagnostics: parses
- Parser and diagnostics → IR optimizer: produces IR
- IR optimizer → Bytecode generation: lowers
- Bytecode generation → String packing: packs strings
lib/BCGen/HBC/ConsecutiveStringStorage.cpp - Bytecode generation → Compact bytecode: emits
README.md - Embedding application → Hermes VM: runs bytecode
README.md - Hermes VM → JavaScript result: executes
README.md - Hermes VM → Array storage: uses storage
- Array storage → Heap storage provider: allocates from
- Embedding application → JSI interface: embeds through
- Embedding application → Node API: embeds through
- Embedding application → C ABI wrapper: embeds through
- Embedding application → Sandbox runtime: runs isolated
- Embedding application → Inspector protocol: inspects runtime
- Inspector protocol → Debugger API: controls debugging
- Embedding application → Tracing runtime: enables tracing
- Hermes VM → Core extensions: registers extensions
- Hermes VM → Contributed extensions: registers extensions