1 //===-- jitcs_memmgr.h - A memory manager for code and data -----*- C++ -*-===//
3 // The manager is an allocator based on Doug Leah's malloc. Memory is allocated
4 // from the system with execution permission.
7 //===----------------------------------------------------------------------===//
9 #ifndef _JITCS_MEMMGR_H_
10 #define _JITCS_MEMMGR_H_
12 #include "jitcs_base.h"
21 u8
* start
; size_t size
;
22 static Space
Make(u8
* s
, size_t sz
) { Space ps
; ps
.start
= s
; ps
.size
= sz
; return ps
; }
33 * allocate area for function relevant constants (aligned to 16 byte)
34 * allocate area for code (aligned to cache line size, currently 64 byte)
35 * allocated areas are stored in a function object, function objects can be forced to free allocated storage
37 CodeAndData
allocate(size_t data
, size_t code
);
38 void deallocate(CodeAndData
);
41 size_t getTotalSpace();
42 size_t getAllocatedSpace();
43 size_t getFreeSpace();
44 size_t getReachableFreeSpace();
48 std::unique_ptr
<MemoryMgrImpl
> _mgr
;
51 } // end of namespace jitcs