changeset 9618:bd4a7d657dcc

moved static methods out of Stub into StubUtil
author Doug Simon <doug.simon@oracle.com>
date Wed, 08 May 2013 21:05:39 +0200
parents c1ef2bf6848e
children 5e3c8dd80632
files graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/CreateNullPointerExceptionStub.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/CreateOutOfBoundsExceptionStub.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/ExceptionHandlerStub.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/IdentityHashCodeStub.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/LogObjectStub.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/LogPrimitiveStub.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/LogPrintfStub.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/MonitorEnterStub.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/MonitorExitStub.java 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/NewMultiArrayStub.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/OSRMigrationEndStub.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/RegisterFinalizerStub.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/Stub.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/StubUtil.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/ThreadIsInterruptedStub.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/UnwindExceptionToCallerStub.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/VMErrorStub.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/VerifyOopStub.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/WriteBarrierPostStub.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/WriteBarrierPreStub.java
diffstat 23 files changed, 312 insertions(+), 275 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java	Wed May 08 20:12:12 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java	Wed May 08 21:05:39 2013 +0200
@@ -56,6 +56,7 @@
 import static com.oracle.graal.hotspot.stubs.NewMultiArrayStub.*;
 import static com.oracle.graal.hotspot.stubs.OSRMigrationEndStub.*;
 import static com.oracle.graal.hotspot.stubs.RegisterFinalizerStub.*;
+import static com.oracle.graal.hotspot.stubs.StubUtil.*;
 import static com.oracle.graal.hotspot.stubs.ThreadIsInterruptedStub.*;
 import static com.oracle.graal.hotspot.stubs.UnwindExceptionToCallerStub.*;
 import static com.oracle.graal.hotspot.stubs.VMErrorStub.*;
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/CreateNullPointerExceptionStub.java	Wed May 08 20:12:12 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/CreateNullPointerExceptionStub.java	Wed May 08 21:05:39 2013 +0200
@@ -46,11 +46,11 @@
     @Snippet
     private static Object createNullPointerException() {
         createNullPointerExceptionC(CREATE_NULL_POINTER_EXCEPTION_C, thread());
-        handlePendingException(true);
-        return verifyObject(getAndClearObjectResult(thread()));
+        StubUtil.handlePendingException(true);
+        return StubUtil.verifyObject(getAndClearObjectResult(thread()));
     }
 
-    public static final Descriptor CREATE_NULL_POINTER_EXCEPTION_C = descriptorFor(CreateNullPointerExceptionStub.class, "createNullPointerExceptionC", false);
+    public static final Descriptor CREATE_NULL_POINTER_EXCEPTION_C = StubUtil.descriptorFor(CreateNullPointerExceptionStub.class, "createNullPointerExceptionC", false);
 
     @NodeIntrinsic(CRuntimeCall.class)
     public static native void createNullPointerExceptionC(@ConstantNodeParameter Descriptor createNullPointerExceptionC, Word thread);
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/CreateOutOfBoundsExceptionStub.java	Wed May 08 20:12:12 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/CreateOutOfBoundsExceptionStub.java	Wed May 08 21:05:39 2013 +0200
@@ -46,11 +46,11 @@
     @Snippet
     private static Object createOutOfBoundsException(int index) {
         createOutOfBoundsExceptionC(CREATE_OUT_OF_BOUNDS_C, thread(), index);
-        handlePendingException(true);
-        return verifyObject(getAndClearObjectResult(thread()));
+        StubUtil.handlePendingException(true);
+        return StubUtil.verifyObject(getAndClearObjectResult(thread()));
     }
 
-    public static final Descriptor CREATE_OUT_OF_BOUNDS_C = descriptorFor(CreateOutOfBoundsExceptionStub.class, "createOutOfBoundsExceptionC", false);
+    public static final Descriptor CREATE_OUT_OF_BOUNDS_C = StubUtil.descriptorFor(CreateOutOfBoundsExceptionStub.class, "createOutOfBoundsExceptionC", false);
 
     @NodeIntrinsic(CRuntimeCall.class)
     public static native void createOutOfBoundsExceptionC(@ConstantNodeParameter Descriptor createOutOfBoundsExceptionC, Word thread, int index);
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/ExceptionHandlerStub.java	Wed May 08 20:12:12 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/ExceptionHandlerStub.java	Wed May 08 21:05:39 2013 +0200
@@ -70,11 +70,11 @@
         writeExceptionOop(thread(), exception);
         writeExceptionPc(thread(), exceptionPc);
         if (logging()) {
-            printf("handling exception %p (", Word.fromObject(exception).rawValue());
-            decipher(Word.fromObject(exception).rawValue());
-            printf(") at %p (", Word.fromObject(exception).rawValue(), exceptionPc.rawValue());
-            decipher(exceptionPc.rawValue());
-            printf(")\n");
+            StubUtil.printf("handling exception %p (", Word.fromObject(exception).rawValue());
+            StubUtil.decipher(Word.fromObject(exception).rawValue());
+            StubUtil.printf(") at %p (", Word.fromObject(exception).rawValue(), exceptionPc.rawValue());
+            StubUtil.decipher(exceptionPc.rawValue());
+            StubUtil.printf(")\n");
         }
 
         // patch throwing pc into return address so that deoptimization finds the right debug info
@@ -83,9 +83,9 @@
         Word handlerPc = exceptionHandlerForPc(EXCEPTION_HANDLER_FOR_PC, thread());
 
         if (logging()) {
-            printf("handler for exception %p at %p is at %p (", Word.fromObject(exception).rawValue(), exceptionPc.rawValue(), handlerPc.rawValue());
-            decipher(handlerPc.rawValue());
-            printf(")\n");
+            StubUtil.printf("handler for exception %p at %p is at %p (", Word.fromObject(exception).rawValue(), exceptionPc.rawValue(), handlerPc.rawValue());
+            StubUtil.decipher(handlerPc.rawValue());
+            StubUtil.printf(")\n");
         }
 
         // patch the return address so that this stub returns to the exception handler
@@ -96,18 +96,18 @@
         if (enabled) {
             Object currentException = readExceptionOop(thread());
             if (currentException != null) {
-                fatal("exception object in thread must be null, not %p", Word.fromObject(currentException).rawValue());
+                StubUtil.fatal("exception object in thread must be null, not %p", Word.fromObject(currentException).rawValue());
             }
             Word currentExceptionPc = readExceptionPc(thread());
             if (currentExceptionPc.notEqual(Word.zero())) {
-                fatal("exception PC in thread must be zero, not %p", currentExceptionPc.rawValue());
+                StubUtil.fatal("exception PC in thread must be zero, not %p", currentExceptionPc.rawValue());
             }
         }
     }
 
     static void checkExceptionNotNull(boolean enabled, Object exception) {
         if (enabled && exception == null) {
-            fatal("exception must not be null");
+            StubUtil.fatal("exception must not be null");
         }
     }
 
@@ -124,7 +124,7 @@
         return enabled || graalRuntime().getConfig().cAssertions;
     }
 
-    public static final Descriptor EXCEPTION_HANDLER_FOR_PC = descriptorFor(ExceptionHandlerStub.class, "exceptionHandlerForPc", false);
+    public static final Descriptor EXCEPTION_HANDLER_FOR_PC = StubUtil.descriptorFor(ExceptionHandlerStub.class, "exceptionHandlerForPc", false);
 
     @NodeIntrinsic(value = CRuntimeCall.class, setStampFromReturnType = true)
     public static native Word exceptionHandlerForPc(@ConstantNodeParameter Descriptor exceptionHandlerForPc, Word thread);
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/IdentityHashCodeStub.java	Wed May 08 20:12:12 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/IdentityHashCodeStub.java	Wed May 08 21:05:39 2013 +0200
@@ -47,11 +47,11 @@
     @Snippet
     private static int identityHashCode(Object object) {
         int result = identityHashCodeC(IDENTITY_HASH_CODE_C, thread(), object);
-        handlePendingException(false);
+        StubUtil.handlePendingException(false);
         return result;
     }
 
-    public static final Descriptor IDENTITY_HASH_CODE_C = descriptorFor(IdentityHashCodeStub.class, "identityHashCodeC", false);
+    public static final Descriptor IDENTITY_HASH_CODE_C = StubUtil.descriptorFor(IdentityHashCodeStub.class, "identityHashCodeC", false);
 
     @NodeIntrinsic(CRuntimeCall.class)
     public static native int identityHashCodeC(@ConstantNodeParameter Descriptor identityHashCodeC, Word thread, Object object);
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/LogObjectStub.java	Wed May 08 20:12:12 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/LogObjectStub.java	Wed May 08 21:05:39 2013 +0200
@@ -49,7 +49,7 @@
         logObjectC(LOG_OBJECT_C, thread(), object, flags);
     }
 
-    public static final Descriptor LOG_OBJECT_C = descriptorFor(LogObjectStub.class, "logObjectC", false);
+    public static final Descriptor LOG_OBJECT_C = StubUtil.descriptorFor(LogObjectStub.class, "logObjectC", false);
 
     @NodeIntrinsic(CRuntimeCall.class)
     public static native void logObjectC(@ConstantNodeParameter Descriptor logObjectC, Word thread, Object object, int flags);
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/LogPrimitiveStub.java	Wed May 08 20:12:12 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/LogPrimitiveStub.java	Wed May 08 21:05:39 2013 +0200
@@ -49,7 +49,7 @@
         logPrimitivefC(LOG_PRIMITIVE_C, thread(), typeChar, value, newline);
     }
 
-    public static final Descriptor LOG_PRIMITIVE_C = descriptorFor(LogPrimitiveStub.class, "logPrimitivefC", false);
+    public static final Descriptor LOG_PRIMITIVE_C = StubUtil.descriptorFor(LogPrimitiveStub.class, "logPrimitivefC", false);
 
     @NodeIntrinsic(CRuntimeCall.class)
     public static native void logPrimitivefC(@ConstantNodeParameter Descriptor logPrimitivefC, Word thread, char typeChar, long value, boolean newline);
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/LogPrintfStub.java	Wed May 08 20:12:12 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/LogPrintfStub.java	Wed May 08 21:05:39 2013 +0200
@@ -49,7 +49,7 @@
         logPrintfC(LOG_PRINTF_C, thread(), format, v1, v2, v3);
     }
 
-    public static final Descriptor LOG_PRINTF_C = descriptorFor(LogPrintfStub.class, "logPrintfC", false);
+    public static final Descriptor LOG_PRINTF_C = StubUtil.descriptorFor(LogPrintfStub.class, "logPrintfC", false);
 
     @NodeIntrinsic(CRuntimeCall.class)
     public static native void logPrintfC(@ConstantNodeParameter Descriptor logPrintfC, Word thread, String format, long v1, long v2, long v3);
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/MonitorEnterStub.java	Wed May 08 20:12:12 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/MonitorEnterStub.java	Wed May 08 21:05:39 2013 +0200
@@ -47,10 +47,10 @@
     @Snippet
     private static void monitorenter(Object object, Word lock) {
         monitorenterC(MONITORENTER_C, thread(), object, lock);
-        handlePendingException(false);
+        StubUtil.handlePendingException(false);
     }
 
-    public static final Descriptor MONITORENTER_C = descriptorFor(MonitorEnterStub.class, "monitorenterC", false);
+    public static final Descriptor MONITORENTER_C = StubUtil.descriptorFor(MonitorEnterStub.class, "monitorenterC", false);
 
     @NodeIntrinsic(CRuntimeCall.class)
     public static native void monitorenterC(@ConstantNodeParameter Descriptor monitorenterC, Word thread, Object object, Word lock);
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/MonitorExitStub.java	Wed May 08 20:12:12 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/MonitorExitStub.java	Wed May 08 21:05:39 2013 +0200
@@ -49,7 +49,7 @@
         monitorexitC(MONITOREXIT_C, thread(), object, lock);
     }
 
-    public static final Descriptor MONITOREXIT_C = descriptorFor(MonitorExitStub.class, "monitorexitC", false);
+    public static final Descriptor MONITOREXIT_C = StubUtil.descriptorFor(MonitorExitStub.class, "monitorexitC", false);
 
     @NodeIntrinsic(CRuntimeCall.class)
     public static native void monitorexitC(@ConstantNodeParameter Descriptor monitorexitC, Word thread, Object object, Word lock);
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/NewArrayStub.java	Wed May 08 20:12:12 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/NewArrayStub.java	Wed May 08 21:05:39 2013 +0200
@@ -94,10 +94,10 @@
         int elementKind = (layoutHelper >> layoutHelperElementTypeShift()) & layoutHelperElementTypeMask();
         int sizeInBytes = computeArrayAllocationSize(length, wordSize(), headerSize, log2ElementSize);
         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());
+            StubUtil.printf("newArray: element kind %d\n", elementKind);
+            StubUtil.printf("newArray: array length %d\n", length);
+            StubUtil.printf("newArray: array size %d\n", sizeInBytes);
+            StubUtil.printf("newArray: hub=%p\n", hub.rawValue());
         }
 
         // check that array length is small enough for fast path.
@@ -105,29 +105,29 @@
             Word memory = refillAllocate(intArrayHub, sizeInBytes, logging());
             if (memory.notEqual(0)) {
                 if (logging()) {
-                    printf("newArray: allocated new array at %p\n", memory.rawValue());
+                    StubUtil.printf("newArray: allocated new array at %p\n", memory.rawValue());
                 }
                 formatArray(hub, sizeInBytes, length, headerSize, memory, Word.unsigned(arrayPrototypeMarkWord()), true);
-                return verifyObject(memory.toObject());
+                return StubUtil.verifyObject(memory.toObject());
             }
         }
         if (logging()) {
-            printf("newArray: calling new_array_c\n");
+            StubUtil.printf("newArray: calling new_array_c\n");
         }
 
         newArrayC(NEW_ARRAY_C, thread(), hub, length);
 
         if (clearPendingException(thread())) {
             if (logging()) {
-                printf("newArray: deoptimizing to caller\n");
+                StubUtil.printf("newArray: deoptimizing to caller\n");
             }
             getAndClearObjectResult(thread());
             DeoptimizeCallerNode.deopt(InvalidateReprofile, RuntimeConstraint);
         }
-        return verifyObject(getAndClearObjectResult(thread()));
+        return StubUtil.verifyObject(getAndClearObjectResult(thread()));
     }
 
-    public static final Descriptor NEW_ARRAY_C = descriptorFor(NewArrayStub.class, "newArrayC", false);
+    public static final Descriptor NEW_ARRAY_C = StubUtil.descriptorFor(NewArrayStub.class, "newArrayC", false);
 
     @NodeIntrinsic(CRuntimeCall.class)
     public static native void newArrayC(@ConstantNodeParameter Descriptor newArrayC, Word thread, Word hub, int length);
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/NewInstanceStub.java	Wed May 08 20:12:12 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/NewInstanceStub.java	Wed May 08 21:05:39 2013 +0200
@@ -98,25 +98,25 @@
                     for (int offset = 2 * wordSize(); offset < sizeInBytes; offset += wordSize()) {
                         memory.writeWord(offset, Word.zero(), ANY_LOCATION);
                     }
-                    return verifyObject(memory.toObject());
+                    return StubUtil.verifyObject(memory.toObject());
                 }
             }
         }
 
         if (logging()) {
-            printf("newInstance: calling new_instance_c\n");
+            StubUtil.printf("newInstance: calling new_instance_c\n");
         }
 
         newInstanceC(NEW_INSTANCE_C, thread(), hub);
 
         if (clearPendingException(thread())) {
             if (logging()) {
-                printf("newInstance: deoptimizing to caller\n");
+                StubUtil.printf("newInstance: deoptimizing to caller\n");
             }
             getAndClearObjectResult(thread());
             DeoptimizeCallerNode.deopt(InvalidateReprofile, RuntimeConstraint);
         }
-        return verifyObject(getAndClearObjectResult(thread()));
+        return StubUtil.verifyObject(getAndClearObjectResult(thread()));
     }
 
     /**
@@ -143,10 +143,10 @@
         Word tlabFreeSpaceInBytes = end.subtract(top);
 
         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());
+            StubUtil.printf("refillTLAB: thread=%p\n", thread.rawValue());
+            StubUtil.printf("refillTLAB: top=%p\n", top.rawValue());
+            StubUtil.printf("refillTLAB: end=%p\n", end.rawValue());
+            StubUtil.printf("refillTLAB: tlabFreeSpaceInBytes=%d\n", tlabFreeSpaceInBytes.rawValue());
         }
 
         Word tlabFreeSpaceInWords = tlabFreeSpaceInBytes.unsignedShiftRight(log2WordSize());
@@ -159,12 +159,12 @@
                 // increment number of refills
                 thread.writeInt(tlabNumberOfRefillsOffset(), thread.readInt(tlabNumberOfRefillsOffset(), TLAB_NOF_REFILLS_LOCATION) + 1, TLAB_NOF_REFILLS_LOCATION);
                 if (log) {
-                    printf("thread: %p -- number_of_refills %d\n", thread.rawValue(), thread.readInt(tlabNumberOfRefillsOffset(), TLAB_NOF_REFILLS_LOCATION));
+                    StubUtil.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);
                 if (log) {
-                    printf("thread: %p -- accumulated wastage %d\n", thread.rawValue(), wastage.rawValue());
+                    StubUtil.printf("thread: %p -- accumulated wastage %d\n", thread.rawValue(), wastage.rawValue());
                 }
                 thread.writeWord(tlabFastRefillWasteOffset(), wastage, TLAB_FAST_REFILL_WASTE_LOCATION);
             }
@@ -202,7 +202,7 @@
             Word newRefillWasteLimit = refillWasteLimit.add(tlabRefillWasteIncrement());
             thread.writeWord(tlabRefillWasteLimitOffset(), newRefillWasteLimit, TLAB_REFILL_WASTE_LIMIT_LOCATION);
             if (log) {
-                printf("refillTLAB: retaining TLAB - newRefillWasteLimit=%p\n", newRefillWasteLimit.rawValue());
+                StubUtil.printf("refillTLAB: retaining TLAB - newRefillWasteLimit=%p\n", newRefillWasteLimit.rawValue());
             }
 
             if (tlabStats()) {
@@ -247,7 +247,7 @@
         return Boolean.getBoolean("graal.newInstanceStub.forceSlowPath");
     }
 
-    public static final Descriptor NEW_INSTANCE_C = descriptorFor(NewInstanceStub.class, "newInstanceC", false);
+    public static final Descriptor NEW_INSTANCE_C = StubUtil.descriptorFor(NewInstanceStub.class, "newInstanceC", false);
 
     @NodeIntrinsic(CRuntimeCall.class)
     public static native void newInstanceC(@ConstantNodeParameter Descriptor newInstanceC, Word thread, Word hub);
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/NewMultiArrayStub.java	Wed May 08 20:12:12 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/NewMultiArrayStub.java	Wed May 08 21:05:39 2013 +0200
@@ -47,11 +47,11 @@
     @Snippet
     private static Object newMultiArray(Word hub, int rank, Word dims) {
         newMultiArrayC(NEW_MULTI_ARRAY_C, thread(), hub, rank, dims);
-        handlePendingException(true);
+        StubUtil.handlePendingException(true);
         return getAndClearObjectResult(thread());
     }
 
-    public static final Descriptor NEW_MULTI_ARRAY_C = descriptorFor(NewMultiArrayStub.class, "newMultiArrayC", false);
+    public static final Descriptor NEW_MULTI_ARRAY_C = StubUtil.descriptorFor(NewMultiArrayStub.class, "newMultiArrayC", false);
 
     @NodeIntrinsic(CRuntimeCall.class)
     public static native void newMultiArrayC(@ConstantNodeParameter Descriptor newArrayC, Word thread, Word hub, int rank, Word dims);
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/OSRMigrationEndStub.java	Wed May 08 20:12:12 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/OSRMigrationEndStub.java	Wed May 08 21:05:39 2013 +0200
@@ -48,7 +48,7 @@
         osrMigrationEndC(OSR_MIGRATION_END_C, buffer);
     }
 
-    public static final Descriptor OSR_MIGRATION_END_C = descriptorFor(OSRMigrationEndStub.class, "osrMigrationEndC", false);
+    public static final Descriptor OSR_MIGRATION_END_C = StubUtil.descriptorFor(OSRMigrationEndStub.class, "osrMigrationEndC", false);
 
     @NodeIntrinsic(CRuntimeCall.class)
     public static native void osrMigrationEndC(@ConstantNodeParameter Descriptor osrMigrationEndC, Word buffer);
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/RegisterFinalizerStub.java	Wed May 08 20:12:12 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/RegisterFinalizerStub.java	Wed May 08 21:05:39 2013 +0200
@@ -48,10 +48,10 @@
     @Snippet
     private static void registerFinalizer(Object object) {
         registerFinalizerC(REGISTER_FINALIZER_C, thread(), object);
-        handlePendingException(false);
+        StubUtil.handlePendingException(false);
     }
 
-    public static final Descriptor REGISTER_FINALIZER_C = descriptorFor(RegisterFinalizerStub.class, "registerFinalizerC", false);
+    public static final Descriptor REGISTER_FINALIZER_C = StubUtil.descriptorFor(RegisterFinalizerStub.class, "registerFinalizerC", false);
 
     @NodeIntrinsic(CRuntimeCall.class)
     public static native void registerFinalizerC(@ConstantNodeParameter Descriptor registerFinalizerC, Word thread, Object object);
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/Stub.java	Wed May 08 20:12:12 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/Stub.java	Wed May 08 21:05:39 2013 +0200
@@ -22,14 +22,8 @@
  */
 package com.oracle.graal.hotspot.stubs;
 
-import static com.oracle.graal.api.code.DeoptimizationAction.*;
-import static com.oracle.graal.api.meta.DeoptimizationReason.*;
 import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*;
-import static com.oracle.graal.hotspot.nodes.CStringNode.*;
-import static com.oracle.graal.hotspot.replacements.HotSpotReplacementsUtil.*;
-import static com.oracle.graal.word.Word.*;
 
-import java.lang.reflect.*;
 import java.util.*;
 import java.util.concurrent.*;
 
@@ -37,14 +31,11 @@
 import com.oracle.graal.api.code.CompilationResult.Call;
 import com.oracle.graal.api.code.CompilationResult.DataPatch;
 import com.oracle.graal.api.code.CompilationResult.Infopoint;
-import com.oracle.graal.api.code.RuntimeCallTarget.Descriptor;
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.compiler.*;
 import com.oracle.graal.compiler.target.*;
 import com.oracle.graal.debug.*;
 import com.oracle.graal.debug.internal.*;
-import com.oracle.graal.graph.Node.ConstantNodeParameter;
-import com.oracle.graal.graph.Node.NodeIntrinsic;
 import com.oracle.graal.hotspot.*;
 import com.oracle.graal.hotspot.meta.*;
 import com.oracle.graal.hotspot.nodes.*;
@@ -53,9 +44,6 @@
 import com.oracle.graal.nodes.spi.*;
 import com.oracle.graal.phases.*;
 import com.oracle.graal.phases.PhasePlan.PhasePosition;
-import com.oracle.graal.replacements.*;
-import com.oracle.graal.replacements.Snippet.Fold;
-import com.oracle.graal.word.*;
 
 //JaCoCo Exclude
 
@@ -142,28 +130,6 @@
         return true;
     }
 
-    /**
-     * Looks for a {@link CRuntimeCall} node intrinsic named {@code name} in {@code stubClass} and
-     * returns a {@link Descriptor} based on its signature and the value of {@code hasSideEffect}.
-     */
-    protected static <T extends Stub> Descriptor descriptorFor(Class<T> stubClass, String name, boolean hasSideEffect) {
-        Method found = null;
-        for (Method method : stubClass.getDeclaredMethods()) {
-            if (Modifier.isStatic(method.getModifiers()) && method.getAnnotation(NodeIntrinsic.class) != null && method.getName().equals(name)) {
-                if (method.getAnnotation(NodeIntrinsic.class).value() == CRuntimeCall.class) {
-                    assert found == null : "found more than one C runtime call named " + name + " in " + stubClass;
-                    assert method.getParameterTypes().length != 0 && method.getParameterTypes()[0] == Descriptor.class : "first parameter of C runtime call '" + name + "' in " + stubClass +
-                                    " must be of type " + Descriptor.class.getSimpleName();
-                    found = method;
-                }
-            }
-        }
-        assert found != null : "could not find C runtime call named " + name + " in " + stubClass;
-        List<Class<?>> paramList = Arrays.asList(found.getParameterTypes());
-        Class[] cCallTypes = paramList.subList(1, paramList.size()).toArray(new Class[paramList.size() - 1]);
-        return new Descriptor(name, hasSideEffect, found.getReturnType(), cCallTypes);
-    }
-
     protected abstract StructuredGraph getGraph();
 
     @Override
@@ -221,177 +187,4 @@
         }
         return code;
     }
-
-    static void handlePendingException(boolean isObjectResult) {
-        if (clearPendingException(thread())) {
-            if (isObjectResult) {
-                getAndClearObjectResult(thread());
-            }
-            DeoptimizeCallerNode.deopt(InvalidateReprofile, RuntimeConstraint);
-        }
-    }
-
-    public static final Descriptor VM_MESSAGE_C = descriptorFor(Stub.class, "vmMessageC", false);
-
-    @NodeIntrinsic(CRuntimeCall.class)
-    private static native void vmMessageC(@ConstantNodeParameter Descriptor stubPrintfC, boolean vmError, Word format, long v1, long v2, long v3);
-
-    /**
-     * Prints a message to the log stream.
-     * <p>
-     * <b>Stubs must use this instead of {@link Log#printf(String, long)} to avoid an object
-     * constant in a RuntimeStub.</b>
-     * 
-     * @param message a message string
-     */
-    public static void printf(String message) {
-        vmMessageC(VM_MESSAGE_C, false, cstring(message), 0L, 0L, 0L);
-    }
-
-    /**
-     * Prints a message to the log stream.
-     * <p>
-     * <b>Stubs must use this instead of {@link Log#printf(String, long)} to avoid an object
-     * constant in a RuntimeStub.</b>
-     * 
-     * @param format a C style printf format value
-     * @param value the value associated with the first conversion specifier in {@code format}
-     */
-    public static void printf(String format, long value) {
-        vmMessageC(VM_MESSAGE_C, false, cstring(format), value, 0L, 0L);
-    }
-
-    /**
-     * Prints a message to the log stream.
-     * <p>
-     * <b>Stubs must use this instead of {@link Log#printf(String, long, long)} to avoid an object
-     * constant in a RuntimeStub.</b>
-     * 
-     * @param format a C style printf format value
-     * @param v1 the value associated with the first conversion specifier in {@code format}
-     * @param v2 the value associated with the second conversion specifier in {@code format}
-     */
-    public static void printf(String format, long v1, long v2) {
-        vmMessageC(VM_MESSAGE_C, false, cstring(format), v1, v2, 0L);
-    }
-
-    /**
-     * Prints a message to the log stream.
-     * <p>
-     * <b>Stubs must use this instead of {@link Log#printf(String, long, long, long)} to avoid an
-     * object constant in a RuntimeStub.</b>
-     * 
-     * @param format a C style printf format value
-     * @param v1 the value associated with the first conversion specifier in {@code format}
-     * @param v2 the value associated with the second conversion specifier in {@code format}
-     * @param v3 the value associated with the third conversion specifier in {@code format}
-     */
-    public static void printf(String format, long v1, long v2, long v3) {
-        vmMessageC(VM_MESSAGE_C, false, cstring(format), v1, v2, v3);
-    }
-
-    /**
-     * Analyzes a given value and prints information about it to the log stream.
-     */
-    public static void decipher(long value) {
-        vmMessageC(VM_MESSAGE_C, false, Word.zero(), value, 0L, 0L);
-    }
-
-    /**
-     * Exits the VM with a given error message.
-     * <p>
-     * <b>Stubs must use this instead of {@link VMErrorNode#vmError(String, long)} to avoid an
-     * object constant in a RuntimeStub.</b>
-     * 
-     * @param message an error message
-     */
-    public static void fatal(String message) {
-        vmMessageC(VM_MESSAGE_C, true, cstring(message), 0L, 0L, 0L);
-    }
-
-    /**
-     * Exits the VM with a given error message.
-     * <p>
-     * <b>Stubs must use this instead of {@link Log#printf(String, long, long, long)} to avoid an
-     * object constant in a RuntimeStub.</b>
-     * 
-     * @param format a C style printf format value
-     * @param value the value associated with the first conversion specifier in {@code format}
-     */
-    public static void fatal(String format, long value) {
-        vmMessageC(VM_MESSAGE_C, true, cstring(format), value, 0L, 0L);
-    }
-
-    /**
-     * Exits the VM with a given error message.
-     * <p>
-     * <b>Stubs must use this instead of {@link Log#printf(String, long, long, long)} to avoid an
-     * object constant in a RuntimeStub.</b>
-     * 
-     * @param format a C style printf format value
-     * @param v1 the value associated with the first conversion specifier in {@code format}
-     * @param v2 the value associated with the second conversion specifier in {@code format}
-     */
-    public static void fatal(String format, long v1, long v2) {
-        vmMessageC(VM_MESSAGE_C, true, cstring(format), v1, v2, 0L);
-    }
-
-    /**
-     * Exits the VM with a given error message.
-     * <p>
-     * <b>Stubs must use this instead of {@link Log#printf(String, long, long, long)} to avoid an
-     * object constant in a RuntimeStub.</b>
-     * 
-     * @param format a C style printf format value
-     * @param v1 the value associated with the first conversion specifier in {@code format}
-     * @param v2 the value associated with the second conversion specifier in {@code format}
-     * @param v3 the value associated with the third conversion specifier in {@code format}
-     */
-    public static void fatal(String format, long v1, long v2, long v3) {
-        vmMessageC(VM_MESSAGE_C, true, cstring(format), v1, v2, v3);
-    }
-
-    /**
-     * Verifies that a given object value is well formed if {@code -XX:+VerifyOops} is enabled.
-     */
-    public static Object verifyObject(Object object) {
-        if (verifyOops()) {
-            Word verifyOopCounter = Word.unsigned(verifyOopCounterAddress());
-            verifyOopCounter.writeInt(0, verifyOopCounter.readInt(0) + 1);
-
-            Pointer oop = Word.fromObject(object);
-            if (object != null) {
-                // make sure object is 'reasonable'
-                if (!oop.and(unsigned(verifyOopMask())).equal(unsigned(verifyOopBits()))) {
-                    fatal("oop not in heap: %p", oop.rawValue());
-                }
-
-                Word klass = oop.readWord(hubOffset());
-                if (klass.equal(Word.zero())) {
-                    fatal("klass for oop %p is null", oop.rawValue());
-                }
-            }
-        }
-        return object;
-    }
-
-    @Fold
-    private static long verifyOopCounterAddress() {
-        return config().verifyOopCounterAddress;
-    }
-
-    @Fold
-    private static long verifyOopMask() {
-        return config().verifyOopMask;
-    }
-
-    @Fold
-    private static long verifyOopBits() {
-        return config().verifyOopBits;
-    }
-
-    @Fold
-    private static int hubOffset() {
-        return config().hubOffset;
-    }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/StubUtil.java	Wed May 08 21:05:39 2013 +0200
@@ -0,0 +1,243 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.graal.hotspot.stubs;
+
+import static com.oracle.graal.api.code.DeoptimizationAction.*;
+import static com.oracle.graal.api.meta.DeoptimizationReason.*;
+import static com.oracle.graal.hotspot.nodes.CStringNode.*;
+import static com.oracle.graal.hotspot.replacements.HotSpotReplacementsUtil.*;
+import static com.oracle.graal.word.Word.*;
+
+import java.lang.reflect.*;
+import java.util.*;
+
+import com.oracle.graal.api.code.RuntimeCallTarget.Descriptor;
+import com.oracle.graal.graph.Node.ConstantNodeParameter;
+import com.oracle.graal.graph.Node.NodeIntrinsic;
+import com.oracle.graal.hotspot.nodes.*;
+import com.oracle.graal.replacements.*;
+import com.oracle.graal.replacements.Snippet.Fold;
+import com.oracle.graal.word.*;
+
+//JaCoCo Exclude
+
+/**
+ * A collection of methods used in {@link Stub}s.
+ */
+public class StubUtil {
+
+    public static final Descriptor VM_MESSAGE_C = descriptorFor(StubUtil.class, "vmMessageC", false);
+
+    /**
+     * Looks for a {@link CRuntimeCall} node intrinsic named {@code name} in {@code stubClass} and
+     * returns a {@link Descriptor} based on its signature and the value of {@code hasSideEffect}.
+     */
+    public static Descriptor descriptorFor(Class<?> stubClass, String name, boolean hasSideEffect) {
+        Method found = null;
+        for (Method method : stubClass.getDeclaredMethods()) {
+            if (Modifier.isStatic(method.getModifiers()) && method.getAnnotation(NodeIntrinsic.class) != null && method.getName().equals(name)) {
+                if (method.getAnnotation(NodeIntrinsic.class).value() == CRuntimeCall.class) {
+                    assert found == null : "found more than one C runtime call named " + name + " in " + stubClass;
+                    assert method.getParameterTypes().length != 0 && method.getParameterTypes()[0] == Descriptor.class : "first parameter of C runtime call '" + name + "' in " + stubClass +
+                                    " must be of type " + Descriptor.class.getSimpleName();
+                    found = method;
+                }
+            }
+        }
+        assert found != null : "could not find C runtime call named " + name + " in " + stubClass;
+        List<Class<?>> paramList = Arrays.asList(found.getParameterTypes());
+        Class[] cCallTypes = paramList.subList(1, paramList.size()).toArray(new Class[paramList.size() - 1]);
+        return new Descriptor(name, hasSideEffect, found.getReturnType(), cCallTypes);
+    }
+
+    public static void handlePendingException(boolean isObjectResult) {
+        if (clearPendingException(thread())) {
+            if (isObjectResult) {
+                getAndClearObjectResult(thread());
+            }
+            DeoptimizeCallerNode.deopt(InvalidateReprofile, RuntimeConstraint);
+        }
+    }
+
+    @NodeIntrinsic(CRuntimeCall.class)
+    private static native void vmMessageC(@ConstantNodeParameter Descriptor stubPrintfC, boolean vmError, Word format, long v1, long v2, long v3);
+
+    /**
+     * Prints a message to the log stream.
+     * <p>
+     * <b>Stubs must use this instead of {@link Log#printf(String, long)} to avoid an object
+     * constant in a RuntimeStub.</b>
+     * 
+     * @param message a message string
+     */
+    public static void printf(String message) {
+        vmMessageC(VM_MESSAGE_C, false, cstring(message), 0L, 0L, 0L);
+    }
+
+    /**
+     * Prints a message to the log stream.
+     * <p>
+     * <b>Stubs must use this instead of {@link Log#printf(String, long)} to avoid an object
+     * constant in a RuntimeStub.</b>
+     * 
+     * @param format a C style printf format value
+     * @param value the value associated with the first conversion specifier in {@code format}
+     */
+    public static void printf(String format, long value) {
+        vmMessageC(VM_MESSAGE_C, false, cstring(format), value, 0L, 0L);
+    }
+
+    /**
+     * Prints a message to the log stream.
+     * <p>
+     * <b>Stubs must use this instead of {@link Log#printf(String, long, long)} to avoid an object
+     * constant in a RuntimeStub.</b>
+     * 
+     * @param format a C style printf format value
+     * @param v1 the value associated with the first conversion specifier in {@code format}
+     * @param v2 the value associated with the second conversion specifier in {@code format}
+     */
+    public static void printf(String format, long v1, long v2) {
+        vmMessageC(VM_MESSAGE_C, false, cstring(format), v1, v2, 0L);
+    }
+
+    /**
+     * Prints a message to the log stream.
+     * <p>
+     * <b>Stubs must use this instead of {@link Log#printf(String, long, long, long)} to avoid an
+     * object constant in a RuntimeStub.</b>
+     * 
+     * @param format a C style printf format value
+     * @param v1 the value associated with the first conversion specifier in {@code format}
+     * @param v2 the value associated with the second conversion specifier in {@code format}
+     * @param v3 the value associated with the third conversion specifier in {@code format}
+     */
+    public static void printf(String format, long v1, long v2, long v3) {
+        vmMessageC(VM_MESSAGE_C, false, cstring(format), v1, v2, v3);
+    }
+
+    /**
+     * Analyzes a given value and prints information about it to the log stream.
+     */
+    public static void decipher(long value) {
+        vmMessageC(VM_MESSAGE_C, false, Word.zero(), value, 0L, 0L);
+    }
+
+    /**
+     * Exits the VM with a given error message.
+     * <p>
+     * <b>Stubs must use this instead of {@link VMErrorNode#vmError(String, long)} to avoid an
+     * object constant in a RuntimeStub.</b>
+     * 
+     * @param message an error message
+     */
+    public static void fatal(String message) {
+        vmMessageC(VM_MESSAGE_C, true, cstring(message), 0L, 0L, 0L);
+    }
+
+    /**
+     * Exits the VM with a given error message.
+     * <p>
+     * <b>Stubs must use this instead of {@link Log#printf(String, long, long, long)} to avoid an
+     * object constant in a RuntimeStub.</b>
+     * 
+     * @param format a C style printf format value
+     * @param value the value associated with the first conversion specifier in {@code format}
+     */
+    public static void fatal(String format, long value) {
+        vmMessageC(VM_MESSAGE_C, true, cstring(format), value, 0L, 0L);
+    }
+
+    /**
+     * Exits the VM with a given error message.
+     * <p>
+     * <b>Stubs must use this instead of {@link Log#printf(String, long, long, long)} to avoid an
+     * object constant in a RuntimeStub.</b>
+     * 
+     * @param format a C style printf format value
+     * @param v1 the value associated with the first conversion specifier in {@code format}
+     * @param v2 the value associated with the second conversion specifier in {@code format}
+     */
+    public static void fatal(String format, long v1, long v2) {
+        vmMessageC(VM_MESSAGE_C, true, cstring(format), v1, v2, 0L);
+    }
+
+    /**
+     * Exits the VM with a given error message.
+     * <p>
+     * <b>Stubs must use this instead of {@link Log#printf(String, long, long, long)} to avoid an
+     * object constant in a RuntimeStub.</b>
+     * 
+     * @param format a C style printf format value
+     * @param v1 the value associated with the first conversion specifier in {@code format}
+     * @param v2 the value associated with the second conversion specifier in {@code format}
+     * @param v3 the value associated with the third conversion specifier in {@code format}
+     */
+    public static void fatal(String format, long v1, long v2, long v3) {
+        vmMessageC(VM_MESSAGE_C, true, cstring(format), v1, v2, v3);
+    }
+
+    /**
+     * Verifies that a given object value is well formed if {@code -XX:+VerifyOops} is enabled.
+     */
+    public static Object verifyObject(Object object) {
+        if (verifyOops()) {
+            Word verifyOopCounter = Word.unsigned(verifyOopCounterAddress());
+            verifyOopCounter.writeInt(0, verifyOopCounter.readInt(0) + 1);
+
+            Pointer oop = Word.fromObject(object);
+            if (object != null) {
+                // make sure object is 'reasonable'
+                if (!oop.and(unsigned(verifyOopMask())).equal(unsigned(verifyOopBits()))) {
+                    fatal("oop not in heap: %p", oop.rawValue());
+                }
+
+                Word klass = oop.readWord(hubOffset());
+                if (klass.equal(Word.zero())) {
+                    fatal("klass for oop %p is null", oop.rawValue());
+                }
+            }
+        }
+        return object;
+    }
+
+    @Fold
+    private static long verifyOopCounterAddress() {
+        return config().verifyOopCounterAddress;
+    }
+
+    @Fold
+    private static long verifyOopMask() {
+        return config().verifyOopMask;
+    }
+
+    @Fold
+    private static long verifyOopBits() {
+        return config().verifyOopBits;
+    }
+
+    @Fold
+    private static int hubOffset() {
+        return config().hubOffset;
+    }
+}
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/ThreadIsInterruptedStub.java	Wed May 08 20:12:12 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/ThreadIsInterruptedStub.java	Wed May 08 21:05:39 2013 +0200
@@ -47,11 +47,11 @@
     @Snippet
     private static boolean threadIsInterrupted(Thread receiverThread, boolean clearIsInterrupted) {
         boolean result = threadIsInterruptedC(THREAD_IS_INTERRUPTED_C, thread(), receiverThread, clearIsInterrupted);
-        handlePendingException(false);
+        StubUtil.handlePendingException(false);
         return result;
     }
 
-    public static final Descriptor THREAD_IS_INTERRUPTED_C = descriptorFor(ThreadIsInterruptedStub.class, "threadIsInterruptedC", false);
+    public static final Descriptor THREAD_IS_INTERRUPTED_C = StubUtil.descriptorFor(ThreadIsInterruptedStub.class, "threadIsInterruptedC", false);
 
     @NodeIntrinsic(CRuntimeCall.class)
     public static native boolean threadIsInterruptedC(@ConstantNodeParameter Descriptor threadIsInterruptedC, Word thread, Thread receiverThread, boolean clearIsInterrupted);
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/UnwindExceptionToCallerStub.java	Wed May 08 20:12:12 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/UnwindExceptionToCallerStub.java	Wed May 08 21:05:39 2013 +0200
@@ -63,11 +63,11 @@
     private static void unwindExceptionToCaller(Object exception, Word returnAddress) {
         Pointer exceptionOop = Word.fromObject(exception);
         if (logging()) {
-            printf("unwinding exception %p (", exceptionOop.rawValue());
-            decipher(exceptionOop.rawValue());
-            printf(") at %p (", exceptionOop.rawValue(), returnAddress.rawValue());
-            decipher(returnAddress.rawValue());
-            printf(")\n");
+            StubUtil.printf("unwinding exception %p (", exceptionOop.rawValue());
+            StubUtil.decipher(exceptionOop.rawValue());
+            StubUtil.printf(") at %p (", exceptionOop.rawValue(), returnAddress.rawValue());
+            StubUtil.decipher(returnAddress.rawValue());
+            StubUtil.printf(")\n");
         }
         checkNoExceptionInThread(assertionsEnabled());
         checkExceptionNotNull(assertionsEnabled(), exception);
@@ -75,9 +75,9 @@
         Word handlerInCallerPc = exceptionHandlerForReturnAddress(EXCEPTION_HANDLER_FOR_RETURN_ADDRESS, thread(), returnAddress);
 
         if (logging()) {
-            printf("handler for exception %p at return address %p is at %p (", exceptionOop.rawValue(), returnAddress.rawValue(), handlerInCallerPc.rawValue());
-            decipher(handlerInCallerPc.rawValue());
-            printf(")\n");
+            StubUtil.printf("handler for exception %p at return address %p is at %p (", exceptionOop.rawValue(), returnAddress.rawValue(), handlerInCallerPc.rawValue());
+            StubUtil.decipher(handlerInCallerPc.rawValue());
+            StubUtil.printf(")\n");
         }
 
         jumpToExceptionHandlerInCaller(handlerInCallerPc, exception, returnAddress);
@@ -96,7 +96,7 @@
         return enabled || graalRuntime().getConfig().cAssertions;
     }
 
-    public static final Descriptor EXCEPTION_HANDLER_FOR_RETURN_ADDRESS = descriptorFor(UnwindExceptionToCallerStub.class, "exceptionHandlerForReturnAddress", false);
+    public static final Descriptor EXCEPTION_HANDLER_FOR_RETURN_ADDRESS = StubUtil.descriptorFor(UnwindExceptionToCallerStub.class, "exceptionHandlerForReturnAddress", false);
 
     @NodeIntrinsic(value = CRuntimeCall.class, setStampFromReturnType = true)
     public static native Word exceptionHandlerForReturnAddress(@ConstantNodeParameter Descriptor exceptionHandlerForReturnAddress, Word thread, Word returnAddress);
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/VMErrorStub.java	Wed May 08 20:12:12 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/VMErrorStub.java	Wed May 08 21:05:39 2013 +0200
@@ -49,7 +49,7 @@
         vmErrorC(VM_ERROR_C, thread(), where, format, value);
     }
 
-    public static final Descriptor VM_ERROR_C = descriptorFor(VMErrorStub.class, "vmErrorC", false);
+    public static final Descriptor VM_ERROR_C = StubUtil.descriptorFor(VMErrorStub.class, "vmErrorC", false);
 
     @NodeIntrinsic(CRuntimeCall.class)
     public static native void vmErrorC(@ConstantNodeParameter Descriptor vmErrorC, Word thread, String where, String format, long value);
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/VerifyOopStub.java	Wed May 08 20:12:12 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/VerifyOopStub.java	Wed May 08 21:05:39 2013 +0200
@@ -40,6 +40,6 @@
 
     @Snippet
     private static Object verifyOop(Object object) {
-        return verifyObject(object);
+        return StubUtil.verifyObject(object);
     }
 }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/WriteBarrierPostStub.java	Wed May 08 20:12:12 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/WriteBarrierPostStub.java	Wed May 08 21:05:39 2013 +0200
@@ -49,7 +49,7 @@
         writeBarrierPostC(WRITE_BARRIER_POST_C, thread(), object, card);
     }
 
-    public static final Descriptor WRITE_BARRIER_POST_C = descriptorFor(WriteBarrierPostStub.class, "writeBarrierPostC", false);
+    public static final Descriptor WRITE_BARRIER_POST_C = StubUtil.descriptorFor(WriteBarrierPostStub.class, "writeBarrierPostC", false);
 
     @NodeIntrinsic(CRuntimeCall.class)
     public static native void writeBarrierPostC(@ConstantNodeParameter Descriptor vmErrorC, Word thread, Object object, Word card);
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/WriteBarrierPreStub.java	Wed May 08 20:12:12 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/WriteBarrierPreStub.java	Wed May 08 21:05:39 2013 +0200
@@ -49,7 +49,7 @@
         writeBarrierPreC(WRITE_BARRIER_PRE_C, thread(), object);
     }
 
-    public static final Descriptor WRITE_BARRIER_PRE_C = descriptorFor(WriteBarrierPreStub.class, "writeBarrierPreC", false);
+    public static final Descriptor WRITE_BARRIER_PRE_C = StubUtil.descriptorFor(WriteBarrierPreStub.class, "writeBarrierPreC", false);
 
     @NodeIntrinsic(CRuntimeCall.class)
     public static native void writeBarrierPreC(@ConstantNodeParameter Descriptor vmErrorC, Word thread, Object object);