• Cherry Zhang's avatar
    [dev.link] cmd/link: add internal packages at the end · 24ea07d5
    Cherry Zhang authored
    Currently in the linker we load internal packges first, then the
    main package, and then load imported packages following the
    dependency graph. As a result, packages are loaded mostly in the
    dependency order, except the internal packages. The global symbol
    indices are assigned the same way.
    
    By loading the internal packages at the end, the packages are
    loaded in the dependency order, so are the global indices. This
    way, a relocation edge is mostly either within a packge or a
    forward edge from a smaller index to a larger one. This allows
    us to use a min-heap work queue in the deadcode pass, to achieve
    better spatial locality (in the next CL).
    
    Change-Id: I01fa9b3cf0c9e9e66006040f6378a51fd78f0f39
    Reviewed-on: https://go-review.googlesource.com/c/go/+/204437Reviewed-by: default avatarJeremy Faller <jeremy@golang.org>
    24ea07d5
lib.go 75.1 KB