summaryrefslogtreecommitdiff
path: root/vendor/github.com/bytedance/sonic/internal/encoder/vars
diff options
context:
space:
mode:
authorLibravatar Terin Stock <terinjokes@gmail.com>2025-03-09 17:47:56 +0100
committerLibravatar Terin Stock <terinjokes@gmail.com>2025-12-01 22:08:04 +0100
commitb1af8fd87760b34e3ff2fd3bda38f211815a0473 (patch)
tree9317fad1a7ec298d7a8d2678e4e422953bbc6f33 /vendor/github.com/bytedance/sonic/internal/encoder/vars
parent[chore] update URLs to forked source (diff)
downloadgotosocial-b1af8fd87760b34e3ff2fd3bda38f211815a0473.tar.xz
[chore] remove vendor
Diffstat (limited to 'vendor/github.com/bytedance/sonic/internal/encoder/vars')
-rw-r--r--vendor/github.com/bytedance/sonic/internal/encoder/vars/cache.go48
-rw-r--r--vendor/github.com/bytedance/sonic/internal/encoder/vars/const.go42
-rw-r--r--vendor/github.com/bytedance/sonic/internal/encoder/vars/errors.go91
-rw-r--r--vendor/github.com/bytedance/sonic/internal/encoder/vars/stack.go146
-rw-r--r--vendor/github.com/bytedance/sonic/internal/encoder/vars/types.go47
5 files changed, 0 insertions, 374 deletions
diff --git a/vendor/github.com/bytedance/sonic/internal/encoder/vars/cache.go b/vendor/github.com/bytedance/sonic/internal/encoder/vars/cache.go
deleted file mode 100644
index 9cf2fb15e..000000000
--- a/vendor/github.com/bytedance/sonic/internal/encoder/vars/cache.go
+++ /dev/null
@@ -1,48 +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 vars
-
-import (
- "unsafe"
-
- "github.com/bytedance/sonic/internal/rt"
-)
-
-type Encoder func(
- rb *[]byte,
- vp unsafe.Pointer,
- sb *Stack,
- fv uint64,
-) error
-
-func FindOrCompile(vt *rt.GoType, pv bool, compiler func(*rt.GoType, ... interface{}) (interface{}, error)) (interface{}, error) {
- if val := programCache.Get(vt); val != nil {
- return val, nil
- } else if ret, err := programCache.Compute(vt, compiler, pv); err == nil {
- return ret, nil
- } else {
- return nil, err
- }
-}
-
-func GetProgram(vt *rt.GoType) (interface{}) {
- return programCache.Get(vt)
-}
-
-func ComputeProgram(vt *rt.GoType, compute func(*rt.GoType, ... interface{}) (interface{}, error), pv bool) (interface{}, error) {
- return programCache.Compute(vt, compute, pv)
-} \ No newline at end of file
diff --git a/vendor/github.com/bytedance/sonic/internal/encoder/vars/const.go b/vendor/github.com/bytedance/sonic/internal/encoder/vars/const.go
deleted file mode 100644
index 88499e959..000000000
--- a/vendor/github.com/bytedance/sonic/internal/encoder/vars/const.go
+++ /dev/null
@@ -1,42 +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 vars
-
-import (
- "os"
- "unsafe"
-)
-
-const (
- MaxStack = 4096 // 4k states
- StackSize = unsafe.Sizeof(Stack{})
- StateSize = int64(unsafe.Sizeof(State{}))
- StackLimit = MaxStack * StateSize
-)
-
-const (
- MAX_ILBUF = 100000 // cutoff at 100k of IL instructions
- MAX_FIELDS = 50 // cutoff at 50 fields struct
-)
-
-var (
- DebugSyncGC = os.Getenv("SONIC_SYNC_GC") != ""
- DebugAsyncGC = os.Getenv("SONIC_NO_ASYNC_GC") == ""
- DebugCheckPtr = os.Getenv("SONIC_CHECK_POINTER") != ""
-)
-
-var UseVM = os.Getenv("SONIC_ENCODER_USE_VM") != ""
diff --git a/vendor/github.com/bytedance/sonic/internal/encoder/vars/errors.go b/vendor/github.com/bytedance/sonic/internal/encoder/vars/errors.go
deleted file mode 100644
index 04e6d934d..000000000
--- a/vendor/github.com/bytedance/sonic/internal/encoder/vars/errors.go
+++ /dev/null
@@ -1,91 +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 vars
-
-import (
- "encoding/json"
- "fmt"
- "os"
- "reflect"
- "strconv"
- "strings"
- "unsafe"
-
- "github.com/bytedance/sonic/internal/rt"
-)
-
-var ERR_too_deep = &json.UnsupportedValueError {
- Str : "Value nesting too deep",
- Value : reflect.ValueOf("..."),
-}
-
-var ERR_nan_or_infinite = &json.UnsupportedValueError {
- Str : "NaN or ±Infinite",
- Value : reflect.ValueOf("NaN or ±Infinite"),
-}
-
-func Error_type(vtype reflect.Type) error {
- return &json.UnsupportedTypeError{Type: vtype}
-}
-
-func Error_number(number json.Number) error {
- return &json.UnsupportedValueError {
- Str : "invalid number literal: " + strconv.Quote(string(number)),
- Value : reflect.ValueOf(number),
- }
-}
-
-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)
-}
-
-const (
- PanicNilPointerOfNonEmptyString int = 1 + iota
-)
-
-func GoPanic(code int, val unsafe.Pointer, buf string) {
- sb := strings.Builder{}
- switch(code){
- case PanicNilPointerOfNonEmptyString:
- sb.WriteString(fmt.Sprintf("val: %#v has nil pointer while its length is not zero!\nThis is a nil pointer exception (NPE) problem. There might be a data race issue. It is recommended to execute the tests related to the code with the `-race` compile flag to detect the problem.\n", (*rt.GoString)(val)))
- default:
- sb.WriteString("encoder error: ")
- sb.WriteString(strconv.Itoa(code))
- sb.WriteString("\n")
- }
- sb.WriteString("JSON: ")
- if len(buf) > 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/vars/stack.go b/vendor/github.com/bytedance/sonic/internal/encoder/vars/stack.go
deleted file mode 100644
index 28a630b40..000000000
--- a/vendor/github.com/bytedance/sonic/internal/encoder/vars/stack.go
+++ /dev/null
@@ -1,146 +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 vars
-
-import (
- "bytes"
- "sync"
- "unsafe"
-
- "github.com/bytedance/sonic/internal/caching"
- "github.com/bytedance/sonic/internal/rt"
- "github.com/bytedance/sonic/option"
-)
-
-type State struct {
- x int
- f uint64
- p unsafe.Pointer
- q unsafe.Pointer
-}
-
-type Stack struct {
- sp uintptr
- sb [MaxStack]State
-}
-
-var (
- bytesPool = sync.Pool{}
- stackPool = sync.Pool{
- New: func() interface{} {
- return &Stack{}
- },
- }
- bufferPool = sync.Pool{}
- programCache = caching.CreateProgramCache()
-)
-
-func NewBytes() *[]byte {
- if ret := bytesPool.Get(); ret != nil {
- return ret.(*[]byte)
- } else {
- ret := make([]byte, 0, option.DefaultEncoderBufferSize)
- return &ret
- }
-}
-
-func NewStack() *Stack {
- ret := stackPool.Get().(*Stack)
- ret.sp = 0
- return ret
-}
-
-func ResetStack(p *Stack) {
- rt.MemclrNoHeapPointers(unsafe.Pointer(p), StackSize)
-}
-
-func (s *Stack) Top() *State {
- return (*State)(rt.Add(unsafe.Pointer(&s.sb[0]), s.sp))
-}
-
-func (s *Stack) Cur() *State {
- return (*State)(rt.Add(unsafe.Pointer(&s.sb[0]), s.sp - uintptr(StateSize)))
-}
-
-const _MaxStackSP = uintptr(MaxStack * StateSize)
-
-func (s *Stack) Push(v State) bool {
- if uintptr(s.sp) >= _MaxStackSP {
- return false
- }
- st := s.Top()
- *st = v
- s.sp += uintptr(StateSize)
- return true
-}
-
-func (s *Stack) Pop() State {
- s.sp -= uintptr(StateSize)
- st := s.Top()
- ret := *st
- *st = State{}
- return ret
-}
-
-func (s *Stack) Load() (int, uint64, unsafe.Pointer, unsafe.Pointer) {
- st := s.Cur()
- return st.x, st.f, st.p, st.q
-}
-
-func (s *Stack) Save(x int, f uint64, p unsafe.Pointer, q unsafe.Pointer) bool {
- return s.Push(State{x: x, f:f, p: p, q: q})
-}
-
-func (s *Stack) Drop() (int, uint64, unsafe.Pointer, unsafe.Pointer) {
- st := s.Pop()
- return st.x, st.f, st.p, st.q
-}
-
-func NewBuffer() *bytes.Buffer {
- if ret := bufferPool.Get(); ret != nil {
- return ret.(*bytes.Buffer)
- } else {
- return bytes.NewBuffer(make([]byte, 0, option.DefaultEncoderBufferSize))
- }
-}
-
-func FreeBytes(p *[]byte) {
- if rt.CanSizeResue(cap(*p)) {
- (*p) = (*p)[:0]
- bytesPool.Put(p)
- }
-}
-
-func FreeStack(p *Stack) {
- p.sp = 0
- stackPool.Put(p)
-}
-
-func FreeBuffer(p *bytes.Buffer) {
- if rt.CanSizeResue(cap(p.Bytes())) {
- p.Reset()
- bufferPool.Put(p)
- }
-}
-
-var (
- ArgPtrs = []bool{true, true, true, false}
- LocalPtrs = []bool{}
-
- ArgPtrs_generic = []bool{true}
- LocalPtrs_generic = []bool{}
-) \ No newline at end of file
diff --git a/vendor/github.com/bytedance/sonic/internal/encoder/vars/types.go b/vendor/github.com/bytedance/sonic/internal/encoder/vars/types.go
deleted file mode 100644
index ef8497807..000000000
--- a/vendor/github.com/bytedance/sonic/internal/encoder/vars/types.go
+++ /dev/null
@@ -1,47 +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 vars
-
-import (
- `encoding`
- `encoding/json`
- `reflect`
-)
-
-var (
- ByteType = reflect.TypeOf(byte(0))
- JsonNumberType = reflect.TypeOf(json.Number(""))
- JsonUnsupportedValueType = reflect.TypeOf(new(json.UnsupportedValueError))
-)
-
-var (
- ErrorType = reflect.TypeOf((*error)(nil)).Elem()
- JsonMarshalerType = reflect.TypeOf((*json.Marshaler)(nil)).Elem()
- EncodingTextMarshalerType = reflect.TypeOf((*encoding.TextMarshaler)(nil)).Elem()
-)
-
-func IsSimpleByte(vt reflect.Type) bool {
- if vt.Kind() != ByteType.Kind() {
- return false
- } else {
- return !isEitherMarshaler(vt) && !isEitherMarshaler(reflect.PtrTo(vt))
- }
-}
-
-func isEitherMarshaler(vt reflect.Type) bool {
- return vt.Implements(JsonMarshalerType) || vt.Implements(EncodingTextMarshalerType)
-}