Skip to content

Commit c09ac55

Browse files
committed
feat: support go1.24
1 parent c5a58f9 commit c09ac55

62 files changed

Lines changed: 425 additions & 580 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/compatibility_test-windows.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ jobs:
2626
- name: main
2727
run: |
2828
set GOMAXPROCS=4
29-
go test -v -race github.com/bytedance/sonic
29+
go test -v -race ./
3030
3131
- name: ast
3232
run: |
3333
set GOMAXPROCS=4
34-
go test -v -race github.com/bytedance/sonic/ast
34+
go test -v -race ./ast
3535
3636
- name: external
3737
run: |

.github/workflows/compatibility_test.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ jobs:
2828
${{ runner.os }}-go-
2929
3030
- name: main
31-
run: go test -race -v -gcflags="all=-l" github.com/bytedance/sonic
31+
run: go test -race -v -gcflags="all=-l" ./
3232

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

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

3939
- name: ast
40-
run: go test -race -v -gcflags="all=-l" github.com/bytedance/sonic/ast
40+
run: go test -race -v -gcflags="all=-l" ./ast
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
2+
name: Unit Test
3+
4+
on: pull_request
5+
6+
jobs:
7+
build:
8+
strategy:
9+
matrix:
10+
go-version: [1.24.x]
11+
runner_arch: [ubuntu-24.04-arm]
12+
13+
runs-on: ${{ matrix.runner_arch }}
14+
15+
steps:
16+
- name: Clear repository
17+
run: sudo rm -fr $GITHUB_WORKSPACE && mkdir $GITHUB_WORKSPACE
18+
- name: Set up Go
19+
uses: actions/setup-go@v4
20+
with:
21+
go-version: ${{ matrix.go-version }}
22+
cache: true
23+
24+
- uses: actions/checkout@v4
25+
26+
- name: Cache Go modules
27+
uses: actions/cache@v3
28+
with:
29+
path: |
30+
~/go/pkg/mod
31+
${{ github.workspace }}/go.sum
32+
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
33+
34+
- name: Unit Test
35+
run: |
36+
GOMAXPROCS=4 go test -ldflags=-checklinkname=0 -race -covermode=atomic -coverprofile=coverage.txt $(go list ./... | grep -v -E 'loader|jit|avx|x86|sse|examples')
37+
38+
- name: Data Race
39+
run: |
40+
./scripts/test_race.sh
41+
42+
- name: Generic Test
43+
if: ${{ !startsWith(matrix.go-version, '1.17.') }}
44+
run: GOMAXPROCS=4 go test -ldflags=-checklinkname=0 -v -race ./generic_test
45+
46+
- name: Codecov
47+
run: bash <(curl -s https://codecov.io/bash)

.github/workflows/test-arm64.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ on: pull_request
66
jobs:
77
build:
88
strategy:
9-
max-parallel: 4
109
matrix:
1110
go-version: [1.20.x, 1.21.x, 1.22.x, 1.23.x]
1211
runner_arch: [ubuntu-24.04-arm]
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
2+
name: Unit Test
3+
4+
on: pull_request
5+
6+
jobs:
7+
build:
8+
strategy:
9+
matrix:
10+
go-version: [1.24.x]
11+
runner_arch: [ubuntu-latest]
12+
13+
runs-on: ${{ matrix.runner_arch }}
14+
15+
steps:
16+
- uses: actions/checkout@v4
17+
18+
- name: Set up Go
19+
uses: actions/setup-go@v4
20+
with:
21+
go-version: ${{ matrix.go-version }}
22+
cache: true
23+
24+
- name: Cache Go modules
25+
uses: actions/cache@v3
26+
with:
27+
path: |
28+
~/go/pkg/mod
29+
${{ github.workspace }}/go.sum
30+
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
31+
32+
- name: Unit Test JIT
33+
run: |
34+
GOMAXPROCS=4 go test -ldflags=-checklinkname=0 -race -covermode=atomic -coverprofile=coverage.txt ./...
35+
36+
- name: Unit Test VM
37+
run: |
38+
SONIC_USE_OPTDEC=1 SONIC_USE_FASTMAP=1 SONIC_ENCODER_USE_VM=1 GOMAXPROCS=4 go test -ldflags=-checklinkname=0 -race -covermode=atomic -coverprofile=coverage.txt ./...
39+
40+
- name: Loader Test
41+
run: |
42+
cd ./loader
43+
go test -ldflags=-checklinkname=0 -v -race ./...
44+
45+
- name: Data Race
46+
run: |
47+
./scripts/test_race.sh
48+
49+
- name: PCSP Test
50+
env:
51+
GOVERSION: ${{ matrix.go-version }}
52+
run: python3 ./scripts/test_pcsp.py
53+
54+
- name: Generic Test JIT
55+
if: ${{ !startsWith(matrix.go-version, '1.17.') }}
56+
run: GOMAXPROCS=4 go test -ldflags=-checklinkname=0 -v -race ./generic_test
57+
58+
- name: Generic Test VM
59+
if: ${{ !startsWith(matrix.go-version, '1.17.') }}
60+
run: GOMAXPROCS=4 SONIC_USE_OPTDEC=1 SONIC_USE_FASTMAP=1 SONIC_ENCODER_USE_VM=1 go test -ldflags=-checklinkname=0 -v -race ./generic_test
61+
62+
- name: Codecov
63+
run: bash <(curl -s https://codecov.io/bash)

ast/api.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
//go:build (amd64 && go1.17 && !go1.24) || (arm64 && go1.20 && !go1.24)
2-
// +build amd64,go1.17,!go1.24 arm64,go1.20,!go1.24
1+
//go:build (amd64 && go1.17 && !go1.25) || (arm64 && go1.20 && !go1.25)
2+
// +build amd64,go1.17,!go1.25 arm64,go1.20,!go1.25
33

44
/*
55
* Copyright 2022 ByteDance Inc.

ast/api_compat.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// +build !amd64,!arm64 go1.24 !go1.17 arm64,!go1.20
1+
// +build !amd64,!arm64 go1.25 !go1.17 arm64,!go1.20
22

33
/*
44
* Copyright 2022 ByteDance Inc.

ast/api_native_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
//go:build (amd64 && go1.17 && !go1.24) || (arm64 && go1.20 && !go1.24)
2-
// +build amd64,go1.17,!go1.24 arm64,go1.20,!go1.24
1+
//go:build (amd64 && go1.17 && !go1.25) || (arm64 && go1.20 && !go1.25)
2+
// +build amd64,go1.17,!go1.25 arm64,go1.20,!go1.25
33

44
/*
55
* Copyright 2022 ByteDance Inc.

ast/node.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1678,7 +1678,7 @@ func NewBytes(src []byte) Node {
16781678
if len(src) == 0 {
16791679
panic("empty src bytes")
16801680
}
1681-
out := rt.EncodeBase64(src)
1681+
out := rt.EncodeBase64ToString(src)
16821682
return NewString(out)
16831683
}
16841684

ast/stubs.go

Lines changed: 0 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -17,126 +17,15 @@
1717
package ast
1818

1919
import (
20-
"unicode/utf8"
2120
"unsafe"
2221

2322
"github.com/bytedance/sonic/internal/rt"
2423
)
2524

26-
//go:noescape
27-
//go:linkname memmove runtime.memmove
28-
//goland:noinspection GoUnusedParameter
29-
func memmove(to unsafe.Pointer, from unsafe.Pointer, n uintptr)
30-
31-
//go:linkname unsafe_NewArray reflect.unsafe_NewArray
32-
//goland:noinspection GoUnusedParameter
33-
func unsafe_NewArray(typ *rt.GoType, n int) unsafe.Pointer
34-
3525
//go:nosplit
3626
func mem2ptr(s []byte) unsafe.Pointer {
3727
return (*rt.GoSlice)(unsafe.Pointer(&s)).Ptr
3828
}
3929

40-
var safeSet = [utf8.RuneSelf]bool{
41-
' ': true,
42-
'!': true,
43-
'"': false,
44-
'#': true,
45-
'$': true,
46-
'%': true,
47-
'&': true,
48-
'\'': true,
49-
'(': true,
50-
')': true,
51-
'*': true,
52-
'+': true,
53-
',': true,
54-
'-': true,
55-
'.': true,
56-
'/': true,
57-
'0': true,
58-
'1': true,
59-
'2': true,
60-
'3': true,
61-
'4': true,
62-
'5': true,
63-
'6': true,
64-
'7': true,
65-
'8': true,
66-
'9': true,
67-
':': true,
68-
';': true,
69-
'<': true,
70-
'=': true,
71-
'>': true,
72-
'?': true,
73-
'@': true,
74-
'A': true,
75-
'B': true,
76-
'C': true,
77-
'D': true,
78-
'E': true,
79-
'F': true,
80-
'G': true,
81-
'H': true,
82-
'I': true,
83-
'J': true,
84-
'K': true,
85-
'L': true,
86-
'M': true,
87-
'N': true,
88-
'O': true,
89-
'P': true,
90-
'Q': true,
91-
'R': true,
92-
'S': true,
93-
'T': true,
94-
'U': true,
95-
'V': true,
96-
'W': true,
97-
'X': true,
98-
'Y': true,
99-
'Z': true,
100-
'[': true,
101-
'\\': false,
102-
']': true,
103-
'^': true,
104-
'_': true,
105-
'`': true,
106-
'a': true,
107-
'b': true,
108-
'c': true,
109-
'd': true,
110-
'e': true,
111-
'f': true,
112-
'g': true,
113-
'h': true,
114-
'i': true,
115-
'j': true,
116-
'k': true,
117-
'l': true,
118-
'm': true,
119-
'n': true,
120-
'o': true,
121-
'p': true,
122-
'q': true,
123-
'r': true,
124-
's': true,
125-
't': true,
126-
'u': true,
127-
'v': true,
128-
'w': true,
129-
'x': true,
130-
'y': true,
131-
'z': true,
132-
'{': true,
133-
'|': true,
134-
'}': true,
135-
'~': true,
136-
'\u007f': true,
137-
}
138-
139-
var hex = "0123456789abcdef"
140-
14130
//go:linkname unquoteBytes encoding/json.unquoteBytes
14231
func unquoteBytes(s []byte) (t []byte, ok bool)

0 commit comments

Comments
 (0)