]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: make PCDATA_RegMapUnsafe more clear and remove magic number
authorchainhelen <chainhelen@gmail.com>
Tue, 8 Sep 2020 03:36:19 +0000 (03:36 +0000)
committerAustin Clements <austin@google.com>
Tue, 8 Sep 2020 15:07:20 +0000 (15:07 +0000)
Change-Id: Ibf3ee755c3fbec03a9396840dc92ce148c49d9f7
GitHub-Last-Rev: 945d8aaa136003dc381c6aa48bff9ea7ca2c6991
GitHub-Pull-Request: golang/go#41262
Reviewed-on: https://go-review.googlesource.com/c/go/+/253377
Reviewed-by: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/cmd/internal/objabi/funcdata.go
src/runtime/debugcall.go
src/runtime/preempt.go
src/runtime/symtab.go

index d5bacb5900bf8937940f11d7596af5a40ef0f2e3..c9480bf2f010790dfef754ec47da143de64563db 100644 (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
index 6c285ec829a30545d35a75bad359e375abb76013..b5480c73aee7d609a2f58583a985457ab2eededb 100644 (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
index 761856576a9c9300ef2a1b5459c1ba54f522f026..17ef2c90d356430f104a6428b368675eed2676fd 100644 (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).
index ddb5ea82b4640389c3acca913f90846ccfef8fe5..fa8d17035e19eb5c6dff629b7c130d5a42a1c410 100644 (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