aboutsummaryrefslogtreecommitdiff
path: root/src/runtime
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2015-04-15 15:00:42 -0400
committerRuss Cox <rsc@golang.org>2015-04-17 01:30:47 +0000
commit6a2b0c0b6d527d45860ec6c0d860b6aebfedea2e (patch)
treeb8156632f788ae13f5b7591a61092a59cdc7ea55 /src/runtime
parent89b7c66d0d14462fd7893be4290bdfe5f9063ae1 (diff)
downloadgo-6a2b0c0b6d527d45860ec6c0d860b6aebfedea2e.tar.xz
runtime: delete cgo_allocate
This memory is untyped and can't be used anymore. The next version of SWIG won't need it. Change-Id: I592b287c5f5186975ee09a9b28d8efe3b57134e7 Reviewed-on: https://go-review.googlesource.com/8956 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/runtime')
-rw-r--r--src/runtime/cgo/callbacks.go26
-rw-r--r--src/runtime/cgocall.go6
-rw-r--r--src/runtime/cgocallback.go27
-rw-r--r--src/runtime/mgc.go9
-rw-r--r--src/runtime/runtime2.go8
5 files changed, 0 insertions, 76 deletions
diff --git a/src/runtime/cgo/callbacks.go b/src/runtime/cgo/callbacks.go
index cbaf064bd8..1682341596 100644
--- a/src/runtime/cgo/callbacks.go
+++ b/src/runtime/cgo/callbacks.go
@@ -22,32 +22,6 @@ func _runtime_cgocallback(unsafe.Pointer, unsafe.Pointer, uintptr)
//go:cgo_export_static crosscall2
//go:cgo_export_dynamic crosscall2
-// Allocate memory. This allocates the requested number of bytes in
-// memory controlled by the Go runtime. The allocated memory will be
-// zeroed. You are responsible for ensuring that the Go garbage
-// collector can see a pointer to the allocated memory for as long as
-// it is valid, e.g., by storing a pointer in a local variable in your
-// C function, or in memory allocated by the Go runtime. If the only
-// pointers are in a C global variable or in memory allocated via
-// malloc, then the Go garbage collector may collect the memory.
-
-// Call like this in code compiled with gcc:
-// struct { size_t len; void *ret; } a;
-// a.len = /* number of bytes to allocate */;
-// crosscall2(_cgo_allocate, &a, sizeof a);
-// /* Here a.ret is a pointer to the allocated memory. */
-
-//go:linkname _runtime_cgo_allocate_internal runtime._cgo_allocate_internal
-var _runtime_cgo_allocate_internal byte
-
-//go:linkname _cgo_allocate _cgo_allocate
-//go:cgo_export_static _cgo_allocate
-//go:cgo_export_dynamic _cgo_allocate
-//go:nosplit
-func _cgo_allocate(a unsafe.Pointer, n int32) {
- _runtime_cgocallback(unsafe.Pointer(&_runtime_cgo_allocate_internal), a, uintptr(n))
-}
-
// Panic. The argument is converted into a Go string.
// Call like this in code compiled with gcc:
diff --git a/src/runtime/cgocall.go b/src/runtime/cgocall.go
index d4d0cf47c3..c01d616ca7 100644
--- a/src/runtime/cgocall.go
+++ b/src/runtime/cgocall.go
@@ -132,12 +132,6 @@ func cgocall_errno(fn, arg unsafe.Pointer) int32 {
//go:nosplit
func endcgo(mp *m) {
mp.ncgo--
- if mp.ncgo == 0 {
- // We are going back to Go and are not in a recursive
- // call. Let the GC collect any memory allocated via
- // _cgo_allocate that is no longer referenced.
- mp.cgomal = nil
- }
if raceenabled {
raceacquire(unsafe.Pointer(&racecgosync))
diff --git a/src/runtime/cgocallback.go b/src/runtime/cgocallback.go
index 20ce87d4ca..f93acaba03 100644
--- a/src/runtime/cgocallback.go
+++ b/src/runtime/cgocallback.go
@@ -4,35 +4,8 @@
package runtime
-import "unsafe"
-
// These functions are called from C code via cgo/callbacks.go.
-// Allocate memory. This allocates the requested number of bytes in
-// memory controlled by the Go runtime. The allocated memory will be
-// zeroed. You are responsible for ensuring that the Go garbage
-// collector can see a pointer to the allocated memory for as long as
-// it is valid, e.g., by storing a pointer in a local variable in your
-// C function, or in memory allocated by the Go runtime. If the only
-// pointers are in a C global variable or in memory allocated via
-// malloc, then the Go garbage collector may collect the memory.
-//
-// TODO(rsc,iant): This memory is untyped.
-// Either we need to add types or we need to stop using it.
-
-func _cgo_allocate_internal(len uintptr) unsafe.Pointer {
- if len == 0 {
- len = 1
- }
- ret := unsafe.Pointer(&make([]unsafe.Pointer, (len+ptrSize-1)/ptrSize)[0])
- c := new(cgomal)
- c.alloc = ret
- gp := getg()
- c.next = gp.m.cgomal
- gp.m.cgomal = c
- return ret
-}
-
// Panic.
func _cgo_panic_internal(p *byte) {
diff --git a/src/runtime/mgc.go b/src/runtime/mgc.go
index bf916f841d..126b95a475 100644
--- a/src/runtime/mgc.go
+++ b/src/runtime/mgc.go
@@ -127,15 +127,6 @@ const (
_RootCount = 5
)
-//go:linkname weak_cgo_allocate go.weak.runtime._cgo_allocate_internal
-var weak_cgo_allocate byte
-
-// Is _cgo_allocate linked into the binary?
-//go:nowritebarrier
-func have_cgo_allocate() bool {
- return &weak_cgo_allocate != nil
-}
-
// heapminimum is the minimum number of bytes in the heap.
// This cleans up the corner case of where we have a very small live set but a lot
// of allocations and collecting every GOGC * live set is expensive.
diff --git a/src/runtime/runtime2.go b/src/runtime/runtime2.go
index cdbaebcc09..609c7cf6f6 100644
--- a/src/runtime/runtime2.go
+++ b/src/runtime/runtime2.go
@@ -283,7 +283,6 @@ type m struct {
fastrand uint32
ncgocall uint64 // number of cgo calls in total
ncgo int32 // number of cgo calls currently in progress
- cgomal *cgomal
park note
alllink *m // on allm
schedlink *m
@@ -485,13 +484,6 @@ type lfnode struct {
pushcnt uintptr
}
-// Track memory allocated by code not written in Go during a cgo call,
-// so that the garbage collector can see them.
-type cgomal struct {
- next *cgomal
- alloc unsafe.Pointer
-}
-
// Indicates to write barrier and sychronization task to preform.
const (
_GCoff = iota // GC not running, write barrier disabled