use of jdk.vm.ci.meta.JavaConstant in project graal by oracle.
the class UnboxNode method findSynonym.
private static ValueNode findSynonym(MetaAccessProvider metaAccess, ConstantReflectionProvider constantReflection, ValueNode forValue, JavaKind boxingKind) {
if (forValue.isConstant()) {
JavaConstant constant = forValue.asJavaConstant();
JavaConstant unboxed = constantReflection.unboxPrimitive(constant);
if (unboxed != null && unboxed.getJavaKind() == boxingKind) {
return ConstantNode.forConstant(unboxed, metaAccess);
}
} else if (forValue instanceof BoxNode) {
BoxNode box = (BoxNode) forValue;
if (boxingKind == box.getBoxingKind()) {
return box.getValue();
}
}
return null;
}
use of jdk.vm.ci.meta.JavaConstant in project graal by oracle.
the class Inflation method scanHub.
private void scanHub(ObjectScanner objectScanner, AnalysisType type) {
SVMHost svmHost = (SVMHost) hostVM;
JavaConstant hubConstant = SubstrateObjectConstant.forObject(svmHost.dynamicHub(type));
objectScanner.scanConstant(hubConstant, "Hub");
}
use of jdk.vm.ci.meta.JavaConstant in project graal by oracle.
the class AnnotationSubstitutionField method readValue.
@Override
public JavaConstant readValue(JavaConstant receiver) {
JavaConstant result = valueCache.get(receiver);
if (result == null) {
try {
/*
* Invoke the accessor method of the annotation object. Since array attributes
* return a different, newly allocated, array at every invocation, we cache the
* result value.
*/
Proxy proxy = snippetReflection.asObject(Proxy.class, receiver);
Method reflectionMethod = proxy.getClass().getDeclaredMethod(accessorMethod.getName());
reflectionMethod.setAccessible(true);
result = snippetReflection.forBoxed(getJavaKind(), reflectionMethod.invoke(proxy));
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException ex) {
throw VMError.shouldNotReachHere(ex);
}
valueCache.put(receiver, result);
}
return result;
}
use of jdk.vm.ci.meta.JavaConstant in project graal by oracle.
the class SPARCAddressLowering method lower.
private AddressNode lower(ValueNode base, long displacement) {
if (base instanceof AddNode) {
AddNode add = (AddNode) base;
JavaConstant immX = asImmediate(add.getX());
if (immX != null && SPARCAssembler.isSimm13(displacement + immX.asLong())) {
return lower(add.getY(), displacement + immX.asLong());
}
JavaConstant immY = asImmediate(add.getY());
if (immY != null && SPARCAssembler.isSimm13(displacement + immY.asLong())) {
return lower(add.getX(), displacement + immY.asLong());
}
if (displacement == 0) {
return lower(add.getX(), add.getY());
}
}
assert SPARCAssembler.isSimm13(displacement);
return base.graph().unique(new SPARCImmediateAddressNode(base, (int) displacement));
}
use of jdk.vm.ci.meta.JavaConstant in project graal by oracle.
the class ConditionTest method testJoin.
@Test
public void testJoin() {
Random rand = new Random(13);
for (Condition c1 : Condition.values()) {
for (Condition c2 : Condition.values()) {
Condition join = c1.join(c2);
assertEquals(join, c2.join(c1));
if (join != null) {
for (int i = 0; i < 1000; i++) {
JavaConstant a = JavaConstant.forInt(rand.nextInt());
JavaConstant b = JavaConstant.forInt(i < 100 ? a.asInt() : rand.nextInt());
boolean result1 = c1.foldCondition(a, b, null, false);
boolean result2 = c2.foldCondition(a, b, null, false);
boolean resultJoin = join.foldCondition(a, b, null, false);
if (result1 && result2) {
assertTrue(resultJoin);
} else {
assertFalse(resultJoin);
}
}
}
}
}
}
Aggregations