From 51b9ef5c346f333e558eca38fd954464322f3b7d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 14 Apr 2025 09:43:56 +0200 Subject: [chore]: Bump github.com/gin-contrib/gzip from 1.2.2 to 1.2.3 (#4000) Bumps [github.com/gin-contrib/gzip](https://github.com/gin-contrib/gzip) from 1.2.2 to 1.2.3. - [Release notes](https://github.com/gin-contrib/gzip/releases) - [Changelog](https://github.com/gin-contrib/gzip/blob/master/.goreleaser.yaml) - [Commits](https://github.com/gin-contrib/gzip/compare/v1.2.2...v1.2.3) --- updated-dependencies: - dependency-name: github.com/gin-contrib/gzip dependency-version: 1.2.3 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .../sonic/internal/encoder/alg/mapiter.go | 11 ++++---- .../sonic/internal/encoder/alg/primitives.go | 17 +++++++++--- .../bytedance/sonic/internal/encoder/alg/spec.go | 4 +-- .../sonic/internal/encoder/alg/spec_compat.go | 2 +- .../bytedance/sonic/internal/encoder/compiler.go | 29 +++++++++++++------- .../bytedance/sonic/internal/encoder/ir/op.go | 28 +++++++++++++++++++ .../sonic/internal/encoder/pools_amd64.go | 21 +-------------- .../sonic/internal/encoder/vars/errors.go | 4 +++ .../bytedance/sonic/internal/encoder/vm/vm.go | 24 ++++++++--------- .../internal/encoder/x86/asm_stubs_amd64_go121.go | 4 +-- .../internal/encoder/x86/assembler_regabi_amd64.go | 31 +++++++++++++++++++--- .../sonic/internal/encoder/x86/debug_go117.go | 4 +-- .../bytedance/sonic/internal/encoder/x86/stbus.go | 3 --- 13 files changed, 119 insertions(+), 63 deletions(-) (limited to 'vendor/github.com/bytedance/sonic/internal/encoder') 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 5d9956a90..032ae3b8a 100644 --- a/vendor/github.com/bytedance/sonic/internal/encoder/alg/mapiter.go +++ b/vendor/github.com/bytedance/sonic/internal/encoder/alg/mapiter.go @@ -165,19 +165,20 @@ func IteratorNext(p *MapIterator) { p.ki++ } -func IteratorStart(t *rt.GoMapType, m *rt.GoMap, fv uint64) (*MapIterator, error) { +func IteratorStart(t *rt.GoMapType, m unsafe.Pointer, fv uint64) (*MapIterator, error) { it := newIterator() rt.Mapiterinit(t, m, &it.It) + count := rt.Maplen(m) /* check for key-sorting, empty map don't need sorting */ - if m.Count == 0 || (fv & (1< it.kv.Cap { - it.kv = rt.GrowSlice(iteratorPair, it.kv, m.Count) + if count > it.kv.Cap { + it.kv = rt.GrowSlice(iteratorPair, it.kv, count) } /* dump all the key-value pairs */ @@ -189,7 +190,7 @@ func IteratorStart(t *rt.GoMapType, m *rt.GoMap, fv uint64) (*MapIterator, error } /* sort the keys, map with only 1 item don't need sorting */ - if it.ki = 1; m.Count > 1 { + if it.ki = 1; count > 1 { radixQsort(it.data(), 0, maxDepth(it.kv.Len)) } diff --git a/vendor/github.com/bytedance/sonic/internal/encoder/alg/primitives.go b/vendor/github.com/bytedance/sonic/internal/encoder/alg/primitives.go index 63fa01890..e2610fbc8 100644 --- a/vendor/github.com/bytedance/sonic/internal/encoder/alg/primitives.go +++ b/vendor/github.com/bytedance/sonic/internal/encoder/alg/primitives.go @@ -1,12 +1,12 @@ /** * 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. @@ -19,8 +19,11 @@ 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" ) @@ -92,4 +95,10 @@ func EncodeTextMarshaler(buf *[]byte, val encoding.TextMarshaler, opt uint64) er return nil } } - \ No newline at end of file + +func IsZero(val unsafe.Pointer, fv *resolver.FieldMeta) bool { + rv := reflect.NewAt(fv.Type, val).Elem() + b1 := fv.IsZero == nil && rv.IsZero() + b2 := fv.IsZero != nil && fv.IsZero(rv) + return b1 || b2 +} diff --git a/vendor/github.com/bytedance/sonic/internal/encoder/alg/spec.go b/vendor/github.com/bytedance/sonic/internal/encoder/alg/spec.go index bff943626..6f76ac739 100644 --- a/vendor/github.com/bytedance/sonic/internal/encoder/alg/spec.go +++ b/vendor/github.com/bytedance/sonic/internal/encoder/alg/spec.go @@ -1,5 +1,5 @@ -//go:build (amd64 && go1.16 && !go1.24) || (arm64 && go1.20 && !go1.24) -// +build amd64,go1.16,!go1.24 arm64,go1.20,!go1.24 +//go:build (amd64 && go1.16 && !go1.25) || (arm64 && go1.20 && !go1.25) +// +build amd64,go1.16,!go1.25 arm64,go1.20,!go1.25 /** * Copyright 2024 ByteDance Inc. 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 c15cbf7d8..cd8369834 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.24 !go1.16 arm64,!go1.20 +// +build !amd64,!arm64 go1.25 !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 902fbc98b..737dd3e07 100644 --- a/vendor/github.com/bytedance/sonic/internal/encoder/compiler.go +++ b/vendor/github.com/bytedance/sonic/internal/encoder/compiler.go @@ -219,7 +219,7 @@ func (self *Compiler) compileOps(p *ir.Program, sp int, vt reflect.Type) { case reflect.Struct: self.compileStruct(p, sp, vt) default: - panic(vars.Error_type(vt)) + self.compileUnsupportedType(p, vt) } } @@ -440,7 +440,8 @@ func (self *Compiler) compileStructBody(p *ir.Program, sp int, vt reflect.Type) p.Add(ir.OP_cond_set) /* compile each field */ - for _, fv := range resolver.ResolveStruct(vt) { + fvs := resolver.ResolveStruct(vt) + for i, fv := range fvs { var s []int var o resolver.Offset @@ -463,7 +464,12 @@ func (self *Compiler) compileStructBody(p *ir.Program, sp int, vt reflect.Type) /* check for "omitempty" option */ if fv.Type.Kind() != reflect.Struct && fv.Type.Kind() != reflect.Array && (fv.Opts&resolver.F_omitempty) != 0 { s = append(s, p.PC()) - self.compileStructFieldZero(p, fv.Type) + self.compileStructFieldEmpty(p, fv.Type) + } + /* check for "omitzero" option */ + if fv.Opts&resolver.F_omitzero != 0 { + s = append(s, p.PC()) + p.VField(ir.OP_is_zero, &fvs[i]) } /* add the comma if not the first element */ @@ -574,7 +580,7 @@ func (self *Compiler) compileStructFieldStr(p *ir.Program, sp int, vt reflect.Ty } } -func (self *Compiler) compileStructFieldZero(p *ir.Program, vt reflect.Type) { +func (self *Compiler) compileStructFieldEmpty(p *ir.Program, vt reflect.Type) { switch vt.Kind() { case reflect.Bool: p.Add(ir.OP_is_zero_1) @@ -626,16 +632,16 @@ func (self *Compiler) compileStructFieldQuoted(p *ir.Program, sp int, vt reflect } func (self *Compiler) compileInterface(p *ir.Program, vt reflect.Type) { - x := p.PC() - p.Add(ir.OP_is_nil_p1) - /* iface and efaces are different */ if vt.NumMethod() == 0 { p.Add(ir.OP_eface) - } else { - p.Add(ir.OP_iface) + return } + x := p.PC() + p.Add(ir.OP_is_nil_p1) + p.Add(ir.OP_iface) + /* the "null" value */ e := p.PC() p.Add(ir.OP_goto) @@ -644,6 +650,11 @@ func (self *Compiler) compileInterface(p *ir.Program, vt reflect.Type) { p.Pin(e) } +func (self *Compiler) compileUnsupportedType(p *ir.Program, vt reflect.Type) { + p.Rtt(ir.OP_unsupported, vt) +} + + func (self *Compiler) compileMarshaler(p *ir.Program, op ir.Op, vt reflect.Type, mt reflect.Type) { pc := p.PC() vk := vt.Kind() diff --git a/vendor/github.com/bytedance/sonic/internal/encoder/ir/op.go b/vendor/github.com/bytedance/sonic/internal/encoder/ir/op.go index a0c693f00..fe5a4ebe7 100644 --- a/vendor/github.com/bytedance/sonic/internal/encoder/ir/op.go +++ b/vendor/github.com/bytedance/sonic/internal/encoder/ir/op.go @@ -24,6 +24,7 @@ import ( "unsafe" "github.com/bytedance/sonic/internal/encoder/vars" + "github.com/bytedance/sonic/internal/resolver" "github.com/bytedance/sonic/internal/rt" ) @@ -80,6 +81,8 @@ const ( OP_marshal_text_p OP_cond_set OP_cond_testc + OP_unsupported + OP_is_zero ) const ( @@ -141,6 +144,7 @@ var OpNames = [256]string{ OP_marshal_text_p: "marshal_text_p", OP_cond_set: "cond_set", OP_cond_testc: "cond_testc", + OP_unsupported: "unsupported type", } func (self Op) String() string { @@ -229,6 +233,11 @@ type typAndTab struct { itab *rt.GoItab } +type typAndField struct { + vt reflect.Type + fv *resolver.FieldMeta +} + func NewInsVtab(op Op, vt reflect.Type, itab *rt.GoItab) Instr { return Instr{ o: op, @@ -239,6 +248,13 @@ func NewInsVtab(op Op, vt reflect.Type, itab *rt.GoItab) Instr { } } +func NewInsField(op Op, fv *resolver.FieldMeta) Instr { + return Instr{ + o: op, + p: unsafe.Pointer(fv), + } +} + func NewInsVp(op Op, vt reflect.Type, pv bool) Instr { i := 0 if pv { @@ -263,6 +279,10 @@ func (self Instr) Vf() uint8 { return (*rt.GoType)(self.p).KindFlags } +func (self Instr) VField() (*resolver.FieldMeta) { + return (*resolver.FieldMeta)(self.p) +} + func (self Instr) Vs() (v string) { (*rt.GoString)(unsafe.Pointer(&v)).Ptr = self.p (*rt.GoString)(unsafe.Pointer(&v)).Len = self.Vi() @@ -273,6 +293,10 @@ func (self Instr) Vk() reflect.Kind { return (*rt.GoType)(self.p).Kind() } +func (self Instr) GoType() *rt.GoType { + return (*rt.GoType)(self.p) +} + func (self Instr) Vt() reflect.Type { return (*rt.GoType)(self.p).Pack() } @@ -442,6 +466,10 @@ func (self *Program) Vtab(op Op, vt reflect.Type, itab *rt.GoItab) { *self = append(*self, NewInsVtab(op, vt, itab)) } +func (self *Program) VField(op Op, fv *resolver.FieldMeta) { + *self = append(*self, NewInsField(op, fv)) +} + func (self Program) Disassemble() string { nb := len(self) tab := make([]bool, nb+1) diff --git a/vendor/github.com/bytedance/sonic/internal/encoder/pools_amd64.go b/vendor/github.com/bytedance/sonic/internal/encoder/pools_amd64.go index 43f026fbe..eda46025d 100644 --- a/vendor/github.com/bytedance/sonic/internal/encoder/pools_amd64.go +++ b/vendor/github.com/bytedance/sonic/internal/encoder/pools_amd64.go @@ -17,7 +17,6 @@ package encoder import ( - "errors" "reflect" "unsafe" @@ -52,29 +51,11 @@ var _KeepAlive struct { frame [x86.FP_offs]byte } -var errCallShadow = errors.New("DON'T CALL THIS!") - -// Faker func of _Encoder, used to export its stackmap as _Encoder's -func _Encoder_Shadow(rb *[]byte, vp unsafe.Pointer, sb *vars.Stack, fv uint64) (err error) { - // align to assembler_amd64.go: x86.FP_offs - var frame [x86.FP_offs]byte - - // must keep all args and frames noticeable to GC - _KeepAlive.rb = rb - _KeepAlive.vp = vp - _KeepAlive.sb = sb - _KeepAlive.fv = fv - _KeepAlive.err = err - _KeepAlive.frame = frame - - return errCallShadow -} - func makeEncoderX86(vt *rt.GoType, ex ...interface{}) (interface{}, error) { pp, err := NewCompiler().Compile(vt.Pack(), ex[0].(bool)) if err != nil { return nil, err - } + } as := x86.NewAssembler(pp) as.Name = vt.String() return as.Load(), nil diff --git a/vendor/github.com/bytedance/sonic/internal/encoder/vars/errors.go b/vendor/github.com/bytedance/sonic/internal/encoder/vars/errors.go index 77919c44a..ca3bbca1f 100644 --- a/vendor/github.com/bytedance/sonic/internal/encoder/vars/errors.go +++ b/vendor/github.com/bytedance/sonic/internal/encoder/vars/errors.go @@ -47,6 +47,10 @@ func Error_number(number json.Number) error { } } +func Error_unsuppoted(typ *rt.GoType) error { + return &json.UnsupportedTypeError{Type: typ.Pack() } +} + func Error_marshaler(ret []byte, pos int) error { return fmt.Errorf("invalid Marshaler output json syntax at %d: %q", pos, ret) } diff --git a/vendor/github.com/bytedance/sonic/internal/encoder/vm/vm.go b/vendor/github.com/bytedance/sonic/internal/encoder/vm/vm.go index b75ba807a..aa3f515ce 100644 --- a/vendor/github.com/bytedance/sonic/internal/encoder/vm/vm.go +++ b/vendor/github.com/bytedance/sonic/internal/encoder/vm/vm.go @@ -26,7 +26,6 @@ import ( "github.com/bytedance/sonic/internal/encoder/ir" "github.com/bytedance/sonic/internal/encoder/vars" "github.com/bytedance/sonic/internal/rt" - "github.com/bytedance/sonic/internal/base64" ) const ( @@ -176,7 +175,7 @@ func Execute(b *[]byte, p unsafe.Pointer, s *vars.Stack, flags uint64, prog *ir. buf = alg.F64toa(buf, v) case ir.OP_bin: v := *(*[]byte)(p) - buf = base64.EncodeBase64(buf, v) + buf = rt.EncodeBase64(buf, v) case ir.OP_quote: v := *(*string)(p) buf = alg.Quote(buf, v, true) @@ -202,13 +201,13 @@ func Execute(b *[]byte, p unsafe.Pointer, s *vars.Stack, flags uint64, prog *ir. } buf = *b case ir.OP_is_zero_map: - v := *(**rt.GoMap)(p) - if v == nil || v.Count == 0 { + v := *(*unsafe.Pointer)(p) + if v == nil || rt.Maplen(v) == 0 { pc = ins.Vi() continue } case ir.OP_map_iter: - v := *(**rt.GoMap)(p) + v := *(*unsafe.Pointer)(p) vt := ins.Vr() it, err := alg.IteratorStart(rt.MapType(vt), v, flags) if err != nil { @@ -284,6 +283,12 @@ func Execute(b *[]byte, p unsafe.Pointer, s *vars.Stack, flags uint64, prog *ir. pc = ins.Vi() continue } + case ir.OP_is_zero: + fv := ins.VField() + if alg.IsZero(p, fv) { + pc = ins.Vi() + continue + } case ir.OP_is_zero_1: if *(*uint8)(p) == 0 { pc = ins.Vi() @@ -338,6 +343,8 @@ func Execute(b *[]byte, p unsafe.Pointer, s *vars.Stack, flags uint64, prog *ir. if err := alg.EncodeJsonMarshaler(&buf, *(*json.Marshaler)(unsafe.Pointer(&it)), (flags)); err != nil { return err } + case ir.OP_unsupported: + return vars.Error_unsuppoted(ins.GoType()) default: panic(fmt.Sprintf("not implement %s at %d", ins.Op().String(), pc)) } @@ -347,13 +354,6 @@ func Execute(b *[]byte, p unsafe.Pointer, s *vars.Stack, flags uint64, prog *ir. return nil } -// func to_buf(w unsafe.Pointer, l int, c int) []byte { -// return rt.BytesFrom(unsafe.Pointer(uintptr(w)-uintptr(l)), l, c) -// } - -// func from_buf(buf []byte) (unsafe.Pointer, int, int) { -// return rt.IndexByte(buf, len(buf)), len(buf), cap(buf) -// } func has_opts(opts uint64, bit int) bool { return opts & (1<