]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: introduce CPU access functions on windows
authorAlex Brainman <alex.brainman@gmail.com>
Wed, 14 Jan 2015 01:25:55 +0000 (12:25 +1100)
committerAlex Brainman <alex.brainman@gmail.com>
Tue, 10 Feb 2015 01:46:30 +0000 (01:46 +0000)
This CL introduces new methods for 'context' type, so we can
manipulate its values in an architecture independent way.

Use new methods to replace both 386 and amd64 versions of
dosigprof with single piece of code.

There is more similar code to be converted in the following CLs.

Also remove os_windows_386.go and os_windows_amd64.go. These
contain unused functions.

Change-Id: I28f76aeb97f6e4249843d30d3d0c33fb233d3f7f
Reviewed-on: https://go-review.googlesource.com/2790
Reviewed-by: Minux Ma <minux@golang.org>
src/runtime/defs_windows_386.go
src/runtime/defs_windows_amd64.go
src/runtime/os1_windows.go
src/runtime/os1_windows_386.go
src/runtime/os1_windows_amd64.go
src/runtime/os_windows_386.go [deleted file]
src/runtime/os_windows_amd64.go [deleted file]

index abec2d839fd90f5a5df8140dab7d71b696011507..c860f74a3f96ca16f6bcea5546175048b5a3498b 100644 (file)
@@ -101,6 +101,12 @@ type context struct {
        extendedregisters [512]uint8
 }
 
+func (c *context) ip() uintptr { return uintptr(c.eip) }
+func (c *context) sp() uintptr { return uintptr(c.esp) }
+
+func (c *context) setip(x uintptr) { c.eip = uint32(x) }
+func (c *context) setsp(x uintptr) { c.esp = uint32(x) }
+
 type overlapped struct {
        internal     uint32
        internalhigh uint32
index 81b13597b7531c2dd17f32315579ffbf3a3d052e..d1e55ec426ca90a5268ee26bf98f65bdf5263c43 100644 (file)
@@ -116,6 +116,12 @@ type context struct {
        lastexceptionfromrip uint64
 }
 
+func (c *context) ip() uintptr { return uintptr(c.rip) }
+func (c *context) sp() uintptr { return uintptr(c.rsp) }
+
+func (c *context) setip(x uintptr) { c.rip = uint64(x) }
+func (c *context) setsp(x uintptr) { c.rsp = uint64(x) }
+
 type overlapped struct {
        internal     uint64
        internalhigh uint64
index 8655c083b25c0e5f92821ee864ac3ecc37e5f89a..5be916ccf3b7c8f2c41abe4bc207f8b00d09f2be 100644 (file)
@@ -506,7 +506,7 @@ func profilem(mp *m) {
        r = (*context)(unsafe.Pointer((uintptr(unsafe.Pointer(&rbuf[15]))) &^ 15))
        r.contextflags = _CONTEXT_CONTROL
        stdcall2(_GetThreadContext, mp.thread, uintptr(unsafe.Pointer(r)))
-       dosigprof(r, gp, mp)
+       sigprof((*byte)(unsafe.Pointer(r.ip())), (*byte)(unsafe.Pointer(r.sp())), nil, gp, mp)
 }
 
 func profileloop1() {
index 7b4fdfe94a70003d776f65683960ebc4fef23d52..b7eae204d1ce7d9a0dda950207be5d1717dcd04c 100644 (file)
@@ -118,7 +118,3 @@ func sigenable(sig uint32) {
 
 func sigdisable(sig uint32) {
 }
-
-func dosigprof(r *context, gp *g, mp *m) {
-       sigprof((*byte)(unsafe.Pointer(uintptr(r.eip))), (*byte)(unsafe.Pointer(uintptr(r.esp))), nil, gp, mp)
-}
index c211f6fd919e92b496c859efa287e41d82ba6b81..4163fcf23d59fd991e584588f5d2fd354157a4b9 100644 (file)
@@ -137,7 +137,3 @@ func sigenable(sig uint32) {
 
 func sigdisable(sig uint32) {
 }
-
-func dosigprof(r *context, gp *g, mp *m) {
-       sigprof((*byte)(unsafe.Pointer(uintptr(r.rip))), (*byte)(unsafe.Pointer(uintptr(r.rsp))), nil, gp, mp)
-}
diff --git a/src/runtime/os_windows_386.go b/src/runtime/os_windows_386.go
deleted file mode 100644 (file)
index 86a1906..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-// Copyright 2014 The Go Authors.  All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package runtime
-
-// contextPC returns the EIP (program counter) register from the context.
-func contextPC(r *context) uintptr { return uintptr(r.eip) }
-
-// contextSP returns the ESP (stack pointer) register from the context.
-func contextSP(r *context) uintptr { return uintptr(r.esp) }
diff --git a/src/runtime/os_windows_amd64.go b/src/runtime/os_windows_amd64.go
deleted file mode 100644 (file)
index 3f4d4d0..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-// Copyright 2014 The Go Authors.  All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package runtime
-
-// contextPC returns the RIP (program counter) register from the context.
-func contextPC(r *context) uintptr { return uintptr(r.rip) }
-
-// contextSP returns the RSP (stack pointer) register from the context.
-func contextSP(r *context) uintptr { return uintptr(r.rsp) }