visaljs 0.0.5 → 0.0.7
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/cli.js +469 -53
- package/node/include/js_node.h +36 -0
- package/node/prelude/async_hooks.js +63 -8
- package/node/prelude/buffer.js +0 -0
- package/node/prelude/diagnostics_channel.js +322 -0
- package/node/prelude/dns.js +3 -2
- package/node/prelude/events.js +17 -3
- package/node/prelude/fs.js +177 -5
- package/node/prelude/fs_promises.js +24 -0
- package/node/prelude/http.js +13 -4
- package/node/prelude/http2.js +0 -0
- package/node/prelude/internal/async_context.js +27 -0
- package/node/prelude/internal/crypto/asym.js +0 -0
- package/node/prelude/internal/crypto/cipher.js +0 -0
- package/node/prelude/internal/crypto/kdf.js +0 -0
- package/node/prelude/internal/crypto/keys.js +0 -0
- package/node/prelude/internal/crypto/random.js +0 -0
- package/node/prelude/internal/crypto/util.js +0 -0
- package/node/prelude/internal/errors.js +11 -0
- package/node/prelude/internal/process_events.js +14 -0
- package/node/prelude/internal/process_signals.js +42 -0
- package/node/prelude/internal/querystring.js +0 -0
- package/node/prelude/internal/timers.js +233 -0
- package/node/prelude/internal/timers_global.js +9 -0
- package/node/prelude/internal/zlib_brotli.js +6 -0
- package/node/prelude/internal/zlib_engines.js +4 -0
- package/node/prelude/internal/zlib_zstd.js +6 -0
- package/node/prelude/module.js +22 -6
- package/node/prelude/net.js +9 -8
- package/node/prelude/os.js +0 -0
- package/node/prelude/path.js +1599 -186
- package/node/prelude/path_posix.js +9 -0
- package/node/prelude/path_win32.js +9 -0
- package/node/prelude/process.js +3 -0
- package/node/prelude/querystring.js +0 -0
- package/node/prelude/stream.js +18 -6
- package/node/prelude/stream_promises.js +0 -0
- package/node/prelude/stream_web.js +0 -0
- package/node/prelude/string_decoder.js +0 -0
- package/node/prelude/timers.js +92 -0
- package/node/prelude/timers_promises.js +133 -0
- package/node/prelude/tty.js +0 -0
- package/node/prelude/url.js +0 -0
- package/node/prelude/util.js +0 -0
- package/node/prelude/zlib.js +912 -72
- package/node/src/host_brotli.c +157 -0
- package/node/src/host_fs.c +95 -1
- package/node/src/host_loop.c +10 -4
- package/node/src/host_os.c +0 -0
- package/node/src/host_signal.c +70 -0
- package/node/src/host_sys.c +50 -0
- package/node/src/host_zlib.c +314 -0
- package/node/src/host_zstd.c +179 -0
- package/node/third_party/brotli/LICENSE +19 -0
- package/node/third_party/brotli/common/constants.c +15 -0
- package/node/third_party/brotli/common/constants.h +201 -0
- package/node/third_party/brotli/common/context.c +156 -0
- package/node/third_party/brotli/common/context.h +113 -0
- package/node/third_party/brotli/common/dictionary.c +5916 -0
- package/node/third_party/brotli/common/dictionary.h +64 -0
- package/node/third_party/brotli/common/platform.c +23 -0
- package/node/third_party/brotli/common/platform.h +541 -0
- package/node/third_party/brotli/common/shared_dictionary.c +521 -0
- package/node/third_party/brotli/common/shared_dictionary_internal.h +75 -0
- package/node/third_party/brotli/common/transform.c +291 -0
- package/node/third_party/brotli/common/transform.h +85 -0
- package/node/third_party/brotli/common/version.h +51 -0
- package/node/third_party/brotli/dec/bit_reader.c +78 -0
- package/node/third_party/brotli/dec/bit_reader.h +423 -0
- package/node/third_party/brotli/dec/decode.c +2875 -0
- package/node/third_party/brotli/dec/huffman.c +342 -0
- package/node/third_party/brotli/dec/huffman.h +122 -0
- package/node/third_party/brotli/dec/prefix.h +733 -0
- package/node/third_party/brotli/dec/state.c +183 -0
- package/node/third_party/brotli/dec/state.h +400 -0
- package/node/third_party/brotli/enc/backward_references.c +207 -0
- package/node/third_party/brotli/enc/backward_references.h +40 -0
- package/node/third_party/brotli/enc/backward_references_hq.c +939 -0
- package/node/third_party/brotli/enc/backward_references_hq.h +96 -0
- package/node/third_party/brotli/enc/backward_references_inc.h +189 -0
- package/node/third_party/brotli/enc/bit_cost.c +36 -0
- package/node/third_party/brotli/enc/bit_cost.h +64 -0
- package/node/third_party/brotli/enc/bit_cost_inc.h +127 -0
- package/node/third_party/brotli/enc/block_encoder_inc.h +34 -0
- package/node/third_party/brotli/enc/block_splitter.c +217 -0
- package/node/third_party/brotli/enc/block_splitter.h +52 -0
- package/node/third_party/brotli/enc/block_splitter_inc.h +481 -0
- package/node/third_party/brotli/enc/brotli_bit_stream.c +1336 -0
- package/node/third_party/brotli/enc/brotli_bit_stream.h +89 -0
- package/node/third_party/brotli/enc/cluster.c +57 -0
- package/node/third_party/brotli/enc/cluster.h +49 -0
- package/node/third_party/brotli/enc/cluster_inc.h +325 -0
- package/node/third_party/brotli/enc/command.c +28 -0
- package/node/third_party/brotli/enc/command.h +191 -0
- package/node/third_party/brotli/enc/compound_dictionary.c +207 -0
- package/node/third_party/brotli/enc/compound_dictionary.h +74 -0
- package/node/third_party/brotli/enc/compress_fragment.c +800 -0
- package/node/third_party/brotli/enc/compress_fragment.h +86 -0
- package/node/third_party/brotli/enc/compress_fragment_two_pass.c +657 -0
- package/node/third_party/brotli/enc/compress_fragment_two_pass.h +72 -0
- package/node/third_party/brotli/enc/dictionary_hash.c +1848 -0
- package/node/third_party/brotli/enc/dictionary_hash.h +25 -0
- package/node/third_party/brotli/enc/encode.c +1996 -0
- package/node/third_party/brotli/enc/encoder_dict.c +640 -0
- package/node/third_party/brotli/enc/encoder_dict.h +157 -0
- package/node/third_party/brotli/enc/entropy_encode.c +504 -0
- package/node/third_party/brotli/enc/entropy_encode.h +123 -0
- package/node/third_party/brotli/enc/entropy_encode_static.h +542 -0
- package/node/third_party/brotli/enc/fast_log.c +105 -0
- package/node/third_party/brotli/enc/fast_log.h +67 -0
- package/node/third_party/brotli/enc/find_match_length.h +72 -0
- package/node/third_party/brotli/enc/hash.h +728 -0
- package/node/third_party/brotli/enc/hash_composite_inc.h +140 -0
- package/node/third_party/brotli/enc/hash_forgetful_chain_inc.h +295 -0
- package/node/third_party/brotli/enc/hash_longest_match64_inc.h +262 -0
- package/node/third_party/brotli/enc/hash_longest_match_inc.h +258 -0
- package/node/third_party/brotli/enc/hash_longest_match_quickly_inc.h +266 -0
- package/node/third_party/brotli/enc/hash_rolling_inc.h +212 -0
- package/node/third_party/brotli/enc/hash_to_binary_tree_inc.h +330 -0
- package/node/third_party/brotli/enc/histogram.c +100 -0
- package/node/third_party/brotli/enc/histogram.h +64 -0
- package/node/third_party/brotli/enc/histogram_inc.h +51 -0
- package/node/third_party/brotli/enc/literal_cost.c +180 -0
- package/node/third_party/brotli/enc/literal_cost.h +32 -0
- package/node/third_party/brotli/enc/memory.c +194 -0
- package/node/third_party/brotli/enc/memory.h +131 -0
- package/node/third_party/brotli/enc/metablock.c +677 -0
- package/node/third_party/brotli/enc/metablock.h +106 -0
- package/node/third_party/brotli/enc/metablock_inc.h +185 -0
- package/node/third_party/brotli/enc/params.h +47 -0
- package/node/third_party/brotli/enc/prefix.h +54 -0
- package/node/third_party/brotli/enc/quality.h +202 -0
- package/node/third_party/brotli/enc/ringbuffer.h +168 -0
- package/node/third_party/brotli/enc/state.h +104 -0
- package/node/third_party/brotli/enc/static_dict.c +542 -0
- package/node/third_party/brotli/enc/static_dict.h +41 -0
- package/node/third_party/brotli/enc/static_dict_lut.h +5866 -0
- package/node/third_party/brotli/enc/utf8_util.c +85 -0
- package/node/third_party/brotli/enc/utf8_util.h +33 -0
- package/node/third_party/brotli/enc/write_bits.h +88 -0
- package/node/third_party/brotli/include/brotli/decode.h +409 -0
- package/node/third_party/brotli/include/brotli/encode.h +501 -0
- package/node/third_party/brotli/include/brotli/port.h +305 -0
- package/node/third_party/brotli/include/brotli/shared_dictionary.h +100 -0
- package/node/third_party/brotli/include/brotli/types.h +83 -0
- package/node/third_party/libuv/LICENSE +0 -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/zlib/LICENSE +19 -0
- package/node/third_party/zlib/README.chromium +38 -0
- package/node/third_party/zlib/adler32.c +197 -0
- package/node/third_party/zlib/chromeconf.h +203 -0
- package/node/third_party/zlib/contrib/optimizations/insert_string.h +80 -0
- package/node/third_party/zlib/cpu_features.c +213 -0
- package/node/third_party/zlib/cpu_features.h +22 -0
- package/node/third_party/zlib/crc32.c +1192 -0
- package/node/third_party/zlib/crc32.h +9446 -0
- package/node/third_party/zlib/deflate.c +2289 -0
- package/node/third_party/zlib/deflate.h +407 -0
- package/node/third_party/zlib/gzguts.h +214 -0
- package/node/third_party/zlib/inffast.c +327 -0
- package/node/third_party/zlib/inffast.h +26 -0
- package/node/third_party/zlib/inffixed.h +94 -0
- package/node/third_party/zlib/inflate.c +1528 -0
- package/node/third_party/zlib/inflate.h +126 -0
- package/node/third_party/zlib/inftrees.c +299 -0
- package/node/third_party/zlib/inftrees.h +62 -0
- package/node/third_party/zlib/trees.c +1161 -0
- package/node/third_party/zlib/trees.h +128 -0
- package/node/third_party/zlib/zconf.h +558 -0
- package/node/third_party/zlib/zlib.h +1967 -0
- package/node/third_party/zlib/zutil.c +299 -0
- package/node/third_party/zlib/zutil.h +275 -0
- package/node/third_party/zstd/LICENSE +30 -0
- package/node/third_party/zstd/common/allocations.h +55 -0
- package/node/third_party/zstd/common/bits.h +205 -0
- package/node/third_party/zstd/common/bitstream.h +454 -0
- package/node/third_party/zstd/common/compiler.h +464 -0
- package/node/third_party/zstd/common/cpu.h +249 -0
- package/node/third_party/zstd/common/debug.c +30 -0
- package/node/third_party/zstd/common/debug.h +107 -0
- package/node/third_party/zstd/common/entropy_common.c +340 -0
- package/node/third_party/zstd/common/error_private.c +64 -0
- package/node/third_party/zstd/common/error_private.h +158 -0
- package/node/third_party/zstd/common/fse.h +625 -0
- package/node/third_party/zstd/common/fse_decompress.c +315 -0
- package/node/third_party/zstd/common/huf.h +277 -0
- package/node/third_party/zstd/common/mem.h +422 -0
- package/node/third_party/zstd/common/pool.c +371 -0
- package/node/third_party/zstd/common/pool.h +81 -0
- package/node/third_party/zstd/common/portability_macros.h +171 -0
- package/node/third_party/zstd/common/threading.c +182 -0
- package/node/third_party/zstd/common/threading.h +142 -0
- package/node/third_party/zstd/common/xxhash.c +18 -0
- package/node/third_party/zstd/common/xxhash.h +7094 -0
- package/node/third_party/zstd/common/zstd_common.c +48 -0
- package/node/third_party/zstd/common/zstd_deps.h +123 -0
- package/node/third_party/zstd/common/zstd_internal.h +324 -0
- package/node/third_party/zstd/common/zstd_trace.h +156 -0
- package/node/third_party/zstd/compress/clevels.h +134 -0
- package/node/third_party/zstd/compress/fse_compress.c +625 -0
- package/node/third_party/zstd/compress/hist.c +191 -0
- package/node/third_party/zstd/compress/hist.h +82 -0
- package/node/third_party/zstd/compress/huf_compress.c +1464 -0
- package/node/third_party/zstd/compress/zstd_compress.c +7843 -0
- package/node/third_party/zstd/compress/zstd_compress_internal.h +1636 -0
- package/node/third_party/zstd/compress/zstd_compress_literals.c +235 -0
- package/node/third_party/zstd/compress/zstd_compress_literals.h +39 -0
- package/node/third_party/zstd/compress/zstd_compress_sequences.c +442 -0
- package/node/third_party/zstd/compress/zstd_compress_sequences.h +55 -0
- package/node/third_party/zstd/compress/zstd_compress_superblock.c +688 -0
- package/node/third_party/zstd/compress/zstd_compress_superblock.h +32 -0
- package/node/third_party/zstd/compress/zstd_cwksp.h +765 -0
- package/node/third_party/zstd/compress/zstd_double_fast.c +778 -0
- package/node/third_party/zstd/compress/zstd_double_fast.h +42 -0
- package/node/third_party/zstd/compress/zstd_fast.c +985 -0
- package/node/third_party/zstd/compress/zstd_fast.h +30 -0
- package/node/third_party/zstd/compress/zstd_lazy.c +2199 -0
- package/node/third_party/zstd/compress/zstd_lazy.h +193 -0
- package/node/third_party/zstd/compress/zstd_ldm.c +745 -0
- package/node/third_party/zstd/compress/zstd_ldm.h +109 -0
- package/node/third_party/zstd/compress/zstd_ldm_geartab.h +106 -0
- package/node/third_party/zstd/compress/zstd_opt.c +1580 -0
- package/node/third_party/zstd/compress/zstd_opt.h +72 -0
- package/node/third_party/zstd/compress/zstd_preSplit.c +238 -0
- package/node/third_party/zstd/compress/zstd_preSplit.h +33 -0
- package/node/third_party/zstd/compress/zstdmt_compress.c +1923 -0
- package/node/third_party/zstd/compress/zstdmt_compress.h +102 -0
- package/node/third_party/zstd/decompress/huf_decompress.c +1944 -0
- package/node/third_party/zstd/decompress/zstd_ddict.c +244 -0
- package/node/third_party/zstd/decompress/zstd_ddict.h +44 -0
- package/node/third_party/zstd/decompress/zstd_decompress.c +2410 -0
- package/node/third_party/zstd/decompress/zstd_decompress_block.c +2209 -0
- package/node/third_party/zstd/decompress/zstd_decompress_block.h +73 -0
- package/node/third_party/zstd/decompress/zstd_decompress_internal.h +240 -0
- package/node/third_party/zstd/zdict.h +481 -0
- package/node/third_party/zstd/zstd.h +3198 -0
- package/node/third_party/zstd/zstd_errors.h +107 -0
- package/package.json +1 -6
- package/runtime/include/js_atoms.gen.h +0 -0
- package/runtime/include/js_atoms.h +0 -0
- package/runtime/include/js_bigint.h +0 -0
- package/runtime/include/js_buffer.h +0 -0
- package/runtime/include/js_builtins.h +0 -0
- package/runtime/include/js_console.h +5 -2
- package/runtime/include/js_convert.h +0 -0
- package/runtime/include/js_core.def +0 -0
- package/runtime/include/js_error.h +0 -0
- package/runtime/include/js_exception.h +0 -0
- package/runtime/include/js_function.h +0 -0
- package/runtime/include/js_gc.h +0 -0
- package/runtime/include/js_generator.h +0 -0
- package/runtime/include/js_host.h +5 -3
- package/runtime/include/js_jobs.h +18 -1
- package/runtime/include/js_module.h +0 -0
- package/runtime/include/js_object.h +0 -0
- package/runtime/include/js_ops.h +0 -0
- package/runtime/include/js_promise.h +1 -0
- package/runtime/include/js_regexp.h +0 -0
- package/runtime/include/js_runtime.h +0 -0
- package/runtime/include/js_symbol.h +0 -0
- package/runtime/include/js_web.h +0 -0
- package/runtime/include/jscell.h +0 -0
- package/runtime/include/jscontext.h +14 -0
- package/runtime/include/jsnum.h +0 -0
- package/runtime/include/jsstring.h +0 -0
- package/runtime/include/jsvalue.h +0 -0
- package/runtime/src/arguments.c +0 -0
- package/runtime/src/array.c +0 -0
- package/runtime/src/arraybuffer.c +0 -0
- package/runtime/src/async_iter.c +0 -0
- package/runtime/src/atoms.c +0 -0
- package/runtime/src/base64.c +0 -0
- package/runtime/src/bigint.c +0 -0
- package/runtime/src/blob.c +0 -0
- package/runtime/src/buffer.c +20 -16
- package/runtime/src/builtin_table.c +0 -0
- package/runtime/src/builtins.c +0 -0
- package/runtime/src/builtins_util.h +0 -0
- package/runtime/src/collections.c +0 -0
- package/runtime/src/components.c +0 -0
- package/runtime/src/console.c +15 -2
- package/runtime/src/convert.c +0 -0
- package/runtime/src/core_all.c +0 -0
- package/runtime/src/crypto.c +0 -0
- package/runtime/src/crypto_host.c +0 -0
- package/runtime/src/crypto_kdf.c +0 -0
- package/runtime/src/crypto_key.c +0 -0
- package/runtime/src/date.c +0 -0
- package/runtime/src/domexception.c +0 -0
- package/runtime/src/elements.c +0 -0
- package/runtime/src/elements.h +0 -0
- package/runtime/src/encoding.c +0 -0
- package/runtime/src/error.c +0 -0
- package/runtime/src/events.c +1 -1
- package/runtime/src/exception.c +0 -0
- package/runtime/src/fetch.c +0 -0
- package/runtime/src/function.c +0 -0
- package/runtime/src/gc.c +2 -0
- package/runtime/src/generator.c +0 -0
- package/runtime/src/global.c +0 -0
- package/runtime/src/headers.c +0 -0
- package/runtime/src/inspect.c +0 -0
- package/runtime/src/internal.h +0 -0
- package/runtime/src/iterate.c +0 -0
- package/runtime/src/iterator.c +0 -0
- package/runtime/src/jobs.c +123 -44
- package/runtime/src/jsnum.c +0 -0
- package/runtime/src/json.c +0 -0
- package/runtime/src/math.c +0 -0
- package/runtime/src/module.c +0 -0
- package/runtime/src/number.c +0 -0
- package/runtime/src/object.c +0 -0
- package/runtime/src/ops.c +0 -0
- package/runtime/src/os.c +0 -0
- package/runtime/src/os.h +0 -0
- package/runtime/src/process.c +92 -8
- package/runtime/src/promise.c +7 -2
- package/runtime/src/proxy.c +0 -0
- package/runtime/src/reflect.c +0 -0
- package/runtime/src/regexp.c +0 -0
- package/runtime/src/regexp_anchor.h +0 -0
- package/runtime/src/regexp_message.h +0 -0
- package/runtime/src/shape.c +0 -0
- package/runtime/src/shape.h +0 -0
- package/runtime/src/streams.c +0 -0
- package/runtime/src/streams.h +0 -0
- package/runtime/src/string.c +0 -0
- package/runtime/src/string_builtins.c +0 -0
- package/runtime/src/symbol.c +0 -0
- package/runtime/src/test_host.c +0 -0
- package/runtime/src/typedarray.c +0 -0
- package/runtime/src/tznames.gen.h +0 -0
- package/runtime/src/uri.c +0 -0
- package/runtime/src/url.c +0 -0
- package/runtime/src/weak.c +1 -4
- package/runtime/src/web.c +0 -0
- package/runtime/src/wrapper.c +0 -0
- package/runtime/src/writable.c +0 -0
- package/runtime/third_party/ada-idna/LICENSE-MIT +0 -0
- package/runtime/third_party/ada-idna/README.md +0 -0
- package/runtime/third_party/ada-idna/convert.mjs +0 -0
- package/runtime/third_party/ada-idna/idna.c +0 -0
- package/runtime/third_party/ada-idna/idna.h +0 -0
- package/runtime/third_party/ada-idna/idna_tables.h +0 -0
- package/runtime/third_party/quickjs-dtoa/LICENSE +0 -0
- package/runtime/third_party/quickjs-dtoa/README.md +0 -0
- 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 +0 -0
- 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/v8-ieee754/LICENSE +0 -0
- package/runtime/third_party/v8-ieee754/README.md +0 -0
- 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 +0 -0
|
@@ -0,0 +1,481 @@
|
|
|
1
|
+
/* NOLINT(build/header_guard) */
|
|
2
|
+
/* Copyright 2013 Google Inc. All Rights Reserved.
|
|
3
|
+
|
|
4
|
+
Distributed under MIT license.
|
|
5
|
+
See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/* template parameters: FN, DataType */
|
|
9
|
+
|
|
10
|
+
#define HistogramType FN(Histogram)
|
|
11
|
+
|
|
12
|
+
static void FN(InitialEntropyCodes)(const DataType* data, size_t length,
|
|
13
|
+
size_t stride,
|
|
14
|
+
size_t num_histograms,
|
|
15
|
+
HistogramType* histograms) {
|
|
16
|
+
uint32_t seed = 7;
|
|
17
|
+
size_t block_length = length / num_histograms;
|
|
18
|
+
size_t i;
|
|
19
|
+
FN(ClearHistograms)(histograms, num_histograms);
|
|
20
|
+
for (i = 0; i < num_histograms; ++i) {
|
|
21
|
+
size_t pos = length * i / num_histograms;
|
|
22
|
+
if (i != 0) {
|
|
23
|
+
pos += MyRand(&seed) % block_length;
|
|
24
|
+
}
|
|
25
|
+
if (pos + stride >= length) {
|
|
26
|
+
pos = length - stride - 1;
|
|
27
|
+
}
|
|
28
|
+
FN(HistogramAddVector)(&histograms[i], data + pos, stride);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
static void FN(RandomSample)(uint32_t* seed,
|
|
33
|
+
const DataType* data,
|
|
34
|
+
size_t length,
|
|
35
|
+
size_t stride,
|
|
36
|
+
HistogramType* sample) {
|
|
37
|
+
size_t pos = 0;
|
|
38
|
+
if (stride >= length) {
|
|
39
|
+
stride = length;
|
|
40
|
+
} else {
|
|
41
|
+
pos = MyRand(seed) % (length - stride + 1);
|
|
42
|
+
}
|
|
43
|
+
FN(HistogramAddVector)(sample, data + pos, stride);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
static void FN(RefineEntropyCodes)(const DataType* data, size_t length,
|
|
47
|
+
size_t stride,
|
|
48
|
+
size_t num_histograms,
|
|
49
|
+
HistogramType* histograms,
|
|
50
|
+
HistogramType* tmp) {
|
|
51
|
+
size_t iters =
|
|
52
|
+
kIterMulForRefining * length / stride + kMinItersForRefining;
|
|
53
|
+
uint32_t seed = 7;
|
|
54
|
+
size_t iter;
|
|
55
|
+
iters = ((iters + num_histograms - 1) / num_histograms) * num_histograms;
|
|
56
|
+
for (iter = 0; iter < iters; ++iter) {
|
|
57
|
+
FN(HistogramClear)(tmp);
|
|
58
|
+
FN(RandomSample)(&seed, data, length, stride, tmp);
|
|
59
|
+
FN(HistogramAddHistogram)(&histograms[iter % num_histograms], tmp);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/* Assigns a block id from the range [0, num_histograms) to each data element
|
|
64
|
+
in data[0..length) and fills in block_id[0..length) with the assigned values.
|
|
65
|
+
Returns the number of blocks, i.e. one plus the number of block switches. */
|
|
66
|
+
static size_t FN(FindBlocks)(const DataType* data, const size_t length,
|
|
67
|
+
const double block_switch_bitcost,
|
|
68
|
+
const size_t num_histograms,
|
|
69
|
+
const HistogramType* histograms,
|
|
70
|
+
double* insert_cost,
|
|
71
|
+
double* cost,
|
|
72
|
+
uint8_t* switch_signal,
|
|
73
|
+
uint8_t* block_id) {
|
|
74
|
+
const size_t alphabet_size = FN(HistogramDataSize)();
|
|
75
|
+
const size_t bitmap_len = (num_histograms + 7) >> 3;
|
|
76
|
+
size_t num_blocks = 1;
|
|
77
|
+
size_t byte_ix;
|
|
78
|
+
size_t i;
|
|
79
|
+
size_t j;
|
|
80
|
+
BROTLI_DCHECK(num_histograms <= 256);
|
|
81
|
+
|
|
82
|
+
/* Trivial case: single historgram -> single block type. */
|
|
83
|
+
if (num_histograms <= 1) {
|
|
84
|
+
for (i = 0; i < length; ++i) {
|
|
85
|
+
block_id[i] = 0;
|
|
86
|
+
}
|
|
87
|
+
return 1;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/* Fill bitcost for each symbol of all histograms.
|
|
91
|
+
* Non-existing symbol cost: 2 + log2(total_count).
|
|
92
|
+
* Regular symbol cost: -log2(symbol_count / total_count). */
|
|
93
|
+
memset(insert_cost, 0,
|
|
94
|
+
sizeof(insert_cost[0]) * alphabet_size * num_histograms);
|
|
95
|
+
for (i = 0; i < num_histograms; ++i) {
|
|
96
|
+
insert_cost[i] = FastLog2((uint32_t)histograms[i].total_count_);
|
|
97
|
+
}
|
|
98
|
+
for (i = alphabet_size; i != 0;) {
|
|
99
|
+
/* Reverse order to use the 0-th row as a temporary storage. */
|
|
100
|
+
--i;
|
|
101
|
+
for (j = 0; j < num_histograms; ++j) {
|
|
102
|
+
insert_cost[i * num_histograms + j] =
|
|
103
|
+
insert_cost[j] - BitCost(histograms[j].data_[i]);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/* After each iteration of this loop, cost[k] will contain the difference
|
|
108
|
+
between the minimum cost of arriving at the current byte position using
|
|
109
|
+
entropy code k, and the minimum cost of arriving at the current byte
|
|
110
|
+
position. This difference is capped at the block switch cost, and if it
|
|
111
|
+
reaches block switch cost, it means that when we trace back from the last
|
|
112
|
+
position, we need to switch here. */
|
|
113
|
+
memset(cost, 0, sizeof(cost[0]) * num_histograms);
|
|
114
|
+
memset(switch_signal, 0, sizeof(switch_signal[0]) * length * bitmap_len);
|
|
115
|
+
for (byte_ix = 0; byte_ix < length; ++byte_ix) {
|
|
116
|
+
size_t ix = byte_ix * bitmap_len;
|
|
117
|
+
size_t symbol = data[byte_ix];
|
|
118
|
+
size_t insert_cost_ix = symbol * num_histograms;
|
|
119
|
+
double min_cost = 1e99;
|
|
120
|
+
double block_switch_cost = block_switch_bitcost;
|
|
121
|
+
size_t k;
|
|
122
|
+
for (k = 0; k < num_histograms; ++k) {
|
|
123
|
+
/* We are coding the symbol with entropy code k. */
|
|
124
|
+
cost[k] += insert_cost[insert_cost_ix + k];
|
|
125
|
+
if (cost[k] < min_cost) {
|
|
126
|
+
min_cost = cost[k];
|
|
127
|
+
block_id[byte_ix] = (uint8_t)k;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
/* More blocks for the beginning. */
|
|
131
|
+
if (byte_ix < 2000) {
|
|
132
|
+
block_switch_cost *= 0.77 + 0.07 * (double)byte_ix / 2000;
|
|
133
|
+
}
|
|
134
|
+
for (k = 0; k < num_histograms; ++k) {
|
|
135
|
+
cost[k] -= min_cost;
|
|
136
|
+
if (cost[k] >= block_switch_cost) {
|
|
137
|
+
const uint8_t mask = (uint8_t)(1u << (k & 7));
|
|
138
|
+
cost[k] = block_switch_cost;
|
|
139
|
+
BROTLI_DCHECK((k >> 3) < bitmap_len);
|
|
140
|
+
switch_signal[ix + (k >> 3)] |= mask;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
byte_ix = length - 1;
|
|
146
|
+
{ /* Trace back from the last position and switch at the marked places. */
|
|
147
|
+
size_t ix = byte_ix * bitmap_len;
|
|
148
|
+
uint8_t cur_id = block_id[byte_ix];
|
|
149
|
+
while (byte_ix > 0) {
|
|
150
|
+
const uint8_t mask = (uint8_t)(1u << (cur_id & 7));
|
|
151
|
+
BROTLI_DCHECK(((size_t)cur_id >> 3) < bitmap_len);
|
|
152
|
+
--byte_ix;
|
|
153
|
+
ix -= bitmap_len;
|
|
154
|
+
if (switch_signal[ix + (cur_id >> 3)] & mask) {
|
|
155
|
+
if (cur_id != block_id[byte_ix]) {
|
|
156
|
+
cur_id = block_id[byte_ix];
|
|
157
|
+
++num_blocks;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
block_id[byte_ix] = cur_id;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
return num_blocks;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
static size_t FN(RemapBlockIds)(uint8_t* block_ids, const size_t length,
|
|
167
|
+
uint16_t* new_id, const size_t num_histograms) {
|
|
168
|
+
static const uint16_t kInvalidId = 256;
|
|
169
|
+
uint16_t next_id = 0;
|
|
170
|
+
size_t i;
|
|
171
|
+
for (i = 0; i < num_histograms; ++i) {
|
|
172
|
+
new_id[i] = kInvalidId;
|
|
173
|
+
}
|
|
174
|
+
for (i = 0; i < length; ++i) {
|
|
175
|
+
BROTLI_DCHECK(block_ids[i] < num_histograms);
|
|
176
|
+
if (new_id[block_ids[i]] == kInvalidId) {
|
|
177
|
+
new_id[block_ids[i]] = next_id++;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
for (i = 0; i < length; ++i) {
|
|
181
|
+
block_ids[i] = (uint8_t)new_id[block_ids[i]];
|
|
182
|
+
BROTLI_DCHECK(block_ids[i] < num_histograms);
|
|
183
|
+
}
|
|
184
|
+
BROTLI_DCHECK(next_id <= num_histograms);
|
|
185
|
+
return next_id;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
static void FN(BuildBlockHistograms)(const DataType* data, const size_t length,
|
|
189
|
+
const uint8_t* block_ids,
|
|
190
|
+
const size_t num_histograms,
|
|
191
|
+
HistogramType* histograms) {
|
|
192
|
+
size_t i;
|
|
193
|
+
FN(ClearHistograms)(histograms, num_histograms);
|
|
194
|
+
for (i = 0; i < length; ++i) {
|
|
195
|
+
FN(HistogramAdd)(&histograms[block_ids[i]], data[i]);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/* Given the initial partitioning build partitioning with limited number
|
|
200
|
+
* of histograms (and block types). */
|
|
201
|
+
static void FN(ClusterBlocks)(MemoryManager* m,
|
|
202
|
+
const DataType* data, const size_t length,
|
|
203
|
+
const size_t num_blocks,
|
|
204
|
+
uint8_t* block_ids,
|
|
205
|
+
BlockSplit* split) {
|
|
206
|
+
uint32_t* histogram_symbols = BROTLI_ALLOC(m, uint32_t, num_blocks);
|
|
207
|
+
uint32_t* u32 =
|
|
208
|
+
BROTLI_ALLOC(m, uint32_t, num_blocks + 4 * HISTOGRAMS_PER_BATCH);
|
|
209
|
+
const size_t expected_num_clusters = CLUSTERS_PER_BATCH *
|
|
210
|
+
(num_blocks + HISTOGRAMS_PER_BATCH - 1) / HISTOGRAMS_PER_BATCH;
|
|
211
|
+
size_t all_histograms_size = 0;
|
|
212
|
+
size_t all_histograms_capacity = expected_num_clusters;
|
|
213
|
+
HistogramType* all_histograms =
|
|
214
|
+
BROTLI_ALLOC(m, HistogramType, all_histograms_capacity);
|
|
215
|
+
size_t cluster_size_size = 0;
|
|
216
|
+
size_t cluster_size_capacity = expected_num_clusters;
|
|
217
|
+
uint32_t* cluster_size = BROTLI_ALLOC(m, uint32_t, cluster_size_capacity);
|
|
218
|
+
size_t num_clusters = 0;
|
|
219
|
+
HistogramType* histograms = BROTLI_ALLOC(m, HistogramType,
|
|
220
|
+
BROTLI_MIN(size_t, num_blocks, HISTOGRAMS_PER_BATCH));
|
|
221
|
+
size_t max_num_pairs =
|
|
222
|
+
HISTOGRAMS_PER_BATCH * HISTOGRAMS_PER_BATCH / 2;
|
|
223
|
+
size_t pairs_capacity = max_num_pairs + 1;
|
|
224
|
+
HistogramPair* pairs = BROTLI_ALLOC(m, HistogramPair, pairs_capacity);
|
|
225
|
+
size_t pos = 0;
|
|
226
|
+
uint32_t* clusters;
|
|
227
|
+
size_t num_final_clusters;
|
|
228
|
+
static const uint32_t kInvalidIndex = BROTLI_UINT32_MAX;
|
|
229
|
+
uint32_t* new_index;
|
|
230
|
+
size_t i;
|
|
231
|
+
uint32_t* BROTLI_RESTRICT const sizes = u32 + 0 * HISTOGRAMS_PER_BATCH;
|
|
232
|
+
uint32_t* BROTLI_RESTRICT const new_clusters = u32 + 1 * HISTOGRAMS_PER_BATCH;
|
|
233
|
+
uint32_t* BROTLI_RESTRICT const symbols = u32 + 2 * HISTOGRAMS_PER_BATCH;
|
|
234
|
+
uint32_t* BROTLI_RESTRICT const remap = u32 + 3 * HISTOGRAMS_PER_BATCH;
|
|
235
|
+
uint32_t* BROTLI_RESTRICT const block_lengths =
|
|
236
|
+
u32 + 4 * HISTOGRAMS_PER_BATCH;
|
|
237
|
+
/* TODO(eustas): move to arena? */
|
|
238
|
+
HistogramType* tmp = BROTLI_ALLOC(m, HistogramType, 2);
|
|
239
|
+
|
|
240
|
+
if (BROTLI_IS_OOM(m) || BROTLI_IS_NULL(histogram_symbols) ||
|
|
241
|
+
BROTLI_IS_NULL(u32) || BROTLI_IS_NULL(all_histograms) ||
|
|
242
|
+
BROTLI_IS_NULL(cluster_size) || BROTLI_IS_NULL(histograms) ||
|
|
243
|
+
BROTLI_IS_NULL(pairs) || BROTLI_IS_NULL(tmp)) {
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
memset(u32, 0, (num_blocks + 4 * HISTOGRAMS_PER_BATCH) * sizeof(uint32_t));
|
|
248
|
+
|
|
249
|
+
/* Calculate block lengths (convert repeating values -> series length). */
|
|
250
|
+
{
|
|
251
|
+
size_t block_idx = 0;
|
|
252
|
+
for (i = 0; i < length; ++i) {
|
|
253
|
+
BROTLI_DCHECK(block_idx < num_blocks);
|
|
254
|
+
++block_lengths[block_idx];
|
|
255
|
+
if (i + 1 == length || block_ids[i] != block_ids[i + 1]) {
|
|
256
|
+
++block_idx;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
BROTLI_DCHECK(block_idx == num_blocks);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/* Pre-cluster blocks (cluster batches). */
|
|
263
|
+
for (i = 0; i < num_blocks; i += HISTOGRAMS_PER_BATCH) {
|
|
264
|
+
const size_t num_to_combine =
|
|
265
|
+
BROTLI_MIN(size_t, num_blocks - i, HISTOGRAMS_PER_BATCH);
|
|
266
|
+
size_t num_new_clusters;
|
|
267
|
+
size_t j;
|
|
268
|
+
for (j = 0; j < num_to_combine; ++j) {
|
|
269
|
+
size_t k;
|
|
270
|
+
size_t block_length = block_lengths[i + j];
|
|
271
|
+
FN(HistogramClear)(&histograms[j]);
|
|
272
|
+
for (k = 0; k < block_length; ++k) {
|
|
273
|
+
FN(HistogramAdd)(&histograms[j], data[pos++]);
|
|
274
|
+
}
|
|
275
|
+
histograms[j].bit_cost_ = FN(BrotliPopulationCost)(&histograms[j]);
|
|
276
|
+
new_clusters[j] = (uint32_t)j;
|
|
277
|
+
symbols[j] = (uint32_t)j;
|
|
278
|
+
sizes[j] = 1;
|
|
279
|
+
}
|
|
280
|
+
num_new_clusters = FN(BrotliHistogramCombine)(
|
|
281
|
+
histograms, tmp, sizes, symbols, new_clusters, pairs, num_to_combine,
|
|
282
|
+
num_to_combine, HISTOGRAMS_PER_BATCH, max_num_pairs);
|
|
283
|
+
BROTLI_ENSURE_CAPACITY(m, HistogramType, all_histograms,
|
|
284
|
+
all_histograms_capacity, all_histograms_size + num_new_clusters);
|
|
285
|
+
BROTLI_ENSURE_CAPACITY(m, uint32_t, cluster_size,
|
|
286
|
+
cluster_size_capacity, cluster_size_size + num_new_clusters);
|
|
287
|
+
if (BROTLI_IS_OOM(m)) return;
|
|
288
|
+
for (j = 0; j < num_new_clusters; ++j) {
|
|
289
|
+
all_histograms[all_histograms_size++] = histograms[new_clusters[j]];
|
|
290
|
+
cluster_size[cluster_size_size++] = sizes[new_clusters[j]];
|
|
291
|
+
remap[new_clusters[j]] = (uint32_t)j;
|
|
292
|
+
}
|
|
293
|
+
for (j = 0; j < num_to_combine; ++j) {
|
|
294
|
+
histogram_symbols[i + j] = (uint32_t)num_clusters + remap[symbols[j]];
|
|
295
|
+
}
|
|
296
|
+
num_clusters += num_new_clusters;
|
|
297
|
+
BROTLI_DCHECK(num_clusters == cluster_size_size);
|
|
298
|
+
BROTLI_DCHECK(num_clusters == all_histograms_size);
|
|
299
|
+
}
|
|
300
|
+
BROTLI_FREE(m, histograms);
|
|
301
|
+
|
|
302
|
+
/* Final clustering. */
|
|
303
|
+
max_num_pairs =
|
|
304
|
+
BROTLI_MIN(size_t, 64 * num_clusters, (num_clusters / 2) * num_clusters);
|
|
305
|
+
if (pairs_capacity < max_num_pairs + 1) {
|
|
306
|
+
BROTLI_FREE(m, pairs);
|
|
307
|
+
pairs = BROTLI_ALLOC(m, HistogramPair, max_num_pairs + 1);
|
|
308
|
+
if (BROTLI_IS_OOM(m) || BROTLI_IS_NULL(pairs)) return;
|
|
309
|
+
}
|
|
310
|
+
clusters = BROTLI_ALLOC(m, uint32_t, num_clusters);
|
|
311
|
+
if (BROTLI_IS_OOM(m) || BROTLI_IS_NULL(clusters)) return;
|
|
312
|
+
for (i = 0; i < num_clusters; ++i) {
|
|
313
|
+
clusters[i] = (uint32_t)i;
|
|
314
|
+
}
|
|
315
|
+
num_final_clusters = FN(BrotliHistogramCombine)(
|
|
316
|
+
all_histograms, tmp, cluster_size, histogram_symbols, clusters, pairs,
|
|
317
|
+
num_clusters, num_blocks, BROTLI_MAX_NUMBER_OF_BLOCK_TYPES,
|
|
318
|
+
max_num_pairs);
|
|
319
|
+
BROTLI_FREE(m, pairs);
|
|
320
|
+
BROTLI_FREE(m, cluster_size);
|
|
321
|
+
|
|
322
|
+
/* Assign blocks to final histograms. */
|
|
323
|
+
new_index = BROTLI_ALLOC(m, uint32_t, num_clusters);
|
|
324
|
+
if (BROTLI_IS_OOM(m) || BROTLI_IS_NULL(new_index)) return;
|
|
325
|
+
for (i = 0; i < num_clusters; ++i) new_index[i] = kInvalidIndex;
|
|
326
|
+
pos = 0;
|
|
327
|
+
{
|
|
328
|
+
uint32_t next_index = 0;
|
|
329
|
+
for (i = 0; i < num_blocks; ++i) {
|
|
330
|
+
size_t j;
|
|
331
|
+
uint32_t best_out;
|
|
332
|
+
double best_bits;
|
|
333
|
+
FN(HistogramClear)(tmp);
|
|
334
|
+
for (j = 0; j < block_lengths[i]; ++j) {
|
|
335
|
+
FN(HistogramAdd)(tmp, data[pos++]);
|
|
336
|
+
}
|
|
337
|
+
/* Among equally good histograms prefer last used. */
|
|
338
|
+
/* TODO(eustas): should we give a block-switch discount here? */
|
|
339
|
+
best_out = (i == 0) ? histogram_symbols[0] : histogram_symbols[i - 1];
|
|
340
|
+
best_bits = FN(BrotliHistogramBitCostDistance)(
|
|
341
|
+
tmp, &all_histograms[best_out], tmp + 1);
|
|
342
|
+
for (j = 0; j < num_final_clusters; ++j) {
|
|
343
|
+
const double cur_bits = FN(BrotliHistogramBitCostDistance)(
|
|
344
|
+
tmp, &all_histograms[clusters[j]], tmp + 1);
|
|
345
|
+
if (cur_bits < best_bits) {
|
|
346
|
+
best_bits = cur_bits;
|
|
347
|
+
best_out = clusters[j];
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
histogram_symbols[i] = best_out;
|
|
351
|
+
if (new_index[best_out] == kInvalidIndex) {
|
|
352
|
+
new_index[best_out] = next_index++;
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
BROTLI_FREE(m, tmp);
|
|
357
|
+
BROTLI_FREE(m, clusters);
|
|
358
|
+
BROTLI_FREE(m, all_histograms);
|
|
359
|
+
BROTLI_ENSURE_CAPACITY(
|
|
360
|
+
m, uint8_t, split->types, split->types_alloc_size, num_blocks);
|
|
361
|
+
BROTLI_ENSURE_CAPACITY(
|
|
362
|
+
m, uint32_t, split->lengths, split->lengths_alloc_size, num_blocks);
|
|
363
|
+
if (BROTLI_IS_OOM(m)) return;
|
|
364
|
+
|
|
365
|
+
/* Rewrite final assignment to block-split. There might be less blocks
|
|
366
|
+
* than |num_blocks| due to clustering. */
|
|
367
|
+
{
|
|
368
|
+
uint32_t cur_length = 0;
|
|
369
|
+
size_t block_idx = 0;
|
|
370
|
+
uint8_t max_type = 0;
|
|
371
|
+
for (i = 0; i < num_blocks; ++i) {
|
|
372
|
+
cur_length += block_lengths[i];
|
|
373
|
+
if (i + 1 == num_blocks ||
|
|
374
|
+
histogram_symbols[i] != histogram_symbols[i + 1]) {
|
|
375
|
+
const uint8_t id = (uint8_t)new_index[histogram_symbols[i]];
|
|
376
|
+
split->types[block_idx] = id;
|
|
377
|
+
split->lengths[block_idx] = cur_length;
|
|
378
|
+
max_type = BROTLI_MAX(uint8_t, max_type, id);
|
|
379
|
+
cur_length = 0;
|
|
380
|
+
++block_idx;
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
split->num_blocks = block_idx;
|
|
384
|
+
split->num_types = (size_t)max_type + 1;
|
|
385
|
+
}
|
|
386
|
+
BROTLI_FREE(m, new_index);
|
|
387
|
+
BROTLI_FREE(m, u32);
|
|
388
|
+
BROTLI_FREE(m, histogram_symbols);
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
/* Create BlockSplit (partitioning) given the limits, estimates and "effort"
|
|
392
|
+
* parameters.
|
|
393
|
+
*
|
|
394
|
+
* NB: max_histograms is often less than number of histograms allowed by format;
|
|
395
|
+
* this is done intentionally, to save some "space" for context-aware
|
|
396
|
+
* clustering (here entropy is estimated for context-free symbols). */
|
|
397
|
+
static void FN(SplitByteVector)(MemoryManager* m,
|
|
398
|
+
const DataType* data, const size_t length,
|
|
399
|
+
const size_t symbols_per_histogram,
|
|
400
|
+
const size_t max_histograms,
|
|
401
|
+
const size_t sampling_stride_length,
|
|
402
|
+
const double block_switch_cost,
|
|
403
|
+
const BrotliEncoderParams* params,
|
|
404
|
+
BlockSplit* split) {
|
|
405
|
+
const size_t data_size = FN(HistogramDataSize)();
|
|
406
|
+
HistogramType* histograms;
|
|
407
|
+
HistogramType* tmp;
|
|
408
|
+
/* Calculate number of histograms; initial estimate is one histogram per
|
|
409
|
+
* specified amount of symbols; however, this value is capped. */
|
|
410
|
+
size_t num_histograms = length / symbols_per_histogram + 1;
|
|
411
|
+
if (num_histograms > max_histograms) {
|
|
412
|
+
num_histograms = max_histograms;
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
/* Corner case: no input. */
|
|
416
|
+
if (length == 0) {
|
|
417
|
+
split->num_types = 1;
|
|
418
|
+
return;
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
if (length < kMinLengthForBlockSplitting) {
|
|
422
|
+
BROTLI_ENSURE_CAPACITY(m, uint8_t,
|
|
423
|
+
split->types, split->types_alloc_size, split->num_blocks + 1);
|
|
424
|
+
BROTLI_ENSURE_CAPACITY(m, uint32_t,
|
|
425
|
+
split->lengths, split->lengths_alloc_size, split->num_blocks + 1);
|
|
426
|
+
if (BROTLI_IS_OOM(m)) return;
|
|
427
|
+
split->num_types = 1;
|
|
428
|
+
split->types[split->num_blocks] = 0;
|
|
429
|
+
split->lengths[split->num_blocks] = (uint32_t)length;
|
|
430
|
+
split->num_blocks++;
|
|
431
|
+
return;
|
|
432
|
+
}
|
|
433
|
+
histograms = BROTLI_ALLOC(m, HistogramType, num_histograms + 1);
|
|
434
|
+
tmp = histograms + num_histograms;
|
|
435
|
+
if (BROTLI_IS_OOM(m) || BROTLI_IS_NULL(histograms)) return;
|
|
436
|
+
/* Find good entropy codes. */
|
|
437
|
+
FN(InitialEntropyCodes)(data, length,
|
|
438
|
+
sampling_stride_length,
|
|
439
|
+
num_histograms, histograms);
|
|
440
|
+
FN(RefineEntropyCodes)(data, length,
|
|
441
|
+
sampling_stride_length,
|
|
442
|
+
num_histograms, histograms, tmp);
|
|
443
|
+
{
|
|
444
|
+
/* Find a good path through literals with the good entropy codes. */
|
|
445
|
+
uint8_t* block_ids = BROTLI_ALLOC(m, uint8_t, length);
|
|
446
|
+
size_t num_blocks = 0;
|
|
447
|
+
const size_t bitmaplen = (num_histograms + 7) >> 3;
|
|
448
|
+
double* insert_cost = BROTLI_ALLOC(m, double, data_size * num_histograms);
|
|
449
|
+
double* cost = BROTLI_ALLOC(m, double, num_histograms);
|
|
450
|
+
uint8_t* switch_signal = BROTLI_ALLOC(m, uint8_t, length * bitmaplen);
|
|
451
|
+
uint16_t* new_id = BROTLI_ALLOC(m, uint16_t, num_histograms);
|
|
452
|
+
const size_t iters = params->quality < HQ_ZOPFLIFICATION_QUALITY ? 3 : 10;
|
|
453
|
+
size_t i;
|
|
454
|
+
if (BROTLI_IS_OOM(m) || BROTLI_IS_NULL(block_ids) ||
|
|
455
|
+
BROTLI_IS_NULL(insert_cost) || BROTLI_IS_NULL(cost) ||
|
|
456
|
+
BROTLI_IS_NULL(switch_signal) || BROTLI_IS_NULL(new_id)) {
|
|
457
|
+
return;
|
|
458
|
+
}
|
|
459
|
+
for (i = 0; i < iters; ++i) {
|
|
460
|
+
num_blocks = FN(FindBlocks)(data, length,
|
|
461
|
+
block_switch_cost,
|
|
462
|
+
num_histograms, histograms,
|
|
463
|
+
insert_cost, cost, switch_signal,
|
|
464
|
+
block_ids);
|
|
465
|
+
num_histograms = FN(RemapBlockIds)(block_ids, length,
|
|
466
|
+
new_id, num_histograms);
|
|
467
|
+
FN(BuildBlockHistograms)(data, length, block_ids,
|
|
468
|
+
num_histograms, histograms);
|
|
469
|
+
}
|
|
470
|
+
BROTLI_FREE(m, insert_cost);
|
|
471
|
+
BROTLI_FREE(m, cost);
|
|
472
|
+
BROTLI_FREE(m, switch_signal);
|
|
473
|
+
BROTLI_FREE(m, new_id);
|
|
474
|
+
BROTLI_FREE(m, histograms);
|
|
475
|
+
FN(ClusterBlocks)(m, data, length, num_blocks, block_ids, split);
|
|
476
|
+
if (BROTLI_IS_OOM(m)) return;
|
|
477
|
+
BROTLI_FREE(m, block_ids);
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
#undef HistogramType
|