Escargot 是一款专为资源受限环境设计的轻量级 JavaScript 引擎。
Escargot is an embeddable JavaScript engine developed by Samsung. It is designed for products that need more than a minimal scripting runtime but still have to manage CPU, memory, and platform constraints carefully.
Rather than minimizing the engine binary at all costs, Escargot balances runtime memory efficiency, interpreter performance, and modern JavaScript functionality. Its C++ implementation and built-in features can produce a larger native binary than ultra-minimal engines, but the engine is designed to use memory efficiently as applications and object graphs grow. This makes it a strong fit for substantial JavaScript workloads on embedded Linux, mobile, IoT, and other resource-aware products.
Escargot compiles JavaScript to bytecode and executes it without a JIT. The interpreter-based architecture avoids executable-memory requirements and provides predictable deployment characteristics, while the standards implementation supplies the language and internationalization features expected by real products.
Key capabilities include:
Intl (ECMA-402) and Temporal backed by ICU.Intl/Temporal functionality for a smaller binary.src/api/EscargotPublic.h, or enable the
Node-API v10 layer and C-style hosting APIs documented in
docs/n-api.md.third_party/GCutil.Escargot powers services in Samsung products and is available as an LGPL-2.1 open source project for other embedders and contributors.
Architecture names below use x86 for 32-bit Intel, x64 for x86-64,
arm for 32-bit ARM, and aarch64/arm64 for 64-bit ARM.
| Platform | Architectures | Status |
|---|---|---|
| Linux | x86, x64, arm, aarch64, riscv64 | Supported Linux platform. Ubuntu is used by CI and in the package-install example; it is not an OS restriction. |
| macOS | x64, aarch64 | Supported on both Intel and Apple Silicon. |
| iOS / iPadOS | aarch64 | Simulator and device builds are supported. |
| Windows | x86, x64, arm64 | Supported; WebAssembly is currently unavailable on arm64. |
| Android | x86, x64, arm, aarch64 | Supported across the Android ABIs. |
| Tizen | x86, x64, arm, aarch64, riscv64 | |
| Bare-metal / RTOS | arm (Cortex-M) | FreeRTOS and NuttX reference ports are provided. |
Pass these options when configuring with CMake.
| Flag | Description | Value | Default |
|---|---|---|---|
| -DESCARGOT_BUILD_SHARED_LIBS | Build shared library | ON/OFF | OFF |
| -DESCARGOT_BUILD_GC_SHARED_LIBS | Build GCutil as a shared library | ON/OFF | OFF |
| -DESCARGOT_ENABLE_SHELL | Build the Escargot shell (-DENABLE_SHELL remains a legacy alias) |
ON/OFF | ON, except OFF when ESCARGOT_NAPI is ON |
| -DESCARGOT_BUILD_CCTEST | Build the C++ tests | ON/OFF | OFF |
| -DESCARGOT_LIBICU_SUPPORT | Include libicu library | ON/OFF | ON, except OFF on bare-metal |
| -DESCARGOT_WASM | Enable WebAssembly support | ON/OFF | OFF |
| -DESCARGOT_CODE_CACHE | Enable code cache | ON/OFF | OFF |
| -DESCARGOT_TCO | Enable tail call optimization | ON/OFF | OFF |
| -DESCARGOT_THREADING | Enable threading features (e.g. Atomics, SharedArrayBuffer) | ON/OFF | ON, except OFF on bare-metal |
| -DESCARGOT_TLS_ACCESS_BY_ADDRESS | Enable thread local storage access optimization (offset) | ON/OFF | OFF everywhere (safety-first; opt in manually on stable glibc-style targets) |
| -DESCARGOT_TLS_ACCESS_BY_PTHREAD_KEY | Enable thread local storage access optimization (pthread_key) | ON/OFF | ON when THREADING is ON and host is Android, otherwise OFF |
| -DESCARGOT_TEMPORAL | Enable Temporal support (requires ICU) | ON/OFF | ON when LIBICU is ON, otherwise OFF |
| -DESCARGOT_SHADOWREALM | Enable ShadowRealm support | ON/OFF | OFF |
| -DESCARGOT_SMALL_CONFIG | Enable aggressive memory optimizations for tiny devices | ON/OFF | OFF |
| -DESCARGOT_EXPORT_ALL | Export all symbols instead of the default curated public API | ON/OFF | OFF |
| -DESCARGOT_TEST | Enable additional features used only for testing | ON/OFF | OFF |
| -DESCARGOT_DEBUGGER | Enable Debug server | ON/OFF | OFF |
| -DESCARGOT_NAPI | Enable Node-API (N-API) support and C-style hosting APIs | ON/OFF | OFF |
Advanced / developer-only options (profiling, sanitizers, internal knobs)
| Flag | Description | Value | Default |
|---|---|---|---|
| -DESCARGOT_ASAN | Build with AddressSanitizer | ON/OFF | OFF |
| -DESCARGOT_COVERAGE | Build with gcov/Codecov instrumentation | ON/OFF | OFF |
| -DESCARGOT_DEPLOY | Build for deployment (set up RPATH for a bundled ICU) | ON/OFF | OFF |
| -DESCARGOT_LIBICU_SUPPORT_WITH_DLOPEN | Load libicu at runtime via dlopen() instead of linking directly | ON/OFF | ON, except OFF on macOS (dlopen-loaded ICU doesn't work correctly there), disallowed entirely on iOS, and OFF when ESCARGOT_LIBICU_SUPPORT_VENDORED is ON |
| -DESCARGOT_LIBICU_SUPPORT_VENDORED | Build/ship Escargot's own ICU instead of relying on a system-provided one (see "Vendored ICU" below) | ON/OFF | ON on windows, macOS and iOS (the only ICU option there), OFF elsewhere (available on linux too) |
| -DESCARGOT_USE_EXTENDED_API | Enable the extended C++ API (FunctionTemplateRef, etc.) | ON/OFF | ON when NAPI is ON, otherwise OFF |
| -DESCARGOT_USE_CUSTOM_LOGGING | Use a custom logging backend instead of the host's native log (e.g. dlog on Tizen) | ON/OFF | OFF |
| -DESCARGOT_YARR_START_CHAR_FILTER | Enable the Yarr interpreter first-character prefilter | ON/OFF | ON |
| -DESCARGOT_TCO_DEBUG | Enable extra tail-call-optimization debug checks (debug builds only, requires ESCARGOT_TCO) | ON/OFF | OFF |
| -DESCARGOT_PROFILE_BDWGC | Enable bdwgc (Boehm GC) profiling | ON/OFF | OFF |
| -DESCARGOT_MEM_STATS | Enable memory usage statistics | ON/OFF | OFF |
| -DESCARGOT_VALGRIND | Build with Valgrind annotations | ON/OFF | OFF |
| -DESCARGOT_GOOGLE_PERF | Build with gperftools (Google Performance Tools) profiling | ON/OFF | OFF |
| -DESCARGOT_BUILD_64BIT_FORCE_LARGE | On 64-bit targets, force full 64-bit pointers instead of 32-bit-in-64-bit compression | ON/OFF | ON |
Escargot supports Linux distributions generally. The commands below use Debian/Ubuntu package names because Ubuntu is used by CI; install the equivalent development packages on other distributions.
Debian/Ubuntu prerequisites:
sudo apt-get install build-essential cmake git libicu-dev pkg-config python3
Prerequisites for x86-64-to-x86 compilation:
sudo apt-get install gcc-multilib g++-multilib
sudo apt-get install libicu-dev:i386
Build Escargot:
git submodule update --init third_party
cmake -S . -B out -DCMAKE_BUILD_TYPE=Release -DESCARGOT_ENABLE_SHELL=ON
cmake --build out
# Run a JavaScript file with the shell produced by the default build.
./out/escargot path/to/script.js
The default configuration produces the static library out/libescargot.a
and the out/escargot shell. Set ESCARGOT_BUILD_SHARED_LIBS=ON for a
shared library, or ESCARGOT_ENABLE_SHELL=OFF when embedding the library
without the command-line shell.
Install the Xcode Command Line Tools (or full Xcode), then install the remaining build prerequisites:
xcode-select --install
brew install cmake python
Build Escargot:
git submodule update --init third_party
cmake -S . -B out -DCMAKE_BUILD_TYPE=Release -DESCARGOT_ENABLE_SHELL=ON
cmake --build out
ICU is vendored by default on macOS (see "Vendored ICU" below) -- it's built
from the third_party/icu submodule above and linked statically, so no
Homebrew icu4c/pkg-config setup is needed for the default path. To opt
back into a Homebrew/system-provided ICU instead:
brew install icu4c
# add icu path to pkg_config_path (x64)
export PKG_CONFIG_PATH="/usr/local/opt/icu4c/lib/pkgconfig:$PKG_CONFIG_PATH"
# add icu path to pkg_config_path (arm64)
export PKG_CONFIG_PATH="/opt/homebrew/opt/icu4c/lib/pkgconfig:$PKG_CONFIG_PATH"
cmake -S . -B out -DCMAKE_BUILD_TYPE=Release \
-DESCARGOT_LIBICU_SUPPORT_VENDORED=OFF \
-DESCARGOT_ENABLE_SHELL=ON
cmake --build out
Build prerequisites on Ubuntu:
sudo apt install openjdk-17-jdk # require java 17
Build Escargot using gradle:
git submodule update --init third_party
export ANDROID_SDK_ROOT=.... # set your android SDK root first
cd build/android/
./gradlew bundleReleaseAar # build escargot AAR
./gradlew bundleHostJar # bundle jar for host
./gradlew javadocJar # create java doc
./gradlew sourcesJar # create sources jar
./gradlew assembleDebug # build debug test shell
./gradlew :escargot:connectedDebugAndroidTest # run escargot-jni tests on android device
./gradlew :escargot:testDebugUnitTest # run escargot-jni tests on host
Escargot is packaged and deployed in Tizen products. The RPM spec supports
the Tizen package architectures x86, x64, arm, aarch64, and
riscv64, and selects product profiles such as TV, mobile, wearable, and
headless through the Tizen build environment.
For a reference GBS build, use the repository's Tizen profile:
git submodule update --init third_party/GCutil
gbs -c .github/workflows/gbs.conf build -A armv7l -P profile.tizen --define "enable_shell 1"
The public CI continuously validates the armv7 package build. Tizen product build and qualification flows use the same RPM packaging integration.
Escargot runs on bare-metal and RTOS targets with no OS underneath
(no pthreads, no mmap, no filesystem). Specifying a bare-metal/RTOS target via CMAKE_SYSTEM_NAME (such as Generic, NuttX, FreeRTOS) automatically
configures the engine side of this (-DOS_BAREMETAL=1 and friends,
ICU/threading defaulted off):
cmake -DCMAKE_SYSTEM_NAME=Generic -DCMAKE_SYSTEM_PROCESSOR=arm ... /path/to/escargot
A full port additionally needs its own small CMake project for BDWGC
(third_party/GCutil) and a PlatformRef implementation providing the
RTOS's task stack bounds and tick source. See
docs/porting/RTOS_PORTING_GUIDE.md
for the full checklist and code contract, and
samples/rtos/freertos/ for a complete, working
in-tree sample (FreeRTOS / Cortex-M55, QEMU mps3-an547) — cross-compiled
a
暂无开放 Issues,或尚未同步最近议题。