source: proiecte/swift/trunk/lib/hoard-371/src/heaplayers/experimental/kingsmodheap.h @ 176

Last change on this file since 176 was 176, checked in by (none), 14 years ago
  • imported repo from "guagal"
File size: 1.0 KB
Line 
1#ifndef _KINGSMODHEAP_H_
2#define _KINGSMODHEAP_H_
3
4#include "segheap.h"
5
6/* KingsMod (segregated fits) allocator */
7
8namespace KingsMod {
9
10  inline size_t class2Size (int i);
11
12  inline int pow2Class (size_t sz) {
13    static   size_t sizeTable[] = {8UL, 16UL, 24UL, 32UL, 40UL, 48UL, 56UL, 72UL, 80UL, 96UL, 120UL, 144UL, 168UL, 200UL, 240UL, 288UL, 344UL, 416UL, 496UL, 592UL, 712UL, 856UL, 1024UL, 1232UL, 1472UL, 1768UL, 2120UL, 2544UL, 3048UL, 3664UL};
14        int c = 0;
15        while (c < 30 && sz < sizeTable[c]) {
16          c++;
17        }
18        return c;
19  }
20
21  inline size_t class2Size (int i) {
22    assert (i >= 0);
23    assert (i < 30);
24    static size_t sizeTable[] = {8UL, 16UL, 24UL, 32UL, 40UL, 48UL, 56UL, 72UL, 80UL, 96UL, 120UL, 144UL, 168UL, 200UL, 240UL, 288UL, 344UL, 416UL, 496UL, 592UL, 712UL, 856UL, 1024UL, 1232UL, 1472UL, 1768UL, 2120UL, 2544UL, 3048UL, 3664UL};
25    return sizeTable[i];
26  }
27
28};
29
30
31template <class PerClassHeap>
32class KingsModHeap : public SegHeap<29, KingsMod::pow2Class, KingsMod::class2Size, PerClassHeap, PerClassHeap> {};
33
34#endif
Note: See TracBrowser for help on using the repository browser.