Skip to content

Commit

Permalink
Synchronize instruction IPC calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
headius committed Jun 18, 2024
1 parent 98d69c9 commit ffc2f70
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ public class InterpreterContext {

// startup interp will mark this at construction and not change but full interpreter will write it
// much later after running compiler passes. JIT will not use this field at all.
protected Instr[] instructions;
protected volatile Instr[] instructions;

// Contains pairs of values. The first value is number of instrs in this range + number of instrs before
// this range. The second number is the rescuePC. getRescuePC(ipc) will walk this list and first odd value
// less than this value will be the rpc.
protected int[] rescueIPCs = null;
protected volatile int[] rescueIPCs = null;

// Cached computed fields
protected boolean hasExplicitCallProtocol; // Only can be true in Full+
Expand Down Expand Up @@ -93,7 +93,7 @@ public Instr[] getInstructions() {
return instructions == null ? NO_INSTRUCTIONS : instructions;
}

private void setInstructions(final List<Instr> instructions) {
private synchronized void setInstructions(final List<Instr> instructions) {
this.instructions = instructions != null ? prepareBuildInstructions(instructions) : null;
}

Expand All @@ -108,7 +108,7 @@ private Instr[] prepareBuildInstructions(List<Instr> instructions) {
}

Deque<Integer> markers = new ArrayDeque<>(8);
rescueIPCs = new int[length];
int[] rescueIPCs = new int[length];
int rpc = -1;

for (int ipc = 0; ipc < length; ipc++) {
Expand All @@ -125,6 +125,8 @@ private Instr[] prepareBuildInstructions(List<Instr> instructions) {
rescueIPCs[ipc] = rpc;
}

this.rescueIPCs = rescueIPCs;

return linearizedInstrArray;
}

Expand Down

0 comments on commit ffc2f70

Please sign in to comment.