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 d771359 commit 92b25ac
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public void generateInstructionsForInterpretation() {
Instr[] linearizedInstrArray = newInstrs.toArray(new Instr[newInstrs.size()]);

BasicBlock[] basicBlocks = getLinearizedBBList();
rescueIPCs = new int[2 * basicBlocks.length];
int[] rescueIPCs = new int[2 * basicBlocks.length];

// Pass 2: Use ipc info from previous to mark all linearized instrs rpc
ipc = 0;
Expand All @@ -154,7 +154,8 @@ public void generateInstructionsForInterpretation() {
}
}

instructions = linearizedInstrArray;
this.rescueIPCs = rescueIPCs;
this.instructions = linearizedInstrArray;

// System.out.println("SCOPE: " + getScope().getId());
// System.out.println("INSTRS: " + cfg.toStringInstrs());
Expand Down
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 92b25ac

Please sign in to comment.