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 --- .../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 +- 159 files changed, 56426 insertions(+), 54929 deletions(-) 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 (limited to 'vendor/github.com/bytedance/sonic/internal') 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<