Skip to content

Instantly share code, notes, and snippets.

@rightfold
Created February 16, 2015 20:28
Show Gist options
  • Save rightfold/dae939d7e69fe2b3e772 to your computer and use it in GitHub Desktop.
Save rightfold/dae939d7e69fe2b3e772 to your computer and use it in GitHub Desktop.
std::unordered_set<mill::Object*> mill::GC::mark() const {
std::unordered_set<Object*> result;
auto helper = [&] (auto const& self, auto object) {
if (result.count(object)) {
return;
}
result.insert(object);
for (auto&& field : object->type->fields()) {
if (field->isBoxed) {
self(self, field->template get<Object*>(object));
}
}
};
for (auto&& gcPtr : gcPtrs) {
helper(helper, gcPtr->get());
}
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment