use of jdk.vm.ci.meta.JavaConstant in project graal by oracle.
the class GraalCompilerTest method bindArguments.
protected void bindArguments(StructuredGraph graph, Object[] argsToBind) {
ResolvedJavaMethod m = graph.method();
Object receiver = isStatic(m.getModifiers()) ? null : this;
Object[] args = argsWithReceiver(receiver, argsToBind);
JavaType[] parameterTypes = m.toParameterTypes();
assert parameterTypes.length == args.length;
for (ParameterNode param : graph.getNodes(ParameterNode.TYPE)) {
JavaConstant c = getSnippetReflection().forBoxed(parameterTypes[param.index()].getJavaKind(), args[param.index()]);
ConstantNode replacement = ConstantNode.forConstant(c, getMetaAccess(), graph);
param.replaceAtUsages(replacement);
}
}
use of jdk.vm.ci.meta.JavaConstant in project graal by oracle.
the class ConditionTest method testMeet.
@Test
public void testMeet() {
Random rand = new Random(13);
for (Condition c1 : Condition.values()) {
for (Condition c2 : Condition.values()) {
Condition meet = c1.meet(c2);
assertEquals(meet, c2.meet(c1));
if (meet != 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 resultMeet = meet.foldCondition(a, b, null, false);
if (result1 || result2) {
assertTrue(resultMeet);
} else {
assertFalse(resultMeet);
}
}
}
}
}
}
use of jdk.vm.ci.meta.JavaConstant in project graal by oracle.
the class NegateNodeCanonicalizationTest method testLong.
@Test
public void testLong() {
long[] a = new long[] { Long.MIN_VALUE, Long.MIN_VALUE + 1, -1, 0, 1, Long.MAX_VALUE - 1, Long.MAX_VALUE };
for (long i : a) {
ConstantNode node = ConstantNode.forLong(i, graph);
JavaConstant expected = JavaConstant.forLong(-i);
assertEquals(expected, ArithmeticOpTable.forStamp(node.stamp(NodeView.DEFAULT)).getNeg().foldConstant(node.asConstant()));
}
}
use of jdk.vm.ci.meta.JavaConstant in project graal by oracle.
the class NegateNodeCanonicalizationTest method testByte.
@Test
public void testByte() {
byte[] a = new byte[] { Byte.MIN_VALUE, Byte.MIN_VALUE + 1, -1, 0, 1, Byte.MAX_VALUE - 1, Byte.MAX_VALUE };
for (byte i : a) {
ConstantNode node = ConstantNode.forByte(i, graph);
JavaConstant expected = JavaConstant.forInt(-i);
assertEquals(expected, ArithmeticOpTable.forStamp(node.stamp(NodeView.DEFAULT)).getNeg().foldConstant(node.asConstant()));
}
}
use of jdk.vm.ci.meta.JavaConstant in project graal by oracle.
the class DynamicDeoptimizeNode method canonical.
@Override
public Node canonical(CanonicalizerTool tool) {
if (actionAndReason.isConstant() && speculation.isConstant()) {
JavaConstant constant = actionAndReason.asJavaConstant();
JavaConstant speculationConstant = speculation.asJavaConstant();
DeoptimizeNode newDeopt = new DeoptimizeNode(tool.getMetaAccess().decodeDeoptAction(constant), tool.getMetaAccess().decodeDeoptReason(constant), tool.getMetaAccess().decodeDebugId(constant), speculationConstant, stateBefore());
return newDeopt;
}
return this;
}
Aggregations