use of jdk.vm.ci.meta.Constant in project graal by oracle.
the class AArch64HotSpotLIRGenerator method emitCompare.
@Override
protected boolean emitCompare(PlatformKind cmpKind, Value a, Value b, Condition condition, boolean unorderedIsTrue) {
Value localA = a;
Value localB = b;
if (isConstantValue(a)) {
Constant c = asConstant(a);
if (HotSpotCompressedNullConstant.COMPRESSED_NULL.equals(c)) {
localA = AArch64.zr.asValue(LIRKind.value(AArch64Kind.DWORD));
} else if (c instanceof HotSpotObjectConstant) {
localA = load(localA);
}
}
if (isConstantValue(b)) {
Constant c = asConstant(b);
if (HotSpotCompressedNullConstant.COMPRESSED_NULL.equals(c)) {
localB = AArch64.zr.asValue(LIRKind.value(AArch64Kind.DWORD));
} else if (c instanceof HotSpotObjectConstant) {
localB = load(localB);
}
}
return super.emitCompare(cmpKind, localA, localB, condition, unorderedIsTrue);
}
use of jdk.vm.ci.meta.Constant in project graal by oracle.
the class GetClassNode method virtualize.
@Override
public void virtualize(VirtualizerTool tool) {
ValueNode alias = tool.getAlias(getObject());
if (alias instanceof VirtualObjectNode) {
VirtualObjectNode virtual = (VirtualObjectNode) alias;
Constant javaClass = tool.getConstantReflectionProvider().asJavaClass(virtual.type());
tool.replaceWithValue(ConstantNode.forConstant(stamp(NodeView.DEFAULT), javaClass, tool.getMetaAccessProvider(), graph()));
}
}
use of jdk.vm.ci.meta.Constant in project graal by oracle.
the class RawLoadNode method canonical.
@Override
public Node canonical(CanonicalizerTool tool) {
if (!isAnyLocationForced() && getLocationIdentity().isAny()) {
ValueNode targetObject = object();
if (offset().isConstant() && targetObject.isConstant() && !targetObject.isNullConstant()) {
ConstantNode objectConstant = (ConstantNode) targetObject;
ResolvedJavaType type = StampTool.typeOrNull(objectConstant);
if (type != null && type.isArray()) {
JavaConstant arrayConstant = objectConstant.asJavaConstant();
if (arrayConstant != null) {
int stableDimension = objectConstant.getStableDimension();
if (stableDimension > 0) {
NodeView view = NodeView.from(tool);
long constantOffset = offset().asJavaConstant().asLong();
Constant constant = stamp(view).readConstant(tool.getConstantReflection().getMemoryAccessProvider(), arrayConstant, constantOffset);
boolean isDefaultStable = objectConstant.isDefaultStable();
if (constant != null && (isDefaultStable || !constant.isDefaultForKind())) {
return ConstantNode.forConstant(stamp(view), constant, stableDimension - 1, isDefaultStable, tool.getMetaAccess());
}
}
}
}
}
}
return super.canonical(tool);
}
use of jdk.vm.ci.meta.Constant in project graal by oracle.
the class ConvertDeoptimizeToGuardPhase method processFixedGuardAndMerge.
@SuppressWarnings("try")
private void processFixedGuardAndMerge(FixedGuardNode fixedGuard, PhaseContext context, CompareNode compare, ValueNode x, ValuePhiNode xPhi, ValueNode y, ValuePhiNode yPhi, AbstractMergeNode merge) {
List<EndNode> mergePredecessors = merge.cfgPredecessors().snapshot();
for (int i = 0; i < mergePredecessors.size(); ++i) {
AbstractEndNode mergePredecessor = mergePredecessors.get(i);
if (!mergePredecessor.isAlive()) {
break;
}
Constant xs;
if (xPhi == null) {
xs = x.asConstant();
} else {
xs = xPhi.valueAt(mergePredecessor).asConstant();
}
Constant ys;
if (yPhi == null) {
ys = y.asConstant();
} else {
ys = yPhi.valueAt(mergePredecessor).asConstant();
}
if (xs != null && ys != null && compare.condition().foldCondition(xs, ys, context.getConstantReflection(), compare.unorderedIsTrue()) == fixedGuard.isNegated()) {
try (DebugCloseable position = fixedGuard.withNodeSourcePosition()) {
propagateFixed(mergePredecessor, fixedGuard, context.getLowerer());
}
}
}
}
use of jdk.vm.ci.meta.Constant in project graal by oracle.
the class GraphUtil method foldIfConstantAndRemove.
public static Constant foldIfConstantAndRemove(ValueNode node, ValueNode constant) {
assert node.inputs().contains(constant);
if (constant.isConstant()) {
node.replaceFirstInput(constant, null);
Constant result = constant.asConstant();
tryKillUnused(constant);
return result;
}
return null;
}
Aggregations