harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From x..@apache.org
Subject svn commit: r601343 - in /harmony/enhanced/drlvm/trunk/vm: gc_gen/javasrc/org/apache/harmony/drlvm/gc_gen/ gc_gen/javasrc_uncomp/org/apache/harmony/drlvm/gc_gen/ gc_gen/src/jni/ gc_gen/src/thread/ vmcore/src/kernel_classes/javasrc/org/apache/harmony/dr...
Date Wed, 05 Dec 2007 14:22:42 GMT
Author: xli
Date: Wed Dec  5 06:22:40 2007
New Revision: 601343

URL: http://svn.apache.org/viewvc?rev=601343&view=rev
Log:
HARMONY-5231 : [drlvm][gc_gen] Implementing allocation prefetch and memset in java GC helpers

Modified:
    harmony/enhanced/drlvm/trunk/vm/gc_gen/javasrc/org/apache/harmony/drlvm/gc_gen/GCHelper.java
    harmony/enhanced/drlvm/trunk/vm/gc_gen/javasrc_uncomp/org/apache/harmony/drlvm/gc_gen/GCHelper.java
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/jni/java_natives.cpp
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/thread/gc_thread.h
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/org/apache/harmony/drlvm/VMHelper.java

Modified: harmony/enhanced/drlvm/trunk/vm/gc_gen/javasrc/org/apache/harmony/drlvm/gc_gen/GCHelper.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/gc_gen/javasrc/org/apache/harmony/drlvm/gc_gen/GCHelper.java?rev=601343&r1=601342&r2=601343&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/gc_gen/javasrc/org/apache/harmony/drlvm/gc_gen/GCHelper.java
(original)
+++ harmony/enhanced/drlvm/trunk/vm/gc_gen/javasrc/org/apache/harmony/drlvm/gc_gen/GCHelper.java
Wed Dec  5 06:22:40 2007
@@ -32,25 +32,63 @@
     }
 
     public static final int TLS_GC_OFFSET = TLSGCOffset();
+    public static final int PREFETCH_DISTANCE = getPrefetchDist();    
+    public static final int ZEROING_SIZE = getZeroingSize();
+    public static final int PREFETCH_STRIDE = getPrefetchStride();
+
+    public static final int TLA_FREE_OFFSET = getTlaFreeOffset();
+    public static final int TLA_CEILING_OFFSET = getTlaCeilingOffset();
+    public static final int TLA_END_OFFSET = getTlaEndOffset();
+
+    public static final int LARGE_OBJECT_SIZE = getLargeObjectSize();
+    public static final boolean PREFETCH_ENABLED = isPrefetchEnabled();
+
 
     @Inline
     private static Address alloc(int objSize, int allocationHandle ) {
 
+	if (objSize > LARGE_OBJECT_SIZE) {
+	    return VMHelper.newResolvedUsingAllocHandleAndSize(objSize, allocationHandle);
+	}
+
         Address TLS_BASE = VMHelper.getTlsBaseAddress();
 
         Address allocator_addr = TLS_BASE.plus(TLS_GC_OFFSET);
         Address allocator = allocator_addr.loadAddress();
-        Address free_addr = allocator.plus(0);
+        Address free_addr = allocator.plus(TLA_FREE_OFFSET);
         Address free = free_addr.loadAddress();
-        Address ceiling = allocator.plus(4).loadAddress();
-        
+        Address ceiling_addr = allocator.plus(TLA_CEILING_OFFSET);
+        Address ceiling = ceiling_addr.loadAddress();
+
         Address new_free = free.plus(objSize);
 
         if (new_free.LE(ceiling)) {
             free_addr.store(new_free);
             free.store(allocationHandle);
             return free;
-        }
+        } else if (PREFETCH_ENABLED) {
+            Address end = allocator.plus(TLA_END_OFFSET).loadAddress();
+            if(new_free.LE(end)) {
+               // do prefetch from new_free to new_free + PREFETCH_DISTANCE + ZEROING_SIZE
+               VMHelper.prefetch(new_free, PREFETCH_DISTANCE + ZEROING_SIZE, PREFETCH_STRIDE);
+
+               Address new_ceiling = new_free.plus(ZEROING_SIZE);
+	       // align ceiling to 64 bytes		
+	       int remainder = new_ceiling.toInt() & 63;
+	       new_ceiling = new_ceiling.minus(remainder);
+
+               if( !new_ceiling.LE(end) ){
+                   new_ceiling = end;
+               }
+
+               VMHelper.memset0(ceiling , new_ceiling.diff(ceiling).toInt());
+
+               ceiling_addr.store(new_ceiling);
+               free_addr.store(new_free);
+               free.store(allocationHandle);
+               return free;
+	    }
+	}    
                 
         return VMHelper.newResolvedUsingAllocHandleAndSize(objSize, allocationHandle);  
 
     }
@@ -64,7 +102,7 @@
 
 
     private static final int ARRAY_LEN_OFFSET = 8;
-    private static final int GC_OBJECT_ALIGNMENT = 4;
+    private static final int GC_OBJECT_ALIGNMENT = getGCObjectAlignment();
 
     @Inline
     public static Address allocArray(Address elemClassHandle, int arrayLen) {
@@ -103,9 +141,22 @@
         VMHelper.writeBarrier(p_objBase, p_objSlot, p_target);
     }
 
+    private static native boolean isPrefetchEnabled();
+    private static native int getLargeObjectSize();
+    private static native int getTlaFreeOffset(); 
+    private static native int getTlaCeilingOffset(); 
+    private static native int getTlaEndOffset(); 
+    private static native int getGCObjectAlignment(); 
+    private static native int getPrefetchDist(); 
+    private static native int getZeroingSize(); 
+    private static native int getPrefetchStride();
     private static native int helperCallback();
     private static native boolean getGenMode(); 
     private static native long getNosBoundary();    
     private static native int TLSGCOffset();
 }
+
+
+
+
 

Modified: harmony/enhanced/drlvm/trunk/vm/gc_gen/javasrc_uncomp/org/apache/harmony/drlvm/gc_gen/GCHelper.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/gc_gen/javasrc_uncomp/org/apache/harmony/drlvm/gc_gen/GCHelper.java?rev=601343&r1=601342&r2=601343&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/gc_gen/javasrc_uncomp/org/apache/harmony/drlvm/gc_gen/GCHelper.java
(original)
+++ harmony/enhanced/drlvm/trunk/vm/gc_gen/javasrc_uncomp/org/apache/harmony/drlvm/gc_gen/GCHelper.java
Wed Dec  5 06:22:40 2007
@@ -32,25 +32,62 @@
     }
 
     public static final int TLS_GC_OFFSET = TLSGCOffset();
+    public static final int PREFETCH_DISTANCE = getPrefetchDist();    
+    public static final int ZEROING_SIZE = getZeroingSize();
+    public static final int PREFETCH_STRIDE = getPrefetchStride();
+
+    public static final int TLA_FREE_OFFSET = getTlaFreeOffset();
+    public static final int TLA_CEILING_OFFSET = getTlaCeilingOffset();
+    public static final int TLA_END_OFFSET = getTlaEndOffset();
+
+    public static final int LARGE_OBJECT_SIZE = getLargeObjectSize();
+    public static final boolean PREFETCH_ENABLED = isPrefetchEnabled();
+
 
     @Inline
     private static Address alloc(int objSize, int allocationHandle ) {
 
+	if (objSize > LARGE_OBJECT_SIZE) {
+	    return VMHelper.newResolvedUsingAllocHandleAndSize(objSize, allocationHandle);
+	}
+
         Address TLS_BASE = VMHelper.getTlsBaseAddress();
 
         Address allocator_addr = TLS_BASE.plus(TLS_GC_OFFSET);
         Address allocator = allocator_addr.loadAddress();
-        Address free_addr = allocator.plus(0);
+        Address free_addr = allocator.plus(TLA_FREE_OFFSET);
         Address free = free_addr.loadAddress();
-        Address ceiling = allocator.plus(4).loadAddress();
-        
+        Address ceiling_addr = allocator.plus(TLA_CEILING_OFFSET);
+        Address ceiling = ceiling_addr.loadAddress();
+
         Address new_free = free.plus(objSize);
 
         if (new_free.LE(ceiling)) {
             free_addr.store(new_free);
             free.store(allocationHandle);
             return free;
-        }
+        } else if (PREFETCH_ENABLED) {
+            Address end = allocator.plus(TLA_END_OFFSET).loadAddress();
+            if(new_free.LE(end)) {
+               // do prefetch from new_free to new_free + PREFETCH_DISTANCE + ZEROING_SIZE
+               VMHelper.prefetch(new_free, PREFETCH_DISTANCE + ZEROING_SIZE, PREFETCH_STRIDE);
+    
+               Address new_ceiling = new_free.plus(ZEROING_SIZE);
+	       // align ceiling to 64 bytes		
+	       int remainder = new_ceiling.toInt() & 63;
+	       new_ceiling = new_ceiling.minus(remainder);
+               if( !new_ceiling.LE(end) ){
+                   new_ceiling = end;
+               }
+
+               VMHelper.memset0(ceiling , new_ceiling.diff(ceiling).toInt());
+
+               ceiling_addr.store(new_ceiling);
+               free_addr.store(new_free);
+               free.store(allocationHandle);
+               return free;
+	    }
+	}    
                 
         return VMHelper.newResolvedUsingAllocHandleAndSize(objSize, allocationHandle);  
 
     }
@@ -64,7 +101,7 @@
 
 
     private static final int ARRAY_LEN_OFFSET = 8;
-    private static final int GC_OBJECT_ALIGNMENT = 4;
+    private static final int GC_OBJECT_ALIGNMENT = getGCObjectAlignment();
 
     @Inline
     public static Address allocArray(Address elemClassHandle, int arrayLen) {
@@ -103,9 +140,22 @@
         VMHelper.writeBarrier(p_objBase, p_objSlot, p_target);
     }
 
+    private static native boolean isPrefetchEnabled();
+    private static native int getLargeObjectSize();
+    private static native int getTlaFreeOffset(); 
+    private static native int getTlaCeilingOffset(); 
+    private static native int getTlaEndOffset(); 
+    private static native int getGCObjectAlignment(); 
+    private static native int getPrefetchDist(); 
+    private static native int getZeroingSize(); 
+    private static native int getPrefetchStride();
     private static native int helperCallback();
     private static native boolean getGenMode(); 
     private static native long getNosBoundary();    
     private static native int TLSGCOffset();
 }
+
+
+
+
 

Modified: harmony/enhanced/drlvm/trunk/vm/gc_gen/src/jni/java_natives.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/jni/java_natives.cpp?rev=601343&r1=601342&r2=601343&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/gc_gen/src/jni/java_natives.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/gc_gen/src/jni/java_natives.cpp Wed Dec  5 06:22:40 2007
@@ -58,6 +58,48 @@
     GCHelper_clss = *vm_class_ptr;
 }
 
+JNIEXPORT jint JNICALL Java_org_apache_harmony_drlvm_gc_1gen_GCHelper_getPrefetchDist(JNIEnv
*e, jclass c)
+{
+    return (jint)PREFETCH_DISTANCE;
+}
+
+JNIEXPORT jint JNICALL Java_org_apache_harmony_drlvm_gc_1gen_GCHelper_getZeroingSize(JNIEnv
*e, jclass c)
+{
+    return (jint)ZEROING_SIZE;
+}
+
+JNIEXPORT jint JNICALL Java_org_apache_harmony_drlvm_gc_1gen_GCHelper_getPrefetchStride(JNIEnv
*e, jclass c)
+{
+    return (jint)PREFETCH_STRIDE;
+}
+
+JNIEXPORT jint JNICALL Java_org_apache_harmony_drlvm_gc_1gen_GCHelper_getTlaFreeOffset(JNIEnv
*, jclass) {
+    Allocator allocator;
+    return (jint) ((POINTER_SIZE_INT)&allocator.free - (POINTER_SIZE_INT)&allocator);
+}
+
+JNIEXPORT jint JNICALL Java_org_apache_harmony_drlvm_gc_1gen_GCHelper_getTlaCeilingOffset(JNIEnv
*, jclass) {
+    Allocator allocator;
+    return (jint) ((POINTER_SIZE_INT)&allocator.ceiling - (POINTER_SIZE_INT)&allocator);
+}
+
+JNIEXPORT jint JNICALL Java_org_apache_harmony_drlvm_gc_1gen_GCHelper_getTlaEndOffset(JNIEnv
*, jclass) {
+    Allocator allocator;
+    return (jint) ((POINTER_SIZE_INT)&allocator.end - (POINTER_SIZE_INT)&allocator);
+}
+
+JNIEXPORT jint JNICALL Java_org_apache_harmony_drlvm_gc_1gen_GCHelper_getGCObjectAlignment(JNIEnv
*, jclass) {
+   return (jint) GC_OBJECT_ALIGNMENT;
+}
+
+JNIEXPORT jint JNICALL Java_org_apache_harmony_drlvm_gc_1gen_GCHelper_getLargeObjectSize(JNIEnv
*, jclass) {
+   return (jint) GC_OBJ_SIZE_THRESHOLD;
+}
+
+JNIEXPORT jboolean JNICALL Java_org_apache_harmony_drlvm_gc_1gen_GCHelper_isPrefetchEnabled(JNIEnv
*, jclass) {
+   return (jboolean) PREFETCH_ENABLED;
+}
+
 #ifdef __cplusplus
 }
 #endif

Modified: harmony/enhanced/drlvm/trunk/vm/gc_gen/src/thread/gc_thread.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/thread/gc_thread.h?rev=601343&r1=601342&r2=601343&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/gc_gen/src/thread/gc_thread.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/gc_gen/src/thread/gc_thread.h Wed Dec  5 06:22:40 2007
@@ -98,6 +98,7 @@
 
   POINTER_SIZE_INT new_ceiling;
   new_ceiling =  new_free + ZEROING_SIZE;
+  new_ceiling = new_ceiling - (new_ceiling & 63);
   
 #ifdef ALLOC_PREFETCH  
   if(PREFETCH_ENABLED)  {
@@ -169,8 +170,10 @@
         }while(pre_addr< pref_dist);
     }
 #endif 
-    allocator->ceiling = (void*)((POINTER_SIZE_INT)new_free + ZEROING_SIZE);
-    memset(new_free, 0, ZEROING_SIZE);
+    POINTER_SIZE_INT new_ceiling = (POINTER_SIZE_INT)new_free + ZEROING_SIZE;
+    POINTER_SIZE_INT align = new_ceiling & 63;
+    allocator->ceiling = (void*)(new_ceiling - align);
+    memset(new_free, 0, ZEROING_SIZE - align);
 
 #endif /* #ifndef ALLOC_ZEROING */
 

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/org/apache/harmony/drlvm/VMHelper.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/org/apache/harmony/drlvm/VMHelper.java?rev=601343&r1=601342&r2=601343&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/org/apache/harmony/drlvm/VMHelper.java
(original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/org/apache/harmony/drlvm/VMHelper.java
Wed Dec  5 06:22:40 2007
@@ -75,6 +75,10 @@
 
     public static void monitorExit(Object obj) {fail();}
 
+    public static void memset0(Address addr, int size) {fail();}
+
+    public static void prefetch(Address addr, int distance, int stride) {fail();}
+
     public static void writeBarrier(Address objBase, Address objSlot, Address source) {fail();}
 
     public static Address getInterfaceVTable(Object obj, Address intfTypePtr) {fail(); return
null;}
@@ -145,4 +149,7 @@
     /** @return object base offset if is in compressed-refs mode or -1*/
     private static native long getCompressedModeObjectBaseOffset();
 }
+
+
+
 



Mime
View raw message