diff options
Diffstat (limited to 'libgo/runtime')
-rw-r--r-- | libgo/runtime/malloc.goc | 2 | ||||
-rw-r--r-- | libgo/runtime/malloc.h | 7 | ||||
-rw-r--r-- | libgo/runtime/mgc0.c | 60 | ||||
-rw-r--r-- | libgo/runtime/runtime.c | 21 | ||||
-rw-r--r-- | libgo/runtime/runtime.h | 1 | ||||
-rw-r--r-- | libgo/runtime/runtime1.goc | 4 | ||||
-rw-r--r-- | libgo/runtime/thread-linux.c | 6 |
7 files changed, 40 insertions, 61 deletions
diff --git a/libgo/runtime/malloc.goc b/libgo/runtime/malloc.goc index f5321856eac..9ad9eda8350 100644 --- a/libgo/runtime/malloc.goc +++ b/libgo/runtime/malloc.goc @@ -129,7 +129,7 @@ __go_free(void *v) if(v == nil) return; - // If you change this also change mgc0.c:/^sweepspan, + // If you change this also change mgc0.c:/^sweep, // which has a copy of the guts of free. m = runtime_m(); diff --git a/libgo/runtime/malloc.h b/libgo/runtime/malloc.h index da0c0f85766..aa7d9ff3ae2 100644 --- a/libgo/runtime/malloc.h +++ b/libgo/runtime/malloc.h @@ -123,10 +123,9 @@ enum // Max number of threads to run garbage collection. // 2, 3, and 4 are all plausible maximums depending - // on the hardware details of the machine. The second - // proc is the one that helps the most (after the first), - // so start with just 2 for now. - MaxGcproc = 2, + // on the hardware details of the machine. The garbage + // collector scales well to 4 cpus. + MaxGcproc = 4, }; // A generic linked list of blocks. (Typically the block is bigger than sizeof(MLink).) diff --git a/libgo/runtime/mgc0.c b/libgo/runtime/mgc0.c index c4ab1454c5b..26633ab1f18 100644 --- a/libgo/runtime/mgc0.c +++ b/libgo/runtime/mgc0.c @@ -62,9 +62,6 @@ enum { #define bitMask (bitBlockBoundary | bitAllocated | bitMarked | bitSpecial) // TODO: Make these per-M. -static uint64 nlookup; -static uint64 nsizelookup; -static uint64 naddrlookup; static uint64 nhandoff; static int32 gctrace; @@ -218,8 +215,6 @@ scanblock(byte *b, int64 n) // Otherwise consult span table to find beginning. // (Manually inlined copy of MHeap_LookupMaybe.) - nlookup++; - naddrlookup++; k = (uintptr)obj>>PageShift; x = k; if(sizeof(void*) == 8) @@ -307,49 +302,8 @@ scanblock(byte *b, int64 n) b = *--wp; nobj--; - // Figure out n = size of b. Start by loading bits for b. - off = (uintptr*)b - (uintptr*)arena_start; - bitp = (uintptr*)arena_start - off/wordsPerBitmapWord - 1; - shift = off % wordsPerBitmapWord; - xbits = *bitp; - bits = xbits >> shift; - - // Might be small; look for nearby block boundary. - // A block boundary is marked by either bitBlockBoundary - // or bitAllocated being set (see notes near their definition). - enum { - boundary = bitBlockBoundary|bitAllocated - }; - // Look for a block boundary both after and before b - // in the same bitmap word. - // - // A block boundary j words after b is indicated by - // bits>>j & boundary - // assuming shift+j < bitShift. (If shift+j >= bitShift then - // we'll be bleeding other bit types like bitMarked into our test.) - // Instead of inserting the conditional shift+j < bitShift into the loop, - // we can let j range from 1 to bitShift as long as we first - // apply a mask to keep only the bits corresponding - // to shift+j < bitShift aka j < bitShift-shift. - bits &= (boundary<<(bitShift-shift)) - boundary; - - // A block boundary j words before b is indicated by - // xbits>>(shift-j) & boundary - // (assuming shift >= j). There is no cleverness here - // avoid the test, because when j gets too large the shift - // turns negative, which is undefined in C. - - for(j=1; j<bitShift; j++) { - if(((bits>>j)&boundary) != 0 || (shift>=j && ((xbits>>(shift-j))&boundary) != 0)) { - n = j*PtrSize; - goto scan; - } - } - - // Fall back to asking span about size class. + // Ask span about size class. // (Manually inlined copy of MHeap_Lookup.) - nlookup++; - nsizelookup++; x = (uintptr)b>>PageShift; if(sizeof(void*) == 8) x -= (uintptr)arena_start>>PageShift; @@ -358,7 +312,6 @@ scanblock(byte *b, int64 n) n = s->npages<<PageShift; else n = runtime_class_to_size[s->sizeclass]; - scan:; } } @@ -1018,9 +971,6 @@ runtime_gc(int32 force) } t0 = runtime_nanotime(); - nlookup = 0; - nsizelookup = 0; - naddrlookup = 0; nhandoff = 0; m->gcing = 1; @@ -1085,11 +1035,11 @@ runtime_gc(int32 force) runtime_printf("pause %llu\n", (unsigned long long)t3-t0); if(gctrace) { - runtime_printf("gc%d: %llu+%llu+%llu ms %llu -> %llu MB %llu -> %llu (%llu-%llu) objects %llu pointer lookups (%llu size, %llu addr) %llu handoff\n", - mstats.numgc, (unsigned long long)(t1-t0)/1000000, (unsigned long long)(t2-t1)/1000000, (unsigned long long)(t3-t2)/1000000, + runtime_printf("gc%d(%d): %llu+%llu+%llu ms %llu -> %llu MB %llu -> %llu (%llu-%llu) objects %llu handoff\n", + mstats.numgc, work.nproc, (unsigned long long)(t1-t0)/1000000, (unsigned long long)(t2-t1)/1000000, (unsigned long long)(t3-t2)/1000000, (unsigned long long)heap0>>20, (unsigned long long)heap1>>20, (unsigned long long)obj0, (unsigned long long)obj1, - (unsigned long long)mstats.nmalloc, (unsigned long long)mstats.nfree, - (unsigned long long)nlookup, (unsigned long long)nsizelookup, (unsigned long long)naddrlookup, (unsigned long long) nhandoff); + (unsigned long long) mstats.nmalloc, (unsigned long long)mstats.nfree, + (unsigned long long) nhandoff); } runtime_semrelease(&gcsema); diff --git a/libgo/runtime/runtime.c b/libgo/runtime/runtime.c index ec96f5b615f..922fa20448d 100644 --- a/libgo/runtime/runtime.c +++ b/libgo/runtime/runtime.c @@ -115,7 +115,7 @@ runtime_goargs(void) } void -runtime_goenvs(void) +runtime_goenvs_unix(void) { String *s; int32 i, n; @@ -183,3 +183,22 @@ runtime_fastrand1(void) m->fastrand = x; return x; } + +struct funcline_go_return +{ + String retfile; + int32 retline; +}; + +struct funcline_go_return +runtime_funcline_go(void *f, uintptr targetpc) + __asm__("libgo_runtime.runtime.funcline_go"); + +struct funcline_go_return +runtime_funcline_go(void *f __attribute__((unused)), + uintptr targetpc __attribute__((unused))) +{ + struct funcline_go_return ret; + runtime_memclr(&ret, sizeof ret); + return ret; +} diff --git a/libgo/runtime/runtime.h b/libgo/runtime/runtime.h index 94113b8db83..253c49b21f3 100644 --- a/libgo/runtime/runtime.h +++ b/libgo/runtime/runtime.h @@ -266,6 +266,7 @@ void runtime_args(int32, byte**); void runtime_osinit(); void runtime_goargs(void); void runtime_goenvs(void); +void runtime_goenvs_unix(void); void runtime_throw(const char*) __attribute__ ((noreturn)); void runtime_panicstring(const char*) __attribute__ ((noreturn)); void* runtime_mal(uintptr); diff --git a/libgo/runtime/runtime1.goc b/libgo/runtime/runtime1.goc index 4cd98041717..fd8918ed577 100644 --- a/libgo/runtime/runtime1.goc +++ b/libgo/runtime/runtime1.goc @@ -8,3 +8,7 @@ package runtime func GOMAXPROCS(n int32) (ret int32) { ret = runtime_gomaxprocsfunc(n); } + +func NumCPU() (ret int32) { + ret = runtime_ncpu; +} diff --git a/libgo/runtime/thread-linux.c b/libgo/runtime/thread-linux.c index a0ee3600650..8dd5fc4b481 100644 --- a/libgo/runtime/thread-linux.c +++ b/libgo/runtime/thread-linux.c @@ -103,3 +103,9 @@ runtime_osinit(void) { runtime_ncpu = getproccount(); } + +void +runtime_goenvs(void) +{ + runtime_goenvs_unix(); +} |