Added Hash map marking
This commit is contained in:
parent
cdca49354a
commit
74e02826e6
8 changed files with 109 additions and 33 deletions
|
|
@ -11,7 +11,7 @@ struct Node {
|
|||
};
|
||||
|
||||
Node *create_chain(int depth) {
|
||||
cout << "entering create_chain";
|
||||
cout << "entering create_chain" << endl;
|
||||
std::vector<Node*> nodes;
|
||||
if (depth > 0) {
|
||||
Node *last_node = static_cast<Node *>(GC::Heap::alloc(sizeof(Node)));
|
||||
|
|
@ -36,14 +36,14 @@ void create_array(size_t size) {
|
|||
}
|
||||
|
||||
void detach_pointer(long **ptr) {
|
||||
cout << "entering detach_pointer";
|
||||
cout << "entering detach_pointer" << endl;
|
||||
long *dummy_ptr = nullptr;
|
||||
*ptr = dummy_ptr;
|
||||
cout << "\nexiting detach_pointer" << endl;
|
||||
}
|
||||
|
||||
Node *test_chain(int depth, bool detach) {
|
||||
cout << "entering test_chain";
|
||||
cout << "entering test_chain" << endl;
|
||||
auto stack_start = reinterpret_cast<uintptr_t *>(__builtin_frame_address(0));
|
||||
|
||||
Node *node_chain = create_chain(depth);
|
||||
|
|
@ -85,9 +85,8 @@ int main() {
|
|||
|
||||
Node *root1 = static_cast<Node *>(gc.alloc(sizeof(Node)));
|
||||
Node *root2 = static_cast<Node *>(gc.alloc(sizeof(Node)));
|
||||
root1 = test_chain(58000, false);
|
||||
root2 = test_chain(58000, false);
|
||||
|
||||
root1 = test_chain(100000, false);
|
||||
//root2 = test_chain(58000, false);
|
||||
|
||||
gc.collect(GC::COLLECT_ALL);
|
||||
auto end = std::chrono::high_resolution_clock::now();
|
||||
|
|
|
|||
20
src/GC/tests/h_test.out.dSYM/Contents/Info.plist
Normal file
20
src/GC/tests/h_test.out.dSYM/Contents/Info.plist
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>English</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>com.apple.xcode.dsym.h_test.out</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>dSYM</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1</string>
|
||||
</dict>
|
||||
</plist>
|
||||
BIN
src/GC/tests/h_test.out.dSYM/Contents/Resources/DWARF/h_test.out
Normal file
BIN
src/GC/tests/h_test.out.dSYM/Contents/Resources/DWARF/h_test.out
Normal file
Binary file not shown.
|
|
@ -12,17 +12,7 @@ typedef struct node {
|
|||
Node *HEAD = NULL;
|
||||
Node *CURRENT = NULL;
|
||||
|
||||
// Creates a linked list of length depth. Global head "HEAD" is updated.
|
||||
void *create_linked_list(int depth) {
|
||||
HEAD = (Node*)(cheap_alloc(sizeof(Node)));
|
||||
HEAD->id = 0;
|
||||
// Purposely omitting adding a child to "last_node", since its the last node
|
||||
for (int i = 1; i < depth - 1; i++) {
|
||||
insert_first(i);
|
||||
}
|
||||
}
|
||||
|
||||
void *insert_first(int node_id) {
|
||||
void insert_first(int node_id) {
|
||||
Node *new_head;
|
||||
new_head = (Node*)(cheap_alloc(sizeof(Node)));
|
||||
new_head->id = node_id;
|
||||
|
|
@ -31,15 +21,33 @@ void *insert_first(int node_id) {
|
|||
HEAD = new_head;
|
||||
}
|
||||
|
||||
void test_linked_list(int list_length){
|
||||
// Creates a linked list of length depth. Global head "HEAD" is updated.
|
||||
Node *create_linked_list(int depth) {
|
||||
HEAD = (Node*)(cheap_alloc(sizeof(Node)));
|
||||
HEAD->id = 0;
|
||||
// Purposely omitting adding a child to "last_node", since its the last node
|
||||
for (int i = 1; i < depth - 1; i++) {
|
||||
insert_first(i);
|
||||
}
|
||||
return HEAD;
|
||||
}
|
||||
|
||||
void create_garbage(int amount) {
|
||||
for (int i = 0; i < amount; i++) {
|
||||
long *garbage = (long*)(cheap_alloc(sizeof(long)));
|
||||
}
|
||||
}
|
||||
|
||||
int main () {
|
||||
cheap_init();
|
||||
cheap_t *heap = cheap_the();
|
||||
cheap_set_profiler(heap, true);
|
||||
create_linked_list(list_length);
|
||||
cheap_dispose();
|
||||
free(heap);
|
||||
}
|
||||
|
||||
int main (int argc, char **argv) {
|
||||
test_linked_list(30);
|
||||
// Every node in this list should be marked
|
||||
Node *head = create_linked_list(5);
|
||||
// Everything create here should be swept
|
||||
create_garbage(30);
|
||||
|
||||
cheap_dispose();
|
||||
return 0;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue