Some spring cleaning
This commit is contained in:
parent
78ccade17d
commit
91f241dba2
6 changed files with 26 additions and 26 deletions
|
|
@ -43,9 +43,9 @@ namespace GC
|
||||||
m_chunk = chunk;
|
m_chunk = chunk;
|
||||||
}
|
}
|
||||||
|
|
||||||
GCEventType getType();
|
GCEventType get_type();
|
||||||
std::time_t getTimeStamp();
|
std::time_t get_time_stamp();
|
||||||
Chunk *getChunk();
|
Chunk *get_chunk();
|
||||||
const char *TypeToString();
|
const char *type_to_string();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
@ -47,7 +47,7 @@ namespace GC
|
||||||
return m_instance;
|
return m_instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline static Chunk *getAt(std::vector<Chunk *> &list, size_t n)
|
inline static Chunk *get_at(std::vector<Chunk *> &list, size_t n)
|
||||||
{
|
{
|
||||||
auto iter = list.begin();
|
auto iter = list.begin();
|
||||||
if (!n)
|
if (!n)
|
||||||
|
|
@ -56,7 +56,7 @@ namespace GC
|
||||||
return *iter;
|
return *iter;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline static bool getProfilerMode() {
|
inline static bool get_profiler_mode() {
|
||||||
auto heap = Heap::the();
|
auto heap = Heap::the();
|
||||||
return heap->m_profiler_enable;
|
return heap->m_profiler_enable;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,12 +23,12 @@ namespace GC {
|
||||||
inline static Profiler *m_instance = nullptr;
|
inline static Profiler *m_instance = nullptr;
|
||||||
std::vector<GCEvent *> m_events;
|
std::vector<GCEvent *> m_events;
|
||||||
|
|
||||||
std::ofstream createFileStream();
|
std::ofstream create_file_stream();
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static void record(GCEventType type);
|
static void record(GCEventType type);
|
||||||
static void record(GCEventType type, Chunk *chunk);
|
static void record(GCEventType type, Chunk *chunk);
|
||||||
static void dumpTrace();
|
static void dump_trace();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
@ -9,23 +9,23 @@
|
||||||
namespace GC
|
namespace GC
|
||||||
{
|
{
|
||||||
|
|
||||||
GCEventType GCEvent::getType()
|
GCEventType GCEvent::get_type()
|
||||||
{
|
{
|
||||||
return m_type;
|
return m_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::time_t GCEvent::getTimeStamp()
|
std::time_t GCEvent::get_time_stamp()
|
||||||
{
|
{
|
||||||
return m_timestamp;
|
return m_timestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
Chunk *GCEvent::getChunk()
|
Chunk *GCEvent::get_chunk()
|
||||||
{
|
{
|
||||||
return m_chunk;
|
return m_chunk;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try to remove inline
|
// Try to remove inline
|
||||||
const char *GCEvent::TypeToString()
|
const char *GCEvent::type_to_string()
|
||||||
{
|
{
|
||||||
switch (m_type)
|
switch (m_type)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -107,7 +107,7 @@ namespace GC
|
||||||
// Check if there are any freed chunks large enough for current request
|
// Check if there are any freed chunks large enough for current request
|
||||||
for (size_t i = 0; i < heap->m_freed_chunks.size(); i++)
|
for (size_t i = 0; i < heap->m_freed_chunks.size(); i++)
|
||||||
{
|
{
|
||||||
auto chunk = getAt(heap->m_freed_chunks, i);
|
auto chunk = Heap::get_at(heap->m_freed_chunks, i);
|
||||||
auto iter = heap->m_freed_chunks.begin();
|
auto iter = heap->m_freed_chunks.begin();
|
||||||
advance(iter, i);
|
advance(iter, i);
|
||||||
if (chunk->size > size)
|
if (chunk->size > size)
|
||||||
|
|
@ -177,7 +177,7 @@ namespace GC
|
||||||
void Heap::mark(uintptr_t *start, const uintptr_t *end, vector<Chunk *> &worklist)
|
void Heap::mark(uintptr_t *start, const uintptr_t *end, vector<Chunk *> &worklist)
|
||||||
{
|
{
|
||||||
cout << "--- mark() was called ---\n" << endl;
|
cout << "--- mark() was called ---\n" << endl;
|
||||||
if (getProfilerMode())
|
if (Heap::get_profiler_mode())
|
||||||
Profiler::record(MarkStart);
|
Profiler::record(MarkStart);
|
||||||
// To find adresses thats in the worklist
|
// To find adresses thats in the worklist
|
||||||
for (; start <= end; start++)
|
for (; start <= end; start++)
|
||||||
|
|
@ -204,7 +204,7 @@ namespace GC
|
||||||
|
|
||||||
if (!chunk->marked)
|
if (!chunk->marked)
|
||||||
{
|
{
|
||||||
if (getProfilerMode())
|
if (Heap::get_profiler_mode())
|
||||||
Profiler::record(ChunkMarked, chunk);
|
Profiler::record(ChunkMarked, chunk);
|
||||||
chunk->marked = true;
|
chunk->marked = true;
|
||||||
cout << "Marked this chunk ^\n" << endl;
|
cout << "Marked this chunk ^\n" << endl;
|
||||||
|
|
@ -356,13 +356,13 @@ namespace GC
|
||||||
std::vector<Chunk *> filtered;
|
std::vector<Chunk *> filtered;
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
// filtered.push_back(heap->m_freed_chunks.at(i++));
|
// filtered.push_back(heap->m_freed_chunks.at(i++));
|
||||||
filtered.push_back(getAt(heap->m_freed_chunks, i++));
|
filtered.push_back(Heap::get_at(heap->m_freed_chunks, i++));
|
||||||
cout << filtered.back()->start << endl;
|
cout << filtered.back()->start << endl;
|
||||||
for (; i < heap->m_freed_chunks.size(); i++)
|
for (; i < heap->m_freed_chunks.size(); i++)
|
||||||
{
|
{
|
||||||
auto prev = filtered.back();
|
auto prev = filtered.back();
|
||||||
// auto next = heap->m_freed_chunks.at(i);
|
// auto next = heap->m_freed_chunks.at(i);
|
||||||
auto next = getAt(heap->m_freed_chunks, i);
|
auto next = Heap::get_at(heap->m_freed_chunks, i);
|
||||||
auto p_start = (uintptr_t)(prev->start);
|
auto p_start = (uintptr_t)(prev->start);
|
||||||
auto p_size = (uintptr_t)(prev->size);
|
auto p_size = (uintptr_t)(prev->size);
|
||||||
auto n_start = (uintptr_t)(next->start);
|
auto n_start = (uintptr_t)(next->start);
|
||||||
|
|
@ -398,7 +398,7 @@ namespace GC
|
||||||
{
|
{
|
||||||
set_profiler(true);
|
set_profiler(true);
|
||||||
|
|
||||||
if (getProfilerMode())
|
if (Heap::get_profiler_mode())
|
||||||
Profiler::record(CollectStart);
|
Profiler::record(CollectStart);
|
||||||
|
|
||||||
cout << "DEBUG COLLECT\nFLAGS: ";
|
cout << "DEBUG COLLECT\nFLAGS: ";
|
||||||
|
|
|
||||||
|
|
@ -26,13 +26,13 @@ namespace GC
|
||||||
profiler->m_events.push_back(event);
|
profiler->m_events.push_back(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Profiler::dumpTrace()
|
void Profiler::dump_trace()
|
||||||
{
|
{
|
||||||
auto profiler = Profiler::the();
|
auto profiler = Profiler::the();
|
||||||
auto start = profiler->m_events.begin();
|
auto start = profiler->m_events.begin();
|
||||||
auto end = profiler->m_events.end();
|
auto end = profiler->m_events.end();
|
||||||
|
|
||||||
std::ofstream fstr = profiler->createFileStream();
|
std::ofstream fstr = profiler->create_file_stream();
|
||||||
char buffer[22];
|
char buffer[22];
|
||||||
std::tm *btm;
|
std::tm *btm;
|
||||||
std::time_t tt;
|
std::time_t tt;
|
||||||
|
|
@ -42,15 +42,15 @@ namespace GC
|
||||||
{
|
{
|
||||||
auto event = *start++;
|
auto event = *start++;
|
||||||
|
|
||||||
tt = event->getTimeStamp();
|
tt = event->get_time_stamp();
|
||||||
btm = std::localtime(&tt);
|
btm = std::localtime(&tt);
|
||||||
std::strftime(buffer, 22, "%a %T", btm);
|
std::strftime(buffer, 22, "%a %T", btm);
|
||||||
|
|
||||||
fstr << "--------------------------------\n"
|
fstr << "--------------------------------\n"
|
||||||
<< buffer
|
<< buffer
|
||||||
<< "\nEvent:\t" << event->TypeToString();
|
<< "\nEvent:\t" << event->type_to_string();
|
||||||
|
|
||||||
chunk = event->getChunk();
|
chunk = event->get_chunk();
|
||||||
|
|
||||||
if (chunk) {
|
if (chunk) {
|
||||||
fstr << "\nChunk:\t" << chunk->start
|
fstr << "\nChunk:\t" << chunk->start
|
||||||
|
|
@ -61,7 +61,7 @@ namespace GC
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::ofstream Profiler::createFileStream()
|
std::ofstream Profiler::create_file_stream()
|
||||||
{
|
{
|
||||||
std::time_t tt = std::time(NULL);
|
std::time_t tt = std::time(NULL);
|
||||||
std::tm *ptm = std::localtime(&tt);
|
std::tm *ptm = std::localtime(&tt);
|
||||||
|
|
@ -69,8 +69,8 @@ namespace GC
|
||||||
std::strftime(buffer, 32, "/profiler/log_%a_%H_%M_%S.txt", ptm);
|
std::strftime(buffer, 32, "/profiler/log_%a_%H_%M_%S.txt", ptm);
|
||||||
std::string filename(buffer);
|
std::string filename(buffer);
|
||||||
|
|
||||||
//const std::string ABS_PATH = "/home/virre/dev/systemF/org/language/src/GC/";
|
const std::string ABS_PATH = "/home/virre/dev/systemF/org/language/src/GC/";
|
||||||
const std::string ABS_PATH = "/Users/valtermiari/Desktop/DV/Bachelors/code/language/src/GC";
|
// const std::string ABS_PATH = "/Users/valtermiari/Desktop/DV/Bachelors/code/language/src/GC";
|
||||||
std::string fullpath = ABS_PATH + filename;
|
std::string fullpath = ABS_PATH + filename;
|
||||||
|
|
||||||
std::ofstream fstr(fullpath);
|
std::ofstream fstr(fullpath);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue