runtime: make PCDATA_RegMapUnsafe more clear and remove magic number

This commit is contained in:
chainhelen 2020-09-08 01:07:01 +08:00
parent dc025c0f9b
commit 945d8aaa13
4 changed files with 6 additions and 3 deletions

View File

@ -35,7 +35,7 @@ const (
// PCDATA_RegMapIndex values.
//
// Only if !go115ReduceLiveness.
PCDATA_RegMapUnsafe = -2 // Unsafe for async preemption
PCDATA_RegMapUnsafe = PCDATA_UnsafePointUnsafe // Unsafe for async preemption
// PCDATA_UnsafePoint values.
PCDATA_UnsafePointSafe = -1 // Safe for async preemption

View File

@ -87,7 +87,7 @@ func debugCallCheck(pc uintptr) string {
pcdata = 0 // in prologue
}
stkmap := (*stackmap)(funcdata(f, _FUNCDATA_RegPointerMaps))
if pcdata == -2 || stkmap == nil {
if pcdata == _PCDATA_RegMapUnsafe || stkmap == nil {
// Not at a safe point.
ret = debugCallUnsafePoint
return

View File

@ -406,7 +406,7 @@ func isAsyncSafePoint(gp *g, pc, sp, lr uintptr) (bool, uintptr) {
var startpc uintptr
if !go115ReduceLiveness {
smi := pcdatavalue(f, _PCDATA_RegMapIndex, pc, nil)
if smi == -2 {
if smi == _PCDATA_RegMapUnsafe {
// Unsafe-point marked by compiler. This includes
// atomic sequences (e.g., write barrier) and nosplit
// functions (except at calls).

View File

@ -284,6 +284,9 @@ const (
)
const (
// Only if !go115ReduceLiveness.
_PCDATA_RegMapUnsafe = _PCDATA_UnsafePointUnsafe // Unsafe for async preemption
// PCDATA_UnsafePoint values.
_PCDATA_UnsafePointSafe = -1 // Safe for async preemption
_PCDATA_UnsafePointUnsafe = -2 // Unsafe for async preemption