]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: allocate internal symbol table eagerly
authorDmitriy Vyukov <dvyukov@google.com>
Tue, 28 May 2013 17:10:10 +0000 (21:10 +0400)
committerDmitriy Vyukov <dvyukov@google.com>
Tue, 28 May 2013 17:10:10 +0000 (21:10 +0400)
we need it for GC anyway.

R=golang-dev, khr, dave, khr
CC=golang-dev
https://golang.org/cl/9728044

src/pkg/runtime/cpuprof.c
src/pkg/runtime/proc.c
src/pkg/runtime/runtime.h
src/pkg/runtime/symtab.c

index 9a0606a225aaf33ecd97cd171ebffed9af7309d1..6793e5d361a0174b571aaa9c9f103a3d76c5f677 100644 (file)
@@ -128,10 +128,6 @@ runtime·SetCPUProfileRate(intgo hz)
        uintptr *p;
        uintptr n;
        
-       // Call findfunc now so that it won't have to
-       // build tables during the signal handler.
-       runtime·findfunc(0);
-
        // Clamp hz to something reasonable.
        if(hz < 0)
                hz = 0;
index d6d308e524526a75cd66664c9e8799f787f0f9f9..7581b35d0bfb262d0f18de0036d1fb1e4e8620d6 100644 (file)
@@ -133,10 +133,8 @@ runtime·schedinit(void)
        runtime·goargs();
        runtime·goenvs();
 
-       // For debugging:
-       // Allocate internal symbol table representation now,
-       // so that we don't need to call malloc when we crash.
-       // runtime·findfunc(0);
+       // Allocate internal symbol table representation now, we need it for GC anyway.
+       runtime·symtabinit();
 
        runtime·sched.lastpoll = runtime·nanotime();
        procs = 1;
index 17f8c9a94a5d0ff5a2d807e027b81af4c32199f3..44cc0138c06a63c4077fef264efcebad30eaa8b9 100644 (file)
@@ -749,6 +749,7 @@ void        runtime·mpreinit(M*);
 void   runtime·minit(void);
 void   runtime·unminit(void);
 void   runtime·signalstack(byte*, int32);
+void   runtime·symtabinit(void);
 Func*  runtime·findfunc(uintptr);
 int32  runtime·funcline(Func*, uintptr);
 void*  runtime·stackalloc(uint32);
index 5edcb49bda8c5ed35affbb31264874099bd7a630..597fa49b7ce4afd40069f8b8a4400708c033bcb2 100644 (file)
@@ -193,8 +193,6 @@ static int32 nfunc;
 static byte **fname;
 static int32 nfname;
 
-static uint32 funcinit;
-static Lock funclock;
 static uintptr lastvalue;
 
 static void
@@ -539,8 +537,8 @@ runtime·funcline_go(Func *f, uintptr targetpc, String retfile, intgo retline)
        FLUSH(&retline);
 }
 
-static void
-buildfuncs(void)
+void
+runtime·symtabinit(void)
 {
        extern byte etext[];
 
@@ -591,26 +589,6 @@ runtime·findfunc(uintptr addr)
        Func *f;
        int32 nf, n;
 
-       // Use atomic double-checked locking,
-       // because when called from pprof signal
-       // handler, findfunc must run without
-       // grabbing any locks.
-       // (Before enabling the signal handler,
-       // SetCPUProfileRate calls findfunc to trigger
-       // the initialization outside the handler.)
-       // Avoid deadlock on fault during malloc
-       // by not calling buildfuncs if we're already in malloc.
-       if(!m->mallocing && !m->gcing) {
-               if(runtime·atomicload(&funcinit) == 0) {
-                       runtime·lock(&funclock);
-                       if(funcinit == 0) {
-                               buildfuncs();
-                               runtime·atomicstore(&funcinit, 1);
-                       }
-                       runtime·unlock(&funclock);
-               }
-       }
-
        if(nfunc == 0)
                return nil;
        if(addr < func[0].entry || addr >= func[nfunc].entry)