Makes wazero complete dependency free (#465)
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
This commit is contained in:
1
Makefile
1
Makefile
@@ -49,6 +49,7 @@ build.spectest: # Note: wabt by default uses >1.0 features, so wast2json flags m
|
|||||||
.PHONY: test
|
.PHONY: test
|
||||||
test:
|
test:
|
||||||
@go test ./... -timeout 120s
|
@go test ./... -timeout 120s
|
||||||
|
@cd ./internal/integration_test && go test ./... -timeout 120s
|
||||||
|
|
||||||
golangci_lint_path := $(shell go env GOPATH)/bin/golangci-lint
|
golangci_lint_path := $(shell go env GOPATH)/bin/golangci-lint
|
||||||
|
|
||||||
|
|||||||
3
go.mod
3
go.mod
@@ -2,6 +2,3 @@ module github.com/tetratelabs/wazero
|
|||||||
|
|
||||||
// This should be the minimum supported Go version per https://go.dev/doc/devel/release (1 version behind latest)
|
// This should be the minimum supported Go version per https://go.dev/doc/devel/release (1 version behind latest)
|
||||||
go 1.17
|
go 1.17
|
||||||
|
|
||||||
// Test-only dependency.
|
|
||||||
require github.com/twitchyliquid64/golang-asm v0.15.1
|
|
||||||
|
|||||||
2
go.sum
2
go.sum
@@ -1,2 +0,0 @@
|
|||||||
github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
|
|
||||||
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import (
|
|||||||
|
|
||||||
"github.com/tetratelabs/wazero/internal/asm"
|
"github.com/tetratelabs/wazero/internal/asm"
|
||||||
asm_amd64 "github.com/tetratelabs/wazero/internal/asm/amd64"
|
asm_amd64 "github.com/tetratelabs/wazero/internal/asm/amd64"
|
||||||
"github.com/tetratelabs/wazero/internal/asm/golang_asm"
|
"github.com/tetratelabs/wazero/internal/integration_test/asm/golang_asm"
|
||||||
)
|
)
|
||||||
|
|
||||||
// NewDebugAssembler can be used for ensuring that our assembler produces exactly the same binary as Go.
|
// NewDebugAssembler can be used for ensuring that our assembler produces exactly the same binary as Go.
|
||||||
@@ -9,7 +9,7 @@ import (
|
|||||||
|
|
||||||
"github.com/tetratelabs/wazero/internal/asm"
|
"github.com/tetratelabs/wazero/internal/asm"
|
||||||
asm_amd64 "github.com/tetratelabs/wazero/internal/asm/amd64"
|
asm_amd64 "github.com/tetratelabs/wazero/internal/asm/amd64"
|
||||||
"github.com/tetratelabs/wazero/internal/asm/golang_asm"
|
"github.com/tetratelabs/wazero/internal/integration_test/asm/golang_asm"
|
||||||
)
|
)
|
||||||
|
|
||||||
// assemblerGoAsmImpl implements asm_amd64.Assembler for golang-asm library.
|
// assemblerGoAsmImpl implements asm_amd64.Assembler for golang-asm library.
|
||||||
@@ -7,7 +7,7 @@ import (
|
|||||||
|
|
||||||
"github.com/tetratelabs/wazero/internal/asm"
|
"github.com/tetratelabs/wazero/internal/asm"
|
||||||
asm_arm64 "github.com/tetratelabs/wazero/internal/asm/arm64"
|
asm_arm64 "github.com/tetratelabs/wazero/internal/asm/arm64"
|
||||||
"github.com/tetratelabs/wazero/internal/asm/golang_asm"
|
"github.com/tetratelabs/wazero/internal/integration_test/asm/golang_asm"
|
||||||
)
|
)
|
||||||
|
|
||||||
// NewDebugAssembler can be used for ensuring that our assembler produces exactly the same binary as Go.
|
// NewDebugAssembler can be used for ensuring that our assembler produces exactly the same binary as Go.
|
||||||
@@ -9,7 +9,7 @@ import (
|
|||||||
|
|
||||||
"github.com/tetratelabs/wazero/internal/asm"
|
"github.com/tetratelabs/wazero/internal/asm"
|
||||||
asm_arm64 "github.com/tetratelabs/wazero/internal/asm/arm64"
|
asm_arm64 "github.com/tetratelabs/wazero/internal/asm/arm64"
|
||||||
"github.com/tetratelabs/wazero/internal/asm/golang_asm"
|
"github.com/tetratelabs/wazero/internal/integration_test/asm/golang_asm"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TODO: this comment seems wrong
|
// TODO: this comment seems wrong
|
||||||
10
internal/integration_test/go.mod
Normal file
10
internal/integration_test/go.mod
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
module github.com/tetratelabs/wazero/internal/integration_test
|
||||||
|
|
||||||
|
go 1.17
|
||||||
|
|
||||||
|
require (
|
||||||
|
github.com/tetratelabs/wazero v0.0.0
|
||||||
|
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
|
||||||
|
)
|
||||||
|
|
||||||
|
replace github.com/tetratelabs/wazero => ../..
|
||||||
4
internal/integration_test/go.sum
Normal file
4
internal/integration_test/go.sum
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
github.com/tetratelabs/wazero v0.0.0-20220414083743-1e383881edc0 h1:MYB8s3+HS4qaxvnEDJm3Qsn0NQXvBhowgSJVyBZeW+k=
|
||||||
|
github.com/tetratelabs/wazero v0.0.0-20220414083743-1e383881edc0/go.mod h1:5JB7ectLUx/rulnLfKI628r3/wUm1grVYnHfmQ2hpBY=
|
||||||
|
github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
|
||||||
|
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
|
||||||
@@ -5,26 +5,10 @@ import (
|
|||||||
|
|
||||||
"github.com/tetratelabs/wazero/internal/asm"
|
"github.com/tetratelabs/wazero/internal/asm"
|
||||||
amd64 "github.com/tetratelabs/wazero/internal/asm/amd64"
|
amd64 "github.com/tetratelabs/wazero/internal/asm/amd64"
|
||||||
"github.com/tetratelabs/wazero/internal/asm/amd64_debug"
|
|
||||||
"github.com/tetratelabs/wazero/internal/testing/require"
|
"github.com/tetratelabs/wazero/internal/testing/require"
|
||||||
"github.com/tetratelabs/wazero/internal/wasm"
|
|
||||||
"github.com/tetratelabs/wazero/internal/wazeroir"
|
"github.com/tetratelabs/wazero/internal/wazeroir"
|
||||||
)
|
)
|
||||||
|
|
||||||
// newDebugAmd64Compiler allows debugging in tests, without pinning a dependency in main code.
|
|
||||||
func newDebugAmd64Compiler(f *wasm.FunctionInstance, ir *wazeroir.CompilationResult) (compiler, error) {
|
|
||||||
c, err := newAmd64Compiler(f, ir)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
a, err := amd64_debug.NewDebugAssembler()
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
c.(*amd64Compiler).assembler = a
|
|
||||||
return c, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestAmd64Compiler_compile_Mul_Div_Rem(t *testing.T) {
|
func TestAmd64Compiler_compile_Mul_Div_Rem(t *testing.T) {
|
||||||
for _, kind := range []wazeroir.OperationKind{
|
for _, kind := range []wazeroir.OperationKind{
|
||||||
wazeroir.OperationKindMul,
|
wazeroir.OperationKindMul,
|
||||||
@@ -87,7 +71,7 @@ func TestAmd64Compiler_compile_Mul_Div_Rem(t *testing.T) {
|
|||||||
const x2Value uint32 = 51
|
const x2Value uint32 = 51
|
||||||
const dxValue uint64 = 111111
|
const dxValue uint64 = 111111
|
||||||
|
|
||||||
compiler := env.requireNewCompiler(t, newDebugAmd64Compiler, nil).(*amd64Compiler)
|
compiler := env.requireNewCompiler(t, newAmd64Compiler, nil).(*amd64Compiler)
|
||||||
err := compiler.compilePreamble()
|
err := compiler.compilePreamble()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
@@ -209,7 +193,7 @@ func TestAmd64Compiler_compile_Mul_Div_Rem(t *testing.T) {
|
|||||||
const dxValue uint64 = 111111
|
const dxValue uint64 = 111111
|
||||||
|
|
||||||
env := newJITEnvironment()
|
env := newJITEnvironment()
|
||||||
compiler := env.requireNewCompiler(t, newDebugAmd64Compiler, nil).(*amd64Compiler)
|
compiler := env.requireNewCompiler(t, newAmd64Compiler, nil).(*amd64Compiler)
|
||||||
err := compiler.compilePreamble()
|
err := compiler.compilePreamble()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
@@ -288,7 +272,7 @@ func TestAmd64Compiler_compile_Mul_Div_Rem(t *testing.T) {
|
|||||||
func TestAmd64Compiler_readInstructionAddress(t *testing.T) {
|
func TestAmd64Compiler_readInstructionAddress(t *testing.T) {
|
||||||
t.Run("invalid", func(t *testing.T) {
|
t.Run("invalid", func(t *testing.T) {
|
||||||
env := newJITEnvironment()
|
env := newJITEnvironment()
|
||||||
compiler := env.requireNewCompiler(t, newDebugAmd64Compiler, nil).(*amd64Compiler)
|
compiler := env.requireNewCompiler(t, newAmd64Compiler, nil).(*amd64Compiler)
|
||||||
|
|
||||||
err := compiler.compilePreamble()
|
err := compiler.compilePreamble()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
@@ -304,7 +288,7 @@ func TestAmd64Compiler_readInstructionAddress(t *testing.T) {
|
|||||||
|
|
||||||
t.Run("ok", func(t *testing.T) {
|
t.Run("ok", func(t *testing.T) {
|
||||||
env := newJITEnvironment()
|
env := newJITEnvironment()
|
||||||
compiler := env.requireNewCompiler(t, newDebugAmd64Compiler, nil).(*amd64Compiler)
|
compiler := env.requireNewCompiler(t, newAmd64Compiler, nil).(*amd64Compiler)
|
||||||
|
|
||||||
err := compiler.compilePreamble()
|
err := compiler.compilePreamble()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|||||||
Reference in New Issue
Block a user