1
0
mirror of https://github.com/golang/go synced 2024-11-16 19:24:49 -07:00

runtime: remove go115ReduceLiveness and go115RestartSeq

Make them always true. Delete code that are only executed when
they are false.

Change-Id: I6194fa00de23486c2b0a0c9075fe3a09d9c52762
Reviewed-on: https://go-review.googlesource.com/c/go/+/264339
Trust: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Austin Clements <austin@google.com>
This commit is contained in:
Cherry Zhang 2020-10-21 20:43:16 -04:00
parent 420c68dd68
commit 8414b1a5a4
4 changed files with 26 additions and 75 deletions

View File

@ -76,32 +76,14 @@ func debugCallCheck(pc uintptr) string {
return return
} }
if !go115ReduceLiveness { // Check that this isn't an unsafe-point.
// Look up PC's register map. if pc != f.entry {
pcdata := int32(-1) pc--
if pc != f.entry { }
pc-- up := pcdatavalue(f, _PCDATA_UnsafePoint, pc, nil)
pcdata = pcdatavalue(f, _PCDATA_RegMapIndex, pc, nil) if up != _PCDATA_UnsafePointSafe {
} // Not at a safe point.
if pcdata == -1 { ret = debugCallUnsafePoint
pcdata = 0 // in prologue
}
stkmap := (*stackmap)(funcdata(f, _FUNCDATA_RegPointerMaps))
if pcdata == _PCDATA_RegMapUnsafe || stkmap == nil {
// Not at a safe point.
ret = debugCallUnsafePoint
return
}
} else {
// Check that this isn't an unsafe-point.
if pc != f.entry {
pc--
}
up := pcdatavalue(f, _PCDATA_UnsafePoint, pc, nil)
if up != _PCDATA_UnsafePointSafe {
// Not at a safe point.
ret = debugCallUnsafePoint
}
} }
}) })
return ret return ret

View File

@ -8,13 +8,12 @@
// //
// These must agree with symtab.go and ../cmd/internal/objabi/funcdata.go. // These must agree with symtab.go and ../cmd/internal/objabi/funcdata.go.
#define PCDATA_RegMapIndex 0 #define PCDATA_UnsafePoint 0
#define PCDATA_StackMapIndex 1 #define PCDATA_StackMapIndex 1
#define PCDATA_InlTreeIndex 2 #define PCDATA_InlTreeIndex 2
#define FUNCDATA_ArgsPointerMaps 0 /* garbage collector blocks */ #define FUNCDATA_ArgsPointerMaps 0 /* garbage collector blocks */
#define FUNCDATA_LocalsPointerMaps 1 #define FUNCDATA_LocalsPointerMaps 1
#define FUNCDATA_RegPointerMaps 2
#define FUNCDATA_StackObjects 3 #define FUNCDATA_StackObjects 3
#define FUNCDATA_InlTree 4 #define FUNCDATA_InlTree 4
#define FUNCDATA_OpenCodedDeferInfo 5 /* info for func with open-coded defers */ #define FUNCDATA_OpenCodedDeferInfo 5 /* info for func with open-coded defers */

View File

@ -58,11 +58,6 @@ import (
"unsafe" "unsafe"
) )
// Keep in sync with cmd/compile/internal/gc/plive.go:go115ReduceLiveness.
const go115ReduceLiveness = true
const go115RestartSeq = go115ReduceLiveness && true // enable restartable sequences
type suspendGState struct { type suspendGState struct {
g *g g *g
@ -402,24 +397,12 @@ func isAsyncSafePoint(gp *g, pc, sp, lr uintptr) (bool, uintptr) {
// use the LR for unwinding, which will be bad. // use the LR for unwinding, which will be bad.
return false, 0 return false, 0
} }
var up int32 up, startpc := pcdatavalue2(f, _PCDATA_UnsafePoint, pc)
var startpc uintptr if up != _PCDATA_UnsafePointSafe {
if !go115ReduceLiveness { // Unsafe-point marked by compiler. This includes
smi := pcdatavalue(f, _PCDATA_RegMapIndex, pc, nil) // atomic sequences (e.g., write barrier) and nosplit
if smi == _PCDATA_RegMapUnsafe { // functions (except at calls).
// Unsafe-point marked by compiler. This includes return false, 0
// atomic sequences (e.g., write barrier) and nosplit
// functions (except at calls).
return false, 0
}
} else {
up, startpc = pcdatavalue2(f, _PCDATA_UnsafePoint, pc)
if up != _PCDATA_UnsafePointSafe {
// Unsafe-point marked by compiler. This includes
// atomic sequences (e.g., write barrier) and nosplit
// functions (except at calls).
return false, 0
}
} }
if fd := funcdata(f, _FUNCDATA_LocalsPointerMaps); fd == nil || fd == unsafe.Pointer(&no_pointers_stackmap) { if fd := funcdata(f, _FUNCDATA_LocalsPointerMaps); fd == nil || fd == unsafe.Pointer(&no_pointers_stackmap) {
// This is assembly code. Don't assume it's // This is assembly code. Don't assume it's
@ -455,25 +438,17 @@ func isAsyncSafePoint(gp *g, pc, sp, lr uintptr) (bool, uintptr) {
// in incrementally. // in incrementally.
return false, 0 return false, 0
} }
if go115RestartSeq { switch up {
switch up { case _PCDATA_Restart1, _PCDATA_Restart2:
case _PCDATA_Restart1, _PCDATA_Restart2: // Restartable instruction sequence. Back off PC to
// Restartable instruction sequence. Back off PC to // the start PC.
// the start PC. if startpc == 0 || startpc > pc || pc-startpc > 20 {
if startpc == 0 || startpc > pc || pc-startpc > 20 { throw("bad restart PC")
throw("bad restart PC")
}
return true, startpc
case _PCDATA_RestartAtEntry:
// Restart from the function entry at resumption.
return true, f.entry
}
} else {
switch up {
case _PCDATA_Restart1, _PCDATA_Restart2, _PCDATA_RestartAtEntry:
// go115RestartSeq is not enabled. Treat it as unsafe point.
return false, 0
} }
return true, startpc
case _PCDATA_RestartAtEntry:
// Restart from the function entry at resumption.
return true, f.entry
} }
return true, pc return true, pc
} }

View File

@ -268,14 +268,12 @@ func (f *Func) funcInfo() funcInfo {
// //
// See funcdata.h and ../cmd/internal/objabi/funcdata.go. // See funcdata.h and ../cmd/internal/objabi/funcdata.go.
const ( const (
_PCDATA_RegMapIndex = 0 // if !go115ReduceLiveness _PCDATA_UnsafePoint = 0
_PCDATA_UnsafePoint = 0 // if go115ReduceLiveness
_PCDATA_StackMapIndex = 1 _PCDATA_StackMapIndex = 1
_PCDATA_InlTreeIndex = 2 _PCDATA_InlTreeIndex = 2
_FUNCDATA_ArgsPointerMaps = 0 _FUNCDATA_ArgsPointerMaps = 0
_FUNCDATA_LocalsPointerMaps = 1 _FUNCDATA_LocalsPointerMaps = 1
_FUNCDATA_RegPointerMaps = 2 // if !go115ReduceLiveness
_FUNCDATA_StackObjects = 3 _FUNCDATA_StackObjects = 3
_FUNCDATA_InlTree = 4 _FUNCDATA_InlTree = 4
_FUNCDATA_OpenCodedDeferInfo = 5 _FUNCDATA_OpenCodedDeferInfo = 5
@ -284,9 +282,6 @@ const (
) )
const ( const (
// Only if !go115ReduceLiveness.
_PCDATA_RegMapUnsafe = _PCDATA_UnsafePointUnsafe // Unsafe for async preemption
// PCDATA_UnsafePoint values. // PCDATA_UnsafePoint values.
_PCDATA_UnsafePointSafe = -1 // Safe for async preemption _PCDATA_UnsafePointSafe = -1 // Safe for async preemption
_PCDATA_UnsafePointUnsafe = -2 // Unsafe for async preemption _PCDATA_UnsafePointUnsafe = -2 // Unsafe for async preemption