Some progress on marking
This commit is contained in:
parent
5fcab54fe4
commit
fb5f283dfd
3 changed files with 51 additions and 20 deletions
|
|
@ -1,27 +1,31 @@
|
|||
#include "heap.hpp"
|
||||
#include "../include/heap.hpp"
|
||||
|
||||
GC::Heap *gc = GC::Heap::the2();
|
||||
|
||||
void init() {
|
||||
std::vector<int> live_int_vec{1, 2, 3, 4, 5};
|
||||
std::vector<int> dead_int_vec(1000000, 1);
|
||||
int *arr = static_cast<int *>(gc->alloc(sizeof(int) * 300));
|
||||
int *a_ptr;
|
||||
int a = 10;
|
||||
a_ptr = &a;
|
||||
auto temp1 = gc->alloc(sizeof(a_ptr));
|
||||
auto temp2 = gc->alloc(sizeof(live_int_vec));
|
||||
auto temp3 = gc->alloc(sizeof(dead_int_vec));
|
||||
|
||||
// *arr, *temp1, *temp2 and *temp3 should all be on the stack
|
||||
//a_ptr = nullptr;
|
||||
auto stack_start = reinterpret_cast<uintptr_t *>(__builtin_frame_address(0));
|
||||
auto stack_end = stack_start - 160;
|
||||
std::cout << "Stack start from init:\t" << stack_start << std::endl;
|
||||
std::cout << "Imaginary stack end:\t" << stack_end << std::endl;
|
||||
int *arr = static_cast<int *>(gc->alloc(sizeof(int) * 300));
|
||||
for (int i = 0; i < (sizeof(int) * 300); i++) {
|
||||
arr[i] = i;
|
||||
}
|
||||
std::cout << "First stack pointer:\t" << &arr << std::endl;
|
||||
long *l = static_cast<long *>(gc->alloc(sizeof(long)));
|
||||
*l = 20;
|
||||
// This doesn't get allocated on our heap, but how is it viewed on valgr?
|
||||
int *arr2 = new int[1000];
|
||||
for (int i = 0; i < 1000; i++) {
|
||||
arr2[i] = i;
|
||||
}
|
||||
}
|
||||
|
||||
int main() {
|
||||
//init();
|
||||
for (int i = 1; i < 10; i++) {
|
||||
gc->alloc(sizeof(i));
|
||||
}
|
||||
auto stack_start = reinterpret_cast<uintptr_t *>(__builtin_frame_address(0));
|
||||
std::cout << "Stack start from main:\t" << stack_start << std::endl;
|
||||
init();
|
||||
gc->collect(MARK | SWEEP);
|
||||
gc->print_contents();
|
||||
//delete gc;
|
||||
|
|
|
|||
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue