]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: untangle Wrapper and ABIWrapper flags
authorCherry Zhang <cherryyz@google.com>
Sun, 4 Apr 2021 16:46:21 +0000 (12:46 -0400)
committerCherry Zhang <cherryyz@google.com>
Mon, 5 Apr 2021 17:27:18 +0000 (17:27 +0000)
Currently, there are Wrapper and ABIWrapper attributes. Wrapper
is set when compiler generates an wrapper function (e.g. method
wrapper). ABIWrapper is set when compiler generates an ABI
wrapper. It also sets Wrapper flag for ABI wrappers.

Currently, they have the following meanings:
- Wrapper flag hides the frame from (normal) traceback.
- Wrapper flag enables special panic+recover adjustment, so it
  can correctly recover when a wrapper function is deferred.
- ABIWrapper flag disables the panic+recover adjustment, because
  we never defer an ABI wrapper that can recover.

This CL changes them to:
- Both Wrapper and ABIWrapper flags hide the frame from (normal)
  traceback. (Setting one is enough.)
- Wrapper flag enables special panic+recover adjustment.
  ABIWrapper flag no longer has effect on this.

This makes it clearer if we do want an ABI wrapper that also does
the panic+recover adjustment. In the old mechanism we'd have to
unset ABIWrapper flag, even if the function is actually an ABI
wrapper. In the new mechanism we just need to set both ABIWrapper
and Wrapper flags.

Updates #40724.

Change-Id: I7fbc83f85d23676dc94db51dfda63dcacdf1fc19
Reviewed-on: https://go-review.googlesource.com/c/go/+/307235
Trust: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Austin Clements <austin@google.com>
src/cmd/compile/internal/ssagen/abi.go
src/cmd/internal/obj/plist.go
src/cmd/internal/obj/x86/obj6.go

index 61d065cea8327b409419ec07f7e727e938dd6ee4..ecd6a32eb3c1e2e9bf68f759505ea1258fb537d8 100644 (file)
@@ -289,13 +289,6 @@ func makeABIWrapper(f *ir.Func, wrapperABI obj.ABI) {
 
        fn.SetABIWrapper(true)
        fn.SetDupok(true)
-       // Set this as a wrapper so it doesn't appear in tracebacks.
-       // Having both ABIWrapper and Wrapper set suppresses obj's
-       // usual panic+recover handling for wrappers; that's okay
-       // because we're never going to defer a wrapper for a function
-       // that then recovers, so that's would just be unnecessary
-       // code in the ABI wrapper.
-       fn.SetWrapper(true)
 
        // ABI0-to-ABIInternal wrappers will be mainly loading params from
        // stack into registers (and/or storing stack locations back to
index b2f2bdcaed6cedbc81ae6a84c46f00b1f4f575df..9dbad20589cdb1ee46c2fe0497833abc791e407e 100644 (file)
@@ -136,7 +136,7 @@ func (ctxt *Link) InitTextSym(s *LSym, flag int) {
                ctxt.Diag("symbol %s listed multiple times", s.Name)
        }
        name := strings.Replace(s.Name, "\"\"", ctxt.Pkgpath, -1)
-       s.Func().FuncID = objabi.GetFuncID(name, flag&WRAPPER != 0)
+       s.Func().FuncID = objabi.GetFuncID(name, flag&WRAPPER != 0 || flag&ABIWRAPPER != 0)
        s.Func().FuncFlag = toFuncFlag(flag)
        s.Set(AttrOnList, true)
        s.Set(AttrDuplicateOK, flag&DUPOK != 0)
index e81e38ad259c21806ff696907fb7374a39fd2c99..b8c7ad7d1bb48c8cb86083f3374f60d7abc767df 100644 (file)
@@ -645,7 +645,7 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym, newprog obj.ProgAlloc) {
        }
 
        var regg int16
-       if !p.From.Sym.NoSplit() || (p.From.Sym.Wrapper() && !p.From.Sym.ABIWrapper()) {
+       if !p.From.Sym.NoSplit() || p.From.Sym.Wrapper() {
                if ctxt.Arch.Family == sys.AMD64 && objabi.Experiment.RegabiG && cursym.ABI() == obj.ABIInternal {
                        regg = REGG // use the g register directly in ABIInternal
                } else {
@@ -713,7 +713,7 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym, newprog obj.ProgAlloc) {
                p.To.Reg = REG_BP
        }
 
-       if cursym.Func().Text.From.Sym.Wrapper() && !cursym.Func().Text.From.Sym.ABIWrapper() {
+       if cursym.Func().Text.From.Sym.Wrapper() {
                // if g._panic != nil && g._panic.argp == FP {
                //   g._panic.argp = bottom-of-frame
                // }