Skip to content

Commit

Permalink
attr,build: add TOPFRAME attribute (#98)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
zchee authored and mmcloughlin committed Sep 27, 2019
1 parent c8004ba commit 15d6a9a
Show file tree
Hide file tree
Showing 4 changed files with 204 additions and 197 deletions.
27 changes: 16 additions & 11 deletions attr/attr.go
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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.
Expand Down Expand Up @@ -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",
}
3 changes: 2 additions & 1 deletion attr/attr_test.go
Expand Up @@ -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()
Expand Down
1 change: 1 addition & 0 deletions build/attr.go
Expand Up @@ -14,4 +14,5 @@ const (
TLSBSS = attr.TLSBSS
NOFRAME = attr.NOFRAME
REFLECTMETHOD = attr.REFLECTMETHOD
TOPFRAME = attr.TOPFRAME
)

0 comments on commit 15d6a9a

Please sign in to comment.