diff options
author | Ian Lance Taylor <iant@google.com> | 2013-06-18 23:49:49 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2013-06-18 23:49:49 +0000 |
commit | fdbc38a6e8d7c920eea6c6231c7fe2c987fa8aa2 (patch) | |
tree | 1a7d38cd8be5484451189338ed6f4b76d8521f31 /libgo/go/runtime | |
parent | 25e00ab67444a01dce446e95308521d1a73f8232 (diff) | |
download | gcc-fdbc38a6e8d7c920eea6c6231c7fe2c987fa8aa2.zip gcc-fdbc38a6e8d7c920eea6c6231c7fe2c987fa8aa2.tar.gz gcc-fdbc38a6e8d7c920eea6c6231c7fe2c987fa8aa2.tar.bz2 |
compiler, runtime: Use function descriptors.
This changes the representation of a Go value of function type
from being a pointer to function code (like a C function
pointer) to being a pointer to a struct. The first field of
the struct points to the function code. The remaining fields,
if any, are the addresses of variables referenced in enclosing
functions. For each call to a function, the address of the
function descriptor is passed as the last argument.
This lets us avoid generating trampolines, and removes the use
of writable/executable sections of the heap.
From-SVN: r200181
Diffstat (limited to 'libgo/go/runtime')
-rw-r--r-- | libgo/go/runtime/extern.go | 3 | ||||
-rw-r--r-- | libgo/go/runtime/parfor_test.go | 9 |
2 files changed, 9 insertions, 3 deletions
diff --git a/libgo/go/runtime/extern.go b/libgo/go/runtime/extern.go index 2a90113..6e91ef5 100644 --- a/libgo/go/runtime/extern.go +++ b/libgo/go/runtime/extern.go @@ -59,9 +59,6 @@ func (f *Func) FileLine(pc uintptr) (file string, line int) { // implemented in symtab.c func funcline_go(*Func, uintptr) (string, int) -// mid returns the current OS thread (m) id. -func mid() uint32 - // SetFinalizer sets the finalizer associated with x to f. // When the garbage collector finds an unreachable block // with an associated finalizer, it clears the association and runs diff --git a/libgo/go/runtime/parfor_test.go b/libgo/go/runtime/parfor_test.go index b382b76..4c69a68 100644 --- a/libgo/go/runtime/parfor_test.go +++ b/libgo/go/runtime/parfor_test.go @@ -13,6 +13,8 @@ import ( "unsafe" ) +var gdata []uint64 + // Simple serial sanity test for parallelfor. func TestParFor(t *testing.T) { const P = 1 @@ -22,7 +24,12 @@ func TestParFor(t *testing.T) { data[i] = i } desc := NewParFor(P) + // Avoid making func a closure: parfor cannot invoke them. + // Since it doesn't happen in the C code, it's not worth doing + // just for the test. + gdata = data ParForSetup(desc, P, N, nil, true, func(desc *ParFor, i uint32) { + data := gdata data[i] = data[i]*data[i] + 1 }) ParForDo(desc) @@ -111,7 +118,9 @@ func TestParForParallel(t *testing.T) { P := GOMAXPROCS(-1) c := make(chan bool, P) desc := NewParFor(uint32(P)) + gdata = data ParForSetup(desc, uint32(P), uint32(N), nil, false, func(desc *ParFor, i uint32) { + data := gdata data[i] = data[i]*data[i] + 1 }) for p := 1; p < P; p++ { |