changeset 14778:5720104b54ba

Merge.
author Doug Simon <doug.simon@oracle.com>
date Wed, 26 Mar 2014 22:38:17 +0100
parents 10c6700908ef (current diff) 390d72c7cc04 (diff)
children 0a2c211e9cd1
files
diffstat 4 files changed, 27 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/NewObjectSnippets.java	Wed Mar 26 22:20:23 2014 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/NewObjectSnippets.java	Wed Mar 26 22:38:17 2014 +0100
@@ -138,7 +138,7 @@
         if (useTLAB() && probability(FAST_PATH_PROBABILITY, newTop.belowOrEqual(end))) {
             writeTlabTop(thread, newTop);
             emitPrefetchAllocate(newTop, false);
-            result = formatObject(hub, size, top, prototypeMarkWord, fillContents, constantSize, false);
+            result = formatObject(hub, size, top, prototypeMarkWord, fillContents, constantSize, false, true);
         } else {
             new_stub.inc();
             result = NewInstanceStubCall.call(hub);
@@ -196,7 +196,7 @@
             writeTlabTop(thread, newTop);
             emitPrefetchAllocate(newTop, true);
             newarray_loopInit.inc();
-            result = formatArray(hub, allocationSize, length, headerSize, top, prototypeMarkWord, fillContents, maybeUnroll);
+            result = formatArray(hub, allocationSize, length, headerSize, top, prototypeMarkWord, fillContents, maybeUnroll, true);
         } else {
             newarray_stub.inc();
             result = NewArrayStubCall.call(hub, length);
@@ -291,7 +291,7 @@
      * @param startOffset offset to begin zeroing. May not be word aligned.
      * @param manualUnroll maximally unroll zeroing
      */
-    private static void zeroMemory(int size, Word memory, boolean constantSize, int startOffset, boolean manualUnroll, boolean noAsserts) {
+    private static void zeroMemory(int size, Word memory, boolean constantSize, int startOffset, boolean manualUnroll, boolean noAsserts, boolean useSnippetCounters) {
         assert noAsserts || size % 8 == 0 : "unaligned object size";
         int offset = startOffset;
         if (offset % 8 != 0) {
@@ -304,7 +304,9 @@
             // This case handles arrays of constant length. Instead of having a snippet variant for
             // each length, generate a chain of stores of maximum length. Once it's inlined the
             // break statement will trim excess stores.
-            new_seqInit.inc();
+            if (useSnippetCounters) {
+                new_seqInit.inc();
+            }
             explodeLoop();
             for (int i = 0; i < MAX_UNROLLED_OBJECT_ZEROING_STORES; i++, offset += 8) {
                 if (offset == size) {
@@ -316,10 +318,14 @@
             // Use Word instead of int to avoid extension to long in generated code
             Word off = Word.signed(offset);
             if (constantSize && ((size - offset) / 8) <= MAX_UNROLLED_OBJECT_ZEROING_STORES) {
-                new_seqInit.inc();
+                if (useSnippetCounters) {
+                    new_seqInit.inc();
+                }
                 explodeLoop();
             } else {
-                new_loopInit.inc();
+                if (useSnippetCounters) {
+                    new_loopInit.inc();
+                }
             }
             for (; off.rawValue() < size; off = off.add(8)) {
                 memory.initializeLong(off, 0, INIT_LOCATION);
@@ -332,17 +338,17 @@
      * since they can't be compiled in stubs.
      */
     public static Object formatObjectForStub(Word hub, int size, Word memory, Word compileTimePrototypeMarkWord) {
-        return formatObject(hub, size, memory, compileTimePrototypeMarkWord, true, false, true);
+        return formatObject(hub, size, memory, compileTimePrototypeMarkWord, true, false, true, false);
     }
 
     /**
      * Formats some allocated memory with an object header and zeroes out the rest.
      */
-    private static Object formatObject(Word hub, int size, Word memory, Word compileTimePrototypeMarkWord, boolean fillContents, boolean constantSize, boolean noAsserts) {
+    private static Object formatObject(Word hub, int size, Word memory, Word compileTimePrototypeMarkWord, boolean fillContents, boolean constantSize, boolean noAsserts, boolean useSnippetCounters) {
         Word prototypeMarkWord = useBiasedLocking() ? hub.readWord(prototypeMarkWordOffset(), PROTOTYPE_MARK_WORD_LOCATION) : compileTimePrototypeMarkWord;
         initializeObjectHeader(memory, prototypeMarkWord, hub);
         if (fillContents) {
-            zeroMemory(size, memory, constantSize, instanceHeaderSize(), false, noAsserts);
+            zeroMemory(size, memory, constantSize, instanceHeaderSize(), false, noAsserts, useSnippetCounters);
         }
         return memory.toObject();
     }
@@ -350,7 +356,8 @@
     /**
      * Formats some allocated memory with an object header and zeroes out the rest.
      */
-    public static Object formatArray(Word hub, int allocationSize, int length, int headerSize, Word memory, Word prototypeMarkWord, boolean fillContents, boolean maybeUnroll) {
+    public static Object formatArray(Word hub, int allocationSize, int length, int headerSize, Word memory, Word prototypeMarkWord, boolean fillContents, boolean maybeUnroll,
+                    boolean useSnippetCounters) {
         memory.writeInt(arrayLengthOffset(), length, INIT_LOCATION);
         /*
          * store hub last as the concurrent garbage collectors assume length is valid if hub field
@@ -358,7 +365,7 @@
          */
         initializeObjectHeader(memory, prototypeMarkWord, hub);
         if (fillContents) {
-            zeroMemory(allocationSize, memory, false, headerSize, maybeUnroll, true);
+            zeroMemory(allocationSize, memory, false, headerSize, maybeUnroll, true, useSnippetCounters);
         }
         return memory.toObject();
     }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/NewArrayStub.java	Wed Mar 26 22:20:23 2014 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/NewArrayStub.java	Wed Mar 26 22:38:17 2014 +0100
@@ -83,7 +83,7 @@
     /**
      * Re-attempts allocation after an initial TLAB allocation failed or was skipped (e.g., due to
      * -XX:-UseTLAB).
-     * 
+     *
      * @param hub the hub of the object to be allocated
      * @param length the length of the array
      * @param intArrayHub the hub for {@code int[].class}
@@ -110,7 +110,7 @@
                 if (logging()) {
                     printf("newArray: allocated new array at %p\n", memory.rawValue());
                 }
-                return verifyObject(formatArray(hub, sizeInBytes, length, headerSize, memory, Word.unsigned(arrayPrototypeMarkWord()), true, false));
+                return verifyObject(formatArray(hub, sizeInBytes, length, headerSize, memory, Word.unsigned(arrayPrototypeMarkWord()), true, false, false));
             }
         }
         if (logging()) {
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/NewInstanceStub.java	Wed Mar 26 22:20:23 2014 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/NewInstanceStub.java	Wed Mar 26 22:38:17 2014 +0100
@@ -97,7 +97,7 @@
     /**
      * Re-attempts allocation after an initial TLAB allocation failed or was skipped (e.g., due to
      * -XX:-UseTLAB).
-     * 
+     *
      * @param hub the hub of the object to be allocated
      * @param intArrayHub the hub for {@code int[].class}
      */
@@ -127,11 +127,11 @@
 
     /**
      * Attempts to refill the current thread's TLAB and retries the allocation.
-     * 
+     *
      * @param intArrayHub the hub for {@code int[].class}
      * @param sizeInBytes the size of the allocation
      * @param log specifies if logging is enabled
-     * 
+     *
      * @return the newly allocated, uninitialized chunk of memory, or {@link Word#zero()} if the
      *         operation was unsuccessful
      */
@@ -188,7 +188,7 @@
                 // an int
                 int tlabFreeSpaceInInts = (int) tlabFreeSpaceInBytes >>> 2;
                 int length = ((alignmentReserveInBytes - headerSize) >>> 2) + tlabFreeSpaceInInts;
-                NewObjectSnippets.formatArray(intArrayHub, -1, length, headerSize, top, intArrayMarkWord, false, false);
+                NewObjectSnippets.formatArray(intArrayHub, -1, length, headerSize, top, intArrayMarkWord, false, false, false);
 
                 long allocated = thread.readLong(threadAllocatedBytesOffset(), TLAB_THREAD_ALLOCATED_BYTES_LOCATION);
                 allocated = allocated + top.subtract(readTlabStart(thread)).rawValue();
@@ -226,7 +226,7 @@
 
     /**
      * Attempts to allocate a chunk of memory from Eden space.
-     * 
+     *
      * @param sizeInBytes the size of the chunk to allocate
      * @param log specifies if logging is enabled
      * @return the allocated chunk or {@link Word#zero()} if allocation fails
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/SnippetCounter.java	Wed Mar 26 22:20:23 2014 +0100
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/SnippetCounter.java	Wed Mar 26 22:38:17 2014 +0100
@@ -39,6 +39,7 @@
  * snippet specific metrics.
  */
 public class SnippetCounter implements Comparable<SnippetCounter> {
+    private static final LocationIdentity SNIPPET_COUNTER_LOCATION = new NamedLocationIdentity("SnippetCounter");
 
     /**
      * A group of related counters.
@@ -134,9 +135,7 @@
      */
     public void inc() {
         if (group != null) {
-            // TODO: instead of ANY_LOCATION we should actually
-            // use the location for the field "value".
-            DirectObjectStoreNode.storeLong(this, countOffset(), 0, value + 1, LocationIdentity.ANY_LOCATION);
+            DirectObjectStoreNode.storeLong(this, countOffset(), 0, value + 1, SNIPPET_COUNTER_LOCATION);
         }
     }