use of org.vmmagic.unboxed.Word in project JikesRVM by JikesRVM.
the class Simplifier method refShl.
private static DefUseEffect refShl(Instruction s, OptOptions opts) {
if (opts.SIMPLIFY_REF_OPS) {
Operand op2 = Binary.getVal2(s);
Operand op1 = Binary.getVal1(s);
if (op2.isIntConstant()) {
int val2 = op2.asIntConstant().value;
if (op1.isConstant() && !op1.isMovableObjectConstant()) {
// BOTH CONSTANTS: FOLD
Word val1 = getAddressValue(op1).toWord();
Move.mutate(s, REF_MOVE, Binary.getClearResult(s), AC(val1.lsh(val2).toAddress()));
return DefUseEffect.MOVE_FOLDED;
} else {
// ONLY OP2 IS CONSTANT: ATTEMPT TO APPLY AXIOMS
if (val2 == 0) {
// x << 0 == x
Move.mutate(s, REF_MOVE, Binary.getClearResult(s), Binary.getClearVal1(s));
return DefUseEffect.MOVE_REDUCED;
}
if ((val2 >= BITS_IN_ADDRESS) || (val2 < 0)) {
// x << 32 == 0
Move.mutate(s, REF_MOVE, Binary.getClearResult(s), IC(0));
return DefUseEffect.MOVE_FOLDED;
}
}
} else if (op1.isConstant() && !op1.isMovableObjectConstant()) {
Word val1 = getAddressValue(op1).toWord();
// ONLY OP1 IS CONSTANT: ATTEMPT TO APPLY AXIOMS
if (val1.isZero()) {
// 0 << x == 0
Move.mutate(s, REF_MOVE, Binary.getClearResult(s), AC(Address.zero()));
return DefUseEffect.MOVE_FOLDED;
}
}
}
return DefUseEffect.UNCHANGED;
}
use of org.vmmagic.unboxed.Word in project JikesRVM by JikesRVM.
the class Simplifier method refNeg.
private static DefUseEffect refNeg(Instruction s, OptOptions opts) {
if (opts.SIMPLIFY_REF_OPS) {
Operand op = Unary.getVal(s);
if (op.isConstant() && !op.isMovableObjectConstant()) {
// CONSTANT: FOLD
Word val = getAddressValue(op).toWord();
Word negVal = Word.zero().minus(val);
Move.mutate(s, REF_MOVE, Unary.getClearResult(s), AC(negVal.toAddress()));
return DefUseEffect.MOVE_FOLDED;
}
}
return DefUseEffect.UNCHANGED;
}
use of org.vmmagic.unboxed.Word in project JikesRVM by JikesRVM.
the class Simplifier method refShr.
private static DefUseEffect refShr(Instruction s, OptOptions opts) {
if (opts.SIMPLIFY_REF_OPS) {
Operand op1 = Binary.getVal1(s);
Operand op2 = Binary.getVal2(s);
if (op2.isIntConstant()) {
int val2 = op2.asIntConstant().value;
if (op1.isConstant() && !op1.isMovableObjectConstant()) {
// BOTH CONSTANTS: FOLD
Word val1 = getAddressValue(op1).toWord();
Move.mutate(s, REF_MOVE, Binary.getClearResult(s), AC(val1.rsha(val2).toAddress()));
return DefUseEffect.MOVE_FOLDED;
} else {
// ONLY OP2 IS CONSTANT: ATTEMPT TO APPLY AXIOMS
if (val2 == 0) {
// x >> 0 == x
Move.mutate(s, REF_MOVE, Binary.getClearResult(s), Binary.getClearVal1(s));
return DefUseEffect.MOVE_REDUCED;
}
if ((val2 >= BITS_IN_ADDRESS) || (val2 < 0)) {
// x >> 32 == x >> 31
Binary.setVal2(s, IC(BITS_IN_ADDRESS - 1));
return DefUseEffect.UNCHANGED;
}
}
} else if (op1.isConstant() && !op1.isMovableObjectConstant()) {
Word val1 = getAddressValue(op1).toWord();
// -1 >> x == -1, 0 >> x == 0
if (val1.EQ(Word.zero()) || val1.EQ(Word.zero().minus(Word.one()))) {
Move.mutate(s, REF_MOVE, Binary.getClearResult(s), op1);
return DefUseEffect.MOVE_FOLDED;
}
}
}
return DefUseEffect.UNCHANGED;
}
use of org.vmmagic.unboxed.Word in project JikesRVM by JikesRVM.
the class TestNullChecks_Resolved 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;
}
}
use of org.vmmagic.unboxed.Word in project JikesRVM by JikesRVM.
the class TestNullChecks_Unresolved_ReadFromNonNullObject 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;
}
}
Aggregations