# HG changeset patch # User Doug Simon # Date 1339675408 -7200 # Node ID e79b593e06328e717fd692aa9819302a2b6eb069 # Parent e1aa233220065082686e01b6289ef7de6e366bd1 made NewInstanceSnippets respect the UseTLAB HotSpot option removed redundant formatting of new instances created by calling the runtime (the runtime call does this already) diff -r e1aa23322006 -r e79b593e0632 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java Thu Jun 14 14:01:37 2012 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java Thu Jun 14 14:03:28 2012 +0200 @@ -41,6 +41,7 @@ public boolean useFastLocking; public boolean useFastNewObjectArray; public boolean useFastNewTypeArray; + public boolean useTLAB; // offsets, ... public int vmPageSize; diff -r e1aa23322006 -r e79b593e0632 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java Thu Jun 14 14:01:37 2012 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java Thu Jun 14 14:03:28 2012 +0200 @@ -75,7 +75,7 @@ installer.install(CheckCastSnippets.class); installer.install(NewInstanceSnippets.class); checkcastSnippets = new CheckCastSnippets.Templates(this); - newInstanceSnippets = new NewInstanceSnippets.Templates(this); + newInstanceSnippets = new NewInstanceSnippets.Templates(this, config.useTLAB); } diff -r e1aa23322006 -r e79b593e0632 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 Thu Jun 14 14:01:37 2012 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/NewInstanceSnippets.java Thu Jun 14 14:03:28 2012 +0200 @@ -61,28 +61,43 @@ * 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, @ConstantParameter("logType") String logType) { + public static Object newInstance( + @Parameter("hub") Object hub, + @ConstantParameter("size") int size, + @ConstantParameter("checkInit") boolean checkInit, + @ConstantParameter("useTLAB") boolean useTLAB, + @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, logType); + if (logType != null) { + Log.print(logType); + Log.println(" - uninitialized"); + } + return NewInstanceStubCall.call(hub); } } - Word thread = asWord(register(r15, wordKind())); - Word top = loadWord(thread, threadTlabTopOffset()); - Word end = loadWord(thread, threadTlabEndOffset()); - Word newTop = top.plus(size); - Object instance; - if (newTop.cmp(BE, end)) { - instance = cast(top, Object.class); - store(thread, 0, threadTlabTopOffset(), newTop); + if (useTLAB) { + Word thread = asWord(register(r15, wordKind())); + Word top = loadWord(thread, threadTlabTopOffset()); + Word end = loadWord(thread, threadTlabEndOffset()); + Word newTop = top.plus(size); + if (newTop.cmp(BE, end)) { + Object instance = cast(top, Object.class); + store(thread, 0, threadTlabTopOffset(), newTop); + return formatInstance(hub, size, instance, logType); + } else { + if (logType != null) { + Log.print(logType); + Log.println(" - stub allocate"); + } + return NewInstanceStubCall.call(hub); + } } else { - instance = NewInstanceStubCall.call(hub); + return NewInstanceStubCall.call(hub); } - - return formatInstance(hub, size, instance, logType); } private static Word asWord(Object object) { @@ -158,12 +173,14 @@ private final Cache cache; private final ResolvedJavaMethod newInstance; private final CodeCacheProvider runtime; + private final boolean useTLAB; - public Templates(CodeCacheProvider runtime) { + public Templates(CodeCacheProvider runtime, boolean useTLAB) { this.runtime = runtime; this.cache = new Cache(runtime); + this.useTLAB = useTLAB; try { - newInstance = runtime.getResolvedJavaMethod(NewInstanceSnippets.class.getDeclaredMethod("newInstance", Object.class, int.class, boolean.class, String.class)); + newInstance = runtime.getResolvedJavaMethod(NewInstanceSnippets.class.getDeclaredMethod("newInstance", Object.class, int.class, boolean.class, boolean.class, String.class)); } catch (NoSuchMethodException e) { throw new GraalInternalError(e); } @@ -178,10 +195,11 @@ 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()).add("logType", LOG_ALLOCATION ? type.name() : null); + Key key = new Key(newInstance).add("size", instanceSize).add("checkInit", !type.isInitialized()).add("useTLAB", useTLAB).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); + //System.out.printf("Lowering newInstance in %s: node=%s, template=%s, arguments=%s%n", graph, newInstanceNode, template, arguments); template.instantiate(runtime, newInstanceNode, newInstanceNode, arguments); new DeadCodeEliminationPhase().apply(graph); } diff -r e1aa23322006 -r e79b593e0632 src/share/vm/graal/graalCompilerToVM.cpp --- a/src/share/vm/graal/graalCompilerToVM.cpp Thu Jun 14 14:01:37 2012 +0200 +++ b/src/share/vm/graal/graalCompilerToVM.cpp Thu Jun 14 14:03:28 2012 +0200 @@ -785,6 +785,7 @@ set_boolean(env, config, "useFastLocking", UseFastLocking); set_boolean(env, config, "useFastNewObjectArray", UseFastNewObjectArray); set_boolean(env, config, "useFastNewTypeArray", UseFastNewTypeArray); + set_boolean(env, config, "useTLAB", UseTLAB); set_int(env, config, "codeEntryAlignment", CodeEntryAlignment); set_int(env, config, "vmPageSize", os::vm_page_size()); set_int(env, config, "stackShadowPages", StackShadowPages);