attr,build: add TOPFRAME attribute (#98)

Go added the TOPFRAME attribute in https://golang.org/cl/169726/. This diff adds the new attribute to avo, and also updates handling of the REFLECTMETHOD attribute.
This commit is contained in:
Koichi Shiraishi
2019-09-27 13:11:50 +09:00
committed by Michael McLoughlin
parent c8004ba627
commit 15d6a9a17e
4 changed files with 204 additions and 197 deletions

View File

@@ -10,7 +10,7 @@ import (
// Attribute represents TEXT or DATA flags.
type Attribute uint16
// Reference: https://github.com/golang/go/blob/35f4ec152b44ae5fc83aaf68e2eb3aa1a778e5cd/src/runtime/textflag.h#L11-L34
// Reference: https://github.com/golang/go/blob/aafe257390cc9048e8b5df898fabd79a9e0d4c39/src/runtime/textflag.h#L11-L37
//
// // Don't profile the marked routine. This flag is deprecated.
// #define NOPROF 1
@@ -36,6 +36,9 @@ type Attribute uint16
// #define NOFRAME 512
// // Function can call reflect.Type.Method or reflect.Type.MethodByName.
// #define REFLECTMETHOD 1024
// // Function is the top of the call stack. Call stack unwinders should stop
// // at this function.
// #define TOPFRAME 2048
//
const (
NOPROF Attribute = 1 << iota
@@ -49,6 +52,7 @@ const (
TLSBSS
NOFRAME
REFLECTMETHOD
TOPFRAME
)
// Asm returns a representation of the attributes in assembly syntax. This may use macros from "textflags.h"; see ContainsTextFlags() to determine if this header is required.
@@ -84,14 +88,15 @@ func (a Attribute) split() ([]string, Attribute) {
}
var attrname = map[Attribute]string{
NOPROF: "NOPROF",
DUPOK: "DUPOK",
NOSPLIT: "NOSPLIT",
RODATA: "RODATA",
NOPTR: "NOPTR",
WRAPPER: "WRAPPER",
NEEDCTXT: "NEEDCTXT",
TLSBSS: "TLSBSS",
NOFRAME: "NOFRAME",
// REFLECTMETHOD excluded due to https://golang.org/issue/29487
NOPROF: "NOPROF",
DUPOK: "DUPOK",
NOSPLIT: "NOSPLIT",
RODATA: "RODATA",
NOPTR: "NOPTR",
WRAPPER: "WRAPPER",
NEEDCTXT: "NEEDCTXT",
TLSBSS: "TLSBSS",
NOFRAME: "NOFRAME",
REFLECTMETHOD: "REFLECTMETHOD",
TOPFRAME: "TOPFRAME",
}

View File

@@ -14,7 +14,8 @@ func TestAttributeAsm(t *testing.T) {
{RODATA | NOSPLIT, "NOSPLIT|RODATA"},
{WRAPPER | 16384 | NOPTR, "NOPTR|WRAPPER|16384"},
{NEEDCTXT + NOFRAME + TLSBSS, "NEEDCTXT|TLSBSS|NOFRAME"},
{REFLECTMETHOD, "1024"}, // REFLECTMETHOD special case due to https://golang.org/issue/29487
{REFLECTMETHOD, "REFLECTMETHOD"},
{TOPFRAME, "TOPFRAME"},
}
for _, c := range cases {
got := c.Attribute.Asm()

View File

@@ -14,4 +14,5 @@ const (
TLSBSS = attr.TLSBSS
NOFRAME = attr.NOFRAME
REFLECTMETHOD = attr.REFLECTMETHOD
TOPFRAME = attr.TOPFRAME
)

File diff suppressed because it is too large Load Diff