use of jdk.vm.ci.meta.PrimitiveConstant in project graal by oracle.
the class ArrayCopyCallNode method updateAlignedDisjoint.
public void updateAlignedDisjoint() {
JavaKind componentKind = elementKind;
if (srcPos == destPos) {
// Can treat as disjoint
disjoint = true;
}
PrimitiveConstant constantSrc = (PrimitiveConstant) srcPos.stamp(NodeView.DEFAULT).asConstant();
PrimitiveConstant constantDst = (PrimitiveConstant) destPos.stamp(NodeView.DEFAULT).asConstant();
if (constantSrc != null && constantDst != null) {
if (!aligned) {
aligned = isHeapWordAligned(constantSrc, componentKind) && isHeapWordAligned(constantDst, componentKind);
}
if (constantSrc.asInt() >= constantDst.asInt()) {
// low to high copy so treat as disjoint
disjoint = true;
}
}
}
use of jdk.vm.ci.meta.PrimitiveConstant in project graal by oracle.
the class AnalysisType method getCachedConstantObject.
public AnalysisObject getCachedConstantObject(BigBang bb, JavaConstant constant) {
/*
* Constant caching is only used we certain analysis policies. Ideally we would store the
* cache in the policy, but it is simpler to store the cache for each type.
*/
assert bb.analysisPolicy().needsConstantCache() : "The analysis policy doesn't specify the need for a constants cache.";
assert bb.trackConcreteAnalysisObjects(this);
assert !(constant instanceof PrimitiveConstant) : "The analysis should not model PrimitiveConstant.";
if (uniqueConstant != null) {
// The constants have been merged, return the unique constant
return uniqueConstant;
}
if (constantObjectsCache.size() > PointstoOptions.MaxConstantObjectsPerType.getValue(bb.getOptions())) {
// The number of constant objects has increased above the limit,
// merge the constants in the uniqueConstant and return it
mergeConstantObjects(bb);
return uniqueConstant;
}
// Get the analysis ConstantObject modeling the JavaConstant
AnalysisObject result = constantObjectsCache.get(constant);
if (result == null) {
// Create a ConstantObject to model each JavaConstant
ConstantContextSensitiveObject newValue = new ConstantContextSensitiveObject(bb, this, constant);
ConstantContextSensitiveObject oldValue = constantObjectsCache.putIfAbsent(constant, newValue);
result = oldValue != null ? oldValue : newValue;
if (PointstoOptions.ProfileConstantObjects.getValue(bb.getOptions())) {
ConstantObjectsProfiler.registerConstant(this);
ConstantObjectsProfiler.maybeDumpConstantHistogram();
}
}
return result;
}
use of jdk.vm.ci.meta.PrimitiveConstant in project graal by oracle.
the class MulNode method canonical.
private static ValueNode canonical(MulNode self, BinaryOp<Mul> op, Stamp stamp, ValueNode forX, ValueNode forY, NodeView view) {
if (forY.isConstant()) {
Constant c = forY.asConstant();
if (op.isNeutral(c)) {
return forX;
}
if (c instanceof PrimitiveConstant && ((PrimitiveConstant) c).getJavaKind().isNumericInteger()) {
long i = ((PrimitiveConstant) c).asLong();
ValueNode result = canonical(stamp, forX, i, view);
if (result != null) {
return result;
}
}
if (op.isAssociative()) {
// canonicalize expressions like "(a * 1) * 2"
return reassociate(self != null ? self : (MulNode) new MulNode(forX, forY).maybeCommuteInputs(), ValueNode.isConstantPredicate(), forX, forY, view);
}
}
return self != null ? self : new MulNode(forX, forY).maybeCommuteInputs();
}
use of jdk.vm.ci.meta.PrimitiveConstant in project graal by oracle.
the class SubstrateMemoryAccessProviderImpl method readObjectConstant.
private static JavaConstant readObjectConstant(Constant baseConstant, long displacement, boolean requireCompressed) {
SignedWord offset = WordFactory.signed(displacement);
if (baseConstant instanceof SubstrateObjectConstant) {
// always compressed (if enabled)
assert !requireCompressed || ReferenceAccess.singleton().haveCompressedReferences();
Object baseObject = ((SubstrateObjectConstant) baseConstant).getObject();
assert baseObject != null : "SubstrateObjectConstant does not wrap null value";
Object rawValue = BarrieredAccess.readObject(baseObject, offset);
return SubstrateObjectConstant.forObject(rawValue, requireCompressed);
}
if (baseConstant instanceof PrimitiveConstant) {
// never compressed
assert !requireCompressed;
PrimitiveConstant prim = (PrimitiveConstant) baseConstant;
if (!prim.getJavaKind().isNumericInteger()) {
return null;
}
Word baseAddress = WordFactory.unsigned(prim.asLong());
if (baseAddress.equal(0)) {
return null;
}
Word address = baseAddress.add(offset);
Object rawValue = ReferenceAccess.singleton().readObjectAt(address, false);
return SubstrateObjectConstant.forObject(rawValue, false);
}
return null;
}
use of jdk.vm.ci.meta.PrimitiveConstant in project graal by oracle.
the class HotSpotResolvedObjectTypeTest method testKlassLayoutHelper.
@Test
public void testKlassLayoutHelper() {
Constant klass = HotSpotResolvedObjectType.fromObjectClass(this.getClass()).klass();
MemoryAccessProvider memoryAccess = getProviders().getConstantReflection().getMemoryAccessProvider();
GraalHotSpotVMConfig config = runtime().getVMConfig();
Constant c = StampFactory.forKind(JavaKind.Int).readConstant(memoryAccess, klass, config.klassLayoutHelperOffset);
assertTrue(c.toString(), c.getClass() == PrimitiveConstant.class);
PrimitiveConstant pc = (PrimitiveConstant) c;
assertTrue(pc.toString(), pc.getJavaKind() == JavaKind.Int);
}
Aggregations