Makes wazero complete dependency free (#465)

Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
This commit is contained in:
Takeshi Yoneda
2022-04-15 10:22:42 +09:00
committed by GitHub
parent 1e383881ed
commit 556cfa1967
13 changed files with 23 additions and 29 deletions

View File

@@ -49,6 +49,7 @@ build.spectest: # Note: wabt by default uses >1.0 features, so wast2json flags m
.PHONY: test
test:
@go test ./... -timeout 120s
@cd ./internal/integration_test && go test ./... -timeout 120s
golangci_lint_path := $(shell go env GOPATH)/bin/golangci-lint

3
go.mod
View File

@@ -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)
go 1.17
// Test-only dependency.
require github.com/twitchyliquid64/golang-asm v0.15.1

2
go.sum
View File

@@ -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=

View File

@@ -9,7 +9,7 @@ import (
"github.com/tetratelabs/wazero/internal/asm"
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.

View File

@@ -9,7 +9,7 @@ import (
"github.com/tetratelabs/wazero/internal/asm"
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.

View File

@@ -7,7 +7,7 @@ import (
"github.com/tetratelabs/wazero/internal/asm"
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.

View File

@@ -9,7 +9,7 @@ import (
"github.com/tetratelabs/wazero/internal/asm"
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

View 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 => ../..

View 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=

View File

@@ -5,26 +5,10 @@ import (
"github.com/tetratelabs/wazero/internal/asm"
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/wasm"
"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) {
for _, kind := range []wazeroir.OperationKind{
wazeroir.OperationKindMul,
@@ -87,7 +71,7 @@ func TestAmd64Compiler_compile_Mul_Div_Rem(t *testing.T) {
const x2Value uint32 = 51
const dxValue uint64 = 111111
compiler := env.requireNewCompiler(t, newDebugAmd64Compiler, nil).(*amd64Compiler)
compiler := env.requireNewCompiler(t, newAmd64Compiler, nil).(*amd64Compiler)
err := compiler.compilePreamble()
require.NoError(t, err)
@@ -209,7 +193,7 @@ func TestAmd64Compiler_compile_Mul_Div_Rem(t *testing.T) {
const dxValue uint64 = 111111
env := newJITEnvironment()
compiler := env.requireNewCompiler(t, newDebugAmd64Compiler, nil).(*amd64Compiler)
compiler := env.requireNewCompiler(t, newAmd64Compiler, nil).(*amd64Compiler)
err := compiler.compilePreamble()
require.NoError(t, err)
@@ -288,7 +272,7 @@ func TestAmd64Compiler_compile_Mul_Div_Rem(t *testing.T) {
func TestAmd64Compiler_readInstructionAddress(t *testing.T) {
t.Run("invalid", func(t *testing.T) {
env := newJITEnvironment()
compiler := env.requireNewCompiler(t, newDebugAmd64Compiler, nil).(*amd64Compiler)
compiler := env.requireNewCompiler(t, newAmd64Compiler, nil).(*amd64Compiler)
err := compiler.compilePreamble()
require.NoError(t, err)
@@ -304,7 +288,7 @@ func TestAmd64Compiler_readInstructionAddress(t *testing.T) {
t.Run("ok", func(t *testing.T) {
env := newJITEnvironment()
compiler := env.requireNewCompiler(t, newDebugAmd64Compiler, nil).(*amd64Compiler)
compiler := env.requireNewCompiler(t, newAmd64Compiler, nil).(*amd64Compiler)
err := compiler.compilePreamble()
require.NoError(t, err)