cfsolve 0.1.2 → 0.1.3
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/THIRD_PARTY_LICENSES/README.md +71 -254
- data/THIRD_PARTY_LICENSES/{derive_builder_macro-0.20.2/LICENSE-APACHE → bytecount-0.6.9/LICENSE.Apache2} +0 -1
- data/THIRD_PARTY_LICENSES/{darling-0.20.11/LICENSE → bytecount-0.6.9/LICENSE.MIT} +1 -3
- data/THIRD_PARTY_LICENSES/{ident_case-1.0.1/LICENSE → cobs-0.3.0/LICENSE-MIT} +1 -1
- data/THIRD_PARTY_LICENSES/cow-utils-0.1.3/LICENSE +21 -0
- data/THIRD_PARTY_LICENSES/{hashbrown-0.14.5 → embedded-io-0.4.0}/LICENSE-MIT +1 -1
- data/THIRD_PARTY_LICENSES/{ahash-0.8.12 → embedded-io-0.6.1}/LICENSE-MIT +1 -1
- data/THIRD_PARTY_LICENSES/{browserslist-data-0.1.4 → escape-simd-0.1.1}/LICENSE +1 -1
- data/THIRD_PARTY_LICENSES/escape-simd-0.1.1/NOTICE +62 -0
- data/THIRD_PARTY_LICENSES/json-escape-simd-3.1.3/LICENSE +21 -0
- data/THIRD_PARTY_LICENSES/{miette-7.6.0/LICENSE → json-escape-simd-3.1.3/LICENSE-APACHE} +0 -1
- data/THIRD_PARTY_LICENSES/json-escape-simd-3.1.3/NOTICE +62 -0
- data/THIRD_PARTY_LICENSES/memchr-2.8.3/UNLICENSE +24 -0
- data/THIRD_PARTY_LICENSES/{derive_builder_core-0.20.2 → nonmax-0.5.5}/LICENSE-APACHE +1 -2
- data/THIRD_PARTY_LICENSES/{dashmap-5.5.3/LICENSE → nonmax-0.5.5/LICENSE-MIT} +2 -4
- data/THIRD_PARTY_LICENSES/{rand-0.8.5 → num-bigint-0.5.1}/LICENSE-MIT +0 -1
- data/THIRD_PARTY_LICENSES/oxc-0.157.0/LICENSE +22 -0
- data/THIRD_PARTY_LICENSES/oxc-0.157.0/THIRD-PARTY-LICENSE +763 -0
- data/THIRD_PARTY_LICENSES/{browserslist-rs-0.19.0 → oxc-browserslist-5.0.1}/LICENSE +1 -0
- data/THIRD_PARTY_LICENSES/oxc_allocator-0.157.0/LICENSE +22 -0
- data/THIRD_PARTY_LICENSES/oxc_allocator-0.157.0/THIRD-PARTY-LICENSE +763 -0
- data/THIRD_PARTY_LICENSES/oxc_ast-0.157.0/LICENSE +22 -0
- data/THIRD_PARTY_LICENSES/oxc_ast-0.157.0/THIRD-PARTY-LICENSE +763 -0
- data/THIRD_PARTY_LICENSES/oxc_ast_macros-0.157.0/LICENSE +22 -0
- data/THIRD_PARTY_LICENSES/oxc_ast_macros-0.157.0/THIRD-PARTY-LICENSE +763 -0
- data/THIRD_PARTY_LICENSES/oxc_ast_visit-0.157.0/LICENSE +22 -0
- data/THIRD_PARTY_LICENSES/oxc_ast_visit-0.157.0/THIRD-PARTY-LICENSE +763 -0
- data/THIRD_PARTY_LICENSES/oxc_codegen-0.157.0/LICENSE +22 -0
- data/THIRD_PARTY_LICENSES/oxc_codegen-0.157.0/THIRD-PARTY-LICENSE +763 -0
- data/THIRD_PARTY_LICENSES/oxc_compat-0.157.0/LICENSE +22 -0
- data/THIRD_PARTY_LICENSES/oxc_compat-0.157.0/THIRD-PARTY-LICENSE +763 -0
- data/THIRD_PARTY_LICENSES/oxc_data_structures-0.157.0/LICENSE +22 -0
- data/THIRD_PARTY_LICENSES/oxc_data_structures-0.157.0/THIRD-PARTY-LICENSE +763 -0
- data/THIRD_PARTY_LICENSES/oxc_diagnostics-0.157.0/LICENSE +22 -0
- data/THIRD_PARTY_LICENSES/oxc_diagnostics-0.157.0/THIRD-PARTY-LICENSE +763 -0
- data/THIRD_PARTY_LICENSES/oxc_ecmascript-0.157.0/LICENSE +22 -0
- data/THIRD_PARTY_LICENSES/oxc_ecmascript-0.157.0/THIRD-PARTY-LICENSE +763 -0
- data/THIRD_PARTY_LICENSES/oxc_estree-0.157.0/LICENSE +22 -0
- data/THIRD_PARTY_LICENSES/oxc_estree-0.157.0/THIRD-PARTY-LICENSE +763 -0
- data/THIRD_PARTY_LICENSES/oxc_index-5.0.0/LICENSE +22 -0
- data/THIRD_PARTY_LICENSES/oxc_parser-0.157.0/LICENSE +22 -0
- data/THIRD_PARTY_LICENSES/oxc_parser-0.157.0/THIRD-PARTY-LICENSE +763 -0
- data/THIRD_PARTY_LICENSES/oxc_regular_expression-0.157.0/LICENSE +22 -0
- data/THIRD_PARTY_LICENSES/oxc_regular_expression-0.157.0/THIRD-PARTY-LICENSE +763 -0
- data/THIRD_PARTY_LICENSES/oxc_semantic-0.157.0/LICENSE +22 -0
- data/THIRD_PARTY_LICENSES/oxc_semantic-0.157.0/THIRD-PARTY-LICENSE +763 -0
- data/THIRD_PARTY_LICENSES/oxc_span-0.157.0/LICENSE +22 -0
- data/THIRD_PARTY_LICENSES/oxc_span-0.157.0/THIRD-PARTY-LICENSE +763 -0
- data/THIRD_PARTY_LICENSES/oxc_str-0.157.0/LICENSE +22 -0
- data/THIRD_PARTY_LICENSES/oxc_str-0.157.0/THIRD-PARTY-LICENSE +763 -0
- data/THIRD_PARTY_LICENSES/oxc_syntax-0.157.0/LICENSE +22 -0
- data/THIRD_PARTY_LICENSES/oxc_syntax-0.157.0/THIRD-PARTY-LICENSE +763 -0
- data/THIRD_PARTY_LICENSES/{fixedbitset-0.5.7 → postcard-1.1.3}/LICENSE-MIT +1 -1
- data/THIRD_PARTY_LICENSES/{bytes-str-0.2.7/LICENSE → self_cell-1.3.0/LICENSE-APACHE} +1 -2
- data/THIRD_PARTY_LICENSES/self_cell-1.3.0/LICENSE-GPLv2 +339 -0
- data/THIRD_PARTY_LICENSES/{darling_core-0.20.11 → smawk-0.3.3}/LICENSE +1 -1
- data/UPSTREAM.md +7 -5
- data/ext/cfsolve/Cargo.lock +534 -1727
- data/ext/cfsolve/Cargo.toml +4 -0
- data/ext/cfsolve/src/main.rs +1 -1
- data/lib/cfsolve/profiles/safari-26-ios/answers.json +266 -265
- data/lib/cfsolve/profiles/safari-26-ios/challenge-page-answers.json +312 -312
- data/lib/cfsolve/profiles/safari-26-ios.json +106 -152
- data/lib/cfsolve/version.rb +2 -2
- data/vendor/cfsolve/Cargo.lock +561 -1729
- data/vendor/cfsolve/Cargo.toml +26 -8
- data/vendor/cfsolve/README.md +4 -0
- data/vendor/cfsolve/examples/check_answers.rs +2 -2
- data/vendor/cfsolve/examples/compare_session.rs +1 -2
- data/vendor/cfsolve/examples/solver_profile.rs +84 -0
- data/vendor/cfsolve/examples/solver_smoke.rs +9 -8
- data/vendor/cfsolve/examples/stage2_snapshot.rs +2 -2
- data/vendor/cfsolve/examples/tls_echo.rs +3 -3
- data/vendor/cfsolve/examples/vm_snapshot.rs +32 -33
- data/vendor/cfsolve/profiles/safari-26-ios/answers.json +266 -265
- data/vendor/cfsolve/profiles/safari-26-ios/challenge-page-answers.json +312 -312
- data/vendor/cfsolve/profiles/safari-26-ios.json +106 -152
- data/vendor/cfsolve/src/bin/capture-proxy/main.rs +3 -2
- data/vendor/cfsolve/src/bin/challenge/cli.rs +8 -2
- data/vendor/cfsolve/src/bin/challenge/main.rs +7 -2
- data/vendor/cfsolve/src/capture/proxy/tests.rs +1 -1
- data/vendor/cfsolve/src/capture/proxy.rs +44 -13
- data/vendor/cfsolve/src/capture/sessions.rs +4 -3
- data/vendor/cfsolve/src/capture/upstream.rs +1 -1
- data/vendor/cfsolve/src/challenge/codec.rs +4 -2
- data/vendor/cfsolve/src/challenge/expression.rs +161 -117
- data/vendor/cfsolve/src/challenge/installed/audit.rs +11 -10
- data/vendor/cfsolve/src/challenge/installed.rs +13 -6
- data/vendor/cfsolve/src/challenge/merge.rs +120 -80
- data/vendor/cfsolve/src/challenge/orchestrator.rs +57 -44
- data/vendor/cfsolve/src/challenge/payload.rs +69 -31
- data/vendor/cfsolve/src/challenge/program.rs +197 -178
- data/vendor/cfsolve/src/challenge/reduced_timing.rs +55 -40
- data/vendor/cfsolve/src/challenge/source.rs +151 -96
- data/vendor/cfsolve/src/challenge/state.rs +180 -148
- data/vendor/cfsolve/src/challenge/tally.rs +64 -50
- data/vendor/cfsolve/src/challenge.rs +1 -0
- data/vendor/cfsolve/src/deobfuscate/analysis/bindings.rs +187 -185
- data/vendor/cfsolve/src/deobfuscate/analysis/effects.rs +42 -51
- data/vendor/cfsolve/src/deobfuscate/analysis/hoisting.rs +147 -228
- data/vendor/cfsolve/src/deobfuscate/analysis/properties.rs +250 -425
- data/vendor/cfsolve/src/deobfuscate/analysis/unconditional.rs +79 -0
- data/vendor/cfsolve/src/deobfuscate/analysis.rs +259 -41
- data/vendor/cfsolve/src/deobfuscate/argument_arrays.rs +70 -73
- data/vendor/cfsolve/src/deobfuscate/arrow_blocks.rs +91 -104
- data/vendor/cfsolve/src/deobfuscate/ast.rs +383 -0
- data/vendor/cfsolve/src/deobfuscate/bitwise.rs +44 -54
- data/vendor/cfsolve/src/deobfuscate/blocks.rs +36 -29
- data/vendor/cfsolve/src/deobfuscate/call_helpers.rs +80 -131
- data/vendor/cfsolve/src/deobfuscate/control_flow.rs +239 -297
- data/vendor/cfsolve/src/deobfuscate/copy_propagation.rs +114 -135
- data/vendor/cfsolve/src/deobfuscate/dead_branches.rs +62 -61
- data/vendor/cfsolve/src/deobfuscate/dead_properties.rs +197 -214
- data/vendor/cfsolve/src/deobfuscate/dispatch.rs +238 -298
- data/vendor/cfsolve/src/deobfuscate/encoded_strings.rs +198 -203
- data/vendor/cfsolve/src/deobfuscate/function_lengths.rs +32 -38
- data/vendor/cfsolve/src/deobfuscate/helper_objects.rs +338 -513
- data/vendor/cfsolve/src/deobfuscate/hygiene.rs +197 -0
- data/vendor/cfsolve/src/deobfuscate/int32_helpers.rs +121 -155
- data/vendor/cfsolve/src/deobfuscate/literals.rs +116 -67
- data/vendor/cfsolve/src/deobfuscate/loops.rs +43 -43
- data/vendor/cfsolve/src/deobfuscate/memoized_strings.rs +127 -131
- data/vendor/cfsolve/src/deobfuscate/merged_functions.rs +262 -220
- data/vendor/cfsolve/src/deobfuscate/pipeline.rs +199 -244
- data/vendor/cfsolve/src/deobfuscate/register_arrays.rs +353 -327
- data/vendor/cfsolve/src/deobfuscate/removal.rs +83 -52
- data/vendor/cfsolve/src/deobfuscate/simplify.rs +147 -0
- data/vendor/cfsolve/src/deobfuscate/state_machines.rs +88 -110
- data/vendor/cfsolve/src/deobfuscate/statements.rs +228 -228
- data/vendor/cfsolve/src/deobfuscate/static_members.rs +46 -31
- data/vendor/cfsolve/src/deobfuscate/testing.rs +49 -59
- data/vendor/cfsolve/src/deobfuscate/unused_bindings.rs +92 -102
- data/vendor/cfsolve/src/deobfuscate.rs +15 -11
- data/vendor/cfsolve/src/embedding_page/extra_params.rs +23 -18
- data/vendor/cfsolve/src/embedding_page/render_sample.rs +184 -147
- data/vendor/cfsolve/src/error.rs +40 -5
- data/vendor/cfsolve/src/fingerprint.rs +8 -2
- data/vendor/cfsolve/src/http/client.rs +7 -10
- data/vendor/cfsolve/src/http/requests.rs +2 -2
- data/vendor/cfsolve/src/js/ast.rs +479 -263
- data/vendor/cfsolve/src/lib.rs +1 -0
- data/vendor/cfsolve/src/listing/fold.rs +19 -9
- data/vendor/cfsolve/src/listing/query.rs +1 -47
- data/vendor/cfsolve/src/performance_clock.rs +20 -1
- data/vendor/cfsolve/src/profiling.rs +49 -0
- data/vendor/cfsolve/src/script.rs +35 -24
- data/vendor/cfsolve/src/session/challenge_page.rs +41 -21
- data/vendor/cfsolve/src/session/channel.rs +2 -2
- data/vendor/cfsolve/src/session/initial.rs +5 -5
- data/vendor/cfsolve/src/session/sink.rs +26 -1
- data/vendor/cfsolve/src/session/tests/challenge_page.rs +36 -1
- data/vendor/cfsolve/src/session.rs +1 -1
- data/vendor/cfsolve/src/solver.rs +3 -1
- data/vendor/cfsolve/src/stage2/analysis/audit.rs +4 -2
- data/vendor/cfsolve/src/stage2/analysis/envelope.rs +2 -1
- data/vendor/cfsolve/src/stage2/audit_globals.rs +142 -74
- data/vendor/cfsolve/src/stage2/benchmark.rs +62 -31
- data/vendor/cfsolve/src/stage2/call_stack.rs +1415 -1025
- data/vendor/cfsolve/src/stage2/challenge_page.rs +3 -2
- data/vendor/cfsolve/src/stage2/interaction/checkbox.rs +202 -150
- data/vendor/cfsolve/src/stage2/interaction/click.rs +2 -2
- data/vendor/cfsolve/src/stage2/interaction/plan.rs +5 -4
- data/vendor/cfsolve/src/stage2/payload/recover.rs +2 -2
- data/vendor/cfsolve/src/stage2/probes/clock.rs +1 -3
- data/vendor/cfsolve/src/stage2/probes/performance.rs +12 -8
- data/vendor/cfsolve/src/stage2/queries.rs +50 -0
- data/vendor/cfsolve/src/stage2/syntax.rs +88 -0
- data/vendor/cfsolve/src/stage2/trace.rs +134 -108
- data/vendor/cfsolve/src/stage2/vocabulary.rs +1 -11
- data/vendor/cfsolve/src/stage2.rs +2 -0
- data/vendor/cfsolve/src/vm/disassemble.rs +7 -3
- data/vendor/cfsolve/src/vm/dispatch.rs +93 -65
- data/vendor/cfsolve/src/vm/extract.rs +347 -250
- data/vendor/cfsolve/src/vm/interpret/access.rs +63 -48
- data/vendor/cfsolve/src/vm/interpret/builtin.rs +10 -10
- data/vendor/cfsolve/src/vm/interpret/call.rs +116 -52
- data/vendor/cfsolve/src/vm/interpret/compile.rs +79 -62
- data/vendor/cfsolve/src/vm/interpret/copies.rs +2 -2
- data/vendor/cfsolve/src/vm/interpret/evaluate/tests.rs +63 -42
- data/vendor/cfsolve/src/vm/interpret/evaluate.rs +65 -575
- data/vendor/cfsolve/src/vm/interpret/explore.rs +7 -10
- data/vendor/cfsolve/src/vm/interpret/formula.rs +131 -0
- data/vendor/cfsolve/src/vm/interpret/frozen.rs +3 -5
- data/vendor/cfsolve/src/vm/interpret/intrinsic.rs +123 -59
- data/vendor/cfsolve/src/vm/interpret/mix32.rs +189 -0
- data/vendor/cfsolve/src/vm/interpret/native_dispatch.rs +220 -0
- data/vendor/cfsolve/src/vm/interpret/pattern.rs +1736 -0
- data/vendor/cfsolve/src/vm/interpret/plan.rs +586 -338
- data/vendor/cfsolve/src/vm/interpret/register_helpers.rs +384 -0
- data/vendor/cfsolve/src/vm/interpret/run.rs +116 -45
- data/vendor/cfsolve/src/vm/interpret/semantics.rs +71 -46
- data/vendor/cfsolve/src/vm/interpret/setup.rs +80 -45
- data/vendor/cfsolve/src/vm/interpret/string_decoder.rs +482 -0
- data/vendor/cfsolve/src/vm/interpret.rs +9 -1
- data/vendor/cfsolve/src/vm/machine.rs +56 -49
- data/vendor/cfsolve/src/vm/output.rs +13 -5
- data/vendor/cfsolve/src/vm/packed_names.rs +11 -7
- data/vendor/cfsolve/src/vm/session.rs +185 -120
- data/vendor/cfsolve/src/vm/value.rs +22 -19
- data/vendor/cfsolve/src/vm.rs +2 -1
- data/vendor/cfsolve/vendor/btls-sys/Cargo.toml +3 -0
- data/vendor/cfsolve/vendor/btls-sys/build/main.rs +20 -0
- metadata +94 -178
- data/THIRD_PARTY_LICENSES/Inflector-0.11.4/LICENSE.md +0 -22
- data/THIRD_PARTY_LICENSES/arrayvec-0.7.6/LICENSE-MIT +0 -25
- data/THIRD_PARTY_LICENSES/ascii-1.1.0/LICENSE-APACHE +0 -201
- data/THIRD_PARTY_LICENSES/ascii-1.1.0/LICENSE-MIT +0 -22
- data/THIRD_PARTY_LICENSES/ast_node-5.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/better_scoped_tls-1.0.1/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/bitvec-1.0.1/LICENSE.txt +0 -21
- data/THIRD_PARTY_LICENSES/bstr-1.12.1/COPYING +0 -8
- data/THIRD_PARTY_LICENSES/bstr-1.12.1/LICENSE-MIT +0 -21
- data/THIRD_PARTY_LICENSES/cargo-platform-0.1.9/LICENSE-APACHE +0 -201
- data/THIRD_PARTY_LICENSES/cargo_metadata-0.19.2/LICENSE-MIT +0 -23
- data/THIRD_PARTY_LICENSES/darling_macro-0.20.11/LICENSE +0 -21
- data/THIRD_PARTY_LICENSES/debugid-0.8.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/derive_builder-0.20.2/LICENSE-MIT +0 -21
- data/THIRD_PARTY_LICENSES/derive_builder_core-0.20.2/LICENSE-MIT +0 -21
- data/THIRD_PARTY_LICENSES/derive_builder_macro-0.20.2/LICENSE-MIT +0 -21
- data/THIRD_PARTY_LICENSES/foldhash-0.1.5/LICENSE +0 -19
- data/THIRD_PARTY_LICENSES/from_variant-3.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/funty-2.0.0/LICENSE.txt +0 -21
- data/THIRD_PARTY_LICENSES/hashbrown-0.16.1/LICENSE-MIT +0 -25
- data/THIRD_PARTY_LICENSES/heck-0.5.0/LICENSE-APACHE +0 -201
- data/THIRD_PARTY_LICENSES/hermit-abi-0.5.2/LICENSE-APACHE +0 -201
- data/THIRD_PARTY_LICENSES/hermit-abi-0.5.2/LICENSE-MIT +0 -23
- data/THIRD_PARTY_LICENSES/hstr-3.0.3/LICENSE +0 -202
- data/THIRD_PARTY_LICENSES/if_chain-1.0.3/LICENSE-APACHE +0 -201
- data/THIRD_PARTY_LICENSES/if_chain-1.0.3/LICENSE-MIT +0 -25
- data/THIRD_PARTY_LICENSES/is-macro-0.3.7/LICENSE +0 -202
- data/THIRD_PARTY_LICENSES/itoa-1.0.17/LICENSE-MIT +0 -23
- data/THIRD_PARTY_LICENSES/jsonc-parser-0.26.3/LICENSE +0 -21
- data/THIRD_PARTY_LICENSES/lazy_static-1.5.0/LICENSE-APACHE +0 -201
- data/THIRD_PARTY_LICENSES/lazy_static-1.5.0/LICENSE-MIT +0 -25
- data/THIRD_PARTY_LICENSES/lru-0.16.2/LICENSE +0 -21
- data/THIRD_PARTY_LICENSES/memchr-2.7.6/COPYING +0 -3
- data/THIRD_PARTY_LICENSES/memchr-2.7.6/LICENSE-MIT +0 -21
- data/THIRD_PARTY_LICENSES/miette-derive-7.6.0/LICENSE +0 -229
- data/THIRD_PARTY_LICENSES/normpath-0.2.0/COPYRIGHT +0 -7
- data/THIRD_PARTY_LICENSES/normpath-0.2.0/LICENSE-MIT +0 -21
- data/THIRD_PARTY_LICENSES/normpath-0.2.0/LICENSE-THIRD-PARTY +0 -210
- data/THIRD_PARTY_LICENSES/num_cpus-1.17.0/LICENSE-APACHE +0 -201
- data/THIRD_PARTY_LICENSES/num_cpus-1.17.0/LICENSE-MIT +0 -20
- data/THIRD_PARTY_LICENSES/owo-colors-4.2.3/LICENSE +0 -21
- data/THIRD_PARTY_LICENSES/par-core-2.0.0/LICENSE +0 -202
- data/THIRD_PARTY_LICENSES/par-iter-2.0.0/LICENSE +0 -202
- data/THIRD_PARTY_LICENSES/path-clean-0.1.0/LICENSE-APACHE +0 -13
- data/THIRD_PARTY_LICENSES/path-clean-0.1.0/LICENSE-MIT +0 -18
- data/THIRD_PARTY_LICENSES/path-clean-1.0.1/LICENSE-APACHE +0 -13
- data/THIRD_PARTY_LICENSES/path-clean-1.0.1/LICENSE-MIT +0 -18
- data/THIRD_PARTY_LICENSES/pathdiff-0.2.3/LICENSE-APACHE +0 -201
- data/THIRD_PARTY_LICENSES/pathdiff-0.2.3/LICENSE-MIT +0 -23
- data/THIRD_PARTY_LICENSES/petgraph-0.7.1/LICENSE-APACHE +0 -201
- data/THIRD_PARTY_LICENSES/precomputed-map-0.2.0/LICENSE +0 -21
- data/THIRD_PARTY_LICENSES/preset_env_base-6.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/radium-0.7.0/LICENSE.txt +0 -21
- data/THIRD_PARTY_LICENSES/radix_fmt-1.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/rand-0.8.5/COPYRIGHT +0 -12
- data/THIRD_PARTY_LICENSES/rand-0.8.5/LICENSE-APACHE +0 -176
- data/THIRD_PARTY_LICENSES/rand_core-0.6.4/COPYRIGHT +0 -12
- data/THIRD_PARTY_LICENSES/rand_core-0.6.4/LICENSE-APACHE +0 -187
- data/THIRD_PARTY_LICENSES/rand_core-0.6.4/LICENSE-MIT +0 -26
- data/THIRD_PARTY_LICENSES/regress-0.10.5/LICENSE-APACHE +0 -201
- data/THIRD_PARTY_LICENSES/regress-0.10.5/LICENSE-MIT +0 -21
- data/THIRD_PARTY_LICENSES/ryu-1.0.22/LICENSE-APACHE +0 -176
- data/THIRD_PARTY_LICENSES/ryu-1.0.22/LICENSE-BOOST +0 -23
- data/THIRD_PARTY_LICENSES/scoped-tls-1.0.1/LICENSE-APACHE +0 -201
- data/THIRD_PARTY_LICENSES/scoped-tls-1.0.1/LICENSE-MIT +0 -25
- data/THIRD_PARTY_LICENSES/siphasher-0.3.11/COPYING +0 -7
- data/THIRD_PARTY_LICENSES/smallvec-1.15.1/LICENSE-APACHE +0 -201
- data/THIRD_PARTY_LICENSES/smartstring-1.0.1/LICENCE.md +0 -355
- data/THIRD_PARTY_LICENSES/st-map-0.2.4/LICENSE +0 -202
- data/THIRD_PARTY_LICENSES/static-map-macro-0.3.4/LICENSE +0 -202
- data/THIRD_PARTY_LICENSES/string_enum-1.0.2/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/strsim-0.11.1/LICENSE +0 -23
- data/THIRD_PARTY_LICENSES/swc-52.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_allocator-4.0.1/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_atoms-9.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_common-18.0.1/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_compiler_base-45.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_config-3.1.2/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_config_macro-1.0.1/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_core-54.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_ecma_ast-19.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_ecma_codegen-21.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_ecma_codegen_macros-2.0.2/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_ecma_compat_bugfixes-39.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_ecma_compat_common-30.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_ecma_compat_es2015-39.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_ecma_compat_es2016-35.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_ecma_compat_es2017-35.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_ecma_compat_es2018-36.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_ecma_compat_es2019-35.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_ecma_compat_es2020-37.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_ecma_compat_es2021-35.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_ecma_compat_es2022-37.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_ecma_compat_es3-26.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_ecma_ext_transforms-25.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_ecma_hooks-0.3.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_ecma_loader-18.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_ecma_minifier-42.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_ecma_parser-32.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_ecma_preset_env-45.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_ecma_transformer-6.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_ecma_transforms-44.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_ecma_transforms_base-35.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_ecma_transforms_classes-35.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_ecma_transforms_compat-40.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_ecma_transforms_macros-1.0.1/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_ecma_transforms_module-38.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_ecma_transforms_optimization-37.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_ecma_transforms_proposal-35.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_ecma_transforms_react-38.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_ecma_transforms_typescript-38.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_ecma_usage_analyzer-27.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_ecma_utils-25.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_ecma_visit-19.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_eq_ignore_macros-1.0.1/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_error_reporters-20.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_macros_common-1.0.1/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_node_comments-18.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_timer-1.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_trace_macro-2.0.2/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_transform_common-12.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_visit-2.0.1/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/tap-1.0.1/LICENSE.txt +0 -21
- data/THIRD_PARTY_LICENSES/tracing-0.1.44/LICENSE +0 -25
- data/THIRD_PARTY_LICENSES/tracing-attributes-0.1.31/LICENSE +0 -25
- data/THIRD_PARTY_LICENSES/tracing-core-0.1.36/LICENSE +0 -25
- data/THIRD_PARTY_LICENSES/triomphe-0.1.15/LICENSE-APACHE +0 -201
- data/THIRD_PARTY_LICENSES/triomphe-0.1.15/LICENSE-MIT +0 -27
- data/THIRD_PARTY_LICENSES/unicode-width-0.1.14/LICENSE-APACHE +0 -201
- data/THIRD_PARTY_LICENSES/unicode-width-0.1.14/LICENSE-MIT +0 -25
- data/THIRD_PARTY_LICENSES/uuid-1.19.0/LICENSE-APACHE +0 -201
- data/THIRD_PARTY_LICENSES/uuid-1.19.0/LICENSE-MIT +0 -26
- data/THIRD_PARTY_LICENSES/vergen-9.0.6/LICENSE-APACHE +0 -201
- data/THIRD_PARTY_LICENSES/vergen-9.0.6/LICENSE-MIT +0 -25
- data/THIRD_PARTY_LICENSES/vergen-lib-0.1.6/LICENSE-APACHE +0 -201
- data/THIRD_PARTY_LICENSES/vergen-lib-0.1.6/LICENSE-MIT +0 -25
- data/THIRD_PARTY_LICENSES/wyz-0.5.1/LICENSE.txt +0 -21
- data/vendor/cfsolve/src/deobfuscate/analysis/globals.rs +0 -33
- data/vendor/cfsolve/src/deobfuscate/analysis/names.rs +0 -52
- /data/THIRD_PARTY_LICENSES/{derive_builder-0.20.2 → cobs-0.3.0}/LICENSE-APACHE +0 -0
- /data/THIRD_PARTY_LICENSES/{compact_str-0.7.1 → compact_str-0.10.0}/LICENSE +0 -0
- /data/THIRD_PARTY_LICENSES/{ahash-0.8.12 → embedded-io-0.4.0}/LICENSE-APACHE +0 -0
- /data/THIRD_PARTY_LICENSES/{arrayvec-0.7.6 → embedded-io-0.6.1}/LICENSE-APACHE +0 -0
- /data/THIRD_PARTY_LICENSES/{normpath-0.2.0 → escape-simd-0.1.1}/LICENSE-APACHE +0 -0
- /data/THIRD_PARTY_LICENSES/{bstr-1.12.1 → itertools-0.15.0}/LICENSE-APACHE +0 -0
- /data/THIRD_PARTY_LICENSES/{petgraph-0.7.1 → itertools-0.15.0}/LICENSE-MIT +0 -0
- /data/THIRD_PARTY_LICENSES/{itoa-1.0.17 → itoa-1.0.19}/LICENSE-APACHE +0 -0
- /data/THIRD_PARTY_LICENSES/{camino-1.2.2 → itoa-1.0.19}/LICENSE-MIT +0 -0
- /data/THIRD_PARTY_LICENSES/{globset-0.4.18 → memchr-2.8.3}/COPYING +0 -0
- /data/THIRD_PARTY_LICENSES/{globset-0.4.18 → memchr-2.8.3}/LICENSE-MIT +0 -0
- /data/THIRD_PARTY_LICENSES/{camino-1.2.2 → num-bigint-0.5.1}/LICENSE-APACHE +0 -0
- /data/THIRD_PARTY_LICENSES/{swc_sourcemap-9.3.4 → oxc_sourcemap-9.0.0}/LICENSE +0 -0
- /data/THIRD_PARTY_LICENSES/{phf-0.11.3 → phf-0.14.0}/LICENSE +0 -0
- /data/THIRD_PARTY_LICENSES/{phf_generator-0.11.3 → phf_generator-0.14.0}/LICENSE +0 -0
- /data/THIRD_PARTY_LICENSES/{phf_macros-0.11.3 → phf_macros-0.14.0}/LICENSE +0 -0
- /data/THIRD_PARTY_LICENSES/{phf_shared-0.11.3 → phf_shared-0.14.0}/LICENSE +0 -0
- /data/THIRD_PARTY_LICENSES/{fixedbitset-0.5.7 → postcard-1.1.3}/LICENSE-APACHE +0 -0
- /data/THIRD_PARTY_LICENSES/{hashbrown-0.14.5 → smallvec-1.16.5}/LICENSE-APACHE +0 -0
- /data/THIRD_PARTY_LICENSES/{smallvec-1.15.1 → smallvec-1.16.5}/LICENSE-MIT +0 -0
- /data/THIRD_PARTY_LICENSES/{unicode-width-0.1.14 → unicode-segmentation-1.13.3}/COPYRIGHT +0 -0
- /data/THIRD_PARTY_LICENSES/{hashbrown-0.16.1 → unicode-segmentation-1.13.3}/LICENSE-APACHE +0 -0
- /data/THIRD_PARTY_LICENSES/{heck-0.5.0 → unicode-segmentation-1.13.3}/LICENSE-MIT +0 -0
- /data/THIRD_PARTY_LICENSES/{cargo-platform-0.1.9 → zmij_ecma-1.0.23}/LICENSE-MIT +0 -0
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
use std::borrow::Cow;
|
|
4
4
|
use std::rc::Rc;
|
|
5
5
|
|
|
6
|
-
use
|
|
6
|
+
use oxc::syntax::operator::BinaryOperator;
|
|
7
7
|
|
|
8
8
|
use super::builtin::{self, Builtin};
|
|
9
9
|
use super::run::{Evaluation, Run, Stop};
|
|
@@ -58,11 +58,31 @@ impl<'key> Key<'key, '_> {
|
|
|
58
58
|
/// The key as property-name text (see [`semantics::property_key`]).
|
|
59
59
|
pub(super) fn property(&self) -> Option<String> {
|
|
60
60
|
match self {
|
|
61
|
-
Self::Name(name) => Some(name.
|
|
61
|
+
Self::Name(name) => Some(name.to_string()),
|
|
62
62
|
Self::Value(value) => semantics::property_key(value),
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
+
/// Calls `visit` with the property-name text (see [`Self::property`]), without allocating
|
|
67
|
+
/// for names and small integers, the usual keys of object lookups.
|
|
68
|
+
fn with_property<R>(&self, visit: impl FnOnce(&str) -> R) -> Option<R> {
|
|
69
|
+
match self {
|
|
70
|
+
Self::Name(name) => Some(visit(name)),
|
|
71
|
+
// Integers below 10^15 are exact in i64 and print as plain digits; -0 prints as 0.
|
|
72
|
+
Self::Value(Value::Number(number)) if number.fract() == 0.0 && number.abs() < 1e15 => {
|
|
73
|
+
use std::io::Write;
|
|
74
|
+
|
|
75
|
+
let mut buffer = [0; 20];
|
|
76
|
+
let mut unwritten = &mut buffer[..];
|
|
77
|
+
write!(unwritten, "{}", *number as i64).expect("20 bytes hold any i64");
|
|
78
|
+
let length = 20 - unwritten.len();
|
|
79
|
+
let text = std::str::from_utf8(&buffer[..length]).expect("digits are ASCII");
|
|
80
|
+
Some(visit(text))
|
|
81
|
+
}
|
|
82
|
+
Self::Value(value) => semantics::property_key(value).map(|name| visit(&name)),
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
66
86
|
fn expr(&self) -> Term {
|
|
67
87
|
match self {
|
|
68
88
|
Self::Name(name) => Term::Const(Constant::String(name.clone().into_owned())),
|
|
@@ -178,24 +198,21 @@ impl<'ast> Run<'ast, '_> {
|
|
|
178
198
|
(None, Some(_)) => Value::Undefined,
|
|
179
199
|
_ => return Err(unsupported("string member", key)),
|
|
180
200
|
},
|
|
181
|
-
Value::Object(properties) =>
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
Some(method) => method,
|
|
197
|
-
None => return Err(unsupported("set member", key)),
|
|
198
|
-
},
|
|
201
|
+
Value::Object(properties) => key
|
|
202
|
+
.with_property(|name| {
|
|
203
|
+
properties
|
|
204
|
+
.borrow()
|
|
205
|
+
.iter()
|
|
206
|
+
.find(|(key, _)| key == name)
|
|
207
|
+
.map_or(Value::Undefined, |(_, value)| value.clone())
|
|
208
|
+
})
|
|
209
|
+
.ok_or_else(|| unsupported("object key", key))?,
|
|
210
|
+
Value::Map(_) => name
|
|
211
|
+
.and_then(|name| builtin::method("Map.prototype", name))
|
|
212
|
+
.ok_or_else(|| unsupported("map member", key))?,
|
|
213
|
+
Value::Set(_) => name
|
|
214
|
+
.and_then(|name| builtin::method("Set.prototype", name))
|
|
215
|
+
.ok_or_else(|| unsupported("set member", key))?,
|
|
199
216
|
Value::Function(function) => match (&**function, name) {
|
|
200
217
|
(_, Some("call")) => Value::function(Callable::Call(object.clone())),
|
|
201
218
|
(_, Some("apply")) => Value::function(Callable::Apply(object.clone())),
|
|
@@ -211,10 +228,8 @@ impl<'ast> Run<'ast, '_> {
|
|
|
211
228
|
_ => Value::symbolic(Term::Get(Box::new((**expr).clone()), Box::new(key.expr()))),
|
|
212
229
|
},
|
|
213
230
|
Value::Undefined | Value::Null => {
|
|
214
|
-
let
|
|
215
|
-
return Err(Stop::throw(Value::string(&
|
|
216
|
-
"TypeError: reading {key}"
|
|
217
|
-
))));
|
|
231
|
+
let error = format!("TypeError: reading {}", key.expr());
|
|
232
|
+
return Err(Stop::throw(Value::string(&error)));
|
|
218
233
|
}
|
|
219
234
|
Value::Bool(_) | Value::Number(_) | Value::Symbol(_) => {
|
|
220
235
|
return Err(unsupported("member of a primitive", key));
|
|
@@ -303,17 +318,19 @@ impl<'ast> Run<'ast, '_> {
|
|
|
303
318
|
elements[index] = value;
|
|
304
319
|
}
|
|
305
320
|
Value::Object(properties) => {
|
|
306
|
-
let
|
|
307
|
-
.
|
|
321
|
+
let existing = key
|
|
322
|
+
.with_property(|name| {
|
|
323
|
+
properties
|
|
324
|
+
.borrow()
|
|
325
|
+
.iter()
|
|
326
|
+
.position(|(existing, _)| existing == name)
|
|
327
|
+
})
|
|
308
328
|
.ok_or_else(|| unsupported("object key", key))?;
|
|
309
329
|
self.writable(object)?;
|
|
310
330
|
let mut properties = properties.borrow_mut();
|
|
311
|
-
match
|
|
312
|
-
|
|
313
|
-
.
|
|
314
|
-
{
|
|
315
|
-
Some((_, slot)) => *slot = value,
|
|
316
|
-
None => properties.push((name, value)),
|
|
331
|
+
match existing {
|
|
332
|
+
Some(index) => properties[index].1 = value,
|
|
333
|
+
None => properties.push((key.property().expect("the key has a name"), value)),
|
|
317
334
|
}
|
|
318
335
|
}
|
|
319
336
|
Value::Symbolic(_) | Value::Namespace(_) => self.effects.push(Effect::SetProperty {
|
|
@@ -322,10 +339,8 @@ impl<'ast> Run<'ast, '_> {
|
|
|
322
339
|
value: Box::new(value.expr()),
|
|
323
340
|
}),
|
|
324
341
|
Value::Undefined | Value::Null => {
|
|
325
|
-
let
|
|
326
|
-
return Err(Stop::throw(Value::string(&
|
|
327
|
-
"TypeError: setting {key}"
|
|
328
|
-
))));
|
|
342
|
+
let error = format!("TypeError: setting {}", key.expr());
|
|
343
|
+
return Err(Stop::throw(Value::string(&error)));
|
|
329
344
|
}
|
|
330
345
|
_ => return Err(unsupported("setting a member", key)),
|
|
331
346
|
}
|
|
@@ -351,9 +366,6 @@ impl<'ast> Run<'ast, '_> {
|
|
|
351
366
|
|
|
352
367
|
/// Decrypts a string record using the same logic as the register file's `read` method.
|
|
353
368
|
fn decrypted(&mut self, record: Value<'ast>) -> Evaluation<'ast, Value<'ast>> {
|
|
354
|
-
if !matches!(record, Value::Array(_)) {
|
|
355
|
-
return Ok(record);
|
|
356
|
-
}
|
|
357
369
|
let decoder = self
|
|
358
370
|
.session
|
|
359
371
|
.record_decoder
|
|
@@ -394,27 +406,30 @@ impl<'ast> Run<'ast, '_> {
|
|
|
394
406
|
/// Parses a canonical numeric property key so `a["0"]` matches `a[0]`. Noncanonical strings
|
|
395
407
|
/// such as `"01"` and `"-0"` remain named properties.
|
|
396
408
|
fn key_index(name: &str) -> Option<f64> {
|
|
397
|
-
use swc_ecma_utils::number::ToJsString;
|
|
398
|
-
|
|
399
409
|
// Most property keys are names rather than numeric strings.
|
|
400
410
|
let first = name.bytes().next()?;
|
|
401
411
|
if !(first.is_ascii_digit() || matches!(first, b'-' | b'I' | b'N')) {
|
|
402
412
|
return None;
|
|
403
413
|
}
|
|
404
414
|
let number = js::string_number(name);
|
|
405
|
-
(number
|
|
415
|
+
(semantics::number_text(number) == name).then_some(number)
|
|
406
416
|
}
|
|
407
417
|
|
|
408
418
|
/// Decodes `value` stored with `tag`, matching the value returned by the register reader.
|
|
409
419
|
fn stored(tag: Stored, value: Value<'_>) -> Value<'_> {
|
|
410
420
|
match tag {
|
|
411
|
-
Stored::Integer(upper) =>
|
|
412
|
-
|
|
413
|
-
|
|
421
|
+
Stored::Integer(upper) => semantics::binary_value(
|
|
422
|
+
BinaryOperator::BitwiseXOR,
|
|
423
|
+
Value::Number(f64::from(upper)),
|
|
424
|
+
value,
|
|
425
|
+
),
|
|
414
426
|
Stored::Boolean(upper) => {
|
|
415
|
-
let bits =
|
|
416
|
-
|
|
417
|
-
|
|
427
|
+
let bits = semantics::binary_value(
|
|
428
|
+
BinaryOperator::BitwiseXOR,
|
|
429
|
+
value,
|
|
430
|
+
Value::Number(f64::from(upper)),
|
|
431
|
+
);
|
|
432
|
+
semantics::binary_value(BinaryOperator::StrictInequality, bits, Value::Number(0.0))
|
|
418
433
|
}
|
|
419
434
|
Stored::Plain | Stored::Record => value,
|
|
420
435
|
}
|
|
@@ -3,8 +3,6 @@
|
|
|
3
3
|
use std::cell::RefCell;
|
|
4
4
|
use std::rc::Rc;
|
|
5
5
|
|
|
6
|
-
use swc_ecma_utils::number::JsNumber;
|
|
7
|
-
|
|
8
6
|
use super::access::Key;
|
|
9
7
|
use super::run::{Evaluation, Run, Stop};
|
|
10
8
|
use super::semantics;
|
|
@@ -246,9 +244,7 @@ impl<'ast> Run<'ast, '_> {
|
|
|
246
244
|
Builtin::Pow => {
|
|
247
245
|
let values = numbers()?;
|
|
248
246
|
let value = |index: usize| values.get(index).copied().unwrap_or(f64::NAN);
|
|
249
|
-
Ok(Value::Number(
|
|
250
|
-
*JsNumber::from(value(0)).pow(value(1).into()),
|
|
251
|
-
))
|
|
247
|
+
Ok(Value::Number(semantics::exponentiate(value(0), value(1))))
|
|
252
248
|
}
|
|
253
249
|
Builtin::Floor => {
|
|
254
250
|
let value = numbers()?.first().copied().unwrap_or(f64::NAN);
|
|
@@ -573,10 +569,11 @@ const STATIC_FUNCTIONS: &[&str] = &[
|
|
|
573
569
|
|
|
574
570
|
#[cfg(test)]
|
|
575
571
|
mod tests {
|
|
576
|
-
use
|
|
572
|
+
use oxc::syntax::operator::BinaryOperator;
|
|
577
573
|
|
|
578
574
|
use super::super::{Run, semantics};
|
|
579
575
|
use super::*;
|
|
576
|
+
use crate::js::ast::ParsedScript;
|
|
580
577
|
use crate::vm::session::Session;
|
|
581
578
|
|
|
582
579
|
fn number(value: Evaluation<'_, Value<'_>>) -> f64 {
|
|
@@ -588,7 +585,8 @@ mod tests {
|
|
|
588
585
|
|
|
589
586
|
#[test]
|
|
590
587
|
fn math_follows_javascript() {
|
|
591
|
-
let
|
|
588
|
+
let parsed = ParsedScript::parse("t", "").expect("an empty script parses");
|
|
589
|
+
let session = Session::empty(parsed.script());
|
|
592
590
|
let mut run = Run::method(&session);
|
|
593
591
|
let mut call = |builtin, arguments: &[f64]| {
|
|
594
592
|
let arguments = arguments.iter().copied().map(Value::Number).collect();
|
|
@@ -607,7 +605,8 @@ mod tests {
|
|
|
607
605
|
/// removal.
|
|
608
606
|
#[test]
|
|
609
607
|
fn a_set_keeps_each_member_once() {
|
|
610
|
-
let
|
|
608
|
+
let parsed = ParsedScript::parse("t", "").expect("an empty script parses");
|
|
609
|
+
let session = Session::empty(parsed.script());
|
|
611
610
|
let mut run = Run::method(&session);
|
|
612
611
|
let source = [1.0, 1.0, f64::NAN, f64::NAN, 0.0, -0.0].map(Value::Number);
|
|
613
612
|
let mut source = source.to_vec();
|
|
@@ -676,7 +675,8 @@ mod tests {
|
|
|
676
675
|
/// `charCodeAt` operate on code units, and a string with a lone surrogate prints as units.
|
|
677
676
|
#[test]
|
|
678
677
|
fn strings_are_code_units() {
|
|
679
|
-
let
|
|
678
|
+
let parsed = ParsedScript::parse("t", "").expect("an empty script parses");
|
|
679
|
+
let session = Session::empty(parsed.script());
|
|
680
680
|
let mut run = Run::method(&session);
|
|
681
681
|
let mut call = |builtin: Builtin, this, arguments| {
|
|
682
682
|
let Ok(value) = run.builtin(builtin, this, arguments) else {
|
|
@@ -707,7 +707,7 @@ mod tests {
|
|
|
707
707
|
});
|
|
708
708
|
let sum = halves
|
|
709
709
|
.into_iter()
|
|
710
|
-
.reduce(|left, right| semantics::binary_value(
|
|
710
|
+
.reduce(|left, right| semantics::binary_value(BinaryOperator::Addition, left, right))
|
|
711
711
|
.expect("there are four halves");
|
|
712
712
|
for string in [joined, sum] {
|
|
713
713
|
let text = semantics::text(&string).and_then(|text| text.text());
|
|
@@ -2,23 +2,27 @@
|
|
|
2
2
|
|
|
3
3
|
use std::ptr;
|
|
4
4
|
|
|
5
|
-
use
|
|
6
|
-
|
|
5
|
+
use oxc::ast::ast::{
|
|
6
|
+
ArrowFunctionExpression, FormalParameters, Function, Statement, VariableDeclaration,
|
|
7
|
+
};
|
|
7
8
|
|
|
8
9
|
use super::access::Key;
|
|
9
|
-
use super::
|
|
10
|
-
use super::{
|
|
11
|
-
use
|
|
10
|
+
use super::intrinsic::{self, Intrinsic};
|
|
11
|
+
use super::plan::{self, Routine};
|
|
12
|
+
use super::run::{CallScope, Evaluation, Frame, RecordKey, RecordPart, Run, Stop};
|
|
13
|
+
use crate::js::ast::Binding;
|
|
14
|
+
use crate::profiling;
|
|
12
15
|
use crate::vm::output::Term;
|
|
13
16
|
use crate::vm::value::{Callable, Env, Scope, Value};
|
|
17
|
+
use crate::vm::{HashMap, extract};
|
|
14
18
|
|
|
15
19
|
impl<'ast> Run<'ast, '_> {
|
|
16
20
|
/// Creates a function capturing its current scope, such as a closure factory's machine and
|
|
17
21
|
/// layout.
|
|
18
22
|
pub(super) fn function_value(
|
|
19
23
|
&mut self,
|
|
20
|
-
name: Option
|
|
21
|
-
function: &'ast Function
|
|
24
|
+
name: Option<&'ast str>,
|
|
25
|
+
function: &'ast Function<'ast>,
|
|
22
26
|
) -> Value<'ast> {
|
|
23
27
|
Value::function(Callable::Script {
|
|
24
28
|
name,
|
|
@@ -28,7 +32,10 @@ impl<'ast> Run<'ast, '_> {
|
|
|
28
32
|
}
|
|
29
33
|
|
|
30
34
|
/// Creates an arrow function capturing both the current scope and `this`.
|
|
31
|
-
pub(super) fn arrow_value(
|
|
35
|
+
pub(super) fn arrow_value(
|
|
36
|
+
&mut self,
|
|
37
|
+
arrow: &'ast ArrowFunctionExpression<'ast>,
|
|
38
|
+
) -> Value<'ast> {
|
|
32
39
|
let this = self.frame().this.clone();
|
|
33
40
|
let scope = Some(self.closure_scope());
|
|
34
41
|
Value::function(Callable::Arrow { arrow, this, scope })
|
|
@@ -105,6 +112,14 @@ impl<'ast> Run<'ast, '_> {
|
|
|
105
112
|
this: Value<'ast>,
|
|
106
113
|
mut arguments: Vec<Value<'ast>>,
|
|
107
114
|
) -> Evaluation<'ast, Value<'ast>> {
|
|
115
|
+
if let Callable::Script { function, .. } = callable
|
|
116
|
+
&& let Some(&intrinsic) = self.session.intrinsics.get(&intrinsic::address(function))
|
|
117
|
+
&& let Some(value) = intrinsic.call(self, &arguments)
|
|
118
|
+
{
|
|
119
|
+
arguments.clear();
|
|
120
|
+
self.spare.arguments.push(arguments);
|
|
121
|
+
return Ok(value);
|
|
122
|
+
}
|
|
108
123
|
match callable {
|
|
109
124
|
// Evaluate helpers with symbolic arguments when their control flow can be followed,
|
|
110
125
|
// such as validation or forwarding wrappers. Record an unresolved call otherwise,
|
|
@@ -118,7 +133,7 @@ impl<'ast> Run<'ast, '_> {
|
|
|
118
133
|
// containers can change during it, so calls without them are kept (`Err`) and
|
|
119
134
|
// recorded only when the attempt fails.
|
|
120
135
|
let call = |arguments: &[Value<'ast>]| Term::Call {
|
|
121
|
-
callee: Box::new(Term::Global(name.
|
|
136
|
+
callee: Box::new(Term::Global((*name).to_owned())),
|
|
122
137
|
this: None,
|
|
123
138
|
arguments: arguments.iter().map(Value::expr).collect(),
|
|
124
139
|
};
|
|
@@ -144,13 +159,19 @@ impl<'ast> Run<'ast, '_> {
|
|
|
144
159
|
function, scope, ..
|
|
145
160
|
} => self.script(function, scope.as_ref(), this, arguments),
|
|
146
161
|
Callable::Arrow { arrow, this, scope } => {
|
|
147
|
-
let locals = parameters(arrow.params
|
|
162
|
+
let locals = parameters(&arrow.params, arguments, 0)?;
|
|
148
163
|
let scope = self.call_scope(locals, scope.as_ref());
|
|
149
|
-
let
|
|
164
|
+
let script = self.session.script;
|
|
165
|
+
let body = self
|
|
166
|
+
.session
|
|
167
|
+
.compiled
|
|
168
|
+
.scoped(ptr::from_ref(*arrow).addr(), || {
|
|
169
|
+
plan::scoped_arrow(script, arrow)
|
|
170
|
+
});
|
|
150
171
|
self.body(
|
|
151
172
|
Frame {
|
|
152
173
|
this: this.clone(),
|
|
153
|
-
scope,
|
|
174
|
+
scope: CallScope::Own(scope),
|
|
154
175
|
},
|
|
155
176
|
&body,
|
|
156
177
|
&mut [],
|
|
@@ -193,31 +214,48 @@ impl<'ast> Run<'ast, '_> {
|
|
|
193
214
|
this,
|
|
194
215
|
arguments: bound,
|
|
195
216
|
} => {
|
|
196
|
-
let all: Vec<Value<'ast>> =
|
|
197
|
-
|
|
198
|
-
|
|
217
|
+
let all: Vec<Value<'ast>> = if bound.is_empty() {
|
|
218
|
+
arguments
|
|
219
|
+
} else {
|
|
220
|
+
bound.iter().cloned().chain(arguments).collect()
|
|
199
221
|
};
|
|
200
222
|
self.apply(target.clone(), this.clone(), all)
|
|
201
223
|
}
|
|
202
224
|
}
|
|
203
225
|
}
|
|
204
226
|
|
|
205
|
-
/// Calls a script function
|
|
206
|
-
/// from the program's cache if it decrypts a string record decrypted before, or else
|
|
207
|
-
/// interpreted.
|
|
227
|
+
/// Calls a script function, timing it when profiling.
|
|
208
228
|
pub(super) fn script(
|
|
209
229
|
&mut self,
|
|
210
|
-
function: &'ast Function
|
|
230
|
+
function: &'ast Function<'ast>,
|
|
231
|
+
scope: Option<&Scope<'ast>>,
|
|
232
|
+
this: Value<'ast>,
|
|
233
|
+
arguments: Vec<Value<'ast>>,
|
|
234
|
+
) -> Evaluation<'ast, Value<'ast>> {
|
|
235
|
+
let started = profiling::start();
|
|
236
|
+
let result = self.run_script(function, scope, this, arguments);
|
|
237
|
+
profiling::record(started, || format!("function@{}", function.span.start));
|
|
238
|
+
result
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/// Calls a script function: natively if it computes BLAKE3 compression on arguments the
|
|
242
|
+
/// native version accepts, from the program's cache if it decrypts a string record decrypted
|
|
243
|
+
/// before, or else interpreted.
|
|
244
|
+
fn run_script(
|
|
245
|
+
&mut self,
|
|
246
|
+
function: &'ast Function<'ast>,
|
|
211
247
|
scope: Option<&Scope<'ast>>,
|
|
212
248
|
this: Value<'ast>,
|
|
213
249
|
arguments: Vec<Value<'ast>>,
|
|
214
250
|
) -> Evaluation<'ast, Value<'ast>> {
|
|
215
|
-
if let Some(
|
|
251
|
+
if let Some(Intrinsic::Blake3Compress) =
|
|
252
|
+
self.session.intrinsics.get(&intrinsic::address(function))
|
|
253
|
+
{
|
|
216
254
|
// Intrinsics may write to their arguments.
|
|
217
255
|
for argument in &arguments {
|
|
218
256
|
self.writable(argument)?;
|
|
219
257
|
}
|
|
220
|
-
if let Some(value) = intrinsic
|
|
258
|
+
if let Some(value) = intrinsic::blake3_compress(&arguments) {
|
|
221
259
|
return Ok(value);
|
|
222
260
|
}
|
|
223
261
|
}
|
|
@@ -233,7 +271,15 @@ impl<'ast> Run<'ast, '_> {
|
|
|
233
271
|
if let Some(text) = decrypted.borrow().get(&key) {
|
|
234
272
|
return Ok(text.clone());
|
|
235
273
|
}
|
|
236
|
-
let
|
|
274
|
+
let native = self
|
|
275
|
+
.session
|
|
276
|
+
.string_decoder
|
|
277
|
+
.as_ref()
|
|
278
|
+
.and_then(|decoder| decoder.decrypt(self, record));
|
|
279
|
+
let text = match native {
|
|
280
|
+
Some(text) => text,
|
|
281
|
+
None => self.interpret(function, scope, this, arguments)?,
|
|
282
|
+
};
|
|
237
283
|
// A run that thawed a shared object may have computed the text differently.
|
|
238
284
|
if matches!(text, Value::String(_)) && !self.thawed {
|
|
239
285
|
decrypted.borrow_mut().insert(key, text.clone());
|
|
@@ -243,34 +289,50 @@ impl<'ast> Run<'ast, '_> {
|
|
|
243
289
|
self.interpret(function, scope, this, arguments)
|
|
244
290
|
}
|
|
245
291
|
|
|
246
|
-
/// Runs a function through its
|
|
292
|
+
/// Runs a function through its routine (see [`Run::routine`]).
|
|
247
293
|
fn interpret(
|
|
248
294
|
&mut self,
|
|
249
|
-
function: &'ast Function
|
|
295
|
+
function: &'ast Function<'ast>,
|
|
296
|
+
scope: Option<&Scope<'ast>>,
|
|
297
|
+
this: Value<'ast>,
|
|
298
|
+
arguments: Vec<Value<'ast>>,
|
|
299
|
+
) -> Evaluation<'ast, Value<'ast>> {
|
|
300
|
+
let routine =
|
|
301
|
+
Routine::function(function).ok_or_else(|| Stop::unsupported("declared function"))?;
|
|
302
|
+
self.routine(routine, scope, this, arguments)
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
/// Runs a routine through its slot plan if it has one, or else through its scoped plan.
|
|
306
|
+
pub(super) fn routine(
|
|
307
|
+
&mut self,
|
|
308
|
+
routine: Routine<'ast>,
|
|
250
309
|
scope: Option<&Scope<'ast>>,
|
|
251
310
|
this: Value<'ast>,
|
|
252
311
|
arguments: Vec<Value<'ast>>,
|
|
253
312
|
) -> Evaluation<'ast, Value<'ast>> {
|
|
313
|
+
let script = self.session.script;
|
|
254
314
|
if self.setup.is_none()
|
|
255
|
-
&& let Some(plan) = self.session.compiled.slots(
|
|
315
|
+
&& let Some(plan) = self.session.compiled.slots(script, routine)
|
|
256
316
|
{
|
|
257
317
|
return self.call_plan(&plan, scope, this, arguments);
|
|
258
318
|
}
|
|
259
|
-
let body = function
|
|
260
|
-
.body
|
|
261
|
-
.as_ref()
|
|
262
|
-
.ok_or_else(|| Stop::unsupported("declared function"))?;
|
|
263
|
-
let patterns = function.params.iter().map(|parameter| ¶meter.pat);
|
|
264
319
|
let all = Value::array(arguments.clone());
|
|
265
320
|
// Room for `arguments` and the variables the body declares.
|
|
266
|
-
let mut locals = parameters(
|
|
267
|
-
locals.insert(
|
|
321
|
+
let mut locals = parameters(routine.parameters, arguments, 1 + declared(routine))?;
|
|
322
|
+
locals.insert(Binding::Global("arguments"), all);
|
|
268
323
|
let scope = self.call_scope(locals, scope);
|
|
269
324
|
let body = self
|
|
270
325
|
.session
|
|
271
326
|
.compiled
|
|
272
|
-
.scoped(
|
|
273
|
-
self.body(
|
|
327
|
+
.scoped(routine.address, || plan::scoped_routine(script, routine));
|
|
328
|
+
self.body(
|
|
329
|
+
Frame {
|
|
330
|
+
this,
|
|
331
|
+
scope: CallScope::Own(scope),
|
|
332
|
+
},
|
|
333
|
+
&body,
|
|
334
|
+
&mut [],
|
|
335
|
+
)
|
|
274
336
|
}
|
|
275
337
|
|
|
276
338
|
/// Creates a call scope with `locals`, nested in the function's captured scope. Functions
|
|
@@ -278,7 +340,7 @@ impl<'ast> Run<'ast, '_> {
|
|
|
278
340
|
/// afterward. Unresolved names fall back to session bindings.
|
|
279
341
|
fn call_scope(
|
|
280
342
|
&self,
|
|
281
|
-
locals: HashMap<
|
|
343
|
+
locals: HashMap<Binding<'ast>, Value<'ast>>,
|
|
282
344
|
closed: Option<&Scope<'ast>>,
|
|
283
345
|
) -> Scope<'ast> {
|
|
284
346
|
let outer = closed.or(self.setup.as_ref()).cloned();
|
|
@@ -330,31 +392,33 @@ fn record_key(record: &Value<'_>) -> Option<RecordKey> {
|
|
|
330
392
|
}
|
|
331
393
|
|
|
332
394
|
/// Binds call arguments to parameters and reserves `room` additional local slots.
|
|
333
|
-
fn parameters<'ast
|
|
334
|
-
|
|
395
|
+
fn parameters<'ast>(
|
|
396
|
+
parameters: &FormalParameters<'_>,
|
|
335
397
|
arguments: Vec<Value<'ast>>,
|
|
336
398
|
room: usize,
|
|
337
|
-
) -> Evaluation<'ast, HashMap<
|
|
399
|
+
) -> Evaluation<'ast, HashMap<Binding<'ast>, Value<'ast>>> {
|
|
400
|
+
let names =
|
|
401
|
+
extract::parameters(parameters).ok_or_else(|| Stop::unsupported("a parameter pattern"))?;
|
|
338
402
|
let mut arguments = arguments.into_iter();
|
|
339
|
-
let capacity =
|
|
403
|
+
let capacity = names.len() + room;
|
|
340
404
|
let mut locals = HashMap::with_capacity_and_hasher(capacity, Default::default());
|
|
341
|
-
for
|
|
342
|
-
let Pat::Ident(name) = pattern else {
|
|
343
|
-
return Err(Stop::unsupported("a parameter pattern"));
|
|
344
|
-
};
|
|
405
|
+
for name in names {
|
|
345
406
|
let argument = arguments.next().unwrap_or(Value::Undefined);
|
|
346
|
-
locals.insert(name.
|
|
407
|
+
locals.insert(Binding::Symbol(name.symbol_id()), argument);
|
|
347
408
|
}
|
|
348
409
|
Ok(locals)
|
|
349
410
|
}
|
|
350
411
|
|
|
351
|
-
/// Counts top-level
|
|
352
|
-
fn declared(
|
|
353
|
-
|
|
412
|
+
/// Counts top-level variable declarations in `routine` to reserve local storage for a call.
|
|
413
|
+
fn declared(routine: Routine<'_>) -> usize {
|
|
414
|
+
let count = |declaration: &VariableDeclaration<'_>| declaration.declarations.len();
|
|
415
|
+
let statements = routine.statements.iter().map(|statement| match statement {
|
|
416
|
+
Statement::VariableDeclaration(declaration) => count(declaration),
|
|
417
|
+
_ => 0,
|
|
418
|
+
});
|
|
419
|
+
let declarations = routine
|
|
420
|
+
.declarations
|
|
354
421
|
.iter()
|
|
355
|
-
.map(|
|
|
356
|
-
|
|
357
|
-
_ => 0,
|
|
358
|
-
})
|
|
359
|
-
.sum()
|
|
422
|
+
.map(|declaration| count(declaration));
|
|
423
|
+
statements.chain(declarations).sum()
|
|
360
424
|
}
|