Skip to content

Commit

Permalink
code generate a single compiler intrinsics table
Browse files Browse the repository at this point in the history
This simplifies the code generator and global variables a bit.
  • Loading branch information
mvdan committed Aug 27, 2024
1 parent 2259abb commit b49a13c
Show file tree
Hide file tree
Showing 4 changed files with 192 additions and 182 deletions.
290 changes: 147 additions & 143 deletions go_std_tables.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -869,7 +869,7 @@ func (tf *transformer) replaceAsmNames(buf *bytes.Buffer, remaining []byte) {
name := string(remaining[:nameEnd])
remaining = remaining[nameEnd:]

if lpkg.ToObfuscate && !compilerIntrinsicsFuncs[lpkg.ImportPath+"."+name] {
if lpkg.ToObfuscate && !compilerIntrinsics[lpkg.ImportPath][name] {
newName := hashWithPackage(lpkg, name)
if flagDebug { // TODO(mvdan): remove once https://go.dev/issue/53465 if fixed
log.Printf("asm name %q hashed with %x to %q", name, tf.curPkg.GarbleActionID, newName)
Expand Down Expand Up @@ -1107,7 +1107,7 @@ func (tf *transformer) transformDirectives(comments []*ast.CommentGroup) {

func (tf *transformer) transformLinkname(localName, newName string) (string, string) {
// obfuscate the local name, if the current package is obfuscated
if tf.curPkg.ToObfuscate && !compilerIntrinsicsFuncs[tf.curPkg.ImportPath+"."+localName] {
if tf.curPkg.ToObfuscate && !compilerIntrinsics[tf.curPkg.ImportPath][localName] {
localName = hashWithPackage(tf.curPkg, localName)
}
if newName == "" {
Expand Down Expand Up @@ -1169,7 +1169,7 @@ func (tf *transformer) transformLinkname(localName, newName string) (string, str
panic(err) // shouldn't happen
}

if !lpkg.ToObfuscate || compilerIntrinsicsFuncs[lpkg.ImportPath+"."+foreignName] {
if !lpkg.ToObfuscate || compilerIntrinsics[lpkg.ImportPath][foreignName] {
// We're not obfuscating that package or name.
return localName, newName
}
Expand Down Expand Up @@ -2010,7 +2010,7 @@ func (tf *transformer) transformGoFile(file *ast.File) *ast.File {
case *types.TypeName:
debugName = "type"
case *types.Func:
if compilerIntrinsicsFuncs[path+"."+name] {
if compilerIntrinsics[path][name] {
return true
}

Expand Down
Loading

0 comments on commit b49a13c

Please sign in to comment.