aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2015-01-14 16:41:39 -0500
committerRuss Cox <rsc@golang.org>2015-01-14 22:20:44 +0000
commit6482fe6c65f105d2177b6278c97d464bc0976ca3 (patch)
treec513ae5a92ce5f7330f4ec66f407a3e2253f883f /src
parentf6d0054e718817df636a1281a2f8de04ac663ee8 (diff)
downloadgo-6482fe6c65f105d2177b6278c97d464bc0976ca3.tar.xz
runtime: delete dead code called from C.
printf, vprintf, snprintf, gc_m_ptr, gc_g_ptr, gc_itab_ptr, gc_unixnanotime. These were called from C. There is no more C. Now that vprintf is gone, delete roundup, which is unsafe (see CL 2814). Change-Id: If8a7b727d497ffa13165c0d3a1ed62abc18f008c Reviewed-on: https://go-review.googlesource.com/2824 Reviewed-by: Austin Clements <austin@google.com>
Diffstat (limited to 'src')
-rw-r--r--src/runtime/mgc.go5
-rw-r--r--src/runtime/mgc0.go20
-rw-r--r--src/runtime/print1.go118
-rw-r--r--src/runtime/stubs.go6
4 files changed, 2 insertions, 147 deletions
diff --git a/src/runtime/mgc.go b/src/runtime/mgc.go
index 3b086db9b4..9f2eb0570a 100644
--- a/src/runtime/mgc.go
+++ b/src/runtime/mgc.go
@@ -2551,7 +2551,6 @@ func getgcmask(p unsafe.Pointer, t *_type, mask **byte, len *uintptr) {
}
func unixnanotime() int64 {
- var now int64
- gc_unixnanotime(&now)
- return now
+ sec, nsec := time_now()
+ return sec*1e9 + int64(nsec)
}
diff --git a/src/runtime/mgc0.go b/src/runtime/mgc0.go
index 614055c941..d2b51cad94 100644
--- a/src/runtime/mgc0.go
+++ b/src/runtime/mgc0.go
@@ -6,26 +6,6 @@ package runtime
import "unsafe"
-// Called from C. Returns the Go type *m.
-func gc_m_ptr(ret *interface{}) {
- *ret = (*m)(nil)
-}
-
-// Called from C. Returns the Go type *g.
-func gc_g_ptr(ret *interface{}) {
- *ret = (*g)(nil)
-}
-
-// Called from C. Returns the Go type *itab.
-func gc_itab_ptr(ret *interface{}) {
- *ret = (*itab)(nil)
-}
-
-func gc_unixnanotime(now *int64) {
- sec, nsec := time_now()
- *now = sec*1e9 + int64(nsec)
-}
-
//go:linkname runtime_debug_freeOSMemory runtime/debug.freeOSMemory
func runtime_debug_freeOSMemory() {
gogc(2) // force GC and do eager sweep
diff --git a/src/runtime/print1.go b/src/runtime/print1.go
index e717c98799..ba5799182a 100644
--- a/src/runtime/print1.go
+++ b/src/runtime/print1.go
@@ -19,28 +19,6 @@ func bytes(s string) (ret []byte) {
return
}
-// printf is only called from C code. It has no type information for the args,
-// but C stacks are ignored by the garbage collector anyway, so having
-// type information would not add anything.
-//go:nosplit
-func printf(s *byte) {
- vprintf(gostringnocopy(s), add(unsafe.Pointer(&s), unsafe.Sizeof(s)))
-}
-
-// sprintf is only called from C code. It has no type information for the args,
-// but C stacks are ignored by the garbage collector anyway, so having
-// type information would not add anything.
-//go:nosplit
-func snprintf(dst *byte, n int32, s *byte) {
- buf := (*[1 << 30]byte)(unsafe.Pointer(dst))[0:n:n]
-
- gp := getg()
- gp.writebuf = buf[0:0 : n-1] // leave room for NUL, this is called from C
- vprintf(gostringnocopy(s), add(unsafe.Pointer(&s), unsafe.Sizeof(s)))
- buf[len(gp.writebuf)] = '\x00'
- gp.writebuf = nil
-}
-
var debuglock mutex
// The compiler emits calls to printlock and printunlock around
@@ -85,16 +63,6 @@ func gwrite(b []byte) {
gp.writebuf = gp.writebuf[:len(gp.writebuf)+n]
}
-func prints(s *byte) {
- b := (*[1 << 30]byte)(unsafe.Pointer(s))
- for i := 0; ; i++ {
- if b[i] == 0 {
- gwrite(b[:i])
- return
- }
- }
-}
-
func printsp() {
print(" ")
}
@@ -103,92 +71,6 @@ func printnl() {
print("\n")
}
-// Very simple printf. Only for debugging prints.
-// Do not add to this without checking with Rob.
-func vprintf(str string, arg unsafe.Pointer) {
- printlock()
-
- s := bytes(str)
- start := 0
- i := 0
- for ; i < len(s); i++ {
- if s[i] != '%' {
- continue
- }
- if i > start {
- gwrite(s[start:i])
- }
- if i++; i >= len(s) {
- break
- }
- var siz uintptr
- switch s[i] {
- case 't', 'c':
- siz = 1
- case 'd', 'x': // 32-bit
- arg = roundup(arg, 4)
- siz = 4
- case 'D', 'U', 'X', 'f': // 64-bit
- arg = roundup(arg, unsafe.Sizeof(uintreg(0)))
- siz = 8
- case 'C':
- arg = roundup(arg, unsafe.Sizeof(uintreg(0)))
- siz = 16
- case 'p', 's': // pointer-sized
- arg = roundup(arg, unsafe.Sizeof(uintptr(0)))
- siz = unsafe.Sizeof(uintptr(0))
- case 'S': // pointer-aligned but bigger
- arg = roundup(arg, unsafe.Sizeof(uintptr(0)))
- siz = unsafe.Sizeof(string(""))
- case 'a': // pointer-aligned but bigger
- arg = roundup(arg, unsafe.Sizeof(uintptr(0)))
- siz = unsafe.Sizeof([]byte{})
- case 'i', 'e': // pointer-aligned but bigger
- arg = roundup(arg, unsafe.Sizeof(uintptr(0)))
- siz = unsafe.Sizeof(interface{}(nil))
- }
- switch s[i] {
- case 'a':
- printslice(*(*[]byte)(arg))
- case 'c':
- printbyte(*(*byte)(arg))
- case 'd':
- printint(int64(*(*int32)(arg)))
- case 'D':
- printint(int64(*(*int64)(arg)))
- case 'e':
- printeface(*(*interface{})(arg))
- case 'f':
- printfloat(*(*float64)(arg))
- case 'C':
- printcomplex(*(*complex128)(arg))
- case 'i':
- printiface(*(*fInterface)(arg))
- case 'p':
- printpointer(*(*unsafe.Pointer)(arg))
- case 's':
- prints(*(**byte)(arg))
- case 'S':
- printstring(*(*string)(arg))
- case 't':
- printbool(*(*bool)(arg))
- case 'U':
- printuint(*(*uint64)(arg))
- case 'x':
- printhex(uint64(*(*uint32)(arg)))
- case 'X':
- printhex(*(*uint64)(arg))
- }
- arg = add(arg, siz)
- start = i + 1
- }
- if start < i {
- gwrite(s[start:i])
- }
-
- printunlock()
-}
-
func printpc(p unsafe.Pointer) {
print("PC=", hex(uintptr(p)))
}
diff --git a/src/runtime/stubs.go b/src/runtime/stubs.go
index 1114a09c28..d198f02e60 100644
--- a/src/runtime/stubs.go
+++ b/src/runtime/stubs.go
@@ -17,12 +17,6 @@ func add(p unsafe.Pointer, x uintptr) unsafe.Pointer {
return unsafe.Pointer(uintptr(p) + x)
}
-// n must be a power of 2
-func roundup(p unsafe.Pointer, n uintptr) unsafe.Pointer {
- delta := -uintptr(p) & (n - 1)
- return unsafe.Pointer(uintptr(p) + delta)
-}
-
func getg() *g
// mcall switches from the g to the g0 stack and invokes fn(g),