mirror of
https://github.com/corda/corda.git
synced 2025-01-01 10:46:46 +00:00
61 lines
1.1 KiB
C++
61 lines
1.1 KiB
C++
#ifndef HEAP_H
|
|
#define HEAP_H
|
|
|
|
#include "system.h"
|
|
|
|
namespace vm {
|
|
|
|
class Heap {
|
|
public:
|
|
enum CollectionType {
|
|
MinorCollection,
|
|
MajorCollection
|
|
};
|
|
|
|
enum Status {
|
|
Null,
|
|
Reachable,
|
|
Unreachable,
|
|
Tenured
|
|
};
|
|
|
|
class Visitor {
|
|
public:
|
|
virtual ~Visitor() { }
|
|
virtual void visit(void*) = 0;
|
|
};
|
|
|
|
class Walker {
|
|
public:
|
|
virtual ~Walker() { }
|
|
virtual bool visit(unsigned) = 0;
|
|
};
|
|
|
|
class Client {
|
|
public:
|
|
virtual ~Client() { }
|
|
virtual void visitRoots(Visitor*) = 0;
|
|
virtual unsigned sizeInWords(void*) = 0;
|
|
virtual unsigned copiedSizeInWords(void*) = 0;
|
|
virtual void copy(void*, void*) = 0;
|
|
virtual void walk(void*, Walker*) = 0;
|
|
};
|
|
|
|
virtual ~Heap() { }
|
|
virtual void collect(CollectionType type, Client* client, unsigned footprint)
|
|
= 0;
|
|
virtual bool needsMark(void* p) = 0;
|
|
virtual void mark(void* p) = 0;
|
|
virtual void pad(void* p, unsigned extra) = 0;
|
|
virtual void* follow(void* p) = 0;
|
|
virtual Status status(void* p) = 0;
|
|
virtual CollectionType collectionType() = 0;
|
|
virtual void dispose() = 0;
|
|
};
|
|
|
|
Heap* makeHeap(System* system);
|
|
|
|
} // namespace vm
|
|
|
|
#endif//HEAP_H
|