Skip to content

Commit

Permalink
Latest
Browse files Browse the repository at this point in the history
  • Loading branch information
Robbert van Renesse committed Nov 2, 2024
1 parent 1eb2127 commit 30b29fd
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions harmony_model_checker/charm/charm.c
Original file line number Diff line number Diff line change
Expand Up @@ -822,6 +822,7 @@ static struct step_output *onestep(
bool rollback = false;
bool printing = false;
bool assert_batch = false;
bool in_assertion = false;

// See if we should first try an interrupt or make a choice.
if (choice == (hvalue_t) -1) {
Expand All @@ -842,7 +843,7 @@ static struct step_output *onestep(
// Consecutive assertions can be combined. Also, can be combined
// with the following atomic section
else if (instrs[step->ctx->pc].is_assert) {
assert_batch = true;
assert_batch = in_assertion = true;
}

int pc = step->ctx->pc;
Expand All @@ -860,7 +861,7 @@ static struct step_output *onestep(
assert(step->ctx->sp > 0);

// Can't choose in an assertion.
if (as_instrcnt > 0) {
if (in_assertion) {
value_ctx_failure(step->ctx, step->allocator, "can't choose in an assertion");
instrcnt++;
break;
Expand Down Expand Up @@ -985,6 +986,7 @@ static struct step_output *onestep(
// If no longer in atomic mode, rollback is no longer necessary.
if (instrs[pc].atomicdec && step->ctx->atomic == 0) {
as_instrcnt = 0;
in_assertion = false;
}

// We're going to peek at the next instruction now
Expand Down Expand Up @@ -1024,16 +1026,12 @@ static struct step_output *onestep(
// See if we're going to lazily evaluate an assert statement. If so,
// save the current state of the context so we can roll back in
// case the assertion reads a global variable.
//
// TODO. Can probably do this for any atomic section
if (instrs[pc].is_assert && step->ctx->atomic == 0) {
if (instrs[pc].atomicinc && step->ctx->atomic == 0) {
memcpy(&w->as_ctx, step->ctx, ctx_size(step->ctx));
as_instrcnt = instrcnt;
}

// See we're going into atomic mode. If so, break.
else if (instrs[pc].atomicinc && step->ctx->atomic == 0) {
break;
if (instrs[pc].is_assert) {
in_assertion = true;
}
}

// If we're not in atomic mode, we limit the number of steps to MAX_STEPS.
Expand Down

0 comments on commit 30b29fd

Please sign in to comment.