-
Notifications
You must be signed in to change notification settings - Fork 11
/
mm-private.h
88 lines (75 loc) · 2.05 KB
/
mm-private.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
80
81
82
83
84
85
86
87
88
// -*- c++ -*-
//
// PTLsim: Cycle Accurate x86-64 Simulator
// Memory Management (private data)
//
// Copyright 2004-2008 Matt T. Yourst <[email protected]>
//
#ifndef _MM_PRIVATE_H_
#define _MM_PRIVATE_H_
#include <globals.h>
enum {
PTL_MM_EVENT_ALLOC,
PTL_MM_EVENT_FREE,
PTL_MM_EVENT_RECLAIM_START,
PTL_MM_EVENT_RECLAIM_CALL,
PTL_MM_EVENT_RECLAIM_END,
PTL_MM_EVENT_CLEANUP,
PTL_MM_EVENT_INIT,
PTL_MM_EVENT_COUNT,
};
static const char* event_names[PTL_MM_EVENT_COUNT] = {"alloc", "free ", "rec-s", "rec-c", "rec-e", "clnup", "init "};
enum {
PTL_MM_POOL_PAGES,
PTL_MM_POOL_SLAB,
PTL_MM_POOL_GENERAL,
PTL_MM_POOL_ALL,
PTL_MM_POOL_COUNT,
};
static const char* pool_names[PTL_MM_POOL_COUNT] = {"page", "slab", "gen ", "all "};
struct MemoryManagerEvent {
W8 event;
W8 pool;
W16 slab;
W32 caller;
W32 address;
W32 bytes;
MemoryManagerEvent() { }
MemoryManagerEvent(int event, int pool, void* caller, void* address, W32 bytes, int slab = 0) {
this->event = event;
this->pool = pool;
this->caller = LO32(Waddr(caller));
this->address = LO32(Waddr(address));
this->bytes = bytes;
this->slab = slab;
}
ostream& print(ostream& os) const {
os << event_names[event], ' ';
switch (event) {
case PTL_MM_EVENT_ALLOC:
case PTL_MM_EVENT_FREE:
os << pool_names[pool], " 0x", hexstring(address, 32), ' ', intstring(bytes, 10), " bytes by caller 0x", hexstring(caller, 32);
if (pool == PTL_MM_POOL_SLAB) os << " (slab ", intstring(slab, 4), ")";
break;
case PTL_MM_EVENT_RECLAIM_START:
case PTL_MM_EVENT_RECLAIM_END:
os << bytes, " bytes";
break;
case PTL_MM_EVENT_RECLAIM_CALL:
os << "call ", (void*)address;
break;
case PTL_MM_EVENT_CLEANUP:
os << "cleanup pass";
break;
case PTL_MM_EVENT_INIT:
os << "initialize: heap range: ", (void*)caller, "-", (void*)address, " (", bytes, " bytes)";
break;
default:
abort();
break;
}
return os;
}
};
PrintOperator(MemoryManagerEvent);
#endif // _MM_PRIVATE_H_