[chore]: Bump github.com/gin-contrib/gzip from 1.2.2 to 1.2.3

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] <support@github.com>
This commit is contained in:
dependabot[bot] 2025-04-14 06:15:04 +00:00 committed by GitHub
commit 41a5f6e513
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
220 changed files with 127887 additions and 125516 deletions

View file

@ -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<<BitSortMapKeys)) == 0 {
if count == 0 || (fv & (1<<BitSortMapKeys)) == 0 {
it.ki = -1
return it, nil
}
/* pre-allocate space if needed */
if m.Count > 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))
}

View file

@ -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
}
}
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
}

View file

@ -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.

View file

@ -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.

View file

@ -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()

View file

@ -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)

View file

@ -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

View file

@ -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)
}

View file

@ -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<<bit) != 0

View file

@ -1,5 +1,5 @@
//go:build go1.21 && !go1.24
// +build go1.21,!go1.24
//go:build go1.21 && !go1.25
// +build go1.21,!go1.25
// Copyright 2023 CloudWeGo Authors
//

View file

@ -1,5 +1,5 @@
//go:build go1.17 && !go1.24
// +build go1.17,!go1.24
//go:build go1.17 && !go1.25
// +build go1.17,!go1.25
/*
* Copyright 2021 ByteDance Inc.
@ -265,6 +265,8 @@ var _OpFuncTab = [256]func(*Assembler, *ir.Instr){
ir.OP_marshal_text_p: (*Assembler)._asm_OP_marshal_text_p,
ir.OP_cond_set: (*Assembler)._asm_OP_cond_set,
ir.OP_cond_testc: (*Assembler)._asm_OP_cond_testc,
ir.OP_unsupported: (*Assembler)._asm_OP_unsupported,
ir.OP_is_zero: (*Assembler)._asm_OP_is_zero,
}
func (self *Assembler) instr(v *ir.Instr) {
@ -756,7 +758,7 @@ var (
_F_f32toa = jit.Imm(int64(native.S_f32toa))
_F_i64toa = jit.Imm(int64(native.S_i64toa))
_F_u64toa = jit.Imm(int64(native.S_u64toa))
_F_b64encode = jit.Imm(int64(_subr__b64encode))
_F_b64encode = jit.Imm(int64(rt.SubrB64Encode))
)
var (
@ -1097,6 +1099,20 @@ func (self *Assembler) _asm_OP_is_zero_map(p *ir.Instr) {
self.Xjmp("JE", p.Vi()) // JE p.Vi()
}
var (
_F_is_zero = jit.Func(alg.IsZero)
_T_reflect_Type = rt.UnpackIface(reflect.Type(nil))
)
func (self *Assembler) _asm_OP_is_zero(p *ir.Instr) {
fv := p.VField()
self.Emit("MOVQ", _SP_p, _AX) // ptr
self.Emit("MOVQ", jit.ImmPtr(unsafe.Pointer(fv)), _BX) // fv
self.call_go(_F_is_zero) // CALL $fn
self.Emit("CMPB", _AX, jit.Imm(0)) // CMPB (SP.p), $0
self.Xjmp("JNE", p.Vi()) // JE p.Vi()
}
func (self *Assembler) _asm_OP_goto(p *ir.Instr) {
self.Xjmp("JMP", p.Vi())
}
@ -1187,6 +1203,15 @@ func (self *Assembler) _asm_OP_cond_testc(p *ir.Instr) {
self.Xjmp("JC", p.Vi())
}
var _F_error_unsupported = jit.Func(vars.Error_unsuppoted)
func (self *Assembler) _asm_OP_unsupported(i *ir.Instr) {
typ := int64(uintptr(unsafe.Pointer(i.GoType())))
self.Emit("MOVQ", jit.Imm(typ), _AX)
self.call_go(_F_error_unsupported)
self.Sjmp("JMP", _LB_error)
}
func (self *Assembler) print_gc(i int, p1 *ir.Instr, p2 *ir.Instr) {
self.Emit("MOVQ", jit.Imm(int64(p2.Op())), _CX) // MOVQ $(p2.Op()), AX
self.Emit("MOVQ", jit.Imm(int64(p1.Op())), _BX) // MOVQ $(p1.Op()), BX

View file

@ -1,5 +1,5 @@
//go:build go1.17 && !go1.24
// +build go1.17,!go1.24
//go:build go1.17 && !go1.25
// +build go1.17,!go1.25
/*
* Copyright 2021 ByteDance Inc.

View file

@ -27,9 +27,6 @@ import (
_ "github.com/cloudwego/base64x"
)
//go:linkname _subr__b64encode github.com/cloudwego/base64x._subr__b64encode
var _subr__b64encode uintptr
var compiler func(*rt.GoType, ... interface{}) (interface{}, error)
func SetCompiler(c func(*rt.GoType, ... interface{}) (interface{}, error)) {