summaryrefslogtreecommitdiff
path: root/vendor/github.com/bytedance/sonic/internal/encoder
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/bytedance/sonic/internal/encoder')
-rw-r--r--vendor/github.com/bytedance/sonic/internal/encoder/asm_stubs_amd64_go121.go2
-rw-r--r--vendor/github.com/bytedance/sonic/internal/encoder/assembler_regabi_amd64.go7
-rw-r--r--vendor/github.com/bytedance/sonic/internal/encoder/compiler.go2
-rw-r--r--vendor/github.com/bytedance/sonic/internal/encoder/debug_go117.go2
-rw-r--r--vendor/github.com/bytedance/sonic/internal/encoder/encoder.go14
-rw-r--r--vendor/github.com/bytedance/sonic/internal/encoder/primitives.go6
-rw-r--r--vendor/github.com/bytedance/sonic/internal/encoder/stream.go13
-rw-r--r--vendor/github.com/bytedance/sonic/internal/encoder/stubs_go116.go4
-rw-r--r--vendor/github.com/bytedance/sonic/internal/encoder/stubs_go117.go4
-rw-r--r--vendor/github.com/bytedance/sonic/internal/encoder/stubs_go120.go4
-rw-r--r--vendor/github.com/bytedance/sonic/internal/encoder/stubs_go121.go4
11 files changed, 31 insertions, 31 deletions
diff --git a/vendor/github.com/bytedance/sonic/internal/encoder/asm_stubs_amd64_go121.go b/vendor/github.com/bytedance/sonic/internal/encoder/asm_stubs_amd64_go121.go
index 2f9445ac4..9f7ff65e6 100644
--- a/vendor/github.com/bytedance/sonic/internal/encoder/asm_stubs_amd64_go121.go
+++ b/vendor/github.com/bytedance/sonic/internal/encoder/asm_stubs_amd64_go121.go
@@ -1,4 +1,4 @@
-// +build go1.21,!go1.22
+// +build go1.21,!go1.23
// Copyright 2023 CloudWeGo Authors
//
diff --git a/vendor/github.com/bytedance/sonic/internal/encoder/assembler_regabi_amd64.go b/vendor/github.com/bytedance/sonic/internal/encoder/assembler_regabi_amd64.go
index a89364b14..4584c6d29 100644
--- a/vendor/github.com/bytedance/sonic/internal/encoder/assembler_regabi_amd64.go
+++ b/vendor/github.com/bytedance/sonic/internal/encoder/assembler_regabi_amd64.go
@@ -1,5 +1,4 @@
-//go:build go1.17 && !go1.22
-// +build go1.17,!go1.22
+// +build go1.17,!go1.23
/*
* Copyright 2021 ByteDance Inc.
@@ -171,7 +170,7 @@ var (
)
var (
- _REG_ffi = []obj.Addr{ _RP, _RL, _RC}
+ _REG_ffi = []obj.Addr{ _RP, _RL, _RC, _SP_q}
_REG_b64 = []obj.Addr{_SP_p, _SP_q}
_REG_all = []obj.Addr{_ST, _SP_x, _SP_f, _SP_p, _SP_q, _RP, _RL, _RC}
@@ -510,11 +509,9 @@ func (self *_Assembler) call_b64(pc obj.Addr) {
func (self *_Assembler) call_c(pc obj.Addr) {
self.Emit("XCHGQ", _SP_p, _BX)
- self.Emit("XCHGQ", _SP_q, _BP)
self.call(pc) // CALL $pc
self.xload(_REG_ffi...) // LOAD $REG_ffi
self.Emit("XCHGQ", _SP_p, _BX)
- self.Emit("XCHGQ", _SP_q, _BP)
}
func (self *_Assembler) call_go(pc obj.Addr) {
diff --git a/vendor/github.com/bytedance/sonic/internal/encoder/compiler.go b/vendor/github.com/bytedance/sonic/internal/encoder/compiler.go
index a949c90f7..ca0be8f40 100644
--- a/vendor/github.com/bytedance/sonic/internal/encoder/compiler.go
+++ b/vendor/github.com/bytedance/sonic/internal/encoder/compiler.go
@@ -831,7 +831,7 @@ func (self *_Compiler) compileStructFieldZero(p *_Program, vt reflect.Type) {
case reflect.Float32 : p.add(_OP_is_zero_4)
case reflect.Float64 : p.add(_OP_is_zero_8)
case reflect.String : p.add(_OP_is_nil_p1)
- case reflect.Interface : p.add(_OP_is_nil_p1)
+ case reflect.Interface : p.add(_OP_is_nil)
case reflect.Map : p.add(_OP_is_zero_map)
case reflect.Ptr : p.add(_OP_is_nil)
case reflect.Slice : p.add(_OP_is_nil_p1)
diff --git a/vendor/github.com/bytedance/sonic/internal/encoder/debug_go117.go b/vendor/github.com/bytedance/sonic/internal/encoder/debug_go117.go
index 56a6cbf5e..37e6f7d4f 100644
--- a/vendor/github.com/bytedance/sonic/internal/encoder/debug_go117.go
+++ b/vendor/github.com/bytedance/sonic/internal/encoder/debug_go117.go
@@ -1,4 +1,4 @@
-// +build go1.17,!go1.22
+// +build go1.17,!go1.23
/*
* Copyright 2021 ByteDance Inc.
diff --git a/vendor/github.com/bytedance/sonic/internal/encoder/encoder.go b/vendor/github.com/bytedance/sonic/internal/encoder/encoder.go
index bd8bae357..0a46455eb 100644
--- a/vendor/github.com/bytedance/sonic/internal/encoder/encoder.go
+++ b/vendor/github.com/bytedance/sonic/internal/encoder/encoder.go
@@ -41,6 +41,7 @@ const (
bitNoNullSliceOrMap
bitValidateString
bitNoValidateJSONMarshaler
+ bitNoEncoderNewline
// used for recursive compile
bitPointerValue = 63
@@ -76,6 +77,9 @@ const (
// NoValidateJSONMarshaler indicates that the encoder should not validate the output string
// after encoding the JSONMarshaler to JSON.
NoValidateJSONMarshaler Options = 1 << bitNoValidateJSONMarshaler
+
+ // NoEncoderNewline indicates that the encoder should not add a newline after every message
+ NoEncoderNewline Options = 1 << bitNoEncoderNewline
// CompatibleWithStd is used to be compatible with std encoder.
CompatibleWithStd Options = SortMapKeys | EscapeHTML | CompactMarshaler
@@ -129,6 +133,16 @@ func (self *Encoder) SetNoValidateJSONMarshaler(f bool) {
}
}
+// SetNoEncoderNewline specifies if option NoEncoderNewline opens
+func (self *Encoder) SetNoEncoderNewline(f bool) {
+ if f {
+ self.Opts |= NoEncoderNewline
+ } else {
+ self.Opts &= ^NoEncoderNewline
+ }
+}
+
+
// SetCompactMarshaler specifies if option CompactMarshaler opens
func (self *Encoder) SetCompactMarshaler(f bool) {
if f {
diff --git a/vendor/github.com/bytedance/sonic/internal/encoder/primitives.go b/vendor/github.com/bytedance/sonic/internal/encoder/primitives.go
index 0e47987c7..0f3c40881 100644
--- a/vendor/github.com/bytedance/sonic/internal/encoder/primitives.go
+++ b/vendor/github.com/bytedance/sonic/internal/encoder/primitives.go
@@ -154,17 +154,17 @@ var (
)
var (
- _F_assertI2I = jit.Func(assertI2I)
+ _F_assertI2I = jit.Func(rt.AssertI2I2)
)
func asText(v unsafe.Pointer) (string, error) {
- text := assertI2I(_T_encoding_TextMarshaler, *(*rt.GoIface)(v))
+ text := rt.AssertI2I2(_T_encoding_TextMarshaler, *(*rt.GoIface)(v))
r, e := (*(*encoding.TextMarshaler)(unsafe.Pointer(&text))).MarshalText()
return rt.Mem2Str(r), e
}
func asJson(v unsafe.Pointer) (string, error) {
- text := assertI2I(_T_json_Marshaler, *(*rt.GoIface)(v))
+ text := rt.AssertI2I2(_T_json_Marshaler, *(*rt.GoIface)(v))
r, e := (*(*json.Marshaler)(unsafe.Pointer(&text))).MarshalJSON()
return rt.Mem2Str(r), e
}
diff --git a/vendor/github.com/bytedance/sonic/internal/encoder/stream.go b/vendor/github.com/bytedance/sonic/internal/encoder/stream.go
index b6f3ce5fb..d498f68fc 100644
--- a/vendor/github.com/bytedance/sonic/internal/encoder/stream.go
+++ b/vendor/github.com/bytedance/sonic/internal/encoder/stream.go
@@ -36,7 +36,8 @@ func NewStreamEncoder(w io.Writer) *StreamEncoder {
// Encode encodes interface{} as JSON to io.Writer
func (enc *StreamEncoder) Encode(val interface{}) (err error) {
- out := newBytes()
+ buf := newBytes()
+ out := buf
/* encode into the buffer */
err = EncodeInto(&out, val, enc.Opts)
@@ -54,7 +55,9 @@ func (enc *StreamEncoder) Encode(val interface{}) (err error) {
}
// according to standard library, terminate each value with a newline...
- buf.WriteByte('\n')
+ if enc.Opts & NoEncoderNewline == 0 {
+ buf.WriteByte('\n')
+ }
/* copy into io.Writer */
_, err = io.Copy(enc.w, buf)
@@ -75,10 +78,12 @@ func (enc *StreamEncoder) Encode(val interface{}) (err error) {
}
// according to standard library, terminate each value with a newline...
- enc.w.Write([]byte{'\n'})
+ if enc.Opts & NoEncoderNewline == 0 {
+ enc.w.Write([]byte{'\n'})
+ }
}
free_bytes:
- freeBytes(out)
+ freeBytes(buf)
return err
}
diff --git a/vendor/github.com/bytedance/sonic/internal/encoder/stubs_go116.go b/vendor/github.com/bytedance/sonic/internal/encoder/stubs_go116.go
index 5577c58d7..a21b6b4a6 100644
--- a/vendor/github.com/bytedance/sonic/internal/encoder/stubs_go116.go
+++ b/vendor/github.com/bytedance/sonic/internal/encoder/stubs_go116.go
@@ -38,10 +38,6 @@ func memmove(to unsafe.Pointer, from unsafe.Pointer, n uintptr)
//goland:noinspection GoUnusedParameter
func growslice(et *rt.GoType, old rt.GoSlice, cap int) rt.GoSlice
-//go:linkname assertI2I runtime.assertI2I
-//goland:noinspection GoUnusedParameter
-func assertI2I(inter *rt.GoType, i rt.GoIface) rt.GoIface
-
//go:linkname mapiternext runtime.mapiternext
//goland:noinspection GoUnusedParameter
func mapiternext(it *rt.GoMapIterator)
diff --git a/vendor/github.com/bytedance/sonic/internal/encoder/stubs_go117.go b/vendor/github.com/bytedance/sonic/internal/encoder/stubs_go117.go
index 6c8c6ec75..7d934be33 100644
--- a/vendor/github.com/bytedance/sonic/internal/encoder/stubs_go117.go
+++ b/vendor/github.com/bytedance/sonic/internal/encoder/stubs_go117.go
@@ -38,10 +38,6 @@ func memmove(to unsafe.Pointer, from unsafe.Pointer, n uintptr)
//goland:noinspection GoUnusedParameter
func growslice(et *rt.GoType, old rt.GoSlice, cap int) rt.GoSlice
-//go:linkname assertI2I runtime.assertI2I2
-//goland:noinspection GoUnusedParameter
-func assertI2I(inter *rt.GoType, i rt.GoIface) rt.GoIface
-
//go:linkname mapiternext runtime.mapiternext
//goland:noinspection GoUnusedParameter
func mapiternext(it *rt.GoMapIterator)
diff --git a/vendor/github.com/bytedance/sonic/internal/encoder/stubs_go120.go b/vendor/github.com/bytedance/sonic/internal/encoder/stubs_go120.go
index 94a2c0f56..ce3c88e9a 100644
--- a/vendor/github.com/bytedance/sonic/internal/encoder/stubs_go120.go
+++ b/vendor/github.com/bytedance/sonic/internal/encoder/stubs_go120.go
@@ -38,10 +38,6 @@ func memmove(to unsafe.Pointer, from unsafe.Pointer, n uintptr)
//goland:noinspection GoUnusedParameter
func growslice(et *rt.GoType, old rt.GoSlice, cap int) rt.GoSlice
-//go:linkname assertI2I runtime.assertI2I2
-//goland:noinspection GoUnusedParameter
-func assertI2I(inter *rt.GoType, i rt.GoIface) rt.GoIface
-
//go:linkname mapiternext runtime.mapiternext
//goland:noinspection GoUnusedParameter
func mapiternext(it *rt.GoMapIterator)
diff --git a/vendor/github.com/bytedance/sonic/internal/encoder/stubs_go121.go b/vendor/github.com/bytedance/sonic/internal/encoder/stubs_go121.go
index e194fbbf3..700ddf8b5 100644
--- a/vendor/github.com/bytedance/sonic/internal/encoder/stubs_go121.go
+++ b/vendor/github.com/bytedance/sonic/internal/encoder/stubs_go121.go
@@ -38,10 +38,6 @@ func memmove(to unsafe.Pointer, from unsafe.Pointer, n uintptr)
//goland:noinspection GoUnusedParameter
func growslice(et *rt.GoType, old rt.GoSlice, cap int) rt.GoSlice
-//go:linkname assertI2I runtime.assertI2I2
-//goland:noinspection GoUnusedParameter
-func assertI2I(inter *rt.GoType, i rt.GoIface) rt.GoIface
-
//go:linkname mapiternext runtime.mapiternext
//goland:noinspection GoUnusedParameter
func mapiternext(it *rt.GoMapIterator)