From afba990169f41d9026c923da5235584db32cab67 Mon Sep 17 00:00:00 2001 From: Austin Clements Date: Thu, 15 Oct 2020 16:11:10 -0400 Subject: runtime/internal/atomic: drop package prefixes This drops package prefixes from the assembly code on 386 and arm. In addition to just being nicer, this allows the assembler to automatically pick up the argument stack map from the Go signatures of these functions. This doesn't matter right now because these functions never call back out to Go, but prepares us for the next CL. Change-Id: I90fed7d4dd63ad49274529c62804211b6390e2e9 Reviewed-on: https://go-review.googlesource.com/c/go/+/262777 Trust: Austin Clements Run-TryBot: Austin Clements TryBot-Result: Go Bot Reviewed-by: Cherry Zhang Reviewed-by: Michael Knyszek --- src/runtime/funcdata.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/runtime/funcdata.h') diff --git a/src/runtime/funcdata.h b/src/runtime/funcdata.h index 0fb50ddfba..cd76c06992 100644 --- a/src/runtime/funcdata.h +++ b/src/runtime/funcdata.h @@ -32,9 +32,9 @@ // defines the pointer map for the function's arguments. // GO_ARGS should be the first instruction in a function that uses it. // It can be omitted if there are no arguments at all. -// GO_ARGS is inserted implicitly by the linker for any function -// that also has a Go prototype and therefore is usually not necessary -// to write explicitly. +// GO_ARGS is inserted implicitly by the linker for any function whose +// name starts with a middle-dot and that also has a Go prototype; it +// is therefore usually not necessary to write explicitly. #define GO_ARGS FUNCDATA $FUNCDATA_ArgsPointerMaps, go_args_stackmap(SB) // GO_RESULTS_INITIALIZED indicates that the assembly function -- cgit v1.3 From 8414b1a5a40e5ef19508e4895b4c12a91fa498e7 Mon Sep 17 00:00:00 2001 From: Cherry Zhang Date: Wed, 21 Oct 2020 20:43:16 -0400 Subject: 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 Reviewed-by: Austin Clements --- src/runtime/debugcall.go | 34 +++++++---------------------- src/runtime/funcdata.h | 3 +-- src/runtime/preempt.go | 57 ++++++++++++++---------------------------------- src/runtime/symtab.go | 7 +----- 4 files changed, 26 insertions(+), 75 deletions(-) (limited to 'src/runtime/funcdata.h') diff --git a/src/runtime/debugcall.go b/src/runtime/debugcall.go index b5480c73ae..efc68a767d 100644 --- a/src/runtime/debugcall.go +++ b/src/runtime/debugcall.go @@ -76,32 +76,14 @@ func debugCallCheck(pc uintptr) string { return } - if !go115ReduceLiveness { - // Look up PC's register map. - pcdata := int32(-1) - if pc != f.entry { - pc-- - pcdata = pcdatavalue(f, _PCDATA_RegMapIndex, pc, nil) - } - if pcdata == -1 { - 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 - } + // 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 diff --git a/src/runtime/funcdata.h b/src/runtime/funcdata.h index cd76c06992..e9b6a7ed06 100644 --- a/src/runtime/funcdata.h +++ b/src/runtime/funcdata.h @@ -8,13 +8,12 @@ // // 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_InlTreeIndex 2 #define FUNCDATA_ArgsPointerMaps 0 /* garbage collector blocks */ #define FUNCDATA_LocalsPointerMaps 1 -#define FUNCDATA_RegPointerMaps 2 #define FUNCDATA_StackObjects 3 #define FUNCDATA_InlTree 4 #define FUNCDATA_OpenCodedDeferInfo 5 /* info for func with open-coded defers */ diff --git a/src/runtime/preempt.go b/src/runtime/preempt.go index 17ef2c90d3..372185266f 100644 --- a/src/runtime/preempt.go +++ b/src/runtime/preempt.go @@ -58,11 +58,6 @@ import ( "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 { 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. return false, 0 } - var up int32 - var startpc uintptr - if !go115ReduceLiveness { - smi := pcdatavalue(f, _PCDATA_RegMapIndex, pc, nil) - if smi == _PCDATA_RegMapUnsafe { - // Unsafe-point marked by compiler. This includes - // 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 - } + 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) { // 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. return false, 0 } - if go115RestartSeq { - switch up { - case _PCDATA_Restart1, _PCDATA_Restart2: - // Restartable instruction sequence. Back off PC to - // the start PC. - if startpc == 0 || startpc > pc || pc-startpc > 20 { - 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 + switch up { + case _PCDATA_Restart1, _PCDATA_Restart2: + // Restartable instruction sequence. Back off PC to + // the start PC. + if startpc == 0 || startpc > pc || pc-startpc > 20 { + throw("bad restart PC") } + return true, startpc + case _PCDATA_RestartAtEntry: + // Restart from the function entry at resumption. + return true, f.entry } return true, pc } diff --git a/src/runtime/symtab.go b/src/runtime/symtab.go index 932fba3de0..a4b4344ea7 100644 --- a/src/runtime/symtab.go +++ b/src/runtime/symtab.go @@ -268,14 +268,12 @@ func (f *Func) funcInfo() funcInfo { // // See funcdata.h and ../cmd/internal/objabi/funcdata.go. const ( - _PCDATA_RegMapIndex = 0 // if !go115ReduceLiveness - _PCDATA_UnsafePoint = 0 // if go115ReduceLiveness + _PCDATA_UnsafePoint = 0 _PCDATA_StackMapIndex = 1 _PCDATA_InlTreeIndex = 2 _FUNCDATA_ArgsPointerMaps = 0 _FUNCDATA_LocalsPointerMaps = 1 - _FUNCDATA_RegPointerMaps = 2 // if !go115ReduceLiveness _FUNCDATA_StackObjects = 3 _FUNCDATA_InlTree = 4 _FUNCDATA_OpenCodedDeferInfo = 5 @@ -284,9 +282,6 @@ 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 -- cgit v1.3 From f96b62be2edd8acc08b79777d692937e8ed79b4a Mon Sep 17 00:00:00 2001 From: Cherry Zhang Date: Tue, 27 Oct 2020 19:47:29 -0400 Subject: cmd/internal/objabi, runtime: compact FUNCDATA indices As we deleted register maps, move FUNCDATA indices of stack objects, inline trees, and open-coded defers earlier. Change-Id: If73797b8c11fd207655c9498802fca9f6f9ac338 Reviewed-on: https://go-review.googlesource.com/c/go/+/265761 Trust: Cherry Zhang Reviewed-by: Austin Clements --- src/cmd/internal/objabi/funcdata.go | 6 +++--- src/runtime/funcdata.h | 6 +++--- src/runtime/symtab.go | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) (limited to 'src/runtime/funcdata.h') diff --git a/src/cmd/internal/objabi/funcdata.go b/src/cmd/internal/objabi/funcdata.go index 1c5e5e1c8c..faa2863325 100644 --- a/src/cmd/internal/objabi/funcdata.go +++ b/src/cmd/internal/objabi/funcdata.go @@ -17,9 +17,9 @@ const ( FUNCDATA_ArgsPointerMaps = 0 FUNCDATA_LocalsPointerMaps = 1 - FUNCDATA_StackObjects = 3 - FUNCDATA_InlTree = 4 - FUNCDATA_OpenCodedDeferInfo = 5 + FUNCDATA_StackObjects = 2 + FUNCDATA_InlTree = 3 + FUNCDATA_OpenCodedDeferInfo = 4 // ArgsSizeUnknown is set in Func.argsize to mark all functions // whose argument size is unknown (C vararg functions, and diff --git a/src/runtime/funcdata.h b/src/runtime/funcdata.h index e9b6a7ed06..798dbaceab 100644 --- a/src/runtime/funcdata.h +++ b/src/runtime/funcdata.h @@ -14,9 +14,9 @@ #define FUNCDATA_ArgsPointerMaps 0 /* garbage collector blocks */ #define FUNCDATA_LocalsPointerMaps 1 -#define FUNCDATA_StackObjects 3 -#define FUNCDATA_InlTree 4 -#define FUNCDATA_OpenCodedDeferInfo 5 /* info for func with open-coded defers */ +#define FUNCDATA_StackObjects 2 +#define FUNCDATA_InlTree 3 +#define FUNCDATA_OpenCodedDeferInfo 4 /* info for func with open-coded defers */ // Pseudo-assembly statements. diff --git a/src/runtime/symtab.go b/src/runtime/symtab.go index a4b4344ea7..7667f23f1d 100644 --- a/src/runtime/symtab.go +++ b/src/runtime/symtab.go @@ -274,9 +274,9 @@ const ( _FUNCDATA_ArgsPointerMaps = 0 _FUNCDATA_LocalsPointerMaps = 1 - _FUNCDATA_StackObjects = 3 - _FUNCDATA_InlTree = 4 - _FUNCDATA_OpenCodedDeferInfo = 5 + _FUNCDATA_StackObjects = 2 + _FUNCDATA_InlTree = 3 + _FUNCDATA_OpenCodedDeferInfo = 4 _ArgsSizeUnknown = -0x80000000 ) -- cgit v1.3