aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/ld/lib.h
diff options
context:
space:
mode:
authorKeith Randall <khr@golang.org>2014-12-27 19:26:40 -0800
committerKeith Randall <khr@golang.org>2015-01-07 21:24:21 +0000
commit63116de558b472c437df186d6bf87e163f674ea2 (patch)
treeb3a997702dd8737db1bbde6408fd1ce6639333ef /src/cmd/ld/lib.h
parentaf7ca8dce4991860263d5e0d0322461cfd00c599 (diff)
downloadgo-63116de558b472c437df186d6bf87e163f674ea2.tar.xz
runtime: faster version of findfunc
Use a lookup table to find the function which contains a pc. It is faster than the old binary search. findfunc is used primarily for stack copying and garbage collection. benchmark old ns/op new ns/op delta BenchmarkStackCopy 294746596 255400980 -13.35% (findfunc is one of several tasks done by stack copy, the findfunc time itself is about 2.5x faster.) The lookup table is built at link time. The table grows the binary size by about 0.5% of the text segment. We impose a lower limit of 16 bytes on any function, which should not have much of an impact. (The real constraint required is <=256 functions in every 4096 bytes, but 16 bytes/function is easier to implement.) Change-Id: Ic315b7a2c83e1f7203cd2a50e5d21a822e18fdca Reviewed-on: https://go-review.googlesource.com/2097 Reviewed-by: Russ Cox <rsc@golang.org>
Diffstat (limited to 'src/cmd/ld/lib.h')
-rw-r--r--src/cmd/ld/lib.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/cmd/ld/lib.h b/src/cmd/ld/lib.h
index 17483e0b4c..fd84c8bccb 100644
--- a/src/cmd/ld/lib.h
+++ b/src/cmd/ld/lib.h
@@ -35,6 +35,7 @@
enum {
MAXIO = 8192,
+ MINFUNC = 16, // minimum size for a function
};
typedef struct Segment Segment;
@@ -260,6 +261,7 @@ void patch(void);
int pathchar(void);
void pcln(void);
void pclntab(void);
+void findfunctab(void);
void putelfsectionsym(LSym* s, int shndx);
void putelfsymshndx(vlong sympos, int shndx);
void putsymb(LSym *s, char *name, int t, vlong v, vlong size, int ver, LSym *typ);