Skip to content

Commit 69cf922

Browse files
bug fixes
Have to be seal BBs as soon as possible - will need to review this carefully
1 parent 8021543 commit 69cf922

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

optvm/src/main/java/com/compilerprogramming/ezlang/compiler/CompiledFunction.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,11 +265,13 @@ private void compileIf(AST.IfElseStmt ifElseStmt) {
265265
issa.sealBlock(currentBlock);
266266
assert vstackEmpty();
267267
startBlock(ifBlock);
268+
issa.sealBlock(ifBlock);
268269
compileStatement(ifElseStmt.ifStmt);
269270
if (!isBlockTerminated(currentBlock))
270271
jumpTo(exitBlock);
271272
if (elseBlock != null) {
272273
startBlock(elseBlock);
274+
issa.sealBlock(elseBlock);
273275
compileStatement(ifElseStmt.elseStmt);
274276
if (!isBlockTerminated(currentBlock))
275277
jumpTo(exitBlock);
@@ -663,7 +665,7 @@ private void codeStoreAppend() {
663665
private void codeArg(Operand.LocalRegisterOperand target) {
664666
var newtarget = (Operand.RegisterOperand) issa.write(target);
665667
var insn = new Instruction.ArgInstruction(newtarget);
666-
issa.recordDef(target, insn);
668+
issa.recordDef(newtarget, insn);
667669
code(insn);
668670
}
669671

@@ -694,7 +696,8 @@ private void codeCall(int newBase,
694696
Operand.RegisterOperand targetOperand,
695697
Type.TypeFunction calleeType,
696698
Operand.RegisterOperand ...arguments) {
697-
targetOperand = (Operand.RegisterOperand) issa.write(targetOperand);
699+
if (targetOperand != null)
700+
targetOperand = (Operand.RegisterOperand) issa.write(targetOperand);
698701
Operand.RegisterOperand args[] = new Operand.RegisterOperand[arguments.length];
699702
for (int i = 0; i < args.length; i++) {
700703
args[i] = (Operand.RegisterOperand) issa.read(arguments[i]);

0 commit comments

Comments
 (0)