# HG changeset patch # User Doug Simon # Date 1339592149 -7200 # Node ID bf4f499cc538ee2368d572e3018777ccdf351f79 # Parent b0d06c58200ceaec613ead0655b5019e3e821e2d added allocation logging to NewInstanceSnippets diff -r b0d06c58200c -r bf4f499cc538 graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalOptions.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalOptions.java Wed Jun 13 14:50:49 2012 +0200 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalOptions.java Wed Jun 13 14:55:49 2012 +0200 @@ -261,7 +261,7 @@ * Only instructions in methods whose fully qualified name contains this option will be HIR lowered. */ public static String HIRLowerCheckcast = ""; - public static String HIRLowerNewInstance = null; + public static String HIRLowerNewInstance = "NewInstanceTest"; /** * The profiling info cache directory. diff -r b0d06c58200c -r bf4f499cc538 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/NewInstanceSnippets.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/NewInstanceSnippets.java Wed Jun 13 14:50:49 2012 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/NewInstanceSnippets.java Wed Jun 13 14:55:49 2012 +0200 @@ -55,16 +55,18 @@ */ public class NewInstanceSnippets implements SnippetsInterface { + private static final boolean LOG_ALLOCATION = false; + /** * Type test used when the type being tested against is a final type. */ @Snippet - public static Object newInstance(@Parameter("hub") Object hub, @ConstantParameter("size") int size, @ConstantParameter("checkInit") boolean checkInit) { + public static Object newInstance(@Parameter("hub") Object hub, @ConstantParameter("size") int size, @ConstantParameter("checkInit") boolean checkInit, @ConstantParameter("logType") String logType) { if (checkInit) { int klassState = load(hub, 0, klassStateOffset(), Kind.Int); if (klassState != klassStateFullyInitialized()) { Object instance = NewInstanceStubCall.call(hub); - return formatInstance(hub, size, instance); + return formatInstance(hub, size, instance, logType); } } @@ -80,7 +82,7 @@ instance = NewInstanceStubCall.call(hub); } - return formatInstance(hub, size, instance); + return formatInstance(hub, size, instance, logType); } private static Word asWord(Object object) { @@ -94,7 +96,7 @@ /** * Formats the header of a created instance and zeroes out its body. */ - private static Object formatInstance(Object hub, int size, Object instance) { + private static Object formatInstance(Object hub, int size, Object instance, String logType) { Word headerPrototype = cast(load(hub, 0, instanceHeaderPrototypeOffset(), wordKind()), Word.class); store(instance, 0, 0, headerPrototype); store(instance, 0, hubOffset(), hub); @@ -102,6 +104,12 @@ for (int offset = 2 * wordSize(); offset < size; offset += wordSize()) { store(instance, 0, offset, 0); } + if (logType != null) { + Log.print("allocated instance of "); + Log.print(logType); + Log.print(" at "); + Log.printlnAddress(instance); + } return instance; } @@ -155,7 +163,7 @@ this.runtime = runtime; this.cache = new Cache(runtime); try { - newInstance = runtime.getResolvedJavaMethod(NewInstanceSnippets.class.getDeclaredMethod("newInstance", Object.class, int.class, boolean.class)); + newInstance = runtime.getResolvedJavaMethod(NewInstanceSnippets.class.getDeclaredMethod("newInstance", Object.class, int.class, boolean.class, String.class)); } catch (NoSuchMethodException e) { throw new GraalInternalError(e); } @@ -170,7 +178,7 @@ HotSpotResolvedJavaType type = (HotSpotResolvedJavaType) newInstanceNode.instanceClass(); HotSpotKlassOop hub = type.klassOop(); int instanceSize = type.instanceSize(); - Key key = new Key(newInstance).add("size", instanceSize).add("checkInit", !type.isInitialized()); + Key key = new Key(newInstance).add("size", instanceSize).add("checkInit", !type.isInitialized()).add("logType", LOG_ALLOCATION ? type.name() : null); Arguments arguments = arguments("hub", hub); SnippetTemplate template = cache.get(key); Debug.log("Lowering newInstance in %s: node=%s, template=%s, arguments=%s", graph, newInstanceNode, template, arguments);