changeset 9567:a8b4f26d8485

removed Stub.log(...) methods
author Doug Simon <doug.simon@oracle.com>
date Sun, 05 May 2013 17:42:45 +0200
parents 7207028ce060
children f64a3fec4e42
files graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/NewArrayStub.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/NewInstanceStub.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/Stub.java
diffstat 3 files changed, 51 insertions(+), 54 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/NewArrayStub.java	Sun May 05 17:31:01 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/NewArrayStub.java	Sun May 05 17:42:45 2013 +0200
@@ -39,7 +39,7 @@
 import com.oracle.graal.hotspot.replacements.*;
 import com.oracle.graal.nodes.spi.*;
 import com.oracle.graal.replacements.*;
-import com.oracle.graal.replacements.Snippet.ConstantParameter;
+import com.oracle.graal.replacements.Snippet.*;
 import com.oracle.graal.replacements.SnippetTemplate.Arguments;
 import com.oracle.graal.replacements.SnippetTemplate.SnippetInfo;
 import com.oracle.graal.word.*;
@@ -70,10 +70,14 @@
         args.add("hub", null);
         args.add("length", null);
         args.addConst("intArrayHub", intArrayHub);
-        args.addConst("log", Boolean.getBoolean("graal.logNewArrayStub"));
         return args;
     }
 
+    @Fold
+    private static boolean logging() {
+        return Boolean.getBoolean("graal.logNewArrayStub");
+    }
+
     /**
      * Re-attempts allocation after an initial TLAB allocation failed or was skipped (e.g., due to
      * -XX:-UseTLAB).
@@ -81,35 +85,42 @@
      * @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}
-     * @param log specifies if logging is enabled
      */
     @Snippet
-    private static Object newArray(Word hub, int length, @ConstantParameter Word intArrayHub, @ConstantParameter boolean log) {
+    private static Object newArray(Word hub, int length, @ConstantParameter Word intArrayHub) {
         int layoutHelper = hub.readInt(layoutHelperOffset(), FINAL_LOCATION);
         int log2ElementSize = (layoutHelper >> layoutHelperLog2ElementSizeShift()) & layoutHelperLog2ElementSizeMask();
         int headerSize = (layoutHelper >> layoutHelperHeaderSizeShift()) & layoutHelperHeaderSizeMask();
         int elementKind = (layoutHelper >> layoutHelperElementTypeShift()) & layoutHelperElementTypeMask();
         int sizeInBytes = computeArrayAllocationSize(length, wordSize(), headerSize, log2ElementSize);
-        log(log, "newArray: element kind %d\n", elementKind);
-        log(log, "newArray: array length %d\n", length);
-        log(log, "newArray: array size %d\n", sizeInBytes);
-        log(log, "newArray: hub=%p\n", hub);
+        if (logging()) {
+            printf("newArray: element kind %d\n", elementKind);
+            printf("newArray: array length %d\n", length);
+            printf("newArray: array size %d\n", sizeInBytes);
+            printf("newArray: hub=%p\n", hub.rawValue());
+        }
 
         // check that array length is small enough for fast path.
         if (length <= MAX_ARRAY_FAST_PATH_ALLOCATION_LENGTH) {
-            Word memory = refillAllocate(intArrayHub, sizeInBytes, log);
+            Word memory = refillAllocate(intArrayHub, sizeInBytes, logging());
             if (memory.notEqual(0)) {
-                log(log, "newArray: allocated new array at %p\n", memory);
+                if (logging()) {
+                    printf("newArray: allocated new array at %p\n", memory.rawValue());
+                }
                 formatArray(hub, sizeInBytes, length, headerSize, memory, Word.unsigned(arrayPrototypeMarkWord()), true);
                 return memory.toObject();
             }
         }
-        log(log, "newArray: calling new_array_c\n", 0L);
+        if (logging()) {
+            printf("newArray: calling new_array_c\n");
+        }
 
         newArrayC(NEW_ARRAY_C, thread(), hub, length);
 
         if (clearPendingException(thread())) {
-            log(log, "newArray: deoptimizing to caller\n", 0L);
+            if (logging()) {
+                printf("newArray: deoptimizing to caller\n");
+            }
             getAndClearObjectResult(thread());
             DeoptimizeCallerNode.deopt(InvalidateReprofile, RuntimeConstraint);
         }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/NewInstanceStub.java	Sun May 05 17:31:01 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/NewInstanceStub.java	Sun May 05 17:42:45 2013 +0200
@@ -71,10 +71,14 @@
         Arguments args = new Arguments(stub);
         args.add("hub", null);
         args.addConst("intArrayHub", intArrayHub);
-        args.addConst("log", Boolean.getBoolean("graal.logNewInstanceStub"));
         return args;
     }
 
+    @Fold
+    private static boolean logging() {
+        return Boolean.getBoolean("graal.logNewInstanceStub");
+    }
+
     /**
      * Re-attempts allocation after an initial TLAB allocation failed or was skipped (e.g., due to
      * -XX:-UseTLAB).
@@ -83,11 +87,11 @@
      * @param intArrayHub the hub for {@code int[].class}
      */
     @Snippet
-    private static Object newInstance(Word hub, @ConstantParameter Word intArrayHub, @ConstantParameter boolean log) {
+    private static Object newInstance(Word hub, @ConstantParameter Word intArrayHub) {
         int sizeInBytes = hub.readInt(klassInstanceSizeOffset(), FINAL_LOCATION);
         if (!forceSlowPath() && inlineContiguousAllocationSupported()) {
             if (hub.readInt(klassStateOffset(), CLASS_STATE_LOCATION) == klassStateFullyInitialized()) {
-                Word memory = refillAllocate(intArrayHub, sizeInBytes, log);
+                Word memory = refillAllocate(intArrayHub, sizeInBytes, logging());
                 if (memory.notEqual(0)) {
                     Word prototypeMarkWord = hub.readWord(prototypeMarkWordOffset(), PROTOTYPE_MARK_WORD_LOCATION);
                     initializeObjectHeader(memory, prototypeMarkWord, hub);
@@ -99,12 +103,16 @@
             }
         }
 
-        log(log, "newInstance: calling new_instance_c\n", 0L);
+        if (logging()) {
+            printf("newInstance: calling new_instance_c\n");
+        }
 
         newInstanceC(NEW_INSTANCE_C, thread(), hub);
 
         if (clearPendingException(thread())) {
-            log(log, "newInstance: deoptimizing to caller\n", 0L);
+            if (logging()) {
+                printf("newInstance: deoptimizing to caller\n");
+            }
             getAndClearObjectResult(thread());
             DeoptimizeCallerNode.deopt(InvalidateReprofile, RuntimeConstraint);
         }
@@ -134,10 +142,12 @@
         // calculate amount of free space
         Word tlabFreeSpaceInBytes = end.subtract(top);
 
-        log(log, "refillTLAB: thread=%p\n", thread);
-        log(log, "refillTLAB: top=%p\n", top);
-        log(log, "refillTLAB: end=%p\n", end);
-        log(log, "refillTLAB: tlabFreeSpaceInBytes=%d\n", tlabFreeSpaceInBytes);
+        if (log) {
+            printf("refillTLAB: thread=%p\n", thread.rawValue());
+            printf("refillTLAB: top=%p\n", top.rawValue());
+            printf("refillTLAB: end=%p\n", end.rawValue());
+            printf("refillTLAB: tlabFreeSpaceInBytes=%d\n", tlabFreeSpaceInBytes.rawValue());
+        }
 
         Word tlabFreeSpaceInWords = tlabFreeSpaceInBytes.unsignedShiftRight(log2WordSize());
 
@@ -148,10 +158,14 @@
             if (tlabStats()) {
                 // increment number of refills
                 thread.writeInt(tlabNumberOfRefillsOffset(), thread.readInt(tlabNumberOfRefillsOffset(), TLAB_NOF_REFILLS_LOCATION) + 1, TLAB_NOF_REFILLS_LOCATION);
-                log(log, "thread: %p -- number_of_refills %d\n", thread, thread.readInt(tlabNumberOfRefillsOffset(), TLAB_NOF_REFILLS_LOCATION));
+                if (log) {
+                    printf("thread: %p -- number_of_refills %d\n", thread.rawValue(), thread.readInt(tlabNumberOfRefillsOffset(), TLAB_NOF_REFILLS_LOCATION));
+                }
                 // accumulate wastage
                 Word wastage = thread.readWord(tlabFastRefillWasteOffset(), TLAB_FAST_REFILL_WASTE_LOCATION).add(tlabFreeSpaceInWords);
-                log(log, "thread: %p -- accumulated wastage %d\n", thread, wastage);
+                if (log) {
+                    printf("thread: %p -- accumulated wastage %d\n", thread.rawValue(), wastage.rawValue());
+                }
                 thread.writeWord(tlabFastRefillWasteOffset(), wastage, TLAB_FAST_REFILL_WASTE_LOCATION);
             }
 
@@ -187,7 +201,9 @@
             // Retain TLAB
             Word newRefillWasteLimit = refillWasteLimit.add(tlabRefillWasteIncrement());
             thread.writeWord(tlabRefillWasteLimitOffset(), newRefillWasteLimit, TLAB_REFILL_WASTE_LIMIT_LOCATION);
-            log(log, "refillTLAB: retaining TLAB - newRefillWasteLimit=%p\n", newRefillWasteLimit);
+            if (log) {
+                printf("refillTLAB: retaining TLAB - newRefillWasteLimit=%p\n", newRefillWasteLimit.rawValue());
+            }
 
             if (tlabStats()) {
                 thread.writeInt(tlabSlowAllocationsOffset(), thread.readInt(tlabSlowAllocationsOffset(), TLAB_SLOW_ALLOCATIONS_LOCATION) + 1, TLAB_SLOW_ALLOCATIONS_LOCATION);
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/Stub.java	Sun May 05 17:31:01 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/Stub.java	Sun May 05 17:42:45 2013 +0200
@@ -232,36 +232,6 @@
         return code;
     }
 
-    static void log(boolean enabled, String message) {
-        if (enabled) {
-            printf(message);
-        }
-    }
-
-    static void log(boolean enabled, String format, long value) {
-        if (enabled) {
-            printf(format, value);
-        }
-    }
-
-    static void log(boolean enabled, String format, WordBase value) {
-        if (enabled) {
-            printf(format, value.rawValue());
-        }
-    }
-
-    static void log(boolean enabled, String format, Word v1, long v2) {
-        if (enabled) {
-            printf(format, v1.rawValue(), v2);
-        }
-    }
-
-    static void log(boolean enabled, String format, Word v1, Word v2) {
-        if (enabled) {
-            printf(format, v1.rawValue(), v2.rawValue());
-        }
-    }
-
     static void handlePendingException(boolean isObjectResult) {
         if (clearPendingException(thread())) {
             if (isObjectResult) {