visaljs 0.0.7 → 0.0.9
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/README.md +68 -4
- package/THIRD_PARTY_LICENSES +1216 -0
- package/cli.js +4461 -321
- package/node/include/js_node.h +57 -1
- package/node/include/js_uv.h +8 -1
- package/node/prelude/_http_agent.js +5 -0
- package/node/prelude/_http_server.js +7 -0
- package/node/prelude/_stream_duplex.js +4 -0
- package/node/prelude/_stream_passthrough.js +4 -0
- package/node/prelude/_stream_readable.js +4 -0
- package/node/prelude/_stream_transform.js +4 -0
- package/node/prelude/_stream_writable.js +4 -0
- package/node/prelude/assert.js +1334 -0
- package/node/prelude/assert_strict.js +12 -0
- package/node/prelude/async_hooks.js +1 -1
- package/node/prelude/buffer.js +43 -3
- package/node/prelude/child_process.js +1098 -0
- package/node/prelude/cluster.js +52 -0
- package/node/prelude/console.js +328 -0
- package/node/prelude/constants.js +10 -0
- package/node/prelude/crypto.js +1 -1
- package/node/prelude/diagnostics_channel.js +1 -1
- package/node/prelude/dns.js +8 -2
- package/node/prelude/domain.js +115 -0
- package/node/prelude/events.js +148 -16
- package/node/prelude/fs.js +1138 -151
- package/node/prelude/fs_promises.js +117 -11
- package/node/prelude/http.js +784 -301
- package/node/prelude/http2.js +1 -1
- package/node/prelude/https.js +159 -0
- package/node/prelude/inspector.js +27 -0
- package/node/prelude/inspector_promises.js +4 -0
- package/node/prelude/internal/async_context.js +1 -1
- package/node/prelude/internal/buffer_transcode.js +44 -0
- package/node/prelude/internal/comparisons.js +916 -0
- package/node/prelude/internal/compression_streams.js +153 -0
- package/node/prelude/internal/crypto/asym.js +27 -14
- package/node/prelude/internal/crypto/cipher.js +16 -5
- package/node/prelude/internal/crypto/diffiehellman.js +3 -2
- package/node/prelude/internal/crypto/hash.js +2 -1
- package/node/prelude/internal/crypto/kdf.js +14 -9
- package/node/prelude/internal/crypto/keys.js +63 -50
- package/node/prelude/internal/crypto/random.js +2 -1
- package/node/prelude/internal/crypto/util.js +4 -4
- package/node/prelude/internal/dotenv.js +98 -0
- package/node/prelude/internal/errors.js +21 -5
- package/node/prelude/internal/events_extras.js +113 -0
- package/node/prelude/internal/events_on.js +100 -0
- package/node/prelude/internal/features.js +72 -0
- package/node/prelude/internal/fetch.js +364 -0
- package/node/prelude/internal/form_data.js +376 -0
- package/node/prelude/internal/fs_bigint_stats.js +41 -0
- package/node/prelude/internal/fs_blob.js +19 -0
- package/node/prelude/internal/fs_cp.js +709 -0
- package/node/prelude/internal/fs_dir.js +166 -0
- package/node/prelude/internal/fs_filehandle.js +287 -0
- package/node/prelude/internal/fs_glob.js +296 -0
- package/node/prelude/internal/fs_statfs.js +42 -0
- package/node/prelude/internal/fs_stats.js +89 -0
- package/node/prelude/internal/fs_streams.js +541 -0
- package/node/prelude/internal/fs_utils.js +286 -0
- package/node/prelude/internal/fs_watch.js +580 -0
- package/node/prelude/internal/http_agent.js +114 -2
- package/node/prelude/internal/http_symbols.js +3 -0
- package/node/prelude/internal/mime.js +249 -0
- package/node/prelude/internal/net.js +1 -0
- package/node/prelude/internal/net_bound.js +123 -0
- package/node/prelude/internal/net_onread.js +73 -0
- package/node/prelude/internal/net_tos.js +54 -0
- package/node/prelude/internal/parse_args.js +288 -0
- package/node/prelude/internal/perf_histogram.js +435 -0
- package/node/prelude/internal/perf_observe.js +125 -0
- package/node/prelude/internal/performance_global.js +19 -0
- package/node/prelude/internal/process_events.js +49 -1
- package/node/prelude/internal/process_memory.js +14 -0
- package/node/prelude/internal/process_more.js +414 -0
- package/node/prelude/internal/process_signals.js +2 -1
- package/node/prelude/internal/process_stdin.js +52 -0
- package/node/prelude/internal/process_stdio.js +36 -0
- package/node/prelude/internal/querystring.js +0 -0
- package/node/prelude/internal/readline.js +338 -0
- package/node/prelude/internal/socketaddress.js +8 -4
- package/node/prelude/internal/source_map.js +122 -0
- package/node/prelude/internal/stream_compose.js +74 -0
- package/node/prelude/internal/stream_from.js +6 -0
- package/node/prelude/internal/stream_operators.js +23 -0
- package/node/prelude/internal/stream_pipeline.js +7 -0
- package/node/prelude/internal/stream_transform.js +10 -0
- package/node/prelude/internal/stream_web_adapters.js +143 -0
- package/node/prelude/internal/streams/add_abort_signal.js +58 -0
- package/node/prelude/internal/streams/compose.js +244 -0
- package/node/prelude/internal/streams/destroy.js +358 -0
- package/node/prelude/internal/streams/duplex.js +199 -0
- package/node/prelude/internal/streams/duplexify.js +378 -0
- package/node/prelude/internal/streams/end_of_stream.js +387 -0
- package/node/prelude/internal/streams/errors.js +216 -0
- package/node/prelude/internal/streams/from.js +211 -0
- package/node/prelude/internal/streams/legacy.js +120 -0
- package/node/prelude/internal/streams/operators.js +375 -0
- package/node/prelude/internal/streams/passthrough.js +45 -0
- package/node/prelude/internal/streams/pipeline.js +468 -0
- package/node/prelude/internal/streams/readable.js +1835 -0
- package/node/prelude/internal/streams/state.js +48 -0
- package/node/prelude/internal/streams/transform.js +203 -0
- package/node/prelude/internal/streams/utils.js +355 -0
- package/node/prelude/internal/streams/validators.js +108 -0
- package/node/prelude/internal/streams/writable.js +1160 -0
- package/node/prelude/internal/structured_clone.js +238 -0
- package/node/prelude/internal/system_errors.js +37 -0
- package/node/prelude/internal/test_runner/mock.js +431 -0
- package/node/prelude/internal/test_runner/reporters.js +404 -0
- package/node/prelude/internal/test_runner/test.js +1571 -0
- package/node/prelude/internal/timers.js +38 -7
- package/node/prelude/internal/timers_global.js +1 -1
- package/node/prelude/internal/tls/common.js +8 -2
- package/node/prelude/internal/tls/wrap.js +5 -16
- package/node/prelude/internal/tls/x509.js +1 -1
- package/node/prelude/internal/tty_read_stream.js +39 -0
- package/node/prelude/internal/tty_streams.js +3 -0
- package/node/prelude/internal/util_debuglog.js +68 -0
- package/node/prelude/internal/util_diff.js +63 -0
- package/node/prelude/internal/util_more.js +111 -0
- package/node/prelude/internal/util_styles.js +76 -0
- package/node/prelude/internal/zlib_engines.js +1 -1
- package/node/prelude/module.js +219 -8
- package/node/prelude/net.js +197 -49
- package/node/prelude/os.js +88 -11
- package/node/prelude/path.js +11 -7
- package/node/prelude/path_posix.js +1 -1
- package/node/prelude/path_win32.js +1 -1
- package/node/prelude/perf_hooks.js +151 -0
- package/node/prelude/process.js +36 -1
- package/node/prelude/punycode.js +188 -0
- package/node/prelude/querystring.js +1 -1
- package/node/prelude/readline.js +8 -0
- package/node/prelude/readline_promises.js +88 -0
- package/node/prelude/repl.js +38 -0
- package/node/prelude/sea.js +23 -0
- package/node/prelude/stream.js +70 -1332
- package/node/prelude/stream_consumers.js +34 -0
- package/node/prelude/stream_promises.js +1 -1
- package/node/prelude/stream_web.js +15 -2
- package/node/prelude/string_decoder.js +1 -1
- package/node/prelude/sys.js +7 -0
- package/node/prelude/test.js +56 -0
- package/node/prelude/test_reporters.js +269 -0
- package/node/prelude/timers.js +7 -84
- package/node/prelude/timers_promises.js +1 -1
- package/node/prelude/tls.js +2 -1
- package/node/prelude/trace_events.js +52 -0
- package/node/prelude/tty.js +10 -4
- package/node/prelude/url.js +88 -27
- package/node/prelude/util.js +121 -5
- package/node/prelude/util_types.js +4 -3
- package/node/prelude/v8.js +814 -0
- package/node/prelude/vm.js +86 -0
- package/node/prelude/wasi.js +10 -0
- package/node/prelude/worker_threads.js +56 -0
- package/node/prelude/zlib.js +58 -25
- package/node/src/host_brotli.c +59 -11
- package/node/src/host_fs.c +342 -11
- package/node/src/host_fswatch.c +170 -0
- package/node/src/host_http.c +292 -39
- package/node/src/host_loop.c +25 -2
- package/node/src/host_net.c +130 -16
- package/node/src/host_os.c +55 -1
- package/node/src/host_proc.c +291 -0
- package/node/src/host_process.c +488 -0
- package/node/src/host_sys.c +64 -2
- package/node/src/host_zlib.c +27 -7
- package/node/src/host_zstd.c +41 -6
- package/node/third_party/hdrhistogram/LICENSE +42 -0
- package/node/third_party/hdrhistogram/README.md +5 -0
- package/node/third_party/libuv/LICENSE +0 -0
- package/node/third_party/libuv/LICENSE-extra +36 -0
- package/node/third_party/libuv/include/uv/aix.h +0 -0
- package/node/third_party/libuv/include/uv/bsd.h +0 -0
- package/node/third_party/libuv/include/uv/darwin.h +0 -0
- package/node/third_party/libuv/include/uv/errno.h +0 -0
- package/node/third_party/libuv/include/uv/linux.h +0 -0
- package/node/third_party/libuv/include/uv/os390.h +0 -0
- package/node/third_party/libuv/include/uv/posix.h +0 -0
- package/node/third_party/libuv/include/uv/sunos.h +0 -0
- package/node/third_party/libuv/include/uv/threadpool.h +0 -0
- package/node/third_party/libuv/include/uv/tree.h +0 -0
- package/node/third_party/libuv/include/uv/unix.h +0 -0
- package/node/third_party/libuv/include/uv/version.h +0 -0
- package/node/third_party/libuv/include/uv/win.h +0 -0
- package/node/third_party/libuv/include/uv.h +0 -0
- package/node/third_party/libuv/src/fs-poll.c +0 -0
- package/node/third_party/libuv/src/heap-inl.h +0 -0
- package/node/third_party/libuv/src/idna.c +0 -0
- package/node/third_party/libuv/src/idna.h +0 -0
- package/node/third_party/libuv/src/inet.c +0 -0
- package/node/third_party/libuv/src/queue.h +0 -0
- package/node/third_party/libuv/src/random.c +0 -0
- package/node/third_party/libuv/src/strscpy.c +0 -0
- package/node/third_party/libuv/src/strscpy.h +0 -0
- package/node/third_party/libuv/src/strtok.c +0 -0
- package/node/third_party/libuv/src/strtok.h +0 -0
- package/node/third_party/libuv/src/thread-common.c +0 -0
- package/node/third_party/libuv/src/threadpool.c +0 -0
- package/node/third_party/libuv/src/timer.c +0 -0
- package/node/third_party/libuv/src/unix/async.c +0 -0
- package/node/third_party/libuv/src/unix/bsd-ifaddrs.c +0 -0
- package/node/third_party/libuv/src/unix/core.c +0 -0
- package/node/third_party/libuv/src/unix/darwin-proctitle.c +0 -0
- package/node/third_party/libuv/src/unix/darwin-stub.h +0 -0
- package/node/third_party/libuv/src/unix/darwin-syscalls.h +0 -0
- package/node/third_party/libuv/src/unix/darwin.c +0 -0
- package/node/third_party/libuv/src/unix/dl.c +0 -0
- package/node/third_party/libuv/src/unix/fs.c +0 -0
- package/node/third_party/libuv/src/unix/fsevents.c +0 -0
- package/node/third_party/libuv/src/unix/getaddrinfo.c +0 -0
- package/node/third_party/libuv/src/unix/getnameinfo.c +0 -0
- package/node/third_party/libuv/src/unix/internal.h +0 -0
- package/node/third_party/libuv/src/unix/kqueue.c +0 -0
- package/node/third_party/libuv/src/unix/linux.c +0 -0
- package/node/third_party/libuv/src/unix/loop-watcher.c +0 -0
- package/node/third_party/libuv/src/unix/loop.c +0 -0
- package/node/third_party/libuv/src/unix/pipe.c +0 -0
- package/node/third_party/libuv/src/unix/poll.c +0 -0
- package/node/third_party/libuv/src/unix/process.c +0 -0
- package/node/third_party/libuv/src/unix/procfs-exepath.c +0 -0
- package/node/third_party/libuv/src/unix/proctitle.c +0 -0
- package/node/third_party/libuv/src/unix/random-devurandom.c +0 -0
- package/node/third_party/libuv/src/unix/random-getentropy.c +0 -0
- package/node/third_party/libuv/src/unix/random-getrandom.c +0 -0
- package/node/third_party/libuv/src/unix/random-sysctl-linux.c +0 -0
- package/node/third_party/libuv/src/unix/signal.c +0 -0
- package/node/third_party/libuv/src/unix/stream.c +0 -0
- package/node/third_party/libuv/src/unix/tcp.c +0 -0
- package/node/third_party/libuv/src/unix/thread.c +0 -0
- package/node/third_party/libuv/src/unix/tty.c +0 -0
- package/node/third_party/libuv/src/unix/udp.c +0 -0
- package/node/third_party/libuv/src/uv-common.c +0 -0
- package/node/third_party/libuv/src/uv-common.h +0 -0
- package/node/third_party/libuv/src/uv-data-getter-setters.c +0 -0
- package/node/third_party/libuv/src/version.c +0 -0
- package/node/third_party/llhttp/LICENSE +0 -0
- package/node/third_party/llhttp/api.c +0 -0
- package/node/third_party/llhttp/http.c +0 -0
- package/node/third_party/llhttp/llhttp.c +0 -0
- package/node/third_party/llhttp/llhttp.h +0 -0
- package/node/third_party/nodejs/LICENSE +47 -0
- package/node/third_party/nodejs/README.md +5 -0
- package/node/third_party/parseargs/LICENSE +21 -0
- package/node/third_party/parseargs/README.md +5 -0
- package/node/third_party/punycode/LICENSE +20 -0
- package/node/third_party/punycode/README.md +5 -0
- package/node/third_party/zlib/LICENSE.chromium +27 -0
- package/package.json +1 -1
- package/prebuilt/darwin-arm64/boringssl-4a47438eaf7e73ba.a +0 -0
- package/prebuilt/darwin-arm64/brotli-7995bbdacc52e51c.a +0 -0
- package/prebuilt/darwin-arm64/uv-72ab666eae197cd8.a +0 -0
- package/prebuilt/darwin-arm64/zlib-4ce2317a4c3f5fb5.a +0 -0
- package/prebuilt/darwin-arm64/zstd-015315ac7c784c73.a +0 -0
- package/prebuilt/darwin-x64/boringssl-4a47438eaf7e73ba.a +0 -0
- package/prebuilt/darwin-x64/brotli-7995bbdacc52e51c.a +0 -0
- package/prebuilt/darwin-x64/uv-72ab666eae197cd8.a +0 -0
- package/prebuilt/darwin-x64/zlib-4ce2317a4c3f5fb5.a +0 -0
- package/prebuilt/darwin-x64/zstd-015315ac7c784c73.a +0 -0
- package/prebuilt/linux-arm64/boringssl-4a47438eaf7e73ba.a +0 -0
- package/prebuilt/linux-arm64/brotli-65481ff838ce9def.a +0 -0
- package/prebuilt/linux-arm64/uv-f1353f50ff983f3c.a +0 -0
- package/prebuilt/linux-arm64/zlib-4ce2317a4c3f5fb5.a +0 -0
- package/prebuilt/linux-arm64/zstd-015315ac7c784c73.a +0 -0
- package/prebuilt/linux-arm64-musl/boringssl-4a47438eaf7e73ba.a +0 -0
- package/prebuilt/linux-arm64-musl/brotli-65481ff838ce9def.a +0 -0
- package/prebuilt/linux-arm64-musl/uv-f1353f50ff983f3c.a +0 -0
- package/prebuilt/linux-arm64-musl/zlib-4ce2317a4c3f5fb5.a +0 -0
- package/prebuilt/linux-arm64-musl/zstd-015315ac7c784c73.a +0 -0
- package/prebuilt/linux-x64/boringssl-4a47438eaf7e73ba.a +0 -0
- package/prebuilt/linux-x64/brotli-65481ff838ce9def.a +0 -0
- package/prebuilt/linux-x64/uv-f1353f50ff983f3c.a +0 -0
- package/prebuilt/linux-x64/zlib-4ce2317a4c3f5fb5.a +0 -0
- package/prebuilt/linux-x64/zstd-015315ac7c784c73.a +0 -0
- package/prebuilt/linux-x64-musl/boringssl-4a47438eaf7e73ba.a +0 -0
- package/prebuilt/linux-x64-musl/brotli-65481ff838ce9def.a +0 -0
- package/prebuilt/linux-x64-musl/uv-f1353f50ff983f3c.a +0 -0
- package/prebuilt/linux-x64-musl/zlib-4ce2317a4c3f5fb5.a +0 -0
- package/prebuilt/linux-x64-musl/zstd-015315ac7c784c73.a +0 -0
- package/prebuilt/win32-x64/boringssl-ce573858472b7fc9.a +0 -0
- package/prebuilt/win32-x64/brotli-20d86a61f30baeb3.a +0 -0
- package/prebuilt/win32-x64/uv-b11bae65d7fced82.a +0 -0
- package/prebuilt/win32-x64/zlib-4ce2317a4c3f5fb5.a +0 -0
- package/prebuilt/win32-x64/zstd-015315ac7c784c73.a +0 -0
- package/runtime/include/js_atoms.gen.h +0 -0
- package/runtime/include/js_atoms.h +5 -1
- package/runtime/include/js_bigint.h +1 -1
- package/runtime/include/js_buffer.h +4 -4
- package/runtime/include/js_builtins.h +41 -3
- package/runtime/include/js_console.h +9 -4
- package/runtime/include/js_convert.h +1 -1
- package/runtime/include/js_core.def +5 -4
- package/runtime/include/js_crypto.h +1 -1
- package/runtime/include/js_error.h +1 -1
- package/runtime/include/js_exception.h +21 -1
- package/runtime/include/js_function.h +33 -9
- package/runtime/include/js_gc.h +172 -30
- package/runtime/include/js_generator.h +2 -2
- package/runtime/include/js_host.h +19 -1
- package/runtime/include/js_jobs.h +5 -5
- package/runtime/include/js_module.h +1 -1
- package/runtime/include/js_object.h +142 -15
- package/runtime/include/js_ops.h +107 -5
- package/runtime/include/js_promise.h +3 -3
- package/runtime/include/js_regexp.h +1 -1
- package/runtime/include/js_runtime.h +0 -0
- package/runtime/include/js_symbol.h +1 -1
- package/runtime/include/js_web.h +5 -1
- package/runtime/include/jscell.h +22 -15
- package/runtime/include/jscontext.h +82 -39
- package/runtime/include/jsnum.h +1 -1
- package/runtime/include/jsstring.h +19 -6
- package/runtime/include/jsvalue.h +7 -3
- package/runtime/src/arguments.c +2 -2
- package/runtime/src/array.c +4 -1
- package/runtime/src/arraybuffer.c +19 -7
- package/runtime/src/async_iter.c +4 -3
- package/runtime/src/atoms.c +38 -4
- package/runtime/src/base64.c +2 -2
- package/runtime/src/bigint.c +1 -1
- package/runtime/src/blob.c +22 -9
- package/runtime/src/boringssl_support.cc +1 -1
- package/runtime/src/buffer.c +299 -91
- package/runtime/src/builtin_table.c +1 -1
- package/runtime/src/builtins.c +30 -4
- package/runtime/src/builtins_util.h +0 -0
- package/runtime/src/collections.c +18 -3
- package/runtime/src/components.c +1 -1
- package/runtime/src/console.c +14 -7
- package/runtime/src/convert.c +0 -0
- package/runtime/src/core_all.c +1 -1
- package/runtime/src/crypto.c +1 -1
- package/runtime/src/crypto_asym.c +1 -1
- package/runtime/src/crypto_bn.c +1 -1
- package/runtime/src/crypto_cipher.c +10 -3
- package/runtime/src/crypto_hash.c +1 -1
- package/runtime/src/crypto_host.c +1 -1
- package/runtime/src/crypto_internal.h +1 -1
- package/runtime/src/crypto_kdf.c +1 -1
- package/runtime/src/crypto_key.c +14 -1
- package/runtime/src/crypto_pkey.c +1 -1
- package/runtime/src/crypto_subtle.c +142 -58
- package/runtime/src/crypto_tls.c +1 -1
- package/runtime/src/date.c +5 -2
- package/runtime/src/domexception.c +2 -2
- package/runtime/src/elements.c +56 -17
- package/runtime/src/elements.h +7 -2
- package/runtime/src/encoding.c +1 -1
- package/runtime/src/error.c +4 -4
- package/runtime/src/events.c +42 -14
- package/runtime/src/exception.c +1 -1
- package/runtime/src/fetch.c +241 -17
- package/runtime/src/function.c +31 -19
- package/runtime/src/gc.c +1720 -211
- package/runtime/src/gc_visit.h +87 -0
- package/runtime/src/generator.c +5 -3
- package/runtime/src/global.c +14 -6
- package/runtime/src/headers.c +10 -10
- package/runtime/src/inspect.c +76 -17
- package/runtime/src/internal.h +9 -6
- package/runtime/src/iterate.c +94 -2
- package/runtime/src/iterator.c +1 -1
- package/runtime/src/jobs.c +11 -5
- package/runtime/src/jsnum.c +2 -2
- package/runtime/src/json.c +1 -1
- package/runtime/src/math.c +9 -1
- package/runtime/src/module.c +3 -3
- package/runtime/src/number.c +0 -0
- package/runtime/src/object.c +107 -74
- package/runtime/src/ops.c +21 -3
- package/runtime/src/os.c +192 -1
- package/runtime/src/os.h +33 -2
- package/runtime/src/process.c +73 -8
- package/runtime/src/promise.c +4 -4
- package/runtime/src/proxy.c +1 -1
- package/runtime/src/reflect.c +1 -1
- package/runtime/src/regexp.c +700 -11
- package/runtime/src/regexp_anchor.h +1 -1
- package/runtime/src/regexp_message.h +1 -1
- package/runtime/src/shape.c +78 -20
- package/runtime/src/shape.h +0 -0
- package/runtime/src/streams.c +22 -8
- package/runtime/src/streams.h +0 -0
- package/runtime/src/string.c +64 -25
- package/runtime/src/string_builtins.c +7 -7
- package/runtime/src/symbol.c +2 -7
- package/runtime/src/test_host.c +3 -3
- package/runtime/src/tls_roots.gen.h +102 -620
- package/runtime/src/typedarray.c +8 -3
- package/runtime/src/tznames.gen.h +2 -1
- package/runtime/src/uri.c +1 -1
- package/runtime/src/url.c +42 -39
- package/runtime/src/weak.c +110 -36
- package/runtime/src/web.c +21 -3
- package/runtime/src/wrapper.c +0 -0
- package/runtime/src/writable.c +7 -6
- package/runtime/third_party/ada-idna/LICENSE-MIT +0 -0
- package/runtime/third_party/ada-idna/README.md +7 -7
- package/runtime/third_party/ada-idna/convert.mjs +89 -27
- package/runtime/third_party/ada-idna/idna.c +30 -31
- package/runtime/third_party/ada-idna/idna.h +0 -0
- package/runtime/third_party/ada-idna/idna_tables.h +2272 -1952
- package/runtime/third_party/boringssl/third_party/fiat/LICENSE +15 -0
- package/runtime/third_party/mozilla-ca/LICENSE +373 -0
- package/runtime/third_party/mozilla-ca/README.md +9 -0
- package/runtime/third_party/nodejs/LICENSE +47 -0
- package/runtime/third_party/nodejs/README.md +7 -0
- package/runtime/third_party/quickjs-dtoa/LICENSE +0 -0
- package/runtime/third_party/quickjs-dtoa/README.md +1 -1
- package/runtime/third_party/quickjs-dtoa/dtoa.c +0 -0
- package/runtime/third_party/quickjs-dtoa/dtoa.h +0 -0
- package/runtime/third_party/quickjs-dtoa/dtoa_compat.h +0 -0
- package/runtime/third_party/quickjs-regexp/LICENSE +0 -0
- package/runtime/third_party/quickjs-regexp/README.md +2 -2
- package/runtime/third_party/quickjs-regexp/cutils.c +0 -0
- package/runtime/third_party/quickjs-regexp/cutils.h +0 -0
- package/runtime/third_party/quickjs-regexp/libregexp-opcode.h +0 -0
- package/runtime/third_party/quickjs-regexp/libregexp.c +0 -0
- package/runtime/third_party/quickjs-regexp/libregexp.h +0 -0
- package/runtime/third_party/quickjs-regexp/libunicode-table.h +0 -0
- package/runtime/third_party/quickjs-regexp/libunicode.c +0 -0
- package/runtime/third_party/quickjs-regexp/libunicode.h +0 -0
- package/runtime/third_party/unicode/LICENSE +39 -0
- package/runtime/third_party/unicode/README.md +9 -0
- package/runtime/third_party/v8-ieee754/LICENSE +0 -0
- package/runtime/third_party/v8-ieee754/LICENSE.fdlibm +10 -0
- package/runtime/third_party/v8-ieee754/README.md +3 -2
- package/runtime/third_party/v8-ieee754/convert.py +0 -0
- package/runtime/third_party/v8-ieee754/ieee754.c +0 -0
- package/runtime/third_party/v8-ieee754/ieee754.h +0 -0
- package/runtime/tools/regexp_compile.c +2 -2
package/runtime/src/json.c
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* JSON (§25.5): an optional component
|
|
1
|
+
/* JSON (§25.5): an optional component, and the serializer util.format's %j uses.
|
|
2
2
|
*
|
|
3
3
|
* JSON.parse follows V8's parser closely enough to give its error messages: the same checks in
|
|
4
4
|
* the same order, at the same positions ("Unexpected token '}', "[1,}" is not valid JSON",
|
package/runtime/src/math.c
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* Math (§21.3), an optional component
|
|
1
|
+
/* Math (§21.3), an optional component. The transcendental functions are V8's
|
|
2
2
|
* fdlibm port, so results match Node's to the last bit; the rest are exact. */
|
|
3
3
|
#include "js_builtins.h"
|
|
4
4
|
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
#include "ieee754.h"
|
|
11
11
|
#include "internal.h"
|
|
12
|
+
#include "js_buffer.h"
|
|
12
13
|
#include "js_convert.h"
|
|
13
14
|
#include "js_exception.h"
|
|
14
15
|
#include "js_ops.h"
|
|
@@ -58,6 +59,10 @@ MATH1(math_exp, js_ieee754_exp)
|
|
|
58
59
|
MATH1(math_expm1, js_ieee754_expm1)
|
|
59
60
|
MATH1(math_floor, floor)
|
|
60
61
|
MATH1(math_fround, js_fround)
|
|
62
|
+
|
|
63
|
+
/* Math.f16round: the nearest half-precision float, as Float16Array stores it */
|
|
64
|
+
static double js_f16round(double x) { return js_from_float16(js_to_float16(x)); }
|
|
65
|
+
MATH1(math_f16round, js_f16round)
|
|
61
66
|
MATH1(math_log, js_ieee754_log)
|
|
62
67
|
MATH1(math_log1p, js_ieee754_log1p)
|
|
63
68
|
MATH1(math_log10, js_ieee754_log10)
|
|
@@ -232,9 +237,12 @@ static const JSBuiltin math_entries[] = {
|
|
|
232
237
|
JS_BUILTIN_NUMBER("PI", 3.141592653589793, 0),
|
|
233
238
|
JS_BUILTIN_NUMBER("SQRT1_2", 0.7071067811865476, 0),
|
|
234
239
|
JS_BUILTIN_NUMBER("SQRT2", 1.4142135623730951, 0),
|
|
240
|
+
JS_BUILTIN_FN("f16round", math_f16round, 1), /* after the constants, where V8 13.6 adds it */
|
|
235
241
|
JS_BUILTIN_SYMBOL_STRING(toStringTag, "Math", JS_PROP_CONFIGURABLE),
|
|
236
242
|
};
|
|
237
243
|
|
|
244
|
+
const JSNativeFn js_math_inline[JS_MATH_INLINE_COUNT] = { math_sqrt, math_abs, math_floor, math_ceil, math_trunc };
|
|
245
|
+
|
|
238
246
|
static void install_math(JSContext *ctx, JSObject *global) {
|
|
239
247
|
JSValue math = js_new_builtin_object(ctx, math_entries, JS_COUNTOF(math_entries));
|
|
240
248
|
js_define_data(ctx, global, js_atom_from_cstr(ctx, "Math"), math, JS_BUILTIN_METHOD_ATTRS);
|
package/runtime/src/module.c
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* Module-level host behavior
|
|
1
|
+
/* Module-level host behavior: import.meta, one object per original file, and
|
|
2
2
|
* import() of a specifier the bundler couldn't resolve at build time. Errors and URLs
|
|
3
3
|
* follow Node: ERR_MODULE_NOT_FOUND, file: URLs percent-encoded like the WHATWG URL parser. */
|
|
4
4
|
#include "js_module.h"
|
|
@@ -288,7 +288,7 @@ JSValue js_dynamic_import(JSContext *ctx, JSValue specifier, JSValue options, co
|
|
|
288
288
|
JSValue with = js_get(ctx, js_as_object(options), js_atom_from_cstr(ctx, "with"), options);
|
|
289
289
|
if (js_is_exception(with)) return reject_pending(ctx, promise);
|
|
290
290
|
if (!js_is_undefined(with)) {
|
|
291
|
-
if (!js_is_object(with)) return reject_type_error(ctx, promise, "The '
|
|
291
|
+
if (!js_is_object(with)) return reject_type_error(ctx, promise, "The 'with' option must be an object"); /* V8 13.6's */
|
|
292
292
|
JSValue keys = js_own_keys(ctx, js_as_object(with));
|
|
293
293
|
if (js_is_exception(keys)) return reject_pending(ctx, promise);
|
|
294
294
|
JSValueArray *list = (JSValueArray *)js_as_cell(keys);
|
|
@@ -301,7 +301,7 @@ JSValue js_dynamic_import(JSContext *ctx, JSValue specifier, JSValue options, co
|
|
|
301
301
|
if (!has || !(desc.attrs & JS_PROP_ENUMERABLE)) continue;
|
|
302
302
|
JSValue v = js_get(ctx, js_as_object(with), key, with);
|
|
303
303
|
if (js_is_exception(v)) return reject_pending(ctx, promise);
|
|
304
|
-
if (!js_is_string(v)) return reject_type_error(ctx, promise, "Import
|
|
304
|
+
if (!js_is_string(v)) return reject_type_error(ctx, promise, "Import attribute value must be a string");
|
|
305
305
|
}
|
|
306
306
|
}
|
|
307
307
|
}
|
package/runtime/src/number.c
CHANGED
|
File without changes
|
package/runtime/src/object.c
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* Objects and the ordinary internal methods (
|
|
1
|
+
/* Objects and the ordinary internal methods (ECMAScript §10.1). */
|
|
2
2
|
#include <math.h>
|
|
3
3
|
#include <stdio.h>
|
|
4
4
|
#include <stdlib.h>
|
|
@@ -21,50 +21,24 @@ const JSElements js_empty_elements = {
|
|
|
21
21
|
{ JS_CELL_ELEMENTS, 0, JS_CELL_STATIC, 0 }, JS_ELEMENTS_DENSE, 0, 0, 0, 0, 0,
|
|
22
22
|
};
|
|
23
23
|
|
|
24
|
-
/* ---- GC classes
|
|
24
|
+
/* ---- GC classes (gc_visit.h visits them) ----------------------------------- */
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
js_trace_value(trc, p->get);
|
|
29
|
-
js_trace_value(trc, p->set);
|
|
30
|
-
}
|
|
31
|
-
const JSCellClass js_accessor_cell_class = { "AccessorPair", accessor_visit, NULL };
|
|
32
|
-
|
|
33
|
-
static void elements_visit(JSCell *c, JSTracer *trc) {
|
|
34
|
-
JSElements *e = (JSElements *)c;
|
|
35
|
-
if (e->kind == JS_ELEMENTS_SPARSE) {
|
|
36
|
-
JSSparseElements *s = (JSSparseElements *)e;
|
|
37
|
-
for (uint32_t k = 0; k < s->cap; k++)
|
|
38
|
-
if (s->entries[k].state == 1) js_trace_value(trc, s->entries[k].value);
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
for (uint32_t i = 0; i < e->length; i++) js_trace_value(trc, e->data[i]);
|
|
42
|
-
}
|
|
43
|
-
const JSCellClass js_elements_cell_class = { "Elements", elements_visit, js_elements_finalize };
|
|
44
|
-
|
|
45
|
-
static void object_visit(JSCell *c, JSTracer *trc) {
|
|
46
|
-
JSObject *o = (JSObject *)c;
|
|
47
|
-
js_trace_cell(trc, &o->shape->cell);
|
|
48
|
-
if (o->ool) js_trace_cell(trc, &o->ool->cell);
|
|
49
|
-
js_trace_cell(trc, &o->elements->cell);
|
|
50
|
-
JSValue *slots = js_object_slots(o);
|
|
51
|
-
for (uint16_t i = 0; i < o->shape->inline_cap; i++) js_trace_value(trc, slots[i]);
|
|
52
|
-
if (o->shape->cls->visit) o->shape->cls->visit(c, trc);
|
|
53
|
-
}
|
|
26
|
+
const JSCellClass js_accessor_cell_class = { "AccessorPair", NULL, NULL, NULL };
|
|
27
|
+
const JSCellClass js_elements_cell_class = { "Elements", NULL, js_elements_finalize, NULL };
|
|
54
28
|
|
|
55
29
|
static void object_finalize(JSRuntime *rt, JSCell *c) {
|
|
56
30
|
JSObject *o = (JSObject *)c;
|
|
57
31
|
if (o->shape->cls->finalize) o->shape->cls->finalize(rt, c);
|
|
58
32
|
}
|
|
59
|
-
const JSCellClass js_object_cell_class = { "Object",
|
|
33
|
+
const JSCellClass js_object_cell_class = { "Object", NULL, object_finalize, NULL };
|
|
60
34
|
|
|
61
35
|
/* ---- Allocation ---------------------------------------------------------------- */
|
|
62
36
|
|
|
63
37
|
JSObject *js_alloc_object(JSContext *ctx, JSCellKind kind, JSShape *shape) {
|
|
64
38
|
size_t size = shape->slot_offset + (size_t)shape->inline_cap * sizeof(JSValue);
|
|
65
39
|
JSObject *o = (JSObject *)js_alloc_cell(ctx, kind, size);
|
|
66
|
-
o->shape = shape;
|
|
67
|
-
o->elements = (JSElements *)&js_empty_elements;
|
|
40
|
+
o->shape = shape; /* barrier: fresh cell */
|
|
41
|
+
o->elements = (JSElements *)&js_empty_elements; /* barrier: fresh cell */
|
|
68
42
|
JSValue *slots = js_object_slots(o);
|
|
69
43
|
for (uint16_t i = 0; i < shape->inline_cap; i++) slots[i] = JS_UNDEFINED;
|
|
70
44
|
if (shape->cls->finalize) {
|
|
@@ -167,11 +141,11 @@ static void ensure_slot(JSContext *ctx, JSObject *o, uint32_t n) {
|
|
|
167
141
|
uint32_t need = n - cap + 1;
|
|
168
142
|
uint32_t have = o->ool ? o->ool->cell.aux : 0;
|
|
169
143
|
if (need <= have) return;
|
|
170
|
-
uint32_t grown = have < 4 ? 4 : have + have / 2; /* ×1.5
|
|
144
|
+
uint32_t grown = have < 4 ? 4 : have + have / 2; /* ×1.5 */
|
|
171
145
|
if (grown < need) grown = need;
|
|
172
146
|
JSValueArray *a = js_alloc_value_array(ctx, grown);
|
|
173
|
-
for (uint32_t i = 0; i < grown; i++) a->values[i] = i < have ? o->ool->values[i] : JS_UNDEFINED;
|
|
174
|
-
o->ool
|
|
147
|
+
for (uint32_t i = 0; i < grown; i++) a->values[i] = i < have ? o->ool->values[i] : JS_UNDEFINED; /* barrier: fresh cell */
|
|
148
|
+
js_store_ptr(ctx, &o->cell, &o->ool, a);
|
|
175
149
|
}
|
|
176
150
|
|
|
177
151
|
/* Gives `o` a private dictionary shape holding its current properties. */
|
|
@@ -180,13 +154,13 @@ static void to_dictionary(JSContext *ctx, JSObject *o) {
|
|
|
180
154
|
JSShape *old = o->shape;
|
|
181
155
|
JSShape *d = js_alloc_shape(ctx);
|
|
182
156
|
d->cls = old->cls;
|
|
183
|
-
d->proto = old->proto;
|
|
157
|
+
d->proto = old->proto; /* barrier: fresh cell */
|
|
184
158
|
d->flags = (uint8_t)(old->flags | JS_SHAPE_DICTIONARY);
|
|
185
159
|
d->inline_cap = old->inline_cap;
|
|
186
160
|
d->slot_offset = old->slot_offset;
|
|
187
161
|
d->prop_count = old->prop_count;
|
|
188
162
|
d->table = js_prop_table_clone(js_shape_entries(old));
|
|
189
|
-
o
|
|
163
|
+
js_object_set_shape(ctx, o, d);
|
|
190
164
|
}
|
|
191
165
|
|
|
192
166
|
static void add_own(JSContext *ctx, JSObject *o, JSValue key, JSValue value, uint8_t attrs) {
|
|
@@ -198,7 +172,7 @@ static void add_own(JSContext *ctx, JSObject *o, JSValue key, JSValue value, uin
|
|
|
198
172
|
if (!crowded && !too_many_transitions) {
|
|
199
173
|
JSShape *child = js_shape_add(ctx, s, key, attrs);
|
|
200
174
|
ensure_slot(ctx, o, s->prop_count);
|
|
201
|
-
o
|
|
175
|
+
js_object_set_shape(ctx, o, child);
|
|
202
176
|
js_store(ctx, &o->cell, js_object_slot(o, child->prop_count - 1), value);
|
|
203
177
|
return;
|
|
204
178
|
}
|
|
@@ -208,7 +182,7 @@ static void add_own(JSContext *ctx, JSObject *o, JSValue key, JSValue value, uin
|
|
|
208
182
|
for (uint32_t i = 0; i < t->count; i++)
|
|
209
183
|
if (js_same_bits(t->items[i].key, key) && t->items[i].attrs == attrs) {
|
|
210
184
|
ensure_slot(ctx, o, s->prop_count);
|
|
211
|
-
o
|
|
185
|
+
js_object_set_shape(ctx, o, t->items[i].child);
|
|
212
186
|
js_store(ctx, &o->cell, js_object_slot(o, o->shape->prop_count - 1), value);
|
|
213
187
|
return;
|
|
214
188
|
}
|
|
@@ -218,6 +192,7 @@ static void add_own(JSContext *ctx, JSObject *o, JSValue key, JSValue value, uin
|
|
|
218
192
|
uint32_t slot = o->shape->prop_count;
|
|
219
193
|
ensure_slot(ctx, o, slot);
|
|
220
194
|
js_prop_table_add(o->shape->table, key, slot, attrs);
|
|
195
|
+
js_write_barrier(ctx, &o->shape->cell, NULL, key); /* a dictionary's keys are traced from its shape */
|
|
221
196
|
o->shape->prop_count++;
|
|
222
197
|
js_store(ctx, &o->cell, js_object_slot(o, slot), value);
|
|
223
198
|
}
|
|
@@ -227,7 +202,7 @@ static void remove_own(JSContext *ctx, JSObject *o, JSValue key, int32_t slot) {
|
|
|
227
202
|
if (!is_dictionary(o) && s->parent && js_same_bits(s->key, key)) {
|
|
228
203
|
/* the last-added property: back to the parent shape */
|
|
229
204
|
*js_object_slot(o, (uint32_t)slot) = JS_UNDEFINED;
|
|
230
|
-
o
|
|
205
|
+
js_object_set_shape(ctx, o, s->parent);
|
|
231
206
|
return;
|
|
232
207
|
}
|
|
233
208
|
to_dictionary(ctx, o);
|
|
@@ -395,10 +370,18 @@ int js_define_own_property(JSContext *ctx, JSObject *o, JSValue key, const JSPro
|
|
|
395
370
|
return js_ordinary_define_own_property(ctx, o, key, desc, throw_on_fail);
|
|
396
371
|
}
|
|
397
372
|
|
|
373
|
+
static bool define_cached(JSContext *ctx, JSObject *o, JSValue key, JSValue value);
|
|
374
|
+
static void remember_define(JSContext *ctx, JSShape *before, JSObject *o, JSValue key);
|
|
375
|
+
|
|
398
376
|
void js_define_data(JSContext *ctx, JSObject *o, JSValue key, JSValue value, uint8_t attrs) {
|
|
377
|
+
/* an object literal's properties: a new key's transition, seen before, is taken directly */
|
|
378
|
+
bool plain = attrs == JS_PROP_DEFAULT && !js_key_is_index(key);
|
|
379
|
+
if (plain && define_cached(ctx, o, key, value)) return;
|
|
380
|
+
JSShape *before = o->shape;
|
|
399
381
|
JSPropertyDescriptor d = js_data_descriptor(value, attrs);
|
|
400
382
|
int r = js_define_own_property(ctx, o, key, &d, false);
|
|
401
383
|
(void)r;
|
|
384
|
+
if (plain) remember_define(ctx, before, o, key);
|
|
402
385
|
}
|
|
403
386
|
|
|
404
387
|
JSValue js_get_prototype_of(JSObject *o) {
|
|
@@ -449,7 +432,7 @@ static void reroot(JSContext *ctx, JSObject *o, JSValue proto) {
|
|
|
449
432
|
JSShape *r = js_shape_root(ctx, s->cls, proto, s->inline_cap);
|
|
450
433
|
for (uint32_t i = 0; i < n; i++) r = js_shape_add(ctx, r, steps[i]->key, steps[i]->attrs);
|
|
451
434
|
if (steps != small) free(steps);
|
|
452
|
-
o
|
|
435
|
+
js_object_set_shape(ctx, o, r);
|
|
453
436
|
}
|
|
454
437
|
|
|
455
438
|
int js_set_prototype_of(JSContext *ctx, JSObject *o, JSValue proto) {
|
|
@@ -463,7 +446,7 @@ int js_set_prototype_of(JSContext *ctx, JSObject *o, JSValue proto) {
|
|
|
463
446
|
return 1;
|
|
464
447
|
}
|
|
465
448
|
to_dictionary(ctx, o);
|
|
466
|
-
o->shape->proto
|
|
449
|
+
js_store(ctx, &o->shape->cell, &o->shape->proto, proto);
|
|
467
450
|
return 1;
|
|
468
451
|
}
|
|
469
452
|
|
|
@@ -621,12 +604,12 @@ JSValue js_ordinary_own_keys(JSContext *ctx, JSObject *o) {
|
|
|
621
604
|
JSValueArray *keys = js_alloc_value_array(ctx, n_idx + n_extra + n_named);
|
|
622
605
|
JSPropTable *t = js_shape_entries(o->shape);
|
|
623
606
|
uint32_t k = 0;
|
|
624
|
-
for (uint32_t i = 0; i < n_idx; i++) keys->values[k++] = indices->values[i];
|
|
625
|
-
for (uint32_t i = 0; i < n_extra; i++) keys->values[k++] = extra[i];
|
|
607
|
+
for (uint32_t i = 0; i < n_idx; i++) keys->values[k++] = indices->values[i]; /* barrier: fresh cell */
|
|
608
|
+
for (uint32_t i = 0; i < n_extra; i++) keys->values[k++] = extra[i]; /* barrier: fresh cell */
|
|
626
609
|
for (int symbols = 0; symbols < 2; symbols++)
|
|
627
610
|
for (uint32_t i = 0; i < n_named; i++) {
|
|
628
611
|
JSValue key = t->entries[i].key;
|
|
629
|
-
if (js_is_symbol(key) == (symbols == 1) && !js_is_private_name(key)) keys->values[k++] = key;
|
|
612
|
+
if (js_is_symbol(key) == (symbols == 1) && !js_is_private_name(key)) keys->values[k++] = key; /* barrier: fresh cell */
|
|
630
613
|
}
|
|
631
614
|
keys->cell.aux = k; /* private names don't count */
|
|
632
615
|
return js_cell(&keys->cell);
|
|
@@ -634,9 +617,9 @@ JSValue js_ordinary_own_keys(JSContext *ctx, JSObject *o) {
|
|
|
634
617
|
|
|
635
618
|
/* ---- Arrays (§10.4.2) ------------------------------------------------------------ */
|
|
636
619
|
|
|
637
|
-
#define ARRAY_LENGTH_FROZEN
|
|
620
|
+
#define ARRAY_LENGTH_FROZEN 0x01u /* cell flags (kind-specific): `length` is non-writable */
|
|
638
621
|
|
|
639
|
-
static bool length_writable(JSObject *a) { return !(a->cell.
|
|
622
|
+
static bool length_writable(JSObject *a) { return !(a->cell.flags & ARRAY_LENGTH_FROZEN); }
|
|
640
623
|
|
|
641
624
|
static bool is_length(JSValue key) { return js_same_bits(key, JS_ATOM(length)); }
|
|
642
625
|
|
|
@@ -683,7 +666,7 @@ static int array_set_length(JSContext *ctx, JSObject *a, const JSPropertyDescrip
|
|
|
683
666
|
}
|
|
684
667
|
}
|
|
685
668
|
a->cell.aux = new_len;
|
|
686
|
-
if (make_frozen) a->cell.
|
|
669
|
+
if (make_frozen) a->cell.flags |= ARRAY_LENGTH_FROZEN;
|
|
687
670
|
return result;
|
|
688
671
|
}
|
|
689
672
|
|
|
@@ -721,7 +704,7 @@ static JSValue array_with_proto(JSContext *ctx, JSValue proto, uint32_t capacity
|
|
|
721
704
|
JSElements *e = (JSElements *)js_alloc_cell(ctx, JS_CELL_ELEMENTS, sizeof(JSElements) + (size_t)capacity * sizeof(JSValue));
|
|
722
705
|
e->kind = JS_ELEMENTS_DENSE;
|
|
723
706
|
e->capacity = capacity;
|
|
724
|
-
a->elements
|
|
707
|
+
js_store_ptr(ctx, &a->cell, &a->elements, e);
|
|
725
708
|
}
|
|
726
709
|
return js_object_value(a);
|
|
727
710
|
}
|
|
@@ -746,6 +729,13 @@ int js_array_push(JSContext *ctx, JSObject *a, JSValue v) {
|
|
|
746
729
|
js_discard(js_throw_type_error(ctx, "Pushing 1 elements on an array-like of length 4294967295 is disallowed"));
|
|
747
730
|
return -1;
|
|
748
731
|
}
|
|
732
|
+
/* the usual case, a dense array without holes at its end: what the define below would do */
|
|
733
|
+
JSElements *e = a->elements;
|
|
734
|
+
if (a->cell.kind == JS_CELL_ARRAY && e->kind == JS_ELEMENTS_DENSE && e->length == len && length_writable(a) && js_is_extensible(a)) {
|
|
735
|
+
js_elements_append_dense(ctx, a, v);
|
|
736
|
+
a->cell.aux = len + 1;
|
|
737
|
+
return 1;
|
|
738
|
+
}
|
|
749
739
|
JSPropertyDescriptor d = js_data_descriptor(v, JS_PROP_DEFAULT);
|
|
750
740
|
return js_define_own_property(ctx, a, js_index_key(len), &d, true);
|
|
751
741
|
}
|
|
@@ -842,7 +832,7 @@ int js_set_value(JSContext *ctx, JSValue obj, JSValue key, JSValue v, bool stric
|
|
|
842
832
|
return js_set(ctx, js_primitive_prototype(ctx, obj), key, v, obj, strict);
|
|
843
833
|
}
|
|
844
834
|
|
|
845
|
-
/* ---- Inline caches
|
|
835
|
+
/* ---- Inline caches ------------------------------------------------------------------ */
|
|
846
836
|
|
|
847
837
|
void js_register_prop_caches(JSRuntime *rt, JSPropCache *ics, size_t n) {
|
|
848
838
|
JSPropCacheTables *t = &rt->prop_caches;
|
|
@@ -878,6 +868,7 @@ void js_prop_caches_sweep(JSRuntime *rt) {
|
|
|
878
868
|
/* the shared caches hold shapes and holders unmarked: emptied, not swept */
|
|
879
869
|
if (rt->mega_get) memset(rt->mega_get, 0, MEGA_SIZE * sizeof *rt->mega_get);
|
|
880
870
|
if (rt->mega_set) memset(rt->mega_set, 0, MEGA_SIZE * sizeof *rt->mega_set);
|
|
871
|
+
if (rt->mega_define) memset(rt->mega_define, 0, MEGA_SIZE * sizeof *rt->mega_define);
|
|
881
872
|
for (size_t t = 0; t < rt->prop_caches.count; t++) {
|
|
882
873
|
struct JSPropCacheTable *table = &rt->prop_caches.tables[t];
|
|
883
874
|
for (size_t i = 0; i < table->n; i++) {
|
|
@@ -895,20 +886,53 @@ void js_prop_caches_sweep(JSRuntime *rt) {
|
|
|
895
886
|
void js_prop_caches_free(JSRuntime *rt) {
|
|
896
887
|
free(rt->mega_get);
|
|
897
888
|
free(rt->mega_set);
|
|
898
|
-
rt->
|
|
889
|
+
free(rt->mega_define);
|
|
890
|
+
rt->mega_get = rt->mega_set = rt->mega_define = NULL;
|
|
899
891
|
free(rt->prop_caches.tables);
|
|
900
892
|
memset(&rt->prop_caches, 0, sizeof rt->prop_caches);
|
|
901
893
|
}
|
|
902
894
|
|
|
903
|
-
/*
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
895
|
+
/* js_define_data of a new key with default attributes: a transition from o's shape remembered
|
|
896
|
+
* by remember_define. The shape fixes the class (no define hook), extensibility and that the key
|
|
897
|
+
* isn't there yet, so the define would add it the same way. */
|
|
898
|
+
static bool define_cached(JSContext *ctx, JSObject *o, JSValue key, JSValue value) {
|
|
899
|
+
JSMegaEntry *m = mega_entry(&ctx->rt->mega_define, o->shape, key);
|
|
900
|
+
if (m->c.shape != o->shape || !js_same_bits(m->key, key)) return false;
|
|
901
|
+
JSShape *next = m->c.next; /* on the stack: kept alive if ensure_slot collects */
|
|
902
|
+
ensure_slot(ctx, o, o->shape->prop_count);
|
|
903
|
+
js_object_set_shape(ctx, o, next);
|
|
904
|
+
js_store(ctx, &o->cell, js_object_slot(o, next->prop_count - 1), value);
|
|
905
|
+
return true;
|
|
906
|
+
}
|
|
907
|
+
|
|
908
|
+
static void remember_define(JSContext *ctx, JSShape *before, JSObject *o, JSValue key) {
|
|
909
|
+
if (before->cls->define_own_property || is_dictionary(o) || o->shape->parent != before || !js_same_bits(o->shape->key, key) ||
|
|
910
|
+
o->shape->attrs != JS_PROP_DEFAULT)
|
|
911
|
+
return;
|
|
912
|
+
JSMegaEntry *m = mega_entry(&ctx->rt->mega_define, before, key);
|
|
913
|
+
m->key = key;
|
|
914
|
+
m->c = (JSPropCache){ .kind = JS_IC_ADD, .shape = before, .next = o->shape };
|
|
915
|
+
}
|
|
916
|
+
|
|
917
|
+
/* A cache with its inline fast path set: `fast` for an OWN cache whose slot is inline. */
|
|
918
|
+
static JSPropCache with_fast_path(JSPropCache c) {
|
|
919
|
+
if (c.kind == JS_IC_OWN && c.slot < c.shape->inline_cap) {
|
|
920
|
+
uint32_t off = c.shape->slot_offset + c.slot * (uint32_t)sizeof(JSValue);
|
|
921
|
+
if (off <= UINT16_MAX) {
|
|
922
|
+
c.fast = c.shape;
|
|
923
|
+
c.fast_off = (uint16_t)off;
|
|
924
|
+
}
|
|
911
925
|
}
|
|
926
|
+
return c;
|
|
927
|
+
}
|
|
928
|
+
|
|
929
|
+
/* Whether the prototypes after ic->shape still have the shapes the cache saw. */
|
|
930
|
+
/* A cache's prototypes are as it saw them: at the epoch it remembers no prototype has changed
|
|
931
|
+
* shape since; else walk the chain, and remember the epoch it still holds at. */
|
|
932
|
+
static bool chain_holds(JSContext *ctx, JSPropCache *ic) {
|
|
933
|
+
if (ic->epoch == ctx->rt->proto_epoch) return true;
|
|
934
|
+
if (!js_prop_cache_chain_holds(ic)) return false;
|
|
935
|
+
ic->epoch = ctx->rt->proto_epoch;
|
|
912
936
|
return true;
|
|
913
937
|
}
|
|
914
938
|
|
|
@@ -955,22 +979,22 @@ static void lookup(JSContext *ctx, JSObject *o, JSValue key, Lookup *l) {
|
|
|
955
979
|
}
|
|
956
980
|
|
|
957
981
|
/* A cached get that still holds for o: true with the value (or JS_EXCEPTION from a getter). */
|
|
958
|
-
static bool cached_get(JSContext *ctx, JSObject *o, JSValue receiver,
|
|
982
|
+
static bool cached_get(JSContext *ctx, JSObject *o, JSValue receiver, JSPropCache *c, JSValue *out) {
|
|
959
983
|
if (c->shape != o->shape) return false;
|
|
960
984
|
switch (c->kind) {
|
|
961
985
|
case JS_IC_OWN: *out = *js_object_slot(o, c->slot); return true;
|
|
962
986
|
case JS_IC_PROTO:
|
|
963
|
-
if (!chain_holds(c)) return false;
|
|
987
|
+
if (!chain_holds(ctx, c)) return false;
|
|
964
988
|
*out = *js_object_slot(c->holder, c->slot);
|
|
965
989
|
return true;
|
|
966
990
|
case JS_IC_GETTER: {
|
|
967
|
-
if (!chain_holds(c)) return false;
|
|
991
|
+
if (!chain_holds(ctx, c)) return false;
|
|
968
992
|
JSAccessorPair *p = (JSAccessorPair *)js_as_cell(*js_object_slot(c->holder ? c->holder : o, c->slot));
|
|
969
993
|
*out = js_is_undefined(p->get) ? JS_UNDEFINED : call_accessor(ctx, p->get, receiver, 0, JS_UNDEFINED);
|
|
970
994
|
return true;
|
|
971
995
|
}
|
|
972
996
|
case JS_IC_ABSENT:
|
|
973
|
-
if (!chain_holds(c)) return false;
|
|
997
|
+
if (!chain_holds(ctx, c)) return false;
|
|
974
998
|
*out = JS_UNDEFINED;
|
|
975
999
|
return true;
|
|
976
1000
|
default: return false;
|
|
@@ -979,10 +1003,16 @@ static bool cached_get(JSContext *ctx, JSObject *o, JSValue receiver, const JSPr
|
|
|
979
1003
|
|
|
980
1004
|
JSValue js_get_prop_slow(JSContext *ctx, JSValue obj, JSValue key, JSPropCache *ic) {
|
|
981
1005
|
JS_ASSERT_NOT_EXC(obj);
|
|
982
|
-
if (!js_is_object(obj) || js_key_is_index(key)) return js_get_value(ctx, obj, key);
|
|
983
|
-
JSObject *o = js_as_object(obj);
|
|
984
1006
|
JSValue v;
|
|
985
|
-
|
|
1007
|
+
/* first: the site's cache, missed inline (a prototype's property, or an out-of-line slot's).
|
|
1008
|
+
* A site's key is one name: its cache never holds an index */
|
|
1009
|
+
if (ic && js_is_object(obj) && cached_get(ctx, js_as_object(obj), obj, ic, &v)) return v;
|
|
1010
|
+
if (js_key_is_index(key) || js_is_nullish(obj) || (js_is_string(obj) && is_length(key))) return js_get_value(ctx, obj, key);
|
|
1011
|
+
/* a primitive's named property (s.charCodeAt) is its prototype's: a string's own properties
|
|
1012
|
+
* are only its indices and length. The prototype is cached like an object, the primitive
|
|
1013
|
+
* still the receiver of a getter. */
|
|
1014
|
+
JSObject *o = js_is_object(obj) ? js_as_object(obj) : js_primitive_prototype(ctx, obj);
|
|
1015
|
+
if (ic && !js_is_object(obj) && cached_get(ctx, o, obj, ic, &v)) return v;
|
|
986
1016
|
if (o->cell.kind == JS_CELL_ARRAY && is_length(key)) return js_number((double)js_array_length(o));
|
|
987
1017
|
JSMegaEntry *m = mega_entry(&ctx->rt->mega_get, o->shape, key);
|
|
988
1018
|
if (js_same_bits(m->key, key) && cached_get(ctx, o, obj, &m->c, &v)) {
|
|
@@ -990,13 +1020,15 @@ JSValue js_get_prop_slow(JSContext *ctx, JSValue obj, JSValue key, JSPropCache *
|
|
|
990
1020
|
return v;
|
|
991
1021
|
}
|
|
992
1022
|
Lookup l;
|
|
1023
|
+
uint32_t epoch = ctx->rt->proto_epoch; /* the chain as the lookup sees it */
|
|
993
1024
|
lookup(ctx, o, key, &l);
|
|
994
1025
|
if (l.exotic) return js_get(ctx, o, key, obj);
|
|
995
1026
|
if (l.cacheable) {
|
|
996
1027
|
uint8_t kind = !l.holder ? JS_IC_ABSENT : (l.attrs & JS_PROP_ACCESSOR) ? JS_IC_GETTER : l.holder == o ? JS_IC_OWN : JS_IC_PROTO;
|
|
997
1028
|
JSObject *holder = kind == JS_IC_ABSENT || l.holder == o ? NULL : l.holder;
|
|
998
|
-
JSPropCache c = {
|
|
1029
|
+
JSPropCache c = { .kind = kind, .depth = l.depth, .slot = l.holder ? (uint32_t)l.slot : 0, .shape = o->shape, .holder = holder, .epoch = epoch };
|
|
999
1030
|
memcpy(c.chain, l.chain, sizeof c.chain);
|
|
1031
|
+
c = with_fast_path(c);
|
|
1000
1032
|
if (ic) *ic = c;
|
|
1001
1033
|
m->key = key;
|
|
1002
1034
|
m->c = c;
|
|
@@ -1014,10 +1046,10 @@ int js_set_prop_slow(JSContext *ctx, JSValue obj, JSValue key, JSValue v, bool s
|
|
|
1014
1046
|
JS_ASSERT_NOT_EXC(v);
|
|
1015
1047
|
if (!js_is_object(obj) || js_key_is_index(key)) return js_set_value(ctx, obj, key, v, strict);
|
|
1016
1048
|
JSObject *o = js_as_object(obj);
|
|
1017
|
-
if (ic->kind == JS_IC_ADD && o->shape == ic->shape && chain_holds(ic)) {
|
|
1049
|
+
if (ic->kind == JS_IC_ADD && o->shape == ic->shape && chain_holds(ctx, ic)) {
|
|
1018
1050
|
JSShape *next = ic->next; /* on the stack: kept alive if ensure_slot collects */
|
|
1019
1051
|
ensure_slot(ctx, o, o->shape->prop_count);
|
|
1020
|
-
o
|
|
1052
|
+
js_object_set_shape(ctx, o, next);
|
|
1021
1053
|
js_store(ctx, &o->cell, js_object_slot(o, next->prop_count - 1), v);
|
|
1022
1054
|
return 1;
|
|
1023
1055
|
}
|
|
@@ -1028,21 +1060,22 @@ int js_set_prop_slow(JSContext *ctx, JSValue obj, JSValue key, JSValue v, bool s
|
|
|
1028
1060
|
js_store(ctx, &o->cell, js_object_slot(o, m->c.slot), v);
|
|
1029
1061
|
return 1;
|
|
1030
1062
|
}
|
|
1031
|
-
if (m->c.kind == JS_IC_ADD && chain_holds(&m->c)) {
|
|
1063
|
+
if (m->c.kind == JS_IC_ADD && chain_holds(ctx, &m->c)) {
|
|
1032
1064
|
*ic = m->c;
|
|
1033
1065
|
JSShape *next = m->c.next;
|
|
1034
1066
|
ensure_slot(ctx, o, o->shape->prop_count);
|
|
1035
|
-
o
|
|
1067
|
+
js_object_set_shape(ctx, o, next);
|
|
1036
1068
|
js_store(ctx, &o->cell, js_object_slot(o, next->prop_count - 1), v);
|
|
1037
1069
|
return 1;
|
|
1038
1070
|
}
|
|
1039
1071
|
}
|
|
1040
1072
|
Lookup l;
|
|
1073
|
+
uint32_t epoch = ctx->rt->proto_epoch; /* the chain as the lookup sees it */
|
|
1041
1074
|
lookup(ctx, o, key, &l);
|
|
1042
1075
|
JSShape *before = o->shape;
|
|
1043
1076
|
bool cacheable = l.cacheable && !l.exotic;
|
|
1044
1077
|
if (cacheable && l.holder == o && (l.attrs & (JS_PROP_WRITABLE | JS_PROP_ACCESSOR)) == JS_PROP_WRITABLE) {
|
|
1045
|
-
JSPropCache c = {
|
|
1078
|
+
JSPropCache c = with_fast_path((JSPropCache){ .kind = JS_IC_OWN, .slot = (uint32_t)l.slot, .shape = before });
|
|
1046
1079
|
*ic = c;
|
|
1047
1080
|
m->key = key;
|
|
1048
1081
|
m->c = c;
|
|
@@ -1053,7 +1086,7 @@ int js_set_prop_slow(JSContext *ctx, JSValue obj, JSValue key, JSValue v, bool s
|
|
|
1053
1086
|
/* a plain add (no setter or read-only property on the chain): remember the transition */
|
|
1054
1087
|
if (r == 1 && cacheable && !l.holder && !before->cls->define_own_property && !is_dictionary(o) &&
|
|
1055
1088
|
o->shape->parent == before && js_same_bits(o->shape->key, key)) {
|
|
1056
|
-
JSPropCache c = {
|
|
1089
|
+
JSPropCache c = { .kind = JS_IC_ADD, .depth = l.depth, .shape = before, .next = o->shape, .epoch = epoch };
|
|
1057
1090
|
memcpy(c.chain, l.chain, sizeof c.chain);
|
|
1058
1091
|
*ic = c;
|
|
1059
1092
|
m = mega_entry(&ctx->rt->mega_set, before, key); /* js_set may have collected: the table was emptied, not moved */
|
package/runtime/src/ops.c
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
|
|
13
13
|
int32_t js_double_to_int32(double d) {
|
|
14
14
|
if (!isfinite(d)) return 0;
|
|
15
|
-
if (d
|
|
15
|
+
if (d > -9223372036854775808.0 && d < 9223372036854775808.0) return (int32_t)(uint32_t)(int64_t)d; /* truncates toward zero */
|
|
16
16
|
double m = fmod(trunc(d), 4294967296.0); /* exact: |d| < 2^1024, fmod is exact */
|
|
17
17
|
if (m < 0) m += 4294967296.0;
|
|
18
18
|
return (int32_t)(uint32_t)m;
|
|
@@ -39,7 +39,7 @@ static int numerics(JSContext *ctx, JSValue *a, JSValue *b) {
|
|
|
39
39
|
return js_is_bigint(*a) || js_is_bigint(*b);
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
/* A binary operator on ToNumeric'd operands of which one is a BigInt
|
|
42
|
+
/* A binary operator on ToNumeric'd operands of which one is a BigInt. */
|
|
43
43
|
static JSValue bigint_binary(JSContext *ctx, JSBigIntOp op, JSValue a, JSValue b) {
|
|
44
44
|
if (!js_is_bigint(a) || !js_is_bigint(b)) return js_throw_type_error(ctx, "Cannot mix BigInt and other types, use explicit conversions");
|
|
45
45
|
return ctx->rt->bigint->arith(ctx, op, a, b);
|
|
@@ -133,7 +133,7 @@ JSValue js_exp(JSContext *ctx, JSValue a, JSValue b) {
|
|
|
133
133
|
if (n < 0) return JS_EXCEPTION;
|
|
134
134
|
if (n) return bigint_binary(ctx, JS_BIGINT_EXP, a, b);
|
|
135
135
|
double x = js_as_number(a), y = js_as_number(b);
|
|
136
|
-
return js_number(js_ieee754_pow(x, y)); /* V8's: Node's results to the last bit
|
|
136
|
+
return js_number(js_ieee754_pow(x, y)); /* V8's: Node's results to the last bit */
|
|
137
137
|
}
|
|
138
138
|
|
|
139
139
|
/* ---- Bitwise ------------------------------------------------------------------ */
|
|
@@ -213,6 +213,24 @@ bool js_strict_equals(JSContext *ctx, JSValue a, JSValue b) {
|
|
|
213
213
|
return js_same_bits(a, b);
|
|
214
214
|
}
|
|
215
215
|
|
|
216
|
+
int32_t js_switch_string(JSContext *ctx, JSValue v, const JSString *const *cases, uint32_t n) {
|
|
217
|
+
if (!js_is_string(v)) return -1;
|
|
218
|
+
const JSCell *c = js_as_cell(v);
|
|
219
|
+
uint32_t length = js_string_length(v);
|
|
220
|
+
bool atom = js_is_atom(v);
|
|
221
|
+
for (uint32_t i = 0; i < n; i++) {
|
|
222
|
+
const JSString *s = cases[i];
|
|
223
|
+
if (s == NULL) {
|
|
224
|
+
if (length == 0) return (int32_t)i;
|
|
225
|
+
continue;
|
|
226
|
+
}
|
|
227
|
+
if (&s->cell == c) return (int32_t)i;
|
|
228
|
+
if (s->length != length || (atom && (s->cell.flags & JS_STR_ATOM))) continue; /* distinct atoms differ */
|
|
229
|
+
if (js_string_equals(ctx, v, js_cell((JSCell *)s))) return (int32_t)i;
|
|
230
|
+
}
|
|
231
|
+
return -1;
|
|
232
|
+
}
|
|
233
|
+
|
|
216
234
|
/* StringToBigInt of a string: the BigInt, or EMPTY when it isn't one. */
|
|
217
235
|
static JSValue string_to_bigint(JSContext *ctx, JSValue s) {
|
|
218
236
|
return ctx->rt->bigint->from_string(ctx, s);
|