Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1)

Delta Between Two Patch Sets: src/pkg/runtime/mgc0.c

Issue 37540043: code review 37540043: runtime: heap dump experiment (Closed)
Left Patch Set: diff -r 62052ebe728b https://code.google.com/p/go/ Created 10 years, 11 months ago
Right Patch Set: diff -r ec2ac2c466aa https://khr%40golang.org@code.google.com/p/go/ Created 10 years, 11 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « src/pkg/runtime/mgc0.h ('k') | src/pkg/runtime/runtime.h » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 // Copyright 2009 The Go Authors. All rights reserved. 1 // Copyright 2009 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 // Garbage collector (GC). 5 // Garbage collector (GC).
6 // 6 //
7 // GC is: 7 // GC is:
8 // - mark&sweep 8 // - mark&sweep
9 // - mostly precise (with the exception of some C-allocated objects, assembly fr ames/arguments, etc) 9 // - mostly precise (with the exception of some C-allocated objects, assembly fr ames/arguments, etc)
10 // - parallel (up to MaxGcproc threads) 10 // - parallel (up to MaxGcproc threads)
(...skipping 1434 matching lines...) Expand 10 before | Expand all | Expand 10 after
1445 enqueue1(wbufp, (Obj){scanp+PtrSize, PtrSize, 0}); 1445 enqueue1(wbufp, (Obj){scanp+PtrSize, PtrSize, 0});
1446 } 1446 }
1447 1447
1448 // Starting from scanp, scans words corresponding to set bits. 1448 // Starting from scanp, scans words corresponding to set bits.
1449 static void 1449 static void
1450 scanbitvector(byte *scanp, BitVector *bv, bool afterprologue, void *wbufp) 1450 scanbitvector(byte *scanp, BitVector *bv, bool afterprologue, void *wbufp)
1451 { 1451 {
1452 uintptr word, bits; 1452 uintptr word, bits;
1453 uint32 *wordp; 1453 uint32 *wordp;
1454 int32 i, remptrs; 1454 int32 i, remptrs;
1455 byte *p;
1455 1456
1456 wordp = bv->data; 1457 wordp = bv->data;
1457 for(remptrs = bv->n; remptrs > 0; remptrs -= 32) { 1458 for(remptrs = bv->n; remptrs > 0; remptrs -= 32) {
1458 word = *wordp++; 1459 word = *wordp++;
1459 if(remptrs < 32) 1460 if(remptrs < 32)
1460 i = remptrs; 1461 i = remptrs;
1461 else 1462 else
1462 i = 32; 1463 i = 32;
1463 i /= BitsPerPointer; 1464 i /= BitsPerPointer;
1464 for(; i > 0; i--) { 1465 for(; i > 0; i--) {
1465 bits = word & 3; 1466 bits = word & 3;
1466 » » » if(bits != BitsNoPointer && *(void**)scanp != nil) 1467 » » » switch(bits) {
1467 » » » » if(bits == BitsPointer) 1468 » » » case BitsDead:
1469 » » » » if(runtime·debug.gcdead)
1470 » » » » » *(uintptr*)scanp = (uintptr)0x6969696969 696969LL;
1471 » » » » break;
1472 » » » case BitsScalar:
1473 » » » » break;
1474 » » » case BitsPointer:
1475 » » » » p = *(byte**)scanp;
1476 » » » » if(p != nil)
1468 enqueue1(wbufp, (Obj){scanp, PtrSize, 0} ); 1477 enqueue1(wbufp, (Obj){scanp, PtrSize, 0} );
1469 » » » » else 1478 » » » » break;
1470 » » » » » scaninterfacedata(bits, scanp, afterprol ogue, wbufp); 1479 » » » case BitsMultiWord:
1480 » » » » p = *(byte**)scanp;
1481 » » » » if(p != nil) {
1482 » » » » » word >>= BitsPerPointer;
1483 » » » » » scanp += PtrSize;
1484 » » » » » i--;
1485 » » » » » if(i == 0) {
1486 » » » » » » // Get next chunk of bits
1487 » » » » » » remptrs -= 32;
1488 » » » » » » word = *wordp++;
1489 » » » » » » if(remptrs < 32)
1490 » » » » » » » i = remptrs;
1491 » » » » » » else
1492 » » » » » » » i = 32;
1493 » » » » » » i /= BitsPerPointer;
1494 » » » » » }
1495 » » » » » switch(word & 3) {
1496 » » » » » case BitsString:
1497 » » » » » » if(((String*)(scanp - PtrSize))- >len != 0)
1498 » » » » » » » markonly(p);
1499 » » » » » » break;
1500 » » » » » case BitsSlice:
1501 » » » » » » if(((Slice*)(scanp - PtrSize))-> cap < ((Slice*)(scanp - PtrSize))->len)
1502 » » » » » » » runtime·throw("slice cap acity smaller than length");
1503 » » » » » » if(((Slice*)(scanp - PtrSize))-> cap != 0)
1504 » » » » » » » enqueue1(wbufp, (Obj){sc anp - PtrSize, PtrSize, 0});
1505 » » » » » » break;
1506 » » » » » case BitsIface:
1507 » » » » » case BitsEface:
1508 » » » » » » scaninterfacedata(word & 3, scan p - PtrSize, afterprologue, wbufp);
1509 » » » » » » break;
1510 » » » » » }
1511 » » » » }
1512 » » » }
1471 word >>= BitsPerPointer; 1513 word >>= BitsPerPointer;
1472 scanp += PtrSize; 1514 scanp += PtrSize;
1473 } 1515 }
1474 } 1516 }
1475 } 1517 }
1476 1518
1477 // Scan a stack frame: local variables and function arguments/results. 1519 // Scan a stack frame: local variables and function arguments/results.
1478 static bool 1520 static bool
1479 scanframe(Stkframe *frame, void *wbufp) 1521 scanframe(Stkframe *frame, void *wbufp)
1480 { 1522 {
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after
2004 uint32 spanidx; 2046 uint32 spanidx;
2005 2047
2006 for(spanidx=0; spanidx<runtime·mheap.nspan; spanidx++) { 2048 for(spanidx=0; spanidx<runtime·mheap.nspan; spanidx++) {
2007 dumpspan(spanidx); 2049 dumpspan(spanidx);
2008 } 2050 }
2009 } 2051 }
2010 2052
2011 void 2053 void
2012 runtime·gchelper(void) 2054 runtime·gchelper(void)
2013 { 2055 {
2014 » int32 nproc; 2056 » uint32 nproc;
2015 2057
2016 gchelperstart(); 2058 gchelperstart();
2017 2059
2018 // parallel mark for over gc roots 2060 // parallel mark for over gc roots
2019 runtime·parfordo(work.markfor); 2061 runtime·parfordo(work.markfor);
2020 2062
2021 // help other threads scan secondary blocks 2063 // help other threads scan secondary blocks
2022 scanblock(nil, true); 2064 scanblock(nil, true);
2023 2065
2024 bufferList[m->helpgc].busy = 0; 2066 bufferList[m->helpgc].busy = 0;
(...skipping 719 matching lines...) Expand 10 before | Expand all | Expand 10 after
2744 bitmapChunk = 8192 2786 bitmapChunk = 8192
2745 }; 2787 };
2746 uintptr n; 2788 uintptr n;
2747 2789
2748 n = (h->arena_used - h->arena_start) / wordsPerBitmapWord; 2790 n = (h->arena_used - h->arena_start) / wordsPerBitmapWord;
2749 n = ROUND(n, bitmapChunk); 2791 n = ROUND(n, bitmapChunk);
2750 n = ROUND(n, PhysPageSize); 2792 n = ROUND(n, PhysPageSize);
2751 if(h->bitmap_mapped >= n) 2793 if(h->bitmap_mapped >= n)
2752 return; 2794 return;
2753 2795
2754 » runtime·SysMap(h->arena_start - n, n - h->bitmap_mapped, &mstats.gc_sys) ; 2796 » runtime·SysMap(h->arena_start - n, n - h->bitmap_mapped, h->arena_reserv ed, &mstats.gc_sys);
2755 h->bitmap_mapped = n; 2797 h->bitmap_mapped = n;
2756 } 2798 }
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b