Made some changes based on Alexey's comments of previous changes. Still getting same error on build.

This commit is contained in:
Steve Hannah 2015-02-07 07:22:13 -08:00
parent e2b6b7b2df
commit 68aa193728
8 changed files with 84 additions and 8 deletions

View File

@ -597,12 +597,24 @@ public class ProgramIO {
@Override
public void visit(MonitorEnterInstruction insn) {
try {
output.writeByte(39);
output.writeShort(insn.getObjectRef().getIndex());
} catch (IOException e) {
throw new IOExceptionWrapper(e);
}
}
@Override
public void visit(MonitorExitInstruction insn) {
try {
output.writeByte(40);
output.writeShort(insn.getObjectRef().getIndex());
} catch (IOException e) {
throw new IOExceptionWrapper(e);
}
}
}
@ -908,6 +920,16 @@ public class ProgramIO {
insn.setValue(program.variableAt(input.readShort()));
return insn;
}
case 39: {
MonitorEnterInstruction insn = new MonitorEnterInstruction();
insn.setObjectRef(program.variableAt(input.readShort()));
return insn;
}
case 40: {
MonitorExitInstruction insn = new MonitorExitInstruction();
insn.setObjectRef(program.variableAt(input.readShort()));
return insn;
}
default:
throw new RuntimeException("Unknown instruction type: " + insnType);
}

View File

@ -490,5 +490,19 @@ class DependencyGraphBuilder {
new CallLocation(caller.getMethod(), currentLocation)).use();
currentExceptionConsumer.consume(dependencyChecker.getType("java.lang.NullPointerException"));
}
@Override
public void monitorEnter(VariableReader objectRef) {
dependencyChecker.linkMethod(
new MethodReference(Object.class, "monitorEnter", Object.class, void.class),
new CallLocation(caller.getMethod(), currentLocation)).use();
}
@Override
public void monitorExit(VariableReader objectRef) {
dependencyChecker.linkMethod(
new MethodReference(Object.class, "monitorExit", Object.class, void.class),
new CallLocation(caller.getMethod(), currentLocation)).use();
}
};
}

View File

@ -22,7 +22,7 @@ package org.teavm.javascript.ast;
public class MonitorEnterStatement extends Statement {
private NodeLocation location;
private VariableExpr objectRef;
private Expr objectRef;
@Override
public void acceptVisitor(StatementVisitor visitor) {
@ -46,14 +46,14 @@ public class MonitorEnterStatement extends Statement {
/**
* @return the objectRef
*/
public VariableExpr getObjectRef() {
public Expr getObjectRef() {
return objectRef;
}
/**
* @param objectRef the objectRef to set
*/
public void setObjectRef(VariableExpr objectRef) {
public void setObjectRef(Expr objectRef) {
this.objectRef = objectRef;
}

View File

@ -22,7 +22,7 @@ package org.teavm.javascript.ast;
public class MonitorExitStatement extends Statement {
private NodeLocation location;
private VariableExpr objectRef;
private Expr objectRef;
@Override
public void acceptVisitor(StatementVisitor visitor) {
@ -46,14 +46,14 @@ public class MonitorExitStatement extends Statement {
/**
* @return the objectRef
*/
public VariableExpr getObjectRef() {
public Expr getObjectRef() {
return objectRef;
}
/**
* @param objectRef the objectRef to set
*/
public void setObjectRef(VariableExpr objectRef) {
public void setObjectRef(Expr objectRef) {
this.objectRef = objectRef;
}

View File

@ -100,4 +100,8 @@ public interface InstructionReader {
void initClass(String className);
void nullCheck(VariableReader receiver, VariableReader value);
void monitorEnter(VariableReader objectRef);
void monitorExit(VariableReader objectRef);
}

View File

@ -352,4 +352,14 @@ public class InstructionStringifier implements InstructionReader {
public void nullCheck(VariableReader receiver, VariableReader value) {
sb.append("@").append(receiver.getIndex()).append(" := nullCheck @").append(value.getIndex());
}
@Override
public void monitorEnter(VariableReader objectRef) {
sb.append("monitorenter @").append(objectRef.getIndex());
}
@Override
public void monitorExit(VariableReader objectRef) {
sb.append("monitorexit @").append(objectRef.getIndex());
}
}

View File

@ -495,5 +495,21 @@ public final class ProgramUtils {
copy = insnCopy;
copy.setLocation(location);
}
@Override
public void monitorEnter(VariableReader objectRef) {
MonitorEnterInstruction insnCopy = new MonitorEnterInstruction();
insnCopy.setObjectRef(copyVar(objectRef));
copy = insnCopy;
copy.setLocation(location);
}
@Override
public void monitorExit(VariableReader objectRef) {
MonitorExitInstruction insnCopy = new MonitorExitInstruction();
insnCopy.setObjectRef(copyVar(objectRef));
copy = insnCopy;
copy.setLocation(location);
}
}
}

View File

@ -88,4 +88,14 @@ class ProgramSourceAggregator implements InstructionReader {
@Override public void isInstance(VariableReader receiver, VariableReader value, ValueType type) { }
@Override public void initClass(String className) { }
@Override public void nullCheck(VariableReader receiver, VariableReader value) { }
@Override
public void monitorEnter(VariableReader objectRef) {
}
@Override
public void monitorExit(VariableReader objectRef) {
}
}