Skip to content
This repository was archived by the owner on May 11, 2020. It is now read-only.

Commit 4176795

Browse files
twitchyliquid64sbinet
authored andcommitted
exec: enable use of amd64 backend on Windows & OSX
* Refactor JITCall to take globals and memory, Implement GetGlobal, SetGlobal. * Implement scalar memory load for 64 bit and 32 bit types. * Add support for 64/32bit memory loads. These are simpler as they don't need spectre mitigations. * Implement a few optimizations. * Eliminate some redundant LEAQ and MOV instructions. * Finish implementing scanning optimizer, add a few more RHS constant-optimized instructions. * Remove scanning optimizer - its not the right time. * Add missing header, add test for fused const + ops * Added test for emitRHSConstOptimizedInstruction() * Refactor amd64 backend into 3 passes. * Remove unused error handling * Enable use of amd64 backend on Windows & OSX. * Address review feedback
1 parent 8772f68 commit 4176795

File tree

3 files changed

+44
-22
lines changed

3 files changed

+44
-22
lines changed

exec/exec_test.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ func testModules(t *testing.T, dir string, repeat bool) {
389389
})
390390
t.Run(fileName+" native", func(t *testing.T) {
391391
t.Parallel()
392-
if runtime.GOARCH != "amd64" || runtime.GOOS != "linux" {
392+
if runtime.GOARCH != "amd64" || !supportedOS(runtime.GOOS) {
393393
t.SkipNow()
394394
}
395395

@@ -543,3 +543,10 @@ func BenchmarkU64Arithmetic50Native(b *testing.B) {
543543
benchmarkDummy, _ = vm.ExecCode(int64(funcIndex), 50, 1234)
544544
}
545545
}
546+
547+
func supportedOS(os string) bool {
548+
if os == "linux" || os == "windows" || os == "darwin" {
549+
return true
550+
}
551+
return false
552+
}

exec/internal/compile/backend_amd64_test.go

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121
)
2222

2323
func TestAMD64JitCall(t *testing.T) {
24-
if runtime.GOOS != "linux" {
24+
if !supportedOS(runtime.GOOS) {
2525
t.SkipNow()
2626
}
2727
allocator := &MMapAllocator{}
@@ -51,7 +51,7 @@ func TestAMD64JitCall(t *testing.T) {
5151
}
5252

5353
func TestAMD64StackPush(t *testing.T) {
54-
if runtime.GOOS != "linux" {
54+
if !supportedOS(runtime.GOOS) {
5555
t.SkipNow()
5656
}
5757
allocator := &MMapAllocator{}
@@ -113,7 +113,7 @@ func TestAMD64StackPush(t *testing.T) {
113113
}
114114

115115
func TestAMD64StackPop(t *testing.T) {
116-
if runtime.GOOS != "linux" {
116+
if !supportedOS(runtime.GOOS) {
117117
t.SkipNow()
118118
}
119119
allocator := &MMapAllocator{}
@@ -153,7 +153,7 @@ func TestAMD64StackPop(t *testing.T) {
153153
}
154154

155155
func TestAMD64ExitSignal(t *testing.T) {
156-
if runtime.GOOS != "linux" {
156+
if !supportedOS(runtime.GOOS) {
157157
t.SkipNow()
158158
}
159159
allocator := &MMapAllocator{}
@@ -236,7 +236,7 @@ func TestAMD64ExitSignal(t *testing.T) {
236236
}
237237

238238
func TestAMD64LocalsGet(t *testing.T) {
239-
if runtime.GOOS != "linux" {
239+
if !supportedOS(runtime.GOOS) {
240240
t.SkipNow()
241241
}
242242
allocator := &MMapAllocator{}
@@ -277,7 +277,7 @@ func TestAMD64LocalsGet(t *testing.T) {
277277
}
278278

279279
func TestAMD64LocalsSet(t *testing.T) {
280-
if runtime.GOOS != "linux" {
280+
if !supportedOS(runtime.GOOS) {
281281
t.SkipNow()
282282
}
283283
allocator := &MMapAllocator{}
@@ -322,7 +322,7 @@ func TestAMD64LocalsSet(t *testing.T) {
322322
}
323323

324324
func TestAMD64GlobalsGet(t *testing.T) {
325-
if runtime.GOOS != "linux" {
325+
if !supportedOS(runtime.GOOS) {
326326
t.SkipNow()
327327
}
328328
allocator := &MMapAllocator{}
@@ -359,7 +359,7 @@ func TestAMD64GlobalsGet(t *testing.T) {
359359
}
360360

361361
func TestAMD64GlobalsSet(t *testing.T) {
362-
if runtime.GOOS != "linux" {
362+
if !supportedOS(runtime.GOOS) {
363363
t.SkipNow()
364364
}
365365
allocator := &MMapAllocator{}
@@ -407,7 +407,7 @@ func TestAMD64GlobalsSet(t *testing.T) {
407407
}
408408

409409
func TestAMD64Select(t *testing.T) {
410-
if runtime.GOOS != "linux" {
410+
if !supportedOS(runtime.GOOS) {
411411
t.SkipNow()
412412
}
413413
allocator := &MMapAllocator{}
@@ -482,7 +482,7 @@ func TestAMD64MemoryLoad(t *testing.T) {
482482
oob: true,
483483
},
484484
}
485-
if runtime.GOOS != "linux" {
485+
if !supportedOS(runtime.GOOS) {
486486
t.SkipNow()
487487
}
488488
allocator := &MMapAllocator{}
@@ -568,7 +568,7 @@ func TestAMD64MemoryStore(t *testing.T) {
568568
oob: true,
569569
},
570570
}
571-
if runtime.GOOS != "linux" {
571+
if !supportedOS(runtime.GOOS) {
572572
t.SkipNow()
573573
}
574574
allocator := &MMapAllocator{}
@@ -688,7 +688,7 @@ func TestAMD64FusedConstStore(t *testing.T) {
688688
expectMem: []byte{0, 0, 0, 0, 0, 5, 0, 0, 0, 0},
689689
},
690690
}
691-
if runtime.GOOS != "linux" {
691+
if !supportedOS(runtime.GOOS) {
692692
t.SkipNow()
693693
}
694694
allocator := &MMapAllocator{}
@@ -829,7 +829,7 @@ func TestAMD64RHSConstOptimizedBinOp(t *testing.T) {
829829
expectStack: []uint64{1},
830830
},
831831
}
832-
if runtime.GOOS != "linux" {
832+
if !supportedOS(runtime.GOOS) {
833833
t.SkipNow()
834834
}
835835
allocator := &MMapAllocator{}
@@ -867,7 +867,7 @@ func TestAMD64RHSConstOptimizedBinOp(t *testing.T) {
867867
}
868868

869869
func TestAMD64OperationsI64(t *testing.T) {
870-
if runtime.GOOS != "linux" {
870+
if !supportedOS(runtime.GOOS) {
871871
t.SkipNow()
872872
}
873873
testCases := []struct {
@@ -984,7 +984,7 @@ func TestAMD64OperationsI64(t *testing.T) {
984984
}
985985

986986
func TestDivOps(t *testing.T) {
987-
if runtime.GOOS != "linux" {
987+
if !supportedOS(runtime.GOOS) {
988988
t.SkipNow()
989989
}
990990
testCases := []struct {
@@ -1106,7 +1106,7 @@ func TestDivOps(t *testing.T) {
11061106
}
11071107

11081108
func TestComparisonOps64(t *testing.T) {
1109-
if runtime.GOOS != "linux" {
1109+
if !supportedOS(runtime.GOOS) {
11101110
t.SkipNow()
11111111
}
11121112
testCases := []struct {
@@ -1258,7 +1258,7 @@ func TestComparisonOps64(t *testing.T) {
12581258
}
12591259

12601260
func TestAMD64RHSOptimizations(t *testing.T) {
1261-
if runtime.GOOS != "linux" {
1261+
if !supportedOS(runtime.GOOS) {
12621262
t.SkipNow()
12631263
}
12641264
tcs := []struct {
@@ -1357,7 +1357,7 @@ func TestAMD64RHSOptimizations(t *testing.T) {
13571357
}
13581358

13591359
func TestAMD64OperationsI32(t *testing.T) {
1360-
if runtime.GOOS != "linux" {
1360+
if !supportedOS(runtime.GOOS) {
13611361
t.SkipNow()
13621362
}
13631363
testCases := []struct {
@@ -1463,7 +1463,7 @@ func TestAMD64OperationsI32(t *testing.T) {
14631463
}
14641464

14651465
func TestAMD64OperationsF64(t *testing.T) {
1466-
if runtime.GOOS != "linux" {
1466+
if !supportedOS(runtime.GOOS) {
14671467
t.SkipNow()
14681468
}
14691469
testCases := []struct {
@@ -1683,7 +1683,7 @@ func TestAMD64OperationsF64(t *testing.T) {
16831683
}
16841684

16851685
func TestComparisonOpsFloat(t *testing.T) {
1686-
if runtime.GOOS != "linux" {
1686+
if !supportedOS(runtime.GOOS) {
16871687
t.SkipNow()
16881688
}
16891689
testCases := []struct {
@@ -1933,7 +1933,7 @@ func TestComparisonOpsFloat(t *testing.T) {
19331933
}
19341934

19351935
func TestAMD64IntToFloat(t *testing.T) {
1936-
if runtime.GOOS != "linux" {
1936+
if !supportedOS(runtime.GOOS) {
19371937
t.SkipNow()
19381938
}
19391939
testCases := []struct {
@@ -2063,3 +2063,10 @@ func u32ConstNegated(i uint32) uint64 {
20632063
tmp := -i
20642064
return uint64(tmp)
20652065
}
2066+
2067+
func supportedOS(os string) bool {
2068+
if os == "linux" || os == "windows" || os == "darwin" {
2069+
return true
2070+
}
2071+
return false
2072+
}

exec/native_compile_nogae.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@ func init() {
1717
Arch: "amd64",
1818
OS: "linux",
1919
make: makeAMD64NativeBackend,
20+
}, nativeArch{
21+
Arch: "amd64",
22+
OS: "windows",
23+
make: makeAMD64NativeBackend,
24+
}, nativeArch{
25+
Arch: "amd64",
26+
OS: "darwin",
27+
make: makeAMD64NativeBackend,
2028
})
2129
}
2230

0 commit comments

Comments
 (0)