-
Notifications
You must be signed in to change notification settings - Fork 0
/
golang_go_quark_nommx_8a317ebc0f50339628c003bf06107cd865406dd4.patch
163 lines (156 loc) · 4.47 KB
/
golang_go_quark_nommx_8a317ebc0f50339628c003bf06107cd865406dd4.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
diff --git a/src/cmd/compile/internal/x86/galign.go b/src/cmd/compile/internal/x86/galign.go
index 7f53ee3731..fce2b9783d 100644
--- a/src/cmd/compile/internal/x86/galign.go
+++ b/src/cmd/compile/internal/x86/galign.go
@@ -16,7 +16,7 @@ func Init(arch *gc.Arch) {
arch.LinkArch = &x86.Link386
arch.REGSP = x86.REGSP
switch v := objabi.GO386; v {
- case "387":
+ case "387", "quark":
arch.Use387 = true
arch.SSAGenValue = ssaGenValue387
arch.SSAGenBlock = ssaGenBlock387
diff --git a/src/cmd/internal/obj/x86/asm6.go b/src/cmd/internal/obj/x86/asm6.go
index 1f668a0166..bdc53340fd 100644
--- a/src/cmd/internal/obj/x86/asm6.go
+++ b/src/cmd/internal/obj/x86/asm6.go
@@ -2030,6 +2030,8 @@ func span6(ctxt *obj.Link, s *obj.LSym, newprog obj.ProgAlloc) {
}
}
+var isQuark = (objabi.GO386 == "quark")
+
func instinit(ctxt *obj.Link) {
if ycover[0] != 0 {
// Already initialized; stop now.
@@ -2054,6 +2056,11 @@ func instinit(ctxt *obj.Link) {
}
for i := 1; optab[i].as != 0; i++ {
c := optab[i].as
+
+ if isQuark && c == ALOCK {
+ optab[i].op = opBytes{}
+ }
+
if opindex[c&obj.AMask] != nil {
ctxt.Diag("phase error in optab: %d (%v)", i, c)
}
diff --git a/src/runtime/asm_386.s b/src/runtime/asm_386.s
index a01841d796..d5e8aa18ba 100644
--- a/src/runtime/asm_386.s
+++ b/src/runtime/asm_386.s
@@ -109,32 +109,6 @@ TEXT runtime·rt0_go(SB),NOSPLIT|NOFRAME,$0
MOVL SP, (g_stack+stack_hi)(BP)
// find out information about the processor we're on
-#ifdef GOOS_nacl // NaCl doesn't like PUSHFL/POPFL
- JMP has_cpuid
-#else
- // first see if CPUID instruction is supported.
- PUSHFL
- PUSHFL
- XORL $(1<<21), 0(SP) // flip ID bit
- POPFL
- PUSHFL
- POPL AX
- XORL 0(SP), AX
- POPFL // restore EFLAGS
- TESTL $(1<<21), AX
- JNE has_cpuid
-#endif
-
-bad_proc: // show that the program requires MMX.
- MOVL $2, 0(SP)
- MOVL $bad_proc_msg<>(SB), 4(SP)
- MOVL $0x3d, 8(SP)
- CALL runtime·write(SB)
- MOVL $1, 0(SP)
- CALL runtime·exit(SB)
- CALL runtime·abort(SB)
-
-has_cpuid:
MOVL $0, AX
CPUID
MOVL AX, SI
@@ -160,10 +134,6 @@ notintel:
MOVL CX, DI // Move to global variable clobbers CX when generating PIC
MOVL AX, runtime·processorVersionInfo(SB)
- // Check for MMX support
- TESTL $(1<<23), DX // MMX
- JZ bad_proc
-
nocpuinfo:
// if there is an _cgo_init, call it to let it
// initialize and to set up GS. if not,
@@ -259,9 +229,6 @@ ok:
CALL runtime·abort(SB)
RET
-DATA bad_proc_msg<>+0x00(SB)/61, $"This program can only be run on processors with MMX support.\n"
-GLOBL bad_proc_msg<>(SB), RODATA, $61
-
DATA runtime·mainPC+0(SB)/4,$runtime·main(SB)
GLOBL runtime·mainPC(SB),RODATA,$4
diff --git a/src/runtime/internal/atomic/asm_386.s b/src/runtime/internal/atomic/asm_386.s
index 13289a88d0..c644dd89f8 100644
--- a/src/runtime/internal/atomic/asm_386.s
+++ b/src/runtime/internal/atomic/asm_386.s
@@ -192,17 +192,30 @@ TEXT runtime∕internal∕atomic·Load64(SB), NOSPLIT, $0-12
TESTL $7, AX
JZ 2(PC)
MOVL 0, AX // crash with nil ptr deref
+ TESTL $(1<<23), runtime·cpuid_edx(SB) // check for mmx
+ JEQ load64_nommx
MOVQ (AX), M0
MOVQ M0, ret+4(FP)
EMMS
RET
+load64_nommx:
+ MOVL DX, CX
+ MOVL AX, BX
+ LOCK
+ CMPXCHG8B (AX)
+ MOVL AX, ret_lo+4(FP)
+ MOVL DX, ret_hi+8(FP)
+ RET
+
// void runtime∕internal∕atomic·Store64(uint64 volatile* addr, uint64 v);
TEXT runtime∕internal∕atomic·Store64(SB), NOSPLIT, $0-12
- MOVL ptr+0(FP), AX
- TESTL $7, AX
+ MOVL ptr+0(FP), SI
+ TESTL $7, SI
JZ 2(PC)
- MOVL 0, AX // crash with nil ptr deref
+ MOVL 0, SI // crash with nil ptr deref
+ TESTL $(1<<23), runtime·cpuid_edx(SB) // check for mmx
+ JEQ store64_nommx
// MOVQ and EMMS were introduced on the Pentium MMX.
MOVQ val+4(FP), M0
MOVQ M0, (AX)
@@ -214,6 +227,15 @@ TEXT runtime∕internal∕atomic·Store64(SB), NOSPLIT, $0-12
XADDL AX, (SP)
RET
+store64_nommx:
+ MOVL val_lo+4(FP), BX
+ MOVL val_hi+8(FP), CX
+store64_loop:
+ LOCK
+ CMPXCHG8B (SI)
+ JNE store64_loop
+ RET
+
// void runtime∕internal∕atomic·Or8(byte volatile*, byte);
TEXT runtime∕internal∕atomic·Or8(SB), NOSPLIT, $0-5
MOVL ptr+0(FP), AX
diff --git a/src/runtime/runtime2.go b/src/runtime/runtime2.go
index 16c02cd1ed..b34063fb21 100644
--- a/src/runtime/runtime2.go
+++ b/src/runtime/runtime2.go
@@ -926,7 +926,7 @@ var (
processorVersionInfo uint32
isIntel bool
lfenceBeforeRdtsc bool
-
+ cpuid_edx uint32
goarm uint8 // set by cmd/link on arm systems
framepointer_enabled bool // set by cmd/link
)