int32 runtime·mlookup(void *v, byte **base, uintptr *size, MSpan **sp) { uintptr n, i; byte *p; MSpan *s; g->m->mcache->local_nlookup++; if (sizeof(void*) == 4 && g->m->mcache->local_nlookup >= (1<<30)) { // purge cache stats to prevent overflow runtime·lock(&runtime·mheap.lock); runtime·purgecachedstats(g->m->mcache); runtime·unlock(&runtime·mheap.lock); } s = runtime·MHeap_LookupMaybe(&runtime·mheap, v); if(sp) *sp = s; if(s == nil) { if(base) *base = nil; if(size) *size = 0; return 0; } p = (byte*)((uintptr)s->start<<PageShift); if(s->sizeclass == 0) { // Large object. if(base) *base = p; if(size) *size = s->npages<<PageShift; return 1; } n = s->elemsize; if(base) { i = ((byte*)v - p)/n; *base = p + i*n; } if(size) *size = n; return 1; }
int32 runtime·mlookup ( void *v , byte **base , uintptr *size , MSpan **sp ) { uintptr n , i; byte *p; MSpan *s; #line 2214 "C:\Go\src\pkg\runtime\malloc.goc" m->mcache->local_nlookup++; s = runtime·MHeap_LookupMaybe ( &runtime·mheap , v ) ; if ( sp ) *sp = s; if ( s == nil ) { runtime·checkfreed ( v , 1 ) ; if ( base ) *base = nil; if ( size ) *size = 0; return 0; } #line 2227 "C:\Go\src\pkg\runtime\malloc.goc" p = ( byte* ) ( ( uintptr ) s->start<<PageShift ) ; if ( s->sizeclass == 0 ) { #line 2230 "C:\Go\src\pkg\runtime\malloc.goc" if ( base ) *base = p; if ( size ) *size = s->npages<<PageShift; return 1; } #line 2237 "C:\Go\src\pkg\runtime\malloc.goc" if ( ( byte* ) v >= ( byte* ) s->limit ) { #line 2239 "C:\Go\src\pkg\runtime\malloc.goc" return 0; } #line 2242 "C:\Go\src\pkg\runtime\malloc.goc" n = runtime·class_to_size[s->sizeclass]; if ( base ) { i = ( ( byte* ) v - p ) /n; *base = p + i*n; } if ( size ) *size = n; #line 2250 "C:\Go\src\pkg\runtime\malloc.goc" return 1; }