-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathallocator.h
More file actions
40 lines (32 loc) · 856 Bytes
/
allocator.h
File metadata and controls
40 lines (32 loc) · 856 Bytes
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
#ifndef ALLOCATOR_H
#define ALLOCATOR_H
#include "value.h"
#include"structInfo.h"
#include "frame.h"
#include <QSet>
#include <QStack>
const int MEGA_BYTE = 1024*1024;
const double HEAP_GROWTH_FACTOR = 2.0;
const double MIN_HEAP_UTILIZATION = 0.35;
const int MIN_HEAP = 1* MEGA_BYTE;
class Allocator
{
public:
Allocator();
Allocator(QStack<Frame> &p_callStack);
Value *New_Int(int p_intValue);
Value *New_String(QString p_stringValue);
Value *New_structInstacne(StructInfo p_srtuctInstance);
Value *Null();
private:
void Check_Heap_Size(int p_newObjectSize);
void Garbage_Collector();
void Mark();
void Sweep();
private:
QSet<Value*> m_heap;
int m_currentHeapSize;
int m_maxHeapSize;
QStack<Frame>& m_callStack;
};
#endif // ALLOCATOR_H