Skip to content

Commit

Permalink
[mycpp] Fix tests, and move cheney_heap.cc out of binary
Browse files Browse the repository at this point in the history
Rename to bump_alloc.h -> bump_leak_heap.h

Eventually we should unify gc_heap.h and marksweep_heap.h.
  • Loading branch information
Andy C committed Oct 25, 2022
1 parent 39fb6ec commit aef3a59
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 22 deletions.
7 changes: 5 additions & 2 deletions mycpp/NINJA_subgraph.py
Expand Up @@ -16,12 +16,15 @@ def DefineTargets(ru):
deps_base_dir = 'prebuilt/ninja',
template = 'mycpp')

ru.cc_library(
'//mycpp/cheney_heap',
srcs = ['mycpp/cheney_heap.cc'])

ru.cc_library(
'//mycpp/runtime',
srcs = [
'mycpp/gc_mylib.cc',
'mycpp/bump_alloc.cc',
'mycpp/cheney_heap.cc',
'mycpp/bump_leak_heap.cc',
'mycpp/marksweep_heap.cc',

# files we haven't added StackRoots to
Expand Down
3 changes: 0 additions & 3 deletions mycpp/TEST.sh
Expand Up @@ -289,9 +289,6 @@ test-translator() {
# Test with more collections -- 5 failures above
examples-variant '' gcevery

# Sanity check that doesn't collect garbage
examples-variant '' mallocleak

run-test-func test-invalid-examples _test/mycpp/test-invalid-examples.log

# Runs test in cxx-asan variant, and benchmarks in cxx-opt variant
Expand Down
4 changes: 2 additions & 2 deletions mycpp/bump_alloc.cc → mycpp/bump_leak_heap.cc
@@ -1,6 +1,6 @@
// mycpp/bump_alloc.cc: Leaky Bump Allocator
// mycpp/bump_leak_heap.cc: Leaky Bump Allocator

#include "mycpp/bump_alloc.h"
#include "mycpp/bump_leak_heap.h"

#include <stddef.h>
#include <stdio.h>
Expand Down
8 changes: 4 additions & 4 deletions mycpp/bump_alloc.h → mycpp/bump_leak_heap.h
@@ -1,7 +1,7 @@
// mycpp/bump_alloc.h: Leaky Bump Allocator
// mycpp/bump_leak_heap.h: Leaky Bump Allocator

#ifndef BUMP_ALLOC_H
#define BUMP_ALLOC_H
#ifndef MYCPP_BUMP_LEAK_HEAP_H
#define MYCPP_BUMP_LEAK_HEAP_H

#include <stdint.h> // int64_t

Expand Down Expand Up @@ -67,4 +67,4 @@ class BumpLeakHeap {
extern BumpLeakHeap gHeap;
#endif

#endif // BUMP_ALLOC_H
#endif // MYCPP_BUMP_LEAK_HEAP_H
9 changes: 0 additions & 9 deletions mycpp/cheney_heap.h
Expand Up @@ -232,15 +232,6 @@ class CheneyHeap {
void ShowFixedChildren(Obj* obj);
#endif

// LayoutForwarded and LayoutFixed aren't real types. You can cast arbitrary
// objs to them to access a HOMOGENEOUS REPRESENTATION useful for garbage
// collection.

class LayoutForwarded : public Obj {
public:
Obj* new_location; // valid if and only if heap_tag_ == Tag::Forwarded
};

#if !defined(MARK_SWEEP) && !defined(BUMP_LEAK)
extern CheneyHeap gHeap;
#endif
Expand Down
12 changes: 10 additions & 2 deletions mycpp/gc_heap.h
@@ -1,8 +1,7 @@
#ifndef GC_HEAP_H
#define GC_HEAP_H

#include "mycpp/bump_alloc.h"
#include "mycpp/cheney_heap.h"
#include "mycpp/bump_leak_heap.h"
#include "mycpp/marksweep_heap.h"

#if defined(MARK_SWEEP)
Expand Down Expand Up @@ -62,6 +61,15 @@ class StackRoots {
int n_;
};

// LayoutForwarded and LayoutFixed aren't real types. You can cast arbitrary
// objs to them to access a HOMOGENEOUS REPRESENTATION useful for garbage
// collection.

class LayoutForwarded : public Obj {
public:
Obj* new_location; // valid if and only if heap_tag_ == Tag::Forwarded
};

// for Tag::FixedSize
class LayoutFixed : public Obj {
public:
Expand Down

0 comments on commit aef3a59

Please sign in to comment.