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

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

Issue 4118042: code review 4118042: runtime: simpler heap map, memory allocation (Closed)
Left Patch Set: Created 14 years, 1 month ago
Right Patch Set: code review 4118042: runtime: simpler heap map, memory allocation Created 14 years, 1 month 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.c ('k') | src/pkg/runtime/mheapmap32.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 // Page heap. 5 // Page heap.
6 // 6 //
7 // See malloc.h for overview. 7 // See malloc.h for overview.
8 // 8 //
9 // When a MSpan is in the heap free list, state == MSpanFree 9 // When a MSpan is in the heap free list, state == MSpanFree
10 // and heapmap(s->start) == span, heapmap(s->start+s->npages-1) == span. 10 // and heapmap(s->start) == span, heapmap(s->start+s->npages-1) == span.
(...skipping 17 matching lines...) Expand all
28 MSpan *s; 28 MSpan *s;
29 29
30 h = vh; 30 h = vh;
31 s = (MSpan*)p; 31 s = (MSpan*)p;
32 s->allnext = h->allspans; 32 s->allnext = h->allspans;
33 h->allspans = s; 33 h->allspans = s;
34 } 34 }
35 35
36 // Initialize the heap; fetch memory using alloc. 36 // Initialize the heap; fetch memory using alloc.
37 void 37 void
38 runtime·MHeap_Init(MHeap *h, void *(*alloc)(void*, uintptr)) 38 runtime·MHeap_Init(MHeap *h, void *(*alloc)(uintptr))
39 { 39 {
40 uint32 i; 40 uint32 i;
41 41
42 runtime·FixAlloc_Init(&h->spanalloc, sizeof(MSpan), alloc, RecordSpan, h ); 42 runtime·FixAlloc_Init(&h->spanalloc, sizeof(MSpan), alloc, RecordSpan, h );
43 runtime·FixAlloc_Init(&h->cachealloc, sizeof(MCache), alloc, nil, nil); 43 runtime·FixAlloc_Init(&h->cachealloc, sizeof(MCache), alloc, nil, nil);
44 // h->mapcache needs no init 44 // h->mapcache needs no init
45 for(i=0; i<nelem(h->free); i++) 45 for(i=0; i<nelem(h->free); i++)
46 runtime·MSpanList_Init(&h->free[i]); 46 runtime·MSpanList_Init(&h->free[i]);
47 runtime·MSpanList_Init(&h->large); 47 runtime·MSpanList_Init(&h->large);
48 for(i=0; i<nelem(h->central); i++) 48 for(i=0; i<nelem(h->central); i++)
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 void 370 void
371 runtime·MSpanList_Insert(MSpan *list, MSpan *span) 371 runtime·MSpanList_Insert(MSpan *list, MSpan *span)
372 { 372 {
373 if(span->next != nil || span->prev != nil) 373 if(span->next != nil || span->prev != nil)
374 runtime·throw("MSpanList_Insert"); 374 runtime·throw("MSpanList_Insert");
375 span->next = list->next; 375 span->next = list->next;
376 span->prev = list; 376 span->prev = list;
377 span->next->prev = span; 377 span->next->prev = span;
378 span->prev->next = span; 378 span->prev->next = span;
379 } 379 }
LEFTRIGHT

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