use of org.vmmagic.unboxed.Word in project JikesRVM by JikesRVM.
the class Simplifier method refXor.
private static DefUseEffect refXor(Instruction s, OptOptions opts) {
if (opts.SIMPLIFY_REF_OPS) {
canonicalizeCommutativeOperator(s);
Operand op1 = Binary.getVal1(s);
Operand op2 = Binary.getVal2(s);
if (op1.similar(op2)) {
// THE SAME OPERAND: x ^ x == 0
Move.mutate(s, REF_MOVE, Binary.getClearResult(s), IC(0));
return DefUseEffect.MOVE_FOLDED;
}
if (op2.isConstant() && !op2.isMovableObjectConstant()) {
Word val2 = getAddressValue(op2).toWord();
if (op1.isConstant() && !op1.isMovableObjectConstant()) {
// BOTH CONSTANTS: FOLD
Word val1 = getAddressValue(op1).toWord();
Move.mutate(s, REF_MOVE, Binary.getClearResult(s), AC(val1.xor(val2).toAddress()));
return DefUseEffect.MOVE_FOLDED;
} else {
// ONLY OP2 IS CONSTANT: ATTEMPT TO APPLY AXIOMS
if (val2.isMax()) {
// x ^ -1 == x ^ 0xffffffff = ~x
Unary.mutate(s, REF_NOT, Binary.getClearResult(s), Binary.getClearVal1(s));
return DefUseEffect.REDUCED;
}
if (val2.isZero()) {
// x ^ 0 == x
Move.mutate(s, REF_MOVE, Binary.getClearResult(s), Binary.getClearVal1(s));
return DefUseEffect.MOVE_REDUCED;
}
}
}
}
return DefUseEffect.UNCHANGED;
}
use of org.vmmagic.unboxed.Word in project JikesRVM by JikesRVM.
the class Simplifier method refAnd.
private static DefUseEffect refAnd(Instruction s, OptOptions opts) {
if (opts.SIMPLIFY_REF_OPS) {
canonicalizeCommutativeOperator(s);
Operand op1 = Binary.getVal1(s);
Operand op2 = Binary.getVal2(s);
if (op1.similar(op2)) {
// THE SAME OPERAND: x & x == x
Move.mutate(s, REF_MOVE, Binary.getClearResult(s), Binary.getClearVal1(s));
return op1.isConstant() ? DefUseEffect.MOVE_FOLDED : DefUseEffect.MOVE_REDUCED;
}
if (op2.isConstant() && !op2.isMovableObjectConstant()) {
Word val2 = getAddressValue(op2).toWord();
if (op1.isConstant() && !op1.isMovableObjectConstant()) {
// BOTH CONSTANTS: FOLD
Word val1 = getAddressValue(op1).toWord();
Move.mutate(s, REF_MOVE, Binary.getClearResult(s), AC(val1.and(val2).toAddress()));
return DefUseEffect.MOVE_FOLDED;
} else {
// ONLY OP2 IS CONSTANT: ATTEMPT TO APPLY AXIOMS
if (val2.isZero()) {
// x & 0 == 0
Move.mutate(s, REF_MOVE, Binary.getClearResult(s), AC(Address.zero()));
return DefUseEffect.MOVE_FOLDED;
}
if (val2.isMax()) {
// x & -1 == x & 0xffffffff == x
Move.mutate(s, REF_MOVE, Binary.getClearResult(s), Binary.getClearVal1(s));
return DefUseEffect.MOVE_REDUCED;
}
}
}
}
return DefUseEffect.UNCHANGED;
}
use of org.vmmagic.unboxed.Word in project JikesRVM by JikesRVM.
the class Simplifier method refOr.
private static DefUseEffect refOr(Instruction s, OptOptions opts) {
if (opts.SIMPLIFY_REF_OPS) {
canonicalizeCommutativeOperator(s);
Operand op1 = Binary.getVal1(s);
Operand op2 = Binary.getVal2(s);
if (op1.similar(op2)) {
// THE SAME OPERAND: x | x == x
Move.mutate(s, REF_MOVE, Binary.getClearResult(s), Binary.getClearVal1(s));
return op1.isConstant() ? DefUseEffect.MOVE_FOLDED : DefUseEffect.MOVE_REDUCED;
}
if (op2.isConstant() && !op2.isMovableObjectConstant()) {
Word val2 = getAddressValue(op2).toWord();
if (op1.isAddressConstant()) {
// BOTH CONSTANTS: FOLD
Word val1 = getAddressValue(op1).toWord();
Move.mutate(s, REF_MOVE, Binary.getClearResult(s), AC(val1.or(val2).toAddress()));
return DefUseEffect.MOVE_FOLDED;
} else {
// ONLY OP2 IS CONSTANT: ATTEMPT TO APPLY AXIOMS
if (val2.isMax()) {
// x | -1 == x | 0xffffffff == 0xffffffff == -1
Move.mutate(s, REF_MOVE, Binary.getClearResult(s), AC(Address.max()));
return DefUseEffect.MOVE_FOLDED;
}
if (val2.isZero()) {
// x | 0 == x
Move.mutate(s, REF_MOVE, Binary.getClearResult(s), Binary.getClearVal1(s));
return DefUseEffect.MOVE_REDUCED;
}
}
}
}
return DefUseEffect.UNCHANGED;
}
use of org.vmmagic.unboxed.Word in project JikesRVM by JikesRVM.
the class TestNullChecks_Resolved method readVolatileWordField.
private static Word readVolatileWordField(ClassWithVolatileWordField c) {
try {
Word readVolatile = c.w;
System.out.println("Read value " + readVolatile.toLong() + " from field");
return readVolatile;
} catch (NullPointerException npe) {
System.out.println("Caught NPE when reading Word field");
return NPE_WORD;
}
}
use of org.vmmagic.unboxed.Word in project JikesRVM by JikesRVM.
the class TestNullChecks_Unresolved_ReadFromNonNullObject method readWordField.
private static Word readWordField(ClassWithWordField c) {
try {
Word read = c.w;
System.out.println("Read value " + read.toLong() + " from field");
return read;
} catch (NullPointerException npe) {
System.out.println("Caught NPE when reading Word field");
return NPE_WORD;
}
}
Aggregations