1
0
mirror of https://github.com/golang/go synced 2024-11-23 18:10:04 -07:00

cmd/compile: remove ignored bool from exported ODCL nodes

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>
This commit is contained in:
Robert Griesemer 2016-08-29 10:37:13 -07:00
parent 428d79bd38
commit 595cebb055
4 changed files with 15 additions and 25 deletions

View File

@ -158,7 +158,7 @@ const debugFormat = false // default: false
const forceObjFileStability = true const forceObjFileStability = true
// Current export format version. Increase with each format change. // 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 // exportInlined enables the export of inlined function bodies and related
// dependencies. The compiler should work w/o any loss of functionality with // 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 { switch op := n.Op; op {
case ODCL: case ODCL:
p.op(ODCL) p.op(ODCL)
switch n.Left.Class { p.sym(n.Left)
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.typ(n.Left.Type) p.typ(n.Left.Type)
// case ODCLFIELD: // case ODCLFIELD:

View File

@ -86,10 +86,10 @@ func Import(in *bufio.Reader) {
// read version specific flags - extend as necessary // read version specific flags - extend as necessary
switch p.version { switch p.version {
// case 2: // case 3:
// ... // ...
// fallthrough // fallthrough
case 1: case 2, 1:
p.debugFormat = p.rawStringln(p.rawByte()) == "debug" p.debugFormat = p.rawStringln(p.rawByte()) == "debug"
p.trackAllTypes = p.bool() p.trackAllTypes = p.bool()
p.posInfoFormat = p.bool() p.posInfoFormat = p.bool()
@ -1000,14 +1000,14 @@ func (p *importer) node() *Node {
// -------------------------------------------------------------------- // --------------------------------------------------------------------
// statements // statements
case ODCL: case ODCL:
var lhs *Node if p.version < 2 {
if p.bool() { // versions 0 and 1 exported a bool here but it
lhs = p.expr() // was always false - simply ignore in this case
} else { p.bool()
lhs = dclname(p.sym())
} }
// TODO(gri) avoid list created here! lhs := dclname(p.sym())
return liststmt(variter([]*Node{lhs}, typenod(p.typ()), nil)) typ := typenod(p.typ())
return liststmt(variter([]*Node{lhs}, typ, nil)) // TODO(gri) avoid list creation
// case ODCLFIELD: // case ODCLFIELD:
// unimplemented // unimplemented

View File

@ -3,7 +3,7 @@
package gc package gc
const runtimeimport = "" + 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" + "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" + "\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" + "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" "b\x16\x98\x03\x00b\x00\v\xf8\x01\v\x00\x01\x00\n$$\n"
const unsafeimport = "" + 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" + "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" "\x01\x16\x00\v\b\v\x00\x01\x00\n$$\n"

View File

@ -93,10 +93,10 @@ func BImportData(imports map[string]*types.Package, data []byte, path string) (_
// read version specific flags - extend as necessary // read version specific flags - extend as necessary
switch p.version { switch p.version {
// case 2: // case 3:
// ... // ...
// fallthrough // fallthrough
case 1: case 2, 1:
p.debugFormat = p.rawStringln(p.rawByte()) == "debug" p.debugFormat = p.rawStringln(p.rawByte()) == "debug"
p.trackAllTypes = p.int() != 0 p.trackAllTypes = p.int() != 0
p.posInfoFormat = p.int() != 0 p.posInfoFormat = p.int() != 0