}
}
+const haveCputicksAsm = GOARCH == "386" || GOARCH == "amd64"
+
func loadOptionalSyscalls() {
var kernel32dll = []byte("kernel32.dll\000")
k32 := stdcall1(_LoadLibraryA, uintptr(unsafe.Pointer(&kernel32dll[0])))
}
_NtWaitForSingleObject = windowsFindfunc(n32, []byte("NtWaitForSingleObject\000"))
- if GOARCH == "arm" {
+ if !haveCputicksAsm {
_QueryPerformanceCounter = windowsFindfunc(k32, []byte("QueryPerformanceCounter\000"))
if _QueryPerformanceCounter == nil {
throw("could not find QPC syscalls")
_SYNCHRONIZE|_TIMER_QUERY_STATE|_TIMER_MODIFY_STATE)
}
+const highResTimerSupported = GOARCH == "386" || GOARCH == "amd64"
+
func initHighResTimer() {
- if GOARCH == "arm" {
+ if !highResTimerSupported {
// TODO: Not yet implemented.
return
}
atomic.Store((*uint32)(unsafe.Pointer(&getg().m.profilehz)), uint32(hz))
}
-const preemptMSupported = GOARCH != "arm"
+const preemptMSupported = GOARCH == "386" || GOARCH == "amd64"
// suspendLock protects simultaneous SuspendThread operations from
// suspending each other.
var suspendLock mutex
func preemptM(mp *m) {
- if GOARCH == "arm" {
+ if !preemptMSupported {
// TODO: Implement call injection
return
}
package runtime
import (
+ "runtime/internal/sys"
"unsafe"
)
// overwrite the PC. (See issue #35773)
if r.ip() != 0 && r.ip() != funcPC(asyncPreempt) {
sp := unsafe.Pointer(r.sp())
- sp = add(sp, ^(unsafe.Sizeof(uintptr(0)) - 1)) // sp--
+ delta := uintptr(sys.StackAlign)
+ sp = add(sp, -delta)
r.set_sp(uintptr(sp))
- switch GOARCH {
- default:
- panic("unsupported architecture")
- case "386", "amd64":
- *((*uintptr)(sp)) = r.ip()
- case "arm":
+ if usesLR {
*((*uintptr)(sp)) = r.lr()
r.set_lr(r.ip())
+ } else {
+ *((*uintptr)(sp)) = r.ip()
}
}
r.set_ip(funcPC(sigpanic))
// registers and the stack.
panic("compileCallback: argument size is larger than uintptr")
}
- if k := t.kind & kindMask; (GOARCH == "amd64" || GOARCH == "arm") && (k == kindFloat32 || k == kindFloat64) {
+ if k := t.kind & kindMask; GOARCH != "386" && (k == kindFloat32 || k == kindFloat64) {
// In fastcall, floating-point arguments in
// the first four positions are passed in
// floating-point registers, which we don't
// currently spill. arm passes floating-point
// arguments in VFP registers, which we also
// don't support.
+ // So basically we only support 386.
panic("compileCallback: float arguments not supported")
}