Skip to content

Commit

Permalink
Rename marked_objects to reachables
Browse files Browse the repository at this point in the history
Signed-off-by: yamacir-kit <[email protected]>
  • Loading branch information
yamacir-kit committed Nov 3, 2024
1 parent c53aceb commit 256b79a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ Procedures for each standard are provided by the following R7RS-style libraries:
cmake -B build -DCMAKE_BUILD_TYPE=Release
cd build
make package
sudo apt install build/meevax_0.5.258_amd64.deb
sudo apt install build/meevax_0.5.259_amd64.deb
```

or
Expand Down Expand Up @@ -122,9 +122,9 @@ sudo rm -rf /usr/local/share/meevax

| Target Name | Description
|-------------|-------------
| `all` | Build shared-library `libmeevax.0.5.258.so` and executable `meevax`
| `all` | Build shared-library `libmeevax.0.5.259.so` and executable `meevax`
| `test` | Test executable `meevax`
| `package` | Generate debian package `meevax_0.5.258_amd64.deb`
| `package` | Generate debian package `meevax_0.5.259_amd64.deb`
| `install` | Copy files into `/usr/local` directly

## Usage
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.5.258
0.5.259
22 changes: 11 additions & 11 deletions include/meevax/memory/collector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ inline namespace memory

static auto mark() noexcept -> pointer_set<top>
{
auto is_root_object = [begin = objects.begin()](mutator const* given) // TODO INEFFICIENT!
auto is_root = [begin = objects.begin()](mutator const* given)
{
/*
If the given mutator is a non-root object, then an object containing
Expand Down Expand Up @@ -564,22 +564,22 @@ inline namespace memory
}
};

auto marked_objects = pointer_set<top>();
auto reachables = pointer_set<top>();

for (auto const& mutator : mutators)
{
assert(mutator);
assert(mutator->unsafe_get());

if (auto object = mutator->unsafe_get(); not marked_objects.contains(object) and is_root_object(mutator))
if (auto object = mutator->unsafe_get(); not reachables.contains(object) and is_root(mutator))
{
auto queue = std::queue<top const*>();

for (queue.push(object); not queue.empty(); queue.pop())
{
if (not marked_objects.contains(queue.front()))
if (not reachables.contains(queue.front()))
{
marked_objects.insert(queue.front());
reachables.insert(queue.front());

for (auto const& mutator : mutators_view(queue.front()->view()))
{
Expand All @@ -593,23 +593,23 @@ inline namespace memory
}
}

return marked_objects;
return reachables;
}

static auto sweep(pointer_set<top> && marked_objects) -> void
static auto sweep(pointer_set<top> && reachables) -> void
{
for (auto marked_object : marked_objects)
for (auto reachable : reachables)
{
assert(objects.contains(marked_object));
objects.erase(marked_object);
assert(objects.contains(reachable));
objects.erase(reachable);
}

for (auto object : objects)
{
delete object;
}

objects.swap(marked_objects);
objects.swap(reachables);
}
};
} // namespace memory
Expand Down

0 comments on commit 256b79a

Please sign in to comment.