Skip to content

Commit

Permalink
Track bcp during instance allocations (#2112)
Browse files Browse the repository at this point in the history
  • Loading branch information
kasperl authored Mar 6, 2024
1 parent 26dd085 commit 0ef78da
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/interpreter_run.cc
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,7 @@ Interpreter::Result Interpreter::run() {
OPCODE_END();

OPCODE_BEGIN_WITH_WIDE(ALLOCATE, class_index);
process_->set_current_bcp(bcp);
Object* result = process_->object_heap()->allocate_instance(Smi::from(class_index));
for (int attempts = 1; result == null && attempts < 4; attempts++) {
#ifdef TOIT_GC_LOGGING
Expand All @@ -540,6 +541,7 @@ Interpreter::Result Interpreter::run() {
result = process_->object_heap()->allocate_instance(Smi::from(class_index));
}
process_->object_heap()->leave_primitive();
process_->set_current_bcp(null);

if (result == null) {
sp = push_error(sp, program->allocation_failed(), "");
Expand Down
7 changes: 6 additions & 1 deletion src/scheduler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -934,10 +934,15 @@ void Scheduler::tick(Locker& locker, int64 now) {
int bci = program->absolute_bci_from_bcp(current_bcp);
fprintf(stderr, " BCI: 0x%x\n", bci);

if (*current_bcp == Opcode::PRIMITIVE) {
Opcode opcode = static_cast<Opcode>(*current_bcp);
if (opcode == Opcode::PRIMITIVE) {
int module = current_bcp[1];
int index = Utils::read_unaligned_uint16(current_bcp + 2);
fprintf(stderr, " Primitive: %d:%d\n", module, index);
} else if (opcode == Opcode::ALLOCATE) {
fprintf(stderr, " Allocate: %d\n", current_bcp[1]);
} else if (opcode == Opcode::ALLOCATE_WIDE) {
fprintf(stderr, " Allocate: %d\n", Utils::read_unaligned_uint16(current_bcp + 1));
}
}
FATAL("Potential dead-lock");
Expand Down

0 comments on commit 0ef78da

Please sign in to comment.