visaljs 0.0.0-stage → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +45 -2
- package/cli.js +8084 -0
- package/node/include/js_node.h +46 -0
- package/node/prelude/async_hooks.js +88 -0
- package/node/prelude/buffer.js +31 -0
- package/node/prelude/crypto.js +114 -0
- package/node/prelude/events.js +227 -0
- package/node/prelude/fs.js +79 -0
- package/node/prelude/http.js +536 -0
- package/node/prelude/http2.js +30 -0
- package/node/prelude/internal/crypto/asym.js +333 -0
- package/node/prelude/internal/crypto/cipher.js +205 -0
- package/node/prelude/internal/crypto/hash.js +137 -0
- package/node/prelude/internal/crypto/kdf.js +182 -0
- package/node/prelude/internal/crypto/keys.js +603 -0
- package/node/prelude/internal/crypto/random.js +118 -0
- package/node/prelude/internal/crypto/util.js +76 -0
- package/node/prelude/internal/errors.js +88 -0
- package/node/prelude/internal/querystring.js +105 -0
- package/node/prelude/module.js +53 -0
- package/node/prelude/net.js +51 -0
- package/node/prelude/os.js +129 -0
- package/node/prelude/path.js +257 -0
- package/node/prelude/process.js +21 -0
- package/node/prelude/querystring.js +469 -0
- package/node/prelude/stream.js +1327 -0
- package/node/prelude/stream_promises.js +7 -0
- package/node/prelude/stream_web.js +6 -0
- package/node/prelude/string_decoder.js +236 -0
- package/node/prelude/tty.js +18 -0
- package/node/prelude/url.js +1156 -0
- package/node/prelude/util.js +64 -0
- package/node/prelude/zlib.js +81 -0
- package/node/src/host_fs.c +126 -0
- package/node/src/host_http.c +486 -0
- package/node/src/host_os.c +505 -0
- package/node/src/host_sys.c +78 -0
- package/node/third_party/libuv/LICENSE +19 -0
- package/node/third_party/libuv/include/uv/aix.h +32 -0
- package/node/third_party/libuv/include/uv/bsd.h +34 -0
- package/node/third_party/libuv/include/uv/darwin.h +61 -0
- package/node/third_party/libuv/include/uv/errno.h +483 -0
- package/node/third_party/libuv/include/uv/linux.h +34 -0
- package/node/third_party/libuv/include/uv/os390.h +33 -0
- package/node/third_party/libuv/include/uv/posix.h +31 -0
- package/node/third_party/libuv/include/uv/sunos.h +44 -0
- package/node/third_party/libuv/include/uv/threadpool.h +37 -0
- package/node/third_party/libuv/include/uv/tree.h +521 -0
- package/node/third_party/libuv/include/uv/unix.h +512 -0
- package/node/third_party/libuv/include/uv/version.h +43 -0
- package/node/third_party/libuv/include/uv/win.h +698 -0
- package/node/third_party/libuv/include/uv.h +1990 -0
- package/node/third_party/libuv/src/fs-poll.c +290 -0
- package/node/third_party/libuv/src/heap-inl.h +245 -0
- package/node/third_party/libuv/src/idna.c +560 -0
- package/node/third_party/libuv/src/idna.h +31 -0
- package/node/third_party/libuv/src/inet.c +298 -0
- package/node/third_party/libuv/src/queue.h +90 -0
- package/node/third_party/libuv/src/random.c +123 -0
- package/node/third_party/libuv/src/strscpy.c +38 -0
- package/node/third_party/libuv/src/strscpy.h +39 -0
- package/node/third_party/libuv/src/strtok.c +52 -0
- package/node/third_party/libuv/src/strtok.h +27 -0
- package/node/third_party/libuv/src/thread-common.c +175 -0
- package/node/third_party/libuv/src/threadpool.c +419 -0
- package/node/third_party/libuv/src/timer.c +200 -0
- package/node/third_party/libuv/src/unix/async.c +418 -0
- package/node/third_party/libuv/src/unix/bsd-ifaddrs.c +164 -0
- package/node/third_party/libuv/src/unix/core.c +2104 -0
- package/node/third_party/libuv/src/unix/darwin-proctitle.c +176 -0
- package/node/third_party/libuv/src/unix/darwin-stub.h +97 -0
- package/node/third_party/libuv/src/unix/darwin-syscalls.h +17 -0
- package/node/third_party/libuv/src/unix/darwin.c +237 -0
- package/node/third_party/libuv/src/unix/dl.c +80 -0
- package/node/third_party/libuv/src/unix/fs.c +2303 -0
- package/node/third_party/libuv/src/unix/fsevents.c +906 -0
- package/node/third_party/libuv/src/unix/getaddrinfo.c +252 -0
- package/node/third_party/libuv/src/unix/getnameinfo.c +121 -0
- package/node/third_party/libuv/src/unix/internal.h +530 -0
- package/node/third_party/libuv/src/unix/kqueue.c +667 -0
- package/node/third_party/libuv/src/unix/linux.c +2761 -0
- package/node/third_party/libuv/src/unix/loop-watcher.c +68 -0
- package/node/third_party/libuv/src/unix/loop.c +240 -0
- package/node/third_party/libuv/src/unix/pipe.c +555 -0
- package/node/third_party/libuv/src/unix/poll.c +159 -0
- package/node/third_party/libuv/src/unix/process.c +1123 -0
- package/node/third_party/libuv/src/unix/procfs-exepath.c +45 -0
- package/node/third_party/libuv/src/unix/proctitle.c +157 -0
- package/node/third_party/libuv/src/unix/random-devurandom.c +93 -0
- package/node/third_party/libuv/src/unix/random-getentropy.c +57 -0
- package/node/third_party/libuv/src/unix/random-getrandom.c +86 -0
- package/node/third_party/libuv/src/unix/random-sysctl-linux.c +99 -0
- package/node/third_party/libuv/src/unix/signal.c +581 -0
- package/node/third_party/libuv/src/unix/stream.c +1567 -0
- package/node/third_party/libuv/src/unix/tcp.c +673 -0
- package/node/third_party/libuv/src/unix/thread.c +975 -0
- package/node/third_party/libuv/src/unix/tty.c +510 -0
- package/node/third_party/libuv/src/unix/udp.c +1434 -0
- package/node/third_party/libuv/src/uv-common.c +1051 -0
- package/node/third_party/libuv/src/uv-common.h +474 -0
- package/node/third_party/libuv/src/uv-data-getter-setters.c +119 -0
- package/node/third_party/libuv/src/version.c +45 -0
- package/node/third_party/llhttp/LICENSE +22 -0
- package/node/third_party/llhttp/api.c +509 -0
- package/node/third_party/llhttp/http.c +170 -0
- package/node/third_party/llhttp/llhttp.c +10099 -0
- package/node/third_party/llhttp/llhttp.h +907 -0
- package/package.json +25 -4
- package/runtime/include/js_atoms.gen.h +68 -0
- package/runtime/include/js_atoms.h +54 -0
- package/runtime/include/js_bigint.h +93 -0
- package/runtime/include/js_buffer.h +79 -0
- package/runtime/include/js_builtins.h +168 -0
- package/runtime/include/js_console.h +58 -0
- package/runtime/include/js_convert.h +22 -0
- package/runtime/include/js_core.def +188 -0
- package/runtime/include/js_crypto.h +58 -0
- package/runtime/include/js_error.h +37 -0
- package/runtime/include/js_exception.h +65 -0
- package/runtime/include/js_function.h +167 -0
- package/runtime/include/js_gc.h +195 -0
- package/runtime/include/js_generator.h +96 -0
- package/runtime/include/js_host.h +19 -0
- package/runtime/include/js_jobs.h +84 -0
- package/runtime/include/js_module.h +16 -0
- package/runtime/include/js_object.h +384 -0
- package/runtime/include/js_ops.h +111 -0
- package/runtime/include/js_promise.h +45 -0
- package/runtime/include/js_regexp.h +25 -0
- package/runtime/include/js_runtime.h +30 -0
- package/runtime/include/js_symbol.h +62 -0
- package/runtime/include/js_web.h +110 -0
- package/runtime/include/jscell.h +48 -0
- package/runtime/include/jscontext.h +240 -0
- package/runtime/include/jsnum.h +42 -0
- package/runtime/include/jsstring.h +161 -0
- package/runtime/include/jsvalue.h +142 -0
- package/runtime/src/arguments.c +115 -0
- package/runtime/src/array.c +1145 -0
- package/runtime/src/arraybuffer.c +608 -0
- package/runtime/src/async_iter.c +479 -0
- package/runtime/src/atoms.c +157 -0
- package/runtime/src/base64.c +107 -0
- package/runtime/src/bigint.c +1189 -0
- package/runtime/src/blob.c +371 -0
- package/runtime/src/buffer.c +1357 -0
- package/runtime/src/builtin_table.c +100 -0
- package/runtime/src/builtins.c +987 -0
- package/runtime/src/builtins_util.h +53 -0
- package/runtime/src/collections.c +912 -0
- package/runtime/src/components.c +28 -0
- package/runtime/src/console.c +637 -0
- package/runtime/src/convert.c +82 -0
- package/runtime/src/core_all.c +21 -0
- package/runtime/src/crypto.c +116 -0
- package/runtime/src/crypto_asym.c +644 -0
- package/runtime/src/crypto_cipher.c +671 -0
- package/runtime/src/crypto_hash.c +260 -0
- package/runtime/src/crypto_host.c +414 -0
- package/runtime/src/crypto_internal.h +304 -0
- package/runtime/src/crypto_kdf.c +143 -0
- package/runtime/src/crypto_key.c +171 -0
- package/runtime/src/crypto_pkey.c +794 -0
- package/runtime/src/crypto_subtle.c +1675 -0
- package/runtime/src/date.c +940 -0
- package/runtime/src/domexception.c +169 -0
- package/runtime/src/elements.c +312 -0
- package/runtime/src/elements.h +45 -0
- package/runtime/src/encoding.c +485 -0
- package/runtime/src/error.c +297 -0
- package/runtime/src/events.c +793 -0
- package/runtime/src/exception.c +56 -0
- package/runtime/src/fetch.c +772 -0
- package/runtime/src/function.c +530 -0
- package/runtime/src/gc.c +803 -0
- package/runtime/src/generator.c +218 -0
- package/runtime/src/global.c +119 -0
- package/runtime/src/headers.c +557 -0
- package/runtime/src/inspect.c +1792 -0
- package/runtime/src/internal.h +80 -0
- package/runtime/src/iterate.c +94 -0
- package/runtime/src/iterator.c +409 -0
- package/runtime/src/jobs.c +337 -0
- package/runtime/src/jsnum.c +353 -0
- package/runtime/src/json.c +1028 -0
- package/runtime/src/math.c +243 -0
- package/runtime/src/module.c +336 -0
- package/runtime/src/number.c +176 -0
- package/runtime/src/object.c +1265 -0
- package/runtime/src/ops.c +322 -0
- package/runtime/src/os.c +196 -0
- package/runtime/src/os.h +29 -0
- package/runtime/src/process.c +432 -0
- package/runtime/src/promise.c +721 -0
- package/runtime/src/proxy.c +570 -0
- package/runtime/src/reflect.c +194 -0
- package/runtime/src/regexp.c +1141 -0
- package/runtime/src/regexp_anchor.h +34 -0
- package/runtime/src/regexp_message.h +32 -0
- package/runtime/src/shape.c +294 -0
- package/runtime/src/shape.h +46 -0
- package/runtime/src/streams.c +1046 -0
- package/runtime/src/streams.h +47 -0
- package/runtime/src/string.c +364 -0
- package/runtime/src/string_builtins.c +837 -0
- package/runtime/src/symbol.c +143 -0
- package/runtime/src/test_host.c +59 -0
- package/runtime/src/typedarray.c +1330 -0
- package/runtime/src/tznames.gen.h +712 -0
- package/runtime/src/uri.c +169 -0
- package/runtime/src/url.c +2116 -0
- package/runtime/src/weak.c +486 -0
- package/runtime/src/web.c +214 -0
- package/runtime/src/wrapper.c +59 -0
- package/runtime/src/writable.c +1486 -0
- package/runtime/third_party/ada-idna/LICENSE-MIT +18 -0
- package/runtime/third_party/ada-idna/README.md +27 -0
- package/runtime/third_party/ada-idna/convert.mjs +83 -0
- package/runtime/third_party/ada-idna/idna.c +416 -0
- package/runtime/third_party/ada-idna/idna.h +15 -0
- package/runtime/third_party/ada-idna/idna_tables.h +2657 -0
- package/runtime/third_party/bearssl/LICENSE.txt +21 -0
- package/runtime/third_party/bearssl/README.txt +136 -0
- package/runtime/third_party/bearssl/VERSION +1 -0
- package/runtime/third_party/bearssl/inc/bearssl.h +183 -0
- package/runtime/third_party/bearssl/inc/bearssl_aead.h +1059 -0
- package/runtime/third_party/bearssl/inc/bearssl_block.h +2618 -0
- package/runtime/third_party/bearssl/inc/bearssl_ec.h +967 -0
- package/runtime/third_party/bearssl/inc/bearssl_hash.h +1346 -0
- package/runtime/third_party/bearssl/inc/bearssl_hmac.h +241 -0
- package/runtime/third_party/bearssl/inc/bearssl_kdf.h +284 -0
- package/runtime/third_party/bearssl/inc/bearssl_pem.h +294 -0
- package/runtime/third_party/bearssl/inc/bearssl_prf.h +150 -0
- package/runtime/third_party/bearssl/inc/bearssl_rand.h +397 -0
- package/runtime/third_party/bearssl/inc/bearssl_rsa.h +1655 -0
- package/runtime/third_party/bearssl/inc/bearssl_ssl.h +4296 -0
- package/runtime/third_party/bearssl/inc/bearssl_x509.h +1474 -0
- package/runtime/third_party/bearssl/src/aead/ccm.c +346 -0
- package/runtime/third_party/bearssl/src/aead/eax.c +525 -0
- package/runtime/third_party/bearssl/src/aead/gcm.c +318 -0
- package/runtime/third_party/bearssl/src/codec/ccopy.c +44 -0
- package/runtime/third_party/bearssl/src/codec/dec16be.c +38 -0
- package/runtime/third_party/bearssl/src/codec/dec16le.c +38 -0
- package/runtime/third_party/bearssl/src/codec/dec32be.c +38 -0
- package/runtime/third_party/bearssl/src/codec/dec32le.c +38 -0
- package/runtime/third_party/bearssl/src/codec/dec64be.c +38 -0
- package/runtime/third_party/bearssl/src/codec/dec64le.c +38 -0
- package/runtime/third_party/bearssl/src/codec/enc16be.c +38 -0
- package/runtime/third_party/bearssl/src/codec/enc16le.c +38 -0
- package/runtime/third_party/bearssl/src/codec/enc32be.c +38 -0
- package/runtime/third_party/bearssl/src/codec/enc32le.c +38 -0
- package/runtime/third_party/bearssl/src/codec/enc64be.c +38 -0
- package/runtime/third_party/bearssl/src/codec/enc64le.c +38 -0
- package/runtime/third_party/bearssl/src/codec/pemdec.c +526 -0
- package/runtime/third_party/bearssl/src/codec/pemdec.t0 +314 -0
- package/runtime/third_party/bearssl/src/codec/pemenc.c +173 -0
- package/runtime/third_party/bearssl/src/config.h +247 -0
- package/runtime/third_party/bearssl/src/ec/ec_all_m15.c +121 -0
- package/runtime/third_party/bearssl/src/ec/ec_all_m31.c +171 -0
- package/runtime/third_party/bearssl/src/ec/ec_c25519_i15.c +398 -0
- package/runtime/third_party/bearssl/src/ec/ec_c25519_i31.c +390 -0
- package/runtime/third_party/bearssl/src/ec/ec_c25519_m15.c +1478 -0
- package/runtime/third_party/bearssl/src/ec/ec_c25519_m31.c +800 -0
- package/runtime/third_party/bearssl/src/ec/ec_c25519_m62.c +605 -0
- package/runtime/third_party/bearssl/src/ec/ec_c25519_m64.c +831 -0
- package/runtime/third_party/bearssl/src/ec/ec_curve25519.c +46 -0
- package/runtime/third_party/bearssl/src/ec/ec_default.c +36 -0
- package/runtime/third_party/bearssl/src/ec/ec_keygen.c +86 -0
- package/runtime/third_party/bearssl/src/ec/ec_p256_m15.c +2124 -0
- package/runtime/third_party/bearssl/src/ec/ec_p256_m31.c +1469 -0
- package/runtime/third_party/bearssl/src/ec/ec_p256_m62.c +1765 -0
- package/runtime/third_party/bearssl/src/ec/ec_p256_m64.c +1781 -0
- package/runtime/third_party/bearssl/src/ec/ec_prime_i15.c +824 -0
- package/runtime/third_party/bearssl/src/ec/ec_prime_i31.c +826 -0
- package/runtime/third_party/bearssl/src/ec/ec_pubkey.c +85 -0
- package/runtime/third_party/bearssl/src/ec/ec_secp256r1.c +51 -0
- package/runtime/third_party/bearssl/src/ec/ec_secp384r1.c +57 -0
- package/runtime/third_party/bearssl/src/ec/ec_secp521r1.c +64 -0
- package/runtime/third_party/bearssl/src/ec/ecdsa_atr.c +134 -0
- package/runtime/third_party/bearssl/src/ec/ecdsa_default_sign_asn1.c +36 -0
- package/runtime/third_party/bearssl/src/ec/ecdsa_default_sign_raw.c +36 -0
- package/runtime/third_party/bearssl/src/ec/ecdsa_default_vrfy_asn1.c +36 -0
- package/runtime/third_party/bearssl/src/ec/ecdsa_default_vrfy_raw.c +36 -0
- package/runtime/third_party/bearssl/src/ec/ecdsa_i15_bits.c +47 -0
- package/runtime/third_party/bearssl/src/ec/ecdsa_i15_sign_asn1.c +45 -0
- package/runtime/third_party/bearssl/src/ec/ecdsa_i15_sign_raw.c +174 -0
- package/runtime/third_party/bearssl/src/ec/ecdsa_i15_vrfy_asn1.c +48 -0
- package/runtime/third_party/bearssl/src/ec/ecdsa_i15_vrfy_raw.c +166 -0
- package/runtime/third_party/bearssl/src/ec/ecdsa_i31_bits.c +47 -0
- package/runtime/third_party/bearssl/src/ec/ecdsa_i31_sign_asn1.c +45 -0
- package/runtime/third_party/bearssl/src/ec/ecdsa_i31_sign_raw.c +173 -0
- package/runtime/third_party/bearssl/src/ec/ecdsa_i31_vrfy_asn1.c +48 -0
- package/runtime/third_party/bearssl/src/ec/ecdsa_i31_vrfy_raw.c +165 -0
- package/runtime/third_party/bearssl/src/ec/ecdsa_rta.c +121 -0
- package/runtime/third_party/bearssl/src/hash/dig_oid.c +84 -0
- package/runtime/third_party/bearssl/src/hash/dig_size.c +50 -0
- package/runtime/third_party/bearssl/src/hash/ghash_ctmul.c +345 -0
- package/runtime/third_party/bearssl/src/hash/ghash_ctmul32.c +251 -0
- package/runtime/third_party/bearssl/src/hash/ghash_ctmul64.c +154 -0
- package/runtime/third_party/bearssl/src/hash/ghash_pclmul.c +389 -0
- package/runtime/third_party/bearssl/src/hash/ghash_pwr8.c +411 -0
- package/runtime/third_party/bearssl/src/hash/md5.c +208 -0
- package/runtime/third_party/bearssl/src/hash/md5sha1.c +141 -0
- package/runtime/third_party/bearssl/src/hash/mgf1.c +56 -0
- package/runtime/third_party/bearssl/src/hash/multihash.c +166 -0
- package/runtime/third_party/bearssl/src/hash/sha1.c +191 -0
- package/runtime/third_party/bearssl/src/hash/sha2big.c +285 -0
- package/runtime/third_party/bearssl/src/hash/sha2small.c +341 -0
- package/runtime/third_party/bearssl/src/inner.h +2577 -0
- package/runtime/third_party/bearssl/src/int/i15_add.c +46 -0
- package/runtime/third_party/bearssl/src/int/i15_bitlen.c +44 -0
- package/runtime/third_party/bearssl/src/int/i15_decmod.c +124 -0
- package/runtime/third_party/bearssl/src/int/i15_decode.c +56 -0
- package/runtime/third_party/bearssl/src/int/i15_decred.c +100 -0
- package/runtime/third_party/bearssl/src/int/i15_encode.c +56 -0
- package/runtime/third_party/bearssl/src/int/i15_fmont.c +59 -0
- package/runtime/third_party/bearssl/src/int/i15_iszero.c +39 -0
- package/runtime/third_party/bearssl/src/int/i15_moddiv.c +465 -0
- package/runtime/third_party/bearssl/src/int/i15_modpow.c +50 -0
- package/runtime/third_party/bearssl/src/int/i15_modpow2.c +160 -0
- package/runtime/third_party/bearssl/src/int/i15_montmul.c +184 -0
- package/runtime/third_party/bearssl/src/int/i15_mulacc.c +61 -0
- package/runtime/third_party/bearssl/src/int/i15_muladd.c +173 -0
- package/runtime/third_party/bearssl/src/int/i15_ninv15.c +38 -0
- package/runtime/third_party/bearssl/src/int/i15_reduce.c +66 -0
- package/runtime/third_party/bearssl/src/int/i15_rshift.c +47 -0
- package/runtime/third_party/bearssl/src/int/i15_sub.c +46 -0
- package/runtime/third_party/bearssl/src/int/i15_tmont.c +36 -0
- package/runtime/third_party/bearssl/src/int/i31_add.c +46 -0
- package/runtime/third_party/bearssl/src/int/i31_bitlen.c +44 -0
- package/runtime/third_party/bearssl/src/int/i31_decmod.c +124 -0
- package/runtime/third_party/bearssl/src/int/i31_decode.c +57 -0
- package/runtime/third_party/bearssl/src/int/i31_decred.c +103 -0
- package/runtime/third_party/bearssl/src/int/i31_encode.c +79 -0
- package/runtime/third_party/bearssl/src/int/i31_fmont.c +60 -0
- package/runtime/third_party/bearssl/src/int/i31_iszero.c +39 -0
- package/runtime/third_party/bearssl/src/int/i31_moddiv.c +488 -0
- package/runtime/third_party/bearssl/src/int/i31_modpow.c +65 -0
- package/runtime/third_party/bearssl/src/int/i31_modpow2.c +160 -0
- package/runtime/third_party/bearssl/src/int/i31_montmul.c +127 -0
- package/runtime/third_party/bearssl/src/int/i31_mulacc.c +74 -0
- package/runtime/third_party/bearssl/src/int/i31_muladd.c +157 -0
- package/runtime/third_party/bearssl/src/int/i31_ninv31.c +39 -0
- package/runtime/third_party/bearssl/src/int/i31_reduce.c +66 -0
- package/runtime/third_party/bearssl/src/int/i31_rshift.c +47 -0
- package/runtime/third_party/bearssl/src/int/i31_sub.c +46 -0
- package/runtime/third_party/bearssl/src/int/i31_tmont.c +36 -0
- package/runtime/third_party/bearssl/src/int/i32_add.c +51 -0
- package/runtime/third_party/bearssl/src/int/i32_bitlen.c +44 -0
- package/runtime/third_party/bearssl/src/int/i32_decmod.c +77 -0
- package/runtime/third_party/bearssl/src/int/i32_decode.c +63 -0
- package/runtime/third_party/bearssl/src/int/i32_decred.c +107 -0
- package/runtime/third_party/bearssl/src/int/i32_div32.c +56 -0
- package/runtime/third_party/bearssl/src/int/i32_encode.c +72 -0
- package/runtime/third_party/bearssl/src/int/i32_fmont.c +60 -0
- package/runtime/third_party/bearssl/src/int/i32_iszero.c +39 -0
- package/runtime/third_party/bearssl/src/int/i32_modpow.c +65 -0
- package/runtime/third_party/bearssl/src/int/i32_montmul.c +69 -0
- package/runtime/third_party/bearssl/src/int/i32_mulacc.c +56 -0
- package/runtime/third_party/bearssl/src/int/i32_muladd.c +138 -0
- package/runtime/third_party/bearssl/src/int/i32_ninv32.c +39 -0
- package/runtime/third_party/bearssl/src/int/i32_reduce.c +66 -0
- package/runtime/third_party/bearssl/src/int/i32_sub.c +51 -0
- package/runtime/third_party/bearssl/src/int/i32_tmont.c +36 -0
- package/runtime/third_party/bearssl/src/int/i62_modpow2.c +493 -0
- package/runtime/third_party/bearssl/src/kdf/hkdf.c +107 -0
- package/runtime/third_party/bearssl/src/kdf/shake.c +590 -0
- package/runtime/third_party/bearssl/src/mac/hmac.c +122 -0
- package/runtime/third_party/bearssl/src/mac/hmac_ct.c +193 -0
- package/runtime/third_party/bearssl/src/rand/aesctr_drbg.c +206 -0
- package/runtime/third_party/bearssl/src/rand/hmac_drbg.c +157 -0
- package/runtime/third_party/bearssl/src/rand/sysrng.c +252 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_default_keygen.c +38 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_default_modulus.c +36 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_default_oaep_decrypt.c +38 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_default_oaep_encrypt.c +38 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_default_pkcs1_sign.c +38 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_default_pkcs1_vrfy.c +38 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_default_priv.c +38 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_default_privexp.c +36 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_default_pss_sign.c +38 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_default_pss_vrfy.c +38 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_default_pub.c +38 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_default_pubexp.c +36 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i15_keygen.c +583 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i15_modulus.c +99 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i15_oaep_decrypt.c +41 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i15_oaep_encrypt.c +44 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i15_pkcs1_sign.c +37 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i15_pkcs1_vrfy.c +43 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i15_priv.c +209 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i15_privexp.c +320 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i15_pss_sign.c +40 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i15_pss_vrfy.c +44 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i15_pub.c +113 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i15_pubexp.c +152 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i31_keygen.c +37 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i31_keygen_inner.c +608 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i31_modulus.c +99 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i31_oaep_decrypt.c +41 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i31_oaep_encrypt.c +44 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i31_pkcs1_sign.c +37 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i31_pkcs1_vrfy.c +43 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i31_priv.c +203 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i31_privexp.c +318 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i31_pss_sign.c +40 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i31_pss_vrfy.c +44 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i31_pub.c +106 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i31_pubexp.c +152 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i32_oaep_decrypt.c +41 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i32_oaep_encrypt.c +44 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i32_pkcs1_sign.c +37 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i32_pkcs1_vrfy.c +43 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i32_priv.c +160 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i32_pss_sign.c +40 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i32_pss_vrfy.c +44 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i32_pub.c +77 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i62_keygen.c +57 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i62_oaep_decrypt.c +61 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i62_oaep_encrypt.c +64 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i62_pkcs1_sign.c +57 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i62_pkcs1_vrfy.c +63 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i62_priv.c +223 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i62_pss_sign.c +60 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i62_pss_vrfy.c +64 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i62_pub.c +125 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_oaep_pad.c +112 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_oaep_unpad.c +145 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_pkcs1_sig_pad.c +100 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_pkcs1_sig_unpad.c +121 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_pss_sig_pad.c +106 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_pss_sig_unpad.c +121 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_ssl_decrypt.c +52 -0
- package/runtime/third_party/bearssl/src/settings.c +306 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_big_cbcdec.c +69 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_big_cbcenc.c +67 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_big_ctr.c +84 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_big_ctrcbc.c +142 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_big_dec.c +254 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_big_enc.c +157 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_common.c +112 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_ct.c +328 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_ct64.c +398 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_ct64_cbcdec.c +104 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_ct64_cbcenc.c +81 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_ct64_ctr.c +114 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_ct64_ctrcbc.c +433 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_ct64_dec.c +159 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_ct64_enc.c +115 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_ct_cbcdec.c +111 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_ct_cbcenc.c +91 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_ct_ctr.c +116 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_ct_ctrcbc.c +422 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_ct_dec.c +170 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_ct_enc.c +112 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_pwr8.c +445 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_pwr8_cbcdec.c +670 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_pwr8_cbcenc.c +417 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_pwr8_ctr.c +717 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_pwr8_ctrcbc.c +946 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_small_cbcdec.c +69 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_small_cbcenc.c +67 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_small_ctr.c +84 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_small_ctrcbc.c +142 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_small_dec.c +176 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_small_enc.c +129 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_x86ni.c +240 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_x86ni_cbcdec.c +223 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_x86ni_cbcenc.c +122 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_x86ni_ctr.c +211 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_x86ni_ctrcbc.c +596 -0
- package/runtime/third_party/bearssl/src/symcipher/chacha20_ct.c +106 -0
- package/runtime/third_party/bearssl/src/symcipher/chacha20_sse2.c +237 -0
- package/runtime/third_party/bearssl/src/symcipher/des_ct.c +411 -0
- package/runtime/third_party/bearssl/src/symcipher/des_ct_cbcdec.c +87 -0
- package/runtime/third_party/bearssl/src/symcipher/des_ct_cbcenc.c +69 -0
- package/runtime/third_party/bearssl/src/symcipher/des_support.c +166 -0
- package/runtime/third_party/bearssl/src/symcipher/des_tab.c +310 -0
- package/runtime/third_party/bearssl/src/symcipher/des_tab_cbcdec.c +85 -0
- package/runtime/third_party/bearssl/src/symcipher/des_tab_cbcenc.c +67 -0
- package/runtime/third_party/bearssl/src/symcipher/poly1305_ctmul.c +260 -0
- package/runtime/third_party/bearssl/src/symcipher/poly1305_ctmul32.c +297 -0
- package/runtime/third_party/bearssl/src/symcipher/poly1305_ctmulq.c +475 -0
- package/runtime/third_party/bearssl/src/symcipher/poly1305_i15.c +221 -0
- package/runtime/third_party/bearssl/src/x509/asn1.t0 +757 -0
- package/runtime/third_party/bearssl/src/x509/asn1enc.c +93 -0
- package/runtime/third_party/bearssl/src/x509/encode_ec_pk8der.c +110 -0
- package/runtime/third_party/bearssl/src/x509/encode_ec_rawder.c +161 -0
- package/runtime/third_party/bearssl/src/x509/encode_rsa_pk8der.c +97 -0
- package/runtime/third_party/bearssl/src/x509/encode_rsa_rawder.c +96 -0
- package/runtime/third_party/bearssl/src/x509/skey_decoder.c +653 -0
- package/runtime/third_party/bearssl/src/x509/skey_decoder.t0 +376 -0
- package/runtime/third_party/bearssl/src/x509/x509_decoder.c +776 -0
- package/runtime/third_party/bearssl/src/x509/x509_decoder.t0 +324 -0
- package/runtime/third_party/bearssl/src/x509/x509_knownkey.c +105 -0
- package/runtime/third_party/bearssl/src/x509/x509_minimal.c +1722 -0
- package/runtime/third_party/bearssl/src/x509/x509_minimal.t0 +1526 -0
- package/runtime/third_party/bearssl/src/x509/x509_minimal_full.c +59 -0
- package/runtime/third_party/quickjs-dtoa/LICENSE +22 -0
- package/runtime/third_party/quickjs-dtoa/README.md +23 -0
- package/runtime/third_party/quickjs-dtoa/dtoa.c +1640 -0
- package/runtime/third_party/quickjs-dtoa/dtoa.h +83 -0
- package/runtime/third_party/quickjs-dtoa/dtoa_compat.h +89 -0
- package/runtime/third_party/quickjs-regexp/LICENSE +22 -0
- package/runtime/third_party/quickjs-regexp/README.md +22 -0
- package/runtime/third_party/quickjs-regexp/cutils.c +641 -0
- package/runtime/third_party/quickjs-regexp/cutils.h +457 -0
- package/runtime/third_party/quickjs-regexp/libregexp-opcode.h +73 -0
- package/runtime/third_party/quickjs-regexp/libregexp.c +3448 -0
- package/runtime/third_party/quickjs-regexp/libregexp.h +65 -0
- package/runtime/third_party/quickjs-regexp/libunicode-table.h +5206 -0
- package/runtime/third_party/quickjs-regexp/libunicode.c +2124 -0
- package/runtime/third_party/quickjs-regexp/libunicode.h +196 -0
- package/runtime/third_party/v8-ieee754/LICENSE +61 -0
- package/runtime/third_party/v8-ieee754/README.md +22 -0
- package/runtime/third_party/v8-ieee754/convert.py +84 -0
- package/runtime/third_party/v8-ieee754/ieee754.c +3030 -0
- package/runtime/third_party/v8-ieee754/ieee754.h +27 -0
- package/runtime/tools/regexp_compile.c +90 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/* regexp_anchor.h — a start-anchored regular expression tries one position (ADR 0015), shared
|
|
2
|
+
* by the runtime (new RegExp) and the compiler's regexp-compile tool (literals).
|
|
3
|
+
*
|
|
4
|
+
* libregexp starts a non-sticky program with a loop that tries every position:
|
|
5
|
+
*
|
|
6
|
+
* split_goto_first +6; any; goto -11; save_start 0; <the pattern>
|
|
7
|
+
*
|
|
8
|
+
* When the pattern's first op is line_start (`^` without the m flag, in front of every
|
|
9
|
+
* alternative), a match can only start at index 0, so trying the later positions only costs
|
|
10
|
+
* time: O(length) for every failed exec, which makes a tokenizer that tries its `^` rules on the
|
|
11
|
+
* rest of its input quadratic. Turning the split into `goto +6` (same size, so no offset moves)
|
|
12
|
+
* leaves one attempt, at lastIndex, where line_start fails unless it is 0. */
|
|
13
|
+
#ifndef JS_REGEXP_ANCHOR_H
|
|
14
|
+
#define JS_REGEXP_ANCHOR_H
|
|
15
|
+
|
|
16
|
+
#include <stdint.h>
|
|
17
|
+
|
|
18
|
+
enum {
|
|
19
|
+
#define DEF(id, size) JS_REOP_##id,
|
|
20
|
+
#include "libregexp-opcode.h"
|
|
21
|
+
#undef DEF
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
#define JS_RE_HEADER_LEN 8 /* libregexp's RE_HEADER_LEN: flags, counts, bytecode length */
|
|
25
|
+
|
|
26
|
+
static inline void js_regexp_anchor(uint8_t *bc, int len) {
|
|
27
|
+
const uint8_t *p = bc + JS_RE_HEADER_LEN;
|
|
28
|
+
if (len < JS_RE_HEADER_LEN + 14 || p[0] != JS_REOP_split_goto_first || p[5] != JS_REOP_any || p[6] != JS_REOP_goto ||
|
|
29
|
+
p[11] != JS_REOP_save_start || p[13] != JS_REOP_line_start)
|
|
30
|
+
return;
|
|
31
|
+
bc[JS_RE_HEADER_LEN] = JS_REOP_goto;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
#endif /* JS_REGEXP_ANCHOR_H */
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/* regexp_message.h — libregexp's error messages in V8's words (ADR 0015), shared by the runtime
|
|
2
|
+
* (new RegExp) and the compiler's regexp-compile tool (literals), so both report alike. */
|
|
3
|
+
#ifndef JS_REGEXP_MESSAGE_H
|
|
4
|
+
#define JS_REGEXP_MESSAGE_H
|
|
5
|
+
|
|
6
|
+
#include <stdio.h>
|
|
7
|
+
#include <string.h>
|
|
8
|
+
|
|
9
|
+
/* V8's wording for libregexp's most common messages; the others, capitalized. */
|
|
10
|
+
static inline const char *js_regexp_message(const char *msg, char *buf, size_t cap) {
|
|
11
|
+
static const struct { const char *lre, *v8; } names[] = {
|
|
12
|
+
{ "expecting ')'", "Unterminated group" },
|
|
13
|
+
{ "extraneous characters at the end", "Unmatched ')'" },
|
|
14
|
+
{ "nothing to repeat", "Nothing to repeat" },
|
|
15
|
+
{ "invalid class range", "Range out of order in character class" },
|
|
16
|
+
{ "duplicate group name", "Duplicate capture group name" },
|
|
17
|
+
{ "invalid repetition count", "numbers out of order in {} quantifier" },
|
|
18
|
+
{ "unknown unicode property name", "Invalid property name" },
|
|
19
|
+
{ "unknown unicode property value", "Invalid property name" },
|
|
20
|
+
{ "unknown unicode script", "Invalid property name" },
|
|
21
|
+
{ "unknown unicode general category", "Invalid property name" },
|
|
22
|
+
{ "group name not defined", "Invalid named capture referenced" },
|
|
23
|
+
{ "expecting ']'", "Unterminated character class" },
|
|
24
|
+
};
|
|
25
|
+
for (size_t i = 0; i < sizeof names / sizeof names[0]; i++)
|
|
26
|
+
if (strcmp(msg, names[i].lre) == 0) return names[i].v8;
|
|
27
|
+
snprintf(buf, cap, "%s", msg);
|
|
28
|
+
if (buf[0] >= 'a' && buf[0] <= 'z') buf[0] = (char)(buf[0] - 'a' + 'A');
|
|
29
|
+
return buf;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
#endif /* JS_REGEXP_MESSAGE_H */
|
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
/* Shapes (ADR 0005): hidden classes, their transition tree and lookup tables. */
|
|
2
|
+
#include <stdlib.h>
|
|
3
|
+
#include <string.h>
|
|
4
|
+
|
|
5
|
+
#include "internal.h"
|
|
6
|
+
#include "js_object.h"
|
|
7
|
+
#include "jscontext.h"
|
|
8
|
+
#include "shape.h"
|
|
9
|
+
|
|
10
|
+
/* ---- Property tables: ordered entries + an identity-keyed hash index ------ */
|
|
11
|
+
|
|
12
|
+
static uint32_t key_hash(JSValue key) {
|
|
13
|
+
uint64_t x = key.bits * UINT64_C(0x9E3779B97F4A7C15);
|
|
14
|
+
return (uint32_t)(x >> 32);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
JSPropTable *js_prop_table_new(uint32_t capacity) {
|
|
18
|
+
JSPropTable *t = calloc(1, sizeof *t);
|
|
19
|
+
if (!t) js_fatal("out of memory (property table)");
|
|
20
|
+
t->cap = capacity < 8 ? 8 : capacity;
|
|
21
|
+
t->entries = malloc(t->cap * sizeof *t->entries);
|
|
22
|
+
t->index_cap = 16;
|
|
23
|
+
while (t->index_cap < 2 * t->cap) t->index_cap *= 2;
|
|
24
|
+
t->index = malloc(t->index_cap * sizeof *t->index);
|
|
25
|
+
if (!t->entries || !t->index) js_fatal("out of memory (property table)");
|
|
26
|
+
memset(t->index, 0xFF, t->index_cap * sizeof *t->index);
|
|
27
|
+
return t;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
void js_prop_table_free(JSPropTable *t) {
|
|
31
|
+
if (!t) return;
|
|
32
|
+
free(t->entries);
|
|
33
|
+
free(t->index);
|
|
34
|
+
free(t);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
static void reindex(JSPropTable *t) {
|
|
38
|
+
while (t->index_cap < 2 * t->cap) t->index_cap *= 2;
|
|
39
|
+
free(t->index);
|
|
40
|
+
t->index = malloc(t->index_cap * sizeof *t->index);
|
|
41
|
+
if (!t->index) js_fatal("out of memory (property table)");
|
|
42
|
+
memset(t->index, 0xFF, t->index_cap * sizeof *t->index);
|
|
43
|
+
for (uint32_t i = 0; i < t->count; i++) {
|
|
44
|
+
uint32_t h = key_hash(t->entries[i].key) & (t->index_cap - 1);
|
|
45
|
+
while (t->index[h] >= 0) h = (h + 1) & (t->index_cap - 1);
|
|
46
|
+
t->index[h] = (int32_t)i;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
int32_t js_prop_table_find(const JSPropTable *t, JSValue key) {
|
|
51
|
+
for (uint32_t h = key_hash(key) & (t->index_cap - 1);; h = (h + 1) & (t->index_cap - 1)) {
|
|
52
|
+
int32_t i = t->index[h];
|
|
53
|
+
if (i < 0) return -1;
|
|
54
|
+
if (js_same_bits(t->entries[i].key, key)) return i;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
void js_prop_table_add(JSPropTable *t, JSValue key, uint32_t slot, uint8_t attrs) {
|
|
59
|
+
if (t->count == t->cap) {
|
|
60
|
+
t->cap *= 2;
|
|
61
|
+
t->entries = realloc(t->entries, t->cap * sizeof *t->entries);
|
|
62
|
+
if (!t->entries) js_fatal("out of memory (property table)");
|
|
63
|
+
reindex(t);
|
|
64
|
+
}
|
|
65
|
+
uint32_t i = t->count++;
|
|
66
|
+
t->entries[i] = (JSPropEntry){ key, slot, attrs };
|
|
67
|
+
uint32_t h = key_hash(key) & (t->index_cap - 1);
|
|
68
|
+
while (t->index[h] >= 0) h = (h + 1) & (t->index_cap - 1);
|
|
69
|
+
t->index[h] = (int32_t)i;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/* Removes entry i, keeping insertion order. */
|
|
73
|
+
void js_prop_table_remove(JSPropTable *t, uint32_t i) {
|
|
74
|
+
memmove(&t->entries[i], &t->entries[i + 1], (t->count - i - 1) * sizeof *t->entries);
|
|
75
|
+
t->count--;
|
|
76
|
+
reindex(t);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
JSPropTable *js_prop_table_clone(const JSPropTable *src) {
|
|
80
|
+
JSPropTable *t = js_prop_table_new(src->count);
|
|
81
|
+
for (uint32_t i = 0; i < src->count; i++) js_prop_table_add(t, src->entries[i].key, src->entries[i].slot, src->entries[i].attrs);
|
|
82
|
+
return t;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/* ---- Shape cells ---------------------------------------------------------- */
|
|
86
|
+
|
|
87
|
+
static void shape_visit(JSCell *c, JSTracer *trc) {
|
|
88
|
+
JSShape *s = (JSShape *)c;
|
|
89
|
+
js_trace_value(trc, s->proto);
|
|
90
|
+
js_trace_value(trc, s->key);
|
|
91
|
+
if (s->parent) js_trace_cell(trc, &s->parent->cell);
|
|
92
|
+
/* a dictionary's keys exist only in its table; a shared table's keys are on the chain */
|
|
93
|
+
if (s->table && (s->flags & JS_SHAPE_DICTIONARY))
|
|
94
|
+
for (uint32_t i = 0; i < s->table->count; i++) js_trace_value(trc, s->table->entries[i].key);
|
|
95
|
+
/* transitions are weak: children aren't traced (js_shapes_sweep) */
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
static void shape_finalize(JSRuntime *rt, JSCell *c) {
|
|
99
|
+
(void)rt;
|
|
100
|
+
JSShape *s = (JSShape *)c;
|
|
101
|
+
js_prop_table_free(s->table);
|
|
102
|
+
if (s->transitions) {
|
|
103
|
+
free(s->transitions->items);
|
|
104
|
+
free(s->transitions);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const JSCellClass js_shape_cell_class = { "Shape", shape_visit, shape_finalize };
|
|
109
|
+
|
|
110
|
+
JSShape *js_alloc_shape(JSContext *ctx) {
|
|
111
|
+
JSShape *s = (JSShape *)js_alloc_cell(ctx, JS_CELL_SHAPE, sizeof(JSShape));
|
|
112
|
+
s->cell.flags |= JS_CELL_FINALIZABLE; /* tables and transitions are malloc'd */
|
|
113
|
+
js_block_of(s)->has_finalizable = 1;
|
|
114
|
+
s->proto = JS_NULL;
|
|
115
|
+
s->key = JS_EMPTY;
|
|
116
|
+
return s;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/* ---- Roots: one per (class, proto, inline capacity), weakly held ------------ */
|
|
120
|
+
|
|
121
|
+
static uint32_t root_hash(const JSClass *cls, JSValue proto, uint16_t cap) {
|
|
122
|
+
uint64_t x = ((uint64_t)(uintptr_t)cls ^ proto.bits ^ ((uint64_t)cap << 48)) * UINT64_C(0x9E3779B97F4A7C15);
|
|
123
|
+
return (uint32_t)(x >> 32);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
static void roots_put(JSShape **table, size_t cap, JSShape *s) {
|
|
127
|
+
size_t i = root_hash(s->cls, s->proto, s->inline_cap) & (cap - 1);
|
|
128
|
+
while (table[i]) i = (i + 1) & (cap - 1);
|
|
129
|
+
table[i] = s;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
static void roots_rebuild(JSShapeRegistry *r, size_t cap, bool (*keep)(JSShape *)) {
|
|
133
|
+
JSShape **table = calloc(cap, sizeof *table);
|
|
134
|
+
if (!table) js_fatal("out of memory (shape roots)");
|
|
135
|
+
size_t count = 0;
|
|
136
|
+
for (size_t i = 0; i < r->root_cap; i++)
|
|
137
|
+
if (r->roots[i] && (!keep || keep(r->roots[i]))) {
|
|
138
|
+
roots_put(table, cap, r->roots[i]);
|
|
139
|
+
count++;
|
|
140
|
+
}
|
|
141
|
+
free(r->roots);
|
|
142
|
+
r->roots = table;
|
|
143
|
+
r->root_cap = cap;
|
|
144
|
+
r->root_count = count;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
JSShape *js_shape_root(JSContext *ctx, const JSClass *cls, JSValue proto, uint16_t inline_cap) {
|
|
148
|
+
if (inline_cap > JS_MAX_INLINE_SLOTS) inline_cap = JS_MAX_INLINE_SLOTS;
|
|
149
|
+
JSShapeRegistry *r = &ctx->rt->shapes;
|
|
150
|
+
if (r->root_cap)
|
|
151
|
+
for (size_t i = root_hash(cls, proto, inline_cap) & (r->root_cap - 1); r->roots[i]; i = (i + 1) & (r->root_cap - 1)) {
|
|
152
|
+
JSShape *s = r->roots[i];
|
|
153
|
+
if (s->cls == cls && js_same_bits(s->proto, proto) && s->inline_cap == inline_cap) return s;
|
|
154
|
+
}
|
|
155
|
+
JSShape *s = js_alloc_shape(ctx); /* may collect: nothing above is held across it */
|
|
156
|
+
s->cls = cls;
|
|
157
|
+
s->proto = proto;
|
|
158
|
+
s->flags = JS_SHAPE_EXTENSIBLE;
|
|
159
|
+
s->inline_cap = inline_cap;
|
|
160
|
+
s->slot_offset = cls->instance_size;
|
|
161
|
+
if (2 * (r->root_count + 1) > r->root_cap) roots_rebuild(r, r->root_cap ? r->root_cap * 2 : 64, NULL);
|
|
162
|
+
roots_put(r->roots, r->root_cap, s);
|
|
163
|
+
r->root_count++;
|
|
164
|
+
return s;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/* ---- Transitions ------------------------------------------------------------ */
|
|
168
|
+
|
|
169
|
+
uint32_t js_shape_transition_count(const JSShape *s) {
|
|
170
|
+
return s->transitions ? s->transitions->count : 0;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
JSShape *js_shape_add(JSContext *ctx, JSShape *shape, JSValue key, uint8_t attrs) {
|
|
174
|
+
JSTransitions *t = shape->transitions;
|
|
175
|
+
if (t)
|
|
176
|
+
for (uint32_t i = 0; i < t->count; i++)
|
|
177
|
+
if (js_same_bits(t->items[i].key, key) && t->items[i].attrs == attrs) return t->items[i].child;
|
|
178
|
+
|
|
179
|
+
JSShape *child = js_alloc_shape(ctx); /* `shape` is kept alive by the caller */
|
|
180
|
+
child->cls = shape->cls;
|
|
181
|
+
child->proto = shape->proto;
|
|
182
|
+
child->parent = shape;
|
|
183
|
+
child->key = key;
|
|
184
|
+
child->attrs = attrs;
|
|
185
|
+
child->flags = shape->flags;
|
|
186
|
+
child->inline_cap = shape->inline_cap;
|
|
187
|
+
child->slot_offset = shape->slot_offset;
|
|
188
|
+
child->prop_count = shape->prop_count + 1;
|
|
189
|
+
|
|
190
|
+
t = shape->transitions;
|
|
191
|
+
if (!t) {
|
|
192
|
+
t = shape->transitions = calloc(1, sizeof *t);
|
|
193
|
+
if (!t) js_fatal("out of memory (transitions)");
|
|
194
|
+
JSShapeRegistry *r = &ctx->rt->shapes;
|
|
195
|
+
if (r->parent_count == r->parent_cap) {
|
|
196
|
+
r->parent_cap = r->parent_cap ? r->parent_cap * 2 : 64;
|
|
197
|
+
r->parents = realloc(r->parents, r->parent_cap * sizeof *r->parents);
|
|
198
|
+
if (!r->parents) js_fatal("out of memory (shape registry)");
|
|
199
|
+
}
|
|
200
|
+
r->parents[r->parent_count++] = shape;
|
|
201
|
+
}
|
|
202
|
+
if (t->count == t->cap) {
|
|
203
|
+
t->cap = t->cap ? t->cap * 2 : 2;
|
|
204
|
+
t->items = realloc(t->items, t->cap * sizeof *t->items);
|
|
205
|
+
if (!t->items) js_fatal("out of memory (transitions)");
|
|
206
|
+
}
|
|
207
|
+
t->items[t->count++] = (JSTransition){ key, attrs, child };
|
|
208
|
+
return child;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/* ---- Lookup ------------------------------------------------------------------- */
|
|
212
|
+
|
|
213
|
+
#define WALK_LIMIT 8 /* above this many properties, build a table (ADR 0005) */
|
|
214
|
+
|
|
215
|
+
static void build_table(JSShape *s) {
|
|
216
|
+
uint32_t n = s->prop_count;
|
|
217
|
+
JSShape **chain = malloc((n ? n : 1) * sizeof *chain);
|
|
218
|
+
if (!chain) js_fatal("out of memory (property table)");
|
|
219
|
+
uint32_t k = n;
|
|
220
|
+
for (JSShape *x = s; x->parent; x = x->parent) chain[--k] = x;
|
|
221
|
+
s->table = js_prop_table_new(n);
|
|
222
|
+
for (uint32_t i = 0; i < n; i++) js_prop_table_add(s->table, chain[i]->key, i, chain[i]->attrs);
|
|
223
|
+
free(chain);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
int32_t js_shape_find(JSShape *s, JSValue key, uint8_t *attrs) {
|
|
227
|
+
if (!s->table && s->prop_count > WALK_LIMIT) build_table(s);
|
|
228
|
+
if (s->table) {
|
|
229
|
+
int32_t i = js_prop_table_find(s->table, key);
|
|
230
|
+
if (i < 0) return -1;
|
|
231
|
+
*attrs = s->table->entries[i].attrs;
|
|
232
|
+
return (int32_t)s->table->entries[i].slot;
|
|
233
|
+
}
|
|
234
|
+
for (JSShape *x = s; x->parent; x = x->parent)
|
|
235
|
+
if (js_same_bits(x->key, key)) {
|
|
236
|
+
*attrs = x->attrs;
|
|
237
|
+
return (int32_t)(x->prop_count - 1);
|
|
238
|
+
}
|
|
239
|
+
return -1;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
JSPropTable *js_shape_entries(JSShape *s) {
|
|
243
|
+
if (!s->table) build_table(s);
|
|
244
|
+
return s->table;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/* ---- Weak processing (after marking) ------------------------------------- */
|
|
248
|
+
|
|
249
|
+
static bool shape_alive(JSShape *s) { return js_gc_is_marked(&s->cell); }
|
|
250
|
+
|
|
251
|
+
void js_shapes_sweep(JSRuntime *rt) {
|
|
252
|
+
JSShapeRegistry *r = &rt->shapes;
|
|
253
|
+
/* a dead parent's children are dead too: they point to it */
|
|
254
|
+
size_t kept = 0;
|
|
255
|
+
for (size_t i = 0; i < r->parent_count; i++) {
|
|
256
|
+
JSShape *p = r->parents[i];
|
|
257
|
+
if (!shape_alive(p)) continue;
|
|
258
|
+
JSTransitions *t = p->transitions;
|
|
259
|
+
uint32_t live = 0;
|
|
260
|
+
for (uint32_t k = 0; k < t->count; k++)
|
|
261
|
+
if (shape_alive(t->items[k].child)) t->items[live++] = t->items[k];
|
|
262
|
+
t->count = live;
|
|
263
|
+
if (live) r->parents[kept++] = p;
|
|
264
|
+
else {
|
|
265
|
+
free(t->items);
|
|
266
|
+
free(t);
|
|
267
|
+
p->transitions = NULL;
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
r->parent_count = kept;
|
|
271
|
+
if (r->root_cap) {
|
|
272
|
+
size_t live = 0;
|
|
273
|
+
for (size_t i = 0; i < r->root_cap; i++) live += r->roots[i] && shape_alive(r->roots[i]);
|
|
274
|
+
size_t cap = 64;
|
|
275
|
+
while (cap < 4 * live) cap *= 2;
|
|
276
|
+
roots_rebuild(r, cap, shape_alive);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
void js_shapes_free(JSRuntime *rt) {
|
|
281
|
+
free(rt->shapes.roots);
|
|
282
|
+
free(rt->shapes.parents);
|
|
283
|
+
memset(&rt->shapes, 0, sizeof rt->shapes);
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
JSShape *js_cached_shape(JSContext *ctx, JSIntrinsic slot, const JSClass *cls, JSValue proto, uint16_t inline_cap,
|
|
287
|
+
uint32_t n, const JSValue *keys, uint8_t attrs) {
|
|
288
|
+
JSValue cached = ctx->intrinsics[slot];
|
|
289
|
+
if (js_is_cell(cached) && js_as_cell(cached)->kind == JS_CELL_SHAPE) return (JSShape *)js_as_cell(cached);
|
|
290
|
+
JSShape *s = js_shape_root(ctx, cls, proto, inline_cap);
|
|
291
|
+
for (uint32_t i = 0; i < n; i++) s = js_shape_add(ctx, s, keys[i], attrs);
|
|
292
|
+
ctx->intrinsics[slot] = js_cell(&s->cell); /* a root: the shape (and its parents) stay alive */
|
|
293
|
+
return s;
|
|
294
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/* shape.h — shape internals shared by shape.c and object.c. Runtime-internal. */
|
|
2
|
+
#ifndef JS_SHAPE_H
|
|
3
|
+
#define JS_SHAPE_H
|
|
4
|
+
|
|
5
|
+
#include "js_object.h"
|
|
6
|
+
|
|
7
|
+
typedef struct JSPropEntry {
|
|
8
|
+
JSValue key;
|
|
9
|
+
uint32_t slot;
|
|
10
|
+
uint8_t attrs;
|
|
11
|
+
} JSPropEntry;
|
|
12
|
+
|
|
13
|
+
/* key → (slot, attrs): entries in insertion order, plus an open-addressing index. */
|
|
14
|
+
struct JSPropTable {
|
|
15
|
+
uint32_t count, cap;
|
|
16
|
+
JSPropEntry *entries;
|
|
17
|
+
uint32_t index_cap;
|
|
18
|
+
int32_t *index; /* entry numbers; -1 = empty */
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
typedef struct JSTransition {
|
|
22
|
+
JSValue key;
|
|
23
|
+
uint8_t attrs;
|
|
24
|
+
JSShape *child; /* weak */
|
|
25
|
+
} JSTransition;
|
|
26
|
+
|
|
27
|
+
struct JSTransitions {
|
|
28
|
+
uint32_t count, cap;
|
|
29
|
+
JSTransition *items;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
#define JS_MAX_TRANSITIONS 64 /* more distinct keys added to one shape: the object becomes a dictionary */
|
|
33
|
+
|
|
34
|
+
JSPropTable *js_prop_table_new(uint32_t capacity);
|
|
35
|
+
void js_prop_table_free(JSPropTable *t);
|
|
36
|
+
int32_t js_prop_table_find(const JSPropTable *t, JSValue key);
|
|
37
|
+
void js_prop_table_add(JSPropTable *t, JSValue key, uint32_t slot, uint8_t attrs);
|
|
38
|
+
void js_prop_table_remove(JSPropTable *t, uint32_t i);
|
|
39
|
+
JSPropTable *js_prop_table_clone(const JSPropTable *src);
|
|
40
|
+
|
|
41
|
+
JSShape *js_alloc_shape(JSContext *ctx);
|
|
42
|
+
uint32_t js_shape_transition_count(const JSShape *s);
|
|
43
|
+
/* All entries of a shape, in insertion order (builds the table if needed). */
|
|
44
|
+
JSPropTable *js_shape_entries(JSShape *s);
|
|
45
|
+
|
|
46
|
+
#endif /* JS_SHAPE_H */
|