Skip to content

Commit

Permalink
#81 fix balls explosion
Browse files Browse the repository at this point in the history
  • Loading branch information
c71n93 committed Nov 17, 2023
1 parent d9d2582 commit 4ee5a9f
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 21 deletions.
42 changes: 23 additions & 19 deletions include/besm-666/basic-block.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,25 @@ class BasicBlock {
BasicBlock() : startPC_(0), sz_(0) {}
BasicBlock(RV64UDWord startPC) : startPC_(startPC), sz_(0) {}

BasicBlock(const BasicBlock &other) {
startPC_ = other.startPC_;
instrs_ = other.instrs_;
sz_ = other.sz_;
currentInstr_ = other.currentInstr_;

std::cerr << "Balls explosion! BB copy ctor" << std::endl;
}

BasicBlock& operator=(const BasicBlock &other) {
startPC_ = other.startPC_;
instrs_ = other.instrs_;
sz_ = other.sz_;
currentInstr_ = other.currentInstr_;

std::cerr << "Balls explosion! BB copy ctor" << std::endl;

return *this;
}
// BasicBlock(const BasicBlock &other) {
// startPC_ = other.startPC_;
// instrs_ = other.instrs_;
// sz_ = other.sz_;
// currentInstr_ = other.currentInstr_;
//
// std::cerr << "Balls explosion! BB copy ctor" << std::endl;
// }
//
// BasicBlock& operator=(const BasicBlock &other) {
// startPC_ = other.startPC_;
// instrs_ = other.instrs_;
// sz_ = other.sz_;
// currentInstr_ = other.currentInstr_;
//
// std::cerr << "Balls explosion! BB copy ctor" << std::endl;
//
// return *this;
// }

static constexpr size_t capacity = 33;

Expand Down Expand Up @@ -62,6 +62,10 @@ class BasicBlock {
void resetBB() {
sz_ = 0;
startPC_ = -1;
currentInstr_ = 0;
}
void resetCurrentInstr() const {
currentInstr_ = 0;
}

using It = std::array<Instruction, capacity>::iterator;
Expand Down
9 changes: 7 additions & 2 deletions src/sim/hart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,6 @@ void Hart::raiseIllegalInstruction() {
}

void Hart::exec_BB_END() {
// TODO: check finished
prevPC_ = currentBB_->startPC() + (currentBB_->size() - 2) * sizeof(RV64UWord);
instrsExecuted_ += currentBB_->size() - 1;
if(this->finished()) {
Expand All @@ -331,13 +330,19 @@ void Hart::exec_BB_END() {
assert(pc % 2 == 0);
auto &entry = cache_.find(pc);
currentBB_ = &entry.getPayload();
if (!entry.valid() || entry.getTag() != pc) {
if (entry.valid() && entry.getTag() == pc) {
currentBB_->resetCurrentInstr();
}
else {
if (entry.valid()) {
currentBB_->resetBB();
}
currentBB_->setStartPC(pc);
dec_.assembleBB(*currentBB_);
// std::cerr << "Here?" << std::endl;
entry.setPayload(*currentBB_, pc);
// std::cerr << "Here!" << std::endl;

cache_.incCounter(pc);
}
hookManager_->triggerBBFetchHook(*currentBB_);
Expand Down

0 comments on commit 4ee5a9f

Please sign in to comment.