NullPointerException in HotSpotRuntime:lower when using Snippets

ATKIN-GRANVILLE Chris s1255753 at sms.ed.ac.uk
Wed Jul 3 05:20:56 PDT 2013


Perhaps I have to install any methods I call in my snippet into Graal before I can execute them?

On 2 Jul 2013, at 20:36, 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());
> 	}
> 	
> 	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);
> 			
> 			template(args).instantiate(runtime, node, DEFAULT_REPLACER, args);
> 		}
> 		
> 		public void lower(final ArrayLoadBehaviourNode<?> node) {
> 			Arguments args = new Arguments(load);
> 			args.add("node", node);
> 			
> 			template(args).instantiate(runtime, node, DEFAULT_REPLACER, args);
> 		}
> 	}
> }
> 
> However, doing this causes NullPointerExceptions to be thrown in HotSpotRuntime:lower:
> 
> java.lang.NullPointerException
> 	at com.oracle.graal.hotspot.meta.HotSpotRuntime.lower(HotSpotRuntime.java:527)
> 	at com.oracle.graal.hotspot.amd64.AMD64HotSpotRuntime.lower(AMD64HotSpotRuntime.java:218)
> 	at com.oracle.graal.nodes.InvokeNode.lower(InvokeNode.java:97)
> 	at com.oracle.graal.phases.common.LoweringPhase$Round.process(LoweringPhase.java:232)
> 	at com.oracle.graal.phases.common.LoweringPhase$Round.processBlock(LoweringPhase.java:182)
> 	at com.oracle.graal.phases.common.LoweringPhase$Round.run(LoweringPhase.java:173)
> 	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:59)
> 	at com.oracle.graal.phases.common.IncrementalCanonicalizerPhase.run(IncrementalCanonicalizerPhase.java:45)
> 	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:145)
> 	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.compiler.GraalCompiler.emitHIR(GraalCompiler.java:143)
> 	at com.oracle.graal.compiler.GraalCompiler$1$1.call(GraalCompiler.java:66)
> 	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:63)
> 	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.compileMethod(GraalCompiler.java:59)
> 	at uk.ac.ed.inf.icsa.locomotion.Locomotion.compile(Locomotion.java:79)
> 	at uk.ac.ed.inf.icsa.locomotion.Application.run(Application.java:34)
> 	at uk.ac.ed.inf.icsa.locomotion.Application.main(Application.java:58)
> 
> Following the stack trace leads to this line being the problem:
> 
> !callTarget.isStatic() && receiver.kind() == Kind.Object && !receiver.objectStamp().nonNull()
> 
> Specifically, receiver == null causes the exception.
> 
> Does anyone have any ideas of how I can get around this problem? Ideally without modifying HotSpotRuntime, but if that's whats required then so be it.
> 
> chris
> 
> -- 
> 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