From ea7eeada77a52fd58a9e1a949a39eccc7bce955a Mon Sep 17 00:00:00 2001 From: kim Date: Mon, 13 Oct 2025 16:49:53 +0200 Subject: [chore] update dependencies (#4495) - github.com/coreos/go-oidc/v3: v3.15.0 -> v3.16.0 - github.com/go-playground/form/v4: v4.2.1 -> v4.3.0 - github.com/go-swagger/go-swagger: v0.32.3 -> v0.33.1 - golang.org/x/crypto: v0.42.0 -> v0.43.0 - golang.org/x/image: v0.31.0 -> v0.32.0 - golang.org/x/net: v0.45.0 -> v0.46.0 - golang.org/x/oauth2: v0.31.0 -> v0.32.0 - golang.org/x/sys: v0.36.0 -> v0.37.0 - golang.org/x/text: v0.29.0 -> v0.30.0 - modernc.org/sqlite: v1.39.0 -> v1.39.1 (w/ concurrency workaround) Reviewed-on: https://codeberg.org/superseriousbusiness/gotosocial/pulls/4495 Co-authored-by: kim Co-committed-by: kim --- vendor/github.com/bytedance/gopkg/LICENSE | 201 + .../bytedance/gopkg/lang/dirtmake/bytes.go | 43 + vendor/github.com/bytedance/sonic/README.md | 2 +- vendor/github.com/bytedance/sonic/README_ZH_CN.md | 2 +- vendor/github.com/bytedance/sonic/ast/api.go | 65 +- .../github.com/bytedance/sonic/ast/api_compat.go | 14 +- vendor/github.com/bytedance/sonic/ast/decode.go | 17 +- vendor/github.com/bytedance/sonic/ast/encode.go | 10 +- vendor/github.com/bytedance/sonic/ast/node.go | 4 +- vendor/github.com/bytedance/sonic/ast/parser.go | 16 +- vendor/github.com/bytedance/sonic/ast/stubs.go | 3 - vendor/github.com/bytedance/sonic/ast/visitor.go | 5 +- vendor/github.com/bytedance/sonic/compat.go | 2 +- .../bytedance/sonic/decoder/decoder_compat.go | 4 +- .../bytedance/sonic/decoder/decoder_native.go | 4 +- .../bytedance/sonic/encoder/encoder_compat.go | 2 +- .../bytedance/sonic/encoder/encoder_native.go | 11 +- vendor/github.com/bytedance/sonic/go.work | 1 + vendor/github.com/bytedance/sonic/go.work.sum | 10 +- .../bytedance/sonic/internal/compat/warn.go | 2 +- .../sonic/internal/decoder/api/decoder_amd64.go | 4 +- .../sonic/internal/decoder/api/decoder_arm64.go | 2 +- .../bytedance/sonic/internal/decoder/api/stream.go | 22 +- .../decoder/jitdec/asm_stubs_amd64_go121.go | 2 +- .../decoder/jitdec/assembler_regabi_amd64.go | 17 +- .../decoder/jitdec/generic_regabi_amd64.go | 2 +- .../decoder/jitdec/generic_regabi_amd64_test.s | 2 +- .../sonic/internal/decoder/optdec/helper.go | 17 +- .../sonic/internal/encoder/alg/mapiter.go | 109 +- .../sonic/internal/encoder/alg/primitives.go | 104 - .../bytedance/sonic/internal/encoder/alg/spec.go | 11 +- .../sonic/internal/encoder/alg/spec_compat.go | 2 +- .../bytedance/sonic/internal/encoder/compiler.go | 6 + .../bytedance/sonic/internal/encoder/encoder.go | 3 +- .../sonic/internal/encoder/prim/primitives.go | 105 + .../sonic/internal/encoder/vars/errors.go | 40 +- .../bytedance/sonic/internal/encoder/vm/stbus.go | 3 +- .../bytedance/sonic/internal/encoder/vm/vm.go | 13 +- .../internal/encoder/x86/asm_stubs_amd64_go121.go | 4 +- .../internal/encoder/x86/assembler_regabi_amd64.go | 15 +- .../sonic/internal/encoder/x86/debug_go117.go | 4 +- .../bytedance/sonic/internal/encoder/x86/stbus.go | 3 +- .../bytedance/sonic/internal/native/avx2/f32toa.go | 2 +- .../bytedance/sonic/internal/native/avx2/f64toa.go | 2 +- .../sonic/internal/native/avx2/get_by_path.go | 2 +- .../sonic/internal/native/avx2/get_by_path_subr.go | 20 +- .../internal/native/avx2/get_by_path_text_amd64.go | 12348 ++++++++++--------- .../sonic/internal/native/avx2/html_escape.go | 2 +- .../bytedance/sonic/internal/native/avx2/i64toa.go | 2 +- .../sonic/internal/native/avx2/lookup_small_key.go | 4 +- .../bytedance/sonic/internal/native/avx2/lspace.go | 2 +- .../sonic/internal/native/avx2/native_export.go | 2 +- .../internal/native/avx2/parse_with_padding.go | 4 +- .../native/avx2/parse_with_padding_text_amd64.go | 42 +- .../bytedance/sonic/internal/native/avx2/quote.go | 2 +- .../sonic/internal/native/avx2/skip_array.go | 2 +- .../sonic/internal/native/avx2/skip_array_subr.go | 20 +- .../internal/native/avx2/skip_array_text_amd64.go | 8197 ++++++------ .../sonic/internal/native/avx2/skip_number.go | 2 +- .../sonic/internal/native/avx2/skip_object.go | 2 +- .../sonic/internal/native/avx2/skip_object_subr.go | 20 +- .../internal/native/avx2/skip_object_text_amd64.go | 8197 ++++++------ .../sonic/internal/native/avx2/skip_one.go | 2 +- .../sonic/internal/native/avx2/skip_one_fast.go | 2 +- .../internal/native/avx2/skip_one_fast_subr.go | 20 +- .../native/avx2/skip_one_fast_text_amd64.go | 1657 +-- .../sonic/internal/native/avx2/skip_one_subr.go | 20 +- .../internal/native/avx2/skip_one_text_amd64.go | 7400 +++++------ .../bytedance/sonic/internal/native/avx2/u64toa.go | 2 +- .../sonic/internal/native/avx2/unquote.go | 2 +- .../sonic/internal/native/avx2/unquote_subr.go | 20 +- .../internal/native/avx2/unquote_text_amd64.go | 1014 +- .../sonic/internal/native/avx2/validate_one.go | 2 +- .../internal/native/avx2/validate_one_subr.go | 20 +- .../native/avx2/validate_one_text_amd64.go | 8197 ++++++------ .../sonic/internal/native/avx2/validate_utf8.go | 2 +- .../internal/native/avx2/validate_utf8_fast.go | 2 +- .../sonic/internal/native/dispatch_arm64.go | 8 +- .../bytedance/sonic/internal/native/f32toa.tmpl | 2 +- .../bytedance/sonic/internal/native/f64toa.tmpl | 2 +- .../sonic/internal/native/fastfloat_test.tmpl | 2 +- .../sonic/internal/native/fastint_test.tmpl | 2 +- .../sonic/internal/native/get_by_path.tmpl | 2 +- .../sonic/internal/native/html_escape.tmpl | 2 +- .../bytedance/sonic/internal/native/i64toa.tmpl | 2 +- .../sonic/internal/native/lookup_small_key.tmpl | 4 +- .../bytedance/sonic/internal/native/lspace.tmpl | 2 +- .../sonic/internal/native/native_export.tmpl | 2 +- .../sonic/internal/native/native_test.tmpl | 4 +- .../sonic/internal/native/neon/f32toa_arm64.go | 2 +- .../sonic/internal/native/neon/f32toa_arm64.s | 2 +- .../sonic/internal/native/neon/f64toa_arm64.go | 2 +- .../sonic/internal/native/neon/f64toa_arm64.s | 2 +- .../internal/native/neon/get_by_path_arm64.go | 2 +- .../sonic/internal/native/neon/get_by_path_arm64.s | 5679 +++++---- .../internal/native/neon/get_by_path_subr_arm64.go | 2 +- .../internal/native/neon/html_escape_arm64.go | 2 +- .../sonic/internal/native/neon/i64toa_arm64.go | 2 +- .../sonic/internal/native/neon/lspace_arm64.go | 2 +- .../internal/native/neon/native_export_arm64.go | 2 +- .../native/neon/parse_with_padding_arm64.s | 1066 +- .../sonic/internal/native/neon/quote_arm64.go | 2 +- .../sonic/internal/native/neon/skip_array_arm64.go | 2 +- .../sonic/internal/native/neon/skip_array_arm64.s | 2894 ++--- .../internal/native/neon/skip_number_arm64.go | 2 +- .../internal/native/neon/skip_object_arm64.go | 2 +- .../sonic/internal/native/neon/skip_object_arm64.s | 2894 ++--- .../sonic/internal/native/neon/skip_one_arm64.go | 2 +- .../sonic/internal/native/neon/skip_one_arm64.s | 521 +- .../internal/native/neon/skip_one_fast_arm64.go | 2 +- .../internal/native/neon/skip_one_fast_arm64.s | 409 +- .../sonic/internal/native/neon/u64toa_arm64.go | 2 +- .../sonic/internal/native/neon/unquote_arm64.go | 2 +- .../internal/native/neon/validate_one_arm64.go | 2 +- .../internal/native/neon/validate_one_arm64.s | 2894 ++--- .../internal/native/neon/validate_utf8_arm64.go | 2 +- .../native/neon/validate_utf8_fast_arm64.go | 2 +- .../sonic/internal/native/parse_with_padding.tmpl | 4 +- .../bytedance/sonic/internal/native/quote.tmpl | 2 +- .../sonic/internal/native/recover_test.tmpl | 2 +- .../sonic/internal/native/skip_array.tmpl | 2 +- .../sonic/internal/native/skip_number.tmpl | 2 +- .../sonic/internal/native/skip_object.tmpl | 2 +- .../bytedance/sonic/internal/native/skip_one.tmpl | 2 +- .../sonic/internal/native/skip_one_fast.tmpl | 2 +- .../bytedance/sonic/internal/native/sse/f32toa.go | 2 +- .../bytedance/sonic/internal/native/sse/f64toa.go | 2 +- .../sonic/internal/native/sse/get_by_path.go | 2 +- .../sonic/internal/native/sse/get_by_path_subr.go | 20 +- .../internal/native/sse/get_by_path_text_amd64.go | 12335 +++++++++--------- .../sonic/internal/native/sse/html_escape.go | 2 +- .../bytedance/sonic/internal/native/sse/i64toa.go | 2 +- .../sonic/internal/native/sse/lookup_small_key.go | 4 +- .../bytedance/sonic/internal/native/sse/lspace.go | 2 +- .../sonic/internal/native/sse/native_export.go | 2 +- .../internal/native/sse/parse_with_padding.go | 4 +- .../native/sse/parse_with_padding_text_amd64.go | 42 +- .../bytedance/sonic/internal/native/sse/quote.go | 2 +- .../sonic/internal/native/sse/skip_array.go | 2 +- .../sonic/internal/native/sse/skip_array_subr.go | 20 +- .../internal/native/sse/skip_array_text_amd64.go | 8032 ++++++------ .../sonic/internal/native/sse/skip_number.go | 2 +- .../sonic/internal/native/sse/skip_object.go | 2 +- .../sonic/internal/native/sse/skip_object_subr.go | 20 +- .../internal/native/sse/skip_object_text_amd64.go | 8032 ++++++------ .../sonic/internal/native/sse/skip_one.go | 2 +- .../sonic/internal/native/sse/skip_one_fast.go | 2 +- .../internal/native/sse/skip_one_fast_subr.go | 20 +- .../native/sse/skip_one_fast_text_amd64.go | 1884 +-- .../sonic/internal/native/sse/skip_one_subr.go | 20 +- .../internal/native/sse/skip_one_text_amd64.go | 7332 +++++------ .../bytedance/sonic/internal/native/sse/u64toa.go | 2 +- .../bytedance/sonic/internal/native/sse/unquote.go | 2 +- .../sonic/internal/native/sse/unquote_subr.go | 20 +- .../internal/native/sse/unquote_text_amd64.go | 705 +- .../sonic/internal/native/sse/validate_one.go | 2 +- .../sonic/internal/native/sse/validate_one_subr.go | 20 +- .../internal/native/sse/validate_one_text_amd64.go | 8032 ++++++------ .../sonic/internal/native/sse/validate_utf8.go | 2 +- .../internal/native/sse/validate_utf8_fast.go | 2 +- .../sonic/internal/native/traceback_test.mock_tmpl | 4 +- .../bytedance/sonic/internal/native/u64toa.tmpl | 2 +- .../bytedance/sonic/internal/native/unquote.tmpl | 2 +- .../sonic/internal/native/validate_one.tmpl | 2 +- .../sonic/internal/native/validate_utf8.tmpl | 2 +- .../sonic/internal/native/validate_utf8_fast.tmpl | 2 +- .../bytedance/sonic/internal/resolver/fields.go | 388 + .../bytedance/sonic/internal/resolver/resolver.go | 8 + .../sonic/internal/resolver/stubs_go120.go | 51 - .../sonic/internal/resolver/stubs_go123.go | 51 - .../sonic/internal/resolver/stubs_latest.go | 59 - .../bytedance/sonic/internal/rt/base64_amd64.go | 2 +- .../bytedance/sonic/internal/rt/base64_compat.go | 2 +- .../github.com/bytedance/sonic/internal/rt/gcwb.go | 2 +- .../sonic/internal/rt/map_nosiwss_go124.go | 4 +- .../bytedance/sonic/internal/rt/map_siwss_go124.go | 4 +- .../bytedance/sonic/internal/rt/stubs.go | 3 - .../bytedance/sonic/internal/utils/skip.go | 10 +- .../bytedance/sonic/loader/funcdata_compat.go | 4 +- .../bytedance/sonic/loader/funcdata_go123.go | 4 +- .../bytedance/sonic/loader/funcdata_latest.go | 4 +- .../sonic/loader/internal/abi/abi_regabi_amd64.go | 2 +- .../sonic/loader/internal/iasm/expr/errors.go | 2 +- .../sonic/loader/internal/iasm/x86_64/program.go | 4 +- vendor/github.com/bytedance/sonic/sonic.go | 5 +- .../github.com/bytedance/sonic/unquote/unquote.go | 4 + .../bytedance/sonic/unquote/unquote_fallback.go | 206 + vendor/github.com/bytedance/sonic/utf8/utf8.go | 3 + .../bytedance/sonic/utf8/utf8_fallback.go | 37 + 189 files changed, 56995 insertions(+), 55051 deletions(-) create mode 100644 vendor/github.com/bytedance/gopkg/LICENSE create mode 100644 vendor/github.com/bytedance/gopkg/lang/dirtmake/bytes.go delete mode 100644 vendor/github.com/bytedance/sonic/internal/encoder/alg/primitives.go create mode 100644 vendor/github.com/bytedance/sonic/internal/encoder/prim/primitives.go create mode 100644 vendor/github.com/bytedance/sonic/internal/resolver/fields.go delete mode 100644 vendor/github.com/bytedance/sonic/internal/resolver/stubs_go120.go delete mode 100644 vendor/github.com/bytedance/sonic/internal/resolver/stubs_go123.go delete mode 100644 vendor/github.com/bytedance/sonic/internal/resolver/stubs_latest.go create mode 100644 vendor/github.com/bytedance/sonic/unquote/unquote_fallback.go create mode 100644 vendor/github.com/bytedance/sonic/utf8/utf8_fallback.go (limited to 'vendor/github.com/bytedance') diff --git a/vendor/github.com/bytedance/gopkg/LICENSE b/vendor/github.com/bytedance/gopkg/LICENSE new file mode 100644 index 000000000..261eeb9e9 --- /dev/null +++ b/vendor/github.com/bytedance/gopkg/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/vendor/github.com/bytedance/gopkg/lang/dirtmake/bytes.go b/vendor/github.com/bytedance/gopkg/lang/dirtmake/bytes.go new file mode 100644 index 000000000..1daa27904 --- /dev/null +++ b/vendor/github.com/bytedance/gopkg/lang/dirtmake/bytes.go @@ -0,0 +1,43 @@ +// Copyright 2024 ByteDance Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package dirtmake + +import ( + "unsafe" +) + +type slice struct { + data unsafe.Pointer + len int + cap int +} + +//go:linkname mallocgc runtime.mallocgc +func mallocgc(size uintptr, typ unsafe.Pointer, needzero bool) unsafe.Pointer + +// Bytes allocates a byte slice but does not clean up the memory it references. +// Throw a fatal error instead of panic if cap is greater than runtime.maxAlloc. +// NOTE: MUST set any byte element before it's read. +func Bytes(len, cap int) (b []byte) { + if len < 0 || len > cap { + panic("dirtmake.Bytes: len out of range") + } + p := mallocgc(uintptr(cap), nil, false) + sh := (*slice)(unsafe.Pointer(&b)) + sh.data = p + sh.len = len + sh.cap = cap + return +} diff --git a/vendor/github.com/bytedance/sonic/README.md b/vendor/github.com/bytedance/sonic/README.md index 41fe77658..6ada7f689 100644 --- a/vendor/github.com/bytedance/sonic/README.md +++ b/vendor/github.com/bytedance/sonic/README.md @@ -6,7 +6,7 @@ A blazingly fast JSON serializing & deserializing library, accelerated by JI ## Requirement -- Go: 1.17~1.24 +- Go: 1.18~1.25 - Notice: Go1.24.0 is not supported due to the [issue](https://github.com/golang/go/issues/71672), please use higher go version or add build tag `--ldflags="-checklinkname=0"` - OS: Linux / MacOS / Windows - CPU: AMD64 / (ARM64, need go1.20 above) diff --git a/vendor/github.com/bytedance/sonic/README_ZH_CN.md b/vendor/github.com/bytedance/sonic/README_ZH_CN.md index 3c24a51aa..ef4fc2179 100644 --- a/vendor/github.com/bytedance/sonic/README_ZH_CN.md +++ b/vendor/github.com/bytedance/sonic/README_ZH_CN.md @@ -6,7 +6,7 @@ ## 依赖 -- Go: 1.17~1.24 +- Go: 1.18~1.25 - 注意:Go1.24.0 由于 [issue](https://github.com/golang/go/issues/71672) 不可用,请升级到更高 Go 版本,或添加编译选项 `--ldflags="-checklinkname=0"` - OS: Linux / MacOS / Windows - CPU: AMD64 / (ARM64, 需要 Go1.20 以上) diff --git a/vendor/github.com/bytedance/sonic/ast/api.go b/vendor/github.com/bytedance/sonic/ast/api.go index 36151f270..b9d3c58ee 100644 --- a/vendor/github.com/bytedance/sonic/ast/api.go +++ b/vendor/github.com/bytedance/sonic/ast/api.go @@ -1,5 +1,5 @@ -//go:build (amd64 && go1.17 && !go1.25) || (arm64 && go1.20 && !go1.25) -// +build amd64,go1.17,!go1.25 arm64,go1.20,!go1.25 +//go:build (amd64 && go1.17 && !go1.26) || (arm64 && go1.20 && !go1.26) +// +build amd64,go1.17,!go1.26 arm64,go1.20,!go1.26 /* * Copyright 2022 ByteDance Inc. @@ -20,62 +20,21 @@ package ast import ( - `runtime` - `unsafe` - - `github.com/bytedance/sonic/encoder` - `github.com/bytedance/sonic/internal/native` - `github.com/bytedance/sonic/internal/native/types` - `github.com/bytedance/sonic/internal/rt` - uq `github.com/bytedance/sonic/unquote` - `github.com/bytedance/sonic/utf8` + "runtime" + "unsafe" + + "github.com/bytedance/sonic/encoder" + "github.com/bytedance/sonic/internal/encoder/alg" + "github.com/bytedance/sonic/internal/native" + "github.com/bytedance/sonic/internal/native/types" + "github.com/bytedance/sonic/internal/rt" + "github.com/bytedance/sonic/utf8" ) var typeByte = rt.UnpackEface(byte(0)).Type -//go:nocheckptr func quote(buf *[]byte, val string) { - *buf = append(*buf, '"') - if len(val) == 0 { - *buf = append(*buf, '"') - return - } - - sp := rt.IndexChar(val, 0) - nb := len(val) - b := (*rt.GoSlice)(unsafe.Pointer(buf)) - - // input buffer - for nb > 0 { - // output buffer - dp := unsafe.Pointer(uintptr(b.Ptr) + uintptr(b.Len)) - dn := b.Cap - b.Len - // call native.Quote, dn is byte count it outputs - ret := native.Quote(sp, nb, dp, &dn, 0) - // update *buf length - b.Len += dn - - // no need more output - if ret >= 0 { - break - } - - // double buf size - *b = rt.GrowSlice(typeByte, *b, b.Cap*2) - // ret is the complement of consumed input - ret = ^ret - // update input buffer - nb -= ret - sp = unsafe.Pointer(uintptr(sp) + uintptr(ret)) - } - - runtime.KeepAlive(buf) - runtime.KeepAlive(sp) - *buf = append(*buf, '"') -} - -func unquote(src string) (string, types.ParsingError) { - return uq.String(src) + *buf = alg.Quote(*buf, val, false) } func (self *Parser) decodeValue() (val types.JsonState) { diff --git a/vendor/github.com/bytedance/sonic/ast/api_compat.go b/vendor/github.com/bytedance/sonic/ast/api_compat.go index 74119fed6..c6a540cbf 100644 --- a/vendor/github.com/bytedance/sonic/ast/api_compat.go +++ b/vendor/github.com/bytedance/sonic/ast/api_compat.go @@ -1,4 +1,4 @@ -// +build !amd64,!arm64 go1.25 !go1.17 arm64,!go1.20 +// +build !amd64,!arm64 go1.26 !go1.17 arm64,!go1.20 /* * Copyright 2022 ByteDance Inc. @@ -23,7 +23,6 @@ import ( `unicode/utf8` `github.com/bytedance/sonic/internal/native/types` - `github.com/bytedance/sonic/internal/rt` `github.com/bytedance/sonic/internal/compat` ) @@ -35,17 +34,6 @@ func quote(buf *[]byte, val string) { quoteString(buf, val) } -// unquote unescapes an internal JSON string (it doesn't count quotas at the beginning and end) -func unquote(src string) (string, types.ParsingError) { - sp := rt.IndexChar(src, -1) - out, ok := unquoteBytes(rt.BytesFrom(sp, len(src)+2, len(src)+2)) - if !ok { - return "", types.ERR_INVALID_ESCAPE - } - return rt.Mem2Str(out), 0 -} - - func (self *Parser) decodeValue() (val types.JsonState) { e, v := decodeValue(self.s, self.p, self.dbuf == nil) if e < 0 { diff --git a/vendor/github.com/bytedance/sonic/ast/decode.go b/vendor/github.com/bytedance/sonic/ast/decode.go index 135ee6eb8..45f5e2d2b 100644 --- a/vendor/github.com/bytedance/sonic/ast/decode.go +++ b/vendor/github.com/bytedance/sonic/ast/decode.go @@ -25,10 +25,9 @@ import ( "github.com/bytedance/sonic/internal/native/types" "github.com/bytedance/sonic/internal/rt" "github.com/bytedance/sonic/internal/utils" + "github.com/bytedance/sonic/unquote" ) -// Hack: this is used for both checking space and cause friendly compile errors in 32-bit arch. -const _Sonic_Not_Support_32Bit_Arch__Checking_32Bit_Arch_Here = (1 << ' ') | (1 << '\t') | (1 << '\r') | (1 << '\n') var bytesNull = []byte("null") @@ -40,17 +39,13 @@ const ( bytesArray = "[]" ) -func isSpace(c byte) bool { - return (int(1<= 0 && isSpace(self.s[self.p]); self.p-=1 {} + for ; self.p >= 0 && utils.IsSpace(self.s[self.p]); self.p-=1 {} } func (self *Parser) decodeArray(ret *linkedNodes) (Node, types.ParsingError) { @@ -217,7 +219,7 @@ func (self *Parser) decodeObject(ret *linkedPairs) (Node, types.ParsingError) { /* check for escape sequence */ if njs.Ep != -1 { - if key, err = unquote(key); err != 0 { + if key, err = unquote.String(key); err != 0 { return Node{}, err } } @@ -282,7 +284,7 @@ func (self *Parser) decodeString(iv int64, ep int) (Node, types.ParsingError) { } /* unquote the string */ - out, err := unquote(s) + out, err := unquote.String(s) /* check for errors */ if err != 0 { @@ -392,7 +394,7 @@ func (self *Parser) searchKey(match string) types.ParsingError { /* check for escape sequence */ if njs.Ep != -1 { - if key, err = unquote(key); err != 0 { + if key, err = unquote.String(key); err != 0 { return err } } @@ -573,7 +575,7 @@ func (self *Node) skipNextPair() (*Pair) { /* check for escape sequence */ if njs.Ep != -1 { - if key, err = unquote(key); err != 0 { + if key, err = unquote.String(key); err != 0 { return newErrorPair(parser.syntaxError(err)) } } @@ -692,7 +694,7 @@ func (self *Parser) ExportError(err types.ParsingError) error { } func backward(src string, i int) int { - for ; i>=0 && isSpace(src[i]); i-- {} + for ; i>=0 && utils.IsSpace(src[i]); i-- {} return i } diff --git a/vendor/github.com/bytedance/sonic/ast/stubs.go b/vendor/github.com/bytedance/sonic/ast/stubs.go index 9991cc89e..6ba1d7eba 100644 --- a/vendor/github.com/bytedance/sonic/ast/stubs.go +++ b/vendor/github.com/bytedance/sonic/ast/stubs.go @@ -26,6 +26,3 @@ import ( func mem2ptr(s []byte) unsafe.Pointer { return (*rt.GoSlice)(unsafe.Pointer(&s)).Ptr } - -//go:linkname unquoteBytes encoding/json.unquoteBytes -func unquoteBytes(s []byte) (t []byte, ok bool) diff --git a/vendor/github.com/bytedance/sonic/ast/visitor.go b/vendor/github.com/bytedance/sonic/ast/visitor.go index fc71d40cb..53faeb9c0 100644 --- a/vendor/github.com/bytedance/sonic/ast/visitor.go +++ b/vendor/github.com/bytedance/sonic/ast/visitor.go @@ -21,6 +21,7 @@ import ( `errors` `github.com/bytedance/sonic/internal/native/types` + `github.com/bytedance/sonic/unquote` ) // Visitor handles the callbacks during preorder traversal of a JSON AST. @@ -270,7 +271,7 @@ func (self *traverser) decodeObject() error { /* check for escape sequence */ if njs.Ep != -1 { - if key, err = unquote(key); err != 0 { + if key, err = unquote.String(key); err != 0 { return err } } @@ -320,7 +321,7 @@ func (self *traverser) decodeString(iv int64, ep int) error { } /* unquote the string */ - out, err := unquote(s) + out, err := unquote.String(s) if err != 0 { return err } diff --git a/vendor/github.com/bytedance/sonic/compat.go b/vendor/github.com/bytedance/sonic/compat.go index ec996493a..1fa670a48 100644 --- a/vendor/github.com/bytedance/sonic/compat.go +++ b/vendor/github.com/bytedance/sonic/compat.go @@ -1,4 +1,4 @@ -// +build !amd64,!arm64 go1.25 !go1.17 arm64,!go1.20 +// +build !amd64,!arm64 go1.26 !go1.17 arm64,!go1.20 /* * Copyright 2021 ByteDance Inc. diff --git a/vendor/github.com/bytedance/sonic/decoder/decoder_compat.go b/vendor/github.com/bytedance/sonic/decoder/decoder_compat.go index 754e5fbc2..75b21746f 100644 --- a/vendor/github.com/bytedance/sonic/decoder/decoder_compat.go +++ b/vendor/github.com/bytedance/sonic/decoder/decoder_compat.go @@ -1,5 +1,5 @@ -//go:build (!amd64 && !arm64) || go1.25 || !go1.17 || (arm64 && !go1.20) -// +build !amd64,!arm64 go1.25 !go1.17 arm64,!go1.20 +//go:build (!amd64 && !arm64) || go1.26 || !go1.17 || (arm64 && !go1.20) +// +build !amd64,!arm64 go1.26 !go1.17 arm64,!go1.20 /* * Copyright 2023 ByteDance Inc. diff --git a/vendor/github.com/bytedance/sonic/decoder/decoder_native.go b/vendor/github.com/bytedance/sonic/decoder/decoder_native.go index 563ca944b..4313a4e14 100644 --- a/vendor/github.com/bytedance/sonic/decoder/decoder_native.go +++ b/vendor/github.com/bytedance/sonic/decoder/decoder_native.go @@ -1,5 +1,5 @@ -//go:build (amd64 && go1.17 && !go1.25) || (arm64 && go1.20 && !go1.25) -// +build amd64,go1.17,!go1.25 arm64,go1.20,!go1.25 +//go:build (amd64 && go1.17 && !go1.26) || (arm64 && go1.20 && !go1.26) +// +build amd64,go1.17,!go1.26 arm64,go1.20,!go1.26 /* diff --git a/vendor/github.com/bytedance/sonic/encoder/encoder_compat.go b/vendor/github.com/bytedance/sonic/encoder/encoder_compat.go index d48e99b1f..a7350548a 100644 --- a/vendor/github.com/bytedance/sonic/encoder/encoder_compat.go +++ b/vendor/github.com/bytedance/sonic/encoder/encoder_compat.go @@ -1,4 +1,4 @@ -// +build !amd64,!arm64 go1.25 !go1.17 arm64,!go1.20 +// +build !amd64,!arm64 go1.26 !go1.17 arm64,!go1.20 /* * Copyright 2023 ByteDance Inc. diff --git a/vendor/github.com/bytedance/sonic/encoder/encoder_native.go b/vendor/github.com/bytedance/sonic/encoder/encoder_native.go index 2881da8d7..bfed805fd 100644 --- a/vendor/github.com/bytedance/sonic/encoder/encoder_native.go +++ b/vendor/github.com/bytedance/sonic/encoder/encoder_native.go @@ -1,4 +1,4 @@ -// +build amd64,go1.17,!go1.25 arm64,go1.20,!go1.25 +// +build amd64,go1.17,!go1.26 arm64,go1.20,!go1.26 /* * Copyright 2023 ByteDance Inc. @@ -71,7 +71,8 @@ const ( // CompatibleWithStd is used to be compatible with std encoder. CompatibleWithStd Options = encoder.CompatibleWithStd - // Encode Infinity or Nan float into `null`, instead of returning an error. + // EncodeNullForInfOrNan encodes Infinity or NaN float values as 'null' + // instead of returning an error. EncodeNullForInfOrNan Options = encoder.EncodeNullForInfOrNan ) @@ -80,12 +81,12 @@ var ( // Encode returns the JSON encoding of val, encoded with opts. Encode = encoder.Encode - // EncodeInto is like Encode but uses a user-supplied buffer instead of allocating a new one. - EncodeIndented = encoder.EncodeIndented - // EncodeIndented is like Encode but applies Indent to format the output. // Each JSON element in the output will begin on a new line beginning with prefix // followed by one or more copies of indent according to the indentation nesting. + EncodeIndented = encoder.EncodeIndented + + // EncodeInto is like Encode but uses a user-supplied buffer instead of allocating a new one. EncodeInto = encoder.EncodeInto // HTMLEscape appends to dst the JSON-encoded src with <, >, &, U+2028 and U+2029 diff --git a/vendor/github.com/bytedance/sonic/go.work b/vendor/github.com/bytedance/sonic/go.work index 8d2af51b9..34c990646 100644 --- a/vendor/github.com/bytedance/sonic/go.work +++ b/vendor/github.com/bytedance/sonic/go.work @@ -5,5 +5,6 @@ use ( ./external_jsonlib_test ./fuzz ./generic_test + ./issue_test ./loader ) diff --git a/vendor/github.com/bytedance/sonic/go.work.sum b/vendor/github.com/bytedance/sonic/go.work.sum index 706c702bb..37269ab66 100644 --- a/vendor/github.com/bytedance/sonic/go.work.sum +++ b/vendor/github.com/bytedance/sonic/go.work.sum @@ -2,6 +2,10 @@ github.com/bytedance/sonic/loader v0.2.0/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4 github.com/bytedance/sonic/loader v0.2.3/go.mod h1:N8A3vUdtUebEY2/VQC0MyhYeKUFosQU6FxH2JmUe6VI= github.com/bytedance/sonic/loader v0.2.4/go.mod h1:N8A3vUdtUebEY2/VQC0MyhYeKUFosQU6FxH2JmUe6VI= github.com/cloudwego/iasm v0.2.0 h1:1KNIy1I1H9hNNFEEH3DVnI4UujN+1zjpuk6gwHLTssg= -github.com/klauspost/cpuid/v2 v2.2.9 h1:66ze0taIn2H33fBvCkXuv9BmCwDfafmiIVpKV9kKGuY= -github.com/klauspost/cpuid/v2 v2.2.9/go.mod h1:rqkxqrZ1EhYM9G+hXH7YdowN5R5RGN6NK4QwQ3WMXF8= -golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w= +golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8= +golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= +golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +golang.org/x/tools v0.6.0 h1:BOw41kyTf3PuCW1pVQf8+Cyg8pMlkYB1oo9iJ6D/lKM= diff --git a/vendor/github.com/bytedance/sonic/internal/compat/warn.go b/vendor/github.com/bytedance/sonic/internal/compat/warn.go index bd9600e5a..4fabaabac 100644 --- a/vendor/github.com/bytedance/sonic/internal/compat/warn.go +++ b/vendor/github.com/bytedance/sonic/internal/compat/warn.go @@ -1,4 +1,4 @@ -// +build !amd64,!arm64 go1.25 !go1.17 arm64,!go1.20 +// +build !amd64,!arm64 go1.26 !go1.17 arm64,!go1.20 package compat diff --git a/vendor/github.com/bytedance/sonic/internal/decoder/api/decoder_amd64.go b/vendor/github.com/bytedance/sonic/internal/decoder/api/decoder_amd64.go index 551b35b1b..4e7f46fa6 100644 --- a/vendor/github.com/bytedance/sonic/internal/decoder/api/decoder_amd64.go +++ b/vendor/github.com/bytedance/sonic/internal/decoder/api/decoder_amd64.go @@ -1,5 +1,5 @@ -//go:build go1.17 && !go1.25 -// +build go1.17,!go1.25 +//go:build go1.17 && !go1.26 +// +build go1.17,!go1.26 /* * Copyright 2021 ByteDance Inc. diff --git a/vendor/github.com/bytedance/sonic/internal/decoder/api/decoder_arm64.go b/vendor/github.com/bytedance/sonic/internal/decoder/api/decoder_arm64.go index a56e1579d..5a7d44de1 100644 --- a/vendor/github.com/bytedance/sonic/internal/decoder/api/decoder_arm64.go +++ b/vendor/github.com/bytedance/sonic/internal/decoder/api/decoder_arm64.go @@ -1,4 +1,4 @@ -// +build go1.17,!go1.25 +// +build go1.17,!go1.26 /* * Copyright 2021 ByteDance Inc. diff --git a/vendor/github.com/bytedance/sonic/internal/decoder/api/stream.go b/vendor/github.com/bytedance/sonic/internal/decoder/api/stream.go index ecf120462..d0ee97511 100644 --- a/vendor/github.com/bytedance/sonic/internal/decoder/api/stream.go +++ b/vendor/github.com/bytedance/sonic/internal/decoder/api/stream.go @@ -17,14 +17,15 @@ package api import ( - `bytes` - `io` - `sync` - - `github.com/bytedance/sonic/internal/native` - `github.com/bytedance/sonic/internal/native/types` - `github.com/bytedance/sonic/internal/rt` - `github.com/bytedance/sonic/option` + "bytes" + "io" + "sync" + + "github.com/bytedance/sonic/internal/native" + "github.com/bytedance/sonic/internal/native/types" + "github.com/bytedance/sonic/internal/rt" + "github.com/bytedance/sonic/internal/utils" + "github.com/bytedance/sonic/option" ) var ( @@ -194,7 +195,7 @@ func (self *StreamDecoder) peek() (byte, error) { func (self *StreamDecoder) scan() (byte, bool) { for i := self.scanp; i < len(self.buf); i++ { c := self.buf[i] - if isSpace(c) { + if utils.IsSpace(c) { continue } self.scanp = i @@ -203,9 +204,6 @@ func (self *StreamDecoder) scan() (byte, bool) { return 0, true } -func isSpace(c byte) bool { - return types.SPACE_MASK & (1 << c) != 0 -} func (self *StreamDecoder) refill() error { // Make room to read more into the buffer. diff --git a/vendor/github.com/bytedance/sonic/internal/decoder/jitdec/asm_stubs_amd64_go121.go b/vendor/github.com/bytedance/sonic/internal/decoder/jitdec/asm_stubs_amd64_go121.go index d6101b2e6..5cd3750bf 100644 --- a/vendor/github.com/bytedance/sonic/internal/decoder/jitdec/asm_stubs_amd64_go121.go +++ b/vendor/github.com/bytedance/sonic/internal/decoder/jitdec/asm_stubs_amd64_go121.go @@ -1,4 +1,4 @@ -// +build go1.21,!go1.25 +// +build go1.21,!go1.26 // Copyright 2023 CloudWeGo Authors // diff --git a/vendor/github.com/bytedance/sonic/internal/decoder/jitdec/assembler_regabi_amd64.go b/vendor/github.com/bytedance/sonic/internal/decoder/jitdec/assembler_regabi_amd64.go index 20c115e79..dc86efe08 100644 --- a/vendor/github.com/bytedance/sonic/internal/decoder/jitdec/assembler_regabi_amd64.go +++ b/vendor/github.com/bytedance/sonic/internal/decoder/jitdec/assembler_regabi_amd64.go @@ -1,5 +1,5 @@ -//go:build go1.17 && !go1.25 -// +build go1.17,!go1.25 +//go:build go1.17 && !go1.26 +// +build go1.17,!go1.26 /* * Copyright 2021 ByteDance Inc. @@ -887,6 +887,17 @@ func (self *_Assembler) range_unsigned_CX(i *rt.GoItab, t *rt.GoType, v uint64) self.Sjmp("JA" , _LB_range_error) // JA _range_error } +func (self *_Assembler) range_uint32_CX(i *rt.GoItab, t *rt.GoType) { + self.Emit("MOVQ" , _VAR_st_Iv, _CX) // MOVQ st.Iv, CX + self.Emit("MOVQ" , jit.Gitab(i), _ET) // MOVQ ${i}, ET + self.Emit("MOVQ" , jit.Gtype(t), _EP) // MOVQ ${t}, EP + self.Emit("TESTQ", _CX, _CX) // TESTQ CX, CX + self.Sjmp("JS" , _LB_range_error) // JS _range_error + self.Emit("MOVL" , _CX, _DX) // MOVL CX, DX + self.Emit("CMPQ" , _CX, _DX) // CMPQ CX, DX + self.Sjmp("JNE" , _LB_range_error) // JNZ _range_error +} + /** String Manipulating Routines **/ var ( @@ -1453,7 +1464,7 @@ func (self *_Assembler) _asm_OP_u16(_ *_Instr) { func (self *_Assembler) _asm_OP_u32(_ *_Instr) { var pin = "_u32_end_{n}" self.parse_unsigned(uint32Type, pin, -1) // PARSE uint32 - self.range_unsigned_CX(_I_uint32, _T_uint32, math.MaxUint32) // RANGE uint32 + self.range_uint32_CX(_I_uint32, _T_uint32) // RANGE uint32 self.Emit("MOVL", _CX, jit.Ptr(_VP, 0)) // MOVL CX, (VP) self.Link(pin) } diff --git a/vendor/github.com/bytedance/sonic/internal/decoder/jitdec/generic_regabi_amd64.go b/vendor/github.com/bytedance/sonic/internal/decoder/jitdec/generic_regabi_amd64.go index 51a850a8a..2cb41f08d 100644 --- a/vendor/github.com/bytedance/sonic/internal/decoder/jitdec/generic_regabi_amd64.go +++ b/vendor/github.com/bytedance/sonic/internal/decoder/jitdec/generic_regabi_amd64.go @@ -1,4 +1,4 @@ -// +build go1.17,!go1.25 +// +build go1.17,!go1.26 /* * Copyright 2021 ByteDance Inc. diff --git a/vendor/github.com/bytedance/sonic/internal/decoder/jitdec/generic_regabi_amd64_test.s b/vendor/github.com/bytedance/sonic/internal/decoder/jitdec/generic_regabi_amd64_test.s index f287eaeb4..a08f0e2ad 100644 --- a/vendor/github.com/bytedance/sonic/internal/decoder/jitdec/generic_regabi_amd64_test.s +++ b/vendor/github.com/bytedance/sonic/internal/decoder/jitdec/generic_regabi_amd64_test.s @@ -1,4 +1,4 @@ -// +build go1.17,!go1.25 +// +build go1.17,!go1.26 // // Copyright 2021 ByteDance Inc. diff --git a/vendor/github.com/bytedance/sonic/internal/decoder/optdec/helper.go b/vendor/github.com/bytedance/sonic/internal/decoder/optdec/helper.go index 61faa6c80..0683f45ae 100644 --- a/vendor/github.com/bytedance/sonic/internal/decoder/optdec/helper.go +++ b/vendor/github.com/bytedance/sonic/internal/decoder/optdec/helper.go @@ -28,11 +28,6 @@ func SkipNumberFast(json string, start int) (int, bool) { return pos, true } - -func isSpace(c byte) bool { - return c == ' ' || c == '\t' || c == '\n' || c == '\r' -} - // pos is the start index of the raw func ValidNumberFast(raw string) bool { ret := utils.SkipNumber(raw, 0) @@ -48,22 +43,12 @@ func ValidNumberFast(raw string) bool { return true } -func SkipOneFast2(json string, pos *int) (int, error) { - // find the number ending, we parsed in sonic-cpp, it always valid - start := native.SkipOneFast(&json, pos) - if start < 0 { - return -1, error_syntax(*pos, json, types.ParsingError(-start).Error()) - } - return start, nil -} - func SkipOneFast(json string, pos int) (string, error) { - // find the number ending, we parsed in sonic-cpp, it always valid start := native.SkipOneFast(&json, &pos) if start < 0 { - // TODO: details error code return "", error_syntax(pos, json, types.ParsingError(-start).Error()) } + return json[start:pos], nil } diff --git a/vendor/github.com/bytedance/sonic/internal/encoder/alg/mapiter.go b/vendor/github.com/bytedance/sonic/internal/encoder/alg/mapiter.go index 090afac13..4664d90ca 100644 --- a/vendor/github.com/bytedance/sonic/internal/encoder/alg/mapiter.go +++ b/vendor/github.com/bytedance/sonic/internal/encoder/alg/mapiter.go @@ -84,15 +84,24 @@ func (self *MapIterator) data() (p []_MapPair) { func (self *MapIterator) append(t *rt.GoType, k unsafe.Pointer, v unsafe.Pointer) (err error) { p := self.add() p.v = v + tk := t.Kind() - /* check for strings */ - if tk := t.Kind(); tk != reflect.String { - return self.appendGeneric(p, t, tk, k) + // followed as `encoding/json/emcode.go:resolveKeyName + if tk == reflect.String { + p.k = *(*string)(k) + return nil } - /* fast path for strings */ - p.k = *(*string)(k) - return nil + // check if the key implements the encoding.TextMarshaler interface + if t.Pack().Implements(vars.EncodingTextMarshalerType) { + if tk != reflect.Interface { + return self.appendConcrete(p, t, k) + } else { + return self.appendInterface(p, t, k) + } + } + + return self.appendGeneric(p, t, tk, k) } func (self *MapIterator) appendGeneric(p *_MapPair, t *rt.GoType, v reflect.Kind, k unsafe.Pointer) error { @@ -109,34 +118,43 @@ func (self *MapIterator) appendGeneric(p *_MapPair, t *rt.GoType, v reflect.Kind case reflect.Uint64 : p.k = rt.Mem2Str(strconv.AppendUint(p.m[:0], uint64(*(*uint64)(k)), 10)) ; return nil case reflect.Uintptr : p.k = rt.Mem2Str(strconv.AppendUint(p.m[:0], uint64(*(*uintptr)(k)), 10)) ; return nil case reflect.Bool : if *(*bool)(k) { p.k = "true" } else { p.k = "false" }; return nil - case reflect.Interface : return self.appendInterface(p, t, k) - case reflect.Struct, reflect.Ptr : return self.appendConcrete(p, t, k) - default : panic("unexpected map key type") + default : return vars.Error_type(t.Pack()) } } -func (self *MapIterator) appendConcrete(p *_MapPair, t *rt.GoType, k unsafe.Pointer) (err error) { +func (self *MapIterator) appendConcrete(p *_MapPair, t *rt.GoType, k unsafe.Pointer) error { // compiler has already checked that the type implements the encoding.MarshalText interface if !t.Indirect() { k = *(*unsafe.Pointer)(k) } + + // check the TextMarshaler interface eface := rt.GoEface{Value: k, Type: t}.Pack() - out, err := eface.(encoding.TextMarshaler).MarshalText() + e, ok := eface.(encoding.TextMarshaler) + if !ok { + return vars.Error_type(t.Pack()) + } + + // check for nil pointer + if t.Kind() == reflect.Ptr && k == nil { + p.k = "" + return nil + } + + out, err := e.MarshalText() if err != nil { return err } p.k = rt.Mem2Str(out) - return + return nil } func (self *MapIterator) appendInterface(p *_MapPair, t *rt.GoType, k unsafe.Pointer) (err error) { if len(rt.IfaceType(t).Methods) == 0 { panic("unexpected map key type") - } else if p.k, err = asText(k); err == nil { - return nil - } else { - return } + p.k, err = asText(k) + return } func IteratorStop(p *MapIterator) { @@ -206,3 +224,62 @@ func asText(v unsafe.Pointer) (string, error) { r, e := (*(*encoding.TextMarshaler)(unsafe.Pointer(&text))).MarshalText() return rt.Mem2Str(r), e } + +func IsValidNumber(s string) bool { + // This function implements the JSON numbers grammar. + // See https://tools.ietf.org/html/rfc7159#section-6 + // and https://www.json.org/img/number.png + + if s == "" { + return false + } + + // Optional - + if s[0] == '-' { + s = s[1:] + if s == "" { + return false + } + } + + // Digits + switch { + default: + return false + + case s[0] == '0': + s = s[1:] + + case '1' <= s[0] && s[0] <= '9': + s = s[1:] + for len(s) > 0 && '0' <= s[0] && s[0] <= '9' { + s = s[1:] + } + } + + // . followed by 1 or more digits. + if len(s) >= 2 && s[0] == '.' && '0' <= s[1] && s[1] <= '9' { + s = s[2:] + for len(s) > 0 && '0' <= s[0] && s[0] <= '9' { + s = s[1:] + } + } + + // e or E followed by an optional - or + and + // 1 or more digits. + if len(s) >= 2 && (s[0] == 'e' || s[0] == 'E') { + s = s[1:] + if s[0] == '+' || s[0] == '-' { + s = s[1:] + if s == "" { + return false + } + } + for len(s) > 0 && '0' <= s[0] && s[0] <= '9' { + s = s[1:] + } + } + + // Make sure we are at the end. + return s == "" +} diff --git a/vendor/github.com/bytedance/sonic/internal/encoder/alg/primitives.go b/vendor/github.com/bytedance/sonic/internal/encoder/alg/primitives.go deleted file mode 100644 index e2610fbc8..000000000 --- a/vendor/github.com/bytedance/sonic/internal/encoder/alg/primitives.go +++ /dev/null @@ -1,104 +0,0 @@ -/** - * Copyright 2024 ByteDance Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package alg - -import ( - "encoding" - "encoding/json" - "reflect" - "unsafe" - - "github.com/bytedance/sonic/internal/encoder/vars" - "github.com/bytedance/sonic/internal/resolver" - "github.com/bytedance/sonic/internal/rt" -) - -func Compact(p *[]byte, v []byte) error { - buf := vars.NewBuffer() - err := json.Compact(buf, v) - - /* check for errors */ - if err != nil { - return err - } - - /* add to result */ - v = buf.Bytes() - *p = append(*p, v...) - - /* return the buffer into pool */ - vars.FreeBuffer(buf) - return nil -} - -func EncodeNil(rb *[]byte) error { - *rb = append(*rb, 'n', 'u', 'l', 'l') - return nil -} - -// func Make_EncodeTypedPointer(computor func(*rt.GoType, ...interface{}) (interface{}, error)) func(*[]byte, *rt.GoType, *unsafe.Pointer, *vars.Stack, uint64) error { -// return func(buf *[]byte, vt *rt.GoType, vp *unsafe.Pointer, sb *vars.Stack, fv uint64) error { -// if vt == nil { -// return EncodeNil(buf) -// } else if fn, err := vars.FindOrCompile(vt, (fv&(1< 0 { + sp = unsafe.Pointer(uintptr(sp) + uintptr(ret)) + } } runtime.KeepAlive(buf) diff --git a/vendor/github.com/bytedance/sonic/internal/encoder/alg/spec_compat.go b/vendor/github.com/bytedance/sonic/internal/encoder/alg/spec_compat.go index cd8369834..cd9beab04 100644 --- a/vendor/github.com/bytedance/sonic/internal/encoder/alg/spec_compat.go +++ b/vendor/github.com/bytedance/sonic/internal/encoder/alg/spec_compat.go @@ -1,4 +1,4 @@ -// +build !amd64,!arm64 go1.25 !go1.16 arm64,!go1.20 +// +build !amd64,!arm64 go1.26 !go1.16 arm64,!go1.20 /** * Copyright 2024 ByteDance Inc. diff --git a/vendor/github.com/bytedance/sonic/internal/encoder/compiler.go b/vendor/github.com/bytedance/sonic/internal/encoder/compiler.go index 737dd3e07..eeeb119cc 100644 --- a/vendor/github.com/bytedance/sonic/internal/encoder/compiler.go +++ b/vendor/github.com/bytedance/sonic/internal/encoder/compiler.go @@ -287,6 +287,12 @@ func (self *Compiler) compileMapBody(p *ir.Program, sp int, vt reflect.Type) { } func (self *Compiler) compileMapBodyKey(p *ir.Program, vk reflect.Type) { + // followed as `encoding/json/emcode.go:resolveKeyName + if vk.Kind() == reflect.String { + self.compileString(p, vk) + return + } + if !vk.Implements(vars.EncodingTextMarshalerType) { self.compileMapBodyTextKey(p, vk) } else { diff --git a/vendor/github.com/bytedance/sonic/internal/encoder/encoder.go b/vendor/github.com/bytedance/sonic/internal/encoder/encoder.go index 4cba1a168..9e675a536 100644 --- a/vendor/github.com/bytedance/sonic/internal/encoder/encoder.go +++ b/vendor/github.com/bytedance/sonic/internal/encoder/encoder.go @@ -28,6 +28,7 @@ import ( "github.com/bytedance/sonic/internal/encoder/vars" "github.com/bytedance/sonic/internal/rt" "github.com/bytedance/sonic/option" + "github.com/bytedance/gopkg/lang/dirtmake" ) // Options is a set of encoding options. @@ -193,7 +194,7 @@ func Encode(val interface{}, opts Options) ([]byte, error) { /* make a copy of the result */ if rt.CanSizeResue(cap(*buf)) { - ret = make([]byte, len(*buf)) + ret = dirtmake.Bytes(len(*buf), len(*buf)) copy(ret, *buf) vars.FreeBytes(buf) } else { diff --git a/vendor/github.com/bytedance/sonic/internal/encoder/prim/primitives.go b/vendor/github.com/bytedance/sonic/internal/encoder/prim/primitives.go new file mode 100644 index 000000000..ec4d2f5ca --- /dev/null +++ b/vendor/github.com/bytedance/sonic/internal/encoder/prim/primitives.go @@ -0,0 +1,105 @@ +/** + * Copyright 2024 ByteDance Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package prim + +import ( + "encoding" + "encoding/json" + "reflect" + "unsafe" + + "github.com/bytedance/sonic/internal/encoder/alg" + "github.com/bytedance/sonic/internal/encoder/vars" + "github.com/bytedance/sonic/internal/resolver" + "github.com/bytedance/sonic/internal/rt" +) + +func Compact(p *[]byte, v []byte) error { + buf := vars.NewBuffer() + err := json.Compact(buf, v) + + /* check for errors */ + if err != nil { + return err + } + + /* add to result */ + v = buf.Bytes() + *p = append(*p, v...) + + /* return the buffer into pool */ + vars.FreeBuffer(buf) + return nil +} + +func EncodeNil(rb *[]byte) error { + *rb = append(*rb, 'n', 'u', 'l', 'l') + return nil +} + +// func Make_EncodeTypedPointer(computor func(*rt.GoType, ...interface{}) (interface{}, error)) func(*[]byte, *rt.GoType, *unsafe.Pointer, *vars.Stack, uint64) error { +// return func(buf *[]byte, vt *rt.GoType, vp *unsafe.Pointer, sb *vars.Stack, fv uint64) error { +// if vt == nil { +// return EncodeNil(buf) +// } else if fn, err := vars.FindOrCompile(vt, (fv&(1< maxJSONLength { + sb.WriteString(buf[len(buf)-maxJSONLength:]) + } else { + sb.WriteString(buf) + } + panic(sb.String()) +} + +var maxJSONLength = 1024 + +func init() { + if v := os.Getenv("SONIC_PANIC_MAX_JSON_LENGTH"); v != "" { + if i, err := strconv.Atoi(v); err == nil { + maxJSONLength = i + } } } diff --git a/vendor/github.com/bytedance/sonic/internal/encoder/vm/stbus.go b/vendor/github.com/bytedance/sonic/internal/encoder/vm/stbus.go index 21b476c3c..152c72ca1 100644 --- a/vendor/github.com/bytedance/sonic/internal/encoder/vm/stbus.go +++ b/vendor/github.com/bytedance/sonic/internal/encoder/vm/stbus.go @@ -22,13 +22,14 @@ import ( "github.com/bytedance/sonic/internal/encoder/alg" "github.com/bytedance/sonic/internal/encoder/ir" + "github.com/bytedance/sonic/internal/encoder/prim" "github.com/bytedance/sonic/internal/encoder/vars" "github.com/bytedance/sonic/internal/rt" ) func EncodeTypedPointer(buf *[]byte, vt *rt.GoType, vp *unsafe.Pointer, sb *vars.Stack, fv uint64) error { if vt == nil { - return alg.EncodeNil(buf) + return prim.EncodeNil(buf) } else if pp, err := vars.FindOrCompile(vt, (fv&(1< 0 { + current, next = next, current[:0] + count, nextCount = nextCount, map[reflect.Type]int{} + + for _, f := range current { + if visited[f.typ] { + continue + } + visited[f.typ] = true + + // Scan f.typ for fields to include. + for i := 0; i < f.typ.NumField(); i++ { + sf := f.typ.Field(i) + if sf.Anonymous { + t := sf.Type + if t.Kind() == reflect.Pointer { + t = t.Elem() + } + if !sf.IsExported() && t.Kind() != reflect.Struct { + // Ignore embedded fields of unexported non-struct types. + continue + } + // Do not ignore embedded fields of unexported struct types + // since they may have exported fields. + } else if !sf.IsExported() { + // Ignore unexported non-embedded fields. + continue + } + tag := sf.Tag.Get("json") + if tag == "-" { + continue + } + name, opts := parseTag(tag) + if !isValidTag(name) { + name = "" + } + index := make([]int, len(f.index)+1) + copy(index, f.index) + index[len(f.index)] = i + + ft := sf.Type + if ft.Name() == "" && ft.Kind() == reflect.Pointer { + // Follow pointer. + ft = ft.Elem() + } + + // Only strings, floats, integers, and booleans can be quoted. + quoted := false + if opts.Contains("string") { + switch ft.Kind() { + case reflect.Bool, + reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, + reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr, + reflect.Float32, reflect.Float64, + reflect.String: + quoted = true + } + } + + // Record found field and index sequence. + if name != "" || !sf.Anonymous || ft.Kind() != reflect.Struct { + tagged := name != "" + if name == "" { + name = sf.Name + } + field := StdField{ + name: name, + tag: tagged, + index: index, + typ: ft, + omitEmpty: opts.Contains("omitempty"), + omitZero: opts.Contains("omitzero"), + quoted: quoted, + } + field.nameBytes = []byte(field.name) + + // Build nameEscHTML and nameNonEsc ahead of time. + nameEscBuf = alg.HtmlEscape(nameEscBuf[:0], field.nameBytes) + field.nameEscHTML = `"` + string(nameEscBuf) + `":` + field.nameNonEsc = `"` + field.name + `":` + + if field.omitZero { + t := sf.Type + // Provide a function that uses a type's IsZero method. + switch { + case t.Kind() == reflect.Interface && t.Implements(isZeroerType): + field.isZero = func(v reflect.Value) bool { + // Avoid panics calling IsZero on a nil interface or + // non-nil interface with nil pointer. + return v.IsNil() || + (v.Elem().Kind() == reflect.Pointer && v.Elem().IsNil()) || + v.Interface().(isZeroer).IsZero() + } + case t.Kind() == reflect.Pointer && t.Implements(isZeroerType): + field.isZero = func(v reflect.Value) bool { + // Avoid panics calling IsZero on nil pointer. + return v.IsNil() || v.Interface().(isZeroer).IsZero() + } + case t.Implements(isZeroerType): + field.isZero = func(v reflect.Value) bool { + return v.Interface().(isZeroer).IsZero() + } + case reflect.PointerTo(t).Implements(isZeroerType): + field.isZero = func(v reflect.Value) bool { + if !v.CanAddr() { + // Temporarily box v so we can take the address. + v2 := reflect.New(v.Type()).Elem() + v2.Set(v) + v = v2 + } + return v.Addr().Interface().(isZeroer).IsZero() + } + } + } + + fields = append(fields, field) + if count[f.typ] > 1 { + // If there were multiple instances, add a second, + // so that the annihilation code will see a duplicate. + // It only cares about the distinction between 1 and 2, + // so don't bother generating any more copies. + fields = append(fields, fields[len(fields)-1]) + } + continue + } + + // Record new anonymous struct to explore in next round. + nextCount[ft]++ + if nextCount[ft] == 1 { + next = append(next, StdField{name: ft.Name(), index: index, typ: ft}) + } + } + } + } + + sort.Slice(fields, func(i, j int) bool { + a, b := fields[i], fields[j] + // sort field by name, breaking ties with depth, then + // breaking ties with "name came from json tag", then + // breaking ties with index sequence. + if c := strings.Compare(a.name, b.name); c != 0 { + return c < 0 + } + if len(a.index) != len(b.index) { + return len(a.index) < len(b.index) + } + if a.tag != b.tag { + if a.tag { + return true + } + return false + } + return compare(a.index, b.index) < 0 + }) + + // Delete all fields that are hidden by the Go rules for embedded fields, + // except that fields with JSON tags are promoted. + + // The fields are sorted in primary order of name, secondary order + // of field index length. Loop over names; for each name, delete + // hidden fields by choosing the one dominant field that survives. + out := fields[:0] + for advance, i := 0, 0; i < len(fields); i += advance { + // One iteration per name. + // Find the sequence of fields with the name of this first field. + fi := fields[i] + name := fi.name + for advance = 1; i+advance < len(fields); advance++ { + fj := fields[i+advance] + if fj.name != name { + break + } + } + if advance == 1 { // Only one field with this name + out = append(out, fi) + continue + } + dominant, ok := dominantField(fields[i : i+advance]) + if ok { + out = append(out, dominant) + } + } + + fields = out + sort.Slice(fields, func(i, j int) bool { + a, b := fields[i], fields[j] + return compare(a.index, b.index) < 0 + }) + + exactNameIndex := make(map[string]*StdField, len(fields)) + foldedNameIndex := make(map[string]*StdField, len(fields)) + for i, field := range fields { + exactNameIndex[field.name] = &fields[i] + // For historical reasons, first folded match takes precedence. + if _, ok := foldedNameIndex[string(foldName(field.nameBytes))]; !ok { + foldedNameIndex[string(foldName(field.nameBytes))] = &fields[i] + } + } + return StdStructFields{fields, exactNameIndex, foldedNameIndex} +} + +func compare(s1, s2 []int) int { + for i, v1 := range s1 { + if i >= len(s2) { + return +1 + } + v2 := s2[i] + if v1 != v2 { + return v1 - v2 + } + } + if len(s1) < len(s2) { + return -1 + } + return 0 +} + +type isZeroer interface { + IsZero() bool +} + +var isZeroerType = reflect.TypeOf((*isZeroer)(nil)).Elem() + +// tagOptions is the string following a comma in a struct field's "json" +// tag, or the empty string. It does not include the leading comma. +type tagOptions string + +// parseTag splits a struct field's json tag into its name and +// comma-separated options. +func parseTag(tag string) (string, tagOptions) { + tag, opt, _ := strings.Cut(tag, ",") + return tag, tagOptions(opt) +} + +// Contains reports whether a comma-separated list of options +// contains a particular substr flag. substr must be surrounded by a +// string boundary or commas. +func (o tagOptions) Contains(optionName string) bool { + if len(o) == 0 { + return false + } + s := string(o) + for s != "" { + var name string + name, s, _ = strings.Cut(s, ",") + if name == optionName { + return true + } + } + return false +} + +func isValidTag(s string) bool { + if s == "" { + return false + } + for _, c := range s { + switch { + case strings.ContainsRune("!#$%&()*+-./:;<=>?@[]^_{|}~ ", c): + // Backslash and quote chars are reserved, but + // otherwise any punctuation chars are allowed + // in a tag name. + case !unicode.IsLetter(c) && !unicode.IsDigit(c): + return false + } + } + return true +} + +// dominantField looks through the fields, all of which are known to +// have the same name, to find the single field that dominates the +// others using Go's embedding rules, modified by the presence of +// JSON tags. If there are multiple top-level fields, the boolean +// will be false: This condition is an error in Go and we skip all +// the fields. +func dominantField(fields []StdField) (StdField, bool) { + // The fields are sorted in increasing index-length order, then by presence of tag. + // That means that the first field is the dominant one. We need only check + // for error cases: two fields at top level, either both tagged or neither tagged. + if len(fields) > 1 && len(fields[0].index) == len(fields[1].index) && fields[0].tag == fields[1].tag { + return StdField{}, false + } + return fields[0], true +} + + +// foldName returns a folded string such that foldName(x) == foldName(y) +// is identical to bytes.EqualFold(x, y). +func foldName(in []byte) []byte { + // This is inlinable to take advantage of "function outlining". + var arr [32]byte // large enough for most JSON names + return appendFoldedName(arr[:0], in) +} + +func appendFoldedName(out, in []byte) []byte { + for i := 0; i < len(in); { + // Handle single-byte ASCII. + if c := in[i]; c < utf8.RuneSelf { + if 'a' <= c && c <= 'z' { + c -= 'a' - 'A' + } + out = append(out, c) + i++ + continue + } + // Handle multi-byte Unicode. + r, n := utf8.DecodeRune(in[i:]) + out = utf8.AppendRune(out, foldRune(r)) + i += n + } + return out +} + +// foldRune is returns the smallest rune for all runes in the same fold set. +func foldRune(r rune) rune { + for { + r2 := unicode.SimpleFold(r) + if r2 <= r { + return r2 + } + r = r2 + } +} diff --git a/vendor/github.com/bytedance/sonic/internal/resolver/resolver.go b/vendor/github.com/bytedance/sonic/internal/resolver/resolver.go index 1c30ad113..4303c6744 100644 --- a/vendor/github.com/bytedance/sonic/internal/resolver/resolver.go +++ b/vendor/github.com/bytedance/sonic/internal/resolver/resolver.go @@ -21,6 +21,7 @@ import ( "reflect" "strings" "sync" + _ "unsafe" ) type FieldOpts int @@ -216,3 +217,10 @@ func ResolveStruct(vt reflect.Type) []FieldMeta { fieldCache[vt] = fm return fm } + +func handleOmitZero(fv StdField, fm *FieldMeta) { + if fv.omitZero { + fm.Opts |= F_omitzero + fm.IsZero = fv.isZero + } +} diff --git a/vendor/github.com/bytedance/sonic/internal/resolver/stubs_go120.go b/vendor/github.com/bytedance/sonic/internal/resolver/stubs_go120.go deleted file mode 100644 index c0276f544..000000000 --- a/vendor/github.com/bytedance/sonic/internal/resolver/stubs_go120.go +++ /dev/null @@ -1,51 +0,0 @@ -//go:build !go1.21 -// +build !go1.21 - -/* - * Copyright 2021 ByteDance Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package resolver - -import ( - _ `encoding/json` - `reflect` - _ `unsafe` -) - -type StdField struct { - name string - nameBytes []byte - equalFold func() - nameNonEsc string - nameEscHTML string - tag bool - index []int - typ reflect.Type - omitEmpty bool - quoted bool - encoder func() -} - -type StdStructFields struct { - list []StdField - nameIndex map[string]int -} - -//go:noescape -//go:linkname typeFields encoding/json.typeFields -func typeFields(_ reflect.Type) StdStructFields - -func handleOmitZero(f StdField, fv *FieldMeta) {} diff --git a/vendor/github.com/bytedance/sonic/internal/resolver/stubs_go123.go b/vendor/github.com/bytedance/sonic/internal/resolver/stubs_go123.go deleted file mode 100644 index a73f024f5..000000000 --- a/vendor/github.com/bytedance/sonic/internal/resolver/stubs_go123.go +++ /dev/null @@ -1,51 +0,0 @@ -//go:build go1.21 && !go1.24 -// +build go1.21,!go1.24 - -/* - * Copyright 2021 ByteDance Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package resolver - -import ( - _ `encoding/json` - `reflect` - _ `unsafe` -) - -type StdField struct { - name string - nameBytes []byte - nameNonEsc string - nameEscHTML string - tag bool - index []int - typ reflect.Type - omitEmpty bool - quoted bool - encoder func() -} - -type StdStructFields struct { - list []StdField - nameIndex map[string]*StdField - byFoldedName map[string]*StdField -} - -//go:noescape -//go:linkname typeFields encoding/json.typeFields -func typeFields(_ reflect.Type) StdStructFields - -func handleOmitZero(f StdField, fv *FieldMeta) {} diff --git a/vendor/github.com/bytedance/sonic/internal/resolver/stubs_latest.go b/vendor/github.com/bytedance/sonic/internal/resolver/stubs_latest.go deleted file mode 100644 index b9486a699..000000000 --- a/vendor/github.com/bytedance/sonic/internal/resolver/stubs_latest.go +++ /dev/null @@ -1,59 +0,0 @@ -//go:build go1.24 -// +build go1.24 - -/* - * Copyright 2021 ByteDance Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package resolver - -import ( - _ `encoding/json` - `reflect` - _ `unsafe` -) - -type StdField struct { - name string - nameBytes []byte - nameNonEsc string - nameEscHTML string - tag bool - index []int - typ reflect.Type - omitEmpty bool - omitZero bool - isZero func(reflect.Value) bool - quoted bool - encoder func() -} - -type StdStructFields struct { - list []StdField - nameIndex map[string]*StdField - byFoldedName map[string]*StdField -} - -//go:noescape -//go:linkname typeFields encoding/json.typeFields -func typeFields(_ reflect.Type) StdStructFields - -func handleOmitZero(fv StdField, fm *FieldMeta) { - if fv.omitZero { - fm.Opts |= F_omitzero - fm.IsZero = fv.isZero - } -} - diff --git a/vendor/github.com/bytedance/sonic/internal/rt/base64_amd64.go b/vendor/github.com/bytedance/sonic/internal/rt/base64_amd64.go index ec5ea88a0..9b0cfca72 100644 --- a/vendor/github.com/bytedance/sonic/internal/rt/base64_amd64.go +++ b/vendor/github.com/bytedance/sonic/internal/rt/base64_amd64.go @@ -1,4 +1,4 @@ -// +build amd64,go1.17,!go1.25 +// +build amd64,go1.17,!go1.26 package rt diff --git a/vendor/github.com/bytedance/sonic/internal/rt/base64_compat.go b/vendor/github.com/bytedance/sonic/internal/rt/base64_compat.go index bd3150fe0..e6abcb57d 100644 --- a/vendor/github.com/bytedance/sonic/internal/rt/base64_compat.go +++ b/vendor/github.com/bytedance/sonic/internal/rt/base64_compat.go @@ -1,4 +1,4 @@ -// +build !amd64 !go1.17 go1.25 +// +build !amd64 !go1.17 go1.26 package rt diff --git a/vendor/github.com/bytedance/sonic/internal/rt/gcwb.go b/vendor/github.com/bytedance/sonic/internal/rt/gcwb.go index bd3e4ef26..c9ad5fb2f 100644 --- a/vendor/github.com/bytedance/sonic/internal/rt/gcwb.go +++ b/vendor/github.com/bytedance/sonic/internal/rt/gcwb.go @@ -1,4 +1,4 @@ -// +build go1.21,!go1.25 +// +build go1.21,!go1.26 /* * Copyright 2021 ByteDance Inc. diff --git a/vendor/github.com/bytedance/sonic/internal/rt/map_nosiwss_go124.go b/vendor/github.com/bytedance/sonic/internal/rt/map_nosiwss_go124.go index 8ecb9878e..8dda15bb8 100644 --- a/vendor/github.com/bytedance/sonic/internal/rt/map_nosiwss_go124.go +++ b/vendor/github.com/bytedance/sonic/internal/rt/map_nosiwss_go124.go @@ -1,5 +1,5 @@ -//go:build go1.24 && !go1.25 && !goexperiment.swissmap -// +build go1.24,!go1.25,!goexperiment.swissmap +//go:build go1.24 && !go1.26 && !goexperiment.swissmap +// +build go1.24,!go1.26,!goexperiment.swissmap package rt diff --git a/vendor/github.com/bytedance/sonic/internal/rt/map_siwss_go124.go b/vendor/github.com/bytedance/sonic/internal/rt/map_siwss_go124.go index b5bf7803c..6a7907691 100644 --- a/vendor/github.com/bytedance/sonic/internal/rt/map_siwss_go124.go +++ b/vendor/github.com/bytedance/sonic/internal/rt/map_siwss_go124.go @@ -1,5 +1,5 @@ -//go:build go1.24 && !go1.25 && goexperiment.swissmap -// +build go1.24,!go1.25,goexperiment.swissmap +//go:build go1.24 && !go1.26 && goexperiment.swissmap +// +build go1.24,!go1.26,goexperiment.swissmap package rt diff --git a/vendor/github.com/bytedance/sonic/internal/rt/stubs.go b/vendor/github.com/bytedance/sonic/internal/rt/stubs.go index f692f1563..553f0f982 100644 --- a/vendor/github.com/bytedance/sonic/internal/rt/stubs.go +++ b/vendor/github.com/bytedance/sonic/internal/rt/stubs.go @@ -38,9 +38,6 @@ func Mapiterinit(t *GoMapType, m unsafe.Pointer, it *GoMapIterator) //go:linkname Maplen reflect.maplen func Maplen(h unsafe.Pointer) int -//go:linkname IsValidNumber encoding/json.isValidNumber -func IsValidNumber(s string) bool - //go:nosplit //go:linkname MemclrHasPointers runtime.memclrHasPointers //goland:noinspection GoUnusedParameter diff --git a/vendor/github.com/bytedance/sonic/internal/utils/skip.go b/vendor/github.com/bytedance/sonic/internal/utils/skip.go index e42bfe759..1ae77195b 100644 --- a/vendor/github.com/bytedance/sonic/internal/utils/skip.go +++ b/vendor/github.com/bytedance/sonic/internal/utils/skip.go @@ -76,4 +76,12 @@ func SkipNumber(src string, pos int) (ret int) { runtime.KeepAlive(src) return int(uintptr(sp) - uintptr((*rt.GoString)(unsafe.Pointer(&src)).Ptr)) -} \ No newline at end of file +} + +// Hack: this is used for both checking space and cause friendly compile errors in 32-bit arch. +const _Sonic_Not_Support_32Bit_Arch__Checking_32Bit_Arch_Here = (1 << ' ') | (1 << '\t') | (1 << '\r') | (1 << '\n') + + +func IsSpace(c byte) bool { + return (int(1< len(xregOrderC) { diff --git a/vendor/github.com/bytedance/sonic/loader/internal/iasm/expr/errors.go b/vendor/github.com/bytedance/sonic/loader/internal/iasm/expr/errors.go index 791c18bd6..ca27b04c7 100644 --- a/vendor/github.com/bytedance/sonic/loader/internal/iasm/expr/errors.go +++ b/vendor/github.com/bytedance/sonic/loader/internal/iasm/expr/errors.go @@ -37,7 +37,7 @@ func (self *SyntaxError) Error() string { return fmt.Sprintf("Syntax error at position %d: %s", self.Pos, self.Reason) } -// RuntimeError is an error which would occure at run time. +// RuntimeError is an error which would occur at run time. type RuntimeError struct { Reason string } diff --git a/vendor/github.com/bytedance/sonic/loader/internal/iasm/x86_64/program.go b/vendor/github.com/bytedance/sonic/loader/internal/iasm/x86_64/program.go index bf7d3a1dc..1c0c7cc00 100644 --- a/vendor/github.com/bytedance/sonic/loader/internal/iasm/x86_64/program.go +++ b/vendor/github.com/bytedance/sonic/loader/internal/iasm/x86_64/program.go @@ -112,7 +112,7 @@ func (self *_Pseudo) evalExpr(low int64, high int64) int64 { func (self *_Pseudo) alignSize(pc uintptr) int { if !ispow2(self.uint) { - panic(fmt.Sprintf("aligment should be a power of 2, not %d", self.uint)) + panic(fmt.Sprintf("alignment should be a power of 2, not %d", self.uint)) } else { return align(int(pc), bits.TrailingZeros64(self.uint)) - int(pc) } @@ -469,7 +469,7 @@ func (self *Program) Free() { // Link pins a label at the current position. func (self *Program) Link(p *Label) { if p.Dest != nil { - panic("lable was alreay linked") + panic("label was already linked") } else { p.Dest = self.pseudo(_PseudoNop) } diff --git a/vendor/github.com/bytedance/sonic/sonic.go b/vendor/github.com/bytedance/sonic/sonic.go index 9645d5e08..3a5aff22f 100644 --- a/vendor/github.com/bytedance/sonic/sonic.go +++ b/vendor/github.com/bytedance/sonic/sonic.go @@ -1,5 +1,5 @@ -//go:build (amd64 && go1.17 && !go1.25) || (arm64 && go1.20 && !go1.25) -// +build amd64,go1.17,!go1.25 arm64,go1.20,!go1.25 +//go:build (amd64 && go1.17 && !go1.26) || (arm64 && go1.20 && !go1.26) +// +build amd64,go1.17,!go1.26 arm64,go1.20,!go1.26 /* * Copyright 2021 ByteDance Inc. @@ -17,7 +17,6 @@ * limitations under the License. */ -//go:generate make package sonic import ( diff --git a/vendor/github.com/bytedance/sonic/unquote/unquote.go b/vendor/github.com/bytedance/sonic/unquote/unquote.go index 29b2fcde8..6c8c0c80f 100644 --- a/vendor/github.com/bytedance/sonic/unquote/unquote.go +++ b/vendor/github.com/bytedance/sonic/unquote/unquote.go @@ -1,3 +1,7 @@ +//go:build (amd64 && go1.17 && !go1.26) || (arm64 && go1.20 && !go1.26) +// +build amd64,go1.17,!go1.26 arm64,go1.20,!go1.26 + + /* * Copyright 2021 ByteDance Inc. * diff --git a/vendor/github.com/bytedance/sonic/unquote/unquote_fallback.go b/vendor/github.com/bytedance/sonic/unquote/unquote_fallback.go new file mode 100644 index 000000000..41e28f067 --- /dev/null +++ b/vendor/github.com/bytedance/sonic/unquote/unquote_fallback.go @@ -0,0 +1,206 @@ +// +build !amd64,!arm64 go1.26 !go1.17 arm64,!go1.20 + +/* + * Copyright 2021 ByteDance Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package unquote + +import ( + "unicode" + "unicode/utf16" + "unicode/utf8" + + "github.com/bytedance/sonic/internal/rt" + "github.com/bytedance/sonic/internal/native/types" +) + +// getu4 decodes \uXXXX from the beginning of s, returning the hex value, +// or it returns -1. +func getu4(s []byte) rune { + if len(s) < 6 || s[0] != '\\' || s[1] != 'u' { + return -1 + } + var r rune + for _, c := range s[2:6] { + switch { + case '0' <= c && c <= '9': + c = c - '0' + case 'a' <= c && c <= 'f': + c = c - 'a' + 10 + case 'A' <= c && c <= 'F': + c = c - 'A' + 10 + default: + return -1 + } + r = r*16 + rune(c) + } + return r +} + + +// unquoteBytes is a fallback implementation copied from Go standard library +// encoding/json/decode.go. This is used when native unquote is not available. +func unquoteBytes(s []byte) (t []byte, ok bool) { + // Check for unusual characters. If there are none, + // then no unquoting is needed, so return a slice of the + // original bytes. + r := 0 + for r < len(s) { + c := s[r] + if c == '\\' || c == '"' || c < ' ' { + break + } + if c < utf8.RuneSelf { + r++ + continue + } + rr, size := utf8.DecodeRune(s[r:]) + if rr == utf8.RuneError && size == 1 { + break + } + r += size + } + if r == len(s) { + return s, true + } + + b := make([]byte, len(s)+2*utf8.UTFMax) + w := copy(b, s[0:r]) + for r < len(s) { + // Out of room? Can only happen if s is full of + // malformed UTF-8 and we're replacing each + // byte with RuneError. + if w >= len(b)-2*utf8.UTFMax { + nb := make([]byte, (len(b)+utf8.UTFMax)*2) + copy(nb, b[0:w]) + b = nb + } + switch c := s[r]; { + case c == '\\': + r++ + if r >= len(s) { + return + } + switch s[r] { + default: + return + case '"', '\\', '/', '\'': + b[w] = s[r] + r++ + w++ + case 'b': + b[w] = '\b' + r++ + w++ + case 'f': + b[w] = '\f' + r++ + w++ + case 'n': + b[w] = '\n' + r++ + w++ + case 'r': + b[w] = '\r' + r++ + w++ + case 't': + b[w] = '\t' + r++ + w++ + case 'u': + r-- + rr := getu4(s[r:]) + if rr < 0 { + return + } + r += 6 + if utf16.IsSurrogate(rr) { + rr1 := getu4(s[r:]) + if dec := utf16.DecodeRune(rr, rr1); dec != unicode.ReplacementChar { + // A valid pair; consume. + r += 6 + w += utf8.EncodeRune(b[w:], dec) + break + } + // Invalid surrogate; fall back to replacement rune. + rr = unicode.ReplacementChar + } + w += utf8.EncodeRune(b[w:], rr) + } + + // Quote, control characters are invalid. + case c == '"', c < ' ': + return + + // ASCII + case c < utf8.RuneSelf: + b[w] = c + r++ + w++ + + // Coerce to well-formed UTF-8. + default: + rr, size := utf8.DecodeRune(s[r:]) + r += size + w += utf8.EncodeRune(b[w:], rr) + } + } + return b[0:w], true +} + + +// getu4Fallback decodes a 4-byte hex sequence from the beginning of s. +// It is copied from Go standard library encoding/json.decode.go. +func getu4Fallback(s []byte) rune { + if len(s) < 6 || s[0] != '\\' || s[1] != 'u' { + return -1 + } + var r rune + for _, c := range s[2:6] { + switch { + case '0' <= c && c <= '9': + c = c - '0' + case 'a' <= c && c <= 'f': + c = c - 'a' + 10 + case 'A' <= c && c <= 'F': + c = c - 'A' + 10 + default: + return -1 + } + r = r*16 + rune(c) + } + return r +} + + +// String unescapes an escaped string (not including `"` at beginning and end) +// It validates invalid UTF8 and replace with `\ufffd` +func String(s string) (ret string, err types.ParsingError) { + // Convert string to []byte and use fallback implementation + sBytes := rt.Str2Mem(s) + result, ok := unquoteBytes(sBytes) + if !ok { + return "", types.ERR_INVALID_ESCAPE + } + return string(result), 0 +} + +// String unescapes an escaped string (not including `"` at beginning and end) +// - replace enables replacing invalid utf8 escaped char with `\uffd` +func _String(s string, _replace bool) (ret string, err error) { + return String(s) +} diff --git a/vendor/github.com/bytedance/sonic/utf8/utf8.go b/vendor/github.com/bytedance/sonic/utf8/utf8.go index c1403fdb2..71403028e 100644 --- a/vendor/github.com/bytedance/sonic/utf8/utf8.go +++ b/vendor/github.com/bytedance/sonic/utf8/utf8.go @@ -1,3 +1,6 @@ +//go:build (amd64 && go1.17 && !go1.26) || (arm64 && go1.20 && !go1.26) +// +build amd64,go1.17,!go1.26 arm64,go1.20,!go1.26 + /* * Copyright 2022 ByteDance Inc. * diff --git a/vendor/github.com/bytedance/sonic/utf8/utf8_fallback.go b/vendor/github.com/bytedance/sonic/utf8/utf8_fallback.go new file mode 100644 index 000000000..bd12fcd1c --- /dev/null +++ b/vendor/github.com/bytedance/sonic/utf8/utf8_fallback.go @@ -0,0 +1,37 @@ +// +build !amd64,!arm64 go1.26 !go1.17 arm64,!go1.20 + +/* + * Copyright 2021 ByteDance Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package utf8 + +import ( + "unicode/utf8" + + "github.com/bytedance/sonic/internal/rt" +) + +// ValidateFallback validates UTF-8 encoded bytes using standard library. +// This is used when native UTF-8 validation is not available. +func Validate(src []byte) bool { + return utf8.Valid(src) +} + +// ValidateStringFallback validates UTF-8 encoded string using standard library. +// This is used when native UTF-8 validation is not available. +func ValidateString(src string) bool { + return utf8.Valid(rt.Str2Mem(src)) +} -- cgit v1.2.3