Skip to content

Commit

Permalink
Merge branch 'main' into feat/ast_lock
Browse files Browse the repository at this point in the history
  • Loading branch information
AsterDY authored Jul 29, 2024
2 parents 2155f34 + 8a2444e commit dc26e16
Show file tree
Hide file tree
Showing 37 changed files with 316 additions and 88 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/go_latest_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Go Latest Linux-X64

on: push

jobs:
build:
strategy:
matrix:
os: [arm, X64]
runs-on: ${{ matrix.os }}
steps:
- name: Clear repository
run: sudo rm -fr $GITHUB_WORKSPACE && mkdir $GITHUB_WORKSPACE

- uses: actions/checkout@v2

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.22.4

- uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: build go
run: sh ./scripts/go_latest.sh go1.23
continue-on-error: true

- name: test
run: |
PWD=$(pwd)
export GOROOT=$PWD/go1.23
export PATH=$GOROOT/bin:$PATH
go version
GOMAXPROCS=4 go test -v -race .
GOMAXPROCS=4 go test -v -race github.com/bytedance/sonic/ast
GOMAXPROCS=4 go test -v -race github.com/bytedance/sonic/encoder
GOMAXPROCS=4 go test -v -race github.com/bytedance/sonic/decoder
GOMAXPROCS=4 go test -v -race github.com/bytedance/sonic/issue_test
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.23) || (arm64 && go1.20 && !go1.23)
// +build amd64,go1.17,!go1.23 arm64,go1.20,!go1.23
//go:build (amd64 && go1.17 && !go1.24) || (arm64 && go1.20 && !go1.24)
// +build amd64,go1.17,!go1.24 arm64,go1.20,!go1.24

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

/*
* Copyright 2022 ByteDance Inc.
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.23) || (arm64 && go1.20 && !go1.23)
// +build amd64,go1.17,!go1.23 arm64,go1.20,!go1.23
//go:build (amd64 && go1.17 && !go1.24) || (arm64 && go1.20 && !go1.24)
// +build amd64,go1.17,!go1.24 arm64,go1.20,!go1.24

/*
* Copyright 2022 ByteDance Inc.
Expand Down
106 changes: 104 additions & 2 deletions ast/stubs.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@
package ast

import (
`unsafe`
"unicode/utf8"
"unsafe"

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

//go:noescape
Expand All @@ -36,5 +37,106 @@ 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.23 !go1.17 arm64,!go1.20
// +build !amd64,!arm64 go1.24 !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.23) || (arm64 && go1.20 && !go1.23)
// +build amd64,go1.17,!go1.23 arm64,go1.20,!go1.23
//go:build (amd64 && go1.17 && !go1.24) || (arm64 && go1.20 && !go1.24)
// +build amd64,go1.17,!go1.24 arm64,go1.20,!go1.24

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

/*
* Copyright 2023 ByteDance Inc.
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.23) || (arm64 && go1.20 && !go1.23)
// +build amd64,go1.17,!go1.23 arm64,go1.20,!go1.23
//go:build (amd64 && go1.17 && !go1.24) || (arm64 && go1.20 && !go1.24)
// +build amd64,go1.17,!go1.24 arm64,go1.20,!go1.24


/*
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.23) || (arm64 && go1.20 && !go1.23)
// +build amd64,go1.17,!go1.23 arm64,go1.20,!go1.23
//go:build (amd64 && go1.17 && !go1.24) || (arm64 && go1.20 && !go1.24)
// +build amd64,go1.17,!go1.24 arm64,go1.20,!go1.24


/*
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.23) || (arm64 && go1.20 && !go1.23)
// +build amd64,go1.17,!go1.23 arm64,go1.20,!go1.23
//go:build (amd64 && go1.17 && !go1.24) || (arm64 && go1.20 && !go1.24)
// +build amd64,go1.17,!go1.24 arm64,go1.20,!go1.24

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

/*
* Copyright 2023 ByteDance Inc.
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.23 arm64,go1.20,!go1.23
// +build amd64,go1.17,!go1.24 arm64,go1.20,!go1.24

/*
* 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.23 arm64,go1.20,!go1.23
// +build amd64,go1.17,!go1.24 arm64,go1.20,!go1.24

/*
* Copyright 2021 ByteDance Inc.
Expand Down
1 change: 1 addition & 0 deletions go1.23
Submodule go1.23 added at c9940f
4 changes: 2 additions & 2 deletions internal/decoder/api/decoder_amd64.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//go:build go1.17 && !go1.23
// +build go1.17,!go1.23
//go:build go1.17 && !go1.24
// +build go1.17,!go1.24

/*
* Copyright 2021 ByteDance Inc.
Expand Down
2 changes: 1 addition & 1 deletion internal/decoder/api/decoder_arm64.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build go1.17,!go1.23
// +build go1.17,!go1.24

/*
* Copyright 2021 ByteDance Inc.
Expand Down
2 changes: 1 addition & 1 deletion internal/decoder/jitdec/asm_stubs_amd64_go121.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build go1.21,!go1.23
// +build go1.21,!go1.24

// Copyright 2023 CloudWeGo Authors
//
Expand Down
2 changes: 1 addition & 1 deletion internal/decoder/jitdec/assembler_regabi_amd64.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build go1.17,!go1.23
// +build go1.17,!go1.24

/*
* Copyright 2021 ByteDance Inc.
Expand Down
2 changes: 1 addition & 1 deletion internal/decoder/jitdec/generic_regabi_amd64.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build go1.17,!go1.23
// +build go1.17,!go1.24

/*
* Copyright 2021 ByteDance Inc.
Expand Down
2 changes: 1 addition & 1 deletion internal/decoder/jitdec/generic_regabi_amd64_test.s
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build go1.17,!go1.23
// +build go1.17,!go1.24

//
// Copyright 2021 ByteDance Inc.
Expand Down
4 changes: 2 additions & 2 deletions internal/encoder/alg/spec.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//go:build (amd64 && go1.16 && !go1.23) || (arm64 && go1.20 && !go1.23)
// +build amd64,go1.16,!go1.23 arm64,go1.20,!go1.23
//go:build (amd64 && go1.16 && !go1.24) || (arm64 && go1.20 && !go1.24)
// +build amd64,go1.16,!go1.24 arm64,go1.20,!go1.24

/**
* Copyright 2024 ByteDance Inc.
Expand Down
2 changes: 1 addition & 1 deletion internal/encoder/alg/spec_compat.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build !amd64,!arm64 go1.23 !go1.16 arm64,!go1.20
// +build !amd64,!arm64 go1.24 !go1.16 arm64,!go1.20

/**
* Copyright 2024 ByteDance Inc.
Expand Down
4 changes: 2 additions & 2 deletions internal/encoder/x86/asm_stubs_amd64_go121.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//go:build go1.21 && !go1.23
// +build go1.21,!go1.23
//go:build go1.21 && !go1.24
// +build go1.21,!go1.24

// Copyright 2023 CloudWeGo Authors
//
Expand Down
4 changes: 2 additions & 2 deletions internal/encoder/x86/assembler_regabi_amd64.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//go:build go1.17 && !go1.23
// +build go1.17,!go1.23
//go:build go1.17 && !go1.24
// +build go1.17,!go1.24

/*
* Copyright 2021 ByteDance Inc.
Expand Down
4 changes: 2 additions & 2 deletions internal/encoder/x86/debug_go117.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//go:build go1.17 && !go1.23
// +build go1.17,!go1.23
//go:build go1.17 && !go1.24
// +build go1.17,!go1.24

/*
* Copyright 2021 ByteDance Inc.
Expand Down
2 changes: 1 addition & 1 deletion internal/native/traceback_test.mock_tmpl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

// +build !race,amd64,go1.16,!go1.23
// +build !race,amd64,go1.16,!go1.24

// Code generated by Makefile, DO NOT EDIT.

Expand Down
2 changes: 1 addition & 1 deletion internal/rt/base64_amd64.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build amd64,go1.17,!go1.23
// +build amd64,go1.17,!go1.24

package rt

Expand Down
2 changes: 1 addition & 1 deletion internal/rt/base64_compat.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build !amd64 !go1.17 go1.23
// +build !amd64 !go1.17 go1.24

package rt

Expand Down
Loading

0 comments on commit dc26e16

Please sign in to comment.