-
Notifications
You must be signed in to change notification settings - Fork 5
/
SmashHeap.h
79 lines (67 loc) · 2.52 KB
/
SmashHeap.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#include "heaps/top/all.h"
#include "heaps/utility/all.h"
#include "utility/all.h"
#include "wrappers/all.h"
#include "heaplayers.h"
#include <unordered_map>
#include <vector>
#include <list>
#include <forward_list>
#include <unordered_set>
#include <set>
#include <queue>
#include "utility/all.h"
#include "heaps/objectrep/sizeheap.h"
#include "heaps/general/kingsleyheap.h"
#include "heaps/debug/debugheap.h"
#include "heaps/threads/lockedheap.h"
#define MAX_WORKING_SET_SIZE 1000 //Size of Working Set
#define COLD_SET_THRESHOLD 100 //Threshold size of Cold Set per size class
namespace SmashSTL {
//STL classes for Smash. You should use these instead of C++ default STL.
//These data structures uses their own heap for allocation, instead of malloc/free.
//You are free to add more C++ STL classes if needed.
class InternalTopHeap : public HL::SizeHeap<HL::BumpAlloc<16384 * 1024, HL::MmapHeap, 16>> {
private:
typedef HL::SizeHeap<HL::BumpAlloc<16384 * 1024, HL::MmapHeap, 16>> SuperHeap;
public:
};
class InternalHeap : public HL::ExactlyOneHeap<HL::LockedHeap<HL::PosixLockType, HL::DebugHeap<HL::KingsleyHeap<HL::FreelistHeap<InternalTopHeap>, HL::MmapHeap>>>> {
protected:
typedef HL::ExactlyOneHeap<HL::LockedHeap<HL::PosixLockType, HL::DebugHeap<HL::KingsleyHeap<HL::FreelistHeap<InternalTopHeap>, HL::MmapHeap>>>>
SuperHeap;
public:
InternalHeap() : SuperHeap() {
static_assert(Alignment % 16 == 0, "16-byte alignment");
}
};
template <typename K, typename V>
using unordered_map = std::unordered_map<K, V, std::hash<K>, std::equal_to<K>, HL::STLAllocator<pair<const K, V>, InternalHeap>>;
template <typename K>
using unordered_set = std::unordered_set<K, std::hash<K>, std::equal_to<K>, HL::STLAllocator<K, InternalHeap>>;
template <class T, class Compare=less<T>>
using set = std::set<T, Compare, HL::STLAllocator<T, InternalHeap>>;
template <typename T>
using list = std::list<T, HL::STLAllocator<T, InternalHeap>>;
template <typename T>
using forward_list = std::forward_list<T, HL::STLAllocator<T, InternalHeap>>;
template <typename T>
using deque = std::deque<T, HL::STLAllocator<T, InternalHeap>>;
template <typename T>
using queue = std::queue<T, deque<T>>;
template <typename T>
using vector = std::vector<T, HL::STLAllocator<T, InternalHeap>>;
};
class SmashHeap {
public:
SmashHeap () {
//Implement
}
void* malloc (size_t size) {
//Implement malloc here
return nullptr;
}
void free (void* ptr) {
//Implement free
}
};