]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: for now, keep parameter numbering in binary export format
authorRobert Griesemer <gri@golang.org>
Mon, 25 Apr 2016 21:39:51 +0000 (14:39 -0700)
committerRobert Griesemer <gri@golang.org>
Mon, 25 Apr 2016 22:17:01 +0000 (22:17 +0000)
The numbering is only required for parameters of functions/methods
with exported inlineable bodies. For now, always export parameter names
with internal numbering to minimize the diffs between assembly code
dumps of code compiled with the textual vs the binary format.

To be disabled again once the new export format is default.

Change-Id: I6d14c564e734cc5596c7e995d8851e06d5a35013
Reviewed-on: https://go-review.googlesource.com/22441
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
src/cmd/compile/internal/gc/bexport.go
src/go/internal/gcimporter/bimport.go

index c635129ccc53bbec02808dffe39bb3b21636ba8d..512da43d51aeaa508ffc072c70e5503f1047f90b 100644 (file)
@@ -123,6 +123,13 @@ const posInfoFormat = false
 // TODO(gri) remove eventually
 const forceNewExport = false // force new export format - DO NOT SUBMIT with this flag set
 
+// forceNumberedParams keeps parameter numbering in exported parameter names
+// even where we don't really need it (because the parameter names are not used
+// elsewhere). Leave it enabled for now to remove this difference in generated
+// object files so we can more easily compare old and new format.
+// TODO(gri) remove once we switched to new format
+const forceNumberedParams = true
+
 const exportVersion = "v0"
 
 // exportInlined enables the export of inlined function bodies and related
@@ -875,7 +882,7 @@ func parName(f *Field, numbered bool) string {
        // Functions that can be inlined use numbered parameters so we can distingish them
        // from other names in their context after inlining (i.e., the parameter numbering
        // is a form of parameter rewriting). See issue 4326 for an example and test case.
-       if numbered {
+       if forceNumberedParams || numbered {
                if !strings.Contains(name, "·") && f.Nname != nil && f.Nname.Name != nil && f.Nname.Name.Vargen > 0 {
                        name = fmt.Sprintf("%s·%d", name, f.Nname.Name.Vargen) // append Vargen
                }
index f2080ffe59bdb77aa2ec13b307cc3f1e096f7aab..5ba9af1b02362d74c574ac1fc60b8f74553043d7 100644 (file)
@@ -11,6 +11,7 @@ import (
        "go/token"
        "go/types"
        "sort"
+       "strings"
        "unicode"
        "unicode/utf8"
 )
@@ -504,6 +505,9 @@ func (p *importer) param(named bool) (*types.Var, bool) {
                if name == "" {
                        panic("expected named parameter")
                }
+               if i := strings.Index(name, "·"); i > 0 {
+                       name = name[:i] // cut off gc-specific parameter numbering
+               }
                pkg = p.pkg()
        }