From 91f241dba249804c5a3b5b6240965e704b59dd98 Mon Sep 17 00:00:00 2001 From: Victor Olin Date: Sun, 19 Mar 2023 15:16:41 +0100 Subject: [PATCH] Some spring cleaning --- src/GC/include/event.hpp | 8 ++++---- src/GC/include/heap.hpp | 4 ++-- src/GC/include/profiler.hpp | 4 ++-- src/GC/lib/event.cpp | 8 ++++---- src/GC/lib/heap.cpp | 12 ++++++------ src/GC/lib/profiler.cpp | 16 ++++++++-------- 6 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/GC/include/event.hpp b/src/GC/include/event.hpp index ac215b3..26fdf99 100644 --- a/src/GC/include/event.hpp +++ b/src/GC/include/event.hpp @@ -43,9 +43,9 @@ namespace GC m_chunk = chunk; } - GCEventType getType(); - std::time_t getTimeStamp(); - Chunk *getChunk(); - const char *TypeToString(); + GCEventType get_type(); + std::time_t get_time_stamp(); + Chunk *get_chunk(); + const char *type_to_string(); }; } \ No newline at end of file diff --git a/src/GC/include/heap.hpp b/src/GC/include/heap.hpp index 0b97d88..0994aa7 100644 --- a/src/GC/include/heap.hpp +++ b/src/GC/include/heap.hpp @@ -47,7 +47,7 @@ namespace GC return m_instance; } - inline static Chunk *getAt(std::vector &list, size_t n) + inline static Chunk *get_at(std::vector &list, size_t n) { auto iter = list.begin(); if (!n) @@ -56,7 +56,7 @@ namespace GC return *iter; } - inline static bool getProfilerMode() { + inline static bool get_profiler_mode() { auto heap = Heap::the(); return heap->m_profiler_enable; } diff --git a/src/GC/include/profiler.hpp b/src/GC/include/profiler.hpp index 4567082..882293b 100644 --- a/src/GC/include/profiler.hpp +++ b/src/GC/include/profiler.hpp @@ -23,12 +23,12 @@ namespace GC { inline static Profiler *m_instance = nullptr; std::vector m_events; - std::ofstream createFileStream(); + std::ofstream create_file_stream(); public: static void record(GCEventType type); static void record(GCEventType type, Chunk *chunk); - static void dumpTrace(); + static void dump_trace(); }; } \ No newline at end of file diff --git a/src/GC/lib/event.cpp b/src/GC/lib/event.cpp index 9387e49..e031382 100644 --- a/src/GC/lib/event.cpp +++ b/src/GC/lib/event.cpp @@ -9,23 +9,23 @@ namespace GC { - GCEventType GCEvent::getType() + GCEventType GCEvent::get_type() { return m_type; } - std::time_t GCEvent::getTimeStamp() + std::time_t GCEvent::get_time_stamp() { return m_timestamp; } - Chunk *GCEvent::getChunk() + Chunk *GCEvent::get_chunk() { return m_chunk; } // Try to remove inline - const char *GCEvent::TypeToString() + const char *GCEvent::type_to_string() { switch (m_type) { diff --git a/src/GC/lib/heap.cpp b/src/GC/lib/heap.cpp index 6969fc9..bc4f593 100644 --- a/src/GC/lib/heap.cpp +++ b/src/GC/lib/heap.cpp @@ -107,7 +107,7 @@ namespace GC // Check if there are any freed chunks large enough for current request 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(); advance(iter, i); if (chunk->size > size) @@ -177,7 +177,7 @@ namespace GC void Heap::mark(uintptr_t *start, const uintptr_t *end, vector &worklist) { cout << "--- mark() was called ---\n" << endl; - if (getProfilerMode()) + if (Heap::get_profiler_mode()) Profiler::record(MarkStart); // To find adresses thats in the worklist for (; start <= end; start++) @@ -204,7 +204,7 @@ namespace GC if (!chunk->marked) { - if (getProfilerMode()) + if (Heap::get_profiler_mode()) Profiler::record(ChunkMarked, chunk); chunk->marked = true; cout << "Marked this chunk ^\n" << endl; @@ -356,13 +356,13 @@ namespace GC std::vector filtered; size_t i = 0; // 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; for (; i < heap->m_freed_chunks.size(); i++) { auto prev = filtered.back(); // 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_size = (uintptr_t)(prev->size); auto n_start = (uintptr_t)(next->start); @@ -398,7 +398,7 @@ namespace GC { set_profiler(true); - if (getProfilerMode()) + if (Heap::get_profiler_mode()) Profiler::record(CollectStart); cout << "DEBUG COLLECT\nFLAGS: "; diff --git a/src/GC/lib/profiler.cpp b/src/GC/lib/profiler.cpp index 94a435b..f695fcc 100644 --- a/src/GC/lib/profiler.cpp +++ b/src/GC/lib/profiler.cpp @@ -26,13 +26,13 @@ namespace GC profiler->m_events.push_back(event); } - void Profiler::dumpTrace() + void Profiler::dump_trace() { auto profiler = Profiler::the(); auto start = profiler->m_events.begin(); auto end = profiler->m_events.end(); - std::ofstream fstr = profiler->createFileStream(); + std::ofstream fstr = profiler->create_file_stream(); char buffer[22]; std::tm *btm; std::time_t tt; @@ -42,15 +42,15 @@ namespace GC { auto event = *start++; - tt = event->getTimeStamp(); + tt = event->get_time_stamp(); btm = std::localtime(&tt); std::strftime(buffer, 22, "%a %T", btm); fstr << "--------------------------------\n" << buffer - << "\nEvent:\t" << event->TypeToString(); + << "\nEvent:\t" << event->type_to_string(); - chunk = event->getChunk(); + chunk = event->get_chunk(); if (chunk) { 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::tm *ptm = std::localtime(&tt); @@ -69,8 +69,8 @@ namespace GC std::strftime(buffer, 32, "/profiler/log_%a_%H_%M_%S.txt", ptm); std::string filename(buffer); - //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 = "/home/virre/dev/systemF/org/language/src/GC/"; + // const std::string ABS_PATH = "/Users/valtermiari/Desktop/DV/Bachelors/code/language/src/GC"; std::string fullpath = ABS_PATH + filename; std::ofstream fstr(fullpath);