Showing preview only (3,209K chars total). Download the full file or copy to clipboard to get everything.
Repository: bellard/quickjs
Branch: master
Commit: f1139494d18a
Files: 70
Total size: 3.1 MB
Directory structure:
gitextract_qmew98ht/
├── .github/
│ └── workflows/
│ └── ci.yml
├── .gitignore
├── Changelog
├── LICENSE
├── Makefile
├── TODO
├── VERSION
├── compat/
│ └── test-closefrom.c
├── cutils.c
├── cutils.h
├── doc/
│ └── quickjs.texi
├── dtoa.c
├── dtoa.h
├── examples/
│ ├── fib.c
│ ├── fib_module.js
│ ├── hello.js
│ ├── hello_module.js
│ ├── message.json
│ ├── pi_bigint.js
│ ├── point.c
│ ├── test_fib.js
│ └── test_point.js
├── fuzz/
│ ├── README
│ ├── fuzz.dict
│ ├── fuzz_common.c
│ ├── fuzz_common.h
│ ├── fuzz_compile.c
│ ├── fuzz_eval.c
│ ├── fuzz_regexp.c
│ └── generate_dict.js
├── libregexp-opcode.h
├── libregexp.c
├── libregexp.h
├── libunicode-table.h
├── libunicode.c
├── libunicode.h
├── list.h
├── qjs.c
├── qjsc.c
├── quickjs-atom.h
├── quickjs-libc.c
├── quickjs-libc.h
├── quickjs-opcode.h
├── quickjs.c
├── quickjs.h
├── readme-cosmo.txt
├── readme.txt
├── release.sh
├── repl.js
├── run-test262.c
├── test262.conf
├── test262o.conf
├── tests/
│ ├── assert.js
│ ├── bjson.c
│ ├── fixture_cyclic_import.js
│ ├── microbench.js
│ ├── test262.patch
│ ├── test_bigint.js
│ ├── test_bjson.js
│ ├── test_builtin.js
│ ├── test_closure.js
│ ├── test_cyclic_import.js
│ ├── test_language.js
│ ├── test_loop.js
│ ├── test_std.js
│ ├── test_worker.js
│ └── test_worker_module.js
├── unicode_download.sh
├── unicode_gen.c
└── unicode_gen_def.h
================================================
FILE CONTENTS
================================================
================================================
FILE: .github/workflows/ci.yml
================================================
name: ci
on:
pull_request:
paths:
- '**'
- '!.gitignore'
- '!LICENSE'
- '!TODO'
- '!doc/**'
- '!examples/**'
- '.github/workflows/ci.yml'
push:
branches:
- '*'
jobs:
linux:
name: Linux (Ubuntu)
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Build
run: |
make -j$(getconf _NPROCESSORS_ONLN) CONFIG_WERROR=y
- name: Stats
run: |
./qjs -qd
- name: Run built-in tests
run: |
make test
- name: Run microbench
run: |
make microbench
- name: Run test262
run: |
make test2-bootstrap
make test2
linux-lto:
name: Linux LTO
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Build
run: |
make -j$(getconf _NPROCESSORS_ONLN) CONFIG_WERROR=y CONFIG_LTO=y
- name: Run built-in tests
run: |
make test
- name: Run microbench
run: |
make microbench
linux-32bit:
name: Linux 32bit
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Install gcc-multilib
run: |
sudo apt update
sudo apt install -y gcc-multilib
- name: Build
run: |
make -j$(getconf _NPROCESSORS_ONLN) CONFIG_WERROR=y CONFIG_M32=y
- name: Run built-in tests
run: |
make CONFIG_M32=y test
- name: Run test262
run: |
make test2-bootstrap
make CONFIG_M32=y test2
linux-asan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Build
run: |
make -j$(getconf _NPROCESSORS_ONLN) CONFIG_WERROR=y CONFIG_ASAN=y
- name: Run built-in tests
env:
ASAN_OPTIONS: halt_on_error=1
run: |
make CONFIG_ASAN=y test
linux-msan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Build
env:
CC: clang
run: |
make -j$(getconf _NPROCESSORS_ONLN) CONFIG_WERROR=y CONFIG_MSAN=y CONFIG_CLANG=y
- name: Run built-in tests
env:
MSAN_OPTIONS: halt_on_error=1
run: |
make CONFIG_MSAN=y CONFIG_CLANG=y test
linux-ubsan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Build
run: |
make -j$(getconf _NPROCESSORS_ONLN) CONFIG_WERROR=y CONFIG_UBSAN=y
- name: Run built-in tests
env:
UBSAN_OPTIONS: halt_on_error=1
run: |
make CONFIG_UBSAN=y test
macos:
name: macOS
runs-on: macos-latest
strategy:
fail-fast: false
steps:
- uses: actions/checkout@v4
- name: Build
run: |
make -j$(getconf _NPROCESSORS_ONLN) CONFIG_WERROR=y
- name: Stats
run: |
./qjs -qd
- name: Run built-in tests
run: |
make test
- name: Run test262
run: |
make test2-bootstrap
make test2
macos-asan:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- name: Build
run: |
make -j$(getconf _NPROCESSORS_ONLN) CONFIG_WERROR=y CONFIG_ASAN=y
- name: Run built-in tests
env:
ASAN_OPTIONS: halt_on_error=1
run: |
make CONFIG_ASAN=y test
macos-ubsan:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- name: Build
run: |
make -j$(getconf _NPROCESSORS_ONLN) CONFIG_WERROR=y CONFIG_UBSAN=y
- name: Run built-in tests
env:
UBSAN_OPTIONS: halt_on_error=1
run: |
make CONFIG_UBSAN=y test
freebsd:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build + test
uses: vmactions/freebsd-vm@v1
with:
usesh: true
copyback: false
mem: 16384
prepare: |
pkg install -y gmake
run: |
gmake
./qjs -qd
gmake test
cosmopolitan:
name: Cosmopolitan
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Install Cosmopolitan
run: |
mkdir ~/cosmocc
cd ~/cosmocc
wget https://cosmo.zip/pub/cosmocc/cosmocc.zip
unzip cosmocc.zip
echo "$HOME/cosmocc/bin" >> "$GITHUB_PATH"
- name: Build
run: |
make CONFIG_COSMO=y
- name: Run built-in tests
run: |
make CONFIG_COSMO=y test
- name: Run test262
run: |
make test2-bootstrap
make CONFIG_COSMO=y test2
mingw-windows:
name: MinGW Windows target
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Install MinGW and Wine
run: |
sudo apt update
sudo apt install -y wine mingw-w64
cp /usr/x86_64-w64-mingw32/lib/libwinpthread-1.dll .
- name: Setup Wine
run: |
wine --version
winecfg /v
# binfmt doesn't work in GitHub Actions
#sudo apt install -y binfmt-support wine-binfmt
#echo ":Wine:M::MZ::/usr/bin/wine:" > /etc/binfmt.d/wine.conf
#sudo systemctl restart systemd-binfmt
- name: Build
run: |
make CONFIG_WIN32=y
- name: Run built-in tests
run: |
# If binfmt support worked, could just run `make CONFIG_WIN32=y test`
make WINE=/usr/bin/wine CONFIG_WIN32=y test
windows-msys:
name: Windows MSYS2
runs-on: windows-latest
defaults:
run:
shell: msys2 {0}
steps:
- uses: actions/checkout@v4
- uses: msys2/setup-msys2@v2
with:
msystem: UCRT64
update: true
install: git make mingw-w64-ucrt-x86_64-gcc mingw-w64-ucrt-x86_64-dlfcn
- name: Build
run: |
make -j$(getconf _NPROCESSORS_ONLN) CONFIG_WERROR=y
- name: Stats
run: |
./qjs -qd
- name: Run built-in tests
run: |
make test
- name: Run microbench
run: |
make microbench
qemu-alpine:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
platform:
- linux/386
- linux/riscv64
- linux/arm64
- linux/arm/v6
- linux/arm/v7
- linux/s390x
- linux/ppc64le
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Get qemu
# See https://github.com/tonistiigi/binfmt/issues/215#issuecomment-2613004741
run: docker run --privileged --rm tonistiigi/binfmt:master --install all
- name: Run tests on ${{ matrix.platform }}
run: docker run --rm --interactive --mount type=bind,source=$(pwd),target=/host --platform ${{ matrix.platform }} alpine sh -c "apk add git patch make gcc libc-dev && cd /host && make test"
================================================
FILE: .gitignore
================================================
*.a
.obj/
tests/bjson.so
examples/test_fib
test_fib.c
examples/*.so
examples/hello
examples/hello_module
examples/hello.exe
examples/test_fib.exe
hello.c
microbench*.txt
qjs
qjs.exe
qjsc
qjsc.exe
host-qjsc
qjscalc
qjscalc.c
repl.c
run-test262
run-test262.exe
test262
test262_*.txt
test262o
test262o_*.txt
unicode
unicode_gen
run_octane
run_sunspider_like
libwinpthread*.dll
================================================
FILE: Changelog
================================================
- micro optimizations (30% faster on bench-v8)
- added resizable array buffers
- added ArrayBuffer.prototype.transfer
- added the Iterator object and methods
- added set methods
- added Atomics.pause
- added added Map and WeakMap upsert methods
- added Math.sumPrecise()
- added regexp duplicate named groups
- misc bug fixes
2025-09-13:
- added JSON modules and import attributes
- added JS_PrintValue() API
- qjs: pretty print objects in print() and console.log()
- qjs: better promise rejection tracker heuristics
- added RegExp v flag
- added RegExp modifiers
- added RegExp.escape
- added Float16Array
- added Promise.try
- improved JSON parser spec conformance
- qjs: improved compatibility of std.parseExtJSON() with JSON5 and
accept JSON5 modules
- added JS_FreePropertyEnum() and JS_AtomToCStringLen() API
- added Error.isError()
- misc bug fixes
2025-04-26:
- removed the bignum extensions and qjscalc
- new BigInt implementation optimized for small numbers
- added WeakRef, FinalizationRegistry and symbols as weakrefs
- added builtin float64 printing and parsing functions for more correctness
- faster repeated string concatenation
- qjs: promise unhandled rejections are fatal errors by default
- added column number in debug information
- removed the "use strip" extension
- qjs: added -s and --strip-source options
- qjsc: added -s and --keep-source options
- added JS_GetAnyOpaque()
- added more callbacks for exotic objects in JSClassExoticMethods
- misc bug fixes
2024-01-13:
- top-level-await support in modules
- allow 'await' in the REPL
- added Array.prototype.{with,toReversed,toSpliced,toSorted} and
TypedArray.prototype.{with,toReversed,toSorted}
- added String.prototype.isWellFormed and String.prototype.toWellFormed
- added Object.groupBy and Map.groupBy
- added Promise.withResolvers
- class static block
- 'in' operator support for private fields
- optional chaining fixes
- added RegExp 'd' flag
- fixed RegExp zero length match logic
- fixed RegExp case insensitive flag
- added os.sleepAsync(), os.getpid() and os.now()
- added cosmopolitan build
- misc bug fixes
2023-12-09:
- added Object.hasOwn, {String|Array|TypedArray}.prototype.at,
{Array|TypedArray}.prototype.findLast{Index}
- BigInt support is enabled even if CONFIG_BIGNUM disabled
- updated to Unicode 15.0.0
- misc bug fixes
2021-03-27:
- faster Array.prototype.push and Array.prototype.unshift
- added JS_UpdateStackTop()
- fixed Windows console
- misc bug fixes
2020-11-08:
- improved function parameter initializers
- added std.setenv(), std.unsetenv() and std.getenviron()
- added JS_EvalThis()
- misc bug fixes
2020-09-06:
- added logical assignment operators
- added IsHTMLDDA support
- faster for-of loops
- os.Worker now takes a module filename as parameter
- qjsc: added -D option to compile dynamically loaded modules or workers
- misc bug fixes
2020-07-05:
- modified JS_GetPrototype() to return a live value
- REPL: support unicode characters larger than 16 bits
- added os.Worker
- improved object serialization
- added std.parseExtJSON
- misc bug fixes
2020-04-12:
- added cross realm support
- added AggregateError and Promise.any
- added env, uid and gid options in os.exec()
- misc bug fixes
2020-03-16:
- reworked error handling in std and os libraries: suppressed I/O
exceptions in std FILE functions and return a positive errno value
when it is explicit
- output exception messages to stderr
- added std.loadFile(), std.strerror(), std.FILE.prototype.tello()
- added JS_GetRuntimeOpaque(), JS_SetRuntimeOpaque(), JS_NewUint32()
- updated to Unicode 13.0.0
- misc bug fixes
2020-01-19:
- keep CONFIG_BIGNUM in the makefile
- added os.chdir()
- qjs: added -I option
- more memory checks in the bignum operations
- modified operator overloading semantics to be closer to the TC39
proposal
- suppressed "use bigint" mode. Simplified "use math" mode
- BigDecimal: changed suffix from 'd' to 'm'
- misc bug fixes
2020-01-05:
- always compile the bignum code. Added '--bignum' option to qjs.
- added BigDecimal
- added String.prototype.replaceAll
- misc bug fixes
2019-12-21:
- added nullish coalescing operator (ES2020)
- added optional chaining (ES2020)
- removed recursions in garbage collector
- test stack overflow in the parser
- improved backtrace logic
- added JS_SetHostPromiseRejectionTracker()
- allow exotic constructors
- improved c++ compatibility
- misc bug fixes
2019-10-27:
- added example of C class in a module (examples/test_point.js)
- added JS_GetTypedArrayBuffer()
- misc bug fixes
2019-09-18:
- added os.exec and other system calls
- exported JS_ValueToAtom()
- qjsc: added 'qjsc_' prefix to the generated C identifiers
- added cross-compilation support
- misc bug fixes
2019-09-01:
- added globalThis
- documented JS_EVAL_FLAG_COMPILE_ONLY
- added import.meta.url and import.meta.main
- added 'debugger' statement
- misc bug fixes
2019-08-18:
- added os.realpath, os.getcwd, os.mkdir, os.stat, os.lstat,
os.readlink, os.readdir, os.utimes, std.popen
- module autodetection
- added import.meta
- misc bug fixes
2019-08-10:
- added public class fields and private class fields, methods and
accessors (TC39 proposal)
- changed JS_ToCStringLen() prototype
- qjsc: handle '-' in module names and modules with the same filename
- added std.urlGet
- exported JS_GetOwnPropertyNames() and JS_GetOwnProperty()
- exported some bigint C functions
- added support for eshost in run-test262
- misc bug fixes
2019-07-28:
- added dynamic import
- added Promise.allSettled
- added String.prototype.matchAll
- added Object.fromEntries
- reduced number of ticks in await
- added BigInt support in Atomics
- exported JS_NewPromiseCapability()
- misc async function and async generator fixes
- enabled hashbang support by default
2019-07-21:
- updated test262 tests
- updated to Unicode version 12.1.0
- fixed missing Date object in qjsc
- fixed multi-context creation
- misc ES2020 related fixes
- simplified power and division operators in bignum extension
- fixed several crash conditions
2019-07-09:
- first public release
================================================
FILE: LICENSE
================================================
QuickJS Javascript Engine
Copyright (c) 2017-2021 Fabrice Bellard
Copyright (c) 2017-2021 Charlie Gordon
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
================================================
FILE: Makefile
================================================
#
# QuickJS Javascript Engine
#
# Copyright (c) 2017-2021 Fabrice Bellard
# Copyright (c) 2017-2021 Charlie Gordon
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
ifeq ($(shell uname -s),Darwin)
CONFIG_DARWIN=y
endif
ifeq ($(shell uname -s),FreeBSD)
CONFIG_FREEBSD=y
endif
# Windows cross compilation from Linux
# May need to have libwinpthread*.dll alongside the executable
# (On Ubuntu/Debian may be installed with mingw-w64-x86-64-dev
# to /usr/x86_64-w64-mingw32/lib/libwinpthread-1.dll)
#CONFIG_WIN32=y
# use link time optimization (smaller and faster executables but slower build)
#CONFIG_LTO=y
# consider warnings as errors (for development)
#CONFIG_WERROR=y
# force 32 bit build on x86_64
#CONFIG_M32=y
# cosmopolitan build (see https://github.com/jart/cosmopolitan)
#CONFIG_COSMO=y
# installation directory
PREFIX?=/usr/local
# use the gprof profiler
#CONFIG_PROFILE=y
# use address sanitizer
#CONFIG_ASAN=y
# use memory sanitizer
#CONFIG_MSAN=y
# use UB sanitizer
#CONFIG_UBSAN=y
# TEST262 bootstrap config: commit id and shallow "since" parameter
TEST262_COMMIT?=d0994d64b07cb6c164dd9f345c94ed797a53d69f
TEST262_SINCE?=2025-09-01
OBJDIR=.obj
ifdef CONFIG_ASAN
OBJDIR:=$(OBJDIR)/asan
endif
ifdef CONFIG_MSAN
OBJDIR:=$(OBJDIR)/msan
endif
ifdef CONFIG_UBSAN
OBJDIR:=$(OBJDIR)/ubsan
endif
ifdef CONFIG_DARWIN
# use clang instead of gcc
CONFIG_CLANG=y
CONFIG_DEFAULT_AR=y
endif
ifdef CONFIG_FREEBSD
# use clang instead of gcc
CONFIG_CLANG=y
CONFIG_DEFAULT_AR=y
CONFIG_LTO=
endif
ifdef CONFIG_WIN32
ifdef CONFIG_M32
CROSS_PREFIX?=i686-w64-mingw32-
else
CROSS_PREFIX?=x86_64-w64-mingw32-
endif
EXE=.exe
else ifdef MSYSTEM
CONFIG_WIN32=y
CROSS_PREFIX?=
EXE=.exe
else
CROSS_PREFIX?=
EXE=
endif
ifdef CONFIG_CLANG
HOST_CC=clang
CC=$(CROSS_PREFIX)clang
CFLAGS+=-g -Wall -MMD -MF $(OBJDIR)/$(@F).d
CFLAGS += -Wextra
CFLAGS += -Wno-sign-compare
CFLAGS += -Wno-missing-field-initializers
CFLAGS += -Wundef -Wuninitialized
CFLAGS += -Wunused -Wno-unused-parameter
CFLAGS += -Wwrite-strings
CFLAGS += -Wchar-subscripts -funsigned-char
CFLAGS += -MMD -MF $(OBJDIR)/$(@F).d
ifdef CONFIG_DEFAULT_AR
AR=$(CROSS_PREFIX)ar
else
ifdef CONFIG_LTO
AR=$(CROSS_PREFIX)llvm-ar
else
AR=$(CROSS_PREFIX)ar
endif
endif
LIB_FUZZING_ENGINE ?= "-fsanitize=fuzzer"
else ifdef CONFIG_COSMO
CONFIG_LTO=
HOST_CC=gcc
CC=cosmocc
# cosmocc does not correct support -MF
CFLAGS=-g -Wall #-MMD -MF $(OBJDIR)/$(@F).d
CFLAGS += -Wno-array-bounds -Wno-format-truncation
AR=cosmoar
else
HOST_CC=gcc
CC=$(CROSS_PREFIX)gcc
CFLAGS+=-g -Wall -MMD -MF $(OBJDIR)/$(@F).d
CFLAGS += -Wno-array-bounds -Wno-format-truncation -Wno-infinite-recursion
ifdef CONFIG_LTO
AR=$(CROSS_PREFIX)gcc-ar
else
AR=$(CROSS_PREFIX)ar
endif
endif
STRIP?=$(CROSS_PREFIX)strip
ifdef CONFIG_M32
CFLAGS+=-msse2 -mfpmath=sse # use SSE math for correct FP rounding
ifndef CONFIG_WIN32
CFLAGS+=-m32
LDFLAGS+=-m32
endif
endif
CFLAGS+=-fwrapv # ensure that signed overflows behave as expected
ifdef CONFIG_WERROR
CFLAGS+=-Werror
endif
DEFINES:=-D_GNU_SOURCE -DCONFIG_VERSION=\"$(shell cat VERSION)\"
ifdef CONFIG_WIN32
DEFINES+=-D__USE_MINGW_ANSI_STDIO # for standard snprintf behavior
endif
ifndef CONFIG_WIN32
ifeq ($(shell $(CC) -o /dev/null compat/test-closefrom.c 2>/dev/null && echo 1),1)
DEFINES+=-DHAVE_CLOSEFROM
endif
endif
CFLAGS+=$(DEFINES)
CFLAGS_DEBUG=$(CFLAGS) -O0
CFLAGS_SMALL=$(CFLAGS) -Os
CFLAGS_OPT=$(CFLAGS) -O2
CFLAGS_NOLTO:=$(CFLAGS_OPT)
ifdef CONFIG_COSMO
LDFLAGS+=-s # better to strip by default
else
LDFLAGS+=-g
endif
ifdef CONFIG_LTO
CFLAGS_SMALL+=-flto
CFLAGS_OPT+=-flto
LDFLAGS+=-flto
endif
ifdef CONFIG_PROFILE
CFLAGS+=-p
LDFLAGS+=-p
endif
ifdef CONFIG_ASAN
CFLAGS+=-fsanitize=address -fno-omit-frame-pointer
LDFLAGS+=-fsanitize=address -fno-omit-frame-pointer
endif
ifdef CONFIG_MSAN
CFLAGS+=-fsanitize=memory -fno-omit-frame-pointer
LDFLAGS+=-fsanitize=memory -fno-omit-frame-pointer
endif
ifdef CONFIG_UBSAN
CFLAGS+=-fsanitize=undefined -fno-omit-frame-pointer
LDFLAGS+=-fsanitize=undefined -fno-omit-frame-pointer
endif
ifdef CONFIG_WIN32
LDEXPORT=
else
LDEXPORT=-rdynamic
endif
ifndef CONFIG_COSMO
ifndef CONFIG_DARWIN
ifndef CONFIG_WIN32
CONFIG_SHARED_LIBS=y # building shared libraries is supported
endif
endif
endif
PROGS=qjs$(EXE) qjsc$(EXE) run-test262$(EXE)
ifneq ($(CROSS_PREFIX),)
QJSC_CC=gcc
QJSC=./host-qjsc
PROGS+=$(QJSC)
else
QJSC_CC=$(CC)
QJSC=./qjsc$(EXE)
endif
PROGS+=libquickjs.a
ifdef CONFIG_LTO
PROGS+=libquickjs.lto.a
endif
# examples
ifeq ($(CROSS_PREFIX),)
ifndef CONFIG_ASAN
ifndef CONFIG_MSAN
ifndef CONFIG_UBSAN
PROGS+=examples/hello examples/test_fib
# no -m32 option in qjsc
ifndef CONFIG_M32
ifndef CONFIG_WIN32
PROGS+=examples/hello_module
endif
endif
ifdef CONFIG_SHARED_LIBS
PROGS+=examples/fib.so examples/point.so
endif
endif
endif
endif
endif
all: $(OBJDIR) $(OBJDIR)/quickjs.check.o $(OBJDIR)/qjs.check.o $(PROGS)
QJS_LIB_OBJS=$(OBJDIR)/quickjs.o $(OBJDIR)/dtoa.o $(OBJDIR)/libregexp.o $(OBJDIR)/libunicode.o $(OBJDIR)/cutils.o $(OBJDIR)/quickjs-libc.o
QJS_OBJS=$(OBJDIR)/qjs.o $(OBJDIR)/repl.o $(QJS_LIB_OBJS)
HOST_LIBS=-lm -ldl -lpthread
LIBS=-lm -lpthread
ifndef CONFIG_WIN32
LIBS+=-ldl
endif
LIBS+=$(EXTRA_LIBS)
$(OBJDIR):
mkdir -p $(OBJDIR) $(OBJDIR)/examples $(OBJDIR)/tests
qjs$(EXE): $(QJS_OBJS)
$(CC) $(LDFLAGS) $(LDEXPORT) -o $@ $^ $(LIBS)
qjs-debug$(EXE): $(patsubst %.o, %.debug.o, $(QJS_OBJS))
$(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
qjsc$(EXE): $(OBJDIR)/qjsc.o $(QJS_LIB_OBJS)
$(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
fuzz_eval: $(OBJDIR)/fuzz_eval.o $(OBJDIR)/fuzz_common.o libquickjs.fuzz.a
$(CC) $(CFLAGS_OPT) $^ -o fuzz_eval $(LIB_FUZZING_ENGINE)
fuzz_compile: $(OBJDIR)/fuzz_compile.o $(OBJDIR)/fuzz_common.o libquickjs.fuzz.a
$(CC) $(CFLAGS_OPT) $^ -o fuzz_compile $(LIB_FUZZING_ENGINE)
fuzz_regexp: $(OBJDIR)/fuzz_regexp.o $(OBJDIR)/libregexp.fuzz.o $(OBJDIR)/cutils.fuzz.o $(OBJDIR)/libunicode.fuzz.o
$(CC) $(CFLAGS_OPT) $^ -o fuzz_regexp $(LIB_FUZZING_ENGINE)
libfuzzer: fuzz_eval fuzz_compile fuzz_regexp
ifneq ($(CROSS_PREFIX),)
$(QJSC): $(OBJDIR)/qjsc.host.o \
$(patsubst %.o, %.host.o, $(QJS_LIB_OBJS))
$(HOST_CC) $(LDFLAGS) -o $@ $^ $(HOST_LIBS)
endif #CROSS_PREFIX
QJSC_DEFINES:=-DCONFIG_CC=\"$(QJSC_CC)\" -DCONFIG_PREFIX=\"$(PREFIX)\"
ifdef CONFIG_LTO
QJSC_DEFINES+=-DCONFIG_LTO
endif
QJSC_HOST_DEFINES:=-DCONFIG_CC=\"$(HOST_CC)\" -DCONFIG_PREFIX=\"$(PREFIX)\"
$(OBJDIR)/qjsc.o: CFLAGS+=$(QJSC_DEFINES)
$(OBJDIR)/qjsc.host.o: CFLAGS+=$(QJSC_HOST_DEFINES)
ifdef CONFIG_LTO
LTOEXT=.lto
else
LTOEXT=
endif
libquickjs$(LTOEXT).a: $(QJS_LIB_OBJS)
$(AR) rcs $@ $^
ifdef CONFIG_LTO
libquickjs.a: $(patsubst %.o, %.nolto.o, $(QJS_LIB_OBJS))
$(AR) rcs $@ $^
endif # CONFIG_LTO
libquickjs.fuzz.a: $(patsubst %.o, %.fuzz.o, $(QJS_LIB_OBJS))
$(AR) rcs $@ $^
repl.c: $(QJSC) repl.js
$(QJSC) -s -c -o $@ -m repl.js
ifneq ($(wildcard unicode/UnicodeData.txt),)
$(OBJDIR)/libunicode.o $(OBJDIR)/libunicode.nolto.o: libunicode-table.h
libunicode-table.h: unicode_gen
./unicode_gen unicode $@
endif
run-test262$(EXE): $(OBJDIR)/run-test262.o $(QJS_LIB_OBJS)
$(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
run-test262-debug: $(patsubst %.o, %.debug.o, $(OBJDIR)/run-test262.o $(QJS_LIB_OBJS))
$(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
# object suffix order: nolto
$(OBJDIR)/%.o: %.c | $(OBJDIR)
$(CC) $(CFLAGS_OPT) -c -o $@ $<
$(OBJDIR)/fuzz_%.o: fuzz/fuzz_%.c | $(OBJDIR)
$(CC) $(CFLAGS_OPT) -c -I. -o $@ $<
$(OBJDIR)/%.host.o: %.c | $(OBJDIR)
$(HOST_CC) $(CFLAGS_OPT) -c -o $@ $<
$(OBJDIR)/%.pic.o: %.c | $(OBJDIR)
$(CC) $(CFLAGS_OPT) -fPIC -DJS_SHARED_LIBRARY -c -o $@ $<
$(OBJDIR)/%.nolto.o: %.c | $(OBJDIR)
$(CC) $(CFLAGS_NOLTO) -c -o $@ $<
$(OBJDIR)/%.debug.o: %.c | $(OBJDIR)
$(CC) $(CFLAGS_DEBUG) -c -o $@ $<
$(OBJDIR)/%.fuzz.o: %.c | $(OBJDIR)
$(CC) $(CFLAGS_OPT) -fsanitize=fuzzer-no-link -c -o $@ $<
$(OBJDIR)/%.check.o: %.c | $(OBJDIR)
$(CC) $(CFLAGS) -DCONFIG_CHECK_JSVALUE -c -o $@ $<
regexp_test: libregexp.c libunicode.c cutils.c
$(CC) $(LDFLAGS) $(CFLAGS) -DTEST -o $@ libregexp.c libunicode.c cutils.c $(LIBS)
unicode_gen: $(OBJDIR)/unicode_gen.host.o $(OBJDIR)/cutils.host.o libunicode.c unicode_gen_def.h
$(HOST_CC) $(LDFLAGS) $(CFLAGS) -o $@ $(OBJDIR)/unicode_gen.host.o $(OBJDIR)/cutils.host.o
clean:
rm -f repl.c out.c
rm -f *.a *.o *.d *~ unicode_gen regexp_test fuzz_eval fuzz_compile fuzz_regexp $(PROGS)
rm -f hello.c test_fib.c
rm -f examples/*.so tests/*.so
rm -rf $(OBJDIR)/ *.dSYM/ qjs-debug$(EXE)
rm -rf run-test262-debug$(EXE)
rm -f run_octane run_sunspider_like
install: all
mkdir -p "$(DESTDIR)$(PREFIX)/bin"
$(STRIP) qjs$(EXE) qjsc$(EXE)
install -m755 qjs$(EXE) qjsc$(EXE) "$(DESTDIR)$(PREFIX)/bin"
mkdir -p "$(DESTDIR)$(PREFIX)/lib/quickjs"
install -m644 libquickjs.a "$(DESTDIR)$(PREFIX)/lib/quickjs"
ifdef CONFIG_LTO
install -m644 libquickjs.lto.a "$(DESTDIR)$(PREFIX)/lib/quickjs"
endif
mkdir -p "$(DESTDIR)$(PREFIX)/include/quickjs"
install -m644 quickjs.h quickjs-libc.h "$(DESTDIR)$(PREFIX)/include/quickjs"
###############################################################################
# examples
# example of static JS compilation
HELLO_SRCS=examples/hello.js
HELLO_OPTS=-fno-string-normalize -fno-map -fno-promise -fno-typedarray \
-fno-typedarray -fno-regexp -fno-json -fno-eval -fno-proxy \
-fno-date -fno-module-loader
hello.c: $(QJSC) $(HELLO_SRCS)
$(QJSC) -e $(HELLO_OPTS) -o $@ $(HELLO_SRCS)
examples/hello: $(OBJDIR)/hello.o $(QJS_LIB_OBJS)
$(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
# example of static JS compilation with modules
HELLO_MODULE_SRCS=examples/hello_module.js
HELLO_MODULE_OPTS=-fno-string-normalize -fno-map -fno-typedarray \
-fno-typedarray -fno-regexp -fno-json -fno-eval -fno-proxy \
-fno-date -m
examples/hello_module: $(QJSC) libquickjs$(LTOEXT).a $(HELLO_MODULE_SRCS)
$(QJSC) $(HELLO_MODULE_OPTS) -o $@ $(HELLO_MODULE_SRCS)
# use of an external C module (static compilation)
test_fib.c: $(QJSC) examples/test_fib.js
$(QJSC) -e -M examples/fib.so,fib -m -o $@ examples/test_fib.js
examples/test_fib: $(OBJDIR)/test_fib.o $(OBJDIR)/examples/fib.o libquickjs$(LTOEXT).a
$(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
examples/fib.so: $(OBJDIR)/examples/fib.pic.o
$(CC) $(LDFLAGS) -shared -o $@ $^
examples/point.so: $(OBJDIR)/examples/point.pic.o
$(CC) $(LDFLAGS) -shared -o $@ $^
###############################################################################
# documentation
DOCS=doc/quickjs.pdf doc/quickjs.html
build_doc: $(DOCS)
clean_doc:
rm -f $(DOCS)
doc/version.texi: VERSION
@echo "@set VERSION `cat $<`" > $@
doc/%.pdf: doc/%.texi doc/version.texi
texi2pdf --clean -o $@ -q $<
doc/%.html.pre: doc/%.texi doc/version.texi
makeinfo --html --no-headers --no-split --number-sections -o $@ $<
doc/%.html: doc/%.html.pre
sed -e 's|</style>|</style>\n<meta name="viewport" content="width=device-width, initial-scale=1.0">|' < $< > $@
###############################################################################
# tests
ifdef CONFIG_SHARED_LIBS
test: tests/bjson.so examples/point.so
endif
test: qjs$(EXE)
$(WINE) ./qjs$(EXE) tests/test_closure.js
$(WINE) ./qjs$(EXE) tests/test_language.js
$(WINE) ./qjs$(EXE) --std tests/test_builtin.js
$(WINE) ./qjs$(EXE) tests/test_loop.js
$(WINE) ./qjs$(EXE) tests/test_bigint.js
$(WINE) ./qjs$(EXE) tests/test_cyclic_import.js
$(WINE) ./qjs$(EXE) tests/test_worker.js
ifndef CONFIG_WIN32
$(WINE) ./qjs$(EXE) tests/test_std.js
endif
ifdef CONFIG_SHARED_LIBS
$(WINE) ./qjs$(EXE) tests/test_bjson.js
$(WINE) ./qjs$(EXE) examples/test_point.js
endif
stats: qjs$(EXE)
$(WINE) ./qjs$(EXE) -qd
microbench: qjs$(EXE)
$(WINE) ./qjs$(EXE) --std tests/microbench.js
ifeq ($(wildcard test262/features.txt),)
test2-bootstrap:
git clone --single-branch --shallow-since=$(TEST262_SINCE) https://github.com/tc39/test262.git
(cd test262 && git checkout -q $(TEST262_COMMIT) && patch -p1 < ../tests/test262.patch && cd ..)
else
test2-bootstrap:
(cd test262 && git fetch && git reset --hard $(TEST262_COMMIT) && patch -p1 < ../tests/test262.patch && cd ..)
endif
ifeq ($(wildcard test262o/tests.txt),)
test2o test2o-update:
@echo test262o tests not installed
else
# ES5 tests (obsolete)
test2o: run-test262
time ./run-test262 -t -m -c test262o.conf
test2o-update: run-test262
./run-test262 -t -u -c test262o.conf
endif
ifeq ($(wildcard test262/features.txt),)
test2 test2-update test2-default test2-check:
@echo test262 tests not installed
else
# Test262 tests
test2-default: run-test262
time ./run-test262 -t -m -c test262.conf
test2: run-test262
time ./run-test262 -t -m -c test262.conf -a
test2-update: run-test262
./run-test262 -t -u -c test262.conf -a
test2-check: run-test262
time ./run-test262 -t -m -c test262.conf -E -a
endif
testall: all test microbench test2o test2
testall-complete: testall
node-test:
node tests/test_closure.js
node tests/test_language.js
node tests/test_builtin.js
node tests/test_loop.js
node tests/test_bigint.js
node-microbench:
node tests/microbench.js -s microbench-node.txt
node --jitless tests/microbench.js -s microbench-node-jitless.txt
bench-v8: qjs
make -C tests/bench-v8
./qjs -d tests/bench-v8/combined.js
node-bench-v8:
make -C tests/bench-v8
node --jitless tests/bench-v8/combined.js
tests/bjson.so: $(OBJDIR)/tests/bjson.pic.o
$(CC) $(LDFLAGS) -shared -o $@ $^ $(LIBS)
BENCHMARKDIR=../quickjs-benchmarks
run_sunspider_like: $(BENCHMARKDIR)/run_sunspider_like.c
$(CC) $(CFLAGS) $(LDFLAGS) -DNO_INCLUDE_DIR -I. -o $@ $< libquickjs$(LTOEXT).a $(LIBS)
run_octane: $(BENCHMARKDIR)/run_octane.c
$(CC) $(CFLAGS) $(LDFLAGS) -DNO_INCLUDE_DIR -I. -o $@ $< libquickjs$(LTOEXT).a $(LIBS)
benchmarks: run_sunspider_like run_octane
./run_sunspider_like $(BENCHMARKDIR)/kraken-1.0/
./run_sunspider_like $(BENCHMARKDIR)/kraken-1.1/
./run_sunspider_like $(BENCHMARKDIR)/sunspider-1.0/
./run_octane $(BENCHMARKDIR)/
-include $(wildcard $(OBJDIR)/*.d)
================================================
FILE: TODO
================================================
Misc ideas:
- use custom printf to avoid compatibility issues with floating point numbers
- consistent naming for preprocessor defines
- unify coding style and naming conventions
- use names from the ECMA spec in library implementation
- use byte code emitters with typed arguments (for clarity)
- use 2 bytecode DynBufs in JSFunctionDef, one for reading, one for writing
and use the same wrappers in all phases
- use more generic method for line numbers in resolve_variables and resolve_labels
- use custom timezone support to avoid C library compatibility issues
Memory:
- use memory pools for objects, etc?
- test border cases for max number of atoms, object properties, string length
- add emergency malloc mode for out of memory exceptions.
- test all DynBuf memory errors
- test all js_realloc memory errors
- improve JS_ComputeMemoryUsage() with more info
Built-in standard library:
- BSD sockets
- modules: use realpath in module name normalizer and put it in quickjs-libc
- modules: if no ".", use a well known module loading path ?
- get rid of __loadScript, use more common name
REPL:
- debugger
- readline: support MS Windows terminal
- readline: handle dynamic terminal resizing
- readline: handle double width unicode characters
- multiline editing
- runtime object and function inspectors
- interactive object browser
- use more generic approach to display evaluation results
- improve directive handling: dispatch, colorize, completion...
- save history
- close all predefined methods in repl.js and jscalc.js
Optimization ideas:
- use 64 bit JSValue in 64 bit mode
- use JSValue as atoms and use a specific constant pool in functions to
reference atoms from the bytecode
- reuse stack slots for disjoint scopes, if strip
- add heuristic to avoid some cycles in closures
- small String (1 codepoint) with immediate storage
- perform static string concatenation at compile time
- add implicit numeric strings for Uint32 numbers?
- optimize `s += a + b`, `s += a.b` and similar simple expressions
- ensure string canonical representation and optimise comparisons and hashes?
- property access optimization on the global object, functions,
prototypes and special non extensible objects.
- create object literals with the correct length by backpatching length argument
- remove redundant set_loc_uninitialized/check_uninitialized opcodes
- peephole optim: push_atom_value, to_propkey -> push_atom_value
- peephole optim: put_loc x, get_loc_check x -> set_loc x
- convert slow array to fast array when all properties != length are numeric
- optimize destructuring assignments for global and local variables
- implement some form of tail-call-optimization
- optimize OP_apply
- optimize f(...b)
Test262o: 0/11262 errors, 463 excluded
Test262o commit: 7da91bceb9ce7613f87db47ddd1292a2dda58b42 (es5-tests branch)
Test262:
Result: 66/83341 errors, 2567 excluded, 5767 skipped
================================================
FILE: VERSION
================================================
2025-09-13
================================================
FILE: compat/test-closefrom.c
================================================
#include <unistd.h>
int main(void) {
closefrom(3);
return 0;
}
================================================
FILE: cutils.c
================================================
/*
* C utilities
*
* Copyright (c) 2017 Fabrice Bellard
* Copyright (c) 2018 Charlie Gordon
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include "cutils.h"
void pstrcpy(char *buf, int buf_size, const char *str)
{
int c;
char *q = buf;
if (buf_size <= 0)
return;
for(;;) {
c = *str++;
if (c == 0 || q >= buf + buf_size - 1)
break;
*q++ = c;
}
*q = '\0';
}
/* strcat and truncate. */
char *pstrcat(char *buf, int buf_size, const char *s)
{
int len;
len = strlen(buf);
if (len < buf_size)
pstrcpy(buf + len, buf_size - len, s);
return buf;
}
int strstart(const char *str, const char *val, const char **ptr)
{
const char *p, *q;
p = str;
q = val;
while (*q != '\0') {
if (*p != *q)
return 0;
p++;
q++;
}
if (ptr)
*ptr = p;
return 1;
}
int has_suffix(const char *str, const char *suffix)
{
size_t len = strlen(str);
size_t slen = strlen(suffix);
return (len >= slen && !memcmp(str + len - slen, suffix, slen));
}
/* Dynamic buffer package */
static void *dbuf_default_realloc(void *opaque, void *ptr, size_t size)
{
return realloc(ptr, size);
}
void dbuf_init2(DynBuf *s, void *opaque, DynBufReallocFunc *realloc_func)
{
memset(s, 0, sizeof(*s));
if (!realloc_func)
realloc_func = dbuf_default_realloc;
s->opaque = opaque;
s->realloc_func = realloc_func;
}
void dbuf_init(DynBuf *s)
{
dbuf_init2(s, NULL, NULL);
}
/* Try to allocate 'len' more bytes. return < 0 if error */
int dbuf_claim(DynBuf *s, size_t len)
{
size_t new_size, size;
uint8_t *new_buf;
new_size = s->size + len;
if (new_size < len)
return -1; /* overflow case */
if (new_size > s->allocated_size) {
if (s->error)
return -1;
size = s->allocated_size + (s->allocated_size / 2);
if (size < s->allocated_size)
return -1; /* overflow case */
if (size > new_size)
new_size = size;
new_buf = s->realloc_func(s->opaque, s->buf, new_size);
if (!new_buf) {
s->error = TRUE;
return -1;
}
s->buf = new_buf;
s->allocated_size = new_size;
}
return 0;
}
int dbuf_put(DynBuf *s, const uint8_t *data, size_t len)
{
if (unlikely((s->allocated_size - s->size) < len)) {
if (dbuf_claim(s, len))
return -1;
}
memcpy_no_ub(s->buf + s->size, data, len);
s->size += len;
return 0;
}
int dbuf_put_self(DynBuf *s, size_t offset, size_t len)
{
if (unlikely((s->allocated_size - s->size) < len)) {
if (dbuf_claim(s, len))
return -1;
}
memcpy(s->buf + s->size, s->buf + offset, len);
s->size += len;
return 0;
}
int __dbuf_putc(DynBuf *s, uint8_t c)
{
return dbuf_put(s, &c, 1);
}
int __dbuf_put_u16(DynBuf *s, uint16_t val)
{
return dbuf_put(s, (uint8_t *)&val, 2);
}
int __dbuf_put_u32(DynBuf *s, uint32_t val)
{
return dbuf_put(s, (uint8_t *)&val, 4);
}
int __dbuf_put_u64(DynBuf *s, uint64_t val)
{
return dbuf_put(s, (uint8_t *)&val, 8);
}
int dbuf_putstr(DynBuf *s, const char *str)
{
return dbuf_put(s, (const uint8_t *)str, strlen(str));
}
int __attribute__((format(printf, 2, 3))) dbuf_printf(DynBuf *s,
const char *fmt, ...)
{
va_list ap;
char buf[128];
int len;
va_start(ap, fmt);
len = vsnprintf(buf, sizeof(buf), fmt, ap);
va_end(ap);
if (len < 0)
return -1;
if (len < sizeof(buf)) {
/* fast case */
return dbuf_put(s, (uint8_t *)buf, len);
} else {
if (dbuf_claim(s, len + 1))
return -1;
va_start(ap, fmt);
vsnprintf((char *)(s->buf + s->size), s->allocated_size - s->size,
fmt, ap);
va_end(ap);
s->size += len;
}
return 0;
}
void dbuf_free(DynBuf *s)
{
/* we test s->buf as a fail safe to avoid crashing if dbuf_free()
is called twice */
if (s->buf) {
s->realloc_func(s->opaque, s->buf, 0);
}
memset(s, 0, sizeof(*s));
}
/* Note: at most 31 bits are encoded. At most UTF8_CHAR_LEN_MAX bytes
are output. */
int unicode_to_utf8(uint8_t *buf, unsigned int c)
{
uint8_t *q = buf;
if (c < 0x80) {
*q++ = c;
} else {
if (c < 0x800) {
*q++ = (c >> 6) | 0xc0;
} else {
if (c < 0x10000) {
*q++ = (c >> 12) | 0xe0;
} else {
if (c < 0x00200000) {
*q++ = (c >> 18) | 0xf0;
} else {
if (c < 0x04000000) {
*q++ = (c >> 24) | 0xf8;
} else if (c < 0x80000000) {
*q++ = (c >> 30) | 0xfc;
*q++ = ((c >> 24) & 0x3f) | 0x80;
} else {
return 0;
}
*q++ = ((c >> 18) & 0x3f) | 0x80;
}
*q++ = ((c >> 12) & 0x3f) | 0x80;
}
*q++ = ((c >> 6) & 0x3f) | 0x80;
}
*q++ = (c & 0x3f) | 0x80;
}
return q - buf;
}
static const unsigned int utf8_min_code[5] = {
0x80, 0x800, 0x10000, 0x00200000, 0x04000000,
};
static const unsigned char utf8_first_code_mask[5] = {
0x1f, 0xf, 0x7, 0x3, 0x1,
};
/* return -1 if error. *pp is not updated in this case. max_len must
be >= 1. The maximum length for a UTF8 byte sequence is 6 bytes. */
int unicode_from_utf8(const uint8_t *p, int max_len, const uint8_t **pp)
{
int l, c, b, i;
c = *p++;
if (c < 0x80) {
*pp = p;
return c;
}
switch(c) {
case 0xc0: case 0xc1: case 0xc2: case 0xc3:
case 0xc4: case 0xc5: case 0xc6: case 0xc7:
case 0xc8: case 0xc9: case 0xca: case 0xcb:
case 0xcc: case 0xcd: case 0xce: case 0xcf:
case 0xd0: case 0xd1: case 0xd2: case 0xd3:
case 0xd4: case 0xd5: case 0xd6: case 0xd7:
case 0xd8: case 0xd9: case 0xda: case 0xdb:
case 0xdc: case 0xdd: case 0xde: case 0xdf:
l = 1;
break;
case 0xe0: case 0xe1: case 0xe2: case 0xe3:
case 0xe4: case 0xe5: case 0xe6: case 0xe7:
case 0xe8: case 0xe9: case 0xea: case 0xeb:
case 0xec: case 0xed: case 0xee: case 0xef:
l = 2;
break;
case 0xf0: case 0xf1: case 0xf2: case 0xf3:
case 0xf4: case 0xf5: case 0xf6: case 0xf7:
l = 3;
break;
case 0xf8: case 0xf9: case 0xfa: case 0xfb:
l = 4;
break;
case 0xfc: case 0xfd:
l = 5;
break;
default:
return -1;
}
/* check that we have enough characters */
if (l > (max_len - 1))
return -1;
c &= utf8_first_code_mask[l - 1];
for(i = 0; i < l; i++) {
b = *p++;
if (b < 0x80 || b >= 0xc0)
return -1;
c = (c << 6) | (b & 0x3f);
}
if (c < utf8_min_code[l - 1])
return -1;
*pp = p;
return c;
}
#if 0
#if defined(EMSCRIPTEN) || defined(__ANDROID__)
static void *rqsort_arg;
static int (*rqsort_cmp)(const void *, const void *, void *);
static int rqsort_cmp2(const void *p1, const void *p2)
{
return rqsort_cmp(p1, p2, rqsort_arg);
}
/* not reentrant, but not needed with emscripten */
void rqsort(void *base, size_t nmemb, size_t size,
int (*cmp)(const void *, const void *, void *),
void *arg)
{
rqsort_arg = arg;
rqsort_cmp = cmp;
qsort(base, nmemb, size, rqsort_cmp2);
}
#endif
#else
typedef void (*exchange_f)(void *a, void *b, size_t size);
typedef int (*cmp_f)(const void *, const void *, void *opaque);
static void exchange_bytes(void *a, void *b, size_t size) {
uint8_t *ap = (uint8_t *)a;
uint8_t *bp = (uint8_t *)b;
while (size-- != 0) {
uint8_t t = *ap;
*ap++ = *bp;
*bp++ = t;
}
}
static void exchange_one_byte(void *a, void *b, size_t size) {
uint8_t *ap = (uint8_t *)a;
uint8_t *bp = (uint8_t *)b;
uint8_t t = *ap;
*ap = *bp;
*bp = t;
}
static void exchange_int16s(void *a, void *b, size_t size) {
uint16_t *ap = (uint16_t *)a;
uint16_t *bp = (uint16_t *)b;
for (size /= sizeof(uint16_t); size-- != 0;) {
uint16_t t = *ap;
*ap++ = *bp;
*bp++ = t;
}
}
static void exchange_one_int16(void *a, void *b, size_t size) {
uint16_t *ap = (uint16_t *)a;
uint16_t *bp = (uint16_t *)b;
uint16_t t = *ap;
*ap = *bp;
*bp = t;
}
static void exchange_int32s(void *a, void *b, size_t size) {
uint32_t *ap = (uint32_t *)a;
uint32_t *bp = (uint32_t *)b;
for (size /= sizeof(uint32_t); size-- != 0;) {
uint32_t t = *ap;
*ap++ = *bp;
*bp++ = t;
}
}
static void exchange_one_int32(void *a, void *b, size_t size) {
uint32_t *ap = (uint32_t *)a;
uint32_t *bp = (uint32_t *)b;
uint32_t t = *ap;
*ap = *bp;
*bp = t;
}
static void exchange_int64s(void *a, void *b, size_t size) {
uint64_t *ap = (uint64_t *)a;
uint64_t *bp = (uint64_t *)b;
for (size /= sizeof(uint64_t); size-- != 0;) {
uint64_t t = *ap;
*ap++ = *bp;
*bp++ = t;
}
}
static void exchange_one_int64(void *a, void *b, size_t size) {
uint64_t *ap = (uint64_t *)a;
uint64_t *bp = (uint64_t *)b;
uint64_t t = *ap;
*ap = *bp;
*bp = t;
}
static void exchange_int128s(void *a, void *b, size_t size) {
uint64_t *ap = (uint64_t *)a;
uint64_t *bp = (uint64_t *)b;
for (size /= sizeof(uint64_t) * 2; size-- != 0; ap += 2, bp += 2) {
uint64_t t = ap[0];
uint64_t u = ap[1];
ap[0] = bp[0];
ap[1] = bp[1];
bp[0] = t;
bp[1] = u;
}
}
static void exchange_one_int128(void *a, void *b, size_t size) {
uint64_t *ap = (uint64_t *)a;
uint64_t *bp = (uint64_t *)b;
uint64_t t = ap[0];
uint64_t u = ap[1];
ap[0] = bp[0];
ap[1] = bp[1];
bp[0] = t;
bp[1] = u;
}
static inline exchange_f exchange_func(const void *base, size_t size) {
switch (((uintptr_t)base | (uintptr_t)size) & 15) {
case 0:
if (size == sizeof(uint64_t) * 2)
return exchange_one_int128;
else
return exchange_int128s;
case 8:
if (size == sizeof(uint64_t))
return exchange_one_int64;
else
return exchange_int64s;
case 4:
case 12:
if (size == sizeof(uint32_t))
return exchange_one_int32;
else
return exchange_int32s;
case 2:
case 6:
case 10:
case 14:
if (size == sizeof(uint16_t))
return exchange_one_int16;
else
return exchange_int16s;
default:
if (size == 1)
return exchange_one_byte;
else
return exchange_bytes;
}
}
static void heapsortx(void *base, size_t nmemb, size_t size, cmp_f cmp, void *opaque)
{
uint8_t *basep = (uint8_t *)base;
size_t i, n, c, r;
exchange_f swap = exchange_func(base, size);
if (nmemb > 1) {
i = (nmemb / 2) * size;
n = nmemb * size;
while (i > 0) {
i -= size;
for (r = i; (c = r * 2 + size) < n; r = c) {
if (c < n - size && cmp(basep + c, basep + c + size, opaque) <= 0)
c += size;
if (cmp(basep + r, basep + c, opaque) > 0)
break;
swap(basep + r, basep + c, size);
}
}
for (i = n - size; i > 0; i -= size) {
swap(basep, basep + i, size);
for (r = 0; (c = r * 2 + size) < i; r = c) {
if (c < i - size && cmp(basep + c, basep + c + size, opaque) <= 0)
c += size;
if (cmp(basep + r, basep + c, opaque) > 0)
break;
swap(basep + r, basep + c, size);
}
}
}
}
static inline void *med3(void *a, void *b, void *c, cmp_f cmp, void *opaque)
{
return cmp(a, b, opaque) < 0 ?
(cmp(b, c, opaque) < 0 ? b : (cmp(a, c, opaque) < 0 ? c : a )) :
(cmp(b, c, opaque) > 0 ? b : (cmp(a, c, opaque) < 0 ? a : c ));
}
/* pointer based version with local stack and insertion sort threshhold */
void rqsort(void *base, size_t nmemb, size_t size, cmp_f cmp, void *opaque)
{
struct { uint8_t *base; size_t count; int depth; } stack[50], *sp = stack;
uint8_t *ptr, *pi, *pj, *plt, *pgt, *top, *m;
size_t m4, i, lt, gt, span, span2;
int c, depth;
exchange_f swap = exchange_func(base, size);
exchange_f swap_block = exchange_func(base, size | 128);
if (nmemb < 2 || size <= 0)
return;
sp->base = (uint8_t *)base;
sp->count = nmemb;
sp->depth = 0;
sp++;
while (sp > stack) {
sp--;
ptr = sp->base;
nmemb = sp->count;
depth = sp->depth;
while (nmemb > 6) {
if (++depth > 50) {
/* depth check to ensure worst case logarithmic time */
heapsortx(ptr, nmemb, size, cmp, opaque);
nmemb = 0;
break;
}
/* select median of 3 from 1/4, 1/2, 3/4 positions */
/* should use median of 5 or 9? */
m4 = (nmemb >> 2) * size;
m = med3(ptr + m4, ptr + 2 * m4, ptr + 3 * m4, cmp, opaque);
swap(ptr, m, size); /* move the pivot to the start or the array */
i = lt = 1;
pi = plt = ptr + size;
gt = nmemb;
pj = pgt = top = ptr + nmemb * size;
for (;;) {
while (pi < pj && (c = cmp(ptr, pi, opaque)) >= 0) {
if (c == 0) {
swap(plt, pi, size);
lt++;
plt += size;
}
i++;
pi += size;
}
while (pi < (pj -= size) && (c = cmp(ptr, pj, opaque)) <= 0) {
if (c == 0) {
gt--;
pgt -= size;
swap(pgt, pj, size);
}
}
if (pi >= pj)
break;
swap(pi, pj, size);
i++;
pi += size;
}
/* array has 4 parts:
* from 0 to lt excluded: elements identical to pivot
* from lt to pi excluded: elements smaller than pivot
* from pi to gt excluded: elements greater than pivot
* from gt to n excluded: elements identical to pivot
*/
/* move elements identical to pivot in the middle of the array: */
/* swap values in ranges [0..lt[ and [i-lt..i[
swapping the smallest span between lt and i-lt is sufficient
*/
span = plt - ptr;
span2 = pi - plt;
lt = i - lt;
if (span > span2)
span = span2;
swap_block(ptr, pi - span, span);
/* swap values in ranges [gt..top[ and [i..top-(top-gt)[
swapping the smallest span between top-gt and gt-i is sufficient
*/
span = top - pgt;
span2 = pgt - pi;
pgt = top - span2;
gt = nmemb - (gt - i);
if (span > span2)
span = span2;
swap_block(pi, top - span, span);
/* now array has 3 parts:
* from 0 to lt excluded: elements smaller than pivot
* from lt to gt excluded: elements identical to pivot
* from gt to n excluded: elements greater than pivot
*/
/* stack the larger segment and keep processing the smaller one
to minimize stack use for pathological distributions */
if (lt > nmemb - gt) {
sp->base = ptr;
sp->count = lt;
sp->depth = depth;
sp++;
ptr = pgt;
nmemb -= gt;
} else {
sp->base = pgt;
sp->count = nmemb - gt;
sp->depth = depth;
sp++;
nmemb = lt;
}
}
/* Use insertion sort for small fragments */
for (pi = ptr + size, top = ptr + nmemb * size; pi < top; pi += size) {
for (pj = pi; pj > ptr && cmp(pj - size, pj, opaque) > 0; pj -= size)
swap(pj, pj - size, size);
}
}
}
#endif
================================================
FILE: cutils.h
================================================
/*
* C utilities
*
* Copyright (c) 2017 Fabrice Bellard
* Copyright (c) 2018 Charlie Gordon
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef CUTILS_H
#define CUTILS_H
#include <stdlib.h>
#include <string.h>
#include <inttypes.h>
#define likely(x) __builtin_expect(!!(x), 1)
#define unlikely(x) __builtin_expect(!!(x), 0)
#define force_inline inline __attribute__((always_inline))
#define no_inline __attribute__((noinline))
#define __maybe_unused __attribute__((unused))
#define xglue(x, y) x ## y
#define glue(x, y) xglue(x, y)
#define stringify(s) tostring(s)
#define tostring(s) #s
#ifndef offsetof
#define offsetof(type, field) ((size_t) &((type *)0)->field)
#endif
#ifndef countof
#define countof(x) (sizeof(x) / sizeof((x)[0]))
#endif
#ifndef container_of
/* return the pointer of type 'type *' containing 'ptr' as field 'member' */
#define container_of(ptr, type, member) ((type *)((uint8_t *)(ptr) - offsetof(type, member)))
#endif
#if !defined(_MSC_VER) && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
#define minimum_length(n) static n
#else
#define minimum_length(n) n
#endif
typedef int BOOL;
#ifndef FALSE
enum {
FALSE = 0,
TRUE = 1,
};
#endif
void pstrcpy(char *buf, int buf_size, const char *str);
char *pstrcat(char *buf, int buf_size, const char *s);
int strstart(const char *str, const char *val, const char **ptr);
int has_suffix(const char *str, const char *suffix);
/* Prevent UB when n == 0 and (src == NULL or dest == NULL) */
static inline void memcpy_no_ub(void *dest, const void *src, size_t n) {
if (n)
memcpy(dest, src, n);
}
static inline int max_int(int a, int b)
{
if (a > b)
return a;
else
return b;
}
static inline int min_int(int a, int b)
{
if (a < b)
return a;
else
return b;
}
static inline uint32_t max_uint32(uint32_t a, uint32_t b)
{
if (a > b)
return a;
else
return b;
}
static inline uint32_t min_uint32(uint32_t a, uint32_t b)
{
if (a < b)
return a;
else
return b;
}
static inline int64_t max_int64(int64_t a, int64_t b)
{
if (a > b)
return a;
else
return b;
}
static inline int64_t min_int64(int64_t a, int64_t b)
{
if (a < b)
return a;
else
return b;
}
/* WARNING: undefined if a = 0 */
static inline int clz32(unsigned int a)
{
return __builtin_clz(a);
}
/* WARNING: undefined if a = 0 */
static inline int clz64(uint64_t a)
{
return __builtin_clzll(a);
}
/* WARNING: undefined if a = 0 */
static inline int ctz32(unsigned int a)
{
return __builtin_ctz(a);
}
/* WARNING: undefined if a = 0 */
static inline int ctz64(uint64_t a)
{
return __builtin_ctzll(a);
}
struct __attribute__((packed)) packed_u64 {
uint64_t v;
};
struct __attribute__((packed)) packed_u32 {
uint32_t v;
};
struct __attribute__((packed)) packed_u16 {
uint16_t v;
};
static inline uint64_t get_u64(const uint8_t *tab)
{
return ((const struct packed_u64 *)tab)->v;
}
static inline int64_t get_i64(const uint8_t *tab)
{
return (int64_t)((const struct packed_u64 *)tab)->v;
}
static inline void put_u64(uint8_t *tab, uint64_t val)
{
((struct packed_u64 *)tab)->v = val;
}
static inline uint32_t get_u32(const uint8_t *tab)
{
return ((const struct packed_u32 *)tab)->v;
}
static inline int32_t get_i32(const uint8_t *tab)
{
return (int32_t)((const struct packed_u32 *)tab)->v;
}
static inline void put_u32(uint8_t *tab, uint32_t val)
{
((struct packed_u32 *)tab)->v = val;
}
static inline uint32_t get_u16(const uint8_t *tab)
{
return ((const struct packed_u16 *)tab)->v;
}
static inline int32_t get_i16(const uint8_t *tab)
{
return (int16_t)((const struct packed_u16 *)tab)->v;
}
static inline void put_u16(uint8_t *tab, uint16_t val)
{
((struct packed_u16 *)tab)->v = val;
}
static inline uint32_t get_u8(const uint8_t *tab)
{
return *tab;
}
static inline int32_t get_i8(const uint8_t *tab)
{
return (int8_t)*tab;
}
static inline void put_u8(uint8_t *tab, uint8_t val)
{
*tab = val;
}
#ifndef bswap16
static inline uint16_t bswap16(uint16_t x)
{
return (x >> 8) | (x << 8);
}
#endif
#ifndef bswap32
static inline uint32_t bswap32(uint32_t v)
{
return ((v & 0xff000000) >> 24) | ((v & 0x00ff0000) >> 8) |
((v & 0x0000ff00) << 8) | ((v & 0x000000ff) << 24);
}
#endif
#ifndef bswap64
static inline uint64_t bswap64(uint64_t v)
{
return ((v & ((uint64_t)0xff << (7 * 8))) >> (7 * 8)) |
((v & ((uint64_t)0xff << (6 * 8))) >> (5 * 8)) |
((v & ((uint64_t)0xff << (5 * 8))) >> (3 * 8)) |
((v & ((uint64_t)0xff << (4 * 8))) >> (1 * 8)) |
((v & ((uint64_t)0xff << (3 * 8))) << (1 * 8)) |
((v & ((uint64_t)0xff << (2 * 8))) << (3 * 8)) |
((v & ((uint64_t)0xff << (1 * 8))) << (5 * 8)) |
((v & ((uint64_t)0xff << (0 * 8))) << (7 * 8));
}
#endif
/* XXX: should take an extra argument to pass slack information to the caller */
typedef void *DynBufReallocFunc(void *opaque, void *ptr, size_t size);
typedef struct DynBuf {
uint8_t *buf;
size_t size;
size_t allocated_size;
BOOL error; /* true if a memory allocation error occurred */
DynBufReallocFunc *realloc_func;
void *opaque; /* for realloc_func */
} DynBuf;
void dbuf_init(DynBuf *s);
void dbuf_init2(DynBuf *s, void *opaque, DynBufReallocFunc *realloc_func);
int dbuf_claim(DynBuf *s, size_t len);
int dbuf_put(DynBuf *s, const uint8_t *data, size_t len);
int dbuf_put_self(DynBuf *s, size_t offset, size_t len);
int dbuf_putstr(DynBuf *s, const char *str);
int __dbuf_putc(DynBuf *s, uint8_t c);
int __dbuf_put_u16(DynBuf *s, uint16_t val);
int __dbuf_put_u32(DynBuf *s, uint32_t val);
int __dbuf_put_u64(DynBuf *s, uint64_t val);
static inline int dbuf_putc(DynBuf *s, uint8_t val)
{
if (unlikely((s->allocated_size - s->size) < 1)) {
return __dbuf_putc(s, val);
} else {
s->buf[s->size++] = val;
return 0;
}
}
static inline int dbuf_put_u16(DynBuf *s, uint16_t val)
{
if (unlikely((s->allocated_size - s->size) < 2)) {
return __dbuf_put_u16(s, val);
} else {
put_u16(s->buf + s->size, val);
s->size += 2;
return 0;
}
}
static inline int dbuf_put_u32(DynBuf *s, uint32_t val)
{
if (unlikely((s->allocated_size - s->size) < 4)) {
return __dbuf_put_u32(s, val);
} else {
put_u32(s->buf + s->size, val);
s->size += 4;
return 0;
}
}
static inline int dbuf_put_u64(DynBuf *s, uint64_t val)
{
if (unlikely((s->allocated_size - s->size) < 8)) {
return __dbuf_put_u64(s, val);
} else {
put_u64(s->buf + s->size, val);
s->size += 8;
return 0;
}
}
int __attribute__((format(printf, 2, 3))) dbuf_printf(DynBuf *s,
const char *fmt, ...);
void dbuf_free(DynBuf *s);
static inline BOOL dbuf_error(DynBuf *s) {
return s->error;
}
static inline void dbuf_set_error(DynBuf *s)
{
s->error = TRUE;
}
#define UTF8_CHAR_LEN_MAX 6
int unicode_to_utf8(uint8_t *buf, unsigned int c);
int unicode_from_utf8(const uint8_t *p, int max_len, const uint8_t **pp);
static inline BOOL is_surrogate(uint32_t c)
{
return (c >> 11) == (0xD800 >> 11); // 0xD800-0xDFFF
}
static inline BOOL is_hi_surrogate(uint32_t c)
{
return (c >> 10) == (0xD800 >> 10); // 0xD800-0xDBFF
}
static inline BOOL is_lo_surrogate(uint32_t c)
{
return (c >> 10) == (0xDC00 >> 10); // 0xDC00-0xDFFF
}
static inline uint32_t get_hi_surrogate(uint32_t c)
{
return (c >> 10) - (0x10000 >> 10) + 0xD800;
}
static inline uint32_t get_lo_surrogate(uint32_t c)
{
return (c & 0x3FF) | 0xDC00;
}
static inline uint32_t from_surrogate(uint32_t hi, uint32_t lo)
{
return 0x10000 + 0x400 * (hi - 0xD800) + (lo - 0xDC00);
}
static inline int from_hex(int c)
{
if (c >= '0' && c <= '9')
return c - '0';
else if (c >= 'A' && c <= 'F')
return c - 'A' + 10;
else if (c >= 'a' && c <= 'f')
return c - 'a' + 10;
else
return -1;
}
void rqsort(void *base, size_t nmemb, size_t size,
int (*cmp)(const void *, const void *, void *),
void *arg);
static inline uint64_t float64_as_uint64(double d)
{
union {
double d;
uint64_t u64;
} u;
u.d = d;
return u.u64;
}
static inline double uint64_as_float64(uint64_t u64)
{
union {
double d;
uint64_t u64;
} u;
u.u64 = u64;
return u.d;
}
static inline double fromfp16(uint16_t v)
{
double d;
uint32_t v1;
v1 = v & 0x7fff;
if (unlikely(v1 >= 0x7c00))
v1 += 0x1f8000; /* NaN or infinity */
d = uint64_as_float64(((uint64_t)(v >> 15) << 63) | ((uint64_t)v1 << (52 - 10)));
return d * 0x1p1008;
}
static inline uint16_t tofp16(double d)
{
uint64_t a, addend;
uint32_t v, sgn;
int shift;
a = float64_as_uint64(d);
sgn = a >> 63;
a = a & 0x7fffffffffffffff;
if (unlikely(a > 0x7ff0000000000000)) {
/* nan */
v = 0x7c01;
} else if (a < 0x3f10000000000000) { /* 0x1p-14 */
/* subnormal f16 number or zero */
if (a <= 0x3e60000000000000) { /* 0x1p-25 */
v = 0x0000; /* zero */
} else {
shift = 1051 - (a >> 52);
a = ((uint64_t)1 << 52) | (a & (((uint64_t)1 << 52) - 1));
addend = ((a >> shift) & 1) + (((uint64_t)1 << (shift - 1)) - 1);
v = (a + addend) >> shift;
}
} else {
/* normal number or infinity */
a -= 0x3f00000000000000; /* adjust the exponent */
/* round */
addend = ((a >> (52 - 10)) & 1) + (((uint64_t)1 << (52 - 11)) - 1);
v = (a + addend) >> (52 - 10);
/* overflow ? */
if (unlikely(v > 0x7c00))
v = 0x7c00;
}
return v | (sgn << 15);
}
static inline int isfp16nan(uint16_t v)
{
return (v & 0x7FFF) > 0x7C00;
}
static inline int isfp16zero(uint16_t v)
{
return (v & 0x7FFF) == 0;
}
#endif /* CUTILS_H */
================================================
FILE: doc/quickjs.texi
================================================
\input texinfo
@iftex
@afourpaper
@headings double
@end iftex
@include version.texi
@titlepage
@afourpaper
@sp 7
@center @titlefont{QuickJS Javascript Engine}
@sp 3
@center Version: @value{VERSION}
@end titlepage
@setfilename spec.info
@settitle QuickJS Javascript Engine
@contents
@chapter Introduction
QuickJS (version @value{VERSION}) is a small and embeddable Javascript
engine. It supports most of the ES2024 specification
@footnote{@url{https://tc39.es/ecma262/2024 }} including modules,
asynchronous generators, proxies and BigInt.
@section Main Features
@itemize
@item Small and easily embeddable: just a few C files, no external dependency, 210 KiB of x86 code for a simple ``hello world'' program.
@item Fast interpreter with very low startup time: runs the 77000 tests of the ECMAScript Test Suite@footnote{@url{https://github.com/tc39/test262}} in less than 2 minutes on a single core of a desktop PC. The complete life cycle of a runtime instance completes in less than 300 microseconds.
@item Almost complete ES2024 support including modules, asynchronous
generators and full Annex B support (legacy web compatibility). Some
features from the upcoming ES2024 specification
@footnote{@url{https://tc39.es/ecma262/}} are also supported.
@item Passes nearly 100% of the ECMAScript Test Suite tests when selecting the ES2024 features.
@item Compile Javascript sources to executables with no external dependency.
@item Garbage collection using reference counting (to reduce memory usage and have deterministic behavior) with cycle removal.
@item Command line interpreter with contextual colorization and completion implemented in Javascript.
@item Small built-in standard library with C library wrappers.
@end itemize
@chapter Usage
@section Installation
A Makefile is provided to compile the engine on Linux or MacOS/X. A
preliminary Windows support is available thru cross compilation on a
Linux host with the MingGW tools.
Edit the top of the @code{Makefile} if you wish to select specific
options then run @code{make}.
You can type @code{make install} as root if you wish to install the binaries and support files to
@code{/usr/local} (this is not necessary to use QuickJS).
Note: On some OSes atomic operations are not available or need a
specific library. If you get related errors, you should either add
@code{-latomics} in the Makefile @code{LIBS} variable or disable
@code{CONFIG_ATOMICS} in @file{quickjs.c}.
@section Quick start
@code{qjs} is the command line interpreter (Read-Eval-Print Loop). You can pass
Javascript files and/or expressions as arguments to execute them:
@example
./qjs examples/hello.js
@end example
@code{qjsc} is the command line compiler:
@example
./qjsc -o hello examples/hello.js
./hello
@end example
generates a @code{hello} executable with no external dependency.
@section Command line options
@subsection @code{qjs} interpreter
@verbatim
usage: qjs [options] [file [args]]
@end verbatim
Options are:
@table @code
@item -h
@item --help
List options.
@item -e @code{EXPR}
@item --eval @code{EXPR}
Evaluate EXPR.
@item -i
@item --interactive
Go to interactive mode (it is not the default when files are provided on the command line).
@item -m
@item --module
Load as ES6 module (default=autodetect). A module is autodetected if
the filename extension is @code{.mjs} or if the first keyword of the
source is @code{import}.
@item --script
Load as ES6 script (default=autodetect).
@item -I file
@item --include file
Include an additional file.
@end table
Advanced options are:
@table @code
@item --std
Make the @code{std} and @code{os} modules available to the loaded
script even if it is not a module.
@item -d
@item --dump
Dump the memory usage stats.
@item -q
@item --quit
just instantiate the interpreter and quit.
@end table
@subsection @code{qjsc} compiler
@verbatim
usage: qjsc [options] [files]
@end verbatim
Options are:
@table @code
@item -c
Only output bytecode in a C file. The default is to output an executable file.
@item -e
Output @code{main()} and bytecode in a C file. The default is to output an
executable file.
@item -o output
Set the output filename (default = @file{out.c} or @file{a.out}).
@item -N cname
Set the C name of the generated data.
@item -m
Compile as Javascript module (default=autodetect).
@item -D module_name
Compile a dynamically loaded module and its dependencies. This option
is needed when your code uses the @code{import} keyword or the
@code{os.Worker} constructor because the compiler cannot statically
find the name of the dynamically loaded modules.
@item -M module_name[,cname]
Add initialization code for an external C module. See the
@code{c_module} example.
@item -x
Byte swapped output (only used for cross compilation).
@item -flto
Use link time optimization. The compilation is slower but the
executable is smaller and faster. This option is automatically set
when the @code{-fno-x} options are used.
@item -fno-[eval|string-normalize|regexp|json|proxy|map|typedarray|promise|bigint]
Disable selected language features to produce a smaller executable file.
@end table
@section Built-in tests
Run @code{make test} to run the few built-in tests included in the
QuickJS archive.
@section Test262 (ECMAScript Test Suite)
A test262 runner is included in the QuickJS archive. The test262 tests
can be installed in the QuickJS source directory with:
@example
git clone https://github.com/tc39/test262.git test262
cd test262
patch -p1 < ../tests/test262.patch
cd ..
@end example
The patch adds the implementation specific @code{harness} functions
and optimizes the inefficient RegExp character classes and Unicode
property escapes tests (the tests themselves are not modified, only a
slow string initialization function is optimized).
The tests can be run with
@example
make test2
@end example
The configuration files @code{test262.conf}
(resp. @code{test262o.conf} for the old ES5.1 tests@footnote{The old
ES5.1 tests can be extracted with @code{git clone --single-branch
--branch es5-tests https://github.com/tc39/test262.git test262o}}))
contain the options to run the various tests. Tests can be excluded
based on features or filename.
The file @code{test262_errors.txt} contains the current list of
errors. The runner displays a message when a new error appears or when
an existing error is corrected or modified. Use the @code{-u} option
to update the current list of errors (or @code{make test2-update}).
The file @code{test262_report.txt} contains the logs of all the
tests. It is useful to have a clearer analysis of a particular
error. In case of crash, the last line corresponds to the failing
test.
Use the syntax @code{./run-test262 -c test262.conf -f filename.js} to
run a single test. Use the syntax @code{./run-test262 -c test262.conf
N} to start testing at test number @code{N}.
For more information, run @code{./run-test262} to see the command line
options of the test262 runner.
@code{run-test262} accepts the @code{-N} option to be invoked from
@code{test262-harness}@footnote{@url{https://github.com/bterlson/test262-harness}}
thru @code{eshost}. Unless you want to compare QuickJS with other
engines under the same conditions, we do not recommend to run the
tests this way as it is much slower (typically half an hour instead of
about 100 seconds).
@chapter Specifications
@section Language support
@subsection ES2024 support
The ES2024 specification is almost fully supported including the Annex
B (legacy web compatibility) and the Unicode related features.
The following features are not supported yet:
@itemize
@item Tail calls@footnote{We believe the current specification of tails calls is too complicated and presents limited practical interests.}
@item Atomics.waitAsync
@end itemize
@subsection ECMA402
ECMA402 (Internationalization API) is not supported.
@section Modules
ES6 modules are fully supported. The default name resolution is the
following:
@itemize
@item Module names with a leading @code{.} or @code{..} are relative
to the current module path.
@item Module names without a leading @code{.} or @code{..} are system
modules, such as @code{std} or @code{os}.
@item Module names ending with @code{.so} are native modules using the
QuickJS C API.
@end itemize
@section Standard library
The standard library is included by default in the command line
interpreter. It contains the two modules @code{std} and @code{os} and
a few global objects.
@subsection Global objects
@table @code
@item scriptArgs
Provides the command line arguments. The first argument is the script name.
@item print(...args)
Print the arguments separated by spaces and a trailing newline.
@item console.log(...args)
Same as print().
@end table
@subsection @code{std} module
The @code{std} module provides wrappers to the libc @file{stdlib.h}
and @file{stdio.h} and a few other utilities.
Available exports:
@table @code
@item exit(n)
Exit the process.
@item evalScript(str, options = undefined)
Evaluate the string @code{str} as a script (global
eval). @code{options} is an optional object containing the following
optional properties:
@table @code
@item backtrace_barrier
Boolean (default = false). If true, error backtraces do not list the
stack frames below the evalScript.
@item async
Boolean (default = false). If true, @code{await} is accepted in the
script and a promise is returned. The promise is resolved with an
object whose @code{value} property holds the value returned by the
script.
@end table
@item loadScript(filename)
Evaluate the file @code{filename} as a script (global eval).
@item loadFile(filename)
Load the file @code{filename} and return it as a string assuming UTF-8
encoding. Return @code{null} in case of I/O error.
@item open(filename, flags, errorObj = undefined)
Open a file (wrapper to the libc @code{fopen()}). Return the FILE
object or @code{null} in case of I/O error. If @code{errorObj} is not
undefined, set its @code{errno} property to the error code or to 0 if
no error occured.
@item popen(command, flags, errorObj = undefined)
Open a process by creating a pipe (wrapper to the libc
@code{popen()}). Return the FILE
object or @code{null} in case of I/O error. If @code{errorObj} is not
undefined, set its @code{errno} property to the error code or to 0 if
no error occured.
@item fdopen(fd, flags, errorObj = undefined)
Open a file from a file handle (wrapper to the libc
@code{fdopen()}). Return the FILE
object or @code{null} in case of I/O error. If @code{errorObj} is not
undefined, set its @code{errno} property to the error code or to 0 if
no error occured.
@item tmpfile(errorObj = undefined)
Open a temporary file. Return the FILE
object or @code{null} in case of I/O error. If @code{errorObj} is not
undefined, set its @code{errno} property to the error code or to 0 if
no error occured.
@item puts(str)
Equivalent to @code{std.out.puts(str)}.
@item printf(fmt, ...args)
Equivalent to @code{std.out.printf(fmt, ...args)}.
@item sprintf(fmt, ...args)
Equivalent to the libc sprintf().
@item in
@item out
@item err
Wrappers to the libc file @code{stdin}, @code{stdout}, @code{stderr}.
@item SEEK_SET
@item SEEK_CUR
@item SEEK_END
Constants for seek().
@item Error
Enumeration object containing the integer value of common errors
(additional error codes may be defined):
@table @code
@item EINVAL
@item EIO
@item EACCES
@item EEXIST
@item ENOSPC
@item ENOSYS
@item EBUSY
@item ENOENT
@item EPERM
@item EPIPE
@end table
@item strerror(errno)
Return a string that describes the error @code{errno}.
@item gc()
Manually invoke the cycle removal algorithm. The cycle removal
algorithm is automatically started when needed, so this function is
useful in case of specific memory constraints or for testing.
@item getenv(name)
Return the value of the environment variable @code{name} or
@code{undefined} if it is not defined.
@item setenv(name, value)
Set the value of the environment variable @code{name} to the string
@code{value}.
@item unsetenv(name)
Delete the environment variable @code{name}.
@item getenviron()
Return an object containing the environment variables as key-value pairs.
@item urlGet(url, options = undefined)
Download @code{url} using the @file{curl} command line
utility. @code{options} is an optional object containing the following
optional properties:
@table @code
@item binary
Boolean (default = false). If true, the response is an ArrayBuffer
instead of a string. When a string is returned, the data is assumed
to be UTF-8 encoded.
@item full
Boolean (default = false). If true, return the an object contains
the properties @code{response} (response content),
@code{responseHeaders} (headers separated by CRLF), @code{status}
(status code). @code{response} is @code{null} is case of protocol or
network error. If @code{full} is false, only the response is
returned if the status is between 200 and 299. Otherwise @code{null}
is returned.
@end table
@item parseExtJSON(str)
Parse @code{str} using a superset of @code{JSON.parse}. The superset
is very close to the JSON5 specification. The following extensions
are accepted:
@itemize
@item Single line and multiline comments
@item unquoted properties (ASCII-only Javascript identifiers)
@item trailing comma in array and object definitions
@item single quoted strings
@item @code{\v} escape and multi-line strings with trailing @code{\}
@item @code{\f} and @code{\v} are accepted as space characters
@item leading plus or decimal point in numbers
@item hexadecimal (@code{0x} prefix), octal (@code{0o} prefix) and binary (@code{0b} prefix) integers
@item @code{NaN} and @code{Infinity} are accepted as numbers
@end itemize
@end table
FILE prototype:
@table @code
@item close()
Close the file. Return 0 if OK or @code{-errno} in case of I/O error.
@item puts(str)
Outputs the string with the UTF-8 encoding.
@item printf(fmt, ...args)
Formatted printf.
The same formats as the standard C library @code{printf} are
supported. Integer format types (e.g. @code{%d}) truncate the Numbers
or BigInts to 32 bits. Use the @code{l} modifier (e.g. @code{%ld}) to
truncate to 64 bits.
@item flush()
Flush the buffered file.
@item seek(offset, whence)
Seek to a give file position (whence is
@code{std.SEEK_*}). @code{offset} can be a number or a bigint. Return
0 if OK or @code{-errno} in case of I/O error.
@item tell()
Return the current file position.
@item tello()
Return the current file position as a bigint.
@item eof()
Return true if end of file.
@item fileno()
Return the associated OS handle.
@item error()
Return true if there was an error.
@item clearerr()
Clear the error indication.
@item read(buffer, position, length)
Read @code{length} bytes from the file to the ArrayBuffer @code{buffer} at byte
position @code{position} (wrapper to the libc @code{fread}).
@item write(buffer, position, length)
Write @code{length} bytes to the file from the ArrayBuffer @code{buffer} at byte
position @code{position} (wrapper to the libc @code{fwrite}).
@item getline()
Return the next line from the file, assuming UTF-8 encoding, excluding
the trailing line feed.
@item readAsString(max_size = undefined)
Read @code{max_size} bytes from the file and return them as a string
assuming UTF-8 encoding. If @code{max_size} is not present, the file
is read up its end.
@item getByte()
Return the next byte from the file. Return -1 if the end of file is reached.
@item putByte(c)
Write one byte to the file.
@end table
@subsection @code{os} module
The @code{os} module provides Operating System specific functions:
@itemize
@item low level file access
@item signals
@item timers
@item asynchronous I/O
@item workers (threads)
@end itemize
The OS functions usually return 0 if OK or an OS specific negative
error code.
Available exports:
@table @code
@item open(filename, flags, mode = 0o666)
Open a file. Return a handle or < 0 if error.
@item O_RDONLY
@item O_WRONLY
@item O_RDWR
@item O_APPEND
@item O_CREAT
@item O_EXCL
@item O_TRUNC
POSIX open flags.
@item O_TEXT
(Windows specific). Open the file in text mode. The default is binary mode.
@item close(fd)
Close the file handle @code{fd}.
@item seek(fd, offset, whence)
Seek in the file. Use @code{std.SEEK_*} for
@code{whence}. @code{offset} is either a number or a bigint. If
@code{offset} is a bigint, a bigint is returned too.
@item read(fd, buffer, offset, length)
Read @code{length} bytes from the file handle @code{fd} to the
ArrayBuffer @code{buffer} at byte position @code{offset}.
Return the number of read bytes or < 0 if error.
@item write(fd, buffer, offset, length)
Write @code{length} bytes to the file handle @code{fd} from the
ArrayBuffer @code{buffer} at byte position @code{offset}.
Return the number of written bytes or < 0 if error.
@item isatty(fd)
Return @code{true} is @code{fd} is a TTY (terminal) handle.
@item ttyGetWinSize(fd)
Return the TTY size as @code{[width, height]} or @code{null} if not available.
@item ttySetRaw(fd)
Set the TTY in raw mode.
@item remove(filename)
Remove a file. Return 0 if OK or @code{-errno}.
@item rename(oldname, newname)
Rename a file. Return 0 if OK or @code{-errno}.
@item realpath(path)
Return @code{[str, err]} where @code{str} is the canonicalized absolute
pathname of @code{path} and @code{err} the error code.
@item getcwd()
Return @code{[str, err]} where @code{str} is the current working directory
and @code{err} the error code.
@item chdir(path)
Change the current directory. Return 0 if OK or @code{-errno}.
@item mkdir(path, mode = 0o777)
Create a directory at @code{path}. Return 0 if OK or @code{-errno}.
@item stat(path)
@item lstat(path)
Return @code{[obj, err]} where @code{obj} is an object containing the
file status of @code{path}. @code{err} is the error code. The
following fields are defined in @code{obj}: dev, ino, mode, nlink,
uid, gid, rdev, size, blocks, atime, mtime, ctime. The times are
specified in milliseconds since 1970. @code{lstat()} is the same as
@code{stat()} excepts that it returns information about the link
itself.
@item S_IFMT
@item S_IFIFO
@item S_IFCHR
@item S_IFDIR
@item S_IFBLK
@item S_IFREG
@item S_IFSOCK
@item S_IFLNK
@item S_ISGID
@item S_ISUID
Constants to interpret the @code{mode} property returned by
@code{stat()}. They have the same value as in the C system header
@file{sys/stat.h}.
@item utimes(path, atime, mtime)
Change the access and modification times of the file @code{path}. The
times are specified in milliseconds since 1970. Return 0 if OK or @code{-errno}.
@item symlink(target, linkpath)
Create a link at @code{linkpath} containing the string @code{target}. Return 0 if OK or @code{-errno}.
@item readlink(path)
Return @code{[str, err]} where @code{str} is the link target and @code{err}
the error code.
@item readdir(path)
Return @code{[array, err]} where @code{array} is an array of strings
containing the filenames of the directory @code{path}. @code{err} is
the error code.
@item setReadHandler(fd, func)
Add a read handler to the file handle @code{fd}. @code{func} is called
each time there is data pending for @code{fd}. A single read handler
per file handle is supported. Use @code{func = null} to remove the
handler.
@item setWriteHandler(fd, func)
Add a write handler to the file handle @code{fd}. @code{func} is
called each time data can be written to @code{fd}. A single write
handler per file handle is supported. Use @code{func = null} to remove
the handler.
@item signal(signal, func)
Call the function @code{func} when the signal @code{signal}
happens. Only a single handler per signal number is supported. Use
@code{null} to set the default handler or @code{undefined} to ignore
the signal. Signal handlers can only be defined in the main thread.
@item SIGINT
@item SIGABRT
@item SIGFPE
@item SIGILL
@item SIGSEGV
@item SIGTERM
POSIX signal numbers.
@item kill(pid, sig)
Send the signal @code{sig} to the process @code{pid}.
@item exec(args[, options])
Execute a process with the arguments @code{args}. @code{options} is an
object containing optional parameters:
@table @code
@item block
Boolean (default = true). If true, wait until the process is
terminated. In this case, @code{exec} return the exit code if positive
or the negated signal number if the process was interrupted by a
signal. If false, do not block and return the process id of the child.
@item usePath
Boolean (default = true). If true, the file is searched in the
@code{PATH} environment variable.
@item file
String (default = @code{args[0]}). Set the file to be executed.
@item cwd
String. If present, set the working directory of the new process.
@item stdin
@item stdout
@item stderr
If present, set the handle in the child for stdin, stdout or stderr.
@item env
Object. If present, set the process environment from the object
key-value pairs. Otherwise use the same environment as the current
process.
@item uid
Integer. If present, the process uid with @code{setuid}.
@item gid
Integer. If present, the process gid with @code{setgid}.
@end table
@item getpid()
Return the current process ID.
@item waitpid(pid, options)
@code{waitpid} Unix system call. Return the array @code{[ret,
status]}. @code{ret} contains @code{-errno} in case of error.
@item WNOHANG
Constant for the @code{options} argument of @code{waitpid}.
@item dup(fd)
@code{dup} Unix system call.
@item dup2(oldfd, newfd)
@code{dup2} Unix system call.
@item pipe()
@code{pipe} Unix system call. Return two handles as @code{[read_fd,
write_fd]} or null in case of error.
@item sleep(delay_ms)
Sleep during @code{delay_ms} milliseconds.
@item sleepAsync(delay_ms)
Asynchronouse sleep during @code{delay_ms} milliseconds. Returns a promise. Example:
@example
await os.sleepAsync(500);
@end example
@item now()
Return a timestamp in milliseconds with more precision than
@code{Date.now()}. The time origin is unspecified and is normally not
impacted by system clock adjustments.
@item setTimeout(func, delay)
Call the function @code{func} after @code{delay} ms. Return a handle
to the timer.
@item clearTimeout(handle)
Cancel a timer.
@item platform
Return a string representing the platform: @code{"linux"}, @code{"darwin"},
@code{"win32"} or @code{"js"}.
@item Worker(module_filename)
Constructor to create a new thread (worker) with an API close to the
@code{WebWorkers}. @code{module_filename} is a string specifying the
module filename which is executed in the newly created thread. As for
dynamically imported module, it is relative to the current script or
module path. Threads normally don't share any data and communicate
between each other with messages. Nested workers are not supported. An
example is available in @file{tests/test_worker.js}.
The worker class has the following static properties:
@table @code
@item parent
In the created worker, @code{Worker.parent} represents the parent
worker and is used to send or receive messages.
@end table
The worker instances have the following properties:
@table @code
@item postMessage(msg)
Send a message to the corresponding worker. @code{msg} is cloned in
the destination worker using an algorithm similar to the @code{HTML}
structured clone algorithm. @code{SharedArrayBuffer} are shared
between workers.
Current limitations: @code{Map} and @code{Set} are not supported
yet.
@item onmessage
Getter and setter. Set a function which is called each time a
message is received. The function is called with a single
argument. It is an object with a @code{data} property containing the
received message. The thread is not terminated if there is at least
one non @code{null} @code{onmessage} handler.
@end table
@end table
@section QuickJS C API
The C API was designed to be simple and efficient. The C API is
defined in the header @code{quickjs.h}.
@subsection Runtime and contexts
@code{JSRuntime} represents a Javascript runtime corresponding to an
object heap. Several runtimes can exist at the same time but they
cannot exchange objects. Inside a given runtime, no multi-threading is
supported.
@code{JSContext} represents a Javascript context (or Realm). Each
JSContext has its own global objects and system objects. There can be
several JSContexts per JSRuntime and they can share objects, similar
to frames of the same origin sharing Javascript objects in a
web browser.
@subsection JSValue
@code{JSValue} represents a Javascript value which can be a primitive
type or an object. Reference counting is used, so it is important to
explicitly duplicate (@code{JS_DupValue()}, increment the reference
count) or free (@code{JS_FreeValue()}, decrement the reference count)
JSValues.
@subsection C functions
C functions can be created with
@code{JS_NewCFunction()}. @code{JS_SetPropertyFunctionList()} is a
shortcut to easily add functions, setters and getters properties to a
given object.
Unlike other embedded Javascript engines, there is no implicit stack,
so C functions get their parameters as normal C parameters. As a
general rule, C functions take constant @code{JSValue}s as parameters
(so they don't need to free them) and return a newly allocated (=live)
@code{JSValue}.
@subsection Exceptions
Exceptions: most C functions can return a Javascript exception. It
must be explicitly tested and handled by the C code. The specific
@code{JSValue} @code{JS_EXCEPTION} indicates that an exception
occurred. The actual exception object is stored in the
@code{JSContext} and can be retrieved with @code{JS_GetException()}.
@subsection Script evaluation
Use @code{JS_Eval()} to evaluate a script or module source.
If the script or module was compiled to bytecode with @code{qjsc}, it
can be evaluated by calling @code{js_std_eval_binary()}. The advantage
is that no compilation is needed so it is faster and smaller because
the compiler can be removed from the executable if no @code{eval} is
required.
Note: the bytecode format is linked to a given QuickJS
version. Moreover, no security check is done before its
execution. Hence the bytecode should not be loaded from untrusted
sources. That's why there is no option to output the bytecode to a
binary file in @code{qjsc}.
@subsection JS Classes
C opaque data can be attached to a Javascript object. The type of the
C opaque data is determined with the class ID (@code{JSClassID}) of
the object. Hence the first step is to register a new class ID and JS
class (@code{JS_NewClassID()}, @code{JS_NewClass()}). Then you can
create objects of this class with @code{JS_NewObjectClass()} and get or
set the C opaque point with
@code{JS_GetOpaque()}/@code{JS_SetOpaque()}.
When defining a new JS class, it is possible to declare a finalizer
which is called when the object is destroyed. The finalizer should be
used to release C resources. It is invalid to execute JS code from
it. A @code{gc_mark} method can be provided so that the cycle removal
algorithm can find the other objects referenced by this object. Other
methods are available to define exotic object behaviors.
The Class ID are globally allocated (i.e. for all runtimes). The
JSClass are allocated per @code{JSRuntime}. @code{JS_SetClassProto()}
is used to define a prototype for a given class in a given
JSContext. @code{JS_NewObjectClass()} sets this prototype in the
created object.
Examples are available in @file{quickjs-libc.c}.
@subsection C Modules
Native ES6 modules are supported and can be dynamically or statically
linked. Look at the @file{test_bjson} and @file{bjson.so}
examples. The standard library @file{quickjs-libc.c} is also a good example
of a native module.
@subsection Memory handling
Use @code{JS_SetMemoryLimit()} to set a global memory allocation limit
to a given JSRuntime.
Custom memory allocation functions can be provided with
@code{JS_NewRuntime2()}.
The maximum system stack size can be set with @code{JS_SetMaxStackSize()}.
@subsection Execution timeout and interrupts
Use @code{JS_SetInterruptHandler()} to set a callback which is
regularly called by the engine when it is executing code. This
callback can be used to implement an execution timeout.
It is used by the command line interpreter to implement a
@code{Ctrl-C} handler.
@chapter Internals
@section Bytecode
The compiler generates bytecode directly with no intermediate
representation such as a parse tree, hence it is very fast. Several
optimizations passes are done over the generated bytecode.
A stack-based bytecode was chosen because it is simple and generates
compact code.
For each function, the maximum stack size is computed at compile time so that
no runtime stack overflow tests are needed.
A separate compressed line number table is maintained for the debug
information.
Access to closure variables is optimized and is almost as fast as local
variables.
Direct @code{eval} in strict mode is optimized.
@section Executable generation
@subsection @code{qjsc} compiler
The @code{qjsc} compiler generates C sources from Javascript files. By
default the C sources are compiled with the system compiler
(@code{gcc} or @code{clang}).
The generated C source contains the bytecode of the compiled functions
or modules. If a full complete executable is needed, it also
contains a @code{main()} function with the necessary C code to initialize the
Javascript engine and to load and execute the compiled functions and
modules.
Javascript code can be mixed with C modules.
In order to have smaller executables, specific Javascript features can
be disabled, in particular @code{eval} or the regular expressions. The
code removal relies on the Link Time Optimization of the system
compiler.
@subsection Binary JSON
@code{qjsc} works by compiling scripts or modules and then serializing
them to a binary format. A subset of this format (without functions or
modules) can be used as binary JSON. The example @file{test_bjson.js}
shows how to use it.
Warning: the binary JSON format may change without notice, so it
should not be used to store persistent data. The @file{test_bjson.js}
example is only used to test the binary object format functions.
@section Runtime
@subsection Strings
Strings are stored either as an 8 bit or a 16 bit array of
characters. Hence random access to characters is always fast.
The C API provides functions to convert Javascript Strings to C UTF-8 encoded
strings. The most common case where the Javascript string contains
only ASCII characters involves no copying.
@subsection Objects
The object shapes (object prototype, property names and flags) are shared
between objects to save memory.
Arrays with no holes (except at the end of the array) are optimized.
TypedArray accesses are optimized.
@subsection Atoms
Object property names and some strings are stored as Atoms (unique
strings) to save memory and allow fast comparison. Atoms are
represented as a 32 bit integer. Half of the atom range is reserved for
immediate integer literals from @math{0} to @math{2^{31}-1}.
@subsection Numbers
Numbers are represented either as 32-bit signed integers or 64-bit IEEE-754
floating point values. Most operations have fast paths for the 32-bit
integer case.
@subsection Garbage collection
Reference counting is used to free objects automatically and
deterministically. A separate cycle removal pass is done when the allocated
memory becomes too large. The cycle removal algorithm only uses the
reference counts and the object content, so no explicit garbage
collection roots need to be manipulated in the C code.
@subsection JSValue
It is a Javascript value which can be a primitive type (such as
Number, String, ...) or an Object. NaN boxing is used in the 32-bit version
to store 64-bit floating point numbers. The representation is
optimized so that 32-bit integers and reference counted values can be
efficiently tested.
In 64-bit code, JSValue are 128-bit large and no NaN boxing is used. The
rationale is that in 64-bit code memory usage is less critical.
In both cases (32 or 64 bits), JSValue exactly fits two CPU registers,
so it can be efficiently returned by C functions.
@subsection Function call
The engine is optimized so that function calls are fast. The system
stack holds the Javascript parameters and local variables.
@section RegExp
A specific regular expression engine was developed. It is both small
and efficient and supports all the ES2024 features including the
Unicode properties. As the Javascript compiler, it directly generates
bytecode without a parse tree.
Backtracking with an explicit stack is used so that there is no
recursion on the system stack. Simple quantifiers are specifically
optimized to avoid recursions.
The full regexp library weights about 15 KiB (x86 code), excluding the
Unicode library.
@section Unicode
A specific Unicode library was developed so that there is no
dependency on an external large Unicode library such as ICU. All the
Unicode tables are compressed while keeping a reasonable access
speed.
The library supports case conversion, Unicode normalization, Unicode
script queries, Unicode general category queries and all Unicode
binary properties.
The full Unicode library weights about 45 KiB (x86 code).
@section BigInt
BigInts are represented using binary two's complement notation. An
additional short bigint value is used to optimize the performance on
small BigInt values.
@chapter License
QuickJS is released under the MIT license.
Unless otherwise specified, the QuickJS sources are copyright Fabrice
Bellard and Charlie Gordon.
@bye
================================================
FILE: dtoa.c
================================================
/*
* Tiny float64 printing and parsing library
*
* Copyright (c) 2024 Fabrice Bellard
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include <inttypes.h>
#include <string.h>
#include <assert.h>
#include <ctype.h>
#include <sys/time.h>
#include <math.h>
#include <setjmp.h>
#include "cutils.h"
#include "dtoa.h"
/*
TODO:
- test n_digits=101 instead of 100
- simplify subnormal handling
- reduce max memory usage
- free format: could add shortcut if exact result
- use 64 bit limb_t when possible
- use another algorithm for free format dtoa in base 10 (ryu ?)
*/
#define USE_POW5_TABLE
/* use fast path to print small integers in free format */
#define USE_FAST_INT
#define LIMB_LOG2_BITS 5
#define LIMB_BITS (1 << LIMB_LOG2_BITS)
typedef int32_t slimb_t;
typedef uint32_t limb_t;
typedef uint64_t dlimb_t;
#define LIMB_DIGITS 9
#define JS_RADIX_MAX 36
#define DBIGNUM_LEN_MAX 52 /* ~ 2^(1072+53)*36^100 (dtoa) */
#define MANT_LEN_MAX 18 /* < 36^100 */
typedef intptr_t mp_size_t;
/* the represented number is sum(i, tab[i]*2^(LIMB_BITS * i)) */
typedef struct {
int len; /* >= 1 */
limb_t tab[];
} mpb_t;
static limb_t mp_add_ui(limb_t *tab, limb_t b, size_t n)
{
size_t i;
limb_t k, a;
k=b;
for(i=0;i<n;i++) {
if (k == 0)
break;
a = tab[i] + k;
k = (a < k);
tab[i] = a;
}
return k;
}
/* tabr[] = taba[] * b + l. Return the high carry */
static limb_t mp_mul1(limb_t *tabr, const limb_t *taba, limb_t n,
limb_t b, limb_t l)
{
limb_t i;
dlimb_t t;
for(i = 0; i < n; i++) {
t = (dlimb_t)taba[i] * (dlimb_t)b + l;
tabr[i] = t;
l = t >> LIMB_BITS;
}
return l;
}
/* WARNING: d must be >= 2^(LIMB_BITS-1) */
static inline limb_t udiv1norm_init(limb_t d)
{
limb_t a0, a1;
a1 = -d - 1;
a0 = -1;
return (((dlimb_t)a1 << LIMB_BITS) | a0) / d;
}
/* return the quotient and the remainder in '*pr'of 'a1*2^LIMB_BITS+a0
/ d' with 0 <= a1 < d. */
static inline limb_t udiv1norm(limb_t *pr, limb_t a1, limb_t a0,
limb_t d, limb_t d_inv)
{
limb_t n1m, n_adj, q, r, ah;
dlimb_t a;
n1m = ((slimb_t)a0 >> (LIMB_BITS - 1));
n_adj = a0 + (n1m & d);
a = (dlimb_t)d_inv * (a1 - n1m) + n_adj;
q = (a >> LIMB_BITS) + a1;
/* compute a - q * r and update q so that the remainder is between
0 and d - 1 */
a = ((dlimb_t)a1 << LIMB_BITS) | a0;
a = a - (dlimb_t)q * d - d;
ah = a >> LIMB_BITS;
q += 1 + ah;
r = (limb_t)a + (ah & d);
*pr = r;
return q;
}
static limb_t mp_div1(limb_t *tabr, const limb_t *taba, limb_t n,
limb_t b, limb_t r)
{
slimb_t i;
dlimb_t a1;
for(i = n - 1; i >= 0; i--) {
a1 = ((dlimb_t)r << LIMB_BITS) | taba[i];
tabr[i] = a1 / b;
r = a1 % b;
}
return r;
}
/* r = (a + high*B^n) >> shift. Return the remainder r (0 <= r < 2^shift).
1 <= shift <= LIMB_BITS - 1 */
static limb_t mp_shr(limb_t *tab_r, const limb_t *tab, mp_size_t n,
int shift, limb_t high)
{
mp_size_t i;
limb_t l, a;
assert(shift >= 1 && shift < LIMB_BITS);
l = high;
for(i = n - 1; i >= 0; i--) {
a = tab[i];
tab_r[i] = (a >> shift) | (l << (LIMB_BITS - shift));
l = a;
}
return l & (((limb_t)1 << shift) - 1);
}
/* r = (a << shift) + low. 1 <= shift <= LIMB_BITS - 1, 0 <= low <
2^shift. */
static limb_t mp_shl(limb_t *tab_r, const limb_t *tab, mp_size_t n,
int shift, limb_t low)
{
mp_size_t i;
limb_t l, a;
assert(shift >= 1 && shift < LIMB_BITS);
l = low;
for(i = 0; i < n; i++) {
a = tab[i];
tab_r[i] = (a << shift) | l;
l = (a >> (LIMB_BITS - shift));
}
return l;
}
static no_inline limb_t mp_div1norm(limb_t *tabr, const limb_t *taba, limb_t n,
limb_t b, limb_t r, limb_t b_inv, int shift)
{
slimb_t i;
if (shift != 0) {
r = (r << shift) | mp_shl(tabr, taba, n, shift, 0);
}
for(i = n - 1; i >= 0; i--) {
tabr[i] = udiv1norm(&r, r, taba[i], b, b_inv);
}
r >>= shift;
return r;
}
static __maybe_unused void mpb_dump(const char *str, const mpb_t *a)
{
int i;
printf("%s= 0x", str);
for(i = a->len - 1; i >= 0; i--) {
printf("%08x", a->tab[i]);
if (i != 0)
printf("_");
}
printf("\n");
}
static void mpb_renorm(mpb_t *r)
{
while (r->len > 1 && r->tab[r->len - 1] == 0)
r->len--;
}
#ifdef USE_POW5_TABLE
static const uint32_t pow5_table[17] = {
0x00000005, 0x00000019, 0x0000007d, 0x00000271,
0x00000c35, 0x00003d09, 0x0001312d, 0x0005f5e1,
0x001dcd65, 0x009502f9, 0x02e90edd, 0x0e8d4a51,
0x48c27395, 0x6bcc41e9, 0x1afd498d, 0x86f26fc1,
0xa2bc2ec5,
};
static const uint8_t pow5h_table[4] = {
0x00000001, 0x00000007, 0x00000023, 0x000000b1,
};
static const uint32_t pow5_inv_table[13] = {
0x99999999, 0x47ae147a, 0x0624dd2f, 0xa36e2eb1,
0x4f8b588e, 0x0c6f7a0b, 0xad7f29ab, 0x5798ee23,
0x12e0be82, 0xb7cdfd9d, 0x5fd7fe17, 0x19799812,
0xc25c2684,
};
#endif
/* return a^b */
static uint64_t pow_ui(uint32_t a, uint32_t b)
{
int i, n_bits;
uint64_t r;
if (b == 0)
return 1;
if (b == 1)
return a;
#ifdef USE_POW5_TABLE
if ((a == 5 || a == 10) && b <= 17) {
r = pow5_table[b - 1];
if (b >= 14) {
r |= (uint64_t)pow5h_table[b - 14] << 32;
}
if (a == 10)
r <<= b;
return r;
}
#endif
r = a;
n_bits = 32 - clz32(b);
for(i = n_bits - 2; i >= 0; i--) {
r *= r;
if ((b >> i) & 1)
r *= a;
}
return r;
}
static uint32_t pow_ui_inv(uint32_t *pr_inv, int *pshift, uint32_t a, uint32_t b)
{
uint32_t r_inv, r;
int shift;
#ifdef USE_POW5_TABLE
if (a == 5 && b >= 1 && b <= 13) {
r = pow5_table[b - 1];
shift = clz32(r);
r <<= shift;
r_inv = pow5_inv_table[b - 1];
} else
#endif
{
r = pow_ui(a, b);
shift = clz32(r);
r <<= shift;
r_inv = udiv1norm_init(r);
}
*pshift = shift;
*pr_inv = r_inv;
return r;
}
enum {
JS_RNDN, /* round to nearest, ties to even */
JS_RNDNA, /* round to nearest, ties away from zero */
JS_RNDZ,
};
static int mpb_get_bit(const mpb_t *r, int k)
{
int l;
l = (unsigned)k / LIMB_BITS;
k = k & (LIMB_BITS - 1);
if (l >= r->len)
return 0;
else
return (r->tab[l] >> k) & 1;
}
/* compute round(r / 2^shift). 'shift' can be negative */
static void mpb_shr_round(mpb_t *r, int shift, int rnd_mode)
{
int l, i;
if (shift == 0)
return;
if (shift < 0) {
shift = -shift;
l = (unsigned)shift / LIMB_BITS;
shift = shift & (LIMB_BITS - 1);
if (shift != 0) {
r->tab[r->len] = mp_shl(r->tab, r->tab, r->len, shift, 0);
r->len++;
mpb_renorm(r);
}
if (l > 0) {
for(i = r->len - 1; i >= 0; i--)
r->tab[i + l] = r->tab[i];
for(i = 0; i < l; i++)
r->tab[i] = 0;
r->len += l;
}
} else {
limb_t bit1, bit2;
int k, add_one;
switch(rnd_mode) {
default:
case JS_RNDZ:
add_one = 0;
break;
case JS_RNDN:
case JS_RNDNA:
bit1 = mpb_get_bit(r, shift - 1);
if (bit1) {
if (rnd_mode == JS_RNDNA) {
bit2 = 1;
} else {
/* bit2 = oring of all the bits after bit1 */
bit2 = 0;
if (shift >= 2) {
k = shift - 1;
l = (unsigned)k / LIMB_BITS;
k = k & (LIMB_BITS - 1);
for(i = 0; i < min_int(l, r->len); i++)
bit2 |= r->tab[i];
if (l < r->len)
bit2 |= r->tab[l] & (((limb_t)1 << k) - 1);
}
}
if (bit2) {
add_one = 1;
} else {
/* round to even */
add_one = mpb_get_bit(r, shift);
}
} else {
add_one = 0;
}
break;
}
l = (unsigned)shift / LIMB_BITS;
shift = shift & (LIMB_BITS - 1);
if (l >= r->len) {
r->len = 1;
r->tab[0] = add_one;
} else {
if (l > 0) {
r->len -= l;
for(i = 0; i < r->len; i++)
r->tab[i] = r->tab[i + l];
}
if (shift != 0) {
mp_shr(r->tab, r->tab, r->len, shift, 0);
mpb_renorm(r);
}
if (add_one) {
limb_t a;
a = mp_add_ui(r->tab, 1, r->len);
if (a)
r->tab[r->len++] = a;
}
}
}
}
/* return -1, 0 or 1 */
static int mpb_cmp(const mpb_t *a, const mpb_t *b)
{
mp_size_t i;
if (a->len < b->len)
return -1;
else if (a->len > b->len)
return 1;
for(i = a->len - 1; i >= 0; i--) {
if (a->tab[i] != b->tab[i]) {
if (a->tab[i] < b->tab[i])
return -1;
else
return 1;
}
}
return 0;
}
static void mpb_set_u64(mpb_t *r, uint64_t m)
{
#if LIMB_BITS == 64
r->tab[0] = m;
r->len = 1;
#else
r->tab[0] = m;
r->tab[1] = m >> LIMB_BITS;
if (r->tab[1] == 0)
r->len = 1;
else
r->len = 2;
#endif
}
static uint64_t mpb_get_u64(mpb_t *r)
{
#if LIMB_BITS == 64
return r->tab[0];
#else
if (r->len == 1) {
return r->tab[0];
} else {
return r->tab[0] | ((uint64_t)r->tab[1] << LIMB_BITS);
}
#endif
}
/* floor_log2() = position of the first non zero bit or -1 if zero. */
static int mpb_floor_log2(mpb_t *a)
{
limb_t v;
v = a->tab[a->len - 1];
if (v == 0)
return -1;
else
return a->len * LIMB_BITS - 1 - clz32(v);
}
#define MUL_LOG2_RADIX_BASE_LOG2 24
/* round((1 << MUL_LOG2_RADIX_BASE_LOG2)/log2(i + 2)) */
static const uint32_t mul_log2_radix_table[JS_RADIX_MAX - 1] = {
0x000000, 0xa1849d, 0x000000, 0x6e40d2,
0x6308c9, 0x5b3065, 0x000000, 0x50c24e,
0x4d104d, 0x4a0027, 0x4768ce, 0x452e54,
0x433d00, 0x418677, 0x000000, 0x3ea16b,
0x3d645a, 0x3c43c2, 0x3b3b9a, 0x3a4899,
0x39680b, 0x3897b3, 0x37d5af, 0x372069,
0x367686, 0x35d6df, 0x354072, 0x34b261,
0x342bea, 0x33ac62, 0x000000, 0x32bfd9,
0x3251dd, 0x31e8d6, 0x318465,
};
/* return floor(a / log2(radix)) for -2048 <= a <= 2047 */
static int mul_log2_radix(int a, int radix)
{
int radix_bits, mult;
if ((radix & (radix - 1)) == 0) {
/* if the radix is a power of two better to do it exactly */
radix_bits = 31 - clz32(radix);
if (a < 0)
a -= radix_bits - 1;
return a / radix_bits;
} else {
mult = mul_log2_radix_table[radix - 2];
return ((int64_t)a * mult) >> MUL_LOG2_RADIX_BASE_LOG2;
}
}
#if 0
static void build_mul_log2_radix_table(void)
{
int base, radix, mult, col, base_log2;
base_log2 = 24;
base = 1 << base_log2;
col = 0;
for(radix = 2; radix <= 36; radix++) {
if ((radix & (radix - 1)) == 0)
mult = 0;
else
mult = lrint((double)base / log2(radix));
printf("0x%06x, ", mult);
if (++col == 4) {
printf("\n");
col = 0;
}
}
printf("\n");
}
static void mul_log2_radix_test(void)
{
int radix, i, ref, r;
for(radix = 2; radix <= 36; radix++) {
for(i = -2048; i <= 2047; i++) {
ref = (int)floor((double)i / log2(radix));
r = mul_log2_radix(i, radix);
if (ref != r) {
printf("ERROR: radix=%d i=%d r=%d ref=%d\n",
radix, i, r, ref);
exit(1);
}
}
}
if (0)
build_mul_log2_radix_table();
}
#endif
static void u32toa_len(char *buf, uint32_t n, size_t len)
{
int digit, i;
for(i = len - 1; i >= 0; i--) {
digit = n % 10;
n = n / 10;
buf[i] = digit + '0';
}
}
/* for power of 2 radixes. len >= 1 */
static void u64toa_bin_len(char *buf, uint64_t n, unsigned int radix_bits, int len)
{
int digit, i;
unsigned int mask;
mask = (1 << radix_bits) - 1;
for(i = len - 1; i >= 0; i--) {
digit = n & mask;
n >>= radix_bits;
if (digit < 10)
digit += '0';
else
digit += 'a' - 10;
buf[i] = digit;
}
}
/* len >= 1. 2 <= radix <= 36 */
static void limb_to_a(char *buf, limb_t n, unsigned int radix, int len)
{
int digit, i;
if (radix == 10) {
/* specific case with constant divisor */
#if LIMB_BITS == 32
u32toa_len(buf, n, len);
#else
/* XXX: optimize */
for(i = len - 1; i >= 0; i--) {
digit = (limb_t)n % 10;
n = (limb_t)n / 10;
buf[i] = digit + '0';
}
#endif
} else {
for(i = len - 1; i >= 0; i--) {
digit = (limb_t)n % radix;
n = (limb_t)n / radix;
if (digit < 10)
digit += '0';
else
digit += 'a' - 10;
buf[i] = digit;
}
}
}
size_t u32toa(char *buf, uint32_t n)
{
char buf1[10], *q;
size_t len;
q = buf1 + sizeof(buf1);
do {
*--q = n % 10 + '0';
n /= 10;
} while (n != 0);
len = buf1 + sizeof(buf1) - q;
memcpy(buf, q, len);
return len;
}
size_t i32toa(char *buf, int32_t n)
{
if (n >= 0) {
return u32toa(buf, n);
} else {
buf[0] = '-';
return u32toa(buf + 1, -(uint32_t)n) + 1;
}
}
#ifdef USE_FAST_INT
size_t u64toa(char *buf, uint64_t n)
{
if (n < 0x100000000) {
return u32toa(buf, n);
} else {
uint64_t n1;
char *q = buf;
uint32_t n2;
n1 = n / 1000000000;
n %= 1000000000;
if (n1 >= 0x100000000) {
n2 = n1 / 1000000000;
n1 = n1 % 1000000000;
/* at most two digits */
if (n2 >= 10) {
*q++ = n2 / 10 + '0';
n2 %= 10;
}
*q++ = n2 + '0';
u32toa_len(q, n1, 9);
q += 9;
} else {
q += u32toa(q, n1);
}
u32toa_len(q, n, 9);
q += 9;
return q - buf;
}
}
size_t i64toa(char *buf, int64_t n)
{
if (n >= 0) {
return u64toa(buf, n);
} else {
buf[0] = '-';
return u64toa(buf + 1, -(uint64_t)n) + 1;
}
}
/* XXX: only tested for 1 <= n < 2^53 */
size_t u64toa_radix(char *buf, uint64_t n, unsigned int radix)
{
int radix_bits, l;
if (likely(radix == 10))
return u64toa(buf, n);
if ((radix & (radix - 1)) == 0) {
radix_bits = 31 - clz32(radix);
if (n == 0)
l = 1;
else
l = (64 - clz64(n) + radix_bits - 1) / radix_bits;
u64toa_bin_len(buf, n, radix_bits, l);
return l;
} else {
char buf1[41], *q; /* maximum length for radix = 3 */
size_t len;
int digit;
q = buf1 + sizeof(buf1);
do {
digit = n % radix;
n /= radix;
if (digit < 10)
digit += '0';
else
digit += 'a' - 10;
*--q = digit;
} while (n != 0);
len = buf1 + sizeof(buf1) - q;
memcpy(buf, q, len);
return len;
}
}
size_t i64toa_radix(char *buf, int64_t n, unsigned int radix)
{
if (n >= 0) {
return u64toa_radix(buf, n, radix);
} else {
buf[0] = '-';
return u64toa_radix(buf + 1, -(uint64_t)n, radix) + 1;
}
}
#endif /* USE_FAST_INT */
static const uint8_t digits_per_limb_table[JS_RADIX_MAX - 1] = {
#if LIMB_BITS == 32
32,20,16,13,12,11,10,10, 9, 9, 8, 8, 8, 8, 8, 7, 7, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
#else
64,40,32,27,24,22,21,20,19,18,17,17,16,16,16,15,15,15,14,14,14,14,13,13,13,13,13,13,13,12,12,12,12,12,12,
#endif
};
static const uint32_t radix_base_table[JS_RADIX_MAX - 1] = {
0x00000000, 0xcfd41b91, 0x00000000, 0x48c27395,
0x81bf1000, 0x75db9c97, 0x40000000, 0xcfd41b91,
0x3b9aca00, 0x8c8b6d2b, 0x19a10000, 0x309f1021,
0x57f6c100, 0x98c29b81, 0x00000000, 0x18754571,
0x247dbc80, 0x3547667b, 0x4c4b4000, 0x6b5a6e1d,
0x94ace180, 0xcaf18367, 0x0b640000, 0x0e8d4a51,
0x1269ae40, 0x17179149, 0x1cb91000, 0x23744899,
0x2b73a840, 0x34e63b41, 0x40000000, 0x4cfa3cc1,
0x5c13d840, 0x6d91b519, 0x81bf1000,
};
/* XXX: remove the table ? */
static uint8_t dtoa_max_digits_table[JS_RADIX_MAX - 1] = {
54, 35, 28, 24, 22, 20, 19, 18, 17, 17, 16, 16, 15, 15, 15, 14, 14, 14, 14, 14, 13, 13, 13, 13, 13, 13, 13, 12, 12, 12, 12, 12, 12, 12, 12,
};
/* we limit the maximum number of significant digits for atod to about
128 bits of precision for non power of two bases. The only
requirement for Javascript is at least 20 digits in base 10. For
power of two bases, we do an exact rounding in all the cases. */
static uint8_t atod_max_digits_table[JS_RADIX_MAX - 1] = {
64, 80, 32, 55, 49, 45, 21, 40, 38, 37, 35, 34, 33, 32, 16, 31, 30, 30, 29, 29, 28, 28, 27, 27, 27, 26, 26, 26, 26, 25, 12, 25, 25, 24, 24,
};
/* if abs(d) >= B^max_exponent, it is an overflow */
static const int16_t max_exponent[JS_RADIX_MAX - 1] = {
1024, 647, 512, 442, 397, 365, 342, 324,
309, 297, 286, 277, 269, 263, 256, 251,
246, 242, 237, 234, 230, 227, 224, 221,
218, 216, 214, 211, 209, 207, 205, 203,
202, 200, 199,
};
/* if abs(d) <= B^min_exponent, it is an underflow */
static const int16_t min_exponent[JS_RADIX_MAX - 1] = {
-1075, -679, -538, -463, -416, -383, -359, -340,
-324, -311, -300, -291, -283, -276, -269, -263,
-258, -254, -249, -245, -242, -238, -235, -232,
-229, -227, -224, -222, -220, -217, -215, -214,
-212, -210, -208,
};
#if 0
void build_tables(void)
{
int r, j, radix, n, col, i;
/* radix_base_table */
for(radix = 2; radix <= 36; radix++) {
r = 1;
for(j = 0; j < digits_per_limb_table[radix - 2]; j++) {
r *= radix;
}
printf(" 0x%08x,", r);
if ((radix % 4) == 1)
printf("\n");
}
printf("\n");
/* dtoa_max_digits_table */
for(radix = 2; radix <= 36; radix++) {
/* Note: over estimated when the radix is a power of two */
printf(" %d,", 1 + (int)ceil(53.0 / log2(radix)));
}
printf("\n");
/* atod_max_digits_table */
for(radix = 2; radix <= 36; radix++) {
if ((radix & (radix - 1)) == 0) {
/* 64 bits is more than enough */
n = (int)floor(64.0 / log2(radix));
} else {
n = (int)floor(128.0 / log2(radix));
}
printf(" %d,", n);
}
printf("\n");
printf("static const int16_t max_exponent[JS_RADIX_MAX - 1] = {\n");
col = 0;
for(radix = 2; radix <= 36; radix++) {
printf("%5d, ", (int)ceil(1024 / log2(radix)));
if (++col == 8) {
col = 0;
printf("\n");
}
}
printf("\n};\n\n");
printf("static const int16_t min_exponent[JS_RADIX_MAX - 1] = {\n");
col = 0;
for(radix = 2; radix <= 36; radix++) {
printf("%5d, ", (int)floor(-1075 / log2(radix)));
if (++col == 8) {
col = 0;
printf("\n");
}
}
printf("\n};\n\n");
printf("static const uint32_t pow5_table[16] = {\n");
col = 0;
for(i = 2; i <= 17; i++) {
r = 1;
for(j = 0; j < i; j++) {
r *= 5;
}
printf("0x%08x, ", r);
if (++col == 4) {
col = 0;
printf("\n");
}
}
printf("\n};\n\n");
/* high part */
printf("static const uint8_t pow5h_table[4] = {\n");
col = 0;
for(i = 14; i <= 17; i++) {
uint64_t r1;
r1 = 1;
for(j = 0; j < i; j++) {
r1 *= 5;
}
printf("0x%08x, ", (uint32_t)(r1 >> 32));
if (++col == 4) {
col = 0;
printf("\n");
}
}
printf("\n};\n\n");
}
#endif
/* n_digits >= 1. 0 <= dot_pos <= n_digits. If dot_pos == n_digits,
the dot is not displayed. 'a' is modified. */
static int output_digits(char *buf,
mpb_t *a, int radix, int n_digits1,
int dot_pos)
{
int n_digits, digits_per_limb, radix_bits, n, len;
n_digits = n_digits1;
if ((radix & (radix - 1)) == 0) {
/* radix = 2^radix_bits */
radix_bits = 31 - clz32(radix);
} else {
radix_bits = 0;
}
digits_per_limb = digits_per_limb_table[radix - 2];
if (radix_bits != 0) {
for(;;) {
n = min_int(n_digits, digits_per_limb);
n_digits -= n;
u64toa_bin_len(buf + n_digits, a->tab[0], radix_bits, n);
if (n_digits == 0)
break;
mpb_shr_round(a, digits_per_limb * radix_bits, JS_RNDZ);
}
} else {
limb_t r;
while (n_digits != 0) {
n = min_int(n_digits, digits_per_limb);
n_digits -= n;
r = mp_div1(a->tab, a->tab, a->len, radix_base_table[radix - 2], 0);
mpb_renorm(a);
limb_to_a(buf + n_digits, r, radix, n);
}
}
/* add the dot */
len = n_digits1;
if (dot_pos != n_digits1) {
memmove(buf + dot_pos + 1, buf + dot_pos, n_digits1 - dot_pos);
buf[dot_pos] = '.';
len++;
}
return len;
}
/* return (a, e_offset) such that a = a * (radix1*2^radix_shift)^f *
2^-e_offset. 'f' can be negative. */
static int mul_pow(mpb_t *a, int radix1, int radix_shift, int f, BOOL is_int, int e)
{
int e_offset, d, n, n0;
e_offset = -f * radix_shift;
if (radix1 != 1) {
d = digits_per_limb_table[radix1 - 2];
if (f >= 0) {
limb_t h, b;
b = 0;
n0 = 0;
while (f != 0) {
n = min_int(f, d);
if (n != n0) {
b = pow_ui(radix1, n);
n0 = n;
}
h = mp_mul1(a->tab, a->tab, a->len, b, 0);
if (h != 0) {
a->tab[a->len++] = h;
}
f -= n;
}
} else {
int extra_bits, l, shift;
limb_t r, rem, b, b_inv;
f = -f;
l = (f + d - 1) / d; /* high bound for the number of limbs (XXX: make it better) */
e_offset += l * LIMB_BITS;
if (!is_int) {
/* at least 'e' bits are needed in the final result for rounding */
extra_bits = max_int(e - mpb_floor_log2(a), 0);
} else {
/* at least two extra bits are needed in the final result
for rounding */
extra_bits = max_int(2 + e - e_offset, 0);
}
e_offset += extra_bits;
mpb_shr_round(a, -(l * LIMB_BITS + extra_bits), JS_RNDZ);
b = 0;
b_inv = 0;
shift = 0;
n0 = 0;
rem = 0;
while (f != 0) {
n = min_int(f, d);
if (n != n0) {
b = pow_ui_inv(&b_inv, &shift, radix1, n);
n0 = n;
}
r = mp_div1norm(a->tab, a->tab, a->len, b, 0, b_inv, shift);
rem |= r;
mpb_renorm(a);
f -= n;
}
/* if the remainder is non zero, use it for rounding */
a->tab[0] |= (rem != 0);
}
}
return e_offset;
}
/* tmp1 = round(m*2^e*radix^f). 'tmp0' is a temporary storage */
static void mul_pow_round(mpb_t *tmp1, uint64_t m, int e, int radix1, int radix_shift, int f,
int rnd_mode)
{
int e_offset;
mpb_set_u64(tmp1, m);
e_offset = mul_pow(tmp1, radix1, radix_shift, f, TRUE, e);
mpb_shr_round(tmp1, -e + e_offset, rnd_mode);
}
/* return round(a*2^e_offset) rounded as a float64. 'a' is modified */
static uint64_t round_to_d(int *pe, mpb_t *a, int e_offset, int rnd_mode)
{
int e;
uint64_t m;
if (a->tab[0] == 0 && a->len == 1) {
/* zero result */
m = 0;
e = 0; /* don't care */
} else {
int prec, prec1, e_min;
e = mpb_floor_log2(a) + 1 - e_offset;
prec1 = 53;
e_min = -1021;
if (e < e_min) {
/* subnormal result or zero */
prec = prec1 - (e_min - e);
} else {
prec = prec1;
}
mpb_shr_round(a, e + e_offset - prec, rnd_mode);
m = mpb_get_u64(a);
m <<= (53 - prec);
/* mantissa overflow due to rounding */
if (m >= (uint64_t)1 << 53) {
m >>= 1;
e++;
}
}
*pe = e;
return m;
}
/* return (m, e) such that m*2^(e-53) = round(a * radix^f) with 2^52
<= m < 2^53 or m = 0.
'a' is modified. */
static uint64_t mul_pow_round_to_d(int *pe, mpb_t *a,
int radix1, int radix_shift, int f, int rnd_mode)
{
int e_offset;
e_offset = mul_pow(a, radix1, radix_shift, f, FALSE, 55);
return round_to_d(pe, a, e_offset, rnd_mode);
}
#ifdef JS_DTOA_DUMP_STATS
static int out_len_count[17];
void js_dtoa_dump_stats(void)
{
int i, sum;
sum = 0;
for(i = 0; i < 17; i++)
sum += out_len_count[i];
for(i = 0; i < 17; i++) {
printf("%2d %8d %5.2f%%\n",
i + 1, out_len_count[i], (double)out_len_count[i] / sum * 100);
}
}
#endif
/* return a maximum bound of the string length. The bound depends on
'd' only if format = JS_DTOA_FORMAT_FRAC or if JS_DTOA_EXP_DISABLED
is enabled. */
int js_dtoa_max_len(double d, int radix, int n_digits, int flags)
{
int fmt = flags & JS_DTOA_FORMAT_MASK;
int n, e;
uint64_t a;
if (fmt != JS_DTOA_FORMAT_FRAC) {
if (fmt == JS_DTOA_FORMAT_FREE) {
n = dtoa_max_digits_table[radix - 2];
} else {
n = n_digits;
}
if ((flags & JS_DTOA_EXP_MASK) == JS_DTOA_EXP_DISABLED) {
/* no exponential */
a = float64_as_uint64(d);
e = (a >> 52) & 0x7ff;
if (e == 0x7ff) {
/* NaN, Infinity */
n = 0;
} else {
e -= 1023;
/* XXX: adjust */
n += 10 + abs(mul_log2_radix(e - 1, radix));
}
} else {
/* extra: sign, 1 dot and exponent "e-1000" */
n += 1 + 1 + 6;
}
} else {
a = float64_as_uint64(d);
e = (a >> 52) & 0x7ff;
if (e == 0x7ff) {
/* NaN, Infinity */
n = 0;
} else {
/* high bound for the integer part */
e -= 1023;
/* x < 2^(e + 1) */
if (e < 0) {
n = 1;
} else {
n = 2 + mul_log2_radix(e - 1, radix);
}
/* sign, extra digit, 1 dot */
n += 1 + 1 + 1 + n_digits;
}
}
return max_int(n, 9); /* also include NaN and [-]Infinity */
}
#if defined(__SANITIZE_ADDRESS__) && 0
static void *dtoa_malloc(uint64_t **pptr, size_t size)
{
return malloc(size);
}
static void dtoa_free(void *ptr)
{
free(ptr);
}
#else
static void *dtoa_malloc(uint64_t **pptr, size_t size)
{
void *ret;
ret = *pptr;
*pptr += (size + 7) / 8;
return ret;
}
static void dtoa_free(void *ptr)
{
}
#endif
/* return the length */
int js_dtoa(char *buf, double d, int radix, int n_digits, int flags,
JSDTOATempMem *tmp_mem)
{
uint64_t a, m, *mptr = tmp_mem->mem;
int e, sgn, l, E, P, i, E_max, radix1, radix_shift;
char *q;
mpb_t *tmp1, *mant_max;
int fmt = flags & JS_DTOA_FORMAT_MASK;
tmp1 = dtoa_malloc(&mptr, sizeof(mpb_t) + sizeof(limb_t) * DBIGNUM_LEN_MAX);
mant_max = dtoa_malloc(&mptr, sizeof(mpb_t) + sizeof(limb_t) * MANT_LEN_MAX);
assert((mptr - tmp_mem->mem) <= sizeof(JSDTOATempMem) / sizeof(mptr[0]));
radix_shift = ctz32(radix);
radix1 = radix >> radix_shift;
a = float64_as_uint64(d);
sgn = a >> 63;
e = (a >> 52) & 0x7ff;
m = a & (((uint64_t)1 << 52) - 1);
q = buf;
if (e == 0x7ff) {
if (m == 0) {
if (sgn)
*q++ = '-';
memcpy(q, "Infinity", 8);
q += 8;
} else {
memcpy(q, "NaN", 3);
q += 3;
}
goto done;
} else if (e == 0) {
if (m == 0) {
tmp1->len = 1;
tmp1->tab[0] = 0;
E = 1;
if (fmt == JS_DTOA_FORMAT_FREE)
P = 1;
else if (fmt == JS_DTOA_FORMAT_FRAC)
P = n_digits + 1;
else
P = n_digits;
/* "-0" is displayed as "0" if JS_DTOA_MINUS_ZERO is not present */
if (sgn && (flags & JS_DTOA_MINUS_ZERO))
*q++ = '-';
goto output;
}
/* denormal number: convert to a normal number */
l = clz64(m) - 11;
e -= l - 1;
m <<= l;
} else {
m |= (uint64_t)1 << 52;
}
if (sgn)
*q++ = '-';
/* remove the bias */
e -= 1022;
/* d = 2^(e-53)*m */
// printf("m=0x%016" PRIx64 " e=%d\n", m, e);
#ifdef USE_FAST_INT
if (fmt == JS_DTOA_FORMAT_FREE &&
e >= 1 && e <= 53 &&
(m & (((uint64_t)1 << (53 - e)) - 1)) == 0 &&
(flags & JS_DTOA_EXP_MASK) != JS_DTOA_EXP_ENABLED) {
m >>= 53 - e;
/* 'm' is never zero */
q += u64toa_radix(q, m, radix);
goto done;
}
#endif
/* this choice of E implies F=round(x*B^(P-E) is such as:
B^(P-1) <= F < 2.B^P. */
E = 1 + mul_log2_radix(e - 1, radix);
if (fmt == JS_DTOA_FORMAT_FREE) {
int P_max, E0, e1, E_found, P_found;
uint64_t m1, mant_found, mant, mant_max1;
/* P_max is guarranteed to work by construction */
P_max = dtoa_max_digits_table[radix - 2];
E0 = E;
E_found = 0;
P_found = 0;
mant_found = 0;
/* find the minimum number of digits by successive tries */
P = P_max; /* P_max is guarateed to work */
for(;;) {
/* mant_max always fits on 64 bits */
mant_max1 = pow_ui(radix, P);
/* compute the mantissa in base B */
E = E0;
for(;;) {
/* XXX: add inexact flag */
mul_pow_round(tmp1, m, e - 53, radix1, radix_shift, P - E, JS_RNDN);
mant = mpb_get_u64(tmp1);
if (mant < mant_max1)
break;
E++; /* at most one iteration is possible */
}
/* remove useless trailing zero digits */
while ((mant % radix) == 0) {
mant /= radix;
P--;
}
/* garanteed to work for P = P_max */
if (P_found == 0)
goto prec_found;
/* convert back to base 2 */
mpb_set_u64(tmp1, mant);
m1 = mul_pow_round_to_d(&e1, tmp1, radix1, radix_shift, E - P, JS_RNDN);
// printf("P=%2d: m=0x%016" PRIx64 " e=%d m1=0x%016" PRIx64 " e1=%d\n", P, m, e, m1, e1);
/* Note: (m, e) is never zero here, so the exponent for m1
= 0 does not matter */
if (m1 == m && e1 == e) {
prec_found:
P_found = P;
E_found = E;
mant_found = mant;
if (P == 1)
break;
P--; /* try lower exponent */
} else {
break;
}
}
P = P_found;
E = E_found;
mpb_set_u64(tmp1, mant_found);
#ifdef JS_DTOA_DUMP_STATS
if (radix == 10) {
out_len_count[P - 1]++;
}
#endif
} else if (fmt == JS_DTOA_FORMAT_FRAC) {
int len;
assert(n_digits >= 0 && n_digits <= JS_DTOA_MAX_DIGITS);
/* P = max_int(E, 1) + n_digits; */
/* frac is rounded using RNDNA */
mul_pow_round(tmp1, m, e - 53, radix1, radix_shift, n_digits, JS_RNDNA);
/* we add one extra digit on the left and remove it if needed
to avoid testing if the result is < radix^P */
len = output_digits(q, tmp1, radix, max_int(E + 1, 1) + n_digits,
max_int(E + 1, 1));
if (q[0] == '0' && len >= 2 && q[1] != '.') {
len--;
memmove(q, q + 1, len);
}
q += len;
goto done;
} else {
int pow_shift;
assert(n_digits >= 1 && n_digits <= JS_DTOA_MAX_DIGITS);
P = n_digits;
/* mant_max = radix^P */
mant_max->len = 1;
mant_max->tab[0] = 1;
pow_shift = mul_pow(mant_max, radix1, radix_shift, P, FALSE, 0);
mpb_shr_round(mant_max, pow_shift, JS_RNDZ);
for(;;) {
/* fixed and frac are rounded using RNDNA */
mul_pow_round(tmp1, m, e - 53, radix1, radix_shift, P - E, JS_RNDNA);
if (mpb_cmp(tmp1, mant_max) < 0)
break;
E++; /* at most one iteration is possible */
}
}
output:
if (fmt == JS_DTOA_FORMAT_FIXED)
E_max = n_digits;
else
E_max = dtoa_max_digits_table[radix - 2] + 4;
if ((flags & JS_DTOA_EXP_MASK) == JS_DTOA_EXP_ENABLED ||
((flags & JS_DTOA_EXP_MASK) == JS_DTOA_EXP_AUTO && (E <= -6 || E > E_max))) {
q += output_digits(q, tmp1, radix, P, 1);
E--;
if (radix == 10) {
*q++ = 'e';
} else if (radix1 == 1 && radix_shift <= 4) {
E *= radix_shift;
*q++ = 'p';
} else {
*q++ = '@';
}
if (E < 0) {
*q++ = '-';
E = -E;
} else {
*q++ = '+';
}
q += u32toa(q, E);
} else if (E <= 0) {
*q++ = '0';
*q++ = '.';
for(i = 0; i < -E; i++)
*q++ = '0';
q += output_digits(q, tmp1, radix, P, P);
} else {
q += output_digits(q, tmp1, radix, P, min_int(P, E));
for(i = 0; i < E - P; i++)
*q++ = '0';
}
done:
*q = '\0';
dtoa_free(mant_max);
dtoa_free(tmp1);
return q - buf;
}
static inline int to_digit(int c)
{
if (c >= '0' && c <= '9')
return c - '0';
else if (c >= 'A' && c <= 'Z')
return c - 'A' + 10;
else if (c >= 'a' && c <= 'z')
return c - 'a' + 10;
else
return 36;
}
/* r = r * radix_base + a. radix_base = 0 means radix_base = 2^32 */
static void mpb_mul1_base(mpb_t *r, limb_t radix_base, limb_t a)
{
int i;
if (r->tab[0] == 0 && r->len == 1) {
r->tab[0] = a;
} else {
if (radix_base == 0) {
for(i = r->len; i >= 0; i--) {
r->tab[i + 1] = r->tab[i];
}
r->tab[0] = a;
} else {
r->tab[r->len] = mp_mul1(r->tab, r->tab, r->len,
radix_base, a);
}
r->len++;
mpb_renorm(r);
}
}
/* XXX: add fast path for small integers */
double js_atod(const char *str, const char **pnext, int radix, int flags,
JSATODTempMem *tmp_mem)
{
uint64_t *mptr = tmp_mem->mem;
const char *p, *p_start;
limb_t cur_limb, radix_base, extra_digits;
int is_neg, digit_count, limb_digit_count, digits_per_limb, sep, radix1, radix_shift;
int radix_bits, expn, e, max_digits, expn_offset, dot_pos, sig_pos, pos;
mpb_t *tmp0;
double dval;
BOOL is_bin_exp, is_zero, expn_overflow;
uint64_t m, a;
tmp0 = dtoa_malloc(&mptr, sizeof(mpb_t) + sizeof(limb_t) * DBIGNUM_LEN_MAX);
assert((mptr - tmp_mem->mem) <= sizeof(JSATODTempMem) / sizeof(mptr[0]));
/* optional separator between digits */
sep = (flags & JS_ATOD_ACCEPT_UNDERSCORES) ? '_' : 256;
p = str;
is_neg = 0;
if (p[0] == '+') {
p++;
p_start = p;
} else if (p[0] == '-') {
is_neg = 1;
p++;
p_start = p;
} else {
p_start = p;
}
if (p[0] == '0') {
if ((p[1] == 'x' || p[1] == 'X') &&
(radix == 0 || radix == 16)) {
p += 2;
radix = 16;
} else if ((p[1] == 'o' || p[1] == 'O') &&
radix == 0 && (flags & JS_ATOD_ACCEPT_BIN_OCT)) {
p += 2;
radix = 8;
} else if ((p[1] == 'b' || p[1] == 'B') &&
radix == 0 && (flags & JS_ATOD_ACCEPT_BIN_OCT)) {
p += 2;
radix = 2;
} else if ((p[1] >= '0' && p[1] <= '9') &&
radix == 0 && (flags & JS_ATOD_ACCEPT_LEGACY_OCTAL)) {
int i;
sep = 256;
for (i = 1; (p[i] >= '0' && p[i] <= '7'); i++)
continue;
if (p[i] == '8' || p[i] == '9')
goto no_prefix;
p += 1;
radix = 8;
} else {
goto no_prefix;
}
/* there must be a digit after the prefix */
if (to_digit((uint8_t)*p) >= radix)
goto fail;
no_prefix: ;
} else {
if (!(flags & JS_ATOD_INT_ONLY) && strstart(p, "Infinity", &p))
goto overflow;
}
if (radix == 0)
radix = 10;
cur_limb = 0;
expn_offset = 0;
digit_count = 0;
limb_digit_count = 0;
max_digits = atod_max_digits_table[radix - 2];
digits_per_limb = digits_per_limb_table[radix - 2];
radix_base = radix_base_table[radix - 2];
radix_shift = ctz32(radix);
radix1 = radix >> radix_shift;
if (radix1 == 1) {
/* radix = 2^radix_bits */
radix_bits = radix_shift;
} else {
radix_bits = 0;
}
tmp0->len = 1;
tmp0->tab[0] = 0;
extra_digits = 0;
pos = 0;
dot_pos = -1;
/* skip leading zeros */
for(;;) {
if (*p == '.' && (p > p_start || to_digit(p[1]) < radix) &&
!(flags & JS_ATOD_INT_ONLY)) {
if (*p == sep)
goto fail;
if (dot_pos >= 0)
break;
dot_pos = pos;
p++;
}
if (*p == sep && p > p_start && p[1] == '0')
p++;
if (*p != '0')
break;
p++;
pos++;
}
sig_pos = pos;
for(;;) {
limb_t c;
if (*p == '.' && (p > p_start || to_digit(p[1]) < radix) &&
!(flags & JS_ATOD_INT_ONLY)) {
if (*p == sep)
goto fail;
if (dot_pos >= 0)
break;
dot_pos = pos;
p++;
}
if (*p == sep && p > p_start && to_digit(p[1]) < radix)
p++;
c = to_digit(*p);
if (c >= radix)
break;
p++;
pos++;
if (digit_count < max_digits) {
/* XXX: could be faster when radix_bits != 0 */
cur_limb = cur_limb * radix + c;
limb_digit_count++;
if (limb_digit_count == digits_per_limb) {
mpb_mul1_base(tmp0, radix_base, cur_limb);
cur_limb = 0;
limb_digit_count = 0;
}
digit_count++;
} else {
extra_digits |= c;
}
}
if (limb_digit_count != 0) {
mpb_mul1_base(tmp0, pow_ui(radix, limb_digit_count), cur_limb);
}
if (digit_count == 0) {
is_zero = TRUE;
expn_offset = 0;
} else {
is_zero = FALSE;
if (dot_pos < 0)
dot_pos = pos;
expn_offset = sig_pos + digit_count - dot_pos;
}
/* Use the extra digits for rounding if the base is a power of
two. Otherwise they are just truncated. */
if (radix_bits != 0 && extra_digits != 0) {
tmp0->tab[0] |= 1;
}
/* parse the exponent, if any */
expn = 0;
expn_overflow = FALSE;
is_bin_exp = FALSE;
if (!(flags & JS_ATOD_INT_ONLY) &&
((radix == 10 && (*p == 'e' || *p == 'E')) ||
(radix != 10 && (*p == '@' ||
(radix_bits >= 1 && radix_bits <= 4 && (*p == 'p' || *p == 'P'))))) &&
p > p_start) {
BOOL exp_is_neg;
int c;
is_bin_exp = (*p == 'p' || *p == 'P');
p++;
exp_is_neg = 0;
if (*p == '+') {
p++;
} else if (*p == '-') {
exp_is_neg = 1;
p++;
}
c = to_digit(*p);
if (c >= 10)
goto fail; /* XXX: could stop before the exponent part */
expn = c;
p++;
for(;;) {
if (*p == sep && to_digit(p[1]) < 10)
p++;
c = to_digit(*p);
if (c >= 10)
break;
if (!expn_overflow) {
if (unlikely(expn > ((INT32_MAX - 2 - 9) / 10))) {
expn_overflow = TRUE;
} else {
expn = expn * 10 + c;
}
}
p++;
}
if (exp_is_neg)
expn = -expn;
/* if zero result, the exponent can be arbitrarily large */
if (!is_zero && expn_overflow) {
if (exp_is_neg)
a = 0;
else
a = (uint64_t)0x7ff << 52; /* infinity */
goto done;
}
}
if (p == p_start)
goto fail;
if (is_zero) {
a = 0;
} else {
int expn1;
if (radix_bits != 0) {
if (!is_bin_exp)
expn *= radix_bits;
expn -= expn_offset * radix_bits;
expn1 = expn + digit_count * radix_bits;
if (expn1 >= 1024 + radix_bits)
goto overflow;
else if (expn1 <= -1075)
goto underflow;
m = round_to_d(&e, tmp0, -expn, JS_RNDN);
} else {
expn -= expn_offset;
expn1 = expn + digit_count;
if (expn1 >= max_exponent[radix - 2] + 1)
goto overflow;
else if (expn1 <= min_exponent[radix - 2])
goto underflow;
m = mul_pow_round_to_d(&e, tmp0, radix1, radix_shift, expn, JS_RNDN);
}
if (m == 0) {
underflow:
a = 0;
} else if (e > 1024) {
overflow:
/* overflow */
a = (uint64_t)0x7ff << 52;
} else if (e < -1073) {
/* underflow */
/* XXX: check rounding */
a = 0;
} else if (e < -1021) {
/* subnormal */
a = m >> (-e - 1021);
} else {
a = ((uint64_t)(e + 1022) << 52) | (m & (((uint64_t)1 << 52) - 1));
}
}
done:
a |= (uint64_t)is_neg << 63;
dval = uint64_as_float64(a);
done1:
if (pnext)
*pnext = p;
dtoa_free(tmp0);
return dval;
fail:
dval = NAN;
goto done1;
}
================================================
FILE: dtoa.h
================================================
/*
* Tiny float64 printing and parsing library
*
* Copyright (c) 2024 Fabrice Bellard
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
//#define JS_DTOA_DUMP_STATS
/* maximum number of digits for fixed and frac formats */
#define JS_DTOA_MAX_DIGITS 101
/* radix != 10 is only supported with flags = JS_DTOA_FORMAT_FREE */
/* use as many digits as necessary */
#define JS_DTOA_FORMAT_FREE (0 << 0)
/* use n_digits significant digits (1 <= n_digits <= JS_DTOA_MAX_DIGITS) */
#define JS_DTOA_FORMAT_FIXED (1 << 0)
/* force fractional format: [-]dd.dd with n_digits fractional digits.
0 <= n_digits <= JS_DTOA_MAX_DIGITS */
#define JS_DTOA_FORMAT_FRAC (2 << 0)
#define JS_DTOA_FORMAT_MASK (3 << 0)
/* select exponential notation either in fixed or free format */
#define JS_DTOA_EXP_AUTO (0 << 2)
#define JS_DTOA_EXP_ENABLED (1 << 2)
#define JS_DTOA_EXP_DISABLED (2 << 2)
#define JS_DTOA_EXP_MASK (3 << 2)
#define JS_DTOA_MINUS_ZERO (1 << 4) /* show the minus sign for -0 */
/* only accepts integers (no dot, no exponent) */
#define JS_ATOD_INT_ONLY (1 << 0)
/* accept Oo and Ob prefixes in addition to 0x prefix if radix = 0 */
#define JS_ATOD_ACCEPT_BIN_OCT (1 << 1)
/* accept O prefix as octal if radix == 0 and properly formed (Annex B) */
#define JS_ATOD_ACCEPT_LEGACY_OCTAL (1 << 2)
/* accept _ between digits as a digit separator */
#define JS_ATOD_ACCEPT_UNDERSCORES (1 << 3)
typedef struct {
uint64_t mem[37];
} JSDTOATempMem;
typedef struct {
uint64_t mem[27];
} JSATODTempMem;
/* return a maximum bound of the string length */
int js_dtoa_max_len(double d, int radix, int n_digits, int flags);
/* return the string length */
int js_dtoa(char *buf, double d, int radix, int n_digits, int flags,
JSDTOATempMem *tmp_mem);
double js_atod(const char *str, const char **pnext, int radix, int flags,
JSATODTempMem *tmp_mem);
#ifdef JS_DTOA_DUMP_STATS
void js_dtoa_dump_stats(void);
#endif
/* additional exported functions */
size_t u32toa(char *buf, uint32_t n);
size_t i32toa(char *buf, int32_t n);
size_t u64toa(char *buf, uint64_t n);
size_t i64toa(char *buf, int64_t n);
size_t u64toa_radix(char *buf, uint64_t n, unsigned int radix);
size_t i64toa_radix(char *buf, int64_t n, unsigned int radix);
================================================
FILE: examples/fib.c
================================================
/*
* QuickJS: Example of C module
*
* Copyright (c) 2017-2018 Fabrice Bellard
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include "../quickjs.h"
#define countof(x) (sizeof(x) / sizeof((x)[0]))
static int fib(int n)
{
if (n <= 0)
return 0;
else if (n == 1)
return 1;
else
return fib(n - 1) + fib(n - 2);
}
static JSValue js_fib(JSContext *ctx, JSValueConst this_val,
int argc, JSValueConst *argv)
{
int n, res;
if (JS_ToInt32(ctx, &n, argv[0]))
return JS_EXCEPTION;
res = fib(n);
return JS_NewInt32(ctx, res);
}
static const JSCFunctionListEntry js_fib_funcs[] = {
JS_CFUNC_DEF("fib", 1, js_fib ),
};
static int js_fib_init(JSContext *ctx, JSModuleDef *m)
{
return JS_SetModuleExportList(ctx, m, js_fib_funcs,
countof(js_fib_funcs));
}
#ifdef JS_SHARED_LIBRARY
#define JS_INIT_MODULE js_init_module
#else
#define JS_INIT_MODULE js_init_module_fib
#endif
JSModuleDef *JS_INIT_MODULE(JSContext *ctx, const char *module_name)
{
JSModuleDef *m;
m = JS_NewCModule(ctx, module_name, js_fib_init);
if (!m)
return NULL;
JS_AddModuleExportList(ctx, m, js_fib_funcs, countof(js_fib_funcs));
return m;
}
================================================
FILE: examples/fib_module.js
================================================
/* fib module */
export function fib(n)
{
if (n <= 0)
return 0;
else if (n == 1)
return 1;
else
return fib(n - 1) + fib(n - 2);
}
================================================
FILE: examples/hello.js
================================================
console.log("Hello World");
================================================
FILE: examples/hello_module.js
================================================
/* example of JS and JSON modules */
import { fib } from "./fib_module.js";
import msg from "./message.json";
console.log("Hello World");
console.log("fib(10)=", fib(10));
console.log("msg=", msg);
================================================
FILE: examples/message.json
================================================
{ "x" : 1, "tab": [ 1, 2, 3 ] }
================================================
FILE: examples/pi_bigint.js
================================================
/*
* PI computation in Javascript using the BigInt type
*/
"use strict";
/* return floor(log2(a)) for a > 0 and 0 for a = 0 */
function floor_log2(a)
{
var k_max, a1, k, i;
k_max = 0n;
while ((a >> (2n ** k_max)) != 0n) {
k_max++;
}
k = 0n;
a1 = a;
for(i = k_max - 1n; i >= 0n; i--) {
a1 = a >> (2n ** i);
if (a1 != 0n) {
a = a1;
k |= (1n << i);
}
}
return k;
}
/* return ceil(log2(a)) for a > 0 */
function ceil_log2(a)
{
return floor_log2(a - 1n) + 1n;
}
/* return floor(sqrt(a)) (not efficient but simple) */
function int_sqrt(a)
{
var l, u, s;
if (a == 0n)
return a;
l = ceil_log2(a);
u = 1n << ((l + 1n) / 2n);
/* u >= floor(sqrt(a)) */
for(;;) {
s = u;
u = ((a / s) + s) / 2n;
if (u >= s)
break;
}
return s;
}
/* return pi * 2**prec */
function calc_pi(prec) {
const CHUD_A = 13591409n;
const CHUD_B = 545140134n;
const CHUD_C = 640320n;
const CHUD_C3 = 10939058860032000n; /* C^3/24 */
const CHUD_BITS_PER_TERM = 47.11041313821584202247; /* log2(C/12)*3 */
/* return [P, Q, G] */
function chud_bs(a, b, need_G) {
var c, P, Q, G, P1, Q1, G1, P2, Q2, G2;
if (a == (b - 1n)) {
G = (2n * b - 1n) * (6n * b - 1n) * (6n * b - 5n);
P = G * (CHUD_B * b + CHUD_A);
if (b & 1n)
P = -P;
Q = b * b * b * CHUD_C3;
} else {
c = (a + b) >> 1n;
[P1, Q1, G1] = chud_bs(a, c, true);
[P2, Q2, G2] = chud_bs(c, b, need_G);
P = P1 * Q2 + P2 * G1;
Q = Q1 * Q2;
if (need_G)
G = G1 * G2;
else
G = 0n;
}
return [P, Q, G];
}
var n, P, Q, G;
/* number of serie terms */
n = BigInt(Math.ceil(Number(prec) / CHUD_BITS_PER_TERM)) + 10n;
[P, Q, G] = chud_bs(0n, n, false);
Q = (CHUD_C / 12n) * (Q << prec) / (P + Q * CHUD_A);
G = int_sqrt(CHUD_C << (2n * prec));
return (Q * G) >> prec;
}
function main(args) {
var r, n_digits, n_bits, out;
if (args.length < 1) {
print("usage: pi n_digits");
return;
}
n_digits = args[0] | 0;
/* we add more bits to reduce the probability of bad rounding for
the last digits */
n_bits = BigInt(Math.ceil(n_digits * Math.log2(10))) + 32n;
r = calc_pi(n_bits);
r = ((10n ** BigInt(n_digits)) * r) >> n_bits;
out = r.toString();
print(out[0] + "." + out.slice(1));
}
var args;
if (typeof scriptArgs != "undefined") {
args = scriptArgs;
args.shift();
} else if (typeof arguments != "undefined") {
args = arguments;
} else {
/* default: 1000 digits */
args=[1000];
}
main(args);
================================================
FILE: examples/point.c
================================================
/*
* QuickJS: Example of C module with a class
*
* Copyright (c) 2019 Fabrice Bellard
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include "../quickjs.h"
#include <math.h>
#define countof(x) (sizeof(x) / sizeof((x)[0]))
/* Point Class */
typedef struct {
int x;
int y;
} JSPointData;
static JSClassID js_point_class_id;
static void js_point_finalizer(JSRuntime *rt, JSValue val)
{
JSPointData *s = JS_GetOpaque(val, js_point_class_id);
/* Note: 's' can be NULL in case JS_SetOpaque() was not called */
js_free_rt(rt, s);
}
static JSValue js_point_ctor(JSContext *ctx,
JSValueConst new_target,
int argc, JSValueConst *argv)
{
JSPointData *s;
JSValue obj = JS_UNDEFINED;
JSValue proto;
s = js_mallocz(ctx, sizeof(*s));
if (!s)
return JS_EXCEPTION;
if (JS_ToInt32(ctx, &s->x, argv[0]))
goto fail;
if (JS_ToInt32(ctx, &s->y, argv[1]))
goto fail;
/* using new_target to get the prototype is necessary when the
class is extended. */
proto = JS_GetPropertyStr(ctx, new_target, "prototype");
if (JS_IsException(proto))
goto fail;
obj = JS_NewObjectProtoClass(ctx, proto, js_point_class_id);
JS_FreeValue(ctx, proto);
if (JS_IsException(obj))
goto fail;
JS_SetOpaque(obj, s);
return obj;
fail:
js_free(ctx, s);
JS_FreeValue(ctx, obj);
return JS_EXCEPTION;
}
static JSValue js_point_get_xy(JSContext *ctx, JSValueConst this_val, int magic)
{
JSPointData *s = JS_GetOpaque2(ctx, this_val, js_point_class_id);
if (!s)
return JS_EXCEPTION;
if (magic == 0)
return JS_NewInt32(ctx, s->x);
else
return JS_NewInt32(ctx, s->y);
}
static JSValue js_point_set_xy(JSContext *ctx, JSValueConst this_val, JSValue val, int magic)
{
JSPointData *s = JS_GetOpaque2(ctx, this_val, js_point_class_id);
int v;
if (!s)
return JS_EXCEPTION;
if (JS_ToInt32(ctx, &v, val))
return JS_EXCEPTION;
if (magic == 0)
s->x = v;
else
s->y = v;
return JS_UNDEFINED;
}
static JSValue js_point_norm(JSContext *ctx, JSValueConst this_val,
int argc, JSValueConst *argv)
{
JSPointData *s = JS_GetOpaque2(ctx, this_val, js_point_class_id);
if (!s)
return JS_EXCEPTION;
return JS_NewFloat64(ctx, sqrt((double)s->x * s->x + (double)s->y * s->y));
}
static JSClassDef js_point_class = {
"Point",
.finalizer = js_point_finalizer,
};
static const JSCFunctionListEntry js_point_proto_funcs[] = {
JS_CGETSET_MAGIC_DEF("x", js_point_get_xy, js_point_set_xy, 0),
JS_CGETSET_MAGIC_DEF("y", js_point_get_xy, js_point_set_xy, 1),
JS_CFUNC_DEF("norm", 0, js_point_norm),
};
static int js_point_init(JSContext *ctx, JSModuleDef *m)
{
JSValue point_proto, point_class;
/* create the Point class */
JS_NewClassID(&js_point_class_id);
JS_NewClass(JS_GetRuntime(ctx), js_point_class_id, &js_point_class);
point_proto = JS_NewObject(ctx);
JS_SetPropertyFunctionList(ctx, point_proto, js_point_proto_funcs, countof(js_point_proto_funcs));
point_class = JS_NewCFunction2(ctx, js_point_ctor, "Point", 2, JS_CFUNC_constructor, 0);
/* set proto.constructor and ctor.prototype */
JS_SetConstructor(ctx, point_class, point_proto);
JS_SetClassProto(ctx, js_point_class_id, point_proto);
JS_SetModuleExport(ctx, m, "Point", point_class);
return 0;
}
JSModuleDef *js_init_module(JSContext *ctx, const char *module_name)
{
JSModuleDef *m;
m = JS_NewCModule(ctx, module_name, js_point_init);
if (!m)
return NULL;
JS_AddModuleExport(ctx, m, "Point");
return m;
}
================================================
FILE: examples/test_fib.js
================================================
/* example of JS module importing a C module */
import { fib } from "./fib.so";
console.log("Hello World");
console.log("fib(10)=", fib(10));
================================================
FILE: examples/test_point.js
================================================
/* example of JS module importing a C module */
import { Point } from "./point.so";
function assert(b, str)
{
if (b) {
return;
} else {
throw Error("assertion failed: " + str);
}
}
class ColorPoint extends Point {
constructor(x, y, color) {
super(x, y);
this.color = color;
}
get_color() {
return this.color;
}
};
function main()
{
var pt, pt2;
pt = new Point(2, 3);
assert(pt.x === 2);
assert(pt.y === 3);
pt.x = 4;
assert(pt.x === 4);
assert(pt.norm() == 5);
pt2 = new ColorPoint(2, 3, 0xffffff);
assert(pt2.x === 2);
assert(pt2.color === 0xffffff);
assert(pt2.get_color() === 0xffffff);
}
main();
================================================
FILE: fuzz/README
================================================
libFuzzer support for QuickJS
=============================
Build QuickJS with libFuzzer support as follows:
CONFIG_CLANG=y make libfuzzer
This can be extended with sanitizer support to improve efficacy:
CONFIG_CLANG=y CONFIG_ASAN=y make libfuzzer
Currently, there are three fuzzing targets defined: fuzz_eval, fuzz_compile and fuzz_regexp.
The above build command will produce an executable binary for each of them, which can be
simply executed as:
./fuzz_eval
or with an initial corpus:
./fuzz_compile corpus_dir/
or with a predefined dictionary to improve its efficacy:
./fuzz_eval -dict fuzz/fuzz.dict
or with arbitrary CLI arguments provided by libFuzzer (https://llvm.org/docs/LibFuzzer.html).
================================================
FILE: fuzz/fuzz.dict
================================================
"__loadScript"
"abs"
"acos"
"acosh"
"add"
"AggregateError"
"and"
"apply"
"Array"
"ArrayBuffer"
"asin"
"asinh"
"atan"
"atan2"
"atanh"
"Atomics"
"BigInt"
"BigInt64Array"
"BigUint64Array"
"Boolean"
"cbrt"
"ceil"
"chdir"
"clearTimeout"
"close"
"clz32"
"compareExchange"
"console"
"construct"
"cos"
"cosh"
"DataView"
"Date"
"decodeURI"
"decodeURIComponent"
"defineProperty"
"deleteProperty"
"dup"
"dup2"
"E"
"encodeURI"
"encodeURIComponent"
"err"
"Error"
"escape"
"eval"
"EvalError"
"evalScript"
"exchange"
"exec"
"exit"
"exp"
"expm1"
"fdopen"
"Float32Array"
"Float64Array"
"floor"
"fround"
"Function"
"gc"
"get"
"getcwd"
"getenv"
"getenviron"
"getOwnPropertyDescriptor"
"getpid"
"getPrototypeOf"
"globalThis"
"has"
"hypot"
"imul"
"in"
"Infinity"
"Int16Array"
"Int32Array"
"Int8Array"
"InternalError"
"isatty"
"isExtensible"
"isFinite"
"isLockFree"
"isNaN"
"iterateBuiltIns"
"JSON"
"kill"
"length"
"LN10"
"LN2"
"load"
"loadFile"
"loadScript"
"log"
"log10"
"LOG10E"
"log1p"
"log2"
"LOG2E"
"lstat"
"Map"
"Math"
"max"
"min"
"mkdir"
"NaN"
"notify"
"now"
"Number"
"O_APPEND"
"O_CREAT"
"O_EXCL"
"O_RDONLY"
"O_RDWR"
"O_TRUNC"
"O_WRONLY"
"Object"
"open"
"Operators"
"or"
"os"
"out"
"ownKeys"
"parse"
"parseExtJSON"
"parseFloat"
"parseInt"
"PI"
"pipe"
"platform"
"popen"
"pow"
"preventExtensions"
"print"
"printf"
"Promise"
"Proxy"
"puts"
"random"
"RangeError"
"read"
"readdir"
"readlink"
"realpath"
"ReferenceError"
"Reflect"
"RegExp"
"remove"
"rename"
"round"
"S_IFBLK"
"S_IFCHR"
"S_IFDIR"
"S_IFIFO"
"S_IFLNK"
"S_IFMT"
"S_IFREG"
"S_IFSOCK"
"S_ISGID"
"S_ISUID"
"scriptArgs"
"seek"
"SEEK_CUR"
"SEEK_END"
"SEEK_SET"
"set"
"Set"
"setenv"
"setPrototypeOf"
"setReadHandler"
"setTimeout"
"setWriteHandler"
"SharedArrayBuffer"
"SIGABRT"
"SIGALRM"
"SIGCHLD"
"SIGCONT"
"SIGFPE"
"SIGILL"
"SIGINT"
"sign"
"signal"
"SIGPIPE"
"SIGQUIT"
"SIGSEGV"
"SIGSTOP"
"SIGTERM"
"SIGTSTP"
"SIGTTIN"
"SIGTTOU"
"SIGUSR1"
"SIGUSR2"
"sin"
"sinh"
"sleep"
"sleepAsync"
"sprintf"
"sqrt"
"SQRT1_2"
"SQRT2"
"stat"
"std"
"store"
"strerror"
"String"
"stringify"
"sub"
"Symbol"
"symlink"
"SyntaxError"
"tan"
"tanh"
"tmpfile"
"trunc"
"ttyGetWinSize"
"ttySetRaw"
"TypeError"
"Uint16Array"
"Uint32Array"
"Uint8Array"
"Uint8ClampedArray"
"undefined"
"unescape"
"unsetenv"
"URIError"
"urlGet"
"utimes"
"wait"
"waitpid"
"WeakMap"
"WeakSet"
"WNOHANG"
"Worker"
"write"
"xor"
"v0"
"v1"
"v2"
"v3"
"v4"
"v5"
"v6"
"v7"
"v8"
"v9"
"v10"
"v11"
"v12"
"v13"
"v14"
"v15"
"v16"
"v17"
"v18"
"v19"
"v20"
================================================
FILE: fuzz/fuzz_common.c
================================================
/* Copyright 2020 Google Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#include <string.h>
#include "fuzz/fuzz_common.h"
// handle timeouts from infinite loops
static int interrupt_handler(JSRuntime *rt, void *opaque)
{
nbinterrupts++;
return (nbinterrupts > 100);
}
void reset_nbinterrupts() {
nbinterrupts = 0;
}
void test_one_input_init(JSRuntime *rt, JSContext *ctx) {
// 64 Mo
JS_SetMemoryLimit(rt, 0x4000000);
// 64 Kb
JS_SetMaxStackSize(rt, 0x10000);
JS_SetModuleLoaderFunc(rt, NULL, js_module_loader, NULL);
JS_SetInterruptHandler(JS_GetRuntime(ctx), interrupt_handler, NULL);
js_std_add_helpers(ctx, 0, NULL);
// Load os and std
js_std_init_handlers(rt);
js_init_module_std(ctx, "std");
js_init_module_os(ctx, "os");
const char *str = "import * as std from 'std';\n"
"import * as os from 'os';\n"
"globalThis.std = std;\n"
"globalThis.os = os;\n";
JSValue std_val = JS_Eval(ctx, str, strlen(str), "<input>", JS_EVAL_TYPE_MODULE | JS_EVAL_FLAG_COMPILE_ONLY);
if (!JS_IsException(std_val)) {
js_module_set_import_meta(ctx, std_val, 1, 1);
std_val = JS_EvalFunction(ctx, std_val);
} else {
js_std_dump_error(ctx);
}
std_val = js_std_await(ctx, std_val);
JS_FreeValue(ctx, std_val);
}
================================================
FILE: fuzz/fuzz_common.h
================================================
/* Copyright 2020 Google Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#include "quickjs.h"
#include "quickjs-libc.h"
static int nbinterrupts = 0;
void reset_nbinterrupts();
void test_one_input_init(JSRuntime *rt, JSContext *ctx);
================================================
FILE: fuzz/fuzz_compile.c
================================================
/* Copyright 2020 Google Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#include "quickjs.h"
#include "quickjs-libc.h"
#include "cutils.h"
#include "fuzz/fuzz_common.h"
#include <stdint.h>
#include <stdio.h>
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
if (size == 0)
return 0;
JSRuntime *rt = JS_NewRuntime();
JSContext *ctx = JS_NewContext(rt);
test_one_input_init(rt, ctx);
uint8_t *null_terminated_data = malloc(size + 1);
memcpy(null_terminated_data, data, size);
null_terminated_data[size] = 0;
JSValue obj = JS_Eval(ctx, (const char *)null_terminated_data, size, "<none>", JS_EVAL_FLAG_COMPILE_ONLY | JS_EVAL_TYPE_MODULE);
free(null_terminated_data);
//TODO target with JS_ParseJSON
if (JS_IsException(obj)) {
js_std_free_handlers(rt);
JS_FreeValue(ctx, obj);
JS_FreeContext(ctx);
JS_FreeRuntime(rt);
return 0;
}
obj = js_std_await(ctx, obj);
size_t bytecode_size;
uint8_t* bytecode = JS_WriteObject(ctx, &bytecode_size, obj, JS_WRITE_OBJ_BYTECODE);
JS_FreeValue(ctx, obj);
if (!bytecode) {
js_std_free_handlers(rt);
JS_FreeContext(ctx);
JS_FreeRuntime(rt);
return 0;
}
obj = JS_ReadObject(ctx, bytecode, bytecode_size, JS_READ_OBJ_BYTECODE);
js_free(ctx, bytecode);
if (JS_IsException(obj)) {
js_std_free_handlers(rt);
JS_FreeContext(ctx);
JS_FreeRuntime(rt);
return 0;
}
reset_nbinterrupts();
/* this is based on
* js_std_eval_binary(ctx, bytecode, bytecode_size, 0);
* modified so as not to exit on JS exception
*/
JSValue val;
if (JS_VALUE_GET_TAG(obj) == JS_TAG_MODULE) {
if (JS_ResolveModule(ctx, obj) < 0) {
JS_FreeValue(ctx, obj);
js_std_free_handlers(rt);
JS_FreeContext(ctx);
JS_FreeRuntime(rt);
return 0;
}
js_module_set_import_meta(ctx, obj, FALSE, TRUE);
}
val = JS_EvalFunction(ctx, obj);
if (JS_IsException(val)) {
js_std_dump_error(ctx);
} else {
js_std_loop(ctx);
}
JS_FreeValue(ctx, val);
js_std_free_handlers(rt);
JS_FreeContext(ctx);
JS_FreeRuntime(rt);
return 0;
}
================================================
FILE: fuzz/fuzz_eval.c
================================================
/* Copyright 2020 Google Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#include "quickjs.h"
#include "quickjs-libc.h"
#include "fuzz/fuzz_common.h"
#include <stdint.h>
#include <stdio.h>
#include <string.h>
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
if (size == 0)
return 0;
JSRuntime *rt = JS_NewRuntime();
JSContext *ctx = JS_NewContext(rt);
test_one_input_init(rt, ctx);
uint8_t *null_terminated_data = malloc(size + 1);
memcpy(null_terminated_data, data, size);
null_terminated_data[size] = 0;
reset_nbinterrupts();
//the final 0 does not count (as in strlen)
JSValue val = JS_Eval(ctx, (const char *)null_terminated_data, size, "<none>", JS_EVAL_TYPE_GLOBAL);
free(null_terminated_data);
//TODO targets with JS_ParseJSON, JS_ReadObject
if (!JS_IsException(val)) {
js_std_loop(ctx);
JS_FreeValue(ctx, val);
}
js_std_free_handlers(rt);
JS_FreeContext(ctx);
JS_FreeRuntime(rt);
return 0;
}
================================================
FILE: fuzz/fuzz_regexp.c
================================================
/* Copyright 2020 Google Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#include "libregexp.h"
#include "quickjs-libc.h"
static int nbinterrupts = 0;
int lre_check_stack_overflow(void *opaque, size_t alloca_size) { return 0; }
void *lre_realloc(void *opaque, void *ptr, size_t size)
{
return realloc(ptr, size);
}
int lre_check_timeout(void *opaque)
{
nbinterrupts++;
return (nbinterrupts > 100);
}
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
int len, ret, i;
uint8_t *bc;
char error_msg[64];
const uint8_t *input;
uint8_t *capture[255 * 2];
size_t size1 = size;
//Splits buffer into 2 sub buffers delimited by null character
for (i = 0; i < size; i++) {
if (data[i] == 0) {
size1 = i;
break;
}
}
if (size1 == size) {
//missing delimiter
return 0;
}
bc = lre_compile(&len, error_msg, sizeof(error_msg), (const char *) data,
size1, 0, NULL);
if (!bc) {
return 0;
}
input = data + size1 + 1;
ret = lre_exec(capture, bc, input, 0, size - (size1 + 1), 0, NULL);
if (ret == 1) {
lre_get_capture_count(bc);
}
free(bc);
return 0;
}
================================================
FILE: fuzz/generate_dict.js
================================================
// Function to recursively iterate through built-in names.
function collectBuiltinNames(obj, visited = new Set(), result = new Set()) {
// Check if the object has already been visited to avoid infinite recursion.
if (visited.has(obj))
return;
// Add the current object to the set of visited objects
visited.add(obj);
// Get the property names of the current object
const properties = Object.getOwnPropertyNames(obj);
// Iterate through each property
for (var i=0; i < properties.length; i++) {
var property = properties[i];
if (property != "collectBuiltinNames" && typeof property != "number")
result.add(property);
// Check if the property is an object and if so, recursively iterate through its properties.
if (typeof obj[property] === 'object' && obj[property] !== null)
collectBuiltinNames(obj[property], visited, result);
}
return result;
}
// Start the recursive iteration with the global object.
console.log(Array.from(collectBuiltinNames(this)).join('\n'));
================================================
FILE: libregexp-opcode.h
================================================
/*
* Regular Expression Engine
*
* Copyright (c) 2017-2018 Fabrice Bellard
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifdef DEF
DEF(invalid, 1) /* never used */
DEF(char, 3)
DEF(char_i, 3)
DEF(char32, 5)
DEF(char32_i, 5)
DEF(dot, 1)
DEF(any, 1) /* same as dot but match any character including line terminator */
DEF(space, 1)
DEF(not_space, 1) /* must come after */
DEF(line_start, 1)
DEF(line_start_m, 1)
DEF(line_end, 1)
DEF(line_end_m, 1)
DEF(goto, 5)
DEF(split_goto_first, 5)
DEF(split_next_first, 5)
DEF(match, 1)
DEF(lookahead_match, 1)
DEF(negative_lookahead_match, 1) /* must come after */
DEF(save_start, 2) /* save start position */
DEF(save_end, 2) /* save end position, must come after saved_start */
DEF(save_reset, 3) /* reset save positions */
DEF(loop, 6) /* decrement the top the stack and goto if != 0 */
DEF(loop_split_goto_first, 10) /* loop and then split */
DEF(loop_split_next_first, 10)
DEF(loop_check_adv_split_goto_first, 10) /* loop and then check advance and split */
DEF(loop_check_adv_split_next_first, 10)
DEF(set_i32, 6) /* store the immediate value to a register */
DEF(word_boundary, 1)
DEF(word_boundary_i, 1)
DEF(not_word_boundary, 1)
DEF(not_word_boundary_i, 1)
DEF(back_reference, 2) /* variable length */
DEF(back_reference_i, 2) /* must come after */
DEF(backward_back_reference, 2) /* must come after */
DEF(backward_back_reference_i, 2) /* must come after */
DEF(range, 3) /* variable length */
DEF(range_i, 3) /* variable length */
DEF(range32, 3) /* variable length */
DEF(range32_i, 3) /* variable length */
DEF(lookahead, 5)
DEF(negative_lookahead, 5) /* must come after */
DEF(set_char_pos, 2) /* store the character position to a register */
DEF(check_advance, 2) /* check that the register is different from the character position */
DEF(prev, 1) /* go to the previous char */
#endif /* DEF */
================================================
FILE: libregexp.c
================================================
/*
* Regular Expression Engine
*
* Copyright (c) 2017-2018 Fabrice Bellard
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include <inttypes.h>
#include <string.h>
#include <assert.h>
#include "cutils.h"
#include "libregexp.h"
#include "libunicode.h"
/*
TODO:
- remove REOP_char_i and REOP_range_i by precomputing the case folding.
- add specific opcodes for simple unicode property tests so that the
generated bytecode is smaller.
- Add a lock step execution mode (=linear time execution guaranteed)
when the regular expression is "simple" i.e. no backreference nor
complicated lookahead. The opcodes are designed for this execution
model.
*/
#if defined(TEST)
#define DUMP_REOP
#endif
//#define DUMP_REOP
//#define DUMP_EXEC
typedef enum {
#define DEF(id, size) REOP_ ## id,
#include "libregexp-opcode.h"
#undef DEF
REOP_COUNT,
} REOPCodeEnum;
#define CAPTURE_COUNT_MAX 255
#define REGISTER_COUNT_MAX 255
/* must be large enough to have a negligible runtime cost and small
enough to call the interrupt callback often. */
#define INTERRUPT_COUNTER_INIT 10000
/* unicode code points */
#define CP_LS 0x2028
#define CP_PS 0x2029
#define TMP_BUF_SIZE 128
typedef struct {
DynBuf byte_code;
const uint8_t *buf_ptr;
const uint8_t *buf_end;
const uint8_t *buf_start;
int re_flags;
BOOL is_unicode;
BOOL unicode_sets; /* if set, is_unicode is also set */
BOOL ignore_case;
BOOL multi_line;
BOOL dotall;
uint8_t group_name_scope;
int capture_count;
int total_capture_count; /* -1 = not computed yet */
int has_named_captures; /* -1 = don't know, 0 = no, 1 = yes */
void *opaque;
DynBuf group_names;
union {
char error_msg[TMP_BUF_SIZE];
char tmp_buf[TMP_BUF_SIZE];
} u;
} REParseState;
typedef struct {
#ifdef DUMP_REOP
const char *name;
#endif
uint8_t size;
} REOpCode;
static const REOpCode reopcode_info[REOP_COUNT] = {
#ifdef DUMP_REOP
#define DEF(id, size) { #id, size },
#else
#define DEF(id, size) { size },
#endif
#include "libregexp-opcode.h"
#undef DEF
};
#define RE_HEADER_FLAGS 0
#define RE_HEADER_CAPTURE_COUNT 2
#define RE_HEADER_REGISTER_COUNT 3
#define RE_HEADER_BYTECODE_LEN 4
#define RE_HEADER_LEN 8
static inline int is_digit(int c) {
return c >= '0' && c <= '9';
}
/* insert 'len' bytes at position 'pos'. Return < 0 if error. */
static int dbuf_insert(DynBuf *s, int pos, int len)
{
if (dbuf_claim(s, len))
return -1;
memmove(s->buf + pos + len, s->buf + pos, s->size - pos);
s->size += len;
return 0;
}
typedef struct REString {
struct REString *next;
uint32_t hash;
uint32_t len;
uint32_t buf[];
} REString;
typedef struct {
/* the string list is the union of 'char_range' and of the strings
in hash_table[]. The strings in hash_table[] have a length !=
1. */
CharRange cr;
uint32_t n_strings;
uint32_t hash_size;
int hash_bits;
REString **hash_table;
} REStringList;
static uint32_t re_string_hash(int len, const uint32_t *buf)
{
int i;
uint32_t h;
h = 1;
for(i = 0; i < len; i++)
h = h * 263 + buf[i];
return h * 0x61C88647;
}
static void re_string_list_init(REParseState *s1, REStringList *s)
{
cr_init(&s->cr, s1->opaque, lre_realloc);
s->n_strings = 0;
s->hash_size = 0;
s->hash_bits = 0;
s->hash_table = NULL;
}
static void re_string_list_free(REStringList *s)
{
REString *p, *p_next;
int i;
for(i = 0; i < s->hash_size; i++) {
for(p = s->hash_table[i]; p != NULL; p = p_next) {
p_next = p->next;
lre_realloc(s->cr.mem_opaque, p, 0);
}
}
lre_realloc(s->cr.mem_opaque, s->hash_table, 0);
cr_free(&s->cr);
}
static void lre_print_char(int c, BOOL is_range)
{
if (c == '\'' || c == '\\' ||
(is_range && (c == '-' || c == ']'))) {
printf("\\%c", c);
} else if (c >= ' ' && c <= 126) {
printf("%c", c);
} else {
printf("\\u{%04x}", c);
}
}
static __maybe_unused void re_string_list_dump(const char *str, const REStringList *s)
{
REString *p;
const CharRange *cr;
int i, j, k;
printf("%s:\n", str);
printf(" ranges: [");
cr = &s->cr;
for(i = 0; i < cr->len; i += 2) {
lre_print_char(cr->points[i], TRUE);
if (cr->points[i] != cr->points[i + 1] - 1) {
printf("-");
lre_print_char(cr->points[i + 1] - 1, TRUE);
}
}
printf("]\n");
j = 0;
for(i = 0; i < s->hash_size; i++) {
for(p = s->hash_table[i]; p != NULL; p = p->next) {
printf(" %d/%d: '", j, s->n_strings);
for(k = 0; k < p->len; k++) {
lre_print_char(p->buf[k], FALSE);
}
printf("'\n");
j++;
}
}
}
static int re_string_find2(REStringList *s, int len, const uint32_t *buf,
uint32_t h0, BOOL add_flag)
{
uint32_t h = 0; /* avoid warning */
REString *p;
if (s->n_strings != 0) {
h = h0 >> (32 - s->hash_bits);
for(p = s->hash_table[h]; p != NULL; p = p->next) {
if (p->hash == h0 && p->len == len &&
!memcmp(p->buf, buf, len * sizeof(buf[0]))) {
return 1;
}
}
}
/* not found */
if (!add_flag)
return 0;
/* increase the size of the hash table if needed */
if (unlikely((s->n_strings + 1) > s->hash_size)) {
REString **new_hash_table, *p_next;
int new_hash_bits, i;
uint32_t new_hash_size;
new_hash_bits = max_int(s->hash_bits + 1, 4);
new_hash_size = 1 << new_hash_bits;
new_hash_table = lre_realloc(s->cr.mem_opaque, NULL,
sizeof(new_hash_table[0]) * new_hash_size);
if (!new_hash_table)
return -1;
memset(new_hash_table, 0, sizeof(new_hash_table[0]) * new_hash_size);
for(i = 0; i < s->hash_size; i++) {
for(p = s->hash_table[i]; p != NULL; p = p_next) {
p_next = p->next;
h = p->hash >> (32 - new_hash_bits);
p->next = new_hash_table[h];
new_hash_table[h] = p;
}
}
lre_realloc(s->cr.mem_opaque, s->hash_table, 0);
s->hash_bits = new_hash_bits;
s->hash_size = new_hash_size;
s->hash_table = new_hash_table;
h = h0 >> (32 - s->hash_bits);
}
p = lre_realloc(s->cr.mem_opaque, NULL, sizeof(REString) + len * sizeof(buf[0]));
if (!p)
return -1;
p->next = s->hash_table[h];
s->hash_table[h] = p;
s->n_strings++;
p->hash = h0;
p->len = len;
memcpy(p->buf, buf, sizeof(buf[0]) * len);
return 1;
}
static int re_string_find(REStringList *s, int len, const uint32_t *buf,
BOOL add_flag)
{
uint32_t h0;
h0 = re_string_hash(len, buf);
return re_string_find2(s, len, buf, h0, add_flag);
}
/* return -1 if memory error, 0 if OK */
static int re_string_add(REStringList *s, int len, const uint32_t *buf)
{
if (len == 1) {
return cr_union_interval(&s->cr, buf[0], buf[0]);
}
if (re_string_find(s, len, buf, TRUE) < 0)
return -1;
return 0;
}
/* a = a op b */
static int re_string_list_op(REStringList *a, REStringList *b, int op)
{
int i, ret;
REString *p, **pp;
if (cr_op1(&a->cr, b->cr.points, b->cr.len, op))
return -1;
switch(op) {
case CR_OP_UNION:
if (b->n_strings != 0) {
for(i = 0; i < b->hash_size; i++) {
for(p = b->hash_table[i]; p != NULL; p = p->next) {
if (re_string_find2(a, p->len, p->buf, p->hash, TRUE) < 0)
return -1;
}
}
}
break;
case CR_OP_INTER:
case CR_OP_SUB:
for(i = 0; i < a->hash_size; i++) {
pp = &a->hash_table[i];
for(;;) {
p = *pp;
if (p == NULL)
break;
ret = re_string_find2(b, p->len, p->buf, p->hash, FALSE);
if (op == CR_OP_SUB)
ret = !ret;
if (!ret) {
/* remove it */
*pp = p->next;
a->n_strings--;
lre_realloc(a->cr.mem_opaque, p, 0);
} else {
/* keep it */
pp = &p->next;
}
}
}
break;
default:
abort();
}
return 0;
}
static int re_string_list_canonicalize(REParseState *s1,
REStringList *s, BOOL is_unicode)
{
if (cr_regexp_canonicalize(&s->cr, is_unicode))
return -1;
if (s->n_strings != 0) {
REStringList a_s, *a = &a_s;
int i, j;
REString *p;
/* XXX: simplify */
re_string_list_init(s1, a);
a->n_strings = s->n_strings;
a->hash_size = s->hash_size;
a->hash_bits = s->hash_bits;
a->hash_table = s->hash_table;
s->n_strings = 0;
s->hash_size = 0;
s->hash_bits = 0;
s->hash_table = NULL;
for(i = 0; i < a->hash_size; i++) {
for(p = a->hash_table[i]; p != NULL; p = p->next) {
for(j = 0; j < p->len; j++) {
p->buf[j] = lre_canonicalize(p->buf[j], is_unicode);
}
if (re_string_add(s, p->len, p->buf)) {
re_string_list_free(a);
return -1;
}
}
}
re_string_list_free(a);
}
return 0;
}
static const uint16_t char_range_d[] = {
1,
0x0030, 0x0039 + 1,
};
/* code point ranges for Zs,Zl or Zp property */
static const uint16_t char_range_s[] = {
10,
0x0009, 0x000D + 1,
0x0020, 0x0020 + 1,
0x00A0, 0x00A0 + 1,
0x1680, 0x1680 + 1,
0x2000, 0x200A + 1,
/* 2028;LINE SEPARATOR;Zl;0;WS;;;;;N;;;;; */
/* 2029;PARAGRAPH SEPARATOR;Zp;0;B;;;;;N;;;;; */
0x2028, 0x2029 + 1,
0x202F, 0x202F + 1,
0x205F, 0x205F + 1,
0x3000, 0x3000 + 1,
/* FEFF;ZERO WIDTH NO-BREAK SPACE;Cf;0;BN;;;;;N;BYTE ORDER MARK;;;; */
0xFEFF, 0xFEFF + 1,
};
static const uint16_t char_range_w[] = {
4,
0x0030, 0x0039 + 1,
0x0041, 0x005A + 1,
0x005F, 0x005F + 1,
0x0061, 0x007A + 1,
};
#define CLASS_RANGE_BASE 0x40000000
typedef enum {
CHAR_RANGE_d,
CHAR_RANGE_D,
CHAR_RANGE_s,
CHAR_RANGE_S,
CHAR_RANGE_w,
CHAR_RANGE_W,
} CharRangeEnum;
static const uint16_t * const char_range_table[] = {
char_range_d,
char_range_s,
char_range_w,
};
static int cr_init_char_range(REParseState *s, REStringList *cr, uint32_t c)
{
BOOL invert;
const uint16_t *c_pt;
int len, i;
invert = c & 1;
c_pt = char_range_table[c >> 1];
len = *c_pt++;
re_string_list_init(s, cr);
for(i = 0; i < len * 2; i++) {
if (cr_add_point(&cr->cr, c_pt[i]))
goto fail;
}
if (invert) {
if (cr_invert(&cr->cr))
goto fail;
}
return 0;
fail:
re_string_list_free(cr);
return -1;
}
#ifdef DUMP_REOP
static __maybe_unused void lre_dump_bytecode(const uint8_t *buf,
int buf_len)
{
int pos, len, opcode, bc_len, re_flags, i;
uint32_t val, val2;
assert(buf_len >= RE_HEADER_LEN);
re_flags = lre_get_flags(buf);
bc_len = get_u32(buf + RE_HEADER_BYTECODE_LEN);
assert(bc_len + RE_HEADER_LEN <= buf_len);
printf("flags: 0x%x capture_count=%d reg_count=%d\n",
re_flags, buf[RE_HEADER_CAPTURE_COUNT], buf[RE_HEADER_REGISTER_COUNT]);
if (re_flags & LRE_FLAG_NAMED_GROUPS) {
const char *p;
p = (char *)buf + RE_HEADER_LEN + bc_len;
printf("named groups: ");
for(i = 1; i < buf[RE_HEADER_CAPTURE_COUNT]; i++) {
if (i != 1)
printf(",");
printf("<%s>", p);
p += strlen(p) + LRE_GROUP_NAME_TRAILER_LEN;
}
printf("\n");
assert(p == (char *)(buf + buf_len));
}
printf("bytecode_len=%d\n", bc_len);
buf += RE_HEADER_LEN;
pos = 0;
while (pos < bc_len) {
printf("%5u: ", pos);
opcode = buf[pos];
len = reopcode_info[opcode].size;
if (opcode >= REOP_COUNT) {
printf(" invalid opcode=0x%02x\n", opcode);
break;
}
if ((pos + len) > bc_len) {
printf(" buffer overflow (opcode=0x%02x)\n", opcode);
break;
}
printf("%s", reopcode_info[opcode].name);
switch(opcode) {
case REOP_char:
case REOP_char_i:
val = get_u16(buf + pos + 1);
if (val >= ' ' && val <= 126)
printf(" '%c'", val);
else
printf(" 0x%04x", val);
break;
case REOP_char32:
case REOP_char32_i:
val = get_u32(buf + pos + 1);
if (val >= ' ' && val <= 126)
printf(" '%c'", val);
else
printf(" 0x%08x", val);
break;
case REOP_goto:
case REOP_split_goto_first:
case REOP_split_next_first:
case REOP_lookahead:
case REOP_negative_lookahead:
val = get_u32(buf + pos + 1);
val += (pos + 5);
printf(" %u", val);
break;
case REOP_loop:
val2 = buf[pos + 1];
val = get_u32(buf + pos + 2);
val += (pos + 6);
printf(" r%u, %u", val2, val);
break;
case REOP_loop_split_goto_first:
case REOP_loop_split_next_first:
case REOP_loop_check_adv_split_goto_first:
case REOP_loop_check_adv_split_next_first:
{
uint32_t limit;
val2 = buf[pos + 1];
limit = get_u32(buf + pos + 2);
val = get_u32(buf + pos + 6);
val += (pos + 10);
printf(" r%u, %u, %u", val2, limit, val);
}
break;
case REOP_save_start:
case REOP_save_end:
printf(" %u", buf[pos + 1]);
break;
case REOP_back_reference:
case REOP_back_reference_i:
case REOP_backward_back_reference:
case REOP_backward_back_reference_i:
{
int n, i;
n = buf[pos + 1];
len += n;
for(i = 0; i < n; i++) {
if (i != 0)
printf(",");
printf(" %u", buf[pos + 2 + i]);
}
}
break;
case REOP_save_reset:
printf(" %u %u", buf[pos + 1], buf[pos + 2]);
break;
case REOP_set_i32:
val = buf[pos + 1];
val2 = get_u32(buf + pos + 2);
printf(" r%u, %d", val, val2);
break;
case REOP_set_char_pos:
case REOP_check_advance:
val = buf[pos + 1];
printf(" r%u", val);
break;
case REOP_range:
case REOP_range_i:
{
int n, i;
n = get_u16(buf + pos + 1);
len += n * 4;
for(i = 0; i < n * 2; i++) {
val = get_u16(buf + pos + 3 + i * 2);
printf(" 0x%04x", val);
}
}
break;
case REOP_range32:
case REOP_range32_i:
{
int n, i;
n = get_u16(buf + pos + 1);
len += n * 8;
for(i = 0; i < n * 2; i++) {
val = get_u32(buf + pos + 3 + i * 4);
printf(" 0x%08x", val);
}
}
break;
default:
break;
}
printf("\n");
pos += len;
}
}
#endif
static void re_emit_op(REParseState *s, int op)
{
dbuf_putc(&s->byte_code, op);
}
/* return the offset of the u32 value */
static int re_emit_op_u32(REParseState *s, int op, uint32_t val)
{
int pos;
dbuf_putc(&s->byte_code, op);
pos = s->byte_code.size;
dbuf_put_u32(&s->byte_code, val);
return pos;
}
static int re_emit_goto(REParseState *s, int op, uint32_t val)
{
int pos;
dbuf_putc(&s->byte_code, op);
pos = s->byte_code.size;
dbuf_put_u32(&s->byte_code, val - (pos + 4));
return pos;
}
static int re_emit_goto_u8(REParseState *s, int op, uint32_t arg, uint32_t val)
{
int pos;
dbuf_putc(&s->byte_code, op);
dbuf_putc(&s->byte_code, arg);
pos = s->byte_code.size;
dbuf_put_u32(&s->byte_code, val - (pos + 4));
return pos;
}
static int re_emit_goto_u8_u32(REParseState *s, int op, uint32_t arg0, uint32_t arg1, uint32_t val)
{
int pos;
dbuf_putc(&s->byte_code, op);
dbuf_putc(&s->byte_code, arg0);
dbuf_put_u32(&s->byte_code, arg1);
pos = s->byte_code.size;
dbuf_put_u32(&s->byte_code, val - (pos + 4));
return pos;
}
static void re_emit_op_u8(REParseState *s, int op, uint32_t val)
{
dbuf_putc(&s->byte_code, op);
dbuf_putc(&s->byte_code, val);
}
static void re_emit_op_u16(REParseState *s, int op, uint32_t val)
{
dbuf_putc(&s->byte_code, op);
dbuf_put_u16(&s->byte_code, val);
}
static int __attribute__((format(printf, 2, 3))) re_parse_error(REParseState *s, const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
vsnprintf(s->u.error_msg, sizeof(s->u.error_msg), fmt, ap);
va_end(ap);
return -1;
}
static int re_parse_out_of_memory(REParseState *s)
{
return re_parse_error(s, "out of memory");
}
/* If allow_overflow is false, return -1 in case of
overflow. Otherwise return INT32_MAX. */
static int parse_digits(const uint8_t **pp, BOOL allow_overflow)
{
const uint8_t *p;
uint64_t v;
int c;
p = *pp;
v = 0;
for(;;) {
c = *p;
if (c < '0' || c > '9')
break;
v = v * 10 + c - '0';
if (v >= INT32_MAX) {
if (allow_overflow)
v = INT32_MAX;
else
return -1;
}
p++;
}
*pp = p;
return v;
}
static int re_parse_expect(REParseState *s, const uint8_t **pp, int c)
{
const uint8_t *p;
p = *pp;
if (*p != c)
return re_parse_error(s, "expecting '%c'", c);
p++;
*pp = p;
return 0;
}
/* Parse an escape sequence, *pp points after the '\':
allow_utf16 value:
0 : no UTF-16 escapes allowed
1 : UTF-16 escapes allowed
2 : UTF-16 escapes allowed and escapes of surrogate pairs are
converted to a unicode character (unicode regexp case).
Return the unicode char and update *pp if recognized,
return -1 if malformed escape,
return -2 otherwise. */
int lre_parse_escape(const uint8_t **pp, int allow_utf16)
{
const uint8_t *p;
uint32_t c;
p = *pp;
c = *p++;
switch(c) {
case 'b':
c = '\b';
break;
case 'f':
c = '\f';
break;
case 'n':
c = '\n';
break;
case 'r':
c = '\r';
break;
case 't':
c = '\t';
break;
case 'v':
c = '\v';
break;
case 'x':
{
int h0, h1;
h0 = from_hex(*p++);
if (h0 < 0)
return -1;
h1 = from_hex(*p++);
if (h1 < 0)
return -1;
c = (h0 << 4) | h1;
}
break;
case 'u':
{
int h, i;
uint32_t c1;
if (*p == '{' && allow_utf16) {
p++;
c = 0;
for(;;) {
h = from_hex(*p++);
if (h < 0)
return -1;
c = (c << 4) | h;
if (c > 0x10FFFF)
return -1;
if (*p == '}')
break;
}
p++;
} else {
c = 0;
for(i = 0; i < 4; i++) {
h = from_hex(*p++);
if (h < 0) {
return -1;
}
c = (c << 4) | h;
}
if (is_hi_surrogate(c) &&
allow_utf16 == 2 && p[0] == '\\' && p[1] == 'u') {
/* convert an escaped surrogate pair into a
unicode char */
c1 = 0;
for(i = 0; i < 4; i++) {
h = from_hex(p[2 + i]);
if (h < 0)
break;
c1 = (c1 << 4) | h;
}
if (i == 4 && is_lo_surrogate(c1)) {
p += 6;
c = from_surrogate(c, c1);
}
}
}
}
break;
case '0': case '1': case '2': case '3':
case '4': case '5': case '6': case '7':
c -= '0';
if (allow_utf16 == 2) {
/* only accept \0 not followed by digit */
if (c != 0 || is_digit(*p))
return -1;
} else {
/* parse a legacy octal sequence */
uint32_t v;
v = *p - '0';
if (v > 7)
break;
c = (c << 3) | v;
p++;
if (c >= 32)
break;
v = *p - '0';
if (v > 7)
break;
c = (c << 3) | v;
p++;
}
break;
default:
return -2;
}
*pp = p;
return c;
}
#ifdef CONFIG_ALL_UNICODE
/* XXX: we use the same chars for name and value */
static BOOL is_unicode_char(int c)
{
return ((c >= '0' && c <= '9') ||
(c >= 'A' && c <= 'Z') ||
(c >= 'a' && c <= 'z') ||
(c == '_'));
}
/* XXX: memory error test */
static void seq_prop_cb(void *opaque, const uint32_t *seq, int seq_len)
{
REStringList *sl = opaque;
re_string_add(sl, seq_len, seq);
}
static int parse_unicode_property(REParseState *s, REStringList *cr,
const uint8_t **pp, BOOL is_inv,
BOOL allow_sequence_prop)
{
const uint8_t *p;
char name[64], value[64];
char *q;
BOOL script_ext;
int ret;
p = *pp;
if (*p != '{')
return re_parse_error(s, "expecting '{' after \\p");
p++;
q = name;
while (is_unicode_char(*p)) {
if ((q - name) >= sizeof(name) - 1)
goto unknown_property_name;
*q++ = *p++;
}
*q = '\0';
q = value;
if (*p == '=') {
p++;
while (is_unicode_char(*p)) {
if ((q - value) >= sizeof(value) - 1)
return re_parse_error(s, "unknown unicode property value");
*q++ = *p++;
}
}
*q = '\0';
if (*p != '}')
return re_parse_error(s, "expecting '}'");
p++;
// printf("name=%s value=%s\n", name, value);
if (!strcmp(name, "Script") || !strcmp(name, "sc")) {
script_ext = FALSE;
goto do_script;
} else if (!strcmp(name, "Script_Extensions") || !strcmp(name, "scx")) {
script_ext = TRUE;
do_script:
re_string_list_init(s, cr);
ret = unicode_script(&cr->cr, value, script_ext);
if (ret) {
re_string_list_free(cr);
if (ret == -2)
return re_parse_error(s, "unknown unicode script");
else
goto out_of_memory;
}
} else if (!strcmp(name, "General_Category") || !strcmp(name, "gc")) {
re_string_list_init(s, cr);
ret = unicode_general_category(&cr->cr, value);
if (ret) {
re_string_list_free(cr);
if (ret == -2)
return re_parse_error(s, "unknown unicode general category");
else
goto out_of_memory;
}
} else i
gitextract_qmew98ht/ ├── .github/ │ └── workflows/ │ └── ci.yml ├── .gitignore ├── Changelog ├── LICENSE ├── Makefile ├── TODO ├── VERSION ├── compat/ │ └── test-closefrom.c ├── cutils.c ├── cutils.h ├── doc/ │ └── quickjs.texi ├── dtoa.c ├── dtoa.h ├── examples/ │ ├── fib.c │ ├── fib_module.js │ ├── hello.js │ ├── hello_module.js │ ├── message.json │ ├── pi_bigint.js │ ├── point.c │ ├── test_fib.js │ └── test_point.js ├── fuzz/ │ ├── README │ ├── fuzz.dict │ ├── fuzz_common.c │ ├── fuzz_common.h │ ├── fuzz_compile.c │ ├── fuzz_eval.c │ ├── fuzz_regexp.c │ └── generate_dict.js ├── libregexp-opcode.h ├── libregexp.c ├── libregexp.h ├── libunicode-table.h ├── libunicode.c ├── libunicode.h ├── list.h ├── qjs.c ├── qjsc.c ├── quickjs-atom.h ├── quickjs-libc.c ├── quickjs-libc.h ├── quickjs-opcode.h ├── quickjs.c ├── quickjs.h ├── readme-cosmo.txt ├── readme.txt ├── release.sh ├── repl.js ├── run-test262.c ├── test262.conf ├── test262o.conf ├── tests/ │ ├── assert.js │ ├── bjson.c │ ├── fixture_cyclic_import.js │ ├── microbench.js │ ├── test262.patch │ ├── test_bigint.js │ ├── test_bjson.js │ ├── test_builtin.js │ ├── test_closure.js │ ├── test_cyclic_import.js │ ├── test_language.js │ ├── test_loop.js │ ├── test_std.js │ ├── test_worker.js │ └── test_worker_module.js ├── unicode_download.sh ├── unicode_gen.c └── unicode_gen_def.h
Showing preview only (243K chars total). Download the full file or copy to clipboard to get everything.
SYMBOL INDEX (2593 symbols across 42 files)
FILE: compat/test-closefrom.c
function main (line 3) | int main(void) {
FILE: cutils.c
function pstrcpy (line 32) | void pstrcpy(char *buf, int buf_size, const char *str)
function strstart (line 59) | int strstart(const char *str, const char *val, const char **ptr)
function has_suffix (line 75) | int has_suffix(const char *str, const char *suffix)
function dbuf_init2 (line 89) | void dbuf_init2(DynBuf *s, void *opaque, DynBufReallocFunc *realloc_func)
function dbuf_init (line 98) | void dbuf_init(DynBuf *s)
function dbuf_claim (line 104) | int dbuf_claim(DynBuf *s, size_t len)
function dbuf_put (line 130) | int dbuf_put(DynBuf *s, const uint8_t *data, size_t len)
function dbuf_put_self (line 141) | int dbuf_put_self(DynBuf *s, size_t offset, size_t len)
function __dbuf_putc (line 152) | int __dbuf_putc(DynBuf *s, uint8_t c)
function __dbuf_put_u16 (line 157) | int __dbuf_put_u16(DynBuf *s, uint16_t val)
function __dbuf_put_u32 (line 162) | int __dbuf_put_u32(DynBuf *s, uint32_t val)
function __dbuf_put_u64 (line 167) | int __dbuf_put_u64(DynBuf *s, uint64_t val)
function dbuf_putstr (line 172) | int dbuf_putstr(DynBuf *s, const char *str)
function dbuf_printf (line 177) | int __attribute__((format(printf, 2, 3))) dbuf_printf(DynBuf *s,
function dbuf_free (line 204) | void dbuf_free(DynBuf *s)
function unicode_to_utf8 (line 216) | int unicode_to_utf8(uint8_t *buf, unsigned int c)
function unicode_from_utf8 (line 261) | int unicode_from_utf8(const uint8_t *p, int max_len, const uint8_t **pp)
function rqsort_cmp2 (line 323) | static int rqsort_cmp2(const void *p1, const void *p2)
function rqsort (line 329) | void rqsort(void *base, size_t nmemb, size_t size,
function exchange_bytes (line 345) | static void exchange_bytes(void *a, void *b, size_t size) {
function exchange_one_byte (line 356) | static void exchange_one_byte(void *a, void *b, size_t size) {
function exchange_int16s (line 364) | static void exchange_int16s(void *a, void *b, size_t size) {
function exchange_one_int16 (line 375) | static void exchange_one_int16(void *a, void *b, size_t size) {
function exchange_int32s (line 383) | static void exchange_int32s(void *a, void *b, size_t size) {
function exchange_one_int32 (line 394) | static void exchange_one_int32(void *a, void *b, size_t size) {
function exchange_int64s (line 402) | static void exchange_int64s(void *a, void *b, size_t size) {
function exchange_one_int64 (line 413) | static void exchange_one_int64(void *a, void *b, size_t size) {
function exchange_int128s (line 421) | static void exchange_int128s(void *a, void *b, size_t size) {
function exchange_one_int128 (line 435) | static void exchange_one_int128(void *a, void *b, size_t size) {
function exchange_f (line 446) | static inline exchange_f exchange_func(const void *base, size_t size) {
function heapsortx (line 480) | static void heapsortx(void *base, size_t nmemb, size_t size, cmp_f cmp, ...
function rqsort (line 522) | void rqsort(void *base, size_t nmemb, size_t size, cmp_f cmp, void *opaque)
FILE: cutils.h
type BOOL (line 60) | typedef int BOOL;
function memcpy_no_ub (line 75) | static inline void memcpy_no_ub(void *dest, const void *src, size_t n) {
function max_int (line 80) | static inline int max_int(int a, int b)
function min_int (line 88) | static inline int min_int(int a, int b)
function max_uint32 (line 96) | static inline uint32_t max_uint32(uint32_t a, uint32_t b)
function min_uint32 (line 104) | static inline uint32_t min_uint32(uint32_t a, uint32_t b)
function max_int64 (line 112) | static inline int64_t max_int64(int64_t a, int64_t b)
function min_int64 (line 120) | static inline int64_t min_int64(int64_t a, int64_t b)
function clz32 (line 129) | static inline int clz32(unsigned int a)
function clz64 (line 135) | static inline int clz64(uint64_t a)
function ctz32 (line 141) | static inline int ctz32(unsigned int a)
function ctz64 (line 147) | static inline int ctz64(uint64_t a)
type packed_u64 (line 152) | struct __attribute__((packed)) packed_u64 {
type packed_u32 (line 156) | struct __attribute__((packed)) packed_u32 {
type packed_u16 (line 160) | struct __attribute__((packed)) packed_u16 {
function get_u64 (line 164) | static inline uint64_t get_u64(const uint8_t *tab)
function get_i64 (line 169) | static inline int64_t get_i64(const uint8_t *tab)
function put_u64 (line 174) | static inline void put_u64(uint8_t *tab, uint64_t val)
function get_u32 (line 179) | static inline uint32_t get_u32(const uint8_t *tab)
function get_i32 (line 184) | static inline int32_t get_i32(const uint8_t *tab)
function put_u32 (line 189) | static inline void put_u32(uint8_t *tab, uint32_t val)
function get_u16 (line 194) | static inline uint32_t get_u16(const uint8_t *tab)
function get_i16 (line 199) | static inline int32_t get_i16(const uint8_t *tab)
function put_u16 (line 204) | static inline void put_u16(uint8_t *tab, uint16_t val)
function get_u8 (line 209) | static inline uint32_t get_u8(const uint8_t *tab)
function get_i8 (line 214) | static inline int32_t get_i8(const uint8_t *tab)
function put_u8 (line 219) | static inline void put_u8(uint8_t *tab, uint8_t val)
function bswap16 (line 225) | static inline uint16_t bswap16(uint16_t x)
function bswap32 (line 232) | static inline uint32_t bswap32(uint32_t v)
function bswap64 (line 240) | static inline uint64_t bswap64(uint64_t v)
type DynBuf (line 256) | typedef struct DynBuf {
function dbuf_putc (line 276) | static inline int dbuf_putc(DynBuf *s, uint8_t val)
function dbuf_put_u16 (line 286) | static inline int dbuf_put_u16(DynBuf *s, uint16_t val)
function dbuf_put_u32 (line 297) | static inline int dbuf_put_u32(DynBuf *s, uint32_t val)
function dbuf_put_u64 (line 308) | static inline int dbuf_put_u64(DynBuf *s, uint64_t val)
function BOOL (line 322) | static inline BOOL dbuf_error(DynBuf *s) {
function dbuf_set_error (line 325) | static inline void dbuf_set_error(DynBuf *s)
function BOOL (line 335) | static inline BOOL is_surrogate(uint32_t c)
function BOOL (line 340) | static inline BOOL is_hi_surrogate(uint32_t c)
function BOOL (line 345) | static inline BOOL is_lo_surrogate(uint32_t c)
function get_hi_surrogate (line 350) | static inline uint32_t get_hi_surrogate(uint32_t c)
function get_lo_surrogate (line 355) | static inline uint32_t get_lo_surrogate(uint32_t c)
function from_surrogate (line 360) | static inline uint32_t from_surrogate(uint32_t hi, uint32_t lo)
function from_hex (line 365) | static inline int from_hex(int c)
function float64_as_uint64 (line 381) | static inline uint64_t float64_as_uint64(double d)
function uint64_as_float64 (line 391) | static inline double uint64_as_float64(uint64_t u64)
function fromfp16 (line 401) | static inline double fromfp16(uint16_t v)
function tofp16 (line 412) | static inline uint16_t tofp16(double d)
function isfp16nan (line 447) | static inline int isfp16nan(uint16_t v)
function isfp16zero (line 452) | static inline int isfp16zero(uint16_t v)
FILE: dtoa.c
type slimb_t (line 56) | typedef int32_t slimb_t;
type limb_t (line 57) | typedef uint32_t limb_t;
type dlimb_t (line 58) | typedef uint64_t dlimb_t;
type mp_size_t (line 67) | typedef intptr_t mp_size_t;
type mpb_t (line 70) | typedef struct {
function limb_t (line 75) | static limb_t mp_add_ui(limb_t *tab, limb_t b, size_t n)
function limb_t (line 92) | static limb_t mp_mul1(limb_t *tabr, const limb_t *taba, limb_t n,
function limb_t (line 107) | static inline limb_t udiv1norm_init(limb_t d)
function limb_t (line 117) | static inline limb_t udiv1norm(limb_t *pr, limb_t a1, limb_t a0,
function limb_t (line 137) | static limb_t mp_div1(limb_t *tabr, const limb_t *taba, limb_t n,
function limb_t (line 152) | static limb_t mp_shr(limb_t *tab_r, const limb_t *tab, mp_size_t n,
function limb_t (line 170) | static limb_t mp_shl(limb_t *tab_r, const limb_t *tab, mp_size_t n,
function no_inline (line 186) | static no_inline limb_t mp_div1norm(limb_t *tabr, const limb_t *taba, li...
function __maybe_unused (line 201) | static __maybe_unused void mpb_dump(const char *str, const mpb_t *a)
function mpb_renorm (line 214) | static void mpb_renorm(mpb_t *r)
function pow_ui (line 242) | static uint64_t pow_ui(uint32_t a, uint32_t b)
function pow_ui_inv (line 271) | static uint32_t pow_ui_inv(uint32_t *pr_inv, int *pshift, uint32_t a, ui...
function mpb_get_bit (line 300) | static int mpb_get_bit(const mpb_t *r, int k)
function mpb_shr_round (line 313) | static void mpb_shr_round(mpb_t *r, int shift, int rnd_mode)
function mpb_cmp (line 401) | static int mpb_cmp(const mpb_t *a, const mpb_t *b)
function mpb_set_u64 (line 419) | static void mpb_set_u64(mpb_t *r, uint64_t m)
function mpb_get_u64 (line 434) | static uint64_t mpb_get_u64(mpb_t *r)
function mpb_floor_log2 (line 448) | static int mpb_floor_log2(mpb_t *a)
function mul_log2_radix (line 474) | static int mul_log2_radix(int a, int radix)
function build_mul_log2_radix_table (line 491) | static void build_mul_log2_radix_table(void)
function mul_log2_radix_test (line 512) | static void mul_log2_radix_test(void)
function u32toa_len (line 532) | static void u32toa_len(char *buf, uint32_t n, size_t len)
function u64toa_bin_len (line 543) | static void u64toa_bin_len(char *buf, uint64_t n, unsigned int radix_bit...
function limb_to_a (line 561) | static void limb_to_a(char *buf, limb_t n, unsigned int radix, int len)
function u32toa (line 590) | size_t u32toa(char *buf, uint32_t n)
function i32toa (line 605) | size_t i32toa(char *buf, int32_t n)
function u64toa (line 616) | size_t u64toa(char *buf, uint64_t n)
function i64toa (line 647) | size_t i64toa(char *buf, int64_t n)
function u64toa_radix (line 658) | size_t u64toa_radix(char *buf, uint64_t n, unsigned int radix)
function i64toa_radix (line 691) | size_t i64toa_radix(char *buf, int64_t n, unsigned int radix)
function build_tables (line 754) | void build_tables(void)
function output_digits (line 847) | static int output_digits(char *buf,
function mul_pow (line 893) | static int mul_pow(mpb_t *a, int radix1, int radix_shift, int f, BOOL is...
function mul_pow_round (line 959) | static void mul_pow_round(mpb_t *tmp1, uint64_t m, int e, int radix1, in...
function round_to_d (line 970) | static uint64_t round_to_d(int *pe, mpb_t *a, int e_offset, int rnd_mode)
function mul_pow_round_to_d (line 1006) | static uint64_t mul_pow_round_to_d(int *pe, mpb_t *a,
function js_dtoa_dump_stats (line 1018) | void js_dtoa_dump_stats(void)
function js_dtoa_max_len (line 1034) | int js_dtoa_max_len(double d, int radix, int n_digits, int flags)
function dtoa_free (line 1089) | static void dtoa_free(void *ptr)
function dtoa_free (line 1102) | static void dtoa_free(void *ptr)
function js_dtoa (line 1108) | int js_dtoa(char *buf, double d, int radix, int n_digits, int flags,
function to_digit (line 1320) | static inline int to_digit(int c)
function mpb_mul1_base (line 1333) | static void mpb_mul1_base(mpb_t *r, limb_t radix_base, limb_t a)
function js_atod (line 1354) | double js_atod(const char *str, const char **pnext, int radix, int flags,
FILE: dtoa.h
type JSDTOATempMem (line 57) | typedef struct {
type JSATODTempMem (line 61) | typedef struct {
FILE: examples/fib.c
function fib (line 28) | static int fib(int n)
function JSValue (line 38) | static JSValue js_fib(JSContext *ctx, JSValueConst this_val,
function js_fib_init (line 52) | static int js_fib_init(JSContext *ctx, JSModuleDef *m)
function JSModuleDef (line 64) | JSModuleDef *JS_INIT_MODULE(JSContext *ctx, const char *module_name)
FILE: examples/fib_module.js
function fib (line 2) | function fib(n)
FILE: examples/pi_bigint.js
function floor_log2 (line 7) | function floor_log2(a)
function ceil_log2 (line 27) | function ceil_log2(a)
function int_sqrt (line 33) | function int_sqrt(a)
function calc_pi (line 51) | function calc_pi(prec) {
function main (line 90) | function main(args) {
FILE: examples/point.c
type JSPointData (line 31) | typedef struct {
function js_point_finalizer (line 38) | static void js_point_finalizer(JSRuntime *rt, JSValue val)
function JSValue (line 45) | static JSValue js_point_ctor(JSContext *ctx,
function JSValue (line 77) | static JSValue js_point_get_xy(JSContext *ctx, JSValueConst this_val, in...
function JSValue (line 88) | static JSValue js_point_set_xy(JSContext *ctx, JSValueConst this_val, JS...
function JSValue (line 103) | static JSValue js_point_norm(JSContext *ctx, JSValueConst this_val,
function js_point_init (line 123) | static int js_point_init(JSContext *ctx, JSModuleDef *m)
function JSModuleDef (line 143) | JSModuleDef *js_init_module(JSContext *ctx, const char *module_name)
FILE: examples/test_point.js
function assert (line 4) | function assert(b, str)
class ColorPoint (line 13) | class ColorPoint extends Point {
method constructor (line 14) | constructor(x, y, color) {
method get_color (line 18) | get_color() {
function main (line 23) | function main()
FILE: fuzz/fuzz_common.c
function interrupt_handler (line 21) | static int interrupt_handler(JSRuntime *rt, void *opaque)
function reset_nbinterrupts (line 27) | void reset_nbinterrupts() {
function test_one_input_init (line 31) | void test_one_input_init(JSRuntime *rt, JSContext *ctx) {
FILE: fuzz/fuzz_compile.c
function LLVMFuzzerTestOneInput (line 25) | int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
FILE: fuzz/fuzz_eval.c
function LLVMFuzzerTestOneInput (line 24) | int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
FILE: fuzz/fuzz_regexp.c
function lre_check_stack_overflow (line 21) | int lre_check_stack_overflow(void *opaque, size_t alloca_size) { return ...
function lre_check_timeout (line 28) | int lre_check_timeout(void *opaque)
function LLVMFuzzerTestOneInput (line 34) | int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
FILE: fuzz/generate_dict.js
function collectBuiltinNames (line 2) | function collectBuiltinNames(obj, visited = new Set(), result = new Set(...
FILE: libregexp.c
type REParseState (line 71) | typedef struct {
type REOpCode (line 94) | typedef struct {
function is_digit (line 118) | static inline int is_digit(int c) {
function dbuf_insert (line 123) | static int dbuf_insert(DynBuf *s, int pos, int len)
type REString (line 132) | typedef struct REString {
type REStringList (line 139) | typedef struct {
function re_string_hash (line 150) | static uint32_t re_string_hash(int len, const uint32_t *buf)
function re_string_list_init (line 160) | static void re_string_list_init(REParseState *s1, REStringList *s)
function re_string_list_free (line 169) | static void re_string_list_free(REStringList *s)
function lre_print_char (line 184) | static void lre_print_char(int c, BOOL is_range)
function __maybe_unused (line 196) | static __maybe_unused void re_string_list_dump(const char *str, const RE...
function re_string_find2 (line 227) | static int re_string_find2(REStringList *s, int len, const uint32_t *buf,
function re_string_find (line 283) | static int re_string_find(REStringList *s, int len, const uint32_t *buf,
function re_string_add (line 292) | static int re_string_add(REStringList *s, int len, const uint32_t *buf)
function re_string_list_op (line 303) | static int re_string_list_op(REStringList *a, REStringList *b, int op)
function re_string_list_canonicalize (line 351) | static int re_string_list_canonicalize(REParseState *s1,
type CharRangeEnum (line 423) | typedef enum {
function cr_init_char_range (line 438) | static int cr_init_char_range(REParseState *s, REStringList *cr, uint32_...
function __maybe_unused (line 463) | static __maybe_unused void lre_dump_bytecode(const uint8_t *buf,
function re_emit_op (line 616) | static void re_emit_op(REParseState *s, int op)
function re_emit_op_u32 (line 622) | static int re_emit_op_u32(REParseState *s, int op, uint32_t val)
function re_emit_goto (line 631) | static int re_emit_goto(REParseState *s, int op, uint32_t val)
function re_emit_goto_u8 (line 640) | static int re_emit_goto_u8(REParseState *s, int op, uint32_t arg, uint32...
function re_emit_goto_u8_u32 (line 650) | static int re_emit_goto_u8_u32(REParseState *s, int op, uint32_t arg0, u...
function re_emit_op_u8 (line 661) | static void re_emit_op_u8(REParseState *s, int op, uint32_t val)
function re_emit_op_u16 (line 667) | static void re_emit_op_u16(REParseState *s, int op, uint32_t val)
function re_parse_error (line 673) | static int __attribute__((format(printf, 2, 3))) re_parse_error(REParseS...
function re_parse_out_of_memory (line 682) | static int re_parse_out_of_memory(REParseState *s)
function parse_digits (line 689) | static int parse_digits(const uint8_t **pp, BOOL allow_overflow)
function re_parse_expect (line 714) | static int re_parse_expect(REParseState *s, const uint8_t **pp, int c)
function lre_parse_escape (line 735) | int lre_parse_escape(const uint8_t **pp, int allow_utf16)
function BOOL (line 854) | static BOOL is_unicode_char(int c)
function seq_prop_cb (line 863) | static void seq_prop_cb(void *opaque, const uint32_t *seq, int seq_len)
function parse_unicode_property (line 869) | static int parse_unicode_property(REParseState *s, REStringList *cr,
function parse_class_string_disjunction (line 993) | static int parse_class_string_disjunction(REParseState *s, REStringList ...
function get_class_atom (line 1044) | static int get_class_atom(REParseState *s, REStringList *cr,
function re_emit_range (line 1225) | static int re_emit_range(REParseState *s, const CharRange *cr)
function re_string_cmp_len (line 1261) | static int re_string_cmp_len(const void *a, const void *b, void *arg)
function re_emit_char (line 1268) | static void re_emit_char(REParseState *s, int c)
function re_emit_string_list (line 1276) | static int re_emit_string_list(REParseState *s, const REStringList *sl)
function re_parse_class_set_operand (line 1356) | static int re_parse_class_set_operand(REParseState *s, REStringList *cr,...
function re_parse_nested_class (line 1382) | static int re_parse_nested_class(REParseState *s, REStringList *cr, cons...
function re_parse_char_class (line 1539) | static int re_parse_char_class(REParseState *s, const uint8_t **pp)
function BOOL (line 1557) | static BOOL re_need_check_adv_and_capture_init(BOOL *pneed_capture_init,
function re_parse_group_name (line 1631) | static int re_parse_group_name(char *buf, int buf_size, const uint8_t **pp)
function re_parse_captures (line 1687) | static int re_parse_captures(REParseState *s, int *phas_named_captures,
function re_count_captures (line 1743) | static int re_count_captures(REParseState *s)
function BOOL (line 1752) | static BOOL re_has_named_captures(REParseState *s)
function find_group_name (line 1759) | static int find_group_name(REParseState *s, const char *name, BOOL emit_...
function BOOL (line 1785) | static BOOL is_duplicate_group_name(REParseState *s, const char *name, i...
function re_parse_modifiers (line 1810) | static int re_parse_modifiers(REParseState *s, const uint8_t **pp)
function BOOL (line 1835) | static BOOL update_modifier(BOOL val, int add_mask, int remove_mask,
function re_parse_term (line 1845) | static int re_parse_term(REParseState *s, BOOL is_backward_dir)
function re_parse_alternative (line 2372) | static int re_parse_alternative(REParseState *s, BOOL is_backward_dir)
function re_parse_disjunction (line 2406) | static int re_parse_disjunction(REParseState *s, BOOL is_backward_dir)
function compute_register_count (line 2444) | static int compute_register_count(uint8_t *bc_buf, int bc_buf_len)
function BOOL (line 2616) | static BOOL is_line_terminator(uint32_t c)
type REExecStateEnum (line 2704) | typedef enum {
type StackElem (line 2716) | typedef union {
type REExecContext (line 2725) | typedef struct {
function lre_poll_timeout (line 2740) | static int lre_poll_timeout(REExecContext *s)
function no_inline (line 2750) | static no_inline int stack_realloc(REExecContext *s, size_t n)
function lre_exec_backtrack (line 2774) | static intptr_t lre_exec_backtrack(REExecContext *s, uint8_t **capture,
function lre_exec (line 3326) | int lre_exec(uint8_t **capture,
function lre_get_alloc_count (line 3366) | int lre_get_alloc_count(const uint8_t *bc_buf)
function lre_get_capture_count (line 3372) | int lre_get_capture_count(const uint8_t *bc_buf)
function lre_get_flags (line 3377) | int lre_get_flags(const uint8_t *bc_buf)
function BOOL (line 3395) | BOOL lre_check_stack_overflow(void *opaque, size_t alloca_size)
function main (line 3405) | int main(int argc, char **argv)
FILE: libunicode-table.h
type UnicodeGCEnum (line 2373) | typedef enum {
type UnicodeScriptEnum (line 2975) | typedef enum {
type UnicodePropertyEnum (line 4611) | typedef enum {
type UnicodeSequencePropertyEnum (line 4876) | typedef enum {
FILE: libunicode.c
function lre_case_conv1 (line 51) | static int lre_case_conv1(uint32_t c, int conv_type)
function lre_case_conv_entry (line 59) | static int lre_case_conv_entry(uint32_t *res, uint32_t c, int conv_type,...
function lre_case_conv (line 156) | int lre_case_conv(uint32_t *res, uint32_t c, int conv_type)
function lre_case_folding_entry (line 192) | static int lre_case_folding_entry(uint32_t c, uint32_t idx, uint32_t v, ...
function lre_canonicalize (line 227) | int lre_canonicalize(uint32_t c, BOOL is_unicode)
function get_le24 (line 263) | static uint32_t get_le24(const uint8_t *ptr)
function get_index_pos (line 271) | static int get_index_pos(uint32_t *pcode, uint32_t c,
function BOOL (line 304) | static BOOL lre_is_in_table(uint32_t c, const uint8_t *table,
function BOOL (line 347) | BOOL lre_is_cased(uint32_t c)
function BOOL (line 372) | BOOL lre_is_case_ignorable(uint32_t c)
function __maybe_unused (line 381) | static __maybe_unused void cr_dump(CharRange *cr)
function cr_init (line 393) | void cr_init(CharRange *cr, void *mem_opaque, DynBufReallocFunc *realloc...
function cr_free (line 401) | void cr_free(CharRange *cr)
function cr_realloc (line 406) | int cr_realloc(CharRange *cr, int size)
function cr_copy (line 423) | int cr_copy(CharRange *cr, const CharRange *cr1)
function cr_compress (line 433) | static void cr_compress(CharRange *cr)
function cr_op (line 462) | int cr_op(CharRange *cr, const uint32_t *a_pt, int a_len,
function cr_op1 (line 517) | int cr_op1(CharRange *cr, const uint32_t *b_pt, int b_len, int op)
function cr_invert (line 529) | int cr_invert(CharRange *cr)
function unicode_case1 (line 552) | static int unicode_case1(CharRange *cr, int case_mask)
function point_cmp (line 615) | static int point_cmp(const void *p1, const void *p2, void *arg)
function cr_sort_and_remove_overlap (line 622) | static void cr_sort_and_remove_overlap(CharRange *cr)
function cr_regexp_canonicalize (line 660) | int cr_regexp_canonicalize(CharRange *cr, BOOL is_unicode)
function BOOL (line 746) | BOOL lre_is_id_start(uint32_t c)
function BOOL (line 753) | BOOL lre_is_id_continue(uint32_t c)
type DecompTypeEnum (line 763) | typedef enum {
function unicode_get_short_code (line 801) | static uint32_t unicode_get_short_code(uint32_t c)
function unicode_get_lower_simple (line 813) | static uint32_t unicode_get_lower_simple(uint32_t c)
function unicode_get16 (line 822) | static uint16_t unicode_get16(const uint8_t *p)
function unicode_decomp_entry (line 827) | static int unicode_decomp_entry(uint32_t *res, uint32_t c,
function unicode_decomp_char (line 968) | static int unicode_decomp_char(uint32_t *res, uint32_t c, BOOL is_compat1)
function unicode_compose_pair (line 997) | static int unicode_compose_pair(uint32_t c0, uint32_t c1)
function unicode_get_cc (line 1033) | static int unicode_get_cc(uint32_t c)
function sort_cc (line 1091) | static void sort_cc(int *buf, int len)
function to_nfd_rec (line 1127) | static void to_nfd_rec(DynBuf *dbuf,
function compose_pair (line 1156) | static int compose_pair(uint32_t c0, uint32_t c1)
function unicode_normalize (line 1171) | int unicode_normalize(uint32_t **pdst, const uint32_t *src, int src_len,
function unicode_find_name (line 1246) | static int unicode_find_name(const char *name_table, const char *name)
function unicode_script (line 1275) | int unicode_script(CharRange *cr,
function unicode_general_category1 (line 1397) | static int unicode_general_category1(CharRange *cr, uint32_t gc_mask)
function unicode_prop1 (line 1458) | static int unicode_prop1(CharRange *cr, int prop_idx)
type PropOPEnum (line 1505) | typedef enum {
function unicode_prop_ops (line 1518) | static int unicode_prop_ops(CharRange *cr, ...)
function unicode_general_category (line 1607) | int unicode_general_category(CharRange *cr, const char *gc_name)
function unicode_prop (line 1626) | int unicode_prop(CharRange *cr, const char *prop_name)
function BOOL (line 1902) | BOOL lre_is_space_non_ascii(uint32_t c)
function unicode_sequence_prop1 (line 1920) | static int unicode_sequence_prop1(int seq_prop_idx, UnicodeSequencePropC...
function unicode_sequence_prop (line 2115) | int unicode_sequence_prop(const char *prop_name, UnicodeSequencePropCB *...
FILE: libunicode.h
type CharRange (line 36) | typedef struct {
type CharRangeOpEnum (line 44) | typedef enum {
function cr_add_point (line 56) | static inline int cr_add_point(CharRange *cr, uint32_t v)
function cr_add_interval (line 66) | static inline int cr_add_interval(CharRange *cr, uint32_t c1, uint32_t c2)
function cr_union_interval (line 81) | static inline int cr_union_interval(CharRange *cr, uint32_t c1, uint32_t...
type UnicodeNormalizationEnum (line 93) | typedef enum {
function lre_is_space_byte (line 135) | static inline int lre_is_space_byte(uint8_t c) {
function lre_is_id_start_byte (line 139) | static inline int lre_is_id_start_byte(uint8_t c) {
function lre_is_id_continue_byte (line 144) | static inline int lre_is_id_continue_byte(uint8_t c) {
function lre_is_word_byte (line 150) | static inline int lre_is_word_byte(uint8_t c) {
function lre_is_space (line 157) | static inline int lre_is_space(uint32_t c) {
function lre_js_is_ident_first (line 164) | static inline int lre_js_is_ident_first(uint32_t c) {
function lre_js_is_ident_next (line 176) | static inline int lre_js_is_ident_next(uint32_t c) {
FILE: list.h
type list_head (line 31) | struct list_head {
function init_list_head (line 41) | static inline void init_list_head(struct list_head *head)
function __list_add (line 48) | static inline void __list_add(struct list_head *el,
function list_add (line 58) | static inline void list_add(struct list_head *el, struct list_head *head)
function list_add_tail (line 64) | static inline void list_add_tail(struct list_head *el, struct list_head ...
function list_del (line 69) | static inline void list_del(struct list_head *el)
function list_empty (line 80) | static inline int list_empty(struct list_head *el)
FILE: qjs.c
function eval_buf (line 49) | static int eval_buf(JSContext *ctx, const void *buf, int buf_len,
function eval_file (line 78) | static int eval_file(JSContext *ctx, const char *filename, int module, i...
function JSContext (line 107) | static JSContext *JS_NewCustomContext(JSRuntime *rt)
type trace_malloc_data (line 125) | struct trace_malloc_data {
function js_trace_malloc_ptr_offset (line 129) | static inline unsigned long long js_trace_malloc_ptr_offset(uint8_t *ptr,
function js_trace_malloc_usable_size (line 136) | static size_t js_trace_malloc_usable_size(const void *ptr)
function js_trace_malloc_init (line 192) | static void js_trace_malloc_init(struct trace_malloc_data *s)
function js_trace_free (line 215) | static void js_trace_free(JSMallocState *s, void *ptr)
function get_suffixed_size (line 263) | static size_t get_suffixed_size(const char *str)
function help (line 291) | void help(void)
function main (line 314) | int main(int argc, char **argv)
FILE: qjsc.c
type namelist_entry_t (line 39) | typedef struct {
type namelist_t (line 45) | typedef struct namelist_t {
type FeatureEntry (line 51) | typedef struct {
function namelist_add (line 82) | void namelist_add(namelist_t *lp, const char *name, const char *short_name,
function namelist_free (line 103) | void namelist_free(namelist_t *lp)
function namelist_entry_t (line 115) | namelist_entry_t *namelist_find(namelist_t *lp, const char *name)
function get_c_name (line 126) | static void get_c_name(char *buf, size_t buf_size, const char *file)
function dump_hex (line 158) | static void dump_hex(FILE *f, const uint8_t *buf, size_t len)
type CNameTypeEnum (line 173) | typedef enum {
function output_object_code (line 179) | static void output_object_code(JSContext *ctx,
function js_module_dummy_init (line 211) | static int js_module_dummy_init(JSContext *ctx, JSModuleDef *m)
function find_unique_cname (line 217) | static void find_unique_cname(char *cname, size_t cname_size)
function JSModuleDef (line 239) | JSModuleDef *jsc_module_loader(JSContext *ctx,
function compile_file (line 330) | static void compile_file(JSContext *ctx, FILE *fo,
function help (line 393) | void help(void)
function exec_cmd (line 431) | int exec_cmd(char **argv)
function output_executable (line 449) | static int output_executable(const char *out_filename, const char *cfile...
function output_executable (line 520) | static int output_executable(const char *out_filename, const char *cfile...
function get_suffixed_size (line 529) | static size_t get_suffixed_size(const char *str)
type OutputTypeEnum (line 555) | typedef enum {
function main (line 576) | int main(int argc, char **argv)
FILE: quickjs-libc.c
type sig_t (line 55) | typedef sig_t sighandler_t;
type JSOSRWHandler (line 87) | typedef struct {
type JSOSSignalHandler (line 93) | typedef struct {
type JSOSTimer (line 99) | typedef struct {
type JSWorkerMessage (line 106) | typedef struct {
type JSWaker (line 115) | typedef struct JSWaker {
type JSWorkerMessagePipe (line 124) | typedef struct {
type JSWorkerMessageHandler (line 133) | typedef struct {
type JSRejectedPromiseEntry (line 139) | typedef struct {
type JSThreadState (line 145) | typedef struct JSThreadState {
function js_std_dbuf_init (line 160) | static void js_std_dbuf_init(JSContext *ctx, DynBuf *s)
function BOOL (line 165) | static BOOL my_isdigit(int c)
function JSValue (line 171) | static JSValue js_printf_internal(JSContext *ctx,
function JSValue (line 434) | static JSValue js_loadScript(JSContext *ctx, JSValueConst this_val,
function JSValue (line 459) | static JSValue js_std_loadFile(JSContext *ctx, JSValueConst this_val,
type JSModuleDef (line 479) | typedef JSModuleDef *(JSInitModuleFunc)(JSContext *ctx,
function JSModuleDef (line 484) | static JSModuleDef *js_module_loader_so(JSContext *ctx,
function JSModuleDef (line 491) | static JSModuleDef *js_module_loader_so(JSContext *ctx,
function js_module_set_import_meta (line 541) | int js_module_set_import_meta(JSContext *ctx, JSValueConst func_val,
function json_module_init (line 594) | static int json_module_init(JSContext *ctx, JSModuleDef *m)
function JSModuleDef (line 602) | static JSModuleDef *create_json_module(JSContext *ctx, const char *modul...
function js_module_check_attributes (line 618) | int js_module_check_attributes(JSContext *ctx, void *opaque,
function js_module_test_json (line 649) | int js_module_test_json(JSContext *ctx, JSValueConst attributes)
function JSModuleDef (line 677) | JSModuleDef *js_module_loader(JSContext *ctx,
function JSValue (line 730) | static JSValue js_std_exit(JSContext *ctx, JSValueConst this_val,
function JSValue (line 740) | static JSValue js_std_getenv(JSContext *ctx, JSValueConst this_val,
function setenv (line 756) | static void setenv(const char *name, const char *value, int overwrite)
function unsetenv (line 771) | static void unsetenv(const char *name)
function JSValue (line 777) | static JSValue js_std_setenv(JSContext *ctx, JSValueConst this_val,
function JSValue (line 795) | static JSValue js_std_unsetenv(JSContext *ctx, JSValueConst this_val,
function JSValue (line 809) | static JSValue js_std_getenviron(JSContext *ctx, JSValueConst this_val,
function JSValue (line 846) | static JSValue js_std_gc(JSContext *ctx, JSValueConst this_val,
function interrupt_handler (line 853) | static int interrupt_handler(JSRuntime *rt, void *opaque)
function get_bool_option (line 858) | static int get_bool_option(JSContext *ctx, BOOL *pbool,
function JSValue (line 873) | static JSValue js_evalScript(JSContext *ctx, JSValueConst this_val,
type JSSTDFile (line 924) | typedef struct {
function js_std_file_finalizer (line 930) | static void js_std_file_finalizer(JSRuntime *rt, JSValue val)
function js_get_errno (line 944) | static ssize_t js_get_errno(ssize_t ret)
function JSValue (line 951) | static JSValue js_std_strerror(JSContext *ctx, JSValueConst this_val,
function JSValue (line 960) | static JSValue js_std_parseExtJSON(JSContext *ctx, JSValueConst this_val,
function JSValue (line 975) | static JSValue js_new_std_file(JSContext *ctx, FILE *f,
function js_set_error_object (line 996) | static void js_set_error_object(JSContext *ctx, JSValue obj, int err)
function JSValue (line 1003) | static JSValue js_std_open(JSContext *ctx, JSValueConst this_val,
function JSValue (line 1039) | static JSValue js_std_popen(JSContext *ctx, JSValueConst this_val,
function JSValue (line 1075) | static JSValue js_std_fdopen(JSContext *ctx, JSValueConst this_val,
function JSValue (line 1108) | static JSValue js_std_tmpfile(JSContext *ctx, JSValueConst this_val,
function JSValue (line 1120) | static JSValue js_std_sprintf(JSContext *ctx, JSValueConst this_val,
function JSValue (line 1126) | static JSValue js_std_printf(JSContext *ctx, JSValueConst this_val,
function FILE (line 1132) | static FILE *js_std_file_get(JSContext *ctx, JSValueConst obj)
function JSValue (line 1144) | static JSValue js_std_file_puts(JSContext *ctx, JSValueConst this_val,
function JSValue (line 1170) | static JSValue js_std_file_close(JSContext *ctx, JSValueConst this_val,
function JSValue (line 1187) | static JSValue js_std_file_printf(JSContext *ctx, JSValueConst this_val,
function js_print_value_write (line 1196) | static void js_print_value_write(void *opaque, const char *buf, size_t len)
function JSValue (line 1202) | static JSValue js_std_file_printObject(JSContext *ctx, JSValueConst this...
function JSValue (line 1209) | static JSValue js_std_file_flush(JSContext *ctx, JSValueConst this_val,
function JSValue (line 1219) | static JSValue js_std_file_tell(JSContext *ctx, JSValueConst this_val,
function JSValue (line 1237) | static JSValue js_std_file_seek(JSContext *ctx, JSValueConst this_val,
function JSValue (line 1259) | static JSValue js_std_file_eof(JSContext *ctx, JSValueConst this_val,
function JSValue (line 1268) | static JSValue js_std_file_error(JSContext *ctx, JSValueConst this_val,
function JSValue (line 1277) | static JSValue js_std_file_clearerr(JSContext *ctx, JSValueConst this_val,
function JSValue (line 1287) | static JSValue js_std_file_fileno(JSContext *ctx, JSValueConst this_val,
function JSValue (line 1296) | static JSValue js_std_file_read_write(JSContext *ctx, JSValueConst this_...
function JSValue (line 1323) | static JSValue js_std_file_getline(JSContext *ctx, JSValueConst this_val,
function JSValue (line 1359) | static JSValue js_std_file_readAsString(JSContext *ctx, JSValueConst thi...
function JSValue (line 1401) | static JSValue js_std_file_getByte(JSContext *ctx, JSValueConst this_val,
function JSValue (line 1410) | static JSValue js_std_file_putByte(JSContext *ctx, JSValueConst this_val,
function http_get_header_line (line 1428) | static int http_get_header_line(FILE *f, char *buf, size_t buf_size,
function http_get_status (line 1450) | static int http_get_status(const char *buf)
function JSValue (line 1462) | static JSValue js_std_urlGet(JSContext *ctx, JSValueConst this_val,
function js_std_init (line 1690) | static int js_std_init(JSContext *ctx, JSModuleDef *m)
function JSModuleDef (line 1712) | JSModuleDef *js_init_module_std(JSContext *ctx, const char *module_name)
function JSValue (line 1728) | static JSValue js_os_open(JSContext *ctx, JSValueConst this_val,
function JSValue (line 1758) | static JSValue js_os_close(JSContext *ctx, JSValueConst this_val,
function JSValue (line 1768) | static JSValue js_os_seek(JSContext *ctx, JSValueConst this_val,
function JSValue (line 1791) | static JSValue js_os_read_write(JSContext *ctx, JSValueConst this_val,
function JSValue (line 1818) | static JSValue js_os_isatty(JSContext *ctx, JSValueConst this_val,
function JSValue (line 1828) | static JSValue js_os_ttyGetWinSize(JSContext *ctx, JSValueConst this_val,
function JSValue (line 1854) | static JSValue js_os_ttySetRaw(JSContext *ctx, JSValueConst this_val,
function JSValue (line 1872) | static JSValue js_os_ttyGetWinSize(JSContext *ctx, JSValueConst this_val,
type termios (line 1894) | struct termios
function term_exit (line 1896) | static void term_exit(void)
function JSValue (line 1902) | static JSValue js_os_ttySetRaw(JSContext *ctx, JSValueConst this_val,
function JSValue (line 1932) | static JSValue js_os_remove(JSContext *ctx, JSValueConst this_val,
function JSValue (line 1958) | static JSValue js_os_rename(JSContext *ctx, JSValueConst this_val,
function BOOL (line 1978) | static BOOL is_main_thread(JSRuntime *rt)
function JSOSRWHandler (line 1984) | static JSOSRWHandler *find_rh(JSThreadState *ts, int fd)
function free_rw_handler (line 1997) | static void free_rw_handler(JSRuntime *rt, JSOSRWHandler *rh)
function JSValue (line 2007) | static JSValue js_os_setReadHandler(JSContext *ctx, JSValueConst this_val,
function JSOSSignalHandler (line 2049) | static JSOSSignalHandler *find_sh(JSThreadState *ts, int sig_num)
function free_sh (line 2061) | static void free_sh(JSRuntime *rt, JSOSSignalHandler *sh)
function os_signal_handler (line 2068) | static void os_signal_handler(int sig_num)
function JSValue (line 2077) | static JSValue js_os_signal(JSContext *ctx, JSValueConst this_val,
function get_time_ms (line 2125) | static int64_t get_time_ms(void)
function get_time_ns (line 2132) | static int64_t get_time_ns(void)
function get_time_ms (line 2140) | static int64_t get_time_ms(void)
function get_time_ns (line 2147) | static int64_t get_time_ns(void)
function JSValue (line 2155) | static JSValue js_os_now(JSContext *ctx, JSValue this_val,
function free_timer (line 2161) | static void free_timer(JSRuntime *rt, JSOSTimer *th)
function JSValue (line 2168) | static JSValue js_os_setTimeout(JSContext *ctx, JSValueConst this_val,
function JSOSTimer (line 2196) | static JSOSTimer *find_timer_by_id(JSThreadState *ts, int timer_id)
function JSValue (line 2209) | static JSValue js_os_clearTimeout(JSContext *ctx, JSValueConst this_val,
function JSValue (line 2227) | static JSValue js_os_sleepAsync(JSContext *ctx, JSValueConst this_val,
function call_handler (line 2258) | static void call_handler(JSContext *ctx, JSValueConst func)
function js_waker_init (line 2275) | static int js_waker_init(JSWaker *w)
function js_waker_signal (line 2281) | static void js_waker_signal(JSWaker *w)
function js_waker_clear (line 2286) | static void js_waker_clear(JSWaker *w)
function js_waker_close (line 2291) | static void js_waker_close(JSWaker *w)
function js_waker_init (line 2299) | static int js_waker_init(JSWaker *w)
function js_waker_signal (line 2310) | static void js_waker_signal(JSWaker *w)
function js_waker_clear (line 2323) | static void js_waker_clear(JSWaker *w)
function js_waker_close (line 2337) | static void js_waker_close(JSWaker *w)
function handle_posted_message (line 2350) | static int handle_posted_message(JSRuntime *rt, JSContext *ctx,
function handle_posted_message (line 2406) | static int handle_posted_message(JSRuntime *rt, JSContext *ctx,
function js_os_poll (line 2415) | static int js_os_poll(JSContext *ctx)
function js_os_poll (line 2510) | static int js_os_poll(JSContext *ctx)
function JSValue (line 2623) | static JSValue make_obj_error(JSContext *ctx,
function JSValue (line 2640) | static JSValue make_string_error(JSContext *ctx,
function JSValue (line 2648) | static JSValue js_os_getcwd(JSContext *ctx, JSValueConst this_val,
function JSValue (line 2663) | static JSValue js_os_chdir(JSContext *ctx, JSValueConst this_val,
function JSValue (line 2677) | static JSValue js_os_mkdir(JSContext *ctx, JSValueConst this_val,
function JSValue (line 2703) | static JSValue js_os_readdir(JSContext *ctx, JSValueConst this_val,
function timespec_to_ms (line 2747) | static int64_t timespec_to_ms(const struct timespec *tv)
function JSValue (line 2754) | static JSValue js_os_stat(JSContext *ctx, JSValueConst this_val,
function ms_to_timeval (line 2849) | static void ms_to_timeval(struct timeval *tv, uint64_t v)
function JSValue (line 2856) | static JSValue js_os_utimes(JSContext *ctx, JSValueConst this_val,
function JSValue (line 2890) | static JSValue js_os_sleep(JSContext *ctx, JSValueConst this_val,
function JSValue (line 2932) | static JSValue js_os_realpath(JSContext *ctx, JSValueConst this_val,
function JSValue (line 2954) | static JSValue js_os_symlink(JSContext *ctx, JSValueConst this_val,
function JSValue (line 2975) | static JSValue js_os_readlink(JSContext *ctx, JSValueConst this_val,
function my_execvpe (line 3056) | static int my_execvpe(const char *filename, char **argv, char **envp)
function JSValue (line 3112) | static JSValue js_os_exec(JSContext *ctx, JSValueConst this_val,
function JSValue (line 3328) | static JSValue js_os_getpid(JSContext *ctx, JSValueConst this_val,
function JSValue (line 3335) | static JSValue js_os_waitpid(JSContext *ctx, JSValueConst this_val,
function JSValue (line 3363) | static JSValue js_os_pipe(JSContext *ctx, JSValueConst this_val,
function JSValue (line 3383) | static JSValue js_os_kill(JSContext *ctx, JSValueConst this_val,
function JSValue (line 3397) | static JSValue js_os_dup(JSContext *ctx, JSValueConst this_val,
function JSValue (line 3409) | static JSValue js_os_dup2(JSContext *ctx, JSValueConst this_val,
type JSWorkerData (line 3428) | typedef struct {
type WorkerFuncArgs (line 3434) | typedef struct {
type JSSABHeader (line 3441) | typedef struct {
function atomic_add_int (line 3449) | static int atomic_add_int(int *ptr, int v)
function js_sab_free (line 3465) | static void js_sab_free(void *opaque, void *ptr)
function js_sab_dup (line 3477) | static void js_sab_dup(void *opaque, void *ptr)
function JSWorkerMessagePipe (line 3484) | static JSWorkerMessagePipe *js_new_message_pipe(void)
function JSWorkerMessagePipe (line 3501) | static JSWorkerMessagePipe *js_dup_message_pipe(JSWorkerMessagePipe *ps)
function js_free_message (line 3507) | static void js_free_message(JSWorkerMessage *msg)
function js_free_message_pipe (line 3519) | static void js_free_message_pipe(JSWorkerMessagePipe *ps)
function js_free_port (line 3541) | static void js_free_port(JSRuntime *rt, JSWorkerMessageHandler *port)
function js_worker_finalizer (line 3552) | static void js_worker_finalizer(JSRuntime *rt, JSValue val)
function js_worker_mark (line 3563) | static void js_worker_mark(JSRuntime *rt, JSValueConst val,
function JSValue (line 3632) | static JSValue js_worker_ctor_internal(JSContext *ctx, JSValueConst new_...
function JSValue (line 3664) | static JSValue js_worker_ctor(JSContext *ctx, JSValueConst new_target,
function JSValue (line 3747) | static JSValue js_worker_postMessage(JSContext *ctx, JSValueConst this_val,
function JSValue (line 3815) | static JSValue js_worker_set_onmessage(JSContext *ctx, JSValueConst this...
function JSValue (line 3850) | static JSValue js_worker_get_onmessage(JSContext *ctx, JSValueConst this...
function js_std_set_worker_new_context_func (line 3871) | void js_std_set_worker_new_context_func(JSContext *(*func)(JSRuntime *rt))
function js_os_init (line 3975) | static int js_os_init(JSContext *ctx, JSModuleDef *m)
function JSModuleDef (line 4011) | JSModuleDef *js_init_module_os(JSContext *ctx, const char *module_name)
function JSValue (line 4026) | static JSValue js_print(JSContext *ctx, JSValueConst this_val,
function JSValue (line 4052) | static JSValue js_console_log(JSContext *ctx, JSValueConst this_val,
function js_std_add_helpers (line 4061) | void js_std_add_helpers(JSContext *ctx, int argc, char **argv)
function js_std_init_handlers (line 4096) | void js_std_init_handlers(JSRuntime *rt)
function js_std_free_handlers (line 4128) | void js_std_free_handlers(JSRuntime *rt)
function js_std_dump_error1 (line 4171) | static void js_std_dump_error1(JSContext *ctx, JSValueConst exception_val)
function js_std_dump_error (line 4177) | void js_std_dump_error(JSContext *ctx)
function JSRejectedPromiseEntry (line 4186) | static JSRejectedPromiseEntry *find_rejected_promise(JSContext *ctx, JST...
function js_std_promise_rejection_tracker (line 4199) | void js_std_promise_rejection_tracker(JSContext *ctx, JSValueConst promise,
function js_std_promise_rejection_check (line 4234) | static void js_std_promise_rejection_check(JSContext *ctx)
function js_std_loop (line 4251) | void js_std_loop(JSContext *ctx)
function JSValue (line 4276) | JSValue js_std_await(JSContext *ctx, JSValue obj)
function js_std_eval_binary (line 4312) | void js_std_eval_binary(JSContext *ctx, const uint8_t *buf, size_t buf_len,
function js_std_eval_binary_json_module (line 4345) | void js_std_eval_binary_json_module(JSContext *ctx,
FILE: quickjs.c
type JSErrorEnum (line 192) | typedef enum JSErrorEnum {
type JSShape (line 221) | typedef struct JSShape JSShape;
type JSString (line 222) | typedef struct JSString JSString;
type JSAtomStruct (line 223) | typedef struct JSString JSAtomStruct;
type JSObject (line 224) | typedef struct JSObject JSObject;
type JSGCPhaseEnum (line 230) | typedef enum {
type OPCodeEnum (line 236) | typedef enum OPCodeEnum OPCodeEnum;
type JSRuntime (line 238) | struct JSRuntime {
type JSClass (line 313) | struct JSClass {
type JSStackFrame (line 327) | typedef struct JSStackFrame {
type JSGCObjectTypeEnum (line 342) | typedef enum {
type JSGCObjectHeader (line 355) | struct JSGCObjectHeader {
type JSWeakRefHeaderTypeEnum (line 365) | typedef enum {
type JSWeakRefHeader (line 371) | typedef struct {
type JSVarRef (line 376) | typedef struct JSVarRef {
type js_slimb_t (line 402) | typedef int32_t js_slimb_t;
type js_limb_t (line 403) | typedef uint32_t js_limb_t;
type js_sdlimb_t (line 404) | typedef int64_t js_sdlimb_t;
type js_dlimb_t (line 405) | typedef uint64_t js_dlimb_t;
type __int128 (line 411) | typedef __int128 int128_t;
type uint128_t (line 412) | typedef unsigned __int128 uint128_t;
type js_slimb_t (line 413) | typedef int64_t js_slimb_t;
type js_limb_t (line 414) | typedef uint64_t js_limb_t;
type int128_t (line 415) | typedef int128_t js_sdlimb_t;
type uint128_t (line 416) | typedef uint128_t js_dlimb_t;
type JSBigInt (line 422) | typedef struct JSBigInt {
type JSBigIntBuf (line 431) | typedef struct {
type JSAutoInitIDEnum (line 437) | typedef enum {
type JSContext (line 447) | struct JSContext {
type JSFloat64Union (line 494) | typedef union JSFloat64Union {
type JSAtomKindEnum (line 507) | typedef enum {
type JSString (line 516) | struct JSString {
type JSStringRope (line 535) | typedef struct JSStringRope {
type JSClosureTypeEnum (line 546) | typedef enum {
type JSClosureVar (line 559) | typedef struct JSClosureVar {
type JSVarKindEnum (line 573) | typedef enum {
type JSBytecodeVarDef (line 589) | typedef struct JSBytecodeVarDef {
type JSFunctionKindEnum (line 613) | typedef enum JSFunctionKindEnum {
type JSFunctionBytecode (line 620) | typedef struct JSFunctionBytecode {
type JSBoundFunction (line 661) | typedef struct JSBoundFunction {
type JSIteratorKindEnum (line 668) | typedef enum JSIteratorKindEnum {
type JSForInIterator (line 674) | typedef struct JSForInIterator {
type JSRegExp (line 683) | typedef struct JSRegExp {
type JSProxyData (line 688) | typedef struct JSProxyData {
type JSArrayBuffer (line 695) | typedef struct JSArrayBuffer {
type JSTypedArray (line 706) | typedef struct JSTypedArray {
type JSGlobalObject (line 715) | typedef struct JSGlobalObject {
type JSAsyncFunctionState (line 719) | typedef struct JSAsyncFunctionState {
type JSOverloadableOperatorEnum (line 731) | typedef enum {
type JSBinaryOperatorDefEntry (line 759) | typedef struct {
type JSBinaryOperatorDef (line 764) | typedef struct {
type JSOperatorSetData (line 769) | typedef struct {
type JSReqModuleEntry (line 778) | typedef struct JSReqModuleEntry {
type JSExportTypeEnum (line 784) | typedef enum JSExportTypeEnum {
type JSExportEntry (line 789) | typedef struct JSExportEntry {
type JSStarExportEntry (line 803) | typedef struct JSStarExportEntry {
type JSImportEntry (line 807) | typedef struct JSImportEntry {
type JSModuleStatus (line 814) | typedef enum {
type JSModuleDef (line 823) | struct JSModuleDef {
type JSJobEntry (line 874) | typedef struct JSJobEntry {
type JSProperty (line 882) | typedef struct JSProperty {
type JSShapeProperty (line 903) | typedef struct JSShapeProperty {
type JSShape (line 909) | struct JSShape {
type JSObject (line 926) | struct JSObject {
type JSMapRecord (line 1021) | typedef struct JSMapRecord {
type JSMapState (line 1030) | typedef struct JSMapState {
type OPCodeFormat (line 1058) | typedef enum OPCodeFormat {
type JSStrictEqModeEnum (line 1204) | typedef enum JSStrictEqModeEnum {
function js_trigger_gc (line 1354) | static void js_trigger_gc(JSRuntime *rt, size_t size)
function js_malloc_usable_size_unknown (line 1374) | static size_t js_malloc_usable_size_unknown(const void *ptr)
function js_free_rt (line 1384) | void js_free_rt(JSRuntime *rt, void *ptr)
function js_malloc_usable_size_rt (line 1394) | size_t js_malloc_usable_size_rt(JSRuntime *rt, const void *ptr)
function js_free (line 1432) | void js_free(JSContext *ctx, void *ptr)
function js_malloc_usable_size (line 1465) | size_t js_malloc_usable_size(JSContext *ctx, const void *ptr)
function no_inline (line 1487) | static no_inline int js_realloc_array(JSContext *ctx, void **parray,
function js_resize_array (line 1505) | static inline int js_resize_array(JSContext *ctx, void **parray, int ele...
function js_dbuf_init (line 1514) | static inline void js_dbuf_init(JSContext *ctx, DynBuf *s)
function js_dbuf_bytecode_init (line 1531) | static inline void js_dbuf_bytecode_init(JSContext *ctx, DynBuf *s)
function is_digit (line 1536) | static inline int is_digit(int c) {
function string_get (line 1540) | static inline int string_get(const JSString *p, int idx) {
type JSClassShortDef (line 1544) | typedef struct JSClassShortDef {
function init_class_range (line 1602) | static int init_class_range(JSRuntime *rt, JSClassShortDef const *tab,
function js_get_stack_pointer (line 1621) | static inline uintptr_t js_get_stack_pointer(void)
function BOOL (line 1626) | static inline BOOL js_check_stack_overflow(JSRuntime *rt, size_t alloca_...
function js_get_stack_pointer (line 1632) | static inline uintptr_t js_get_stack_pointer(void)
function BOOL (line 1637) | static inline BOOL js_check_stack_overflow(JSRuntime *rt, size_t alloca_...
function JSRuntime (line 1645) | JSRuntime *JS_NewRuntime2(const JSMallocFunctions *mf, void *opaque)
function JS_SetRuntimeOpaque (line 1712) | void JS_SetRuntimeOpaque(JSRuntime *rt, void *opaque)
function js_def_malloc_usable_size (line 1718) | static size_t js_def_malloc_usable_size(const void *ptr)
function js_def_free (line 1753) | static void js_def_free(JSMallocState *s, void *ptr)
function JSRuntime (line 1797) | JSRuntime *JS_NewRuntime(void)
function JS_SetMemoryLimit (line 1802) | void JS_SetMemoryLimit(JSRuntime *rt, size_t limit)
function JS_SetGCThreshold (line 1808) | void JS_SetGCThreshold(JSRuntime *rt, size_t gc_threshold)
function JS_SetInterruptHandler (line 1817) | void JS_SetInterruptHandler(JSRuntime *rt, JSInterruptHandler *cb, void ...
function JS_SetCanBlock (line 1823) | void JS_SetCanBlock(JSRuntime *rt, BOOL can_block)
function JS_SetSharedArrayBufferFunctions (line 1828) | void JS_SetSharedArrayBufferFunctions(JSRuntime *rt,
function JS_SetStripInfo (line 1834) | void JS_SetStripInfo(JSRuntime *rt, int flags)
function JS_GetStripInfo (line 1839) | int JS_GetStripInfo(JSRuntime *rt)
function JS_EnqueueJob (line 1845) | int JS_EnqueueJob(JSContext *ctx, JSJobFunc *job_func,
function BOOL (line 1865) | BOOL JS_IsJobPending(JSRuntime *rt)
function JS_ExecutePendingJob (line 1875) | int JS_ExecutePendingJob(JSRuntime *rt, JSContext **pctx)
function atom_get_free (line 1911) | static inline uint32_t atom_get_free(const JSAtomStruct *p)
function BOOL (line 1916) | static inline BOOL atom_is_free(const JSAtomStruct *p)
function JSAtomStruct (line 1921) | static inline JSAtomStruct *atom_set_free(uint32_t v)
function JSString (line 1927) | static JSString *js_alloc_string_rt(JSRuntime *rt, int max_len, int is_w...
function JSString (line 1945) | static JSString *js_alloc_string(JSContext *ctx, int max_len, int is_wid...
function js_free_string (line 1957) | static inline void js_free_string(JSRuntime *rt, JSString *str)
function JS_SetRuntimeInfo (line 1971) | void JS_SetRuntimeInfo(JSRuntime *rt, const char *s)
function JS_FreeRuntime (line 1977) | void JS_FreeRuntime(JSRuntime *rt)
function JSContext (line 2165) | JSContext *JS_NewContextRaw(JSRuntime *rt)
function JSContext (line 2199) | JSContext *JS_NewContext(JSRuntime *rt)
function JS_SetContextOpaque (line 2229) | void JS_SetContextOpaque(JSContext *ctx, void *opaque)
function set_value (line 2236) | static inline void set_value(JSContext *ctx, JSValue *pval, JSValue new_...
function JS_SetClassProto (line 2244) | void JS_SetClassProto(JSContext *ctx, JSClassID class_id, JSValue obj)
function JSValue (line 2251) | JSValue JS_GetClassProto(JSContext *ctx, JSClassID class_id)
type JSFreeModuleEnum (line 2258) | typedef enum JSFreeModuleEnum {
function js_free_modules (line 2264) | static void js_free_modules(JSContext *ctx, JSFreeModuleEnum flag)
function JSContext (line 2282) | JSContext *JS_DupContext(JSContext *ctx)
function JS_MarkContext (line 2289) | static void JS_MarkContext(JSRuntime *rt, JSContext *ctx,
function JS_FreeContext (line 2337) | void JS_FreeContext(JSContext *ctx)
function JSRuntime (line 2408) | JSRuntime *JS_GetRuntime(JSContext *ctx)
function update_stack_limit (line 2413) | static void update_stack_limit(JSRuntime *rt)
function JS_SetMaxStackSize (line 2422) | void JS_SetMaxStackSize(JSRuntime *rt, size_t stack_size)
function JS_UpdateStackTop (line 2428) | void JS_UpdateStackTop(JSRuntime *rt)
function BOOL (line 2434) | static inline BOOL is_strict_mode(JSContext *ctx)
function BOOL (line 2449) | static inline BOOL __JS_AtomIsConst(JSAtom v)
function BOOL (line 2458) | static inline BOOL __JS_AtomIsTaggedInt(JSAtom v)
function JSAtom (line 2463) | static inline JSAtom __JS_AtomFromUInt32(uint32_t v)
function __JS_AtomToUInt32 (line 2468) | static inline uint32_t __JS_AtomToUInt32(JSAtom atom)
function is_num (line 2473) | static inline int is_num(int c)
function BOOL (line 2479) | static inline BOOL is_num_string(uint32_t *pval, const JSString *p)
function hash_string8 (line 2514) | static inline uint32_t hash_string8(const uint8_t *str, size_t len, uint...
function hash_string16 (line 2523) | static inline uint32_t hash_string16(const uint16_t *str,
function hash_string (line 2533) | static uint32_t hash_string(const JSString *str, uint32_t h)
function hash_string_rope (line 2542) | static uint32_t hash_string_rope(JSValueConst val, uint32_t h)
function __maybe_unused (line 2553) | static __maybe_unused void JS_DumpChar(FILE *fo, int c, int sep)
function __maybe_unused (line 2568) | static __maybe_unused void JS_DumpString(JSRuntime *rt, const JSString *p)
function __maybe_unused (line 2585) | static __maybe_unused void JS_DumpAtoms(JSRuntime *rt)
function JS_ResizeAtomHash (line 2620) | static int JS_ResizeAtomHash(JSRuntime *rt, int new_hash_size)
function JS_InitAtoms (line 2650) | static int JS_InitAtoms(JSRuntime *rt)
function JSAtom (line 2679) | static JSAtom JS_DupAtomRT(JSRuntime *rt, JSAtom v)
function JSAtom (line 2690) | JSAtom JS_DupAtom(JSContext *ctx, JSAtom v)
function JSAtomKindEnum (line 2703) | static JSAtomKindEnum JS_AtomGetKind(JSContext *ctx, JSAtom v)
function BOOL (line 2727) | static BOOL JS_AtomIsString(JSContext *ctx, JSAtom v)
function JSAtom (line 2732) | static JSAtom js_get_atom_index(JSRuntime *rt, JSAtomStruct *p)
function JSAtom (line 2751) | static JSAtom __JS_NewAtom(JSRuntime *rt, JSString *str, int atom_type)
function JSAtom (line 2907) | static JSAtom __JS_NewAtomInit(JSRuntime *rt, const char *str, int len,
function JSAtom (line 2920) | static JSAtom __JS_FindAtom(JSRuntime *rt, const char *str, size_t len,
function JS_FreeAtomStruct (line 2946) | static void JS_FreeAtomStruct(JSRuntime *rt, JSAtomStruct *p)
function __JS_FreeAtom (line 2995) | static void __JS_FreeAtom(JSRuntime *rt, uint32_t i)
function JSAtom (line 3006) | static JSAtom JS_NewAtomStr(JSContext *ctx, JSString *p)
function count_ascii (line 3021) | static size_t count_ascii(const uint8_t *buf, size_t len)
function JSAtom (line 3032) | JSAtom JS_NewAtomLen(JSContext *ctx, const char *str, size_t len)
function JSAtom (line 3049) | JSAtom JS_NewAtom(JSContext *ctx, const char *str)
function JSAtom (line 3054) | JSAtom JS_NewAtomUInt32(JSContext *ctx, uint32_t n)
function JSAtom (line 3071) | static JSAtom JS_NewAtomInt64(JSContext *ctx, int64_t n)
function JSValue (line 3089) | static JSValue JS_NewSymbol(JSContext *ctx, JSString *p, int atom_type)
function JSValue (line 3100) | static JSValue JS_NewSymbolFromAtom(JSContext *ctx, JSAtom descr,
function JSValue (line 3167) | static JSValue __JS_AtomToValue(JSContext *ctx, JSAtom atom, BOOL force_...
function JSValue (line 3194) | JSValue JS_AtomToValue(JSContext *ctx, JSAtom atom)
function JSValue (line 3199) | JSValue JS_AtomToString(JSContext *ctx, JSAtom atom)
function BOOL (line 3206) | static BOOL JS_AtomIsArrayIndex(JSContext *ctx, uint32_t *pval, JSAtom a...
function JSValue (line 3232) | static JSValue JS_AtomIsNumericIndex1(JSContext *ctx, JSAtom atom)
function JS_AtomIsNumericIndex (line 3284) | static int JS_AtomIsNumericIndex(JSContext *ctx, JSAtom atom)
function JS_FreeAtom (line 3296) | void JS_FreeAtom(JSContext *ctx, JSAtom v)
function JS_FreeAtomRT (line 3302) | void JS_FreeAtomRT(JSRuntime *rt, JSAtom v)
function BOOL (line 3309) | static BOOL JS_AtomSymbolHasDescription(JSContext *ctx, JSAtom v)
function JSAtom (line 3342) | static JSAtom js_atom_concat_str(JSContext *ctx, JSAtom name, const char...
function JSAtom (line 3374) | static JSAtom js_atom_concat_num(JSContext *ctx, JSAtom name, uint32_t n)
function BOOL (line 3383) | static inline BOOL JS_IsEmptyString(JSValueConst v)
function JSClassID (line 3395) | JSClassID JS_NewClassID(JSClassID *pclass_id)
function JSClassID (line 3412) | JSClassID JS_GetClassID(JSValue v)
function BOOL (line 3421) | BOOL JS_IsRegisteredClass(JSRuntime *rt, JSClassID class_id)
function JS_NewClass1 (line 3429) | static int JS_NewClass1(JSRuntime *rt, JSClassID class_id,
function JS_NewClass (line 3478) | int JS_NewClass(JSRuntime *rt, JSClassID class_id, const JSClassDef *cla...
function JSValue (line 3495) | static JSValue js_new_string8_len(JSContext *ctx, const char *buf, int len)
function JSValue (line 3510) | static JSValue js_new_string8(JSContext *ctx, const char *buf)
function JSValue (line 3515) | static JSValue js_new_string16_len(JSContext *ctx, const uint16_t *buf, ...
function JSValue (line 3525) | static JSValue js_new_string_char(JSContext *ctx, uint16_t c)
function JSValue (line 3536) | static JSValue js_sub_string(JSContext *ctx, JSString *p, int start, int...
type StringBuffer (line 3565) | typedef struct StringBuffer {
function string_buffer_init2 (line 3578) | static int string_buffer_init2(JSContext *ctx, StringBuffer *s, int size,
function string_buffer_init (line 3598) | static inline int string_buffer_init(JSContext *ctx, StringBuffer *s, in...
function string_buffer_free (line 3603) | static void string_buffer_free(StringBuffer *s)
function string_buffer_set_error (line 3609) | static int string_buffer_set_error(StringBuffer *s)
function no_inline (line 3618) | static no_inline int string_buffer_widen(StringBuffer *s, int size)
function no_inline (line 3640) | static no_inline int string_buffer_realloc(StringBuffer *s, int new_len,...
function no_inline (line 3667) | static no_inline int string_buffer_putc16_slow(StringBuffer *s, uint32_t c)
function string_buffer_putc8 (line 3686) | static int string_buffer_putc8(StringBuffer *s, uint32_t c)
function string_buffer_putc16 (line 3701) | static int string_buffer_putc16(StringBuffer *s, uint32_t c)
function string_buffer_putc_slow (line 3715) | static int string_buffer_putc_slow(StringBuffer *s, uint32_t c)
function string_buffer_putc (line 3727) | static inline int string_buffer_putc(StringBuffer *s, uint32_t c)
function string_getc (line 3747) | static int string_getc(const JSString *p, int *pidx)
function string_buffer_write8 (line 3767) | static int string_buffer_write8(StringBuffer *s, const uint8_t *p, int len)
function string_buffer_write16 (line 3787) | static int string_buffer_write16(StringBuffer *s, const uint16_t *p, int...
function string_buffer_puts8 (line 3814) | static int string_buffer_puts8(StringBuffer *s, const char *str)
function string_buffer_concat (line 3819) | static int string_buffer_concat(StringBuffer *s, const JSString *p,
function string_buffer_concat_value (line 3830) | static int string_buffer_concat_value(StringBuffer *s, JSValueConst v)
function string_buffer_concat_value_free (line 3861) | static int string_buffer_concat_value_free(StringBuffer *s, JSValue v)
function string_buffer_fill (line 3882) | static int string_buffer_fill(StringBuffer *s, int c, int count)
function JSValue (line 3896) | static JSValue string_buffer_end(StringBuffer *s)
function JSValue (line 3929) | JSValue JS_NewStringLen(JSContext *ctx, const char *buf, size_t buf_len)
function JSValue (line 3986) | static JSValue JS_ConcatString3(JSContext *ctx, const char *str1,
function JSValue (line 4017) | JSValue JS_NewAtomString(JSContext *ctx, const char *str)
function JS_FreeCString (line 4126) | void JS_FreeCString(JSContext *ctx, const char *ptr)
function memcmp16_8 (line 4136) | static int memcmp16_8(const uint16_t *src1, const uint8_t *src2, int len)
function memcmp16 (line 4147) | static int memcmp16(const uint16_t *src1, const uint16_t *src2, int len)
function js_string_memcmp (line 4158) | static int js_string_memcmp(const JSString *p1, int pos1, const JSString...
function BOOL (line 4177) | static BOOL js_string_eq(JSContext *ctx,
function js_string_compare (line 4188) | static int js_string_compare(JSContext *ctx,
function copy_str16 (line 4205) | static void copy_str16(uint16_t *dst, const JSString *p, int offset, int...
function JSValue (line 4218) | static JSValue JS_ConcatString1(JSContext *ctx,
function BOOL (line 4243) | static BOOL JS_ConcatStringInPlace(JSContext *ctx, JSString *p1, JSValue...
function JSValue (line 4279) | static JSValue JS_ConcatString2(JSContext *ctx, JSValue op1, JSValue op2)
function string_rope_get (line 4296) | static int string_rope_get(JSValueConst val, uint32_t idx)
type JSStringRopeIter (line 4314) | typedef struct {
function string_rope_iter_init (line 4319) | static void string_rope_iter_init(JSStringRopeIter *s, JSValueConst val)
function JSString (line 4326) | static JSString *string_rope_iter_next(JSStringRopeIter *s)
function string_rope_get_len (line 4344) | static uint32_t string_rope_get_len(JSValueConst val)
function js_string_rope_compare (line 4352) | static int js_string_rope_compare(JSContext *ctx, JSValueConst op1,
function JSValue (line 4403) | static JSValue js_linearize_string_rope(JSContext *ctx, JSValue rope)
function JSValue (line 4440) | static JSValue js_new_string_rope(JSContext *ctx, JSValue op1, JSValue op2)
function js_rebalancee_string_rope_rec (line 4521) | static int js_rebalancee_string_rope_rec(JSContext *ctx, JSValue *buckets,
function JSValue (line 4577) | static JSValue js_rebalancee_string_rope(JSContext *ctx, JSValueConst rope)
function JSValue (line 4614) | static JSValue JS_ConcatString(JSContext *ctx, JSValue op1, JSValue op2)
function get_shape_size (line 4693) | static inline size_t get_shape_size(size_t hash_size, size_t prop_size)
function JSShape (line 4699) | static inline JSShape *get_shape_from_alloc(void *sh_alloc, size_t hash_...
function JSShapeProperty (line 4714) | static inline JSShapeProperty *get_shape_prop(JSShape *sh)
function init_shape_hash (line 4719) | static int init_shape_hash(JSRuntime *rt)
function shape_hash (line 4732) | static uint32_t shape_hash(uint32_t h, uint32_t val)
function get_shape_hash (line 4738) | static uint32_t get_shape_hash(uint32_t h, int hash_bits)
function shape_initial_hash (line 4743) | static uint32_t shape_initial_hash(JSObject *proto)
function resize_shape_hash (line 4752) | static int resize_shape_hash(JSRuntime *rt, int new_shape_hash_bits)
function js_shape_hash_link (line 4778) | static void js_shape_hash_link(JSRuntime *rt, JSShape *sh)
function js_shape_hash_unlink (line 4787) | static void js_shape_hash_unlink(JSRuntime *rt, JSShape *sh)
function JSShape (line 4801) | static inline JSShape *js_new_shape_nohash(JSContext *ctx, JSObject *proto,
function no_inline (line 4828) | static no_inline JSShape *js_new_shape2(JSContext *ctx, JSObject *proto,
function JSShape (line 4850) | static JSShape *js_new_shape(JSContext *ctx, JSObject *proto)
function JSShape (line 4858) | static JSShape *js_clone_shape(JSContext *ctx, JSShape *sh1)
function JSShape (line 4886) | static JSShape *js_dup_shape(JSShape *sh)
function js_free_shape0 (line 4892) | static void js_free_shape0(JSRuntime *rt, JSShape *sh)
function js_free_shape (line 4912) | static void js_free_shape(JSRuntime *rt, JSShape *sh)
function js_free_shape_null (line 4919) | static void js_free_shape_null(JSRuntime *rt, JSShape *sh)
function no_inline (line 4926) | static no_inline int resize_properties(JSContext *ctx, JSShape **psh,
function compact_properties (line 4988) | static int compact_properties(JSContext *ctx, JSObject *p)
function add_shape_property (line 5055) | static int add_shape_property(JSContext *ctx, JSShape **psh,
function JSShape (line 5100) | static JSShape *find_hashed_shape_proto(JSRuntime *rt, JSObject *proto)
function JSShape (line 5119) | static JSShape *find_hashed_shape_prop(JSRuntime *rt, JSShape *sh,
function __maybe_unused (line 5150) | static __maybe_unused void JS_DumpShape(JSRuntime *rt, int i, JSShape *sh)
function __maybe_unused (line 5166) | static __maybe_unused void JS_DumpShapes(JSRuntime *rt)
function JSValue (line 5197) | static JSValue JS_NewObjectFromShape(JSContext *ctx, JSShape *sh, JSClas...
function JSObject (line 5318) | static JSObject *get_proto_obj(JSValueConst proto_val)
function JSValue (line 5327) | JSValue JS_NewObjectProtoClass(JSContext *ctx, JSValueConst proto_val,
function JSValue (line 5347) | static JSValue JS_NewObjectProtoClassAlloc(JSContext *ctx, JSValueConst ...
function JSValue (line 5369) | static JSValue JS_GetObjectData(JSContext *ctx, JSValueConst obj)
function JS_SetObjectData (line 5389) | static int JS_SetObjectData(JSContext *ctx, JSValueConst obj, JSValue val)
function JSValue (line 5415) | JSValue JS_NewObjectClass(JSContext *ctx, int class_id)
function JSValue (line 5420) | JSValue JS_NewObjectProto(JSContext *ctx, JSValueConst proto)
function JSValue (line 5425) | JSValue JS_NewArray(JSContext *ctx)
function JSValue (line 5431) | JSValue JS_NewObject(JSContext *ctx)
function js_function_set_properties (line 5437) | static void js_function_set_properties(JSContext *ctx, JSValueConst func...
function BOOL (line 5447) | static BOOL js_class_has_bytecode(JSClassID class_id)
function JSFunctionBytecode (line 5456) | static JSFunctionBytecode *JS_GetFunctionBytecode(JSValueConst val)
function js_method_set_home_object (line 5467) | static void js_method_set_home_object(JSContext *ctx, JSValueConst func_...
function JSValue (line 5492) | static JSValue js_get_function_name(JSContext *ctx, JSAtom name)
function js_method_set_properties (line 5507) | static int js_method_set_properties(JSContext *ctx, JSValueConst func_obj,
function JSValue (line 5528) | static JSValue JS_NewCFunction3(JSContext *ctx, JSCFunction *func,
function JSValue (line 5567) | JSValue JS_NewCFunction2(JSContext *ctx, JSCFunction *func,
type JSCFunctionDataRecord (line 5575) | typedef struct JSCFunctionDataRecord {
function js_c_function_data_finalizer (line 5583) | static void js_c_function_data_finalizer(JSRuntime *rt, JSValue val)
function js_c_function_data_mark (line 5596) | static void js_c_function_data_mark(JSRuntime *rt, JSValueConst val,
function JSValue (line 5609) | static JSValue js_c_function_data_call(JSContext *ctx, JSValueConst func...
function JSValue (line 5631) | JSValue JS_NewCFunctionData(JSContext *ctx, JSCFunctionData *func,
function JSContext (line 5660) | static JSContext *js_autoinit_get_realm(JSProperty *pr)
function JSAutoInitIDEnum (line 5665) | static JSAutoInitIDEnum js_autoinit_get_id(JSProperty *pr)
function js_autoinit_free (line 5670) | static void js_autoinit_free(JSRuntime *rt, JSProperty *pr)
function js_autoinit_mark (line 5675) | static void js_autoinit_mark(JSRuntime *rt, JSProperty *pr,
function free_property (line 5681) | static void free_property(JSRuntime *rt, JSProperty *pr, int prop_flags)
function force_inline (line 5699) | static force_inline JSShapeProperty *find_own_property1(JSObject *p,
function force_inline (line 5719) | static force_inline JSShapeProperty *find_own_property(JSProperty **ppr,
function set_cycle_flag (line 5744) | static void set_cycle_flag(JSContext *ctx, JSValueConst obj)
function free_var_ref (line 5748) | static void free_var_ref(JSRuntime *rt, JSVarRef *var_ref)
function js_array_finalizer (line 5770) | static void js_array_finalizer(JSRuntime *rt, JSValue val)
function js_array_mark (line 5781) | static void js_array_mark(JSRuntime *rt, JSValueConst val,
function js_object_data_finalizer (line 5792) | static void js_object_data_finalizer(JSRuntime *rt, JSValue val)
function js_object_data_mark (line 5799) | static void js_object_data_mark(JSRuntime *rt, JSValueConst val,
function js_c_function_finalizer (line 5806) | static void js_c_function_finalizer(JSRuntime *rt, JSValue val)
function js_c_function_mark (line 5814) | static void js_c_function_mark(JSRuntime *rt, JSValueConst val,
function js_bytecode_function_finalizer (line 5823) | static void js_bytecode_function_finalizer(JSRuntime *rt, JSValue val)
function js_bytecode_function_mark (line 5846) | static void js_bytecode_function_mark(JSRuntime *rt, JSValueConst val,
function js_bound_function_finalizer (line 5873) | static void js_bound_function_finalizer(JSRuntime *rt, JSValue val)
function js_bound_function_mark (line 5887) | static void js_bound_function_mark(JSRuntime *rt, JSValueConst val,
function js_for_in_iterator_finalizer (line 5900) | static void js_for_in_iterator_finalizer(JSRuntime *rt, JSValue val)
function js_for_in_iterator_mark (line 5916) | static void js_for_in_iterator_mark(JSRuntime *rt, JSValueConst val,
function free_object (line 5924) | static void free_object(JSRuntime *rt, JSObject *p)
function free_gc_object (line 5978) | static void free_gc_object(JSRuntime *rt, JSGCObjectHeader *gp)
function free_zero_refcount (line 5998) | static void free_zero_refcount(JSRuntime *rt)
function __JS_FreeValueRT (line 6016) | void __JS_FreeValueRT(JSRuntime *rt, JSValue v)
function __JS_FreeValue (line 6087) | void __JS_FreeValue(JSContext *ctx, JSValue v)
function gc_remove_weak_objects (line 6094) | static void gc_remove_weak_objects(JSRuntime *rt)
function add_gc_object (line 6124) | static void add_gc_object(JSRuntime *rt, JSGCObjectHeader *h,
function remove_gc_object (line 6132) | static void remove_gc_object(JSGCObjectHeader *h)
function JS_MarkValue (line 6137) | void JS_MarkValue(JSRuntime *rt, JSValueConst val, JS_MarkFunc *mark_func)
function mark_children (line 6152) | static void mark_children(JSRuntime *rt, JSGCObjectHeader *gp,
function gc_decref_child (line 6271) | static void gc_decref_child(JSRuntime *rt, JSGCObjectHeader *p)
function gc_decref (line 6281) | static void gc_decref(JSRuntime *rt)
function gc_scan_incref_child (line 6303) | static void gc_scan_incref_child(JSRuntime *rt, JSGCObjectHeader *p)
function gc_scan_incref_child2 (line 6315) | static void gc_scan_incref_child2(JSRuntime *rt, JSGCObjectHeader *p)
function gc_scan (line 6320) | static void gc_scan(JSRuntime *rt)
function gc_free_cycles (line 6340) | static void gc_free_cycles(JSRuntime *rt)
function JS_RunGCInternal (line 6399) | static void JS_RunGCInternal(JSRuntime *rt, BOOL remove_weak_objects)
function JS_RunGC (line 6419) | void JS_RunGC(JSRuntime *rt)
function BOOL (line 6427) | BOOL JS_IsLiveObject(JSRuntime *rt, JSValueConst obj)
type JSMemoryUsage_helper (line 6438) | typedef struct JSMemoryUsage_helper {
function compute_jsstring_size (line 6451) | static void compute_jsstring_size(JSString *str, JSMemoryUsage_helper *hp)
function compute_bytecode_size (line 6461) | static void compute_bytecode_size(JSFunctionBytecode *b, JSMemoryUsage_h...
function compute_value_size (line 6500) | static void compute_value_size(JSValueConst val, JSMemoryUsage_helper *hp)
function JS_ComputeMemoryUsage (line 6512) | void JS_ComputeMemoryUsage(JSRuntime *rt, JSMemoryUsage *s)
function JS_DumpMemoryUsage (line 6808) | void JS_DumpMemoryUsage(FILE *fp, const JSMemoryUsage *s, JSRuntime *rt)
function JSValue (line 6933) | JSValue JS_GetGlobalObject(JSContext *ctx)
function JSValue (line 6939) | JSValue JS_Throw(JSContext *ctx, JSValue obj)
function JSValue (line 6949) | JSValue JS_GetException(JSContext *ctx)
function JS_BOOL (line 6958) | JS_BOOL JS_HasException(JSContext *ctx)
function dbuf_put_leb128 (line 6963) | static void dbuf_put_leb128(DynBuf *s, uint32_t v)
function dbuf_put_sleb128 (line 6978) | static void dbuf_put_sleb128(DynBuf *s, int32_t v1)
function get_leb128 (line 6984) | static int get_leb128(uint32_t *pval, const uint8_t *buf,
function get_sleb128 (line 7004) | static int get_sleb128(int32_t *pval, const uint8_t *buf,
function find_line_num (line 7019) | static int find_line_num(JSContext *ctx, JSFunctionBytecode *b,
function build_backtrace (line 7122) | static void build_backtrace(JSContext *ctx, JSValueConst error_obj,
function BOOL (line 7204) | static BOOL is_backtrace_needed(JSContext *ctx, JSValueConst obj)
function JSValue (line 7217) | JSValue JS_NewError(JSContext *ctx)
function JSValue (line 7222) | static JSValue JS_ThrowError2(JSContext *ctx, JSErrorEnum error_num,
function JSValue (line 7246) | static JSValue JS_ThrowError(JSContext *ctx, JSErrorEnum error_num,
function JSValue (line 7260) | JSValue __attribute__((format(printf, 2, 3))) JS_ThrowSyntaxError(JSCont...
function JSValue (line 7271) | JSValue __attribute__((format(printf, 2, 3))) JS_ThrowTypeError(JSContex...
function JS_ThrowTypeErrorOrFalse (line 7282) | static int __attribute__((format(printf, 3, 4))) JS_ThrowTypeErrorOrFals...
function JSValue (line 7298) | static JSValue __attribute__((format(printf, 3, 4))) __JS_ThrowTypeError...
function JSValue (line 7306) | static JSValue __attribute__((format(printf, 3, 4))) __JS_ThrowSyntaxErr...
function JS_ThrowTypeErrorReadOnly (line 7318) | static int JS_ThrowTypeErrorReadOnly(JSContext *ctx, int flags, JSAtom a...
function JSValue (line 7329) | JSValue __attribute__((format(printf, 2, 3))) JS_ThrowReferenceError(JSC...
function JSValue (line 7340) | JSValue __attribute__((format(printf, 2, 3))) JS_ThrowRangeError(JSConte...
function JSValue (line 7351) | JSValue __attribute__((format(printf, 2, 3))) JS_ThrowInternalError(JSCo...
function JSValue (line 7362) | JSValue JS_ThrowOutOfMemory(JSContext *ctx)
function JSValue (line 7373) | static JSValue JS_ThrowStackOverflow(JSContext *ctx)
function JSValue (line 7378) | static JSValue JS_ThrowTypeErrorNotAnObject(JSContext *ctx)
function JSValue (line 7383) | static JSValue JS_ThrowTypeErrorNotAConstructor(JSContext *ctx,
function JSValue (line 7399) | static JSValue JS_ThrowTypeErrorNotASymbol(JSContext *ctx)
function JSValue (line 7404) | static JSValue JS_ThrowReferenceErrorNotDefined(JSContext *ctx, JSAtom n...
function JSValue (line 7411) | static JSValue JS_ThrowReferenceErrorUninitialized(JSContext *ctx, JSAto...
function JSValue (line 7419) | static JSValue JS_ThrowReferenceErrorUninitialized2(JSContext *ctx,
function JSValue (line 7434) | static JSValue JS_ThrowTypeErrorInvalidClass(JSContext *ctx, int class_id)
function JS_ThrowInterrupted (line 7442) | static void JS_ThrowInterrupted(JSContext *ctx)
function __js_poll_interrupts (line 7448) | int __js_poll_interrupts(JSContext *ctx)
function __exception (line 7461) | static inline __exception int js_poll_interrupts(JSContext *ctx)
function JS_SetImmutablePrototype (line 7470) | static void JS_SetImmutablePrototype(JSContext *ctx, JSValueConst obj)
function JS_SetPrototypeInternal (line 7481) | static int JS_SetPrototypeInternal(JSContext *ctx, JSValueConst obj,
function JS_SetPrototype (line 7573) | int JS_SetPrototype(JSContext *ctx, JSValueConst obj, JSValueConst proto...
function JSValueConst (line 7579) | static JSValueConst JS_GetPrototypePrimitive(JSContext *ctx, JSValueCons...
function JSValue (line 7611) | JSValue JS_GetPrototype(JSContext *ctx, JSValueConst obj)
function JSValue (line 7634) | static JSValue JS_GetPrototypeFree(JSContext *ctx, JSValue obj)
function JS_OrdinaryIsInstanceOf (line 7643) | static int JS_OrdinaryIsInstanceOf(JSContext *ctx, JSValueConst val,
function JS_IsInstanceOf (line 7717) | int JS_IsInstanceOf(JSContext *ctx, JSValueConst val, JSValueConst obj)
type JSValue (line 7742) | typedef JSValue JSAutoInitFunc(JSContext *ctx, JSObject *p, JSAtom atom,...
function JS_AutoInitProperty (line 7751) | static int JS_AutoInitProperty(JSContext *ctx, JSObject *p, JSAtom prop,
function JSValue (line 7794) | JSValue JS_GetPropertyInternal(JSContext *ctx, JSValueConst obj,
function JSValue (line 7950) | static JSValue JS_ThrowTypeErrorPrivateNotFound(JSContext *ctx, JSAtom a...
function JS_DefinePrivateField (line 7958) | static int JS_DefinePrivateField(JSContext *ctx, JSValueConst obj,
function JSValue (line 7993) | static JSValue JS_GetPrivateField(JSContext *ctx, JSValueConst obj,
function JS_SetPrivateField (line 8016) | static int JS_SetPrivateField(JSContext *ctx, JSValueConst obj,
function JS_AddBrand (line 8048) | static int JS_AddBrand(JSContext *ctx, JSValueConst obj, JSValueConst ho...
function JS_CheckBrand (line 8099) | static int JS_CheckBrand(JSContext *ctx, JSValueConst obj, JSValueConst ...
function js_string_obj_get_length (line 8136) | static uint32_t js_string_obj_get_length(JSContext *ctx,
function num_keys_cmp (line 8151) | static int num_keys_cmp(const void *p1, const void *p2, void *opaque)
function JS_FreePropertyEnum (line 8170) | void JS_FreePropertyEnum(JSContext *ctx, JSPropertyEnum *tab, uint32_t len)
function JS_GetOwnPropertyNamesInternal (line 8182) | static int __exception JS_GetOwnPropertyNamesInternal(JSContext *ctx,
function JS_GetOwnPropertyNames (line 8387) | int JS_GetOwnPropertyNames(JSContext *ctx, JSPropertyEnum **ptab,
function JS_GetOwnPropertyInternal (line 8401) | static int JS_GetOwnPropertyInternal(JSContext *ctx, JSPropertyDescripto...
function JS_GetOwnProperty (line 8479) | int JS_GetOwnProperty(JSContext *ctx, JSPropertyDescriptor *desc,
function JS_IsExtensible (line 8490) | int JS_IsExtensible(JSContext *ctx, JSValueConst obj)
function JS_PreventExtensions (line 8507) | int JS_PreventExtensions(JSContext *ctx, JSValueConst obj)
function JS_HasProperty (line 8537) | int JS_HasProperty(JSContext *ctx, JSValueConst obj, JSAtom prop)
function JSAtom (line 8580) | static JSAtom js_symbol_to_atom(JSContext *ctx, JSValue val)
function JSAtom (line 8587) | JSAtom JS_ValueToAtom(JSContext *ctx, JSValueConst val)
function JSValue (line 8613) | static JSValue JS_GetPropertyValue(JSContext *ctx, JSValueConst this_obj,
function JSValue (line 8688) | JSValue JS_GetPropertyUint32(JSContext *ctx, JSValueConst this_obj,
function JS_TryGetPropertyInt64 (line 8699) | static int JS_TryGetPropertyInt64(JSContext *ctx, JSValueConst obj, int6...
function JSValue (line 8730) | static JSValue JS_GetPropertyInt64(JSContext *ctx, JSValueConst obj, int...
function JSValue (line 8748) | JSValue JS_GetPropertyStr(JSContext *ctx, JSValueConst this_obj,
function JSProperty (line 8763) | static JSProperty *add_property(JSContext *ctx,
function convert_fast_array_to_array (line 8828) | int convert_fast_array_to_array(JSContext *ctx,
function remove_global_object_property (line 8872) | static int remove_global_object_property(JSContext *ctx, JSObject *p,
function delete_property (line 8895) | static int delete_property(JSContext *ctx, JSObject *p, JSAtom atom)
function call_setter (line 8991) | static int call_setter(JSContext *ctx, JSObject *setter,
function set_array_length (line 9017) | static int set_array_length(JSContext *ctx, JSObject *p, JSValue val,
function expand_fast_array (line 9108) | static int expand_fast_array(JSContext *ctx, JSObject *p, uint32_t new_len)
function add_fast_array_element (line 9126) | static inline int add_fast_array_element(JSContext *ctx, JSObject *p,
function JSValue (line 9159) | static JSValue js_allocate_fast_array(JSContext *ctx, int64_t len)
function JSValue (line 9180) | static JSValue js_create_array(JSContext *ctx, int len, JSValueConst *tab)
function JSValue (line 9204) | static JSValue js_create_array_free(JSContext *ctx, int len, JSValue *tab)
function js_free_desc (line 9231) | static void js_free_desc(JSContext *ctx, JSPropertyDescriptor *desc)
function JS_SetPropertyInternal (line 9242) | int JS_SetPropertyInternal(JSContext *ctx, JSValueConst obj,
function force_inline (line 9514) | static force_inline BOOL can_extend_fast_array(JSObject *p)
function JS_SetPropertyValue (line 9526) | static int JS_SetPropertyValue(JSContext *ctx, JSValueConst this_obj,
function JS_SetPropertyUint32 (line 9651) | int JS_SetPropertyUint32(JSContext *ctx, JSValueConst this_obj,
function JS_SetPropertyInt64 (line 9658) | int JS_SetPropertyInt64(JSContext *ctx, JSValueConst this_obj,
function JS_SetPropertyStr (line 9679) | int JS_SetPropertyStr(JSContext *ctx, JSValueConst this_obj,
function get_prop_flags (line 9698) | static int get_prop_flags(int flags, int def_flags)
function JS_CreateProperty (line 9705) | static int JS_CreateProperty(JSContext *ctx, JSObject *p,
function BOOL (line 9851) | static BOOL check_define_prop_flags(int prop_flags, int flags)
function js_shape_prepare_update (line 9881) | static int js_shape_prepare_update(JSContext *ctx, JSObject *p,
function js_update_property_flags (line 9908) | static int js_update_property_flags(JSContext *ctx, JSObject *p,
function JS_DefineProperty (line 9929) | int JS_DefineProperty(JSContext *ctx, JSValueConst this_obj,
function JS_DefineAutoInitProperty (line 10227) | static int JS_DefineAutoInitProperty(JSContext *ctx, JSValueConst this_obj,
function JS_DefinePropertyValue (line 10258) | int JS_DefinePropertyValue(JSContext *ctx, JSValueConst this_obj,
function JS_DefinePropertyValueValue (line 10268) | int JS_DefinePropertyValueValue(JSContext *ctx, JSValueConst this_obj,
function JS_DefinePropertyValueUint32 (line 10284) | int JS_DefinePropertyValueUint32(JSContext *ctx, JSValueConst this_obj,
function JS_DefinePropertyValueInt64 (line 10291) | int JS_DefinePropertyValueInt64(JSContext *ctx, JSValueConst this_obj,
function JS_DefinePropertyValueStr (line 10298) | int JS_DefinePropertyValueStr(JSContext *ctx, JSValueConst this_obj,
function JS_DefinePropertyGetSet (line 10314) | int JS_DefinePropertyGetSet(JSContext *ctx, JSValueConst this_obj,
function JS_CreateDataPropertyUint32 (line 10327) | static int JS_CreateDataPropertyUint32(JSContext *ctx, JSValueConst this...
function BOOL (line 10337) | static BOOL js_object_has_name(JSContext *ctx, JSValueConst obj)
function JS_DefineObjectName (line 10356) | static int JS_DefineObjectName(JSContext *ctx, JSValueConst obj,
function JS_DefineObjectNameComputed (line 10368) | static int JS_DefineObjectNameComputed(JSContext *ctx, JSValueConst obj,
function JSValue (line 10391) | static JSValue JS_ThrowSyntaxErrorVarRedeclaration(JSContext *ctx, JSAto...
function JS_CheckDefineGlobalVar (line 10398) | static int JS_CheckDefineGlobalVar(JSContext *ctx, JSAtom prop, int flags)
function JS_GetGlobalVarRef (line 10438) | static int JS_GetGlobalVarRef(JSContext *ctx, JSAtom prop, JSValue *sp)
function JS_DeleteGlobalVar (line 10474) | static int JS_DeleteGlobalVar(JSContext *ctx, JSAtom prop)
function JS_DeleteProperty (line 10499) | int JS_DeleteProperty(JSContext *ctx, JSValueConst obj, JSAtom prop, int...
function JS_DeletePropertyInt64 (line 10521) | int JS_DeletePropertyInt64(JSContext *ctx, JSValueConst obj, int64_t idx...
function BOOL (line 10538) | BOOL JS_IsFunction(JSContext *ctx, JSValueConst val)
function BOOL (line 10554) | BOOL JS_IsCFunction(JSContext *ctx, JSValueConst val, JSCFunction *func,...
function BOOL (line 10566) | BOOL JS_IsConstructor(JSContext *ctx, JSValueConst val)
function BOOL (line 10575) | BOOL JS_SetConstructorBit(JSContext *ctx, JSValueConst func_obj, BOOL val)
function BOOL (line 10585) | BOOL JS_IsError(JSContext *ctx, JSValueConst val)
function JS_SetUncatchableException (line 10595) | void JS_SetUncatchableException(JSContext *ctx, BOOL flag)
function JS_SetOpaque (line 10600) | void JS_SetOpaque(JSValue obj, void *opaque)
function JSValue (line 10642) | static JSValue JS_ToPrimitiveFree(JSContext *ctx, JSValue val, int hint)
function JSValue (line 10716) | static JSValue JS_ToPrimitive(JSContext *ctx, JSValueConst val, int hint)
function JS_SetIsHTMLDDA (line 10721) | void JS_SetIsHTMLDDA(JSContext *ctx, JSValueConst obj)
function BOOL (line 10730) | static inline BOOL JS_IsHTMLDDA(JSContext *ctx, JSValueConst obj)
function JS_ToBoolFree (line 10739) | static int JS_ToBoolFree(JSContext *ctx, JSValue val)
function JS_ToBool (line 10804) | int JS_ToBool(JSContext *ctx, JSValueConst val)
function skip_spaces (line 10809) | static int skip_spaces(const char *pc)
function to_digit (line 10831) | static inline int to_digit(int c)
function js_limb_t (line 10872) | static inline js_limb_t js_limb_clz(js_limb_t a)
function js_limb_t (line 10877) | static inline js_limb_t js_limb_clz(js_limb_t a)
function js_limb_t (line 10884) | static inline js_limb_t js_limb_safe_clz(js_limb_t a)
function js_limb_t (line 10892) | static js_limb_t mp_add(js_limb_t *res, const js_limb_t *op1, const js_l...
function js_limb_t (line 10902) | static js_limb_t mp_sub(js_limb_t *res, const js_limb_t *op1, const js_l...
function js_limb_t (line 10921) | static js_limb_t mp_neg(js_limb_t *res, const js_limb_t *op2, int n)
function js_limb_t (line 10936) | static js_limb_t mp_mul1(js_limb_t *tabr, const js_limb_t *taba, js_limb...
function js_limb_t (line 10950) | static js_limb_t mp_div1(js_limb_t *tabr, const js_limb_t *taba, js_limb...
function js_limb_t (line 10964) | static js_limb_t mp_add_mul1(js_limb_t *tabr, const js_limb_t *taba, js_...
function mp_mul_basecase (line 10980) | static void mp_mul_basecase(js_limb_t *result,
function js_limb_t (line 10996) | static js_limb_t mp_sub_mul1(js_limb_t *tabr, const js_limb_t *taba, js_...
function js_limb_t (line 11012) | static inline js_limb_t udiv1norm_init(js_limb_t d)
function js_limb_t (line 11022) | static inline js_limb_t udiv1norm(js_limb_t *pr, js_limb_t a1, js_limb_t...
function js_limb_t (line 11045) | static js_limb_t mp_div1norm(js_limb_t *tabr, const js_limb_t *taba, js_...
function mp_divnorm (line 11071) | static void mp_divnorm(js_limb_t *tabq, js_limb_t *taba, js_limb_t na,
function js_limb_t (line 11139) | static js_limb_t mp_shl(js_limb_t *tabr, const js_limb_t *taba, int n,
function js_limb_t (line 11155) | static js_limb_t mp_shr(js_limb_t *tab_r, const js_limb_t *tab, int n,
function JSBigInt (line 11170) | static JSBigInt *js_bigint_new(JSContext *ctx, int len)
function JSBigInt (line 11185) | static JSBigInt *js_bigint_set_si(JSBigIntBuf *buf, js_slimb_t a)
function JSBigInt (line 11194) | static JSBigInt *js_bigint_set_si64(JSBigIntBuf *buf, int64_t a)
function JSBigInt (line 11214) | static JSBigInt *js_bigint_set_short(JSBigIntBuf *buf, JSValueConst val)
function __maybe_unused (line 11219) | static __maybe_unused void js_bigint_dump1(JSContext *ctx, const char *str,
function __maybe_unused (line 11234) | static __maybe_unused void js_bigint_dump(JSContext *ctx, const char *str,
function JSBigInt (line 11240) | static JSBigInt *js_bigint_new_si(JSContext *ctx, js_slimb_t a)
function JSBigInt (line 11250) | static JSBigInt *js_bigint_new_si64(JSContext *ctx, int64_t a)
function JSBigInt (line 11269) | static JSBigInt *js_bigint_new_ui64(JSContext *ctx, uint64_t a)
function JSBigInt (line 11290) | static JSBigInt *js_bigint_new_di(JSContext *ctx, js_sdlimb_t a)
function JSBigInt (line 11311) | static JSBigInt *js_bigint_normalize1(JSContext *ctx, JSBigInt *a, int l)
function JSBigInt (line 11335) | static JSBigInt *js_bigint_normalize(JSContext *ctx, JSBigInt *a)
function js_bigint_sign (line 11341) | static inline int js_bigint_sign(const JSBigInt *a)
function js_slimb_t (line 11346) | static js_slimb_t js_bigint_get_si_sat(const JSBigInt *a)
function JSBigInt (line 11366) | static JSBigInt *js_bigint_extend(JSContext *ctx, JSBigInt *r,
function JSBigInt (line 11392) | static JSBigInt *js_bigint_add(JSContext *ctx, const JSBigInt *a,
function JSBigInt (line 11433) | static JSBigInt *js_bigint_neg(JSContext *ctx, const JSBigInt *a)
function JSBigInt (line 11441) | static JSBigInt *js_bigint_mul(JSContext *ctx, const JSBigInt *a,
function JSBigInt (line 11461) | static JSBigInt *js_bigint_divrem(JSContext *ctx, const JSBigInt *a,
function JSBigInt (line 11563) | static JSBigInt *js_bigint_logic(JSContext *ctx, const JSBigInt *a,
function JSBigInt (line 11615) | static JSBigInt *js_bigint_not(JSContext *ctx, const JSBigInt *a)
function JSBigInt (line 11630) | static JSBigInt *js_bigint_shl(JSContext *ctx, const JSBigInt *a,
function JSBigInt (line 11659) | static JSBigInt *js_bigint_shr(JSContext *ctx, const JSBigInt *a,
function JSBigInt (line 11686) | static JSBigInt *js_bigint_pow(JSContext *ctx, const JSBigInt *a, JSBigI...
function js_bigint_get_mant_exp (line 11771) | static uint64_t js_bigint_get_mant_exp(JSContext *ctx,
function shr_rndn (line 11831) | static uint64_t shr_rndn(uint64_t a, int n)
function js_bigint_to_float64 (line 11839) | static double js_bigint_to_float64(JSContext *ctx, const JSBigInt *a)
function JSBigInt (line 11872) | static JSBigInt *js_bigint_from_float64(JSContext *ctx, int *pres, doubl...
function js_bigint_float64_cmp (line 11920) | static int js_bigint_float64_cmp(JSContext *ctx, const JSBigInt *a,
function js_bigint_cmp (line 11974) | static int js_bigint_cmp(JSContext *ctx, const JSBigInt *a,
function JSBigInt (line 12033) | static JSBigInt *js_bigint_from_string(JSContext *ctx,
function JSValue (line 12211) | static JSValue js_bigint_to_string1(JSContext *ctx, JSValueConst val, in...
function JSValue (line 12309) | static JSValue JS_CompactBigInt(JSContext *ctx, JSBigInt *p)
function JSValue (line 12340) | static JSValue js_atof(JSContext *ctx, const char *str, const char **pp,
type JSToNumberHintEnum (line 12530) | typedef enum JSToNumberHintEnum {
function JSValue (line 12535) | static JSValue JS_ToNumberHintFree(JSContext *ctx, JSValue val,
function JSValue (line 12609) | static JSValue JS_ToNumberFree(JSContext *ctx, JSValue val)
function JSValue (line 12614) | static JSValue JS_ToNumericFree(JSContext *ctx, JSValue val)
function JSValue (line 12619) | static JSValue JS_ToNumeric(JSContext *ctx, JSValueConst val)
function __exception (line 12624) | static __exception int __JS_ToFloat64Free(JSContext *ctx, double *pres,
function JS_ToFloat64Free (line 12651) | static inline int JS_ToFloat64Free(JSContext *ctx, double *pres, JSValue...
function JS_ToFloat64 (line 12667) | int JS_ToFloat64(JSContext *ctx, double *pres, JSValueConst val)
function JSValue (line 12672) | static JSValue JS_ToNumber(JSContext *ctx, JSValueConst val)
function __maybe_unused (line 12678) | static __maybe_unused JSValue JS_ToIntegerFree(JSContext *ctx, JSValue val)
function JS_ToInt32SatFree (line 12714) | static int JS_ToInt32SatFree(JSContext *ctx, int *pres, JSValue val)
function JS_ToInt32Sat (line 12758) | int JS_ToInt32Sat(JSContext *ctx, int *pres, JSValueConst val)
function JS_ToInt32Clamp (line 12763) | int JS_ToInt32Clamp(JSContext *ctx, int *pres, JSValueConst val,
function JS_ToInt64SatFree (line 12780) | static int JS_ToInt64SatFree(JSContext *ctx, int64_t *pres, JSValue val)
function JS_ToInt64Sat (line 12821) | int JS_ToInt64Sat(JSContext *ctx, int64_t *pres, JSValueConst val)
function JS_ToInt64Clamp (line 12826) | int JS_ToInt64Clamp(JSContext *ctx, int64_t *pres, JSValueConst val,
function JS_ToInt64Free (line 12843) | static int JS_ToInt64Free(JSContext *ctx, int64_t *pres, JSValue val)
function JS_ToInt64 (line 12894) | int JS_ToInt64(JSContext *ctx, int64_t *pres, JSValueConst val)
function JS_ToInt64Ext (line 12899) | int JS_ToInt64Ext(JSContext *ctx, int64_t *pres, JSValueConst val)
function JS_ToInt32Free (line 12908) | static int JS_ToInt32Free(JSContext *ctx, int32_t *pres, JSValue val)
function JS_ToInt32 (line 12960) | int JS_ToInt32(JSContext *ctx, int32_t *pres, JSValueConst val)
function JS_ToUint32Free (line 12965) | static inline int JS_ToUint32Free(JSContext *ctx, uint32_t *pres, JSValu...
function JS_ToUint8ClampFree (line 12970) | static int JS_ToUint8ClampFree(JSContext *ctx, int32_t *pres, JSValue val)
function __exception (line 13012) | static __exception int JS_ToArrayLengthFree(JSContext *ctx, uint32_t *plen,
function BOOL (line 13076) | static BOOL is_safe_integer(double d)
function JS_ToIndex (line 13082) | int JS_ToIndex(JSContext *ctx, uint64_t *plen, JSValueConst val)
function __exception (line 13098) | static __exception int JS_ToLengthFree(JSContext *ctx, int64_t *plen,
function JS_NumberIsInteger (line 13107) | static int JS_NumberIsInteger(JSContext *ctx, JSValueConst val)
function BOOL (line 13117) | static BOOL JS_NumberIsNegativeOrMinusZero(JSContext *ctx, JSValueConst ...
function JSValue (line 13147) | static JSValue js_bigint_to_string(JSContext *ctx, JSValueConst val)
function JSValue (line 13152) | static JSValue js_dtoa2(JSContext *ctx,
function JSValue (line 13177) | static JSValue JS_ToStringInternal(JSContext *ctx, JSValueConst val, BOO...
function JSValue (line 13234) | JSValue JS_ToString(JSContext *ctx, JSValueConst val)
function JSValue (line 13239) | static JSValue JS_ToStringFree(JSContext *ctx, JSValue val)
function JSValue (line 13247) | static JSValue JS_ToLocaleStringFree(JSContext *ctx, JSValue val)
function JSValue (line 13254) | JSValue JS_ToPropertyKey(JSContext *ctx, JSValueConst val)
function JSValue (line 13259) | static JSValue JS_ToStringCheckObject(JSContext *ctx, JSValueConst val)
type JSPrintValueState (line 13269) | typedef struct {
function js_putc (line 13281) | static void js_putc(JSPrintValueState *s, char c)
function js_puts (line 13286) | static void js_puts(JSPrintValueState *s, const char *str)
function js_printf (line 13291) | static void __attribute__((format(printf, 2, 3))) js_printf(JSPrintValue...
function js_print_float64 (line 13302) | static void js_print_float64(JSPrintValueState *s, double d)
function js_string_get_length (line 13311) | static uint32_t js_string_get_length(JSValueConst val)
function js_print_string1 (line 13325) | static void js_print_string1(JSPrintValueState *s, JSString *p, int len,...
function js_print_string_rec (line 13382) | static void js_print_string_rec(JSPrintValueState *s, JSValueConst val,
function js_print_string (line 13401) | static void js_print_string(JSPrintValueState *s, JSValueConst val)
function js_print_raw_string (line 13420) | static void js_print_raw_string(JSPrintValueState *s, JSValueConst val)
function BOOL (line 13431) | static BOOL is_ascii_ident(const JSString *p)
function js_print_atom (line 13446) | static void js_print_atom(JSPrintValueState *s, JSAtom atom)
function js_print_array_get_length (line 13470) | static uint32_t js_print_array_get_length(JSObject *p)
function js_print_comma (line 13492) | static void js_print_comma(JSPrintValueState *s, int *pcomma_state)
function js_print_more_items (line 13507) | static void js_print_more_items(JSPrintValueState *s, int *pcomma_state,
function js_print_regexp (line 13515) | static void js_print_regexp(JSPrintValueState *s, JSObject *p1)
function js_print_error (line 13581) | static void js_print_error(JSPrintValueState *s, JSObject *p)
function js_print_object (line 13617) | static void js_print_object(JSPrintValueState *s, JSObject *p)
function js_print_stack_index (line 13858) | static int js_print_stack_index(JSPrintValueState *s, JSObject *p)
function js_print_value (line 13867) | static void js_print_value(JSPrintValueState *s, JSValueConst val)
function JS_PrintValueSetDefaultOptions (line 13990) | void JS_PrintValueSetDefaultOptions(JSPrintValueOptions *options)
function JS_PrintValueInternal (line 13998) | static void JS_PrintValueInternal(JSRuntime *rt, JSContext *ctx,
function JS_PrintValueRT (line 14023) | void JS_PrintValueRT(JSRuntime *rt, JSPrintValueWrite *write_func, void ...
function JS_PrintValue (line 14029) | void JS_PrintValue(JSContext *ctx, JSPrintValueWrite *write_func, void *...
function js_dump_value_write (line 14035) | static void js_dump_value_write(void *opaque, const char *buf, size_t len)
function __maybe_unused (line 14041) | static __maybe_unused void print_atom(JSContext *ctx, JSAtom atom)
function __maybe_unused (line 14052) | static __maybe_unused void JS_DumpAtom(JSContext *ctx, const char *str, ...
function __maybe_unused (line 14059) | static __maybe_unused void JS_DumpValue(JSContext *ctx, const char *str,...
function __maybe_unused (line 14066) | static __maybe_unused void JS_DumpValueRT(JSRuntime *rt, const char *str...
function __maybe_unused (line 14073) | static __maybe_unused void JS_DumpObjectHeader(JSRuntime *rt)
function __maybe_unused (line 14080) | static __maybe_unused void JS_DumpObject(JSRuntime *rt, JSObject *p)
function __maybe_unused (line 14108) | static __maybe_unused void JS_DumpGCObject(JSRuntime *rt, JSGCObjectHead...
function JS_IsArray (line 14145) | int JS_IsArray(JSContext *ctx, JSValueConst val)
function js_pow (line 14157) | static double js_pow(double a, double b)
function JSValue (line 14167) | JSValue JS_NewBigInt64(JSContext *ctx, int64_t v)
function JSValue (line 14184) | JSValue JS_NewBigUint64(JSContext *ctx, uint64_t v)
function JSValue (line 14198) | static JSValue JS_StringToBigInt(JSContext *ctx, JSValue val)
function JSValue (line 14227) | static JSValue JS_StringToBigIntErr(JSContext *ctx, JSValue val)
function JSValue (line 14236) | static JSValue JS_ToBigIntFree(JSContext *ctx, JSValue val)
function JSValue (line 14273) | static JSValue JS_ToBigInt(JSContext *ctx, JSValueConst val)
function JS_ToBigInt64Free (line 14279) | static int JS_ToBigInt64Free(JSContext *ctx, int64_t *pres, JSValue val)
function JS_ToBigInt64 (line 14304) | int JS_ToBigInt64(JSContext *ctx, int64_t *pres, JSValueConst val)
function js_unary_arith_slow (line 14309) | int js_unary_arith_slow(JSContext *ctx,
function __exception (line 14449) | static __exception int js_post_inc_slow(JSContext *ctx,
function no_inline (line 14466) | static no_inline int js_not_slow(JSContext *ctx, JSValue *sp)
function js_binary_arith_slow (line 14495) | int js_binary_arith_slow(JSContext *ctx, JSValue *sp,
function BOOL (line 14682) | static inline BOOL tag_is_string(uint32_t tag)
function js_add_slow (line 14687) | int js_add_slow(JSContext *ctx, JSValue *sp)
function js_binary_logic_slow (line 14803) | int js_binary_logic_slow(JSContext *ctx,
function JSBigInt (line 14965) | static JSBigInt *JS_ToBigIntBuf(JSContext *ctx, JSBigIntBuf *buf1,
function js_compare_bigint (line 14988) | static int js_compare_bigint(JSContext *ctx, OPCodeEnum op,
function no_inline (line 15057) | static no_inline int js_relational_slow(JSContext *ctx, JSValue *sp,
function BOOL (line 15191) | static BOOL tag_is_number(uint32_t tag)
function js_eq_slow (line 15198) | int js_eq_slow(JSContext *ctx, JSValue *sp,
function no_inline (line 15318) | static no_inline int js_shr_slow(JSContext *ctx, JSValue *sp)
function BOOL (line 15357) | static BOOL js_strict_eq2(JSContext *ctx, JSValue op1, JSValue op2,
function BOOL (line 15482) | static BOOL js_strict_eq(JSContext *ctx, JSValueConst op1, JSValueConst ...
function BOOL (line 15489) | BOOL JS_StrictEq(JSContext *ctx, JSValueConst op1, JSValueConst op2)
function BOOL (line 15494) | static BOOL js_same_value(JSContext *ctx, JSValueConst op1, JSValueConst...
function BOOL (line 15501) | BOOL JS_SameValue(JSContext *ctx, JSValueConst op1, JSValueConst op2)
function BOOL (line 15506) | static BOOL js_same_value_zero(JSContext *ctx, JSValueConst op1, JSValue...
function BOOL (line 15513) | BOOL JS_SameValueZero(JSContext *ctx, JSValueConst op1, JSValueConst op2)
function no_inline (line 15518) | static no_inline int js_strict_eq_slow(JSContext *ctx, JSValue *sp,
function __exception (line 15527) | static __exception int js_operator_in(JSContext *ctx, JSValue *sp)
function __exception (line 15553) | static __exception int js_operator_private_in(JSContext *ctx, JSValue *sp)
function __exception (line 15590) | static __exception int js_has_unscopable(JSContext *ctx, JSValueConst obj,
function __exception (line 15608) | static __exception int js_operator_instanceof(JSContext *ctx, JSValue *sp)
function __exception (line 15624) | static __exception int js_operator_typeof(JSContext *ctx, JSValueConst op1)
function __exception (line 15675) | static __exception int js_operator_delete(JSContext *ctx, JSValue *sp)
function JSValue (line 15699) | static JSValue js_throw_type_error(JSContext *ctx, JSValueConst this_val,
function JSValue (line 15709) | static JSValue js_function_proto_fileName(JSContext *ctx,
function JSValue (line 15719) | static JSValue js_function_proto_lineNumber(JSContext *ctx,
function js_arguments_define_own_property (line 15734) | static int js_arguments_define_own_property(JSContext *ctx,
function JSValue (line 15757) | static JSValue js_build_arguments(JSContext *ctx, int argc, JSValueConst...
function js_mapped_arguments_finalizer (line 15796) | static void js_mapped_arguments_finalizer(JSRuntime *rt, JSValue val)
function js_mapped_arguments_mark (line 15806) | static void js_mapped_arguments_mark(JSRuntime *rt, JSValueConst val,
function JSValue (line 15818) | static JSValue js_build_mapped_arguments(JSContext *ctx, int argc,
function JSValue (line 15871) | static JSValue build_for_in_iterator(JSContext *ctx, JSValue obj)
function __exception (line 15935) | static __exception int js_for_in_start(JSContext *ctx, JSValue *sp)
function __exception (line 15944) | static __exception int js_for_in_prepare_prototype_chain_enum(JSContext ...
function __exception (line 16007) | static __exception int js_for_in_next(JSContext *ctx, JSValue *sp)
function JSValue (line 16101) | static JSValue JS_GetIterator2(JSContext *ctx, JSValueConst obj,
function JSValue (line 16116) | static JSValue JS_GetIterator(JSContext *ctx, JSValueConst obj, BOOL is_...
function JSValue (line 16151) | static JSValue JS_IteratorNext2(JSContext *ctx, JSValueConst enum_obj,
function JSValue (line 16192) | static JSValue JS_IteratorNext(JSContext *ctx, JSValueConst enum_obj,
function JS_IteratorClose (line 16228) | static int JS_IteratorClose(JSContext *ctx, JSValueConst enum_obj,
function __exception (line 16268) | static __exception int js_for_of_start(JSContext *ctx, JSValue *sp,
function __exception (line 16289) | static __exception int js_for_of_next(JSContext *ctx, JSValue *sp, int o...
function __exception (line 16316) | static __exception int js_for_await_of_next(JSContext *ctx, JSValue *sp)
function JSValue (line 16331) | static JSValue JS_IteratorGetCompleteValue(JSContext *ctx, JSValueConst ...
function __exception (line 16350) | static __exception int js_iterator_get_value_done(JSContext *ctx, JSValu...
function JSValue (line 16371) | static JSValue js_create_iterator_result(JSContext *ctx,
function BOOL (line 16401) | static BOOL js_is_fast_array(JSContext *ctx, JSValueConst obj)
function BOOL (line 16414) | static BOOL js_get_fast_array(JSContext *ctx, JSValueConst obj,
function __exception (line 16429) | static __exception int js_append_enumerate(JSContext *ctx, JSValue *sp)
function __exception (line 16512) | static __exception int JS_CopyDataProperties(JSContext *ctx,
function JSValueConst (line 16588) | static JSValueConst JS_GetActiveFunction(JSContext *ctx)
function JSVarRef (line 16593) | static JSVarRef *js_create_var_ref(JSContext *ctx, BOOL is_lexical)
function JSVarRef (line 16612) | static JSVarRef *get_var_ref(JSContext *ctx, JSStackFrame *sf, int var_idx,
function js_global_object_finalizer (line 16671) | static void js_global_object_finalizer(JSRuntime *rt, JSValue obj)
function js_global_object_mark (line 16677) | static void js_global_object_mark(JSRuntime *rt, JSValueConst val,
function JSVarRef (line 16684) | static JSVarRef *js_global_object_get_uninitialized_var(JSContext *ctx, ...
function JSVarRef (line 16715) | static JSVarRef *js_global_object_find_uninitialized_var(JSContext *ctx,...
function JSVarRef (line 16740) | static JSVarRef *js_closure_define_global_var(JSContext *ctx, JSClosureV...
function JSVarRef (line 16843) | static JSVarRef *js_closure_global_var(JSContext *ctx, JSClosureVar *cv)
function JSValue (line 16877) | static JSValue js_closure2(JSContext *ctx, JSValue func_obj,
function JSValue (line 16956) | static JSValue js_instantiate_prototype(JSContext *ctx, JSObject *p, JSA...
function JSValue (line 16984) | static JSValue js_closure(JSContext *ctx, JSValue bfunc,
function js_op_define_class (line 17041) | static int js_op_define_class(JSContext *ctx, JSValue *sp,
function close_var_ref (line 17136) | static void close_var_ref(JSRuntime *rt, JSStackFrame *sf, JSVarRef *var...
function close_var_refs (line 17148) | static void close_var_refs(JSRuntime *rt, JSFunctionBytecode *b, JSStack...
function close_lexical_var (line 17160) | static void close_lexical_var(JSContext *ctx, JSFunctionBytecode *b,
function JSValue (line 17177) | static JSValue js_call_c_function(JSContext *ctx, JSValueConst func_obj,
function JSValue (line 17306) | static JSValue js_call_bound_function(JSContext *ctx, JSValueConst func_...
type OPSpecialObjectEnum (line 17340) | typedef enum {
function JSValue (line 17356) | static JSValue JS_CallInternal(JSContext *caller_ctx, JSValueConst func_...
function free_token (line 21603) | static void free_token(JSParseState *s, JSToken *token)
function dump_token (line 21630) | static void __attribute((unused)) dump_token(JSParseState *s,
function get_line_col (line 21693) | static int get_line_col(int *pcol_num, const uint8_t *buf, size_t len)
function get_line_col_cached (line 21713) | static int get_line_col_cached(GetLineColCache *s, int *pcol_num, const ...
function js_parse_error_v (line 21749) | static int js_parse_error_v(JSParseState *s, const uint8_t *ptr, const c...
function js_parse_error_pos (line 21760) | static __attribute__((format(printf, 3, 4))) int js_parse_error_pos(JSPa...
function js_parse_error (line 21771) | static __attribute__((format(printf, 2, 3))) int js_parse_error(JSParseS...
function js_parse_expect (line 21782) | static int js_parse_expect(JSParseState *s, int tok)
function js_parse_expect_semi (line 21791) | static int js_parse_expect_semi(JSParseState *s)
function js_parse_error_reserved_identifier (line 21803) | static int js_parse_error_reserved_identifier(JSParseState *s)
function __exception (line 21811) | static __exception int js_parse_template_part(JSParseState *s, const uin...
function __exception (line 21874) | static __exception int js_parse_string(JSParseState *s, int sep,
function BOOL (line 22011) | static inline BOOL token_is_pseudo_keyword(JSParseState *s, JSAtom atom) {
function __exception (line 22016) | static __exception int js_parse_regexp(JSParseState *s)
function __exception (line 22124) | static __exception int ident_realloc(JSContext *ctx, char **pbuf, size_t...
function update_token_ident (line 22152) | static void update_token_ident(JSParseState *s)
function reparse_ident_token (line 22182) | static void reparse_ident_token(JSParseState *s)
function JSAtom (line 22194) | static JSAtom parse_ident(JSParseState *s, const uint8_t **pp,
function __exception (line 22242) | static __exception int next_token(JSParseState *s)
function JSAtom (line 22686) | static JSAtom json_parse_ident(JSParseState *s, const uint8_t **pp, int c)
function json_parse_string (line 22718) | static int json_parse_string(JSParseState *s, const uint8_t **pp, int sep)
function json_parse_number (line 22805) | static int json_parse_number(JSParseState *s, const uint8_t **pp)
function __exception (line 22890) | static __exception int json_next_token(JSParseState *s)
function match_identifier (line 23060) | static int match_identifier(const uint8_t *p, const char *s) {
function simple_next_token (line 23083) | static int simple_next_token(const uint8_t **pp, BOOL no_line_terminator)
function peek_token (line 23168) | static int peek_token(JSParseState *s, BOOL no_line_terminator)
function skip_shebang (line 23174) | static void skip_shebang(const uint8_t **pp, const uint8_t *buf_end)
function BOOL (line 23205) | BOOL JS_DetectModule(const char *input, size_t input_len)
function get_prev_opcode (line 23222) | static inline int get_prev_opcode(JSFunctionDef *fd) {
function BOOL (line 23229) | static BOOL js_is_live_code(JSParseState *s) {
function emit_u8 (line 23250) | static void emit_u8(JSParseState *s, uint8_t val)
function emit_u16 (line 23255) | static void emit_u16(JSParseState *s, uint16_t val)
function emit_u32 (line 23260) | static void emit_u32(JSParseState *s, uint32_t val)
function emit_source_pos (line 23265) | static void emit_source_pos(JSParseState *s, const uint8_t *source_ptr)
function emit_op (line 23277) | static void emit_op(JSParseState *s, uint8_t val)
function emit_atom (line 23286) | static void emit_atom(JSParseState *s, JSAtom name)
function update_label (line 23295) | static int update_label(JSFunctionDef *s, int label, int delta)
function new_label_fd (line 23306) | static int new_label_fd(JSFunctionDef *fd)
function new_label (line 23325) | static int new_label(JSParseState *s)
function emit_label_raw (line 23336) | static void emit_label_raw(JSParseState *s, int label)
function emit_label (line 23344) | static int emit_label(JSParseState *s, int label)
function emit_goto (line 23357) | static int emit_goto(JSParseState *s, int opcode, int label)
function cpool_add (line 23374) | static int cpool_add(JSParseState *s, JSValue val)
function __exception (line 23387) | static __exception int emit_push_const(JSParseState *s, JSValueConst val,
function find_arg (line 23414) | static int find_arg(JSContext *ctx, JSFunctionDef *fd, JSAtom name)
function find_var (line 23424) | static int find_var(JSContext *ctx, JSFunctionDef *fd, JSAtom name)
function find_var_in_scope (line 23435) | static int find_var_in_scope(JSContext *ctx, JSFunctionDef *fd,
function BOOL (line 23451) | static BOOL is_child_scope(JSContext *ctx, JSFunctionDef *fd,
function find_var_in_child_scope (line 23463) | static int find_var_in_child_scope(JSContext *ctx, JSFunctionDef *fd,
function JSGlobalVar (line 23479) | static JSGlobalVar *find_global_var(JSFunctionDef *fd, JSAtom name)
function JSGlobalVar (line 23491) | static JSGlobalVar *find_lexical_global_var(JSFunctionDef *fd, JSAtom name)
function find_lexical_decl (line 23500) | static int find_lexical_decl(JSContext *ctx, JSFunctionDef *fd, JSAtom n...
function push_scope (line 23519) | static int push_scope(JSParseState *s) {
function get_first_lexical_var (line 23554) | static int get_first_lexical_var(JSFunctionDef *fd, int scope)
function pop_scope (line 23565) | static void pop_scope(JSParseState *s) {
function close_scopes (line 23577) | static void close_scopes(JSParseState *s, int scope, int scope_stop)
function add_var (line 23587) | static int add_var(JSContext *ctx, JSFunctionDef *fd, JSAtom name)
function add_scope_var (line 23606) | static int add_scope_var(JSContext *ctx, JSFunctionDef *fd, JSAtom name,
function add_func_var (line 23621) | static int add_func_var(JSContext *ctx, JSFunctionDef *fd, JSAtom name)
function add_arguments_var (line 23633) | static int add_arguments_var(JSContext *ctx, JSFunctionDef *fd)
function add_arguments_arg (line 23644) | static int add_arguments_arg(JSContext *ctx, JSFunctionDef *fd)
function add_arg (line 23667) | static int add_arg(JSContext *ctx, JSFunctionDef *fd, JSAtom name)
function JSGlobalVar (line 23687) | static JSGlobalVar *add_global_var(JSContext *ctx, JSFunctionDef *s,
type JSVarDefEnum (line 23706) | typedef enum {
function define_var (line 23716) | static int define_var(JSParseState *s, JSFunctionDef *fd, JSAtom name,
function add_private_class_field (line 23845) | static int add_private_class_field(JSParseState *s, JSFunctionDef *fd,
function seal_template_obj (line 23888) | static int seal_template_obj(JSContext *ctx, JSValueConst obj)
function __exception (line 23904) | static __exception int js_parse_template(JSParseState *s, int call, int ...
function BOOL (line 24025) | static BOOL token_is_ident(int tok)
function js_parse_property_name (line 24034) | static int __exception js_parse_property_name(JSParseState *s,
type JSParsePos (line 24153) | typedef struct JSParsePos {
function js_parse_get_pos (line 24158) | static int js_parse_get_pos(JSParseState *s, JSParsePos *sp)
function __exception (line 24165) | static __exception int js_parse_seek_token(JSParseState *s, const JSPars...
function BOOL (line 24173) | static BOOL is_regexp_allowed(int tok)
function BOOL (line 24199) | static BOOL has_lf_in_range(const uint8_t *p1, const uint8_t *p2)
function js_parse_skip_parens_token (line 24213) | static int js_parse_skip_parens_token(JSParseState *s, int *pbits, BOOL ...
function set_object_name (line 24331) | static void set_object_name(JSParseState *s, JSAtom name)
function set_object_name_computed (line 24359) | static void set_object_name_computed(JSParseState *s)
function __exception (line 24380) | static __exception int js_parse_object_literal(JSParseState *s)
function __exception (line 24517) | static __exception int js_parse_left_hand_side_expr(JSParseState *s)
function __exception (line 24522) | static __exception int js_parse_class_default_ctor(JSParseState *s,
function find_private_class_field (line 24579) | static int find_private_class_field(JSContext *ctx, JSFunctionDef *fd,
function emit_class_field_init (line 24597) | static void emit_class_field_init(JSParseState *s)
function JSAtom (line 24623) | static JSAtom get_private_setter_name(JSContext *ctx, JSAtom name)
type ClassFieldsDef (line 24628) | typedef struct {
function __exception (line 24636) | static __exception int emit_class_init_start(JSParseState *s,
function emit_class_init_end (line 24671) | static void emit_class_init_end(JSParseState *s, ClassFieldsDef *cf)
function __exception (line 24687) | static __exception int js_parse_class(JSParseState *s, BOOL is_class_expr,
function __exception (line 25199) | static __exception int js_parse_array_literal(JSParseState *s)
function BOOL (line 25326) | static BOOL has_with_scope(JSFunctionDef *s, int scope_level)
function __exception (line 25346) | static __exception int get_lvalue(JSParseState *s, int *popcode, int *ps...
type PutLValueEnum (line 25479) | typedef enum {
function put_lvalue (line 25490) | static void put_lvalue(JSParseState *s, int opcode, int scope,
function __exception (line 25608) | static __exception int js_parse_expr_paren(JSParseState *s)
function js_unsupported_keyword (line 25619) | static int js_unsupported_keyword(JSParseState *s, JSAtom atom)
function __exception (line 25626) | static __exception int js_define_var(JSParseState *s, JSAtom name, int tok)
function js_emit_spread_code (line 25663) | static void js_emit_spread_code(JSParseState *s, int depth)
function js_parse_check_duplicate_parameter (line 25689) | static int js_parse_check_duplicate_parameter(JSParseState *s, JSAtom name)
function BOOL (line 25713) | static BOOL need_var_reference(JSParseState *s, int tok)
function JSAtom (line 25727) | static JSAtom js_parse_destructuring_var(JSParseState *s, int tok, int i...
function js_parse_destructuring_element (line 25751) | static int js_parse_destructuring_element(JSParseState *s, int tok, int ...
type FuncCallType (line 26220) | typedef enum FuncCallType {
function optional_chain_test (line 26227) | static void optional_chain_test(JSParseState *s, int *poptional_chaining...
function __exception (line 26245) | static __exception int js_parse_postfix_expr(JSParseState *s, int parse_...
function __exception (line 26913) | static __exception int js_parse_delete(JSParseState *s)
function __exception (line 27006) | static __exception int js_parse_unary(JSParseState *s, int parse_flags)
function __exception (line 27146) | static __exception int js_parse_expr_binary(JSParseState *s, int level,
function __exception (line 27313) | static __exception int js_parse_logical_and_or(JSParseState *s, int op,
function __exception (line 27355) | static __exception int js_parse_coalesce_expr(JSParseState *s, int parse...
function __exception (line 27383) | static __exception int js_parse_cond_expr(JSParseState *s, int parse_flags)
function __exception (line 27412) | static __exception int js_parse_assign_expr2(JSParseState *s, int parse_...
function __exception (line 27696) | static __exception int js_parse_assign_expr(JSParseState *s)
function __exception (line 27702) | static __exception int js_parse_expr2(JSParseState *s, int parse_flags)
function __exception (line 27726) | static __exception int js_parse_expr(JSParseState *s)
function push_break_entry (line 27731) | static void push_break_entry(JSFunctionDef *fd, BlockEnv *be,
function pop_break_entry (line 27748) | static void pop_break_entry(JSFunctionDef *fd)
function __exception (line 27755) | static __exception int emit_break(JSParseState *s, JSAtom name, int is_c...
function emit_return (line 27805) | static void emit_return(JSParseState *s, BOOL hasval)
function __exception (line 27903) | static __exception int js_parse_statement(JSParseState *s)
function __exception (line 27908) | static __exception int js_parse_block(JSParseState *s)
function __exception (line 27928) | static __exception int js_parse_var(JSParseState *s, int parse_flags, in...
function BOOL (line 28022) | static BOOL is_label(JSParseState *s)
function is_let (line 28029) | static int is_let(JSParseState *s, int decl_mask)
function __exception (line 28075) | static __exception int js_parse_for_in_of(JSParseState *s, int label_name,
function set_eval_ret_undefined (line 28297) | static void set_eval_ret_undefined(JSParseState *s)
function __exception (line 28306) | static __exception int js_parse_statement_or_decl(JSParseState *s,
function JSModuleDef (line 29068) | static JSModuleDef *js_new_module_def(JSContext *ctx, JSAtom name)
function js_mark_module_def (line 29091) | static void js_mark_module_def(JSRuntime *rt, JSModuleDef *m,
function js_free_module_def (line 29119) | static void js_free_module_def(JSRuntime *rt, JSModuleDef *m)
function add_req_module_entry (line 29171) | static int add_req_module_entry(JSContext *ctx, JSModuleDef *m,
function JSExportEntry (line 29188) | static JSExportEntry *find_export_entry(JSContext *ctx, JSModuleDef *m,
function JSExportEntry (line 29201) | static JSExportEntry *add_export_entry2(JSContext *ctx,
function JSExportEntry (line 29232) | static JSExportEntry *add_export_entry(JSParseState *s, JSModuleDef *m,
function add_star_export_entry (line 29240) | static int add_star_export_entry(JSContext *ctx, JSModuleDef *m,
function JSModuleDef (line 29256) | JSModuleDef *JS_NewCModule(JSContext *ctx, const char *name_str,
function JS_AddModuleExport (line 29271) | int JS_AddModuleExport(JSContext *ctx, JSModuleDef *m, const char *expor...
function JS_SetModuleExport (line 29287) | int JS_SetModuleExport(JSContext *ctx, JSModuleDef *m, const char *expor...
function JS_SetModulePrivateValue (line 29306) | int JS_SetModulePrivateValue(JSContext *ctx, JSModuleDef *m, JSValue val)
function JSValue (line 29312) | JSValue JS_GetModulePrivateValue(JSContext *ctx, JSModuleDef *m)
function JS_SetModuleLoaderFunc (line 29317) | void JS_SetModuleLoaderFunc(JSRuntime *rt,
function JS_SetModuleLoaderFunc2 (line 29328) | void JS_SetModuleLoaderFunc2(JSRuntime *rt,
function JSModuleDef (line 29401) | static JSModuleDef *js_find_loaded_module(JSContext *ctx, JSAtom name)
function JSModuleDef (line 29416) | static JSModuleDef *js_host_resolve_imported_module(JSContext *ctx,
function JSModuleDef (line 29468) | static JSModuleDef *js_host_resolve_imported_module_atom(JSContext *ctx,
type JSResolveEntry (line 29490) | typedef struct JSResolveEntry {
type JSResolveState (line 29495) | typedef struct JSResolveState {
function find_resolve_entry (line 29501) | static int find_resolve_entry(JSResolveState *s,
function add_resolve_entry (line 29513) | static int add_resolve_entry(JSContext *ctx, JSResolveState *s,
type JSResolveResultEnum (line 29528) | typedef enum JSResolveResultEnum {
function JSResolveResultEnum (line 29536) | static JSResolveResultEnum js_resolve_export1(JSContext *ctx,
function JSResolveResultEnum (line 29613) | static JSResolveResultEnum js_resolve_export(JSContext *ctx,
function js_resolve_export_throw_error (line 29636) | static void js_resolve_export_throw_error(JSContext *ctx,
type ExportedNameEntryEnum (line 29665) | typedef enum {
type ExportedNameEntry (line 29671) | typedef struct ExportedNameEntry {
type GetExportNamesState (line 29680) | typedef struct GetExportNamesState {
function find_exported_name (line 29690) | static int find_exported_name(GetExportNamesState *s, JSAtom name)
function __exception (line 29700) | static __exception int get_exported_names(JSContext *ctx,
function js_module_ns_has (line 29750) | static int js_module_ns_has(JSContext *ctx, JSValueConst obj, JSAtom atom)
function exported_names_cmp (line 29759) | static int exported_names_cmp(const void *p1, const void *p2, void *opaque)
function JSValue (line 29782) | static JSValue js_module_ns_autoinit(JSContext *ctx, JSObject *p, JSAtom...
function JSValue (line 29811) | static JSValue js_build_module_ns(JSContext *ctx, JSModuleDef *m)
function JSValue (line 29916) | JSValue JS_GetModuleNamespace(JSContext *ctx, JSModuleDef *m)
function js_resolve_module (line 29929) | static int js_resolve_module(JSContext *ctx, JSModuleDef *m)
function js_create_module_bytecode_function (line 29961) | static int js_create_module_bytecode_function(JSContext *ctx, JSModuleDe...
function js_create_module_function (line 29984) | static int js_create_module_function(JSContext *ctx, JSModuleDef *m)
function js_inner_module_linking (line 30026) | static int js_inner_module_linking(JSContext *ctx, JSModuleDef *m,
function js_link_module (line 30225) | static int js_link_module(JSContext *ctx, JSModuleDef *m)
function JSAtom (line 30258) | JSAtom JS_GetScriptOrModuleName(JSContext *ctx, int n_stack_levels)
function JSAtom (line 30293) | JSAtom JS_GetModuleName(JSContext *ctx, JSModuleDef *m)
function JSValue (line 30298) | JSValue JS_GetImportMeta(JSContext *ctx, JSModuleDef *m)
function JSValue (line 30312) | static JSValue js_import_meta(JSContext *ctx)
function JSValue (line 30333) | static JSValue JS_NewModuleValue(JSContext *ctx, JSModuleDef *m)
function JSValue (line 30338) | static JSValue js_load_module_rejected(JSContext *ctx, JSValueConst this...
function JSValue (line 30356) | static JSValue js_load_module_fulfilled(JSContext *ctx, JSValueConst thi...
function JS_LoadModuleInternal (line 30377) | static void JS_LoadModuleInternal(JSContext *ctx, const char *basename,
function JSValue (line 30425) | JSValue JS_LoadModule(JSContext *ctx, const char *basename,
function JSValue (line 30440) | static JSValue js_dynamic_import_job(JSContext *ctx,
function JSValue (line 30477) | static JSValue js_dynamic_import(JSContext *ctx, JSValueConst specifier,...
function js_set_module_evaluated (line 30577) | static void js_set_module_evaluated(JSContext *ctx, JSModuleDef *m)
type ExecModuleList (line 30590) | typedef struct {
function BOOL (line 30597) | static BOOL find_in_exec_module_list(ExecModuleList *exec_list, JSModule...
function gather_available_ancestors (line 30607) | static int gather_available_ancestors(JSContext *ctx, JSModuleDef *module,
function exec_module_list_cmp (line 30640) | static int exec_module_list_cmp(const void *p1, const void *p2, void *op...
function js_dump_module (line 30652) | static void js_dump_module(JSContext *ctx, const char *str, JSModuleDef *m)
function JSValue (line 30660) | static JSValue js_async_module_execution_rejected(JSContext *ctx, JSValu...
function JSValue (line 30705) | static JSValue js_async_module_execution_fulfilled(JSContext *ctx, JSVal...
function js_execute_async_module (line 30766) | static int js_execute_async_module(JSContext *ctx, JSModuleDef *m)
function js_execute_sync_module (line 30789) | static int js_execute_sync_module(JSContext *ctx, JSModuleDef *m,
function js_inner_module_evaluation (line 30827) | static int js_inner_module_evaluation(JSContext *ctx, JSModuleDef *m,
function JSValue (line 30939) | static JSValue js_evaluate_module(JSContext *ctx, JSModuleDef *m)
function __exception (line 30998) | static __exception int js_parse_with_clause(JSParseState *s, JSReqModule...
function __exception (line 31069) | static __exception int js_parse_from_clause(JSParseState *s, JSModuleDef...
function __exception (line 31103) | static __exception int js_parse_export(JSParseState *s)
function add_import (line 31268) | static int add_import(JSParseState *s, JSModuleDef *m,
function __exception (line 31303) | static __exception int js_parse_import(JSParseState *s)
function __exception (line 31438) | static __exception int js_parse_source_element(JSParseState *s)
function JSFunctionDef (line 31466) | static JSFunctionDef *js_new_function_def(JSContext *ctx,
function free_bytecode_atoms (line 31531) | static void free_bytecode_atoms(JSRuntime *rt,
function js_free_function_def (line 31566) | static void js_free_function_def(JSContext *ctx, JSFunctionDef *fd)
function print_lines (line 31636) | static void print_lines(const char *source, int line, int line1) {
function dump_byte_code (line 31652) | static void dump_byte_code(JSContext *ctx, int pass,
function __maybe_unused (line 31930) | static __maybe_unused void dump_pc2line(JSContext *ctx, const uint8_t *b...
function __maybe_unused (line 31990) | static __maybe_unused void js_dump_function_bytecode(JSContext *ctx, JSF...
function add_closure_var (line 32093) | static int add_closure_var(JSContext *ctx, JSFunctionDef *s,
function find_closure_var (line 32121) | static int find_closure_var(JSContext *ctx, JSFunctionDef *s,
function get_closure_var (line 32135) | static int get_closure_var(JSContext *ctx, JSFunctionDef *s,
function get_with_scope_opcode (line 32161) | static int get_with_scope_opcode(int op)
function BOOL (line 32169) | static BOOL can_opt_put_ref_value(const uint8_t *bc_buf, int pos)
function BOOL (line 32179) | static BOOL can_opt_put_global_ref_value(const uint8_t *bc_buf, int pos)
function optimize_scope_make_ref (line 32189) | static int optimize_scope_make_ref(JSContext *ctx, JSFunctionDef *s,
function add_var_this (line 32233) | static int add_var_this(JSContext *ctx, JSFunctionDef *fd)
function resolve_pseudo_var (line 32246) | static int resolve_pseudo_var(JSContext *ctx, JSFunctionDef *s,
function var_object_test (line 32287) | static void var_object_test(JSContext *ctx, JSFunctionDef *s,
function capture_var (line 32306) | static inline void capture_var(JSFunctionDef *s, JSVarDef *vd)
function resolve_scope_var (line 32315) | static int resolve_scope_var(JSContext *ctx, JSFunctionDef *s,
function find_private_class_field_all (line 32797) | static int find_private_class_field_all(JSContext *ctx, JSFunctionDef *fd,
function get_loc_or_ref (line 32811) | static void get_loc_or_ref(DynBuf *bc, BOOL is_ref, int idx)
function resolve_scope_private_field1 (line 32822) | static int resolve_scope_private_field1(JSContext *ctx,
function resolve_scope_private_field (line 32885) | static int resolve_scope_private_field(JSContext *ctx, JSFunctionDef *s,
function mark_eval_captured_variables (line 32985) | static void mark_eval_captured_variables(JSContext *ctx, JSFunctionDef *s,
function BOOL (line 32999) | static BOOL is_var_in_arg_scope(JSAtom var_name, JSVarKindEnum var_kind)
function add_eval_variables (line 33009) | static void add_eval_variables(JSContext *ctx, JSFunctionDef *s)
function set_closure_from_var (line 33166) | static void set_closure_from_var(JSContext *ctx, JSClosureVar *cv,
function __exception (line 33179) | static __exception int add_closure_variables(JSContext *ctx, JSFunctionD...
type CodeContext (line 33264) | typedef struct CodeContext {
function BOOL (line 33280) | static BOOL code_match(CodeContext *s, int pos, ...)
function instantiate_hoisted_definitions (line 33404) | static void instantiate_hoisted_definitions(JSContext *ctx, JSFunctionDe...
function skip_dead_code (line 33511) | static int skip_dead_code(JSFunctionDef *s, const uint8_t *bc_buf, int b...
function get_label_pos (line 33561) | static int get_label_pos(JSFunctionDef *s, int label)
function __exception (line 33586) | static __exception int resolve_variables(JSContext *ctx, JSFunctionDef *s)
function add_pc2line_info (line 33946) | static void add_pc2line_info(JSFunctionDef *s, uint32_t pc, uint32_t sou...
function compute_pc2line_info (line 33966) | static void compute_pc2line_info(JSFunctionDef *s)
function RelocEntry (line 34019) | static RelocEntry *add_reloc(JSContext *ctx, LabelSlot *ls, uint32_t add...
function BOOL (line 34032) | static BOOL code_has_label(CodeContext *s, int pos, int label)
function find_jump_target (line 34060) | static int find_jump_target(JSFunctionDef *s, int label0, int *pop, int ...
function push_short_int (line 34114) | static void push_short_int(DynBuf *bc_out, int val)
function put_short_code (line 34136) | static void put_short_code(DynBuf *bc_out, int op, int idx)
function __exception (line 34195) | static __exception int resolve_labels(JSContext *ctx, JSFunctionDef *s)
type StackSizeState (line 35100) | typedef struct StackSizeState {
function __exception (line 35111) | static __exception int ss_check(JSContext *ctx, StackSizeState *s,
function __exception (line 35152) | static __exception int compute_stack_size(JSContext *ctx,
function add_global_variables (line 35353) | static int add_global_variables(JSContext *ctx, JSFunctionDef *fd)
function JSValue (line 35423) | static JSValue js_create_function(JSContext *ctx, JSFunctionDef *fd)
function free_function_bytecode (line 35682) | static void free_function_bytecode(JSRuntime *rt, JSFunctionBytecode *b)
function __exception (line 35726) | static __exception int js_parse_directives(JSParseState *s)
function BOOL (line 35813) | static BOOL is_strict_future_keyword(JSAtom atom)
function js_parse_function_check_names (line 35818) | static int js_parse_function_check_names(JSParseState *s, JSFunctionDef ...
function JSFunctionDef (line 35871) | static JSFunctionDef *js_parse_function_class_fields_init(JSParseState *s)
function __exception (line 35899) | static __exception int js_parse_function_decl2(JSParseState *s,
function __exception (line 36467) | static __exception int js_parse_function_decl(JSParseState *s,
function __exception (line 36477) | static __exception int js_parse_program(JSParseState *s)
function js_parse_init (line 36529) | static void js_parse_init(JSContext *ctx, JSParseState *s,
function JSValue (line 36547) | static JSValue JS_EvalFunctionInternal(JSContext *ctx, JSValue fun_obj,
function JSValue (line 36581) | JSValue JS_EvalFunction(JSContext *ctx, JSValue fun_obj)
function JSValue (line 36587) | static JSValue __JS_EvalInternal(JSContext *ctx, JSValueConst this_obj,
function JSValue (line 36703) | static JSValue JS_EvalInternal(JSContext *ctx, JSValueConst this_obj,
function JSValue (line 36725) | static JSValue JS_EvalObject(JSContext *ctx, JSValueConst this_obj,
function JSValue (line 36743) | JSValue JS_EvalThis(JSContext *ctx, JSValueConst this_obj,
function JSValue (line 36757) | JSValue JS_Eval(JSContext *ctx, const char *input, size_t input_len,
function JS_ResolveModule (line 36764) | int JS_ResolveModule(JSContext *ctx, JSValueConst obj)
type JSObjectListEntry (line 36779) | typedef struct {
type JSObjectList (line 36785) | typedef struct {
function js_object_list_init (line 36793) | static void js_object_list_init(JSObjectList *s)
function js_object_list_get_hash (line 36798) | static uint32_t js_object_list_get_hash(JSObject *p, uint32_t hash_size)
function js_object_list_resize_hash (line 36803) | static int js_object_list_resize_hash(JSContext *ctx, JSObjectList *s,
function js_object_list_add (line 36830) | static int js_object_list_add(JSContext *ctx, JSObjectList *s, JSObject ...
function js_object_list_find (line 36855) | static int js_object_list_find(JSContext *ctx, JSObjectList *s, JSObject...
function js_object_list_end (line 36874) | static void js_object_list_end(JSContext *ctx, JSObjectList *s)
type BCTagEnum (line 36883) | typedef enum BCTagEnum {
type BCWriterState (line 36907) | typedef struct BCWriterState {
function BOOL (line 36951) | static inline BOOL is_be(void)
function bc_put_u8 (line 36960) | static void bc_put_u8(BCWriterState *s, uint8_t v)
function bc_put_u16 (line 36965) | static void bc_put_u16(BCWriterState *s, uint16_t v)
function __maybe_unused (line 36972) | static __maybe_unused void bc_put_u32(BCWriterState *s, uint32_t v)
function bc_put_u64 (line 36979) | static void bc_put_u64(BCWriterState *s, uint64_t v)
function bc_put_leb128 (line 36986) | static void bc_put_leb128(BCWriterState *s, uint32_t v)
function bc_put_sleb128 (line 36991) | static void bc_put_sleb128(BCWriterState *s, int32_t v)
function bc_set_flags (line 36996) | static void bc_set_flags(uint32_t *pflags, int *pidx, uint32_t val, int n)
function bc_atom_to_idx (line 37002) | static int bc_atom_to_idx(BCWriterState *s, uint32_t *pres, JSAtom atom)
function bc_put_atom (line 37042) | static int bc_put_atom(BCWriterState *s, JSAtom atom)
function bc_byte_swap (line 37057) | static void bc_byte_swap(uint8_t *bc_buf, int bc_len)
function JS_WriteFunctionBytecode (line 37117) | static int JS_WriteFunctionBytecode(BCWriterState *s,
function JS_WriteString (line 37163) | static void JS_WriteString(BCWriterState *s, JSString *p)
function JS_WriteBigInt (line 37175) | static int JS_WriteBigInt(BCWriterState *s, JSValueConst obj)
function JS_WriteFunctionTag (line 37226) | static int JS_WriteFunctionTag(BCWriterState *s, JSValueConst obj)
function JS_WriteModule (line 37315) | static int JS_WriteModule(BCWriterState *s, JSValueConst obj)
function JS_WriteArray (line 37369) | static int JS_WriteArray(BCWriterState *s, JSValueConst obj)
function JS_WriteObjectTag (line 37447) | static int JS_WriteObjectTag(BCWriterState *s, JSValueConst obj)
function JS_WriteTypedArray (line 37486) | static int JS_WriteTypedArray(BCWriterState *s, JSValueConst obj)
function JS_WriteArrayBuffer (line 37500) | static int JS_WriteArrayBuffer(BCWriterState *s, JSValueConst obj)
function JS_WriteSharedArrayBuffer (line 37515) | static int JS_WriteSharedArrayBuffer(BCWriterState *s, JSValueConst obj)
function JS_WriteObjectRec (line 37532) | static int JS_WriteObjectRec(BCWriterState *s, JSValueConst obj)
function JS_WriteObjectAtoms (line 37673) | static int JS_WriteObjectAtoms(BCWriterState *s)
type BCReaderState (line 37757) | typedef struct BCReaderState {
function bc_read_trace (line 37780) | static void __attribute__((format(printf, 2, 3))) bc_read_trace(BCReader...
function bc_read_error_end (line 37814) | static int bc_read_error_end(BCReaderState *s)
function bc_get_u8 (line 37822) | static int bc_get_u8(BCReaderState *s, uint8_t *pval)
function bc_get_u16 (line 37832) | static int bc_get_u16(BCReaderState *s, uint16_t *pval)
function __maybe_unused (line 37847) | static __maybe_unused int bc_get_u32(BCReaderState *s, uint32_t *pval)
function bc_get_u64 (line 37862) | static int bc_get_u64(BCReaderState *s, uint64_t *pval)
function bc_get_leb128 (line 37877) | static int bc_get_leb128(BCReaderState *s, uint32_t *pval)
function bc_get_sleb128 (line 37887) | static int bc_get_sleb128(BCReaderState *s, int32_t *pval)
function bc_get_leb128_int (line 37898) | static int bc_get_leb128_int(BCReaderState *s, int *pval)
function bc_get_leb128_u16 (line 37903) | static int bc_get_leb128_u16(BCReaderState *s, uint16_t *pval)
function bc_get_buf (line 37914) | static int bc_get_buf(BCReaderState *s, uint8_t *buf, uint32_t buf_len)
function bc_idx_to_atom (line 37925) | static int bc_idx_to_atom(BCReaderState *s, JSAtom *patom, uint32_t idx)
function bc_get_atom (line 37947) | static int bc_get_atom(BCReaderState *s, JSAtom *patom)
function JSString (line 37960) | static JSString *JS_ReadString(BCReaderState *s)
function bc_get_flags (line 38003) | static uint32_t bc_get_flags(uint32_t flags, int *pidx, int n)
function JS_ReadFunctionBytecode (line 38012) | static int JS_ReadFunctionBytecode(BCReaderState *s, JSFunctionBytecode *b,
function JSValue (line 38070) | static JSValue JS_ReadBigInt(BCReaderState *s)
function BC_add_object_ref1 (line 38124) | static int BC_add_object_ref1(BCReaderState *s, JSObject *p)
function BC_add_object_ref (line 38136) | static int BC_add_object_ref(BCReaderState *s, JSValueConst obj)
function JSValue (line 38141) | static JSValue JS_ReadFunctionTag(BCReaderState *s)
function JSValue (line 38341) | static JSValue JS_ReadModule(BCReaderState *s)
function JSValue (line 38455) | static JSValue JS_ReadObjectTag(BCReaderState *s)
function JSValue (line 38491) | static JSValue JS_ReadArray(BCReaderState *s, int tag)
function JSValue (line 38536) | static JSValue JS_ReadTypedArray(BCReaderState *s)
function JSValue (line 38583) | static JSValue JS_ReadArrayBuffer(BCReaderState *s)
function JSValue (line 38622) | static JSValue JS_ReadSharedArrayBuffer(BCReaderState *s)
function JSValue (line 38660) | static JSValue JS_ReadDate(BCReaderState *s)
function JSValue (line 38686) | static JSValue JS_ReadObjectValue(BCReaderState *s)
function JSValue (line 38707) | static JSValue JS_ReadObjectRec(BCReaderState *s)
function JS_ReadObjectAtoms (line 38820) | static int JS_ReadObjectAtoms(BCReaderState *s)
function bc_reader_free (line 38860) | static void bc_reader_free(BCReaderState *s)
function JSValue (line 38872) | JSValue JS_ReadObject(JSContext *ctx, const uint8_t *buf, size_t buf_len,
function check_function (line 38913) | static int check_function(JSContext *ctx, JSValueConst obj)
function check_exception_free (line 38921) | static int check_exception_free(JSContext *ctx, JSValue obj)
function JSAtom (line 38927) | static JSAtom find_atom(JSContext *ctx, const char *name)
function JSValue (line 38950) | static JSValue JS_NewObjectProtoList(JSContext *ctx, JSValueConst proto,
function JSValue (line 38964) | static JSValue JS_InstantiateFunctionListItem2(JSContext *ctx, JSObject *p,
function JS_InstantiateFunctionListItem (line 38993) | static int JS_InstantiateFunctionListItem(JSContext *ctx, JSValueConst obj,
function JS_SetPropertyFunctionList (line 39104) | int JS_SetPropertyFunctionList(JSContext *ctx, JSValueConst obj,
function JS_AddModuleExportList (line 39122) | int JS_AddModuleExportList(JSContext *ctx, JSModuleDef *m,
function JS_SetModuleExportList (line 39133) | int JS_SetModuleExportList(JSContext *ctx, JSModuleDef *m,
function JS_SetConstructor2 (line 39172) | static int JS_SetConstructor2(JSContext *ctx,
function JS_SetConstructor (line 39190) | int JS_SetConstructor(JSContext *ctx, JSValueConst func_obj,
function JSValue (line 39206) | static JSValue JS_NewCConstructor(JSContext *ctx, int class_id, const ch...
function JSValue (line 39275) | static JSValue js_global_eval(JSContext *ctx, JSValueConst this_val,
function JSValue (line 39281) | static JSValue js_global_isNaN(JSContext *ctx, JSValueConst this_val,
function JSValue (line 39291) | static JSValue js_global_isFinite(JSContext *ctx, JSValueConst this_val,
function JSValue (line 39302) | static JSValue JS_ToObject(JSContext *ctx, JSValueConst val)
function JSValue (line 39352) | static JSValue JS_ToObjectFree(JSContext *ctx, JSValue val)
function js_obj_to_desc (line 39359) | static int js_obj_to_desc(JSContext *ctx, JSPropertyDescriptor *d,
function __exception (line 39438) | static __exception int JS_DefinePropertyDesc(JSContext *ctx, JSValueCons...
function __exception (line 39454) | static __exception int JS_ObjectDefineProperties(JSContext *ctx,
function JSValue (line 39493) | static JSValue js_object_constructor(JSContext *ctx, JSValueConst new_ta...
function JSValue (line 39516) | static JSValue js_object_create(JSContext *ctx, JSValueConst this_val,
function JSValue (line 39538) | static JSValue js_object_getPrototypeOf(JSContext *ctx, JSValueConst thi...
function JSValue (line 39554) | static JSValue js_object_setPrototypeOf(JSContext *ctx, JSValueConst thi...
function JSValue (line 39565) | static JSValue js_object_defineProperty(JSContext *ctx, JSValueConst thi...
function JSValue (line 39595) | static JSValue js_object_defineProperties(JSContext *ctx, JSValueConst t...
function JSValue (line 39608) | static JSValue js_object___defineGetter__(JSContext *ctx, JSValueConst t...
function JSValue (line 39654) | static JSValue js_object_getOwnPropertyDescriptor(JSContext *ctx, JSValu...
function JSValue (line 39718) | static JSValue js_object_getOwnPropertyDescriptors(JSContext *ctx, JSVal...
function JSValue (line 39769) | static JSValue JS_GetOwnPropertyNames2(JSContext *ctx, JSValueConst obj1,
function JSValue (line 39848) | static JSValue js_object_getOwnPropertyNames(JSContext *ctx, JSValueCons...
function JSValue (line 39855) | static JSValue js_object_getOwnPropertySymbols(JSContext *ctx, JSValueCo...
function JSValue (line 39862) | static JSValue js_object_keys(JSContext *ctx, JSValueConst this_val,
function JSValue (line 39869) | static JSValue js_object_isExtensible(JSContext *ctx, JSValueConst this_...
function JSValue (line 39889) | static JSValue js_object_preventExtensions(JSContext *ctx, JSValueConst ...
function JSValue (line 39914) | static JSValue js_object_hasOwnProperty(JSContext *ctx, JSValueConst thi...
function JSValue (line 39940) | static JSValue js_object_hasOwn(JSContext *ctx, JSValueConst this_val,
function JSValue (line 39966) | static JSValue js_object_valueOf(JSContext *ctx, JSValueConst this_val,
function JSValue (line 39972) | static JSValue js_object_toString(JSContext *ctx, JSValueConst this_val,
function JSValue (line 40027) | static JSValue js_object_toLocaleString(JSContext *ctx, JSValueConst thi...
function JSValue (line 40033) | static JSValue js_object_assign(JSContext *ctx, JSValueConst this_val,
function JSValue (line 40061) | static JSValue js_object_seal(JSContext *ctx, JSValueConst this_val,
function JSValue (line 40112) | static JSValue js_object_isSealed(JSContext *ctx, JSValueConst this_val,
function JSValue (line 40158) | static JSValue js_object_fromEntries(JSContext *ctx, JSValueConst this_val,
function JSValue (line 40224) | static JSValue js_object_is(JSContext *ctx, JSValueConst this_val,
function JSValue (line 40230) | static JSValue JS_SpeciesConstructor(JSContext *ctx, JSValueConst obj,
function JSValue (line 40260) | static JSValue js_object_get___proto__(JSContext *ctx, JSValueConst this...
function JSValue (line 40272) | static JSValue js_object_set___proto__(JSContext *ctx, JSValueConst this...
function JSValue (line 40285) | static JSValue js_object_isPrototypeOf(JSContext *ctx, JSValueConst this...
function JSValue (line 40325) | static JSValue js_object_propertyIsEnumerable(JSContext *ctx, JSValueCon...
function JSValue (line 40356) | static JSValue js_object___lookupGetter__(JSContext *ctx, JSValueConst t...
function JSValue (line 40443) | static JSValue js_function_proto(JSContext *ctx, JSValueConst this_val,
function JSValue (line 40450) | static JSValue js_function_constructor(JSContext *ctx, JSValueConst new_...
function __exception (line 40520) | static __exception int js_get_length32(JSContext *ctx, uint32_t *pres,
function __exception (line 40532) | static __exception int js_get_length64(JSContext *ctx, int64_t *pres,
function free_arg_list (line 40544) | static void free_arg_list(JSContext *ctx, JSValue *tab, uint32_t len)
function JSValue (line 40554) | static JSValue *build_arg_list(JSContext *ctx, uint32_t *plen,
function JSValue (line 40608) | static JSValue js_function_apply(JSContext *ctx, JSValueConst this_val,
function JSValue (line 40635) | static JSValue js_function_call(JSContext *ctx, JSValueConst this_val,
function JSValue (line 40645) | static JSValue js_function_bind(JSContext *ctx, JSValueConst this_val,
function JSValue (line 40730) | static JSValue js_function_toString(JSContext *ctx, JSValueConst this_val,
function JSValue (line 40774) | static JSValue js_function_hasInstance(JSContext *ctx, JSValueConst this...
function JSValue (line 40798) | static JSValue iterator_to_array(JSContext *ctx, JSValueConst items)
function JSValue (line 40836) | static JSValue js_error_constructor(JSContext *ctx, JSValueConst new_tar...
function JSValue (line 40910) | static JSValue js_error_toString(JSContext *ctx, JSValueConst this_val,
function JSValue (line 40964) | static JSValue js_error_isError(JSContext *ctx, JSValueConst this_val,
function JSValue (line 40977) | static JSValue js_aggregate_error_constructor(JSContext *ctx,
function JS_CopySubArray (line 40994) | static int JS_CopySubArray(JSContext *ctx,
function JSValue (line 41064) | static JSValue js_array_constructor(JSContext *ctx, JSValueConst new_tar...
function JSValue (line 41091) | static JSValue js_array_from(JSContext *ctx, JSValueConst this_val,
function JSValue (line 41210) | static JSValue js_array_of(JSContext *ctx, JSValueConst this_val,
function JSValue (line 41238) | static JSValue js_array_isArray(JSContext *ctx, JSValueConst this_val,
function JSValue (line 41249) | static JSValue js_get_this(JSContext *ctx,
function JSValue (line 41255) | static JSValue JS_ArraySpeciesCreate(JSContext *ctx, JSValueConst obj,
function JS_isConcatSpreadable (line 41308) | static int JS_isConcatSpreadable(JSContext *ctx, JSValueConst obj)
function JSValue (line 41322) | static JSValue js_array_at(JSContext *ctx, JSValueConst this_val,
function JSValue (line 41357) | static JSValue js_array_with(JSContext *ctx, JSValueConst this_val,
function JSValue (line 41422) | static JSValue js_array_concat(JSContext *ctx, JSValueConst this_val,
function JSValue (line 41499) | static JSValue js_array_every(JSContext *ctx, JSValueConst this_val,
function JSValue (line 41656) | static JSValue js_array_reduce(JSContext *ctx, JSValueConst this_val,
function JSValue (line 41747) | static JSValue js_array_fill(JSContext *ctx, JSValueConst this_val,
function JSValue (line 41783) | static JSValue js_array_includes(JSContext *ctx, JSValueConst this_val,
function JSValue (line 41833) | static JSValue js_array_indexOf(JSContext *ctx, JSValueConst this_val,
function JSValue (line 41882) | static JSValue js_array_lastIndexOf(JSContext *ctx, JSValueConst this_val,
function JSValue (line 41928) | static JSValue js_array_find(JSContext *ctx, JSValueConst this_val,
function JSValue (line 42001) | static JSValue js_array_toString(JSContext *ctx, JSValueConst this_val,
function JSValue (line 42024) | static JSValue js_array_join(JSContext *ctx, JSValueConst this_val,
function JSValue (line 42081) | static JSValue js_array_pop(JSContext *ctx, JSValueConst this_val,
function JSValue (line 42134) | static JSValue js_array_push(JSContext *ctx, JSValueConst this_val,
function JSValue (line 42194) | static JSValue js_array_reverse(JSContext *ctx, JSValueConst this_val,
function JSValue (line 42267) | static JSValue js_array_toReversed(JSContext *ctx, JSValueConst this_val,
function JSValue (line 42318) | static JSValue js_array_slice(JSContext *ctx, JSValueConst this_val,
function JSValue (line 42425) | static JSValue js_array_toSpliced(JSContext *ctx, JSValueConst this_val,
function JSValue (line 42511) | static JSValue js_array_copyWithin(JSContext *ctx, JSValueConst this_val,
function JS_FlattenIntoArray (line 42546) | static int64_t JS_FlattenIntoArray(JSContext *ctx, JSValueConst target,
function JSValue (line 42608) | static JSValue js_array_flatten(JSContext *ctx, JSValueConst this_val,
type ValueSlot (line 42654) | typedef struct ValueSlot {
type array_sort_context (line 42660) | struct array_sort_context {
function js_array_cmp_generic (line 42667) | static int js_array_cmp_generic(const void *a, const void *b, void *opaq...
function JSValue (line 42728) | static JSValue js_array_sort(JSContext *ctx, JSValueConst this_val,
function JSValue (line 42818) | static JSValue js_array_toSorted(JSContext *ctx, JSValueConst this_val,
type JSArrayIteratorData (line 42876) | typedef struct JSArrayIteratorData {
function js_array_iterator_finalizer (line 42882) | static void js_array_iterator_finalizer(JSRuntime *rt, JSValue val)
function js_array_iterator_mark (line 42892) | static void js_array_iterator_mark(JSRuntime *rt, JSValueConst val,
function JSValue (line 42902) | static JSValue js_create_array_iterator(JSContext *ctx, JSValueConst thi...
function JSValue (line 42939) | static JSValue js_array_iterator_next(JSContext *ctx, JSValueConst this_...
type JSIteratorWrapData (line 43002) | typedef struct JSIteratorWrapData {
function js_iterator_wrap_finalizer (line 43007) | static void js_iterator_wrap_finalizer(JSRuntime *rt, JSValue val)
function js_iterator_wrap_mark (line 43018) | static void js_iterator_wrap_mark(JSRuntime *rt, JSValueConst val,
function JSValue (line 43029) | static JSValue js_iterator_wrap_next(JSContext *ctx, JSValueConst this_val,
function JSValue (line 43061) | static JSValue js_iterator_constructor_getset(JSContext *ctx,
function JSValue (line 43083) | static JSValue js_iterator_constructor(JSContext *ctx, JSValueConst new_...
type JSIteratorConcatData (line 43100) | typedef struct JSIteratorConcatData {
function js_iterator_concat_finalizer (line 43106) | static void js_iterator_concat_finalizer(JSRuntime *rt, JSValue val)
function js_iterator_concat_mark (line 43119) | static void js_iterator_concat_mark(JSRuntime *rt, JSValueConst val,
function JSValue (line 43132) | static JSValue js_iterator_concat_next(JSContext *ctx, JSValueConst this...
function JSValue (line 43207) | static JSValue js_iterator_concat_return(JSContext *ctx, JSValueConst th...
function JSValue (line 43244) | static JSValue js_iterator_concat(JSContext *ctx, JSValueConst this_val,
function JSValue (line 43287) | static JSValue js_iterator_from(JSContext *ctx, JSValueConst this_val,
type JSIteratorHelperKindEnum (line 43342) | typedef enum JSIteratorHelperKindEnum {
type JSIteratorHelperData (line 43354) | typedef struct JSIteratorHelperData {
function JSValue (line 43365) | static JSValue js_create_iterator_helper(JSContext *ctx, JSValueConst th...
function JSValue (line 43458) | static JSValue js_iterator_proto_func(JSContext *ctx, JSValueConst this_...
function JSValue (line 43613) | static JSValue js_iterator_proto_reduce(JSContext *ctx, JSValueConst thi...
function JSValue (line 43678) | static JSValue js_iterator_proto_toArray(JSContext *ctx, JSValueConst th...
function JSValue (line 43714) | static JSValue js_iterator_proto_iterator(JSContext *ctx, JSValueConst t...
function JSValue (line 43720) | static JSValue js_iterator_proto_get_toStringTag(JSContext *ctx, JSValue...
function JSValue (line 43725) | static JSValue js_iterator_proto_set_toStringTag(JSContext *ctx, JSValue...
function js_iterator_helper_finalizer (line 43748) | static void js_iterator_helper_finalizer(JSRuntime *rt, JSValue val)
function js_iterator_helper_mark (line 43761) | static void js_iterator_helper_mark(JSRuntime *rt, JSValueConst val,
function JSValue (line 43774) | static JSValue js_iterator_helper_next(JSContext *ctx, JSValueConst this...
function JSValue (line 44125) | static JSValue js_number_constructor(JSContext *ctx, JSValueConst new_ta...
function JSValue (line 44165) | static JSValue js_number___toInteger(JSContext *ctx, JSValueConst this_val,
function JSValue (line 44171) | static JSValue js_number___toLength(JSContext *ctx, JSValueConst this_val,
function JSValue (line 44181) | static JSValue js_number_isNaN(JSContext *ctx, JSValueConst this_val,
function JSValue (line 44189) | static JSValue js_number_isFinite(JSContext *ctx, JSValueConst this_val,
function JSValue (line 44197) | static JSValue js_number_isInteger(JSContext *ctx, JSValueConst this_val,
function JSValue (line 44208) | static JSValue js_number_isSafeInteger(JSContext *ctx, JSValueConst this...
function JSValue (line 44239) | static JSValue js_thisNumberValue(JSContext *ctx, JSValueConst this_val)
function JSValue (line 44254) | static JSValue js_number_valueOf(JSContext *ctx, JSValueConst this_val,
function js_get_radix (line 44260) | static int js_get_radix(JSContext *ctx, JSValueConst val)
function JSValue (line 44272) | static JSValue js_number_toString(JSContext *ctx, JSValueConst this_val,
function JSValue (line 44306) | static JSValue js_number_toFixed(JSContext *ctx, JSValueConst this_val,
function JSValue (line 44329) | static JSValue js_number_toExponential(JSContext *ctx, JSValueConst this...
function JSValue (line 44358) | static JSValue js_number_toPrecision(JSContext *ctx, JSValueConst this_val,
function JSValue (line 44392) | static JSValue js_parseInt(JSContext *ctx, JSValueConst this_val,
function JSValue (line 44418) | static JSValue js_parseFloat(JSContext *ctx, JSValueConst this_val,
function JSValue (line 44435) | static JSValue js_boolean_constructor(JSContext *ctx, JSValueConst new_t...
function JSValue (line 44450) | static JSValue js_thisBooleanValue(JSContext *ctx, JSValueConst this_val)
function JSValue (line 44465) | static JSValue js_boolean_toString(JSContext *ctx, JSValueConst this_val,
function JSValue (line 44475) | static JSValue js_boolean_valueOf(JSContext *ctx, JSValueConst this_val,
function js_string_get_own_property (line 44488) | static int js_string_get_own_property(JSContext *ctx,
function js_string_define_own_property (line 44517) | static int js_string_define_own_property(JSContext *ctx,
function js_string_delete_property (line 44557) | static int js_string_delete_property(JSContext *ctx,
function JSValue (line 44577) | static JSValue js_string_constructor(JSContext *ctx, JSValueConst new_ta...
function JSValue (line 44609) | static JSValue js_thisStringValue(JSContext *ctx, JSValueConst this_val)
function JSValue (line 44625) | static JSValue js_string_fromCharCode(JSContext *ctx, JSValueConst this_...
function JSValue (line 44643) | static JSValue js_string_fromCodePoint(JSContext *ctx, JSValueConst this...
function JSValue (line 44677) | static JSValue js_string_raw(JSContext *ctx, JSValueConst this_val,
function JSValue (line 44718) | JSValue js_string_codePointRange(JSContext *ctx, JSValueConst this_val,
function JSValue (line 44745) | static JSValue js_string___isSpace(JSContext *ctx, JSValueConst this_val,
function JSValue (line 44755) | static JSValue js_string_charCodeAt(JSContext *ctx, JSValueConst this_val,
function JSValue (line 44780) | static JSValue js_string_charAt(JSContext *ctx, JSValueConst this_val,
function JSValue (line 44810) | static JSValue js_string_codePointAt(JSContext *ctx, JSValueConst this_val,
function JSValue (line 44835) | static JSValue js_string_concat(JSContext *ctx, JSValueConst this_val,
function string_cmp (line 44853) | static int string_cmp(JSString *p1, JSString *p2, int x1, int x2, int len)
function string_indexof_char (line 44863) | static int string_indexof_char(JSString *p, int c, int from)
function string_indexof (line 44883) | static int string_indexof(JSString *p1, JSString *p2, int from)
function string_advance_index (line 44899) | static int64_t string_advance_index(JSString *p, int64_t index, BOOL uni...
function js_string_find_invalid_codepoint (line 44913) | static int js_string_find_invalid_codepoint(JSString *p)
function JSValue (line 44932) | static JSValue js_string_isWellFormed(JSContext *ctx, JSValueConst this_...
function JSValue (line 44948) | static JSValue js_string_toWellFormed(JSContext *ctx, JSValueConst this_...
function JSValue (line 44985) | static JSValue js_string_indexOf(JSContext *ctx, JSValueConst this_val,
function JSValue (line 45053) | static JSValue js_string_includes(JSContext *ctx, JSValueConst this_val,
function check_regexp_g_flag (line 45117) | static int check_regexp_g_flag(JSContext *ctx, JSValueConst regexp)
function JSValue (line 45146) | static JSValue js_string_match(JSContext *ctx, JSValueConst this_val,
function js_string_GetSubstitution (line 45198) | static int js_string_GetSubstitution(JSContext *ctx,
function JSValue (line 45318) | static JSValue js_string_replace(JSContext *ctx, JSValueConst this_val,
function JSValue (line 45431) | static JSValue js_string_split(JSContext *ctx, JSValueConst this_val,
function JSValue (line 45520) | static JSValue js_string_substring(JSContext *ctx, JSValueConst this_val,
function JSValue (line 45554) | static JSValue js_string_substr(JSContext *ctx, JSValueConst this_val,
function JSValue (line 45582) | static JSValue js_string_slice(JSContext *ctx, JSValueConst this_val,
function JSValue (line 45610) | static JSValue js_string_pad(JSContext *ctx, JSValueConst this_val,
function JSValue (line 45681) | static JSValue js_string_repeat(JSContext *ctx, JSValueConst this_val,
function JSValue (line 45726) | static JSValue js_string_trim(JSContext *ctx, JSValueConst this_val,
function string_prevc (line 45753) | static int string_prevc(JSString *p, int *pidx)
function BOOL (line 45777) | static BOOL test_final_sigma(JSString *p, int sigma_pos)
function JSValue (line 45805) | static JSValue js_string_toLowerCase(JSContext *ctx, JSValueConst this_val,
function JS_ToUTF32String (line 45846) | static int JS_ToUTF32String(JSContext *ctx, uint32_t **pbuf, JSValueCons...
function JSValue (line 45874) | static JSValue JS_NewUTF32String(JSContext *ctx, const uint32_t *buf, in...
function js_string_normalize1 (line 45890) | static int js_string_normalize1(JSContext *ctx, uint32_t **pout_buf,
function JSValue (line 45909) | static JSValue js_string_normalize(JSContext *ctx, JSValueConst this_val,
function js_UTF32_compare (line 45963) | static int js_UTF32_compare(const uint32_t *buf1, int buf1_len,
function JSValue (line 45983) | static JSValue js_string_localeCompare(JSContext *ctx, JSValueConst this...
function JSValue (line 46017) | static JSValue js_string_localeCompare(JSContext *ctx, JSValueConst this...
function JSValue (line 46039) | static JSValue js_string_toString(JSContext *ctx, JSValueConst this_val,
function JSValue (line 46047) | static JSValue js_string_iterator_next(JSContext *ctx, JSValueConst this...
function JSValue (line 46100) | static JSValue js_string_CreateHTML(JSContext *ctx, JSValueConst this_val,
function JS_AddIntrinsicStringNormalize (line 46226) | int JS_AddIntrinsicStringNormalize(JSContext *ctx)
function js_fmin (line 46235) | static double js_fmin(double a, double b)
function js_fmax (line 46249) | static double js_fmax(double a, double b)
function JSValue (line 46262) | static JSValue js_math_min_max(JSContext *ctx, JSValueConst this_val,
function js_math_sign (line 46315) | static double js_math_sign(double a)
function js_math_round (line 46325) | static double js_math_round(double a)
function JSValue (line 46353) | static JSValue js_math_hypot(JSContext *ctx, JSValueConst this_val,
function js_math_f16round (line 46377) | static double js_math_f16round(double a)
function js_math_fround (line 46382) | static double js_math_fround(double a)
function JSValue (line 46387) | static JSValue js_math_imul(JSContext *ctx, JSValueConst this_val,
function JSValue (line 46402) | static JSValue js_math_clz32(JSContext *ctx, JSValueConst this_val,
type SumPreciseStateEnum (line 46416) | typedef enum {
type SumPreciseState (line 46430) | typedef struct {
function sum_precise_init (line 46439) | static void sum_precise_init(SumPreciseState *s)
function sum_precise_renorm (line 46447) | static void sum_precise_renorm(SumPreciseState *s)
function sum_precise_add (line 46464) | static void sum_precise_add(SumPreciseState *s, double d)
function sum_precise_get_result (line 46527) | static double sum_precise_get_result(SumPreciseState *s)
function JSValue (line 46628) | static JSValue js_math_sumPrecise(JSContext *ctx, JSValueConst this_val,
function xorshift64star (line 46672) | static uint64_t xorshift64star(uint64_t *pstate)
function js_random_init (line 46683) | static void js_random_init(JSContext *ctx)
function JSValue (line 46693) | static JSValue js_math_random(JSContext *ctx, JSValueConst this_val,
function getTimezoneOffset (line 46764) | static int getTimezoneOffset(int64_t time)
function JSValue (line 46819) | static JSValue js___date_getTimezoneOffset(JSContext *ctx, JSValueConst ...
function JSValue (line 46832) | static JSValue js_get_prototype_from_ctor(JSContext *ctx, JSValueConst c...
function JSValue (line 46847) | static JSValue js___date_create(JSContext *ctx, JSValueConst this_val,
function js_regexp_finalizer (line 46864) | static void js_regexp_finalizer(JSRuntime *rt, JSValue val)
function JSValue (line 46875) | static JSValue js_compile_regexp(JSContext *ctx, JSValueConst pattern,
function JSValue (line 46954) | static JSValue JS_NewRegexp(JSContext *ctx, JSValue pattern, JSValue bc)
function JSValue (line 46983) | static JSValue js_regexp_set_internal(JSContext *ctx,
function JSRegExp (line 47010) | static JSRegExp *js_get_regexp(JSContext *ctx, JSValueConst obj, BOOL th...
function js_is_regexp (line 47024) | static int js_is_regexp(JSContext *ctx, JSValueConst obj)
function JSValue (line 47038) | static JSValue js_regexp_constructor(JSContext *ctx, JSValueConst new_ta...
function JSValue (line 47121) | static JSValue js_regexp_compile(JSContext *ctx, JSValueConst this_val,
function JSValue (line 47165) | static JSValue js_regexp_get_source(JSContext *ctx, JSValueConst this_val)
function JSValue (line 47231) | static JSValue js_regexp_get_flag(JSContext *ctx, JSValueConst this_val,...
function JSValue (line 47253) | static JSValue js_regexp_get_flags(JSContext *ctx, JSValueConst this_val)
function JSValue (line 47285) | static JSValue js_regexp_toString(JSContext *ctx, JSValueConst this_val,
function lre_check_stack_overflow (line 47310) | int lre_check_stack_overflow(void *opaque, size_t alloca_size)
function lre_check_timeout (line 47316) | int lre_check_timeout(void *opaque)
function JSValue (line 47331) | static JSValue js_regexp_escape(JSContext *ctx, JSValueConst this_val,
function force_inline (line 47384) | static force_inline int js_regexp_get_lastIndex(JSContext *ctx, int64_t ...
function force_inline (line 47399) | static force_inline int js_regexp_set_lastIndex(JSContext *ctx, JSValueC...
function JSValue (line 47416) | static JSValue js_regexp_exec(JSContext *ctx, JSValueConst this_val,
function JSValue (line 47636) | static JSValue js_regexp_replace(JSContext *ctx, JSValueConst this_val, ...
function JSValue (line 47752) | static JSValue JS_RegExpExec(JSContext *ctx, JSValueConst r, JSValueCons...
function JSValue (line 47773) | static JSValue js_regexp_test(JSContext *ctx, JSValueConst this_val,
function JSValue (line 47787) | static JSValue js_regexp_Symbol_match(JSContext *ctx, JSValueConst this_...
type JSRegExpStringIteratorData (line 47870) | typedef struct JSRegExpStringIteratorData {
function js_regexp_string_iterator_finalizer (line 47878) | static void js_regexp_string_iterator_finalizer(JSRuntime *rt, JSValue val)
function js_regexp_string_iterator_mark (line 47889) | static void js_regexp_string_iterator_mark(JSRuntime *rt, JSValueConst val,
function JSValue (line 47900) | static JSValue js_regexp_string_iterator_next(JSContext *ctx,
function JSValue (line 47954) | static JSValue js_regexp_Symbol_matchAll(JSContext *ctx, JSValueConst th...
type ValueBuffer (line 48021) | typedef struct ValueBuffer {
function value_buffer_init (line 48030) | static int value_buffer_init(JSContext *ctx, ValueBuffer *b)
function value_buffer_free (line 48040) | static void value_buffer_free(ValueBuffer *b)
function value_buffer_append (line 48050) | static int value_buffer_append(ValueBuffer *b, JSValue val)
function JSShapeProperty (line 48082) | static JSShapeProperty *find_property_regexp(JSProperty **ppr,
function BOOL (line 48099) | static BOOL check_regexp_getter(JSContext *ctx,
function BOOL (line 48115) | static BOOL js_is_standard_regexp(JSContext *ctx, JSValueConst obj)
function JSValue (line 48155) | static JSValue js_regexp_Symbol_replace(JSContext *ctx, JSValueConst thi...
function JSValue (line 48350) | static JSValue js_regexp_Symbol_search(JSContext *ctx, JSValueConst this...
function JSValue (line 48408) | static JSValue js_regexp_Symbol_split(JSContext *ctx, JSValueConst this_...
function JS_AddIntrinsicRegExpCompiler (line 48567) | void JS_AddIntrinsicRegExpCompiler(JSContext *ctx)
function JS_AddIntrinsicRegExp (line 48572) | int JS_AddIntrinsicRegExp(JSContext *ctx)
function json_parse_expect (line 48625) | static int json_parse_expect(JSParseState *s, int tok)
function JSValue (line 48634) | static JSValue json_parse_value(JSParseState *s)
function JSValue (line 48767) | JSValue JS_ParseJSON2(JSContext *ctx, const char *buf, size_t buf_len,
function JSValue (line 48791) | JSValue JS_ParseJSON(JSContext *ctx, const char *buf, size_t buf_len,
function JSValue (line 48797) | static JSValue internalize_json_property(JSContext *ctx, JSValueConst ho...
function JSValue (line 48866) | static JSValue js_json_parse(JSContext *ctx, JSValueConst this_val,
type JSONStringifyContext (line 48900) | typedef struct JSONStringifyContext {
function JS_ToQuotedString (line 48909) | static int JS_ToQuotedString(JSContext *ctx, StringBuffer *b, JSValueCon...
function JS_ToQuotedStringFree (line 48971) | static int JS_ToQuotedStringFree(JSContext *ctx, StringBuffer *b, JSValu...
function JSValue (line 48977) | static JSValue js_json_check(JSContext *ctx, JSONStringifyContext *jsc,
function js_json_to_str (line 49035) | static int js_json_to_str(JSContext *ctx, JSONStringifyContext *jsc,
function JSValue (line 49220) | JSValue JS_JSONStringify(JSContext *ctx, JSValueConst obj,
function JSValue (line 49354) | static JSValue js_json_stringify(JSContext *ctx, JSValueConst this_val,
function JS_AddIntrinsicJSON (line 49371) | int JS_AddIntrinsicJSON(JSContext *ctx)
function JSValue (line 49379) | static JSValue js_reflect_apply(JSContext *ctx, JSValueConst this_val,
function JSValue (line 49385) | static JSValue js_reflect_construct(JSContext *ctx, JSValueConst this_val,
function JSValue (line 49409) | static JSValue js_reflect_deleteProperty(JSContext *ctx, JSValueConst th...
function JSValue (line 49430) | static JSValue js_reflect_get(JSContext *ctx, JSValueConst this_val,
function JSValue (line 49453) | static JSValue js_reflect_has(JSContext *ctx, JSValueConst this_val,
function JSValue (line 49475) | static JSValue js_reflect_set(JSContext *ctx, JSValueConst this_val,
function JSValue (line 49503) | static JSValue js_reflect_setPrototypeOf(JSContext *ctx, JSValueConst th...
function JSValue (line 49514) | static JSValue js_reflect_ownKeys(JSContext *ctx, JSValueConst this_val,
function js_proxy_finalizer (line 49547) | static void js_proxy_finalizer(JSRuntime *rt, JSValue val)
function js_proxy_mark (line 49557) | static void js_proxy_mark(JSRuntime *rt, JSValueConst val,
function JSValue (line 49567) | static JSValue JS_ThrowTypeErrorRevokedProxy(JSContext *ctx)
function JSProxyData (line 49572) | static JSProxyData *get_proxy_method(JSContext *ctx, JSValue *pmethod,
function JSValue (line 49598) | static JSValue js_proxy_get_prototype(JSContext *ctx, JSValueConst obj)
function js_proxy_set_prototype (line 49639) | static int js_proxy_set_prototype(JSContext *ctx, JSValueConst obj,
function js_proxy_is_extensible (line 49678) | static int js_proxy_is_extensible(JSContext *ctx, JSValueConst obj)
function js_proxy_prevent_extensions (line 49704) | static int js_proxy_prevent_extensions(JSContext *ctx, JSValueConst obj)
function js_proxy_has (line 49732) | static int js_proxy_has(JSContext *ctx, JSValueConst obj, JSAtom atom)
function JSValue (line 49776) | static JSValue js_proxy_get(JSContext *ctx, JSValueConst obj, JSAtom atom,
function js_proxy_set (line 49826) | static int js_proxy_set(JSContext *ctx, JSValueConst obj, JSAtom atom,
function JSValue (line 49884) | static JSValue js_create_desc(JSContext *ctx, JSValueConst val,
function js_proxy_get_own_property (line 49922) | static int js_proxy_get_own_property(JSContext *ctx, JSPropertyDescripto...
function js_proxy_define_own_property (line 50027) | static int js_proxy_define_own_property(JSContext *ctx, JSValueConst obj,
function js_proxy_delete_property (line 50124) | static int js_proxy_delete_property(JSContext *ctx, JSValueConst obj,
function find_prop_key (line 50176) | static int find_prop_key(const JSPropertyEnum *tab, int n, JSAtom atom)
function js_proxy_get_own_property_names (line 50186) | static int js_proxy_get_own_property_names(JSContext *ctx,
function JSValue (line 50304) | static JSValue js_proxy_call_constructor(JSContext *ctx, JSValueConst fu...
function JSValue (line 50338) | static JSValue js_proxy_call(JSContext *ctx, JSValueConst func_obj,
function js_resolve_proxy (line 50379) | static int js_resolve_proxy(JSContext *ctx, JSValueConst *pval, BOOL thr...
function JSValue (line 50418) | static JSValue js_proxy_constructor(JSContext *ctx, JSValueConst this_val,
function JSValue (line 50448) | static JSValue js_proxy_revoke(JSContext *ctx, JSValueConst this_val,
function JSValue (line 50463) | static JSValue js_proxy_revoke_constructor(JSContext *ctx,
function JSValue (line 50469) | static JSValue js_proxy_revocable(JSContext *ctx, JSValueConst this_val,
function JS_AddIntrinsicProxy (line 50501) | int JS_AddIntrinsicProxy(JSContext *ctx)
function JSValue (line 50535) | static JSValue js_symbol_constructor(JSContext *ctx, JSValueConst new_ta...
function JSValue (line 50554) | static JSValue js_thisSymbolValue(JSContext *ctx, JSValueConst this_val)
function JSValue (line 50569) | static JSValue js_symbol_toString(JSContext *ctx, JSValueConst this_val,
function JSValue (line 50582) | static JSValue js_symbol_valueOf(JSContext *ctx, JSValueConst this_val,
function JSValue (line 50588) | static JSValue js_symbol_get_description(JSContext *ctx, JSValueConst th...
function JSValue (line 50615) | static JSValue js_symbol_for(JSContext *ctx, JSValueConst this_val,
function JSValue (line 50626) | static JSValue js_symbol_keyFor(JSContext *ctx, JSValueConst this_val,
function BOOL (line 50659) | static BOOL js_weakref_is_target(JSValueConst val)
function BOOL (line 50680) | static BOOL js_weakref_is_live(JSValueConst val)
function js_weakref_free (line 50690) | static void js_weakref_free(JSRuntime *rt, JSValue val)
function JSValue (line 50716) | static JSValue js_weakref_new(JSContext *ctx, JSValueConst val)
function JSValue (line 50735) | static JSValue js_map_constructor(JSContext *ctx, JSValueConst new_target,
function JSValue (line 50847) | static JSValue map_normalize_key(JSContext *ctx, JSValue key)
function JSValueConst (line 50857) | static JSValueConst map_normalize_key_const(JSContext *ctx, JSValueConst...
function map_hash32 (line 50867) | static uint32_t map_hash32(uint32_t a, int hash_bits)
function map_hash64 (line 50872) | static uint32_t map_hash64(uint64_t a, int hash_bits)
function map_hash_pointer (line 50877) | static uint32_t map_hash_pointer(uintptr_t a, int hash_bits)
function map_hash_key (line 50888) | static uint32_t map_hash_key(JSValueConst key, int hash_bits)
function JSMapRecord (line 50945) | static JSMapRecord *map_find_record(JSContext *ctx, JSMapState *s,
function map_hash_resize (line 50962) | static void map_hash_resize(JSContext *ctx, JSMapState *s)
function JSMapRecord (line 50994) | static JSMapRecord *map_add_record(JSContext *ctx, JSMapState *s,
function JSMapRecord (line 51021) | static JSMapRecord *set_add_record(JSContext *ctx, JSMapState *s,
function map_delete_record_internal (line 51033) | static void map_delete_record_internal(JSRuntime *rt, JSMapState *s, JSM...
function map_decref_record (line 51056) | static void map_decref_record(JSRuntime *rt, JSMapRecord *mr)
function map_delete_weakrefs (line 51066) | static void map_delete_weakrefs(JSRuntime *rt, JSWeakRefHeader *wh)
function JSValue (line 51098) | static JSValue js_map_set(JSContext *ctx, JSValueConst this_val,
function JSValue (line 51126) | static JSValue js_map_get(JSContext *ctx, JSValueConst this_val,
function JSValue (line 51144) | static JSValue map_delete_record(JSContext *ctx, JSMapState *s, JSValueC...
function JSValue (line 51173) | static JSValue js_map_getOrInsert(JSContext *ctx, JSValueConst this_val,
function JSValue (line 51210) | static JSValue js_map_has(JSContext *ctx, JSValueConst this_val,
function JSValue (line 51224) | static JSValue js_map_delete(JSContext *ctx, JSValueConst this_val,
function JSValue (line 51233) | static JSValue js_map_clear(JSContext *ctx, JSValueConst this_val,
function JSValue (line 51253) | static JSValue js_map_get_size(JSContext *ctx, JSValueConst this_val, in...
function JSValue (line 51261) | static JSValue js_map_forEach(JSContext *ctx, JSValueConst this_val,
function JSValue (line 51309) | static JSValue js_object_groupBy(JSContext *ctx, JSValueConst this_val,
function js_map_finalizer (line 51426) | static void js_map_finalizer(JSRuntime *rt, JSValue val)
function js_map_mark (line 51457) | static void js_map_mark(JSRuntime *rt, JSValueConst val, JS_MarkFunc *ma...
type JSMapIteratorData (line 51477) | typedef struct JSMapIteratorData {
function js_map_iterator_finalizer (line 51483) | static void js_map_iterator_finalizer(JSRuntime *rt, JSValue val)
function js_map_iterator_mark (line 51501) | static void js_map_iterator_mark(JSRuntime *rt, JSValueConst val,
function JSValue (line 51513) | static JSValue js_create_map_iterator(JSContext *ctx, JSValueConst this_...
function JSValue (line 51543) | static JSValue js_map_iterator_next(JSContext *ctx, JSValueConst this_val,
function get_set_record (line 51608) | static int get_set_record(JSContext *ctx, JSValueConst obj,
function JSValue (line 51681) | static JSValue js_copy_set(JSContext *ctx, JSValueConst this_val)
function JSValue (line 51712) | static JSValue js_set_isDisjointFrom(JSContext *ctx, JSValueConst this_val,
function JSValue (line 51780) | static JSValue js_set_isSubsetOf(JSContext *ctx, JSValueConst this_val,
function JSValue (line 51827) | static JSValue js_set_isSupersetOf(JSContext *ctx, JSValueConst this_val,
function JSValue (line 51878) | static JSValue js_set_intersection(JSContext *ctx, JSValueConst this_val,
function JSValue (line 51969) | static JSValue js_set_difference(JSContext *ctx, JSValueConst this_val,
function JSValue (line 52042) | static JSValue js_set_symmetricDifference(JSContext *ctx, JSValueConst t...
function JSValue (line 52111) | static JSValue js_set_union(JSContext *ctx, JSValueConst this_val,
function JS_AddIntrinsicMapSet (line 52254) | int JS_AddIntrinsicMapSet(JSContext *ctx)
type JSPromiseData (line 52301) | typedef struct JSPromiseData {
type JSPromiseFunctionDataResolved (line 52309) | typedef struct JSPromiseFunctionDataResolved {
type JSPromiseFunctionData (line 52314) | typedef struct JSPromiseFunctionData {
type JSPromiseReactionData (line 52319) | typedef struct JSPromiseReactionData {
function JSPromiseStateEnum (line 52325) | JSPromiseStateEnum JS_PromiseState(JSContext *ctx, JSValue promise)
function JSValue (line 52333) | JSValue JS_PromiseResult(JSContext *ctx, JSValue promise)
function promise_reaction_data_free (line 52344) | static void promise_reaction_data_free(JSRuntime *rt,
function JSValue (line 52353) | static JSValue promise_reaction_job(JSContext *ctx, int argc,
function JS_SetHostPromiseRejectionTracker (line 52395) | void JS_SetHostPromiseRejectionTracker(JSRuntime *rt,
function fulfill_or_reject_promise (line 52403) | static void fulfill_or_reject_promise(JSContext *ctx, JSValueConst promise,
function reject_promise (line 52445) | static void reject_promise(JSContext *ctx, JSValueConst promise,
function JSValue (line 52451) | static JSValue js_promise_resolve_thenable_job(JSContext *ctx,
function js_promise_resolve_function_free_resolved (line 52477) | static void js_promise_resolve_function_free_resolved(JSRuntime *rt,
function js_create_resolving_functions (line 52485) | static int js_create_resolving_functions(JSContext *ctx,
function js_promise_resolve_function_finalizer (line 52527) | static void js_promise_resolve_function_finalizer(JSRuntime *rt, JSValue...
function js_promise_resolve_function_mark (line 52537) | static void js_promise_resolve_function_mark(JSRuntime *rt, JSValueConst...
function JSValue (line 52546) | static JSValue js_promise_resolve_function_call(JSContext *ctx,
function js_promise_finalizer (line 52599) | static void js_promise_finalizer(JSRuntime *rt, JSValue val)
function js_promise_mark (line 52618) | static void js_promise_mark(JSRuntime *rt, JSValueConst val,
function JSValue (line 52639) | static JSValue js_promise_constructor(JSContext *ctx, JSValueConst new_t...
function JSValue (line 52687) | static JSValue js_promise_executor(JSContext *ctx,
function JSValue (line 52702) | static JSValue js_promise_executor_new(JSContext *ctx)
function JSValue (line 52712) | static JSValue js_new_promise_capability(JSContext *ctx,
function JSValue (line 52748) | JSValue JS_NewPromiseCapability(JSContext *ctx, JSValue *resolving_funcs)
function JSValue (line 52753) | static JSValue js_promise_resolve(JSContext *ctx, JSValueConst this_val,
function JSValue (line 52786) | static JSValue js_promise_withResolvers(JSContext *ctx,
function JSValue (line 52822) | static JSValue js_promise_try(JSContext *ctx, JSValueConst this_val,
function __exception (line 52850) | static __exception int remainingElementsCount_add(JSContext *ctx,
function JSValue (line 52873) | static JSValue js_promise_all_resolve_element(JSContext *ctx,
function JSValue (line 52944) | static JSValue js_promise_all(JSContext *ctx, JSValueConst this_val,
function JSValue (line 53089) | static JSValue js_promise_race(JSContext *ctx, JSValueConst this_val,
function __exception (line 53158) | static __exception int perform_promise_then(JSContext *ctx,
function JSValue (line 53213) | static JSValue js_promise_then(JSContext *ctx, JSValueConst this_val,
function JSValue (line 53242) | static JSValue js_promise_catch(JSContext *ctx, JSValueConst this_val,
function JSValue (line 53251) | static JSValue js_promise_finally_value_thunk(JSContext *ctx, JSValueCon...
function JSValue (line 53258) | static JSValue js_promise_finally_thrower(JSContext *ctx, JSValueConst t...
function JSValue (line 53265) | static JSValue js_promise_then_finally_func(JSContext *ctx, JSValueConst...
function JSValue (line 53296) | static JSValue js_promise_finally(JSContext *ctx, JSValueConst this_val,
type JSAsyncFromSyncIteratorData (line 53363) | typedef struct JSAsyncFromSyncIteratorData {
function js_async_from_sync_iterator_finalizer (line 53368) | static void js_async_from_sync_iterator_finalizer(JSRuntime *rt, JSValue...
function js_async_from_sync_iterator_mark (line 53379) | static void js_async_from_sync_iterator_mark(JSRuntime *rt, JSValueConst...
function JSValue (line 53390) | static JSValue JS_CreateAsyncFromSyncIterator(JSContext *ctx,
function JSValue (line 53416) | static JSValue js_async_from_sync_iterator_unwrap(JSContext *ctx,
function JSValue (line 53425) | static JSValue js_async_from_sync_iterator_unwrap_func_create(JSContext ...
function JSValue (line 53435) | static JSValue js_async_from_sync_iterator_close_wrap(JSContext *ctx,
function JSValue (line 53445) | static JSValue js_async_from_sync_iterator_close_wrap_func_create(JSCont...
function JSValue (line 53451) | static JSValue js_async_from_sync_iterator_next(JSContext *ctx, JSValueC...
function JS_AddIntrinsicPromise (line 53603) | int JS_AddIntrinsicPromise(JSContext *ctx)
function string_get_hex (line 53687) | static int string_get_hex(JSString *p, int k, int n) {
function isURIReserved (line 53697) | static int isURIReserved(int c) {
function js_throw_URIError (line 53701) | static int __attribute__((format(printf, 2, 3))) js_throw_URIError(JSCon...
function hex_decode (line 53711) | static int hex_decode(JSContext *ctx, JSString *p, int k) {
function JSValue (line 53722) | static JSValue js_global_decodeURI(JSContext *ctx, JSValueConst this_val,
function isUnescaped (line 53798) | static int isUnescaped(int c) {
function isURIUnescaped (line 53808) | static int isURIUnescaped(int c, int isComponent) {
function encodeURI_hex (line 53817) | static int encodeURI_hex(StringBuffer *b, int c) {
function JSValue (line 53833) | static JSValue js_global_encodeURI(JSContext *ctx, JSValueConst this_val,
function JSValue (line 53898) | static JSValue js_global_escape(JSContext *ctx, JSValueConst this_val,
function JSValue (line 53924) | static JSValue js_global_unescape(JSContext *ctx, JSValueConst this_val,
function math_mod (line 53982) | static int64_t math_mod(int64_t a, int64_t b) {
function floor_div (line 53988) | static int64_t floor_div(int64_t a, int64_t b) {
function __exception (line 53997) | static __exception int JS_ThisTimeValue(JSContext *ctx, double *valp, JS...
function JSValue (line 54008) | static JSValue JS_SetThisTimeValue(JSContext *ctx, JSValueConst this_val...
function days_from_year (line 54021) | static int64_t days_from_year(int64_t y) {
function days_in_year (line 54026) | static int64_t days_in_year(int64_t y) {
function year_from_days (line 54031) | static int64_t year_from_days(int64_t *days) {
function __exception (line 54057) | static __exception int get_date_fields(JSContext *ctx, JSValueConst obj,
function time_clip (line 54110) | static double time_clip(double t) {
function set_date_fields (line 54119) | static double set_date_fields(double fields[minimum_length(7)], int is_l...
function set_date_fields_checked (line 54176) | static double set_date_fields_checked(double fields[minimum_length(7)], ...
function JSValue (line 54191) | static JSValue get_date_field(JSContext *ctx, JSValueConst this_val,
function JSValue (line 54212) | static JSValue set_date_field(JSContext *ctx, JSValueConst this_val,
function JSValue (line 54257) | static JSValue get_date_string(JSContext *ctx, JSValueConst this_val,
function date_now (line 54364) | static int64_t date_now(void) {
function JSValue (line 54370) | static JSValue js_date_constructor(JSContext *ctx, JSValueConst new_target,
function JSValue (line 54441) | static JSValue js_Date_UTC(JSContext *ctx, JSValueConst this_val,
function BOOL (line 54462) | static BOOL string_skip_char(const uint8_t *sp, int *pp, int c) {
function string_skip_spaces (line 54472) | static int string_skip_spaces(const uint8_t *sp, int *pp) {
function string_skip_separators (line 54480) | static int string_skip_separators(const uint8_t *sp, int *pp) {
function string_skip_until (line 54488) | static int string_skip_until(const uint8_t *sp, int *pp, const char *sto...
function BOOL (line 54496) | static BOOL string_get_digits(const uint8_t *sp, int *pp, int *pval,
function BOOL (line 54519) | static BOOL string_get_milliseconds(const uint8_t *sp, int *pp, int *pva...
function upper_ascii (line 54544) | static uint8_t upper_ascii(uint8_t c) {
function BOOL (line 54548) | static BOOL string_get_tzoffset(const uint8_t *sp, int *pp, int *tzp, BO...
function BOOL (line 54591) | static BOOL string_match(const uint8_t *sp, int *pp, const char *s) {
function find_abbrev (line 54602) | static int find_abbrev(const uint8_t *sp, int p, const char *list, int c...
function BOOL (line 54616) | static BOOL string_get_month(const uint8_t *sp, int *pp, int *pval) {
function BOOL (line 54629) | static BOOL js_date_parse_isostring(const uint8_t *sp, int fields[9], BO...
function BOOL (line 54714) | static BOOL string_get_tzabbr(const uint8_t *sp, int *pp, int *offset) {
function BOOL (line 54725) | static BOOL js_date_parse_otherstring(const uint8_t *sp,
function JSValue (line 54874) | static JSValue js_Date_parse(JSContext *ctx, JSValueConst this_val,
function JSValue (line 54924) | static JSValue js_Date_now(JSContext *ctx, JSValueConst this_val,
function JSValue (line 54931) | static JSValue js_date_Symbol_toPrimitive(JSContext *ctx, JSValueConst t...
function JSValue (line 54963) | static JSValue js_date_getTimezoneOffset(JSContext *ctx, JSValueConst th...
function JSValue (line 54978) | static JSValue js_date_getTime(JSContext *ctx, JSValueConst this_val,
function JSValue (line 54989) | static JSValue js_date_setTime(JSContext *ctx, JSValueConst this_val,
function JSValue (line 55000) | static JSValue js_date_setYear(JSContext *ctx, JSValueConst this_val,
function JSValue (line 55019) | static JSValue js_date_toJSON(JSContext *ctx, JSValueConst this_val,
function JSValue (line 55113) | JSValue JS_NewDate(JSContext *ctx, double epoch_ms)
function JS_AddIntrinsicDate (line 55122) | int JS_AddIntrinsicDate(JSContext *ctx)
function JS_AddIntrinsicEval (line 55141) | int JS_AddIntrinsicEval(JSContext *ctx)
function JSValue (line 55149) | static JSValue JS_ToBigIntCtorFree(JSContext *ctx, JSValue val)
function JSValue (line 55199) | static JSValue js_bigint_constructor(JSContext *ctx,
function JSValue (line 55208) | static JSValue js_thisBigIntValue(JSContext *ctx, JSValueConst this_val)
function JSValue (line 55223) | static JSValue js_bigint_toString(JSContext *ctx, JSValueConst this_val,
function JSValue (line 55248) | static JSValue js_bigint_valueOf(JSContext *ctx, JSValueConst this_val,
function JSValue (line 55254) | static JSValue js_bigint_asUintN(JSContext *ctx,
function JS_AddIntrinsicBigInt (line 55328) | static int JS_AddIntrinsicBigInt(JSContext *ctx)
function JS_AddIntrinsicBasicObjects (line 55346) | static int JS_AddIntrinsicBasicObjects(JSContext *ctx)
function JS_AddIntrinsicBaseObjects (line 55478) | int JS_AddIntrinsicBaseObjects(JSContext *ctx)
function JSValue (line 55706) | static JSValue js_array_buffer_constructor3(JSContext *ctx,
function js_array_buffer_free (line 55782) | static void js_array_buffer_free(JSRuntime *rt, void *opaque, void *ptr)
function JSValue (line 55787) | static JSValue js_array_buffer_constructor2(JSContext *ctx,
function JSValue (line 55797) | static JSValue js_array_buffer_constructor1(JSContext *ctx,
function JSValue (line 55805) | JSValue JS_NewArrayBuffer(JSContext *ctx, uint8_t *buf, size_t len,
function JSValue (line 55816) | JSValue JS_NewArrayBufferCopy(JSContext *ctx, const uint8_t *buf, size_t...
function JSValue (line 55825) | static JSValue js_array_buffer_constructor0(JSContext *ctx, JSValueConst...
function JSValue (line 55860) | static JSValue js_array_buffer_constructor(JSContext *ctx,
function JSValue (line 55868) | static JSValue js_shared_array_buffer_constructor(JSContext *ctx,
function js_array_buffer_finalizer (line 55877) | static void js_array_buffer_finalizer(JSRuntime *rt, JSValue val)
function JSValue (line 55911) | static JSValue js_array_buffer_isView(JSContext *ctx,
function JSValue (line 55933) | static JSValue JS_ThrowTypeErrorDetachedArrayBuffer(JSContext *ctx)
function JSValue (line 55938) | static JSValue JS_ThrowTypeErrorArrayBufferOOB(JSContext *ctx)
function JSValue (line 55944) | static JSValue js_array_buffer_get_detached(JSContext *ctx,
function JSValue (line 55955) | static JSValue js_array_buffer_get_byteLength(JSContext *ctx,
function JSValue (line 55966) | static JSValue js_array_buffer_get_maxByteLength(JSContext *ctx,
function JSValue (line 55978) | static JSValue js_array_buffer_get_resizable(JSContext *ctx,
function js_array_buffer_update_typed_arrays (line 55988) | static void js_array_buffer_update_typed_arrays(JSArrayBuffer *abuf)
function JS_DetachArrayBuffer (line 56031) | void JS_DetachArrayBuffer(JSContext *ctx, JSValueConst obj)
function JSArrayBuffer (line 56046) | static JSArrayBuffer *js_get_array_buffer(JSContext *ctx, JSValueConst obj)
function BOOL (line 56079) | static BOOL array_buffer_is_resizable(const JSArrayBuffer *abuf)
function JSValue (line 56085) | static JSValue js_array_buffer_transfer(JSContext *ctx,
function JSValue (line 56165) | static JSValue js_array_buffer_resize(JSContext *ctx, JSValueConst this_...
function JSValue (line 56215) | static JSValue js_array_buffer_slice(JSContext *ctx,
function JSObject (line 56308) | static JSObject *get_typed_array(JSContext *ctx, JSValueConst this_val)
function BOOL (line 56325) | static BOOL typed_array_is_oob(JSObject *p)
function js_typed_array_get_length_unsafe (line 56359) | static int js_typed_array_get_length_unsafe(JSContext *ctx, JSValueConst...
function validate_typed_array (line 56372) | static int validate_typed_array(JSContext *ctx, JSValueConst this_val)
function JSValue (line 56385) | static JSValue js_typed_array_get_length(JSContext *ctx,
function JSValue (line 56395) | static JSValue js_typed_array_get_buffer(JSContext *ctx,
function JSValue (line 56407) | static JSValue js_typed_array_get_byteLength(JSContext *ctx,
function JSValue (line 56426) | static JSValue js_typed_array_get_byteOffset(JSContext *ctx,
function JSValue (line 56440) | JSValue JS_NewTypedArray(JSContext *ctx, int argc, JSValueConst *argv,
function JSValue (line 56453) | JSValue JS_GetTypedArrayBuffer(JSContext *ctx, JSValueConst obj,
function JSValue (line 56476) | static JSValue js_typed_array_get_toStringTag(JSContext *ctx,
function JSValue (line 56489) | static JSValue js_typed_array_set_internal(JSContext *ctx,
function JSValue (line 56570) | static JSValue js_typed_array_at(JSContext *ctx, JSValueConst this_val,
function JSValue (line 56597) | static JSValue js_typed_array_with(JSContext *ctx, JSValueConst this_val,
function JSValue (line 56637) | static JSValue js_typed_array_set(JSContext *ctx,
function JSValue (line 56648) | static JSValue js_create_typed_array_iterator(JSContext *ctx, JSValueCon...
function JSValue (line 56656) | static JSValue js_typed_array_create(JSContext *ctx, JSValueConst ctor,
function JSValue (line 56685) | static JSValue js_typed_array___create(JSContext *ctx,
function JSValue (line 56693) | static JSValue js_typed_array___speciesCreate(JSContext *ctx,
function JSValue (line 56720) | static JSValue js_typed_array_from(JSContext *ctx, JSValueConst this_val,
function JSValue (line 56799) | static JSValue js_typed_array_of(JSContext *ctx, JSValueConst this_val,
function JSValue (line 56820) | static JSValue js_typed_array_copyWithin(JSContext *ctx, JSValueConst th...
function JSValue (line 56861) | static JSValue js_typed_array_fill(JSContext *ctx, JSValueConst this_val,
function JSValue (line 56953) | static JSValue js_typed_array_find(JSContext *ctx, JSValueConst this_val,
function JSValue (line 57019) | static JSValue js_typed_array_indexOf(JSContext *ctx, JSValueConst this_...
function JSValue (line 57306) | static JSValue js_typed_array_join(JSContext *ctx, JSValueConst this_val,
function JSValue (line 57385) | static JSValue js_typed_array_reverse(JSContext *ctx, JSValueConst this_...
function JSValue (line 57448) | static JSValue js_typed_array_toReversed(JSContext *ctx, JSValueConst th...
function slice_memcpy (line 57466) | static void slice_memcpy(uint8_t *dst, const uint8_t *src, size_t len)
function JSValue (line 57478) | static JSValue js_typed_array_slice(JSContext *ctx, JSValueConst this_val,
function JSValue (line 57541) | static JSValue js_typed_array_subarray(JSContext *ctx, JSValueConst this...
function js_cmp_doubles (line 57589) | static int js_cmp_doubles(double x, double y)
function js_TA_cmp_int8 (line 57600) | static int js_TA_cmp_int8(const void *a, const void *b, void *opaque) {
function js_TA_cmp_uint8 (line 57604) | static int js_TA_cmp_uint8(const void *a, const void *b, void *opaque) {
function js_TA_cmp_int16 (line 57608) | static int js_TA_cmp_int16(const void *a, const void *b, void *opaque) {
function js_TA_cmp_uint16 (line 57612) | static int js_TA_cmp_uint16(const void *a, const void *b, void *opaque) {
function js_TA_cmp_int32 (line 57616) | static int js_TA_cmp_int32(const void *a, const void *b, void *opaque) {
function js_TA_cmp_uint32 (line 57622) | static int js_TA_cmp_uint32(const void *a, const void *b, void *opaque) {
function js_TA_cmp_int64 (line 57628) | static int js_TA_cmp_int64(const void *a, const void *b, void *opaque) {
function js_TA_cmp_uint64 (line 57634) | static int js_TA_cmp_uint64(const void *a, const void *b, void *opaque) {
function js_TA_cmp_float16 (line 57640) | static int js_TA_cmp_float16(const void *a, const void *b, void *opaque) {
function js_TA_cmp_float32 (line 57645) | static int js_TA_cmp_float32(const void *a, const void *b, void *opaque) {
function js_TA_cmp_float64 (line 57649) | static int js_TA_cmp_float64(const void *a, const void *b, void *opaque) {
function JSValue (line 57653) | static JSValue js_TA_get_int8(JSContext *ctx, const void *a) {
function JSValue (line 57657) | static JSValue js_TA_get_uint8(JSContext *ctx, const void *a) {
function JSValue (line 57661) | static JSValue js_TA_get_int16(JSContext *ctx, const void *a) {
function JSValue (line 57665) | static JSValue js_TA_get_uint16(JSContext *ctx, const void *a) {
function JSValue (line 57669) | static JSValue js_TA_get_int32(JSContext *ctx, const void *a) {
function JSValue (line 57673) | static JSValue js_TA_get_uint32(JSContext *ctx, const void *a) {
function JSValue (line 57677) | static JSValue js_TA_get_int64(JSContext *ctx, const void *a) {
function JSValue (line 57681) | static JSValue js_TA_get_uint64(JSContext *ctx, const void *a) {
function JSValue (line 57685) | static JSValue js_TA_get_float16(JSContext *ctx, const void *a) {
function JSValue (line 57689) | static JSValue js_TA_get_float32(JSContext *ctx, const void *a) {
function JSValue (line 57693) | static JSValue js_TA_get_float64(JSContext *ctx, const void *a) {
type TA_sort_context (line 57697) | struct TA_sort_context {
function js_TA_cmp_generic (line 57706) | static int js_TA_cmp_generic(const void *a, const void *b, void *opaque) {
function JSValu
Condensed preview — 70 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (3,313K chars).
[
{
"path": ".github/workflows/ci.yml",
"chars": 7584,
"preview": "name: ci\n\non:\n pull_request:\n paths:\n - '**'\n - '!.gitignore'\n - '!LICENSE'\n - '!TODO'\n - '"
},
{
"path": ".gitignore",
"chars": 374,
"preview": "*.a\n.obj/\ntests/bjson.so\nexamples/test_fib\ntest_fib.c\nexamples/*.so\nexamples/hello\nexamples/hello_module\nexamples/hello."
},
{
"path": "Changelog",
"chars": 6098,
"preview": "- micro optimizations (30% faster on bench-v8)\n- added resizable array buffers\n- added ArrayBuffer.prototype.transfer\n- "
},
{
"path": "LICENSE",
"chars": 1130,
"preview": "QuickJS Javascript Engine\n\nCopyright (c) 2017-2021 Fabrice Bellard\nCopyright (c) 2017-2021 Charlie Gordon\n\nPermission is"
},
{
"path": "Makefile",
"chars": 14994,
"preview": "#\n# QuickJS Javascript Engine\n#\n# Copyright (c) 2017-2021 Fabrice Bellard\n# Copyright (c) 2017-2021 Charlie Gordon\n#\n# P"
},
{
"path": "TODO",
"chars": 2897,
"preview": "Misc ideas:\n- use custom printf to avoid compatibility issues with floating point numbers\n- consistent naming for prepro"
},
{
"path": "VERSION",
"chars": 11,
"preview": "2025-09-13\n"
},
{
"path": "compat/test-closefrom.c",
"chars": 72,
"preview": "#include <unistd.h>\n\nint main(void) {\n closefrom(3);\n return 0;\n}\n"
},
{
"path": "cutils.c",
"chars": 17794,
"preview": "/*\n * C utilities\n *\n * Copyright (c) 2017 Fabrice Bellard\n * Copyright (c) 2018 Charlie Gordon\n *\n * Permission is here"
},
{
"path": "cutils.h",
"chars": 11162,
"preview": "/*\n * C utilities\n *\n * Copyright (c) 2017 Fabrice Bellard\n * Copyright (c) 2018 Charlie Gordon\n *\n * Permission is here"
},
{
"path": "doc/quickjs.texi",
"chars": 33600,
"preview": "\\input texinfo\n\n@iftex\n@afourpaper\n@headings double\n@end iftex\n\n@include version.texi\n\n@titlepage\n@afourpaper\n@sp 7\n@cen"
},
{
"path": "dtoa.c",
"chars": 44875,
"preview": "/*\n * Tiny float64 printing and parsing library\n *\n * Copyright (c) 2024 Fabrice Bellard\n *\n * Permission is hereby gran"
},
{
"path": "dtoa.h",
"chars": 3306,
"preview": "/*\n * Tiny float64 printing and parsing library\n *\n * Copyright (c) 2024 Fabrice Bellard\n *\n * Permission is hereby gran"
},
{
"path": "examples/fib.c",
"chars": 2290,
"preview": "/*\n * QuickJS: Example of C module\n *\n * Copyright (c) 2017-2018 Fabrice Bellard\n *\n * Permission is hereby granted, fre"
},
{
"path": "examples/fib_module.js",
"chars": 166,
"preview": "/* fib module */\nexport function fib(n)\n{\n if (n <= 0)\n return 0;\n else if (n == 1)\n return 1;\n e"
},
{
"path": "examples/hello.js",
"chars": 28,
"preview": "console.log(\"Hello World\");\n"
},
{
"path": "examples/hello_module.js",
"chars": 200,
"preview": "/* example of JS and JSON modules */\n\nimport { fib } from \"./fib_module.js\";\nimport msg from \"./message.json\";\n\nconsole."
},
{
"path": "examples/message.json",
"chars": 33,
"preview": "{ \"x\" : 1, \"tab\": [ 1, 2, 3 ] }\n\n"
},
{
"path": "examples/pi_bigint.js",
"chars": 2830,
"preview": "/*\n * PI computation in Javascript using the BigInt type\n */\n\"use strict\";\n\n/* return floor(log2(a)) for a > 0 and 0 for"
},
{
"path": "examples/point.c",
"chars": 4781,
"preview": "/*\n * QuickJS: Example of C module with a class\n *\n * Copyright (c) 2019 Fabrice Bellard\n *\n * Permission is hereby gran"
},
{
"path": "examples/test_fib.js",
"chars": 144,
"preview": "/* example of JS module importing a C module */\n\nimport { fib } from \"./fib.so\";\n\nconsole.log(\"Hello World\");\nconsole.lo"
},
{
"path": "examples/test_point.js",
"chars": 718,
"preview": "/* example of JS module importing a C module */\nimport { Point } from \"./point.so\";\n\nfunction assert(b, str)\n{\n if (b"
},
{
"path": "fuzz/README",
"chars": 722,
"preview": "libFuzzer support for QuickJS\n=============================\n\nBuild QuickJS with libFuzzer support as follows:\n\n CONFIG_"
},
{
"path": "fuzz/fuzz.dict",
"chars": 2432,
"preview": "\"__loadScript\"\n\"abs\"\n\"acos\"\n\"acosh\"\n\"add\"\n\"AggregateError\"\n\"and\"\n\"apply\"\n\"Array\"\n\"ArrayBuffer\"\n\"asin\"\n\"asinh\"\n\"atan\"\n\"at"
},
{
"path": "fuzz/fuzz_common.c",
"chars": 1846,
"preview": "/* Copyright 2020 Google Inc.\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this fi"
},
{
"path": "fuzz/fuzz_common.h",
"chars": 727,
"preview": "/* Copyright 2020 Google Inc.\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this fi"
},
{
"path": "fuzz/fuzz_compile.c",
"chars": 2782,
"preview": "/* Copyright 2020 Google Inc.\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this fi"
},
{
"path": "fuzz/fuzz_eval.c",
"chars": 1507,
"preview": "/* Copyright 2020 Google Inc.\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this fi"
},
{
"path": "fuzz/fuzz_regexp.c",
"chars": 1731,
"preview": "/* Copyright 2020 Google Inc.\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this fi"
},
{
"path": "fuzz/generate_dict.js",
"chars": 1020,
"preview": "// Function to recursively iterate through built-in names.\nfunction collectBuiltinNames(obj, visited = new Set(), result"
},
{
"path": "libregexp-opcode.h",
"chars": 2887,
"preview": "/*\n * Regular Expression Engine\n *\n * Copyright (c) 2017-2018 Fabrice Bellard\n *\n * Permission is hereby granted, free o"
},
{
"path": "libregexp.c",
"chars": 113209,
"preview": "/*\n * Regular Expression Engine\n *\n * Copyright (c) 2017-2018 Fabrice Bellard\n *\n * Permission is hereby granted, free o"
},
{
"path": "libregexp.h",
"chars": 2737,
"preview": "/*\n * Regular Expression Engine\n *\n * Copyright (c) 2017-2018 Fabrice Bellard\n *\n * Permission is hereby granted, free o"
},
{
"path": "libunicode-table.h",
"chars": 252492,
"preview": "/* Compressed unicode tables */\n/* Automatically generated file - do not edit */\n\n#include <stdint.h>\n\nstatic const uint"
},
{
"path": "libunicode.c",
"chars": 63587,
"preview": "/*\n * Unicode utilities\n *\n * Copyright (c) 2017-2018 Fabrice Bellard\n *\n * Permission is hereby granted, free of charge"
},
{
"path": "libunicode.h",
"chars": 5817,
"preview": "/*\n * Unicode utilities\n *\n * Copyright (c) 2017-2018 Fabrice Bellard\n *\n * Permission is hereby granted, free of charge"
},
{
"path": "list.h",
"chars": 3089,
"preview": "/*\n * Linux klist like system\n *\n * Copyright (c) 2016-2017 Fabrice Bellard\n *\n * Permission is hereby granted, free of "
},
{
"path": "qjs.c",
"chars": 16968,
"preview": "/*\n * QuickJS stand alone interpreter\n *\n * Copyright (c) 2017-2021 Fabrice Bellard\n * Copyright (c) 2017-2021 Charlie G"
},
{
"path": "qjsc.c",
"chars": 26078,
"preview": "/*\n * QuickJS command line compiler\n *\n * Copyright (c) 2018-2021 Fabrice Bellard\n *\n * Permission is hereby granted, fr"
},
{
"path": "quickjs-atom.h",
"chars": 8137,
"preview": "/*\n * QuickJS atom definitions\n *\n * Copyright (c) 2017-2018 Fabrice Bellard\n * Copyright (c) 2017-2018 Charlie Gordon\n "
},
{
"path": "quickjs-libc.c",
"chars": 124130,
"preview": "/*\n * QuickJS C library\n *\n * Copyright (c) 2017-2021 Fabrice Bellard\n * Copyright (c) 2017-2021 Charlie Gordon\n *\n * Pe"
},
{
"path": "quickjs-libc.h",
"chars": 2919,
"preview": "/*\n * QuickJS C library\n *\n * Copyright (c) 2017-2018 Fabrice Bellard\n *\n * Permission is hereby granted, free of charge"
},
{
"path": "quickjs-opcode.h",
"chars": 15801,
"preview": "/*\n * QuickJS opcode definitions\n *\n * Copyright (c) 2017-2018 Fabrice Bellard\n * Copyright (c) 2017-2018 Charlie Gordon"
},
{
"path": "quickjs.c",
"chars": 1963877,
"preview": "/*\n * QuickJS Javascript Engine\n *\n * Copyright (c) 2017-2025 Fabrice Bellard\n * Copyright (c) 2017-2025 Charlie Gordon\n"
},
{
"path": "quickjs.h",
"chars": 46978,
"preview": "/*\n * QuickJS Javascript Engine\n *\n * Copyright (c) 2017-2021 Fabrice Bellard\n * Copyright (c) 2017-2021 Charlie Gordon\n"
},
{
"path": "readme-cosmo.txt",
"chars": 758,
"preview": "The executables included in this archive run on Linux, Mac, Windows,\nFreeBSD, OpenBSD and NetBSD for both the ARM64 and "
},
{
"path": "readme.txt",
"chars": 66,
"preview": "The main documentation is in doc/quickjs.pdf or doc/quickjs.html.\n"
},
{
"path": "release.sh",
"chars": 3815,
"preview": "#!/bin/sh\n# Release the QuickJS source code\n\nset -e\n\nversion=`cat VERSION`\n\nif [ \"$1\" = \"-h\" ] ; then\n echo \"release."
},
{
"path": "repl.js",
"chars": 39164,
"preview": "/*\n * QuickJS Read Eval Print Loop\n *\n * Copyright (c) 2017-2020 Fabrice Bellard\n * Copyright (c) 2017-2020 Charlie Gord"
},
{
"path": "run-test262.c",
"chars": 69597,
"preview": "/*\n * ECMA Test 262 Runner for QuickJS\n *\n * Copyright (c) 2017-2021 Fabrice Bellard\n * Copyright (c) 2017-2021 Charlie "
},
{
"path": "test262.conf",
"chars": 7218,
"preview": "[config]\n# general settings for test262 ES6 version\n\n# framework style: old, new\nstyle=new\n\n# handle tests tagged as [no"
},
{
"path": "test262o.conf",
"chars": 21866,
"preview": "[config]\n# general settings for test262 ES5 version\n\n# framework style: old, new\nstyle=old\n\n# handle tests tagged as @no"
},
{
"path": "tests/assert.js",
"chars": 1084,
"preview": "export function assert(actual, expected, message) {\n if (arguments.length === 1)\n expected = true;\n\n if (ty"
},
{
"path": "tests/bjson.c",
"chars": 3130,
"preview": "/*\n * QuickJS: binary JSON module (test only)\n *\n * Copyright (c) 2017-2019 Fabrice Bellard\n *\n * Permission is hereby g"
},
{
"path": "tests/fixture_cyclic_import.js",
"chars": 88,
"preview": "import * as a from \"./test_cyclic_import.js\"\nexport function f(x) { return 2 * a.g(x) }\n"
},
{
"path": "tests/microbench.js",
"chars": 33852,
"preview": "/*\n * Javascript Micro benchmark\n *\n * Copyright (c) 2017-2019 Fabrice Bellard\n * Copyright (c) 2017-2019 Charlie Gordon"
},
{
"path": "tests/test262.patch",
"chars": 2287,
"preview": "diff --git a/harness/atomicsHelper.js b/harness/atomicsHelper.js\nindex 9828b15..9e24d64 100644\n--- a/harness/atomicsHelp"
},
{
"path": "tests/test_bigint.js",
"chars": 8478,
"preview": "\"use strict\";\n\nfunction assert(actual, expected, message) {\n if (arguments.length == 1)\n expected = true;\n\n "
},
{
"path": "tests/test_bjson.js",
"chars": 6095,
"preview": "import * as bjson from \"./bjson.so\";\n\nfunction assert(actual, expected, message) {\n if (arguments.length == 1)\n "
},
{
"path": "tests/test_builtin.js",
"chars": 34073,
"preview": "\"use strict\";\n\nvar status = 0;\nvar throw_errors = true;\n\nfunction throw_error(msg) {\n if (throw_errors)\n throw"
},
{
"path": "tests/test_closure.js",
"chars": 4347,
"preview": "function assert(actual, expected, message) {\n if (arguments.length == 1)\n expected = true;\n\n if (actual ==="
},
{
"path": "tests/test_cyclic_import.js",
"chars": 354,
"preview": "/*---\nnegative:\n phase: resolution\n type: SyntaxError\n---*/\n// FIXME(bnoordhuis) shouldn't throw SyntaxError but that'"
},
{
"path": "tests/test_language.js",
"chars": 14422,
"preview": "function assert(actual, expected, message) {\n if (arguments.length == 1)\n expected = true;\n\n if (Object.is("
},
{
"path": "tests/test_loop.js",
"chars": 7092,
"preview": "function assert(actual, expected, message) {\n if (arguments.length == 1)\n expected = true;\n\n if (actual ==="
},
{
"path": "tests/test_std.js",
"chars": 8197,
"preview": "#! (shebang test)\nimport * as std from \"std\";\nimport * as os from \"os\";\n\nfunction assert(actual, expected, message) {\n "
},
{
"path": "tests/test_worker.js",
"chars": 1610,
"preview": "/* os.Worker API test */\nimport * as std from \"std\";\nimport * as os from \"os\";\n\nfunction assert(actual, expected, messag"
},
{
"path": "tests/test_worker_module.js",
"chars": 737,
"preview": "/* Worker code for test_worker.js */\nimport * as std from \"std\";\nimport * as os from \"os\";\n\nvar parent = os.Worker.paren"
},
{
"path": "unicode_download.sh",
"chars": 665,
"preview": "#!/bin/sh\nset -e\n\nversion=\"17.0.0\"\nurl=\"ftp://ftp.unicode.org/Public\"\n\nfiles=\"CaseFolding.txt DerivedNormalizationProps."
},
{
"path": "unicode_gen.c",
"chars": 105279,
"preview": "/*\n * Generation of Unicode tables\n *\n * Copyright (c) 2017-2018 Fabrice Bellard\n * Copyright (c) 2017-2018 Charlie Gord"
},
{
"path": "unicode_gen_def.h",
"chars": 7784,
"preview": "#ifdef UNICODE_GENERAL_CATEGORY\nDEF(Cn, \"Unassigned\") /* must be zero */\nDEF(Lu, \"Uppercase_Letter\")\nDEF(Ll, \"Lowercase_"
}
]
About this extraction
This page contains the full source code of the bellard/quickjs GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 70 files (3.1 MB), approximately 802.4k tokens, and a symbol index with 2593 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.