Skip to content

Commit

Permalink
#111 reset roots
Browse files Browse the repository at this point in the history
  • Loading branch information
c71n93 committed Jun 14, 2024
1 parent 77c6f34 commit 61b93bb
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/ChaiVM/interpreter/executor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ const GarbageCollector &interpreter::Executor::getGC() const {
}
void interpreter::Executor::triggerGC() {
if (static_cast<double>(objectsAllocator_.allocated()) >
static_cast<double>(objectsAllocator_.size()) * 0.9) {
static_cast<double>(objectsAllocator_.size()) * 0.4) {
gc_.collect();
}
}
Expand Down
1 change: 1 addition & 0 deletions src/ChaiVM/interpreter/garbage-collector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,5 @@ void GarbageCollector::sweep() {
iter++;
}
}
roots_ = std::vector<Object>{};
}
4 changes: 2 additions & 2 deletions test/ChaiVM/interpreter/garbage-collector-test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class GarbageCollectorTest : public ::testing::Test {
protected:
size_t numOfRegs = 50;
size_t numOfFrames = 256;
size_t objBufSize = 1000;
size_t objBufSize = 300;
chai::utils::fileformat::ChaiFile chaiFile_;
chai::interpreter::CodeManager codeManager_;
chai::memory::LinearBuffer frameBuffer_ = chai::memory::LinearBuffer(
Expand Down Expand Up @@ -157,7 +157,7 @@ TEST_F(GarbageCollectorTest, CollectRoots) {
chaiFile_.addField(bar_klass, "bar.num2", 0U, FieldTag::I64);
chaiFile_.addField(bar_klass, "bar.num3", 0U, FieldTag::I64);
chaiFile_.addField(bar_klass, "bar.num4", 0U, FieldTag::I64);
constexpr int64_t threshold = 1000;
constexpr int64_t threshold = 4000;
//Immidiate zero_imm = chaiFile_.addConst(std::make_unique<ConstI64>(0));
Immidiate one_imm = chaiFile_.addConst(std::make_unique<ConstI64>(1));
Immidiate threshold_imm = chaiFile_.addConst(std::make_unique<ConstI64>(threshold));
Expand Down

0 comments on commit 61b93bb

Please sign in to comment.