use of jdk.vm.ci.meta.JavaConstant in project graal by oracle.
the class AArch64ArithmeticLIRGenerator method emitStore.
@Override
public void emitStore(ValueKind<?> lirKind, Value address, Value inputVal, LIRFrameState state) {
AArch64AddressValue storeAddress = getLIRGen().asAddressValue(address);
AArch64Kind kind = (AArch64Kind) lirKind.getPlatformKind();
if (isJavaConstant(inputVal) && kind.isInteger()) {
JavaConstant c = asJavaConstant(inputVal);
if (c.isDefaultForKind()) {
// We can load 0 directly into integer registers
getLIRGen().append(new StoreConstantOp(kind, storeAddress, c, state));
return;
}
}
AllocatableValue input = getLIRGen().asAllocatable(inputVal);
getLIRGen().append(new StoreOp(kind, storeAddress, input, state));
}
use of jdk.vm.ci.meta.JavaConstant in project graal by oracle.
the class AArch64LIRGenerator method isCompareConstant.
/**
* Checks whether value can be used directly with a gpCompare instruction. This is <b>not</b>
* the same as {@link AArch64ArithmeticLIRGenerator#isArithmeticConstant(JavaConstant)}, because
* 0.0 is a valid compare constant for floats, while there are no arithmetic constants for
* floats.
*
* @param value any type. Non null.
* @return true if value can be used directly in comparison instruction, false otherwise.
*/
public boolean isCompareConstant(Value value) {
if (isJavaConstant(value)) {
JavaConstant constant = asJavaConstant(value);
if (constant instanceof PrimitiveConstant) {
final long longValue = constant.asLong();
long maskedValue;
switch(constant.getJavaKind()) {
case Boolean:
case Byte:
maskedValue = longValue & 0xFF;
break;
case Char:
case Short:
maskedValue = longValue & 0xFFFF;
break;
case Int:
maskedValue = longValue & 0xFFFF_FFFF;
break;
case Long:
maskedValue = longValue;
break;
default:
throw GraalError.shouldNotReachHere();
}
return AArch64MacroAssembler.isArithmeticImmediate(maskedValue);
} else {
return constant.isDefaultForKind();
}
}
return false;
}
use of jdk.vm.ci.meta.JavaConstant in project graal by oracle.
the class ConditionalNode method inferStamp.
@Override
public boolean inferStamp() {
Stamp valueStamp = trueValue.stamp(NodeView.DEFAULT).meet(falseValue.stamp(NodeView.DEFAULT));
if (condition instanceof IntegerLessThanNode) {
IntegerLessThanNode lessThan = (IntegerLessThanNode) condition;
if (lessThan.getX() == trueValue && lessThan.getY() == falseValue) {
// this encodes a min operation
JavaConstant constant = lessThan.getX().asJavaConstant();
if (constant == null) {
constant = lessThan.getY().asJavaConstant();
}
if (constant != null) {
IntegerStamp bounds = StampFactory.forInteger(constant.getJavaKind(), constant.getJavaKind().getMinValue(), constant.asLong());
valueStamp = valueStamp.join(bounds);
}
} else if (lessThan.getX() == falseValue && lessThan.getY() == trueValue) {
// this encodes a max operation
JavaConstant constant = lessThan.getX().asJavaConstant();
if (constant == null) {
constant = lessThan.getY().asJavaConstant();
}
if (constant != null) {
IntegerStamp bounds = StampFactory.forInteger(constant.getJavaKind(), constant.asLong(), constant.getJavaKind().getMaxValue());
valueStamp = valueStamp.join(bounds);
}
}
}
return updateStamp(valueStamp);
}
use of jdk.vm.ci.meta.JavaConstant in project graal by oracle.
the class ObjectScanner method scanMethod.
private void scanMethod(AnalysisMethod method) {
try {
StreamSupport.stream(method.getTypeFlow().getGraph().getNodes().spliterator(), false).filter(n -> n instanceof ConstantNode).forEach(n -> {
ConstantNode cn = (ConstantNode) n;
JavaConstant c = (JavaConstant) cn.getValue();
if (c.getJavaKind() == JavaKind.Object) {
scanConstant(c, method);
}
});
} catch (UnsupportedFeatureException ex) {
bb.getUnsupportedFeatures().addMessage(method.format("%H.%n(%p)"), method, ex.getMessage(), null, ex);
}
}
use of jdk.vm.ci.meta.JavaConstant in project graal by oracle.
the class ObjectScanner method scanField.
/**
* Scans the value of a field giving a receiver object.
*
* @param field the scanned field
* @param receiver the receiver object
* @param reason what triggered the scanning
*/
protected final void scanField(AnalysisField field, JavaConstant receiver, Object reason) {
try {
JavaConstant fieldValue = bb.getConstantReflectionProvider().readFieldValue(field, receiver);
if (fieldValue.getJavaKind() == JavaKind.Object && bb.getHostVM().isRelocatedPointer(bb.getSnippetReflectionProvider().asObject(Object.class, fieldValue))) {
forRelocatedPointerFieldValue(receiver, field, fieldValue);
} else if (fieldValue.isNull()) {
forNullFieldValue(receiver, field);
} else if (fieldValue.getJavaKind() == JavaKind.Object) {
if (receiver == null) {
registerRoot(fieldValue, field);
} else {
propagateRoot(receiver, fieldValue);
}
/* Scan the field value. */
scanConstant(fieldValue, reason);
/* Process the field value. */
forNonNullFieldValue(receiver, field, fieldValue);
}
} catch (UnsupportedFeatureException ex) {
unsupportedFeature(field.format("%H.%n"), ex.getMessage(), reason);
}
}
Aggregations