use of org.graalvm.compiler.nodes.ConstantNode in project graal by oracle.
the class AheadOfTimeCompilationTest method testBoxedBooleanAOT.
@Test
public void testBoxedBooleanAOT() {
StructuredGraph result = compile("getBoxedBoolean", true);
assertDeepEquals(0, result.getNodes().filter(FloatingReadNode.class).count());
assertDeepEquals(0, result.getNodes(PiNode.TYPE).count());
assertDeepEquals(1, getConstantNodes(result).count());
ConstantNode constant = getConstantNodes(result).first();
assertDeepEquals(JavaKind.Object, constant.getStackKind());
JavaConstant c = constant.asJavaConstant();
Assert.assertEquals(getSnippetReflection().asObject(Boolean.class, c), Boolean.TRUE);
}
use of org.graalvm.compiler.nodes.ConstantNode in project graal by oracle.
the class AheadOfTimeCompilationTest method testClassObjectAOT.
@Test
public void testClassObjectAOT() {
StructuredGraph result = compile("getClassObject", true);
NodeIterable<ConstantNode> filter = getConstantNodes(result);
assertDeepEquals(1, filter.count());
HotSpotResolvedObjectType type = (HotSpotResolvedObjectType) getMetaAccess().lookupJavaType(AheadOfTimeCompilationTest.class);
assertDeepEquals(type.klass(), filter.first().asConstant());
int expected = runtime().getVMConfig().classMirrorIsHandle ? 2 : 1;
assertDeepEquals(expected, result.getNodes().filter(ReadNode.class).count());
}
use of org.graalvm.compiler.nodes.ConstantNode in project graal by oracle.
the class AheadOfTimeCompilationTest method testClassObject.
@Test
public void testClassObject() {
StructuredGraph result = compile("getClassObject", false);
NodeIterable<ConstantNode> filter = getConstantNodes(result);
assertDeepEquals(1, filter.count());
JavaConstant c = filter.first().asJavaConstant();
Assert.assertEquals(getSnippetReflection().asObject(Class.class, c), AheadOfTimeCompilationTest.class);
assertDeepEquals(0, result.getNodes().filter(ReadNode.class).count());
}
use of org.graalvm.compiler.nodes.ConstantNode in project graal by oracle.
the class InstalledCodeExecuteHelperTest method parse.
@Override
protected StructuredGraph parse(Builder builder, PhaseSuite<HighTierContext> graphBuilderSuite) {
StructuredGraph graph = super.parse(builder, graphBuilderSuite);
if (argsToBind != null) {
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 (int i = 0; i < argsToBind.length; i++) {
ParameterNode param = graph.getParameter(i);
JavaConstant c = getSnippetReflection().forBoxed(parameterTypes[i].getJavaKind(), argsToBind[i]);
ConstantNode replacement = ConstantNode.forConstant(c, getMetaAccess(), graph);
param.replaceAtUsages(replacement);
}
}
return graph;
}
use of org.graalvm.compiler.nodes.ConstantNode in project graal by oracle.
the class BinaryGraphPrinter method nodeProperties.
@Override
@SuppressWarnings({ "unchecked", "rawtypes" })
public void nodeProperties(GraphInfo info, Node node, Map<String, Object> props) {
node.getDebugProperties((Map) props);
Graph graph = info.graph;
ControlFlowGraph cfg = info.cfg;
NodeMap<Block> nodeToBlocks = info.nodeToBlocks;
if (cfg != null && DebugOptions.PrintGraphProbabilities.getValue(graph.getOptions()) && node instanceof FixedNode) {
try {
props.put("probability", cfg.blockFor(node).probability());
} catch (Throwable t) {
props.put("probability", 0.0);
props.put("probability-exception", t);
}
}
try {
props.put("NodeCost-Size", node.estimatedNodeSize());
props.put("NodeCost-Cycles", node.estimatedNodeCycles());
} catch (Throwable t) {
props.put("node-cost-exception", t.getMessage());
}
if (nodeToBlocks != null) {
Object block = getBlockForNode(node, nodeToBlocks);
if (block != null) {
props.put("node-to-block", block);
}
}
if (node instanceof ControlSinkNode) {
props.put("category", "controlSink");
} else if (node instanceof ControlSplitNode) {
props.put("category", "controlSplit");
} else if (node instanceof AbstractMergeNode) {
props.put("category", "merge");
} else if (node instanceof AbstractBeginNode) {
props.put("category", "begin");
} else if (node instanceof AbstractEndNode) {
props.put("category", "end");
} else if (node instanceof FixedNode) {
props.put("category", "fixed");
} else if (node instanceof VirtualState) {
props.put("category", "state");
} else if (node instanceof PhiNode) {
props.put("category", "phi");
} else if (node instanceof ProxyNode) {
props.put("category", "proxy");
} else {
if (node instanceof ConstantNode) {
ConstantNode cn = (ConstantNode) node;
updateStringPropertiesForConstant((Map) props, cn);
}
props.put("category", "floating");
}
if (getSnippetReflectionProvider() != null) {
for (Map.Entry<String, Object> prop : props.entrySet()) {
if (prop.getValue() instanceof JavaConstantFormattable) {
props.put(prop.getKey(), ((JavaConstantFormattable) prop.getValue()).format(this));
}
}
}
}
Aggregations