]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: remove ignored bool from exported ODCL nodes
authorRobert Griesemer <gri@golang.org>
Mon, 29 Aug 2016 17:37:13 +0000 (10:37 -0700)
committerRobert Griesemer <gri@golang.org>
Mon, 29 Aug 2016 18:07:47 +0000 (18:07 +0000)
This shortens the export format by 1 byte for each exported ODCL
node in inlined function bodies.

Maintain backward compatibility by updating format version and
continue to accept older format.

Change-Id: I549bb3ade90bc0f146decf8016d5c9c3f14eb293
Reviewed-on: https://go-review.googlesource.com/27999
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
src/cmd/compile/internal/gc/bexport.go
src/cmd/compile/internal/gc/bimport.go
src/cmd/compile/internal/gc/builtin.go
src/go/internal/gcimporter/bimport.go

index f3204656dc213acf21845482647c70592706bb31..3ac1ade28e0735c9c6fc14b362299de6ba707dd1 100644 (file)
@@ -158,7 +158,7 @@ const debugFormat = false // default: false
 const forceObjFileStability = true
 
 // Current export format version. Increase with each format change.
-const exportVersion = 1
+const exportVersion = 2
 
 // exportInlined enables the export of inlined function bodies and related
 // dependencies. The compiler should work w/o any loss of functionality with
@@ -1418,17 +1418,7 @@ func (p *exporter) stmt(n *Node) {
        switch op := n.Op; op {
        case ODCL:
                p.op(ODCL)
-               switch n.Left.Class {
-               case PPARAM, PPARAMOUT, PAUTO, PAUTOHEAP:
-                       // TODO(gri) when is this not PAUTO?
-                       // Also, originally this didn't look like
-                       // the default case. Investigate.
-                       fallthrough
-               default:
-                       // TODO(gri) Can we ever reach here?
-                       p.bool(false)
-                       p.sym(n.Left)
-               }
+               p.sym(n.Left)
                p.typ(n.Left.Type)
 
        // case ODCLFIELD:
index 99c8554729a7adda34e0e7f05a6495dac36bd573..6232f81d7fef33f6db03929af58b6040963772bd 100644 (file)
@@ -86,10 +86,10 @@ func Import(in *bufio.Reader) {
 
        // read version specific flags - extend as necessary
        switch p.version {
-       // case 2:
+       // case 3:
        //      ...
        //      fallthrough
-       case 1:
+       case 2, 1:
                p.debugFormat = p.rawStringln(p.rawByte()) == "debug"
                p.trackAllTypes = p.bool()
                p.posInfoFormat = p.bool()
@@ -1000,14 +1000,14 @@ func (p *importer) node() *Node {
        // --------------------------------------------------------------------
        // statements
        case ODCL:
-               var lhs *Node
-               if p.bool() {
-                       lhs = p.expr()
-               } else {
-                       lhs = dclname(p.sym())
+               if p.version < 2 {
+                       // versions 0 and 1 exported a bool here but it
+                       // was always false - simply ignore in this case
+                       p.bool()
                }
-               // TODO(gri) avoid list created here!
-               return liststmt(variter([]*Node{lhs}, typenod(p.typ()), nil))
+               lhs := dclname(p.sym())
+               typ := typenod(p.typ())
+               return liststmt(variter([]*Node{lhs}, typ, nil)) // TODO(gri) avoid list creation
 
        // case ODCLFIELD:
        //      unimplemented
index e49224b4a4d50a6980f7f05aaa272817683bf292..637a661cddeba96e61dc1eade0877ca6bd5a3f2e 100644 (file)
@@ -3,7 +3,7 @@
 package gc
 
 const runtimeimport = "" +
-       "version 1\n\n\x00\x00\x01\rruntime\x00\t\x11newobject\x00\x02\x17\"\vt" +
+       "version 2\n\n\x00\x00\x01\rruntime\x00\t\x11newobject\x00\x02\x17\"\vt" +
        "yp·2\x00\x00\x01\x17:\x00\t\x13panicindex\x00\x00\x00\t\x13panicslice\x00\x00" +
        "\x00\t\x15panicdivide\x00\x00\x00\t\x15throwreturn\x00\x00\x00\t\x11throw" +
        "init\x00\x00\x00\t\x11panicwrap\x00\x05 \x00 \x00 \x00\x00\t\rgopanic\x00\x01\x1b\x00" +
@@ -106,6 +106,6 @@ const runtimeimport = "" +
        "b\x16\x98\x03\x00b\x00\v\xf8\x01\v\x00\x01\x00\n$$\n"
 
 const unsafeimport = "" +
-       "version 1\n\n\x00\x00\x01\vunsafe\x00\x05\r\rPointer\x00\x16\x00\t\x0fOff" +
+       "version 2\n\n\x00\x00\x01\vunsafe\x00\x05\r\rPointer\x00\x16\x00\t\x0fOff" +
        "setof\x00\x01:\x00\x01\x16\x00\t\vSizeof\x00\x01:\x00\x01\x16\x00\t\rAlignof\x00\x01:\x00" +
        "\x01\x16\x00\v\b\v\x00\x01\x00\n$$\n"
index f155b8fe754b1d91727418e1a32f75816e25c95c..2a8b98b66fe3eb33f16f78638e24de496016d345 100644 (file)
@@ -93,10 +93,10 @@ func BImportData(imports map[string]*types.Package, data []byte, path string) (_
 
        // read version specific flags - extend as necessary
        switch p.version {
-       // case 2:
+       // case 3:
        //      ...
        //      fallthrough
-       case 1:
+       case 2, 1:
                p.debugFormat = p.rawStringln(p.rawByte()) == "debug"
                p.trackAllTypes = p.int() != 0
                p.posInfoFormat = p.int() != 0