]> Cypherpunks repositories - gostls13.git/commit
cmd/compile, runtime: new static name encoding
authorDavid Crawshaw <crawshaw@golang.org>
Mon, 21 Mar 2016 17:21:55 +0000 (13:21 -0400)
committerDavid Crawshaw <crawshaw@golang.org>
Fri, 25 Mar 2016 00:13:49 +0000 (00:13 +0000)
commit24ce64d1a967eb9c4f1a42e7371362b09920bd60
tree5526a0d14cc557e3a3811a177b8b77866cd64b43
parent0a82ed5d7c6db2c01a840e2a494cb6ff22a02823
cmd/compile, runtime: new static name encoding

Create a byte encoding designed for static Go names.

It is intended to be a compact representation of a name
and optional tag data that can be turned into a Go string
without allocating, and describes whether or not it is
exported without unicode table.

The encoding is described in reflect/type.go:

// The first byte is a bit field containing:
//
// 1<<0 the name is exported
// 1<<1 tag data follows the name
// 1<<2 pkgPath *string follow the name and tag
//
// The next two bytes are the data length:
//
//  l := uint16(data[1])<<8 | uint16(data[2])
//
// Bytes [3:3+l] are the string data.
//
// If tag data follows then bytes 3+l and 3+l+1 are the tag length,
// with the data following.
//
// If the import path follows, then ptrSize bytes at the end of
// the data form a *string. The import path is only set for concrete
// methods that are defined in a different package than their type.

Shrinks binary sizes:

cmd/go: 164KB (1.6%)
jujud:  1.0MB (1.5%)

For #6853.

Change-Id: I46b6591015b17936a443c9efb5009de8dfe8b609
Reviewed-on: https://go-review.googlesource.com/20968
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/cmd/compile/internal/gc/reflect.go
src/cmd/link/internal/ld/decodesym.go
src/reflect/type.go
src/reflect/value.go
src/runtime/iface.go
src/runtime/type.go