]> Cypherpunks.ru repositories - gostls13.git/blobdiff - src/cmd/compile/internal/inline/inlheur/callsite.go
cmd/compile/internal/inline: score call sites exposed by inlines
[gostls13.git] / src / cmd / compile / internal / inline / inlheur / callsite.go
index 0ec7c521836ac8103f8c7088a9b33b1b43911683..baa1c20dcf7facd5549ec044536d610d7ac1784e 100644 (file)
@@ -27,11 +27,13 @@ import (
 type CallSite struct {
        Callee    *ir.Func
        Call      *ir.CallExpr
+       parent    *CallSite
        Assign    ir.Node
        Flags     CSPropBits
        Score     int
        ScoreMask scoreAdjustTyp
        ID        uint
+       aux       uint8
 }
 
 // CallSiteTab is a table of call sites, keyed by call expr.
@@ -41,9 +43,6 @@ type CallSite struct {
 // with many calls that share the same auto-generated pos.
 type CallSiteTab map[*ir.CallExpr]*CallSite
 
-// Package-level table of callsites.
-var cstab = CallSiteTab{}
-
 type CSPropBits uint32
 
 const (
@@ -52,6 +51,12 @@ const (
        CallSiteInInitFunc
 )
 
+type csAuxBits uint8
+
+const (
+       csAuxInlined = 1 << iota
+)
+
 // encodedCallSiteTab is a table keyed by "encoded" callsite
 // (stringified src.XPos plus call site ID) mapping to a value of call
 // property bits and score.
@@ -90,7 +95,7 @@ func fmtFullPos(p src.XPos) string {
        return sb.String()
 }
 
-func encodeCallSiteKey(cs *CallSite) string {
+func EncodeCallSiteKey(cs *CallSite) string {
        var sb strings.Builder
        // FIXME: maybe rewrite line offsets relative to function start?
        sb.WriteString(fmtFullPos(cs.Call.Pos()))
@@ -101,7 +106,7 @@ func encodeCallSiteKey(cs *CallSite) string {
 func buildEncodedCallSiteTab(tab CallSiteTab) encodedCallSiteTab {
        r := make(encodedCallSiteTab)
        for _, cs := range tab {
-               k := encodeCallSiteKey(cs)
+               k := EncodeCallSiteKey(cs)
                r[k] = propsAndScore{
                        props: cs.Flags,
                        score: cs.Score,