use of jdk.vm.ci.meta.JavaConstant in project graal by oracle.
the class ReverseBytesNode method canonical.
@Override
public ValueNode canonical(CanonicalizerTool tool, ValueNode forValue) {
if (forValue.isConstant()) {
JavaConstant c = forValue.asJavaConstant();
long reversed = getStackKind() == JavaKind.Int ? Integer.reverseBytes(c.asInt()) : Long.reverseBytes(c.asLong());
return ConstantNode.forIntegerKind(getStackKind(), reversed);
}
return this;
}
use of jdk.vm.ci.meta.JavaConstant in project graal by oracle.
the class IntegerSubExactNode method canonicalXYconstant.
private ValueNode canonicalXYconstant(ValueNode forX, ValueNode forY) {
JavaConstant xConst = forX.asJavaConstant();
JavaConstant yConst = forY.asJavaConstant();
assert xConst.getJavaKind() == yConst.getJavaKind();
try {
if (xConst.getJavaKind() == JavaKind.Int) {
return ConstantNode.forInt(Math.subtractExact(xConst.asInt(), yConst.asInt()));
} else {
assert xConst.getJavaKind() == JavaKind.Long;
return ConstantNode.forLong(Math.subtractExact(xConst.asLong(), yConst.asLong()));
}
} catch (ArithmeticException ex) {
// The operation will result in an overflow exception, so do not canonicalize.
}
return this;
}
use of jdk.vm.ci.meta.JavaConstant in project graal by oracle.
the class SubstrateInspectedFrame method getLocalConstant.
private JavaConstant getLocalConstant(int index) {
checkDeoptimized();
checkLocalIndex(index);
JavaConstant result;
if (virtualFrame != null) {
result = virtualFrame.getConstant(index);
assert locals[index] == null || locals[index].equals(result) : "value before and after deoptimization must be equal";
} else {
result = locals[index];
if (result == null) {
result = getDeoptimizer().readLocalVariable(index, frameInfo);
locals[index] = result;
}
}
return result;
}
use of jdk.vm.ci.meta.JavaConstant in project graal by oracle.
the class SubstrateInspectedFrame method toString.
@Override
public String toString() {
checkDeoptimized();
StringBuilder result = new StringBuilder();
final StackTraceElement sourceReference = frameInfo.getSourceReference();
result.append(sourceReference != null ? sourceReference.toString() : "[method name not available]");
result.append(" bci: ").append(frameInfo.getBci());
if (virtualFrame != null) {
result.append(" [deoptimized]");
}
result.append(" sp: 0x").append(Long.toHexString(sp.rawValue()));
result.append(" ip: 0x").append(Long.toHexString(ip.rawValue()));
if (frameInfo.getDeoptMethodOffset() != 0) {
result.append(" deoptTarget: 0x").append(Long.toHexString(frameInfo.getDeoptMethodAddress().rawValue()));
}
for (int i = 0; i < frameInfo.getNumLocals(); i++) {
JavaConstant con = getLocalConstant(i);
if (con.getJavaKind() != JavaKind.Illegal) {
result.append("\n local ").append(i);
String name = frameInfo.getLocalVariableName(i);
if (name != null) {
result.append(" ").append(name);
}
if (con.getJavaKind() == JavaKind.Object) {
if (isVirtual(i)) {
result.append(" [virtual object]");
}
Object val = SubstrateObjectConstant.asObject(con);
if (val == null) {
result.append(" null");
} else {
result.append(" class: ").append(val.getClass().getName());
result.append(" address: 0x").append(Long.toHexString(Word.objectToUntrackedPointer(val).rawValue()));
}
} else {
result.append(" kind: ").append(con.getJavaKind().toString());
if (con.getJavaKind().isNumericInteger()) {
result.append(" value: ").append(con.asLong());
}
}
}
}
return result.toString();
}
use of jdk.vm.ci.meta.JavaConstant in project graal by oracle.
the class AMD64ArithmeticLIRGenerator method emitStoreConst.
protected void emitStoreConst(AMD64Kind kind, AMD64AddressValue address, ConstantValue value, LIRFrameState state) {
Constant c = value.getConstant();
if (JavaConstant.isNull(c)) {
assert kind == AMD64Kind.DWORD || kind == AMD64Kind.QWORD;
OperandSize size = kind == AMD64Kind.DWORD ? DWORD : QWORD;
getLIRGen().append(new AMD64BinaryConsumer.MemoryConstOp(AMD64MIOp.MOV, size, address, 0, state));
return;
} else if (c instanceof VMConstant) {
// only 32-bit constants can be patched
if (kind == AMD64Kind.DWORD) {
if (getLIRGen().target().inlineObjects || !(c instanceof JavaConstant)) {
// if c is a JavaConstant, it's an oop, otherwise it's a metaspace constant
assert !(c instanceof JavaConstant) || ((JavaConstant) c).getJavaKind() == JavaKind.Object;
getLIRGen().append(new AMD64BinaryConsumer.MemoryVMConstOp(AMD64MIOp.MOV, address, (VMConstant) c, state));
return;
}
}
} else {
JavaConstant jc = (JavaConstant) c;
assert jc.getJavaKind().isPrimitive();
AMD64MIOp op = AMD64MIOp.MOV;
OperandSize size;
long imm;
switch(kind) {
case BYTE:
op = AMD64MIOp.MOVB;
size = BYTE;
imm = jc.asInt();
break;
case WORD:
size = WORD;
imm = jc.asInt();
break;
case DWORD:
size = DWORD;
imm = jc.asInt();
break;
case QWORD:
size = QWORD;
imm = jc.asLong();
break;
case SINGLE:
size = DWORD;
imm = Float.floatToRawIntBits(jc.asFloat());
break;
case DOUBLE:
size = QWORD;
imm = Double.doubleToRawLongBits(jc.asDouble());
break;
default:
throw GraalError.shouldNotReachHere("unexpected kind " + kind);
}
if (NumUtil.isInt(imm)) {
getLIRGen().append(new AMD64BinaryConsumer.MemoryConstOp(op, size, address, (int) imm, state));
return;
}
}
// fallback: load, then store
emitStore(kind, address, getLIRGen().asAllocatable(value), state);
}
Aggregations