Continued work on profiler
This commit is contained in:
parent
137687e446
commit
0d376171c8
6 changed files with 56 additions and 2 deletions
|
|
@ -15,7 +15,9 @@ namespace GC {
|
|||
MarkStart,
|
||||
ChunkMarked,
|
||||
ChunkSwept,
|
||||
ChunkFreed
|
||||
ChunkFreed,
|
||||
NewChunk,
|
||||
ReusedChunk
|
||||
};
|
||||
|
||||
using TimeStamp = chrono::_V2::system_clock::time_point;
|
||||
|
|
|
|||
|
|
@ -64,6 +64,7 @@ namespace GC {
|
|||
size_t m_size;
|
||||
size_t m_allocated_size;
|
||||
uintptr_t *m_stack_top = nullptr;
|
||||
bool m_profiler_enable = false;
|
||||
|
||||
// maybe change to std::list
|
||||
std::vector<Chunk *> m_allocated_chunks;
|
||||
|
|
@ -92,5 +93,6 @@ namespace GC {
|
|||
void collect(uint flags); // conditional collection
|
||||
void check_init(); // print dummy things
|
||||
void print_contents(); // print dummy things
|
||||
void set_profiler(bool mode);
|
||||
};
|
||||
}
|
||||
|
|
@ -27,7 +27,7 @@ namespace GC {
|
|||
return m_instance;
|
||||
}
|
||||
|
||||
inline static Profiler *m_instance;
|
||||
inline static Profiler *m_instance = nullptr;
|
||||
vector<GCEvent *> m_events;
|
||||
|
||||
public:
|
||||
|
|
|
|||
|
|
@ -28,5 +28,6 @@ namespace GC {
|
|||
|
||||
void GCEvent::printFull() {
|
||||
assert(false && "TODO: unimplemented");
|
||||
ostream s1 = cout;
|
||||
}
|
||||
}
|
||||
|
|
@ -404,4 +404,9 @@ namespace GC {
|
|||
cout << "NO FREED CHUNKS" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
void Heap::set_profiler(bool mode) {
|
||||
auto heap = Heap::the();
|
||||
heap->m_profiler_enable = mode;
|
||||
}
|
||||
}
|
||||
44
src/GC/tests/events.cpp
Normal file
44
src/GC/tests/events.cpp
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
#include <iostream>
|
||||
#include <stdio.h>
|
||||
|
||||
using namespace std;
|
||||
// broken :(
|
||||
// [event_source(native)]
|
||||
class ESource {
|
||||
public:
|
||||
__event void TestEvent(int eValue);
|
||||
};
|
||||
|
||||
// [event_receiver(native)]
|
||||
class EReceiver {
|
||||
public:
|
||||
void Handler1(int eValue) {
|
||||
cout << "Handler1 with: " << eValue << endl;
|
||||
}
|
||||
|
||||
void Handler2(int eValue) {
|
||||
cout << "Handler2 with: " << eValue << endl;
|
||||
}
|
||||
|
||||
void hookEvent(ESource *eSource) {
|
||||
__hook(&ESource::TestEvent, eSource, &EReceiver::Handler1);
|
||||
__hook(&ESource::TestEvent, eSource, &EReceiver::Handler2);
|
||||
}
|
||||
|
||||
void unhookEvent(ESource *eSource) {
|
||||
__unhook(&ESource::TestEvent, eSource, &EReceiver::Handler1);
|
||||
__unhook(&ESource::TestEvent, eSource, &EReceiver::Handler2);
|
||||
}
|
||||
};
|
||||
|
||||
int main() {
|
||||
|
||||
ESource src;
|
||||
EReceiver rcv;
|
||||
|
||||
rcv.hookEvent(&src);
|
||||
__raise src.TestEvent(12);
|
||||
rcv.unhookEvent(&src);
|
||||
|
||||
return 0;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue