2011-02-15 Tobias Burnus <burnus@net-b.de>
[official-gcc.git] / libgo / runtime / mheapmap32.h
blob2861624690f1afe97fd3f0cabbdfed969a3a6d44
1 // Copyright 2009 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
5 // Free(v) must be able to determine the MSpan containing v.
6 // The MHeapMap is a 2-level radix tree mapping page numbers to MSpans.
8 typedef struct MHeapMapNode2 MHeapMapNode2;
10 enum
12 // 32 bit address - 12 bit page size = 20 bits to map
13 MHeapMap_Level1Bits = 10,
14 MHeapMap_Level2Bits = 10,
16 MHeapMap_TotalBits =
17 MHeapMap_Level1Bits +
18 MHeapMap_Level2Bits,
20 MHeapMap_Level1Mask = (1<<MHeapMap_Level1Bits) - 1,
21 MHeapMap_Level2Mask = (1<<MHeapMap_Level2Bits) - 1,
24 struct MHeapMap
26 void *(*allocator)(uintptr);
27 MHeapMapNode2 *p[1<<MHeapMap_Level1Bits];
30 struct MHeapMapNode2
32 MSpan *s[1<<MHeapMap_Level2Bits];
35 void runtime_MHeapMap_Init(MHeapMap *m, void *(*allocator)(uintptr));
36 bool runtime_MHeapMap_Preallocate(MHeapMap *m, PageID k, uintptr npages);
37 MSpan* runtime_MHeapMap_Get(MHeapMap *m, PageID k);
38 MSpan* runtime_MHeapMap_GetMaybe(MHeapMap *m, PageID k);
39 void runtime_MHeapMap_Set(MHeapMap *m, PageID k, MSpan *v);