NullPointerException in HotSpotRuntime:lower when using Snippets
Doug Simon
doug.simon at oracle.com
Sun Jul 7 13:58:46 PDT 2013
In general, snippets inline any calls they make except for foreign calls. Wha call is not being inlined and do you know why not? You can figure this out by debugging the call to ReplacementsImpl.buildGraph() when your snippet is be processed.
On Jul 6, 2013, at 12:14 AM, ATKIN-GRANVILLE Chris <s1255753 at sms.ed.ac.uk> wrote:
> Thanks for the advice. I tried your suggestions and I can now access fields in the snippet (so far I'm just incrementing a static field). However, if I try to do something a little more fancy like calling a method, I get another exception. I'll investigate further next week, but if you have any suggestions they'd be appreciated. FWIW I tried outputting to stdout whenever a node (i.e., my custom node) is being lowered and this error doesn't occur for *all* nodes - it appears to correctly lower some nodes first. I think I do some pattern matching and only replace nodes within loops (which are the only ones I'm interested in) and hope that the problem will go away that way but I haven't had time to try that (yet).
>
> scope: GraalCompiler.FrontEnd.LowTier.Lowering.IncrementalCanonicalizer.Lowering iteration 0.InterceptException
> Exception occurred in scope: GraalCompiler.FrontEnd.LowTier.Lowering.IncrementalCanonicalizer.Lowering iteration 0.InterceptException
> Context obj com.oracle.graal.graph.GraalInternalError: Cannot create guards in after-guard lowering
> Context obj com.oracle.graal.phases.common.LoweringPhase$Round at 76505305
> Context obj com.oracle.graal.phases.common.IncrementalCanonicalizerPhase at 14cd1699
> Context obj com.oracle.graal.phases.common.LoweringPhase at 77888435
> Context obj com.oracle.graal.compiler.phases.LowTier at 73a1e9a9
> Context obj StructuredGraph:3{HotSpotMethod<CodeSamples.loopDependency(int[], int[])>}
> Connected to the IGV on 127.0.0.1:4445
> Context obj com.oracle.graal.hotspot.amd64.AMD64HotSpotRuntime at 5ad851c9
> Exception in thread "main" com.oracle.graal.graph.GraalInternalError: Cannot create guards in after-guard lowering
> at com.oracle.graal.phases.common.LoweringPhase$LoweringToolImpl.createGuard(LoweringPhase.java:103)
> at com.oracle.graal.phases.common.LoweringPhase$LoweringToolImpl.createNullCheckGuard(LoweringPhase.java:84)
> at com.oracle.graal.hotspot.meta.HotSpotRuntime.lower(HotSpotRuntime.java:497)
> at com.oracle.graal.hotspot.amd64.AMD64HotSpotRuntime.lower(AMD64HotSpotRuntime.java:82)
> at com.oracle.graal.nodes.InvokeNode.lower(InvokeNode.java:112)
> at com.oracle.graal.phases.common.LoweringPhase$Round.process(LoweringPhase.java:258)
> at com.oracle.graal.phases.common.LoweringPhase$Round.processBlock(LoweringPhase.java:192)
> at com.oracle.graal.phases.common.LoweringPhase$Round.processBlock(LoweringPhase.java:204)
> at com.oracle.graal.phases.common.LoweringPhase$Round.processBlock(LoweringPhase.java:204)
> at com.oracle.graal.phases.common.LoweringPhase$Round.processBlock(LoweringPhase.java:204)
> at com.oracle.graal.phases.common.LoweringPhase$Round.processBlock(LoweringPhase.java:204)
> at com.oracle.graal.phases.common.LoweringPhase$Round.processBlock(LoweringPhase.java:204)
> at com.oracle.graal.phases.common.LoweringPhase$Round.run(LoweringPhase.java:183)
> at com.oracle.graal.phases.Phase.run(Phase.java:51)
> at com.oracle.graal.phases.BasePhase$1.run(BasePhase.java:62)
> at com.oracle.graal.debug.internal.DebugScope.executeScope(DebugScope.java:179)
> at com.oracle.graal.debug.internal.DebugScope.scope(DebugScope.java:167)
> at com.oracle.graal.debug.Debug.scope(Debug.java:118)
> at com.oracle.graal.debug.Debug.scope(Debug.java:113)
> at com.oracle.graal.phases.BasePhase.apply(BasePhase.java:59)
> at com.oracle.graal.phases.BasePhase.apply(BasePhase.java:55)
> at com.oracle.graal.phases.PhaseSuite.run(PhaseSuite.java:69)
> at com.oracle.graal.phases.common.IncrementalCanonicalizerPhase.run(IncrementalCanonicalizerPhase.java:47)
> at com.oracle.graal.phases.common.IncrementalCanonicalizerPhase.run(IncrementalCanonicalizerPhase.java:1)
> at com.oracle.graal.phases.BasePhase$1.run(BasePhase.java:62)
> at com.oracle.graal.debug.internal.DebugScope.executeScope(DebugScope.java:179)
> at com.oracle.graal.debug.internal.DebugScope.scope(DebugScope.java:167)
> at com.oracle.graal.debug.Debug.scope(Debug.java:118)
> at com.oracle.graal.debug.Debug.scope(Debug.java:113)
> at com.oracle.graal.phases.BasePhase.apply(BasePhase.java:59)
> at com.oracle.graal.phases.BasePhase.apply(BasePhase.java:55)
> at com.oracle.graal.phases.common.LoweringPhase.run(LoweringPhase.java:159)
> at com.oracle.graal.phases.common.LoweringPhase.run(LoweringPhase.java:1)
> at com.oracle.graal.phases.BasePhase$1.run(BasePhase.java:62)
> at com.oracle.graal.debug.internal.DebugScope.executeScope(DebugScope.java:179)
> at com.oracle.graal.debug.internal.DebugScope.scope(DebugScope.java:167)
> at com.oracle.graal.debug.Debug.scope(Debug.java:118)
> at com.oracle.graal.debug.Debug.scope(Debug.java:113)
> at com.oracle.graal.phases.BasePhase.apply(BasePhase.java:59)
> at com.oracle.graal.phases.BasePhase.apply(BasePhase.java:55)
> at com.oracle.graal.phases.PhaseSuite.run(PhaseSuite.java:69)
> at com.oracle.graal.phases.BasePhase$1.run(BasePhase.java:62)
> at com.oracle.graal.debug.internal.DebugScope.executeScope(DebugScope.java:179)
> at com.oracle.graal.debug.internal.DebugScope.scope(DebugScope.java:167)
> at com.oracle.graal.debug.Debug.scope(Debug.java:118)
> at com.oracle.graal.debug.Debug.scope(Debug.java:113)
> at com.oracle.graal.phases.BasePhase.apply(BasePhase.java:59)
> at com.oracle.graal.phases.BasePhase.apply(BasePhase.java:55)
> at com.oracle.graal.compiler.GraalCompiler.emitHIR(GraalCompiler.java:172)
> at com.oracle.graal.compiler.GraalCompiler$1$1.call(GraalCompiler.java:86)
> at com.oracle.graal.compiler.GraalCompiler$1$1.call(GraalCompiler.java:1)
> at com.oracle.graal.debug.internal.DebugScope.call(DebugScope.java:301)
> at com.oracle.graal.debug.internal.DebugScope.executeScope(DebugScope.java:182)
> at com.oracle.graal.debug.internal.DebugScope.scope(DebugScope.java:167)
> at com.oracle.graal.debug.Debug.scope(Debug.java:138)
> at com.oracle.graal.debug.Debug.scope(Debug.java:109)
> at com.oracle.graal.compiler.GraalCompiler$1.run(GraalCompiler.java:83)
> at com.oracle.graal.debug.internal.DebugScope.executeScope(DebugScope.java:179)
> at com.oracle.graal.debug.internal.DebugScope.scope(DebugScope.java:167)
> at com.oracle.graal.debug.Debug.scope(Debug.java:118)
> at com.oracle.graal.compiler.GraalCompiler.compileGraph(GraalCompiler.java:79)
> at uk.ac.ed.inf.icsa.locomotion.core.Locomotion.compile(Locomotion.java:57)
> at uk.ac.ed.inf.icsa.locomotion.Application.run(Application.java:46)
> at uk.ac.ed.inf.icsa.locomotion.Application.main(Application.java:65)
>
>
>
> On 3 Jul 2013, at 14:53, Doug Simon <doug.simon at oracle.com> wrote:
>
> >
> > On Jul 2, 2013, at 9:36 PM, ATKIN-GRANVILLE Chris <s1255753 at sms.ed.ac.uk> wrote:
> >
> >> Hi there,
> >>
> >> I'm trying add arbitrary behaviour to array accesses - the end goal being to create traces of all memory operations within a program. What I've done so far was suggested to me in a previous thread on this list, but in short, I've got phases that add my own custom nodes to each LoadIndexedNode/StoreIndexedNode. These are then lowered to the desired behaviour via snippets:
> >>
> >> public class InstrumentationSnippets implements Snippets {
> >> @Snippet
> >> public static void store(final ArrayStoreBehaviourNode<?> node) {
> >> Instrument.arrayStores.add(node.getInfo());
> >> }
> >>
> >> @Snippet
> >> public static void load(final ArrayLoadBehaviourNode<?> node) {
> >> Instrument.arrayLoads.add(node.getInfo());
> >> }
> >
> > This doesn't look right, having compiler nodes as parameter types of snippets. The value of a snippet parameter may come from a compiler node when the snippet is instantiated (during lowering) but the snippet sees the "raw" Java type of the value. Assuming ArrayLoadInfo is the type returned by node.getInfo(), you probably want something like this:
> >
> > @Snippet
> > public static void load(ArrayLoadInfo info) {
> > Instrument.arrayLoads.add(info);
> > }
> >
> >
> >> public static class Templates extends AbstractTemplates {
> >> private final SnippetInfo store = snippet(InstrumentationSnippets.class, "store");
> >> private final SnippetInfo load = snippet(InstrumentationSnippets.class, "load");
> >>
> >> public Templates(MetaAccessProvider runtime, Replacements replacements, TargetDescription target) {
> >> super(runtime, replacements, target);
> >> }
> >>
> >> public void lower(final ArrayStoreBehaviourNode<?> node) {
> >> Arguments args = new Arguments(store);
> >> args.add("node", node);
> >
> > and replace the above with:
> >
> > args.add("info", node.getInfo());
> >
> > -Doug
>
> <except.xml>The University of Edinburgh is a charitable body, registered in
> Scotland, with registration number SC005336.
More information about the graal-dev
mailing list