Cleaned up include guards
This commit is contained in:
parent
cdca49354a
commit
c9e2bc2278
7 changed files with 16 additions and 48 deletions
|
|
@ -7,9 +7,9 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// #define DEBUG
|
// #define WRAPPER_DEBUG
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef WRAPPER_DEBUG
|
||||||
typedef struct cheap
|
typedef struct cheap
|
||||||
{
|
{
|
||||||
void *obj;
|
void *obj;
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
#include <iostream>
|
|
||||||
#include <list>
|
|
||||||
#include <time.h>
|
|
||||||
|
|
||||||
#include "chunk.hpp"
|
#include "chunk.hpp"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,5 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
#include <iostream>
|
|
||||||
#include <setjmp.h>
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
|
@ -11,7 +8,7 @@
|
||||||
|
|
||||||
#define HEAP_SIZE 2097152 //65536
|
#define HEAP_SIZE 2097152 //65536
|
||||||
#define FREE_THRESH (uint) 100000
|
#define FREE_THRESH (uint) 100000
|
||||||
#define DEBUG
|
// #define HEAP_DEBUG
|
||||||
|
|
||||||
namespace GC
|
namespace GC
|
||||||
{
|
{
|
||||||
|
|
@ -89,7 +86,7 @@ namespace GC
|
||||||
Heap(Heap const&) = delete;
|
Heap(Heap const&) = delete;
|
||||||
Heap& operator=(Heap const&) = delete;
|
Heap& operator=(Heap const&) = delete;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef HEAP_DEBUG
|
||||||
void collect(CollectOption flags); // conditional collection
|
void collect(CollectOption flags); // conditional collection
|
||||||
void check_init(); // print dummy things
|
void check_init(); // print dummy things
|
||||||
void print_contents(); // print dummy things
|
void print_contents(); // print dummy things
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "chunk.hpp"
|
#include "chunk.hpp"
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <iostream>
|
||||||
|
|
||||||
#include "heap.hpp"
|
#include "heap.hpp"
|
||||||
#include "cheap.h"
|
#include "cheap.h"
|
||||||
|
|
||||||
#ifndef DEBUG
|
#ifndef WRAPPER_DEBUG
|
||||||
struct cheap
|
struct cheap
|
||||||
{
|
{
|
||||||
void *obj;
|
void *obj;
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,3 @@
|
||||||
// #include <chrono>
|
|
||||||
// #include <iostream>
|
|
||||||
// #include <list>
|
|
||||||
|
|
||||||
#include "chunk.hpp"
|
#include "chunk.hpp"
|
||||||
#include "event.hpp"
|
#include "event.hpp"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,4 @@
|
||||||
#include <algorithm>
|
|
||||||
#include <assert.h>
|
|
||||||
#include <cstring>
|
|
||||||
#include <execinfo.h>
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <setjmp.h>
|
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
@ -83,7 +78,8 @@ namespace GC
|
||||||
{
|
{
|
||||||
heap.collect();
|
heap.collect();
|
||||||
// If memory is not enough after collect, crash with OOM error
|
// If memory is not enough after collect, crash with OOM error
|
||||||
throw std::runtime_error(std::string("Error: Heap out of memory"));
|
if (heap.m_size + size > HEAP_SIZE)
|
||||||
|
throw std::runtime_error(std::string("Error: Heap out of memory"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// If a chunk was recycled, return the old chunk address
|
// If a chunk was recycled, return the old chunk address
|
||||||
|
|
@ -159,25 +155,6 @@ namespace GC
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Advances an iterator and returns an element
|
|
||||||
* at position `n`.
|
|
||||||
*
|
|
||||||
* @param list The list to retrieve an element from.
|
|
||||||
*
|
|
||||||
* @param n The position to retrieve an element at.
|
|
||||||
*
|
|
||||||
* @returns The pointer to the chunk at position n in list.
|
|
||||||
*/
|
|
||||||
// Chunk *Heap::get_at(std::vector<Chunk *> &list, size_t n)
|
|
||||||
// {
|
|
||||||
// auto iter = list.begin();
|
|
||||||
// if (!n)
|
|
||||||
// return *iter;
|
|
||||||
// std::advance(iter, n);
|
|
||||||
// return *iter;
|
|
||||||
// }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a bool whether the profiler is enabled
|
* Returns a bool whether the profiler is enabled
|
||||||
* or not.
|
* or not.
|
||||||
|
|
@ -414,7 +391,13 @@ namespace GC
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG
|
void Heap::set_profiler(bool mode)
|
||||||
|
{
|
||||||
|
Heap &heap = Heap::the();
|
||||||
|
heap.m_profiler_enable = mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef HEAP_DEBUG
|
||||||
/**
|
/**
|
||||||
* Prints the result of Heap::init() and a dummy value
|
* Prints the result of Heap::init() and a dummy value
|
||||||
* for the current stack frame for reference.
|
* for the current stack frame for reference.
|
||||||
|
|
@ -565,12 +548,6 @@ namespace GC
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Heap::set_profiler(bool mode)
|
|
||||||
{
|
|
||||||
Heap &heap = Heap::the();
|
|
||||||
heap.m_profiler_enable = mode;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Heap::print_allocated_chunks(Heap *heap) {
|
void Heap::print_allocated_chunks(Heap *heap) {
|
||||||
cout << "--- Allocated Chunks ---\n" << endl;
|
cout << "--- Allocated Chunks ---\n" << endl;
|
||||||
for (auto chunk : heap->m_allocated_chunks) {
|
for (auto chunk : heap->m_allocated_chunks) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue