mirror of
https://github.com/golang/go
synced 2024-11-23 18:30:06 -07:00
runtime: tweak js and plan9 to avoid/disable write barrier & gc problems
runtime code for js contains possible write barriers that fail the nowritebarrierrec check when internal local package naming conventions are changed. The problem was there all already; this allows the code to compile, and it seems to work anyway in the (single-threaded) js/wasm environment. The offending operations are noted with TODO, which is an improvement. runtime code for plan9 contained an apparent allocation that was not really an allocation; rewrite to remove the potential allocation to avoid nowritebarrierrec problems. This CL is a prerequisite for a pending code cleanup, https://go-review.googlesource.com/c/go/+/393715 Updates #51734. Change-Id: I93f31831ff9b92632137dd7b0055eaa721c81556 Reviewed-on: https://go-review.googlesource.com/c/go/+/405901 Run-TryBot: David Chase <drchase@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
parent
540f8c2b50
commit
364ced6255
@ -144,8 +144,12 @@ func notetsleepg(n *note, ns int64) bool {
|
||||
}
|
||||
|
||||
// checkTimeouts resumes goroutines that are waiting on a note which has reached its deadline.
|
||||
// TODO(drchase): need to understand if write barriers are really okay in this context.
|
||||
//
|
||||
//go:yeswritebarrierrec
|
||||
func checkTimeouts() {
|
||||
now := nanotime()
|
||||
// TODO: map iteration has the write barriers in it; is that okay?
|
||||
for n, nt := range notesWithTimeout {
|
||||
if n.key == note_cleared && now >= nt.deadline {
|
||||
n.key = note_timeout
|
||||
@ -175,6 +179,9 @@ var idleID int32
|
||||
// If an event handler returned, we resume it and it will pause the execution.
|
||||
// beforeIdle either returns the specific goroutine to schedule next or
|
||||
// indicates with otherReady that some goroutine became ready.
|
||||
// TODO(drchase): need to understand if write barriers are really okay in this context.
|
||||
//
|
||||
//go:yeswritebarrierrec
|
||||
func beforeIdle(now, pollUntil int64) (gp *g, otherReady bool) {
|
||||
delay := int64(-1)
|
||||
if pollUntil != 0 {
|
||||
@ -196,6 +203,7 @@ func beforeIdle(now, pollUntil int64) (gp *g, otherReady bool) {
|
||||
}
|
||||
|
||||
if len(events) == 0 {
|
||||
// TODO: this is the line that requires the yeswritebarrierrec
|
||||
go handleAsyncEvent()
|
||||
return nil, true
|
||||
}
|
||||
|
@ -129,7 +129,7 @@ func initsig(preinit bool) {
|
||||
//
|
||||
//go:nowritebarrier
|
||||
func newosproc(mp *m) {
|
||||
panic("newosproc: not implemented")
|
||||
throw("newosproc: not implemented")
|
||||
}
|
||||
|
||||
func setProcessCPUProfiler(hz int32) {}
|
||||
|
@ -437,7 +437,9 @@ func exit(e int32) {
|
||||
} else {
|
||||
// build error string
|
||||
var tmp [32]byte
|
||||
status = append(itoa(tmp[:len(tmp)-1], uint64(e)), 0)
|
||||
sl := itoa(tmp[:len(tmp)-1], uint64(e))
|
||||
// Don't append, rely on the existing data being zero.
|
||||
status = tmp[:len(sl)+1]
|
||||
}
|
||||
goexitsall(&status[0])
|
||||
exits(&status[0])
|
||||
|
Loading…
Reference in New Issue
Block a user