Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/compatibility_test-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ jobs:
- name: main
run: |
set GOMAXPROCS=4
go test -v -race github.com/bytedance/sonic
go test -v -race ./

- name: ast
run: |
set GOMAXPROCS=4
go test -v -race github.com/bytedance/sonic/ast
go test -v -race ./ast

- name: external
run: |
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/compatibility_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ jobs:
${{ runner.os }}-go-

- name: main
run: go test -race -v -gcflags="all=-l" github.com/bytedance/sonic
run: go test -race -v -gcflags="all=-l" ./

- name: decoder
run: go test -race -v -gcflags="all=-l" github.com/bytedance/sonic/decoder
run: go test -race -v -gcflags="all=-l" ./decoder

- name: encoder
run: go test -race -v -gcflags="all=-l" github.com/bytedance/sonic/encoder
run: go test -race -v -gcflags="all=-l" ./encoder

- name: ast
run: go test -race -v -gcflags="all=-l" github.com/bytedance/sonic/ast
run: go test -race -v -gcflags="all=-l" ./ast
3 changes: 1 addition & 2 deletions .github/workflows/test-arm64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ on: pull_request
jobs:
build:
strategy:
max-parallel: 4
matrix:
go-version: [1.20.x, 1.21.x, 1.22.x, 1.23.x]
go-version: [1.20.x, 1.21.x, 1.22.x, 1.23.x, 1.24.x]
runner_arch: [ubuntu-24.04-arm]

runs-on: ${{ matrix.runner_arch }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-x86.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
build:
strategy:
matrix:
go-version: [1.17.x, 1.18.x, 1.19.x, 1.20.x, 1.21.x, 1.22.x, 1.23.x]
go-version: [1.17.x, 1.18.x, 1.19.x, 1.20.x, 1.21.x, 1.22.x, 1.23.x, 1.24.x]
runner_arch: [ubuntu-latest]

runs-on: ${{ matrix.runner_arch }}
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ A blazingly fast JSON serializing & deserializing library, accelerated by JI

## Requirement

- Go: 1.17~1.23
- Go: 1.17~1.24
- OS: Linux / MacOS / Windows
- CPU: AMD64 / ARM64(need go1.20 above)
- CPU: AMD64 / (ARM64, need go1.20 above)

## Features

Expand Down
4 changes: 2 additions & 2 deletions README_ZH_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

## 依赖

- Go: 1.17~1.23
- Go: 1.17~1.24
- OS: Linux / MacOS / Windows
- CPU: AMD64 / ARM64需要 Go1.20 以上)
- CPU: AMD64 / (ARM64, 需要 Go1.20 以上)

## 接口

Expand Down
4 changes: 2 additions & 2 deletions ast/api.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//go:build (amd64 && go1.17 && !go1.24) || (arm64 && go1.20 && !go1.24)
// +build amd64,go1.17,!go1.24 arm64,go1.20,!go1.24
//go:build (amd64 && go1.17 && !go1.25) || (arm64 && go1.20 && !go1.25)
// +build amd64,go1.17,!go1.25 arm64,go1.20,!go1.25

/*
* Copyright 2022 ByteDance Inc.
Expand Down
7 changes: 3 additions & 4 deletions ast/api_compat.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build !amd64,!arm64 go1.24 !go1.17 arm64,!go1.20
// +build !amd64,!arm64 go1.25 !go1.17 arm64,!go1.20

/*
* Copyright 2022 ByteDance Inc.
Expand All @@ -20,16 +20,15 @@ package ast

import (
`encoding/json`
`fmt`
`os`
`unicode/utf8`

`github.com/bytedance/sonic/internal/native/types`
`github.com/bytedance/sonic/internal/rt`
`github.com/bytedance/sonic/internal/compat`
)

func init() {
fmt.Fprintln(os.Stderr, "WARNING:(ast) sonic only supports go1.17~1.23, but your environment is not suitable")
compat.Warn("sonic/ast")
}

func quote(buf *[]byte, val string) {
Expand Down
4 changes: 2 additions & 2 deletions ast/api_native_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//go:build (amd64 && go1.17 && !go1.24) || (arm64 && go1.20 && !go1.24)
// +build amd64,go1.17,!go1.24 arm64,go1.20,!go1.24
//go:build (amd64 && go1.17 && !go1.25) || (arm64 && go1.20 && !go1.25)
// +build amd64,go1.17,!go1.25 arm64,go1.20,!go1.25

/*
* Copyright 2022 ByteDance Inc.
Expand Down
2 changes: 1 addition & 1 deletion ast/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -1678,7 +1678,7 @@ func NewBytes(src []byte) Node {
if len(src) == 0 {
panic("empty src bytes")
}
out := rt.EncodeBase64(src)
out := rt.EncodeBase64ToString(src)
return NewString(out)
}

Expand Down
111 changes: 0 additions & 111 deletions ast/stubs.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,126 +17,15 @@
package ast

import (
"unicode/utf8"
"unsafe"

"github.com/bytedance/sonic/internal/rt"
)

//go:noescape
//go:linkname memmove runtime.memmove
//goland:noinspection GoUnusedParameter
func memmove(to unsafe.Pointer, from unsafe.Pointer, n uintptr)

//go:linkname unsafe_NewArray reflect.unsafe_NewArray
//goland:noinspection GoUnusedParameter
func unsafe_NewArray(typ *rt.GoType, n int) unsafe.Pointer

//go:nosplit
func mem2ptr(s []byte) unsafe.Pointer {
return (*rt.GoSlice)(unsafe.Pointer(&s)).Ptr
}

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"

//go:linkname unquoteBytes encoding/json.unquoteBytes
func unquoteBytes(s []byte) (t []byte, ok bool)
2 changes: 1 addition & 1 deletion compat.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build !amd64,!arm64 go1.24 !go1.17 arm64,!go1.20
// +build !amd64,!arm64 go1.25 !go1.17 arm64,!go1.20

/*
* Copyright 2021 ByteDance Inc.
Expand Down
4 changes: 2 additions & 2 deletions decode_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//go:build (amd64 && go1.17 && !go1.24) || (arm64 && go1.20 && !go1.24)
// +build amd64,go1.17,!go1.24 arm64,go1.20,!go1.24
//go:build (amd64 && go1.17 && !go1.25) || (arm64 && go1.20 && !go1.25)
// +build amd64,go1.17,!go1.25 arm64,go1.20,!go1.25

/*
* Copyright 2021 ByteDance Inc.
Expand Down
9 changes: 4 additions & 5 deletions decoder/decoder_compat.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//go:build (!amd64 && !arm64) || go1.24 || !go1.17 || (arm64 && !go1.20)
// +build !amd64,!arm64 go1.24 !go1.17 arm64,!go1.20
//go:build (!amd64 && !arm64) || go1.25 || !go1.17 || (arm64 && !go1.20)
// +build !amd64,!arm64 go1.25 !go1.17 arm64,!go1.20

/*
* Copyright 2023 ByteDance Inc.
Expand All @@ -22,19 +22,18 @@ package decoder
import (
"bytes"
"encoding/json"
"fmt"
"io"
"os"
"reflect"
"unsafe"

"github.com/bytedance/sonic/internal/decoder/consts"
"github.com/bytedance/sonic/internal/native/types"
"github.com/bytedance/sonic/option"
"github.com/bytedance/sonic/internal/compat"
)

func init() {
fmt.Fprintln(os.Stderr, "WARNING: sonic/decoder only supports (Go1.17~1.23 && CPU amd64) or (go1.20~1.23 && CPU arm64), but your environment is not suitable")
compat.Warn("sonic/decoder")
}

const (
Expand Down
4 changes: 2 additions & 2 deletions decoder/decoder_native.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//go:build (amd64 && go1.17 && !go1.24) || (arm64 && go1.20 && !go1.24)
// +build amd64,go1.17,!go1.24 arm64,go1.20,!go1.24
//go:build (amd64 && go1.17 && !go1.25) || (arm64 && go1.20 && !go1.25)
// +build amd64,go1.17,!go1.25 arm64,go1.20,!go1.25


/*
Expand Down
4 changes: 2 additions & 2 deletions decoder/decoder_native_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//go:build (amd64 && go1.17 && !go1.24) || (arm64 && go1.20 && !go1.24)
// +build amd64,go1.17,!go1.24 arm64,go1.20,!go1.24
//go:build (amd64 && go1.17 && !go1.25) || (arm64 && go1.20 && !go1.25)
// +build amd64,go1.17,!go1.25 arm64,go1.20,!go1.25

/*
* Copyright 2021 ByteDance Inc.
Expand Down
4 changes: 2 additions & 2 deletions encode_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//go:build (amd64 && go1.17 && !go1.24) || (arm64 && go1.20 && !go1.24)
// +build amd64,go1.17,!go1.24 arm64,go1.20,!go1.24
//go:build (amd64 && go1.17 && !go1.25) || (arm64 && go1.20 && !go1.25)
// +build amd64,go1.17,!go1.25 arm64,go1.20,!go1.25

/*
* Copyright 2021 ByteDance Inc.
Expand Down
7 changes: 3 additions & 4 deletions encoder/encoder_compat.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build !amd64,!arm64 go1.24 !go1.17 arm64,!go1.20
// +build !amd64,!arm64 go1.25 !go1.17 arm64,!go1.20

/*
* Copyright 2023 ByteDance Inc.
Expand All @@ -20,17 +20,16 @@ package encoder

import (
`io`
`fmt`
`os`
`bytes`
`encoding/json`
`reflect`

`github.com/bytedance/sonic/option`
`github.com/bytedance/sonic/internal/compat`
)

func init() {
fmt.Fprintln(os.Stderr, "WARNING:(encoder) sonic only supports (Go1.17~1.23 && CPU amd64) or (G01.20~1.23 && CPU arm64) , but your environment is not suitable")
compat.Warn("sonic/encoder")
}

// EnableFallback indicates if encoder use fallback
Expand Down
2 changes: 1 addition & 1 deletion encoder/encoder_native.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build amd64,go1.17,!go1.24 arm64,go1.20,!go1.24
// +build amd64,go1.17,!go1.25 arm64,go1.20,!go1.25

/*
* Copyright 2023 ByteDance Inc.
Expand Down
2 changes: 1 addition & 1 deletion encoder/encoder_native_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build amd64,go1.17,!go1.24 arm64,go1.20,!go1.24
// +build amd64,go1.17,!go1.25 arm64,go1.20,!go1.25

/*
* Copyright 2021 ByteDance Inc.
Expand Down
2 changes: 2 additions & 0 deletions examples/example_stream_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// +build !go1.24

package example

import (
Expand Down
Loading
Loading