Commit 43941d85 authored by Russ Cox's avatar Russ Cox

cmd/internal/ld: cache file name construction in linkgetline

This avoids repeated allocation and map lookups
when constructing the pcln tables.

For 6g compiling cmd/internal/gc/*.go this saves about 8% wall time.

Change-Id: I6a1a80e278ae2c2a44bd1537015ea7b4e7a4d6ca
Reviewed-on: https://go-review.googlesource.com/6793Reviewed-by: default avatarRob Pike <r@golang.org>
parent 5a16d6fc
...@@ -154,14 +154,6 @@ type Auto struct { ...@@ -154,14 +154,6 @@ type Auto struct {
Gotype *LSym Gotype *LSym
} }
type Hist struct {
Link *Hist
Name string
Line int32
Offset int32
Printed uint8
}
type Link struct { type Link struct {
Thechar int32 Thechar int32
Thestring string Thestring string
......
...@@ -15,6 +15,15 @@ const ( ...@@ -15,6 +15,15 @@ const (
NSYM = 50 NSYM = 50
) )
type Hist struct {
Link *Hist
Name string
Sym *LSym
Line int32
Offset int32
Printed uint8
}
func Linklinefmt(ctxt *Link, lno0 int, showAll, showFullPath bool) string { func Linklinefmt(ctxt *Link, lno0 int, showAll, showFullPath bool) string {
var a [HISTSZ]struct { var a [HISTSZ]struct {
incl *Hist incl *Hist
...@@ -174,13 +183,17 @@ func linkgetline(ctxt *Link, line int32, f **LSym, l *int32) { ...@@ -174,13 +183,17 @@ func linkgetline(ctxt *Link, line int32, f **LSym, l *int32) {
n-- n--
var dlno int32 var dlno int32
var file string var file string
var sym *LSym
if a[n].line != nil { if a[n].line != nil {
file = a[n].line.Name file = a[n].line.Name
sym = a[n].line.Sym
dlno = a[n].ldel - 1 dlno = a[n].ldel - 1
} else { } else {
file = a[n].incl.Name file = a[n].incl.Name
sym = a[n].incl.Sym
dlno = a[n].idel - 1 dlno = a[n].idel - 1
} }
if sym == nil {
var buf string var buf string
if filepath.IsAbs(file) || strings.HasPrefix(file, "<") { if filepath.IsAbs(file) || strings.HasPrefix(file, "<") {
buf = file buf = file
...@@ -202,8 +215,15 @@ func linkgetline(ctxt *Link, line int32, f **LSym, l *int32) { ...@@ -202,8 +215,15 @@ func linkgetline(ctxt *Link, line int32, f **LSym, l *int32) {
buf1 := fmt.Sprintf("%s%s", ctxt.Goroot_final, buf[len(ctxt.Goroot):]) buf1 := fmt.Sprintf("%s%s", ctxt.Goroot_final, buf[len(ctxt.Goroot):])
buf = buf1 buf = buf1
} }
sym = Linklookup(ctxt, buf, HistVersion)
if a[n].line != nil {
a[n].line.Sym = sym
} else {
a[n].incl.Sym = sym
}
}
lno -= dlno lno -= dlno
*f = Linklookup(ctxt, buf, HistVersion) *f = sym
*l = lno *l = lno
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment