// Mark mheap as 'no pointers', it does not contain interesting pointers but occupies ~45K.
#pragma dataflag NOPTR
MHeap runtime·mheap;
-MStats mstats;
int32 runtime·checking;
}
}
-// Size of the trailing by_size array differs between Go and C,
-// NumSizeClasses was changed, but we can not change Go struct because of backward compatibility.
-// sizeof_C_MStats is what C thinks about size of Go struct.
-uintptr runtime·sizeof_C_MStats = sizeof(MStats) - (NumSizeClasses - 61) * sizeof(mstats.by_size[0]);
+uintptr runtime·sizeof_C_MStats = sizeof(MStats);
#define MaxArena32 (2U<<30)
enum
{
- PageShift = 13,
+ PageShift = 12,
PageSize = 1<<PageShift,
PageMask = PageSize - 1,
};
// size classes. NumSizeClasses is that number. It's needed here
// because there are static arrays of this length; when msize runs its
// size choosing algorithm it double-checks that NumSizeClasses agrees.
- NumSizeClasses = 67,
+ NumSizeClasses = 61,
// Tunable constants.
MaxSmallSize = 32<<10,
} by_size[NumSizeClasses];
};
-#define mstats runtime·memStats
+#define mstats runtime·memStats /* name shared with Go */
extern MStats mstats;
// Size classes. Computed and initialized by InitSizes.
wordsPerBitmapWord = sizeof(void*)*8/4,
bitShift = sizeof(void*)*8/4,
- WorkbufSize = 16*1024,
- RootBlockSize = 4*1024,
- FinBlockSize = 4*1024,
-
handoffThreshold = 4,
IntermediateBufferCapacity = 64,
uintptr ti; // type info
};
+// The size of Workbuf is N*PageSize.
typedef struct Workbuf Workbuf;
struct Workbuf
{
-#define SIZE (WorkbufSize-sizeof(LFNode)-sizeof(uintptr))
+#define SIZE (2*PageSize-sizeof(LFNode)-sizeof(uintptr))
LFNode node; // must be first
uintptr nobj;
Obj obj[SIZE/sizeof(Obj) - 1];
ChanType *chantype;
Obj *wp;
- if(sizeof(Workbuf) % WorkbufSize != 0)
+ if(sizeof(Workbuf) % PageSize != 0)
runtime·throw("scanblock: size of Workbuf is suboptimal");
// Memory arena parameters.
runtime·lock(&finlock);
if(finq == nil || finq->cnt == finq->cap) {
if(finc == nil) {
- finc = runtime·persistentalloc(FinBlockSize, 0, &mstats.gc_sys);
- finc->cap = (FinBlockSize - sizeof(FinBlock)) / sizeof(Finalizer) + 1;
+ finc = runtime·persistentalloc(PageSize, 0, &mstats.gc_sys);
+ finc->cap = (PageSize - sizeof(FinBlock)) / sizeof(Finalizer) + 1;
finc->alllink = allfin;
allfin = finc;
}
runtime·MProf_GC();
}
-extern uintptr runtime·sizeof_C_MStats;
-
void
runtime·ReadMemStats(MStats *stats)
{
m->gcing = 1;
runtime·stoptheworld();
updatememstats(nil);
- // Size of the trailing by_size array differs between Go and C,
- // NumSizeClasses was changed, but we can not change Go struct because of backward compatibility.
- runtime·memcopy(runtime·sizeof_C_MStats, stats, &mstats);
+ *stats = mstats;
m->gcing = 0;
m->locks++;
runtime·semrelease(&runtime·worldsema);
#define READY ((G*)1)
#define WAIT ((G*)2)
-enum
-{
- PollBlockSize = 4*1024,
-};
-
struct PollDesc
{
PollDesc* link; // in pollcache, protected by pollcache.Lock
runtime·lock(&pollcache);
if(pollcache.first == nil) {
- n = PollBlockSize/sizeof(*pd);
+ n = PageSize/sizeof(*pd);
if(n == 0)
n = 1;
// Must be in non-GC memory because can be referenced