Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/compile: double aliases lead to double serialization of an object #17636

Closed
griesemer opened this issue Oct 27, 2016 · 5 comments
Closed

Comments

@griesemer
Copy link
Contributor

package p
import "imported"
func F1 => imported.F
func F2 => imported.F

will serialize the data for imported.F twice in the export data for this package, once for F1 and once for F2.

While this doesn't bother the importer (it already can handle multiple imports of the same object), it breaks the original invariant that objects of the current package are serialized exactly once in the export data (we use maps to ensure this for packages and types).

@griesemer griesemer added this to the Go1.8Maybe milestone Oct 27, 2016
@griesemer griesemer self-assigned this Oct 27, 2016
@griesemer
Copy link
Contributor Author

See also comment in go/internal/gcimporter/bimport.go, method importer.declare.

@griesemer
Copy link
Contributor Author

@mdempsky suggests:

Seems like it would be a little cleaner to instead export aliases as

    aliasTag, aliasName, orig.qualifiedName

and ensure we emit aliases after we've emitted the original object, but I'm okay with this too.  Like you say, I don't think it should matter much in practice either way.

(see https://go-review.googlesource.com/#/c/32538/)

@griesemer
Copy link
Contributor Author

cc: @alandonovan

@alandonovan
Copy link
Contributor

Emitting imported.F exactly once in p's export data is not sufficient to avoid duplication. The importer needs to know that p.F1 and importer.F (which it may already have) are the same object, which means, as Matthew says, that the export data for the alias must record the canonical name of the original object. But the qualified name is also not sufficient, since the object definiion is required. I think you need:

  aliasTag, aliasName, orig.qualifiedName, obj

where obj is either the definition of the original object, or a back reference to an earlier object. obj should also permit "unknownTag" to represent dangling aliases.

@gopherbot
Copy link

CL https://golang.org/cl/32575 mentions this issue.

@golang golang locked and limited conversation to collaborators Nov 2, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants