diff options
Diffstat (limited to 'vendor/github.com/bytedance/sonic/internal/rt')
18 files changed, 0 insertions, 1456 deletions
diff --git a/vendor/github.com/bytedance/sonic/internal/rt/asm_amd64.s b/vendor/github.com/bytedance/sonic/internal/rt/asm_amd64.s deleted file mode 100644 index 48a564bee..000000000 --- a/vendor/github.com/bytedance/sonic/internal/rt/asm_amd64.s +++ /dev/null @@ -1,20 +0,0 @@ -// +build !noasm,amd64 !appengine,amd64 -// Code generated by asm2asm, DO NOT EDIT· - -#include "go_asm.h" -#include "funcdata.h" -#include "textflag.h" - -TEXT ·MoreStack(SB), NOSPLIT, $0 - 8 - NO_LOCAL_POINTERS -_entry: - MOVQ (TLS), R14 - MOVQ size+0(FP), R12 - NOTQ R12 - LEAQ (SP)(R12*1), R12 - CMPQ R12, 16(R14) - JBE _stack_grow - RET -_stack_grow: - CALL runtime·morestack_noctxt<>(SB) - JMP _entry diff --git a/vendor/github.com/bytedance/sonic/internal/rt/asm_compat.s b/vendor/github.com/bytedance/sonic/internal/rt/asm_compat.s deleted file mode 100644 index c807d8343..000000000 --- a/vendor/github.com/bytedance/sonic/internal/rt/asm_compat.s +++ /dev/null @@ -1,10 +0,0 @@ -// +build !noasm,!amd64 !appengine,!amd64 -// Code generated by asm2asm, DO NOT EDIT. - -#include "go_asm.h" -#include "funcdata.h" -#include "textflag.h" - -TEXT ·MoreStack(SB), NOSPLIT, $0 - 8 - NO_LOCAL_POINTERS - RET diff --git a/vendor/github.com/bytedance/sonic/internal/rt/assertI2I.go b/vendor/github.com/bytedance/sonic/internal/rt/assertI2I.go deleted file mode 100644 index d19376a60..000000000 --- a/vendor/github.com/bytedance/sonic/internal/rt/assertI2I.go +++ /dev/null @@ -1,42 +0,0 @@ -// +build go1.17 - -/* - * 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 rt - -import ( - _ `unsafe` -) - -func AssertI2I(t *GoType, i GoIface) (r GoIface) { - inter := IfaceType(t) - tab := i.Itab - if tab == nil { - return - } - if (*GoInterfaceType)(tab.it) != inter { - tab = GetItab(inter, tab.Vt, true) - if tab == nil { - return - } - } - r.Itab = tab - r.Value = i.Value - return -} - - diff --git a/vendor/github.com/bytedance/sonic/internal/rt/base64_amd64.go b/vendor/github.com/bytedance/sonic/internal/rt/base64_amd64.go deleted file mode 100644 index 263bc592f..000000000 --- a/vendor/github.com/bytedance/sonic/internal/rt/base64_amd64.go +++ /dev/null @@ -1,20 +0,0 @@ -// +build amd64,go1.17,!go1.24 - -package rt - -import ( - "github.com/cloudwego/base64x" -) - -func DecodeBase64(raw []byte) ([]byte, error) { - ret := make([]byte, base64x.StdEncoding.DecodedLen(len(raw))) - n, err := base64x.StdEncoding.Decode(ret, raw) - if err != nil { - return nil, err - } - return ret[:n], nil -} - -func EncodeBase64(src []byte) string { - return base64x.StdEncoding.EncodeToString(src) -} diff --git a/vendor/github.com/bytedance/sonic/internal/rt/base64_compat.go b/vendor/github.com/bytedance/sonic/internal/rt/base64_compat.go deleted file mode 100644 index 791f79355..000000000 --- a/vendor/github.com/bytedance/sonic/internal/rt/base64_compat.go +++ /dev/null @@ -1,20 +0,0 @@ -// +build !amd64 !go1.17 go1.24 - -package rt - -import ( - "encoding/base64" -) - -func DecodeBase64(raw []byte) ([]byte, error) { - ret := make([]byte, base64.StdEncoding.DecodedLen(len(raw))) - n, err := base64.StdEncoding.Decode(ret, raw) - if err != nil { - return nil, err - } - return ret[:n], nil -} - -func EncodeBase64(src []byte) string { - return base64.StdEncoding.EncodeToString(src) -} diff --git a/vendor/github.com/bytedance/sonic/internal/rt/fastconv.go b/vendor/github.com/bytedance/sonic/internal/rt/fastconv.go deleted file mode 100644 index 81196650d..000000000 --- a/vendor/github.com/bytedance/sonic/internal/rt/fastconv.go +++ /dev/null @@ -1,175 +0,0 @@ -package rt - -import ( - "unsafe" - "encoding/json" -) - -// Copied from Golang -var staticuint64s = [...]uint64{ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, - 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, - 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, - 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, - 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, - 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, - 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, - 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, - 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, - 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, - 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, - 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, - 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, - 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, - 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, - 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, - 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, - 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, - 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, - 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, - 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, - 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, - 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, - 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, - 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, - 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, - 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff, -} - -const maxZero = 1024 // must match value in reflect/value.go:maxZero cmd/compile/internal/gc/walk.go:zeroValSize -var zeroVal [maxZero]byte - - -type TslicePool struct { - pool []GoSlice - index int -} - -func NewTslicePool (hint int) TslicePool { - return TslicePool{ - pool: make([]GoSlice, hint, hint), - index: 0, - } -} - -func (self *TslicePool) Conv(val GoSlice, typ *GoType, ep *interface{}) { - var vp unsafe.Pointer - - if ((*GoSlice)(unsafe.Pointer(&val))).Ptr == nil { - vp = unsafe.Pointer(&zeroVal[0]) - } else if self.index < len(self.pool) { - dst := &(self.pool)[self.index] - *dst = val - self.index++ - vp = unsafe.Pointer(dst) - } else { - vp = Mallocgc(unsafe.Sizeof(val), BytesType, true) - } - *((*GoEface)(unsafe.Pointer(ep))) = GoEface{Type: typ, Value: vp} -} - -func (self *TslicePool) Free() { - self.pool = nil -} - -type TstringPool struct { - pool []string - index int -} - -func NewTstringPool (hint int) TstringPool { - return TstringPool{ - pool: make([]string, hint), - index: 0, - } -} - -func (self *TstringPool) Conv(val string, ep *interface{}) { - var vp unsafe.Pointer - if val == "" { - vp = unsafe.Pointer(&zeroVal[0]) - } else if self.index < len(self.pool) { - dst := &(self.pool)[self.index] - *dst = val - self.index++ - vp = unsafe.Pointer(dst) - } else { - vp = Mallocgc(unsafe.Sizeof(val), StringType, true) - } - - // convert into interface{} - *((*GoEface)(unsafe.Pointer(ep))) = GoEface{Type: StringType, Value: vp} -} - - -func (self *TstringPool) ConvNum(val json.Number, ep *interface{}) { - var vp unsafe.Pointer - if val == "" { - vp = unsafe.Pointer(&zeroVal[0]) - } else if self.index < len(self.pool) { - dst := &(self.pool)[self.index] - *dst = string(val) - self.index++ - vp = unsafe.Pointer(dst) - } else { - vp = Mallocgc(unsafe.Sizeof(val), StringType, true) - } - - // convert into interface{} - *((*GoEface)(unsafe.Pointer(ep))) = GoEface{Type: JsonNumberType, Value: vp} -} - - -func (self *TstringPool) Free() { - self.pool = nil -} - -type T64Pool struct { - pool []uint64 - index int -} - -func NewT64Pool (hint int) T64Pool { - return T64Pool{ - pool: make([]uint64, hint, hint), - index: 0, - } -} - -func (self *T64Pool) Conv(val uint64, typ *GoType, ep *interface{}) { - var vp unsafe.Pointer - if val < uint64(len(staticuint64s)) { - vp = unsafe.Pointer(&staticuint64s[val]) - } else if self.index < len(self.pool) { - dst := &(self.pool)[self.index] - *dst = val - self.index++ - vp = unsafe.Pointer(dst) - } else { - vp = Mallocgc(8, Uint64Type, false) - } - - // convert into interface{} - *((*GoEface)(unsafe.Pointer(ep))) = GoEface{Type: typ, Value: vp} -} - -func (self *T64Pool) Free() { - self.pool = nil -} - -func ConvTBool(val bool, ep *interface{}) { - var vp unsafe.Pointer - if val { - vp = unsafe.Pointer(&staticuint64s[1]) - } else { - vp = unsafe.Pointer(&staticuint64s[0]) - } - - *((*GoEface)(unsafe.Pointer(ep))) = GoEface{Type: BoolType, Value: vp} -} - diff --git a/vendor/github.com/bytedance/sonic/internal/rt/fastmem.go b/vendor/github.com/bytedance/sonic/internal/rt/fastmem.go deleted file mode 100644 index 508be4765..000000000 --- a/vendor/github.com/bytedance/sonic/internal/rt/fastmem.go +++ /dev/null @@ -1,155 +0,0 @@ -/* - * 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 rt - -import ( - "reflect" - "unsafe" - - "github.com/bytedance/sonic/option" -) - -//go:nosplit -func Get16(v []byte) int16 { - return *(*int16)((*GoSlice)(unsafe.Pointer(&v)).Ptr) -} - -//go:nosplit -func Get32(v []byte) int32 { - return *(*int32)((*GoSlice)(unsafe.Pointer(&v)).Ptr) -} - -//go:nosplit -func Get64(v []byte) int64 { - return *(*int64)((*GoSlice)(unsafe.Pointer(&v)).Ptr) -} - -//go:nosplit -func Mem2Str(v []byte) (s string) { - (*GoString)(unsafe.Pointer(&s)).Len = (*GoSlice)(unsafe.Pointer(&v)).Len - (*GoString)(unsafe.Pointer(&s)).Ptr = (*GoSlice)(unsafe.Pointer(&v)).Ptr - return -} - -//go:nosplit -func Str2Mem(s string) (v []byte) { - (*GoSlice)(unsafe.Pointer(&v)).Cap = (*GoString)(unsafe.Pointer(&s)).Len - (*GoSlice)(unsafe.Pointer(&v)).Len = (*GoString)(unsafe.Pointer(&s)).Len - (*GoSlice)(unsafe.Pointer(&v)).Ptr = (*GoString)(unsafe.Pointer(&s)).Ptr - return -} - -func BytesFrom(p unsafe.Pointer, n int, c int) (r []byte) { - (*GoSlice)(unsafe.Pointer(&r)).Ptr = p - (*GoSlice)(unsafe.Pointer(&r)).Len = n - (*GoSlice)(unsafe.Pointer(&r)).Cap = c - return -} - -func FuncAddr(f interface{}) unsafe.Pointer { - if vv := UnpackEface(f); vv.Type.Kind() != reflect.Func { - panic("f is not a function") - } else { - return *(*unsafe.Pointer)(vv.Value) - } -} - -//go:nocheckptr -func IndexChar(src string, index int) unsafe.Pointer { - return unsafe.Pointer(uintptr((*GoString)(unsafe.Pointer(&src)).Ptr) + uintptr(index)) -} - -//go:nocheckptr -func IndexByte(ptr []byte, index int) unsafe.Pointer { - return unsafe.Pointer(uintptr((*GoSlice)(unsafe.Pointer(&ptr)).Ptr) + uintptr(index)) -} - -func GuardSlice(buf *[]byte, n int) { - c := cap(*buf) - l := len(*buf) - if c-l < n { - c = c>>1 + n + l - if c < 32 { - c = 32 - } - tmp := make([]byte, l, c) - copy(tmp, *buf) - *buf = tmp - } -} - -func GuardSlice2(buf []byte, n int) []byte { - c := cap(buf) - l := len(buf) - if c-l < n { - c = c>>1 + n + l - if c < 32 { - c = 32 - } - tmp := make([]byte, l, c) - copy(tmp, buf) - buf = tmp - } - return buf -} - -//go:nosplit -func Ptr2SlicePtr(s unsafe.Pointer, l int, c int) unsafe.Pointer { - slice := &GoSlice{ - Ptr: s, - Len: l, - Cap: c, - } - return unsafe.Pointer(slice) -} - -//go:nosplit -func StrPtr(s string) unsafe.Pointer { - return (*GoString)(unsafe.Pointer(&s)).Ptr -} - -//go:nosplit -func StrFrom(p unsafe.Pointer, n int64) (s string) { - (*GoString)(unsafe.Pointer(&s)).Ptr = p - (*GoString)(unsafe.Pointer(&s)).Len = int(n) - return -} - -// NoEscape hides a pointer from escape analysis. NoEscape is -// the identity function but escape analysis doesn't think the -// output depends on the input. NoEscape is inlined and currently -// compiles down to zero instructions. -// USE CAREFULLY! -//go:nosplit -//goland:noinspection GoVetUnsafePointer -func NoEscape(p unsafe.Pointer) unsafe.Pointer { - x := uintptr(p) - return unsafe.Pointer(x ^ 0) -} - -//go:nosplit -func MoreStack(size uintptr) - -//go:nosplit -func Add(ptr unsafe.Pointer, off uintptr) unsafe.Pointer { - return unsafe.Pointer(uintptr(ptr) + off) -} - -// CanSizeResue -func CanSizeResue(cap int) bool { - return cap <= int(option.LimitBufferSize) -} diff --git a/vendor/github.com/bytedance/sonic/internal/rt/fastvalue.go b/vendor/github.com/bytedance/sonic/internal/rt/fastvalue.go deleted file mode 100644 index 85c90fc07..000000000 --- a/vendor/github.com/bytedance/sonic/internal/rt/fastvalue.go +++ /dev/null @@ -1,261 +0,0 @@ -/* - * 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 rt - -import ( - "reflect" - "unsafe" -) - -var ( - reflectRtypeItab = findReflectRtypeItab() -) - -// GoType.KindFlags const -const ( - F_direct = 1 << 5 - F_kind_mask = (1 << 5) - 1 -) - -// GoType.Flags const -const ( - tflagUncommon uint8 = 1 << 0 - tflagExtraStar uint8 = 1 << 1 - tflagNamed uint8 = 1 << 2 - tflagRegularMemory uint8 = 1 << 3 -) - -type GoType struct { - Size uintptr - PtrData uintptr - Hash uint32 - Flags uint8 - Align uint8 - FieldAlign uint8 - KindFlags uint8 - Traits unsafe.Pointer - GCData *byte - Str int32 - PtrToSelf int32 -} - -func (self *GoType) IsNamed() bool { - return (self.Flags & tflagNamed) != 0 -} - -func (self *GoType) Kind() reflect.Kind { - return reflect.Kind(self.KindFlags & F_kind_mask) -} - -func (self *GoType) Pack() (t reflect.Type) { - (*GoIface)(unsafe.Pointer(&t)).Itab = reflectRtypeItab - (*GoIface)(unsafe.Pointer(&t)).Value = unsafe.Pointer(self) - return -} - -func (self *GoType) String() string { - return self.Pack().String() -} - -func (self *GoType) Indirect() bool { - return self.KindFlags&F_direct == 0 -} - -type GoMap struct { - Count int - Flags uint8 - B uint8 - Overflow uint16 - Hash0 uint32 - Buckets unsafe.Pointer - OldBuckets unsafe.Pointer - Evacuate uintptr - Extra unsafe.Pointer -} - -type GoMapIterator struct { - K unsafe.Pointer - V unsafe.Pointer - T *GoMapType - H *GoMap - Buckets unsafe.Pointer - Bptr *unsafe.Pointer - Overflow *[]unsafe.Pointer - OldOverflow *[]unsafe.Pointer - StartBucket uintptr - Offset uint8 - Wrapped bool - B uint8 - I uint8 - Bucket uintptr - CheckBucket uintptr -} - -type GoItab struct { - it unsafe.Pointer - Vt *GoType - hv uint32 - _ [4]byte - fn [1]uintptr -} - -type GoIface struct { - Itab *GoItab - Value unsafe.Pointer -} - -type GoEface struct { - Type *GoType - Value unsafe.Pointer -} - -func (self GoEface) Pack() (v interface{}) { - *(*GoEface)(unsafe.Pointer(&v)) = self - return -} - -type GoPtrType struct { - GoType - Elem *GoType -} - -type GoMapType struct { - GoType - Key *GoType - Elem *GoType - Bucket *GoType - Hasher func(unsafe.Pointer, uintptr) uintptr - KeySize uint8 - ElemSize uint8 - BucketSize uint16 - Flags uint32 -} - -func (self *GoMapType) IndirectElem() bool { - return self.Flags&2 != 0 -} - -type GoStructType struct { - GoType - Pkg *byte - Fields []GoStructField -} - -type GoStructField struct { - Name *byte - Type *GoType - OffEmbed uintptr -} - -type GoInterfaceType struct { - GoType - PkgPath *byte - Methods []GoInterfaceMethod -} - -type GoInterfaceMethod struct { - Name int32 - Type int32 -} - -type GoSlice struct { - Ptr unsafe.Pointer - Len int - Cap int -} - -type GoString struct { - Ptr unsafe.Pointer - Len int -} - -func PtrElem(t *GoType) *GoType { - return (*GoPtrType)(unsafe.Pointer(t)).Elem -} - -func MapType(t *GoType) *GoMapType { - return (*GoMapType)(unsafe.Pointer(t)) -} - -func IfaceType(t *GoType) *GoInterfaceType { - return (*GoInterfaceType)(unsafe.Pointer(t)) -} - -func UnpackType(t reflect.Type) *GoType { - return (*GoType)((*GoIface)(unsafe.Pointer(&t)).Value) -} - -func UnpackEface(v interface{}) GoEface { - return *(*GoEface)(unsafe.Pointer(&v)) -} - -func UnpackIface(v interface{}) GoIface { - return *(*GoIface)(unsafe.Pointer(&v)) -} - -func findReflectRtypeItab() *GoItab { - v := reflect.TypeOf(struct{}{}) - return (*GoIface)(unsafe.Pointer(&v)).Itab -} - -func AssertI2I2(t *GoType, i GoIface) (r GoIface) { - inter := IfaceType(t) - tab := i.Itab - if tab == nil { - return - } - if (*GoInterfaceType)(tab.it) != inter { - tab = GetItab(inter, tab.Vt, true) - if tab == nil { - return - } - } - r.Itab = tab - r.Value = i.Value - return -} - -func (t *GoType) IsInt64() bool { - return t.Kind() == reflect.Int64 || (t.Kind() == reflect.Int && t.Size == 8) -} - -func (t *GoType) IsInt32() bool { - return t.Kind() == reflect.Int32 || (t.Kind() == reflect.Int && t.Size == 4) -} - -//go:nosplit -func (t *GoType) IsUint64() bool { - isUint := t.Kind() == reflect.Uint || t.Kind() == reflect.Uintptr - return t.Kind() == reflect.Uint64 || (isUint && t.Size == 8) -} - -//go:nosplit -func (t *GoType) IsUint32() bool { - isUint := t.Kind() == reflect.Uint || t.Kind() == reflect.Uintptr - return t.Kind() == reflect.Uint32 || (isUint && t.Size == 4) -} - -//go:nosplit -func PtrAdd(ptr unsafe.Pointer, offset uintptr) unsafe.Pointer { - return unsafe.Pointer(uintptr(ptr) + offset) -} - -//go:noescape -//go:linkname GetItab runtime.getitab -func GetItab(inter *GoInterfaceType, typ *GoType, canfail bool) *GoItab - - diff --git a/vendor/github.com/bytedance/sonic/internal/rt/gcwb.go b/vendor/github.com/bytedance/sonic/internal/rt/gcwb.go deleted file mode 100644 index 9c670e721..000000000 --- a/vendor/github.com/bytedance/sonic/internal/rt/gcwb.go +++ /dev/null @@ -1,85 +0,0 @@ -// +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 rt - -import ( - `sync/atomic` - `unsafe` - - `golang.org/x/arch/x86/x86asm` -) - -//go:linkname GcWriteBarrier2 runtime.gcWriteBarrier2 -func GcWriteBarrier2() - -//go:linkname RuntimeWriteBarrier runtime.writeBarrier -var RuntimeWriteBarrier uintptr - -const ( - _MaxInstr = 15 -) - -func isvar(arg x86asm.Arg) bool { - v, ok := arg.(x86asm.Mem) - return ok && v.Base == x86asm.RIP -} - -func iszero(arg x86asm.Arg) bool { - v, ok := arg.(x86asm.Imm) - return ok && v == 0 -} - -func GcwbAddr() uintptr { - var err error - var off uintptr - var ins x86asm.Inst - - /* get the function address */ - pc := uintptr(0) - fp := FuncAddr(atomic.StorePointer) - - /* search within the first 16 instructions */ - for i := 0; i < 16; i++ { - mem := unsafe.Pointer(uintptr(fp) + pc) - buf := BytesFrom(mem, _MaxInstr, _MaxInstr) - - /* disassemble the instruction */ - if ins, err = x86asm.Decode(buf, 64); err != nil { - panic("gcwbaddr: " + err.Error()) - } - - /* check for a byte comparison with zero */ - if ins.Op == x86asm.CMP && ins.MemBytes == 1 && isvar(ins.Args[0]) && iszero(ins.Args[1]) { - off = pc + uintptr(ins.Len) + uintptr(ins.Args[0].(x86asm.Mem).Disp) - break - } - - /* move to next instruction */ - nb := ins.Len - pc += uintptr(nb) - } - - /* check for address */ - if off == 0 { - panic("gcwbaddr: could not locate the variable `writeBarrier`") - } else { - return uintptr(fp) + off - } -} - diff --git a/vendor/github.com/bytedance/sonic/internal/rt/gcwb_legacy.go b/vendor/github.com/bytedance/sonic/internal/rt/gcwb_legacy.go deleted file mode 100644 index 86e14f2b2..000000000 --- a/vendor/github.com/bytedance/sonic/internal/rt/gcwb_legacy.go +++ /dev/null @@ -1,29 +0,0 @@ -// +build go1.16,!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 rt - -import ( - _ `unsafe` -) - -//go:linkname GcWriteBarrierAX runtime.gcWriteBarrier -func GcWriteBarrierAX() - -//go:linkname RuntimeWriteBarrier runtime.writeBarrier -var RuntimeWriteBarrier uintptr diff --git a/vendor/github.com/bytedance/sonic/internal/rt/growslice.go b/vendor/github.com/bytedance/sonic/internal/rt/growslice.go deleted file mode 100644 index fe182a5c9..000000000 --- a/vendor/github.com/bytedance/sonic/internal/rt/growslice.go +++ /dev/null @@ -1,36 +0,0 @@ -// +build 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 rt - -import "unsafe" - -// Growslice to newCap, not append length -// Note: the [old, newCap) will not be zeroed if et does not have any ptr data. -func GrowSlice(et *GoType, old GoSlice, newCap int) GoSlice { - if newCap < old.Len { - panic("growslice's newCap is smaller than old length") - } - s := growslice(old.Ptr, newCap, old.Cap, newCap - old.Len, et) - s.Len = old.Len - return s -} - -//go:linkname growslice runtime.growslice -//goland:noinspection GoUnusedParameter -func growslice(oldPtr unsafe.Pointer, newLen, oldCap, num int, et *GoType) GoSlice diff --git a/vendor/github.com/bytedance/sonic/internal/rt/growslice_legacy.go b/vendor/github.com/bytedance/sonic/internal/rt/growslice_legacy.go deleted file mode 100644 index 2456ffbbb..000000000 --- a/vendor/github.com/bytedance/sonic/internal/rt/growslice_legacy.go +++ /dev/null @@ -1,27 +0,0 @@ -// +build go1.16,!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 rt - -import ( - _ `unsafe` -) - -//go:linkname GrowSlice runtime.growslice -//goland:noinspection GoUnusedParameter -func GrowSlice(et *GoType, old GoSlice, cap int) GoSlice diff --git a/vendor/github.com/bytedance/sonic/internal/rt/int48.go b/vendor/github.com/bytedance/sonic/internal/rt/int48.go deleted file mode 100644 index a0eb64ad7..000000000 --- a/vendor/github.com/bytedance/sonic/internal/rt/int48.go +++ /dev/null @@ -1,36 +0,0 @@ -/* - * 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 rt - -const ( - MinInt48 int64 = -(1 << 47) - MaxInt48 int64 = +(1 << 47) - 1 -) - -func PackInt(v int) uint64 { - if u := uint64(v); int64(v) < MinInt48 || int64(v) > MaxInt48 { - panic("int48 out of range") - } else { - return ((u >> 63) << 47) | (u & 0x00007fffffffffff) - } -} - -func UnpackInt(v uint64) int { - v &= 0x0000ffffffffffff - v |= (v >> 47) * (0xffff << 48) - return int(v) -} diff --git a/vendor/github.com/bytedance/sonic/internal/rt/pool.go b/vendor/github.com/bytedance/sonic/internal/rt/pool.go deleted file mode 100644 index 60545b1ff..000000000 --- a/vendor/github.com/bytedance/sonic/internal/rt/pool.go +++ /dev/null @@ -1,31 +0,0 @@ -package rt - -import ( - "unsafe" -) - -type SlicePool struct { - pool unsafe.Pointer - len int - index int - typ uintptr -} - -func NewPool(typ *GoType, size int) SlicePool { - return SlicePool{pool: newarray(typ, size), len: size, typ: uintptr(unsafe.Pointer(typ))} -} - -func (self *SlicePool) GetSlice(size int) unsafe.Pointer { - // pool is full, fallback to normal alloc - if size > self.Remain() { - return newarray(AsGoType(self.typ), size) - } - - ptr := PtrAdd(self.pool, uintptr(self.index)* AsGoType(self.typ).Size) - self.index += size - return ptr -} - -func (self *SlicePool) Remain() int { - return self.len - self.index -} diff --git a/vendor/github.com/bytedance/sonic/internal/rt/stackmap.go b/vendor/github.com/bytedance/sonic/internal/rt/stackmap.go deleted file mode 100644 index 024912029..000000000 --- a/vendor/github.com/bytedance/sonic/internal/rt/stackmap.go +++ /dev/null @@ -1,181 +0,0 @@ -/** - * Copyright 2023 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 rt - -import ( - `fmt` - `strings` - `unsafe` - -) - -type Bitmap struct { - N int - B []byte -} - -func (self *Bitmap) grow() { - if self.N >= len(self.B) * 8 { - self.B = append(self.B, 0) - } -} - -func (self *Bitmap) mark(i int, bv int) { - if bv != 0 { - self.B[i / 8] |= 1 << (i % 8) - } else { - self.B[i / 8] &^= 1 << (i % 8) - } -} - -func (self *Bitmap) Set(i int, bv int) { - if i >= self.N { - panic("bitmap: invalid bit position") - } else { - self.mark(i, bv) - } -} - -func (self *Bitmap) Append(bv int) { - self.grow() - self.mark(self.N, bv) - self.N++ -} - -func (self *Bitmap) AppendMany(n int, bv int) { - for i := 0; i < n; i++ { - self.Append(bv) - } -} - -// var ( -// _stackMapLock = sync.Mutex{} -// _stackMapCache = make(map[*StackMap]struct{}) -// ) - -type BitVec struct { - N uintptr - B unsafe.Pointer -} - -func (self BitVec) Bit(i uintptr) byte { - return (*(*byte)(unsafe.Pointer(uintptr(self.B) + i / 8)) >> (i % 8)) & 1 -} - -func (self BitVec) String() string { - var i uintptr - var v []string - - /* add each bit */ - for i = 0; i < self.N; i++ { - v = append(v, fmt.Sprintf("%d", self.Bit(i))) - } - - /* join them together */ - return fmt.Sprintf( - "BitVec { %s }", - strings.Join(v, ", "), - ) -} - -type StackMap struct { - N int32 - L int32 - B [1]byte -} - -// func (self *StackMap) add() { -// _stackMapLock.Lock() -// _stackMapCache[self] = struct{}{} -// _stackMapLock.Unlock() -// } - -func (self *StackMap) Pin() uintptr { - // self.add() - return uintptr(unsafe.Pointer(self)) -} - -func (self *StackMap) Get(i int32) BitVec { - return BitVec { - N: uintptr(self.L), - B: unsafe.Pointer(uintptr(unsafe.Pointer(&self.B)) + uintptr(i * ((self.L + 7) >> 3))), - } -} - -func (self *StackMap) String() string { - sb := strings.Builder{} - sb.WriteString("StackMap {") - - /* dump every stack map */ - for i := int32(0); i < self.N; i++ { - sb.WriteRune('\n') - sb.WriteString(" " + self.Get(i).String()) - } - - /* close the stackmap */ - sb.WriteString("\n}") - return sb.String() -} - -func (self *StackMap) MarshalBinary() ([]byte, error) { - size := int(self.N) * int(self.L) + int(unsafe.Sizeof(self.L)) + int(unsafe.Sizeof(self.N)) - return BytesFrom(unsafe.Pointer(self), size, size), nil -} - -var ( - byteType = UnpackEface(byte(0)).Type -) - -const ( - _StackMapSize = unsafe.Sizeof(StackMap{}) -) - -//go:linkname mallocgc runtime.mallocgc -//goland:noinspection GoUnusedParameter -func mallocgc(nb uintptr, vt *GoType, zero bool) unsafe.Pointer - -type StackMapBuilder struct { - b Bitmap -} - -//go:nocheckptr -func (self *StackMapBuilder) Build() (p *StackMap) { - nb := len(self.b.B) - bm := mallocgc(_StackMapSize + uintptr(nb) - 1, byteType, false) - - /* initialize as 1 bitmap of N bits */ - p = (*StackMap)(bm) - p.N, p.L = 1, int32(self.b.N) - copy(BytesFrom(unsafe.Pointer(&p.B), nb, nb), self.b.B) - return -} - -func (self *StackMapBuilder) AddField(ptr bool) { - if ptr { - self.b.Append(1) - } else { - self.b.Append(0) - } -} - -func (self *StackMapBuilder) AddFields(n int, ptr bool) { - if ptr { - self.b.AppendMany(n, 1) - } else { - self.b.AppendMany(n, 0) - } -} diff --git a/vendor/github.com/bytedance/sonic/internal/rt/stubs.go b/vendor/github.com/bytedance/sonic/internal/rt/stubs.go deleted file mode 100644 index 1074f491b..000000000 --- a/vendor/github.com/bytedance/sonic/internal/rt/stubs.go +++ /dev/null @@ -1,165 +0,0 @@ -/* - * 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 rt - -import ( - "reflect" - "unsafe" -) - -//go:noescape -//go:linkname Memmove runtime.memmove -func Memmove(to unsafe.Pointer, from unsafe.Pointer, n uintptr) - -//go:linkname Mapiternext runtime.mapiternext -func Mapiternext(it *GoMapIterator) - -//go:linkname Mapiterinit runtime.mapiterinit -func Mapiterinit(t *GoMapType, m *GoMap, it *GoMapIterator) - -//go:linkname IsValidNumber encoding/json.isValidNumber -func IsValidNumber(s string) bool - -//go:nosplit -//go:linkname MemclrHasPointers runtime.memclrHasPointers -//goland:noinspection GoUnusedParameter -func MemclrHasPointers(ptr unsafe.Pointer, n uintptr) - -//go:linkname MemclrNoHeapPointers runtime.memclrNoHeapPointers -//goland:noinspection GoUnusedParameter -func MemclrNoHeapPointers(ptr unsafe.Pointer, n uintptr) - -//go:linkname newarray runtime.newarray -func newarray(typ *GoType, n int) unsafe.Pointer - -func add(p unsafe.Pointer, x uintptr) unsafe.Pointer { - return unsafe.Pointer(uintptr(p) + x) -} - -func ClearMemory(et *GoType, ptr unsafe.Pointer, size uintptr) { - if et.PtrData == 0 { - MemclrNoHeapPointers(ptr, size) - } else { - MemclrHasPointers(ptr, size) - } -} - -// runtime.maxElementSize -const _max_map_element_size uintptr = 128 - -func IsMapfast(vt reflect.Type) bool { - return vt.Elem().Size() <= _max_map_element_size -} - -//go:linkname Mallocgc runtime.mallocgc -//goland:noinspection GoUnusedParameter -func Mallocgc(size uintptr, typ *GoType, needzero bool) unsafe.Pointer - -//go:linkname Makemap reflect.makemap -func Makemap(*GoType, int) unsafe.Pointer - -//go:linkname Mapassign runtime.mapassign -//goland:noinspection GoUnusedParameter -func Mapassign(t *GoMapType, h unsafe.Pointer, k unsafe.Pointer) unsafe.Pointer - -//go:linkname Mapassign_fast32 runtime.mapassign_fast32 -//goland:noinspection GoUnusedParameter -func Mapassign_fast32(t *GoMapType, h unsafe.Pointer, k uint32) unsafe.Pointer - -//go:linkname Mapassign_fast64 runtime.mapassign_fast64 -//goland:noinspection GoUnusedParameter -func Mapassign_fast64(t *GoMapType, h unsafe.Pointer, k uint64) unsafe.Pointer - -//go:linkname Mapassign_faststr runtime.mapassign_faststr -//goland:noinspection GoUnusedParameter -func Mapassign_faststr(t *GoMapType, h unsafe.Pointer, s string) unsafe.Pointer - -type MapStrAssign func (t *GoMapType, h unsafe.Pointer, s string) unsafe.Pointer - -func GetMapStrAssign(vt reflect.Type) MapStrAssign { - if IsMapfast(vt) { - return Mapassign_faststr - } else { - return func (t *GoMapType, h unsafe.Pointer, s string) unsafe.Pointer { - return Mapassign(t, h, unsafe.Pointer(&s)) - } - } -} - -type Map32Assign func(t *GoMapType, h unsafe.Pointer, k uint32) unsafe.Pointer - -func GetMap32Assign(vt reflect.Type) Map32Assign { - if IsMapfast(vt) { - return Mapassign_fast32 - } else { - return func (t *GoMapType, h unsafe.Pointer, s uint32) unsafe.Pointer { - return Mapassign(t, h, unsafe.Pointer(&s)) - } - } -} - -type Map64Assign func(t *GoMapType, h unsafe.Pointer, k uint64) unsafe.Pointer - -func GetMap64Assign(vt reflect.Type) Map64Assign { - if IsMapfast(vt) { - return Mapassign_fast64 - } else { - return func (t *GoMapType, h unsafe.Pointer, s uint64) unsafe.Pointer { - return Mapassign(t, h, unsafe.Pointer(&s)) - } - } -} - - -var emptyBytes = make([]byte, 0, 0) -var EmptySlice = *(*GoSlice)(unsafe.Pointer(&emptyBytes)) - -//go:linkname makeslice runtime.makeslice -//goland:noinspection GoUnusedParameter -func makeslice(et *GoType, len int, cap int) unsafe.Pointer - -func MakeSlice(oldPtr unsafe.Pointer, et *GoType, newLen int) *GoSlice { - if newLen == 0 { - return &EmptySlice - } - - if *(*unsafe.Pointer)(oldPtr) == nil { - return &GoSlice{ - Ptr: makeslice(et, newLen, newLen), - Len: newLen, - Cap: newLen, - } - } - - old := (*GoSlice)(oldPtr) - if old.Cap >= newLen { - old.Len = newLen - return old - } - - new := GrowSlice(et, *old, newLen) - - // we should clear the memory from [oldLen:newLen] - if et.PtrData == 0 { - oldlenmem := uintptr(old.Len) * et.Size - newlenmem := uintptr(newLen) * et.Size - MemclrNoHeapPointers(add(new.Ptr, oldlenmem), newlenmem-oldlenmem) - } - - new.Len = newLen - return &new -} diff --git a/vendor/github.com/bytedance/sonic/internal/rt/table.go b/vendor/github.com/bytedance/sonic/internal/rt/table.go deleted file mode 100644 index 7d49f90e4..000000000 --- a/vendor/github.com/bytedance/sonic/internal/rt/table.go +++ /dev/null @@ -1,118 +0,0 @@ -// Copyright 2024 CloudWeGo Authors -// -// 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 -// -// https://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 rt - -import "unicode/utf8" - -var SafeSet = [utf8.RuneSelf]bool{ - ' ': true, - '!': true, - '"': false, - '#': true, - '$': true, - '%': true, - '&': true, - '\'': true, - '(': true, - ')': true, - '*': true, - '+': true, - ',': true, - '-': true, - '.': true, - '/': true, - '0': true, - '1': true, - '2': true, - '3': true, - '4': true, - '5': true, - '6': true, - '7': true, - '8': true, - '9': true, - ':': true, - ';': true, - '<': true, - '=': true, - '>': true, - '?': true, - '@': true, - 'A': true, - 'B': true, - 'C': true, - 'D': true, - 'E': true, - 'F': true, - 'G': true, - 'H': true, - 'I': true, - 'J': true, - 'K': true, - 'L': true, - 'M': true, - 'N': true, - 'O': true, - 'P': true, - 'Q': true, - 'R': true, - 'S': true, - 'T': true, - 'U': true, - 'V': true, - 'W': true, - 'X': true, - 'Y': true, - 'Z': true, - '[': true, - '\\': false, - ']': true, - '^': true, - '_': true, - '`': true, - 'a': true, - 'b': true, - 'c': true, - 'd': true, - 'e': true, - 'f': true, - 'g': true, - 'h': true, - 'i': true, - 'j': true, - 'k': true, - 'l': true, - 'm': true, - 'n': true, - 'o': true, - 'p': true, - 'q': true, - 'r': true, - 's': true, - 't': true, - 'u': true, - 'v': true, - 'w': true, - 'x': true, - 'y': true, - 'z': true, - '{': true, - '|': true, - '}': true, - '~': true, - '\u007f': true, -} - -var Hex = "0123456789abcdef" diff --git a/vendor/github.com/bytedance/sonic/internal/rt/types.go b/vendor/github.com/bytedance/sonic/internal/rt/types.go deleted file mode 100644 index 2c9aaa583..000000000 --- a/vendor/github.com/bytedance/sonic/internal/rt/types.go +++ /dev/null @@ -1,45 +0,0 @@ -package rt - -import ( - "reflect" - "unsafe" - "encoding/json" -) - -func AsGoType(t uintptr) *GoType { - return (*GoType)(unsafe.Pointer(t)) -} - -var ( - BoolType = UnpackType(reflect.TypeOf(false)) - ByteType = UnpackType(reflect.TypeOf(byte(0))) - IncntType = UnpackType(reflect.TypeOf(int(0))) - Int8Type = UnpackType(reflect.TypeOf(int8(0))) - Int16Type = UnpackType(reflect.TypeOf(int16(0))) - Int32Type = UnpackType(reflect.TypeOf(int32(0))) - Int64Type = UnpackType(reflect.TypeOf(int64(0))) - UintType = UnpackType(reflect.TypeOf(uint(0))) - Uint8Type = UnpackType(reflect.TypeOf(uint8(0))) - Uint16Type = UnpackType(reflect.TypeOf(uint16(0))) - Uint32Type = UnpackType(reflect.TypeOf(uint32(0))) - Uint64Type = UnpackType(reflect.TypeOf(uint64(0))) - Float32Type = UnpackType(reflect.TypeOf(float32(0))) - Float64Type = UnpackType(reflect.TypeOf(float64(0))) - - StringType = UnpackType(reflect.TypeOf("")) - BytesType = UnpackType(reflect.TypeOf([]byte(nil))) - JsonNumberType = UnpackType(reflect.TypeOf(json.Number(""))) - - SliceEfaceType = UnpackType(reflect.TypeOf([]interface{}(nil))) - SliceStringType = UnpackType(reflect.TypeOf([]string(nil))) - SliceI32Type = UnpackType(reflect.TypeOf([]int32(nil))) - SliceI64Type = UnpackType(reflect.TypeOf([]int64(nil))) - SliceU32Type = UnpackType(reflect.TypeOf([]uint32(nil))) - SliceU64Type = UnpackType(reflect.TypeOf([]uint64(nil))) - - AnyType = UnpackType(reflect.TypeOf((*interface{})(nil)).Elem()) - MapEfaceType = UnpackType(reflect.TypeOf(map[string]interface{}(nil))) - MapStringType = UnpackType(reflect.TypeOf(map[string]string(nil))) - - MapEfaceMapType = MapType(UnpackType(reflect.TypeOf(map[string]interface{}(nil)))) -) |