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
;
12 // 32 bit address - 12 bit page size = 20 bits to map
13 MHeapMap_Level1Bits
= 10,
14 MHeapMap_Level2Bits
= 10,
20 MHeapMap_Level1Mask
= (1<<MHeapMap_Level1Bits
) - 1,
21 MHeapMap_Level2Mask
= (1<<MHeapMap_Level2Bits
) - 1,
26 void *(*allocator
)(uintptr
);
27 MHeapMapNode2
*p
[1<<MHeapMap_Level1Bits
];
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
);