diff options
author | ian <ian@138bc75d-0d04-0410-961f-82ee72b054a4> | 2016-10-10 23:13:39 +0000 |
---|---|---|
committer | ian <ian@138bc75d-0d04-0410-961f-82ee72b054a4> | 2016-10-10 23:13:39 +0000 |
commit | 88b03a708f99ca0466096d70243f35b9b4a65ab0 (patch) | |
tree | 661f2ef36aee0c3ee5866edd2bcf540260a98506 /libgo/go | |
parent | dff001eec50889171a74412171e6f5ec1f461d4e (diff) | |
download | gcc-88b03a708f99ca0466096d70243f35b9b4a65ab0.tar.gz |
runtime: copy print/println support from Go 1.7
Update the compiler to use the new names. Add calls to printlock and
printunlock around print statements. Move expression evaluation before
the call to printlock. Update g's writebuf field to a slice, and adjust
C code accordingly.
Reviewed-on: https://go-review.googlesource.com/30717
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@240956 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgo/go')
-rw-r--r-- | libgo/go/runtime/print.go | 28 | ||||
-rw-r--r-- | libgo/go/runtime/runtime2.go | 22 | ||||
-rw-r--r-- | libgo/go/runtime/stubs.go | 3 |
3 files changed, 30 insertions, 23 deletions
diff --git a/libgo/go/runtime/print.go b/libgo/go/runtime/print.go index 97d595fb2fb..371cec50587 100644 --- a/libgo/go/runtime/print.go +++ b/libgo/go/runtime/print.go @@ -2,12 +2,32 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build ignore - package runtime import "unsafe" +// For gccgo, use go:linkname to rename compiler-called functions to +// themselves, so that the compiler will export them. +// +//go:linkname printbool runtime.printbool +//go:linkname printfloat runtime.printfloat +//go:linkname printint runtime.printint +//go:linkname printhex runtime.printhex +//go:linkname printuint runtime.printuint +//go:linkname printcomplex runtime.printcomplex +//go:linkname printstring runtime.printstring +//go:linkname printpointer runtime.printpointer +//go:linkname printiface runtime.printiface +//go:linkname printeface runtime.printeface +//go:linkname printslice runtime.printslice +//go:linkname printnl runtime.printnl +//go:linkname printsp runtime.printsp +//go:linkname printlock runtime.printlock +//go:linkname printunlock runtime.printunlock +// Temporary for C code to call: +//go:linkname gwrite runtime.gwrite +//go:linkname printhex runtime.printhex + // The compiler knows that a print of a value of this type // should use printhex instead of printuint (decimal). type hex uint64 @@ -201,10 +221,6 @@ func printpointer(p unsafe.Pointer) { } func printstring(s string) { - if uintptr(len(s)) > maxstring { - gwrite(bytes("[string too long]")) - return - } gwrite(bytes(s)) } diff --git a/libgo/go/runtime/runtime2.go b/libgo/go/runtime/runtime2.go index 688efcdcb83..25b5b79de20 100644 --- a/libgo/go/runtime/runtime2.go +++ b/libgo/go/runtime/runtime2.go @@ -347,20 +347,14 @@ type g struct { tracelastp puintptr // last P emitted an event for this goroutine lockedm *m sig uint32 - - // Temporary gccgo field. - writenbuf int32 - // Not for gccgo yet: writebuf []byte - // Temporary different type for gccgo. - writebuf *byte - - sigcode0 uintptr - sigcode1 uintptr - sigpc uintptr - gopc uintptr // pc of go statement that created this goroutine - startpc uintptr // pc of goroutine function - racectx uintptr - waiting *sudog // sudog structures this g is waiting on (that have a valid elem ptr); in lock order + writebuf []byte + sigcode0 uintptr + sigcode1 uintptr + sigpc uintptr + gopc uintptr // pc of go statement that created this goroutine + startpc uintptr // pc of goroutine function + racectx uintptr + waiting *sudog // sudog structures this g is waiting on (that have a valid elem ptr); in lock order // Not for gccgo: cgoCtxt []uintptr // cgo traceback context // Per-G GC state diff --git a/libgo/go/runtime/stubs.go b/libgo/go/runtime/stubs.go index c687cbf6220..f014610841f 100644 --- a/libgo/go/runtime/stubs.go +++ b/libgo/go/runtime/stubs.go @@ -445,6 +445,3 @@ func releaseSudog(s *sudog) { // Temporary hack for gccgo until we port the garbage collector. func typeBitsBulkBarrier(typ *_type, p, size uintptr) {} - -// Temporary for gccgo until we port print.go. -type hex uint64 |