NullPointerException in HotSpotRuntime:lower when using Snippets

ATKIN-GRANVILLE Chris s1255753 at sms.ed.ac.uk
Mon Jul 8 09:37:00 PDT 2013


Just to add some more information--

There appears to be several nodes for which lowering is successful. I added System.out.println() to display output the WriteNode associated with the Array(Store/Load)BehaviourNode. When these nodes are created, they are instantiated with the toString() of the node their are instrumenting (currently, a WriteNode. In the future hopefully they will contain a reference to the node, but that's on the todo list). It looks like this:

public void lower(final ArrayStoreBehaviourNode node) {
	System.out.println(node.getString());

	Arguments args= … // rest of the lowering stage as below
}

This results in several nodes being lowered, appearingly successfully:

561|Write
586|Write
614|Write
615|Write
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
(snip)

I stepped through the times buildGraph() are called /after/ 615|Write is printed. At no point where methodToParse.forceInline or methodToParse.dontInline true (they were always false). Interestingly it appears as if there are two errors:

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 37313c65
Context obj com.oracle.graal.phases.common.IncrementalCanonicalizerPhase at 465232e9
Context obj com.oracle.graal.phases.common.LoweringPhase at 798162bc
Context obj com.oracle.graal.compiler.phases.LowTier at 1df8da7a
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 478db956

occurs at a different time than the GraalInternalError is thrown.

On 8 Jul 2013, at 16:04, ATKIN-GRANVILLE Chris <s1255753 at sms.ed.ac.uk> wrote:

> I couldn't find a ReplacementsImpl.buildGraph() so I used ReplacementsImpl.GraphMaker.buildGraph() instead, specifically ReplacementsImpl.java:303.
> 
> My snippet at the moment consists of a call to HashSet.add().
> 
> @Snippet
> public static void load(String s) {
> 	// call to add(s) on a public static Set (HashSet)
> }
> 
> private final SnippetInfo load = snippet(InstrumentationSnippets.class, "load");
> 
> My lowering code looks like (in an inner class Templates extending AbstractTemplates):
> 
> public void lower(final ArrayLoadBehaviourNode node) {
> 	Arguments args = new Arguments(load);
> 	args.add("s", node.getInfoAsString());
> 
> 	template(args).instantiate(runtime, node, DEFAULT_REPLACER, args);
> }
> 
> My lowering code is called though a HIGH_LEVEL phase (via Suites) that scans through the graph:
> 
> for(Node n: graph.getNodes())
> 	if (n instanceof ArrayLoadBehaviourNode)
> 		new InstrumentationSnippets.Templates(runtime, replacements, target).lower((ArrayLoadBehaviourNode) n);
> 
> I added a breakpoint to ReplacementsImpl.GraphMaker.pharseGraph() line 303 (return buildGraph(…)). I inspected every call at this point, checking this.this$1.method. There were no calls with dontInline = true or forceInline = true - i.e., they were all false. Is that what you meant?
> 
> On 7 Jul 2013, at 21:58, Doug Simon <doug.simon at oracle.com>
> wrote:
> 
>> 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.
>> 
>> 
> 
> 
> 
> -- 
> The University of Edinburgh is a charitable body, registered in
> Scotland, with registration number SC005336.
> 
> 



-- 
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.



More information about the graal-dev mailing list