-
Notifications
You must be signed in to change notification settings - Fork 0
[-v] cmd/compile: incorrect package initialization order for spec example #2
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
Conversation
Okay! Failing test. Now what? 😬 |
Are there some side-effects to |
Here are the functions in
|
|
Here is global state:
And here is the call graph (
Aaaand here is a call graph coming in from
|
Yeah, okay, getting back into it: right now declarations are sorted by a) reverse dependency and b) RHS appearance (i.e., usage or reference), but they need to be sorted by a) reverse dependency and b) LHS appearance (i.e., declaration). That is, |
With 5cb3111:
|
With 9e14150:
|
|
Here's a sketch of data structures and an algorithm to add to
|
|
Bringing back append logging in 91b85e4 .
|
Here's logging that includes the
|
Alright, sooo ... I'm pretty sure |
Has to be When I am appending
(It's trivial to populate both |
Progress! Now how about
|
I'm referring to golang#22326 (comment) in another tab through all of this, btw. |
ea56f22 🤔
|
7c1eca0 💃
|
Alright, so we can get from |
Got it! 😍 💃 6504037
|
💃💃💃💃💃💃
|
|
f5cdd46
|
!!!!!!
|
😍 😍 😍 😍 😍 😍 😍 😍 😍 😍 😍
|
That's acbf979. Still a ways to go, apparently a) |
Okay, trying to button together
|
go/src/cmd/internal/obj/link.go Lines 667 to 676 in 048c916
Soooo ... the default value is what we're seeing, we're not seeing the result of ... setting go/src/cmd/internal/obj/x86/obj6.go Lines 1276 to 1284 in 048c916
Wasn't that not showing up earlier? Yes. 🤔 |
Actually I think that's a lie. |
(Regarding the default value.) |
Okay maybe it's not a lie: https://play.golang.org/p/NJrROy3SkSk package main
import (
"fmt"
)
type LinkArch struct {
DWARFRegisters map[int16]int16
}
func main() {
var arch = new(LinkArch)
println(fmt.Sprintf("%v", arch.DWARFRegisters))
} Outputs:
|
Alright, so we have something like this: https://play.golang.org/p/XDuMFzoSM2m package main
import (
"fmt"
)
var AMD64DWARFRegisters = map[int16]int16{
0: 42,
}
type LinkArch struct {
DWARFRegisters map[int16]int16
}
func main() {
var arch = LinkArch{
DWARFRegisters: AMD64DWARFRegisters,
}
println(fmt.Sprintf("%v", arch.DWARFRegisters))
}
Except there is package traversal in there. And it breaks. |
71fbcb8
|
Okay! So why does that work? 🤔 Tune in next time! 😬 |
Test passing in 81daac1. 👍
|
dcf1787
to
bc55a9a
Compare
|
Significant slowdown relative to 048c916:
|
Squashed! Getting ready to contribute! |
Rebased on latest master (af43203).
|
Alright, I'm going to give this a once-over before submitting. Not planning to address any of the big issues in the issue description (out of time! :( ) but just basic reorganization and |
Baseline. 👍
|
Okay! I have a commit! e041f1e Now, how do I get that into Gerrit? 🤔 |
I mean, besides letting Gopherbot do it for me. 😆 |
The spec advertises the sort order for variable initialization as dependency and then declaration, but the compiler currently orders initialization by dependency and then use. This CL introduces NodeSet and Deps structs in sinit.go, uses instances of these structs in the call chain under initreorder to track dependency information, and uses this dependency information back in initfix to properly order its output. Fixing the order of the output of initfix ran afoul of a complex bug in the build toolchain that I did not have time to fully comprehend. This CL works around it by constructing obj.LinkArches at run time instead of compile time. Unfortunately, this CL results in a performance penalty for make.bash: it takes half-again as long to run with as without. Fixes golang#22326
I've figured out how to convince |
🤔 |
Okay the test suite is totally hosed. 😞 |
💃
Moving to https://go-review.googlesource.com/c/go/+/156328/! 😍 |
Picking up from #1 ...
Todo
lout
properlylout
properlyThen
Deps
bool
instead ofstruct{}
for depsGOARCH
/GOOS
?Meanwhile
Finally
Further
OAS2
andOASOP
—what happens if Ix,y = 1,2
orx = 1; x += 1
inxtop
?Ninit
—doesinitreorder
ever actually recurse? Can we get some test coverage reporting?nf
—what if we have init functions but no statements? really return early?