harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wjwashb...@apache.org
Subject svn commit: r500803 [1/3] - in /harmony/enhanced/drlvm/trunk: build/make/components/vm/ vm/gc_gen/javasrc/org/apache/harmony/drlvm/gc_gen/ vm/gc_gen/src/common/ vm/gc_gen/src/finalizer_weakref/ vm/gc_gen/src/gen/ vm/gc_gen/src/jni/ vm/gc_gen/src/mark_c...
Date Sun, 28 Jan 2007 14:41:11 GMT
Author: wjwashburn
Date: Sun Jan 28 06:41:08 2007
New Revision: 500803

URL: http://svn.apache.org/viewvc?view=rev&rev=500803
Log:
Harmony-3042, patch for 32-bit linux and large page support
build test runs on windowsxp and linux rhel4 w/ gcc 4.0.2

Added:
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/large_pages.cpp
Modified:
    harmony/enhanced/drlvm/trunk/build/make/components/vm/gc_gen.xml
    harmony/enhanced/drlvm/trunk/vm/gc_gen/javasrc/org/apache/harmony/drlvm/gc_gen/GCHelper.java
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/fix_repointed_refs.h
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_block.h
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_common.cpp
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_common.h
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_for_class.cpp
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_for_class.h
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_for_vm.cpp
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_metadata.cpp
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_metadata.h
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_platform.h
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_space.h
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/interior_pointer.cpp
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/mark_scan_pool.cpp
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/space_tuner.cpp
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/space_tuner.h
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/finalizer_weakref/finalizer_weakref.cpp
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/finalizer_weakref/finalizer_weakref.h
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/finalizer_weakref/finalizer_weakref_metadata.cpp
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/finalizer_weakref/finalizer_weakref_metadata.h
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/gen/gen.cpp
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/gen/gen.h
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/gen/gen_adapt.cpp
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/jni/java_natives.cpp
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/jni/java_support.cpp
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_compact/fallback_mark_scan.cpp
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_compact/mspace.cpp
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_compact/mspace.h
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_compact/mspace_alloc.cpp
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_compact/mspace_collect_compact.cpp
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_compact/mspace_extend_compact.cpp
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_compact/mspace_move_compact.cpp
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_compact/mspace_slide_compact.cpp
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_sweep/free_area_pool.h
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_sweep/lspace.cpp
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_sweep/lspace.h
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_sweep/lspace_alloc_collect.cpp
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/thread/collector.cpp
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/thread/collector_alloc.h
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/thread/gc_thread.h
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/thread/mutator.cpp
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/thread/mutator_alloc.cpp
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/trace_forward/fspace.cpp
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/trace_forward/fspace.h
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/trace_forward/fspace_alloc.cpp
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/trace_forward/fspace_gen_forward_pool.cpp
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/trace_forward/fspace_nongen_forward_pool.cpp
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/utils/bit_ops.h
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/utils/sync_queue.h
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/utils/sync_stack.h
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/utils/vector_block.h

Modified: harmony/enhanced/drlvm/trunk/build/make/components/vm/gc_gen.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/build/make/components/vm/gc_gen.xml?view=diff&rev=500803&r1=500802&r2=500803
==============================================================================
--- harmony/enhanced/drlvm/trunk/build/make/components/vm/gc_gen.xml (original)
+++ harmony/enhanced/drlvm/trunk/build/make/components/vm/gc_gen.xml Sun Jan 28 06:41:08 2007
@@ -52,7 +52,7 @@
             </includepath>
 
             <fileset dir="${src}/gc_gen/src">
-                <select arch="ia32">
+                <select arch="ia32,em64t">
                 <include name="common/*.cpp" />            
                 <include name="gen/*.cpp" />            
                 <include name="mark_compact/*.cpp" />            
@@ -65,7 +65,7 @@
                 <include name="finalizer_weakref/*.cpp" />
                 </select>
 
-                <select arch="em64t,ipf">
+                <select arch="ipf">
                 <exclude name="common/*.cpp" />            
                 <exclude name="gen/*.cpp" />            
                 <exclude name="mark_compact/*.cpp" />            

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?view=diff&rev=500803&r1=500802&r2=500803
==============================================================================
--- 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 Sun Jan 28 06:41:08 2007
@@ -33,7 +33,7 @@
 
     public static final int TLS_GC_OFFSET = TLSGCOffset();
 
-    public static Address alloc(int objSize, int allocationHandle) throws InlinePragma {
+    public static Address alloc(int objSize, int allocationHandle)  throws InlinePragma {
         Address TLS_BASE = VMHelper.getTlsBaseAddress();
 
         Address allocator_addr = TLS_BASE.plus(TLS_GC_OFFSET);
@@ -74,13 +74,13 @@
        be a constant in future.
     */
 
-    public static final int NOS_BOUNDARY = getNosBoundary();
+    public static Address NOS_BOUNDARY = getNosBoundary();
     public static boolean GEN_MODE = getGenMode();
 
     public static void write_barrier_slot_rem(Address p_objBase, Address p_objSlot, Address p_target)  throws InlinePragma {
       
        /* If the slot is in NOS or the target is not in NOS, we simply return*/
-        if(p_objSlot.toInt() >= NOS_BOUNDARY || p_target.toInt() < NOS_BOUNDARY || !GEN_MODE) {
+        if(p_objSlot.GE(NOS_BOUNDARY) || p_target.LT(NOS_BOUNDARY) || !GEN_MODE) {
             p_objSlot.store(p_target);
             return;
         }
@@ -90,7 +90,7 @@
 
     private static native int helperCallback();
     private static native boolean getGenMode(); 
-    private static native int getNosBoundary();    
+    private static native Address getNosBoundary();    
     private static native int TLSGCOffset();
 }
 

Modified: harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/fix_repointed_refs.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/fix_repointed_refs.h?view=diff&rev=500803&r1=500802&r2=500803
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/fix_repointed_refs.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/fix_repointed_refs.h Sun Jan 28 06:41:08 2007
@@ -37,9 +37,9 @@
       /* Condition obj_is_moved(p_obj) is for preventing mistaking previous mark bit of large obj as fw bit when fallback happens.
        * Because until fallback happens, perhaps the large obj hasn't been marked. So its mark bit remains as the last time.
        * In major collection condition obj_is_fw_in_oi(p_obj) can be omitted,
-       * for whose which can be scanned in MOS & NOS must have been set fw bit in oi.
+       * since those which can be scanned in MOS & NOS must have been set fw bit in oi.
        */
-      assert((unsigned int)obj_get_fw_in_oi(p_obj) > DUAL_MARKBITS);
+      assert((POINTER_SIZE_INT)obj_get_fw_in_oi(p_obj) > DUAL_MARKBITS);
       *p_ref = obj_get_fw_in_oi(p_obj);
     }
   }
@@ -57,7 +57,7 @@
     assert(!obj_is_primitive_array(p_obj));
     
     int32 array_length = array->array_len;
-    Partial_Reveal_Object** p_refs = (Partial_Reveal_Object**)((int)array + (int)array_first_element_offset(array));
+    Partial_Reveal_Object** p_refs = (Partial_Reveal_Object**)((POINTER_SIZE_INT)array + (int)array_first_element_offset(array));
     for (int i = 0; i < array_length; i++) {
       slot_fix(p_refs + i);
     }   
@@ -79,11 +79,11 @@
 
 inline void block_fix_ref_after_copying(Block_Header* curr_block)
 {
-  unsigned int cur_obj = (unsigned int)curr_block->base;
-  unsigned int block_end = (unsigned int)curr_block->free;
+  POINTER_SIZE_INT cur_obj = (POINTER_SIZE_INT)curr_block->base;
+  POINTER_SIZE_INT block_end = (POINTER_SIZE_INT)curr_block->free;
   while(cur_obj < block_end){
     object_fix_ref_slots((Partial_Reveal_Object*)cur_obj);   
-    cur_obj = (unsigned int)cur_obj + vm_object_size((Partial_Reveal_Object*)cur_obj);
+    cur_obj = cur_obj + vm_object_size((Partial_Reveal_Object*)cur_obj);
   }
   return;
 }

Modified: harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_block.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_block.h?view=diff&rev=500803&r1=500802&r2=500803
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_block.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_block.h Sun Jan 28 06:41:08 2007
@@ -23,8 +23,6 @@
 
 #include "gc_common.h"
 
-#define SYSTEM_ALLOC_UNIT 0x10000
-
 #define GC_BLOCK_SHIFT_COUNT 15
 #define GC_BLOCK_SIZE_BYTES (1 << GC_BLOCK_SHIFT_COUNT)
 
@@ -50,7 +48,7 @@
   Partial_Reveal_Object* src;
   Partial_Reveal_Object* next_src;
   Block_Header* next;
-  unsigned int table[1]; /* entry num == OFFSET_TABLE_SIZE_WORDS */
+  POINTER_SIZE_INT table[1]; /* entry num == OFFSET_TABLE_SIZE_WORDS */
 }Block_Header;
 
 typedef union Block{
@@ -58,7 +56,7 @@
     unsigned char raw_bytes[GC_BLOCK_SIZE_BYTES];
 }Block;
 
-#define GC_BLOCK_HEADER_VARS_SIZE_BYTES (unsigned int)&(((Block_Header*)0)->table)
+#define GC_BLOCK_HEADER_VARS_SIZE_BYTES (POINTER_SIZE_INT)&(((Block_Header*)0)->table)
 
 #define SECTOR_SIZE_SHIFT_COUNT  8
 #define SECTOR_SIZE_BYTES        (1 << SECTOR_SIZE_SHIFT_COUNT)
@@ -75,22 +73,22 @@
 
 #define GC_BLOCK_HEADER_SIZE_BYTES (OFFSET_TABLE_SIZE_BYTES + GC_BLOCK_HEADER_VARS_SIZE_BYTES)
 #define GC_BLOCK_BODY_SIZE_BYTES (GC_BLOCK_SIZE_BYTES - GC_BLOCK_HEADER_SIZE_BYTES)
-#define GC_BLOCK_BODY(block) ((void*)((unsigned int)(block) + GC_BLOCK_HEADER_SIZE_BYTES))
-#define GC_BLOCK_END(block) ((void*)((unsigned int)(block) + GC_BLOCK_SIZE_BYTES))
+#define GC_BLOCK_BODY(block) ((void*)((POINTER_SIZE_INT)(block) + GC_BLOCK_HEADER_SIZE_BYTES))
+#define GC_BLOCK_END(block) ((void*)((POINTER_SIZE_INT)(block) + GC_BLOCK_SIZE_BYTES))
 
-#define GC_BLOCK_LOW_MASK ((unsigned int)(GC_BLOCK_SIZE_BYTES - 1))
+#define GC_BLOCK_LOW_MASK ((POINTER_SIZE_INT)(GC_BLOCK_SIZE_BYTES - 1))
 #define GC_BLOCK_HIGH_MASK (~GC_BLOCK_LOW_MASK)
-#define GC_BLOCK_HEADER(addr) ((Block_Header *)((unsigned int)(addr) & GC_BLOCK_HIGH_MASK))
+#define GC_BLOCK_HEADER(addr) ((Block_Header *)((POINTER_SIZE_INT)(addr) & GC_BLOCK_HIGH_MASK))
 #define GC_BLOCK_INDEX(addr) ((unsigned int)(GC_BLOCK_HEADER(addr)->block_idx))
-#define GC_BLOCK_INDEX_FROM(heap_start, addr) ((unsigned int)(((unsigned int)(addr)-(unsigned int)(heap_start)) >> GC_BLOCK_SHIFT_COUNT))
+#define GC_BLOCK_INDEX_FROM(heap_start, addr) ((unsigned int)(((POINTER_SIZE_INT)(addr)-(POINTER_SIZE_INT)(heap_start)) >> GC_BLOCK_SHIFT_COUNT))
 
-#define ADDRESS_OFFSET_TO_BLOCK_HEADER(addr) ((unsigned int)((unsigned int)addr&GC_BLOCK_LOW_MASK))
+#define ADDRESS_OFFSET_TO_BLOCK_HEADER(addr) ((unsigned int)((POINTER_SIZE_INT)addr&GC_BLOCK_LOW_MASK))
 #define ADDRESS_OFFSET_IN_BLOCK_BODY(addr) ((unsigned int)(ADDRESS_OFFSET_TO_BLOCK_HEADER(addr)- GC_BLOCK_HEADER_SIZE_BYTES))
 
 inline void block_init(Block_Header* block)
 {
-  block->free = (void*)((unsigned int)block + GC_BLOCK_HEADER_SIZE_BYTES);
-  block->ceiling = (void*)((unsigned int)block + GC_BLOCK_SIZE_BYTES); 
+  block->free = (void*)((POINTER_SIZE_INT)block + GC_BLOCK_HEADER_SIZE_BYTES);
+  block->ceiling = (void*)((POINTER_SIZE_INT)block + GC_BLOCK_SIZE_BYTES); 
   block->base = block->free;
   block->new_free = block->free;
   block->status = BLOCK_FREE;
@@ -101,7 +99,7 @@
 
 inline Partial_Reveal_Object *obj_end(Partial_Reveal_Object *obj)
 {
-  return (Partial_Reveal_Object *)((unsigned int)obj + vm_object_size(obj));
+  return (Partial_Reveal_Object *)((POINTER_SIZE_INT)obj + vm_object_size(obj));
 }
 
 inline Partial_Reveal_Object *next_marked_obj_in_block(Partial_Reveal_Object *cur_obj, Partial_Reveal_Object *block_end)
@@ -240,12 +238,12 @@
   /* only for inter-sector compaction */
   unsigned int index    = OBJECT_INDEX_TO_OFFSET_TABLE(p_obj);
   Block_Header *curr_block = GC_BLOCK_HEADER(p_obj);
-  return (Partial_Reveal_Object *)(((unsigned int)p_obj) - curr_block->table[index]);
+  return (Partial_Reveal_Object *)(((POINTER_SIZE_INT)p_obj) - curr_block->table[index]);
 }
 
 inline void block_clear_table(Block_Header* block)
 {
-  unsigned int* table = block->table;
+  POINTER_SIZE_INT* table = block->table;
   memset(table, 0, OFFSET_TABLE_SIZE_BYTES);
   return;
 }

Modified: harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_common.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_common.cpp?view=diff&rev=500803&r1=500802&r2=500803
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_common.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_common.cpp Sun Jan 28 06:41:08 2007
@@ -29,10 +29,13 @@
 unsigned int Cur_Mark_Bit = 0x1;
 unsigned int Cur_Forward_Bit = 0x2;
 
+unsigned int SPACE_ALLOC_UNIT;
+
 extern Boolean GC_VERIFY;
 
 extern unsigned int NOS_SIZE;
 extern unsigned int MIN_NOS_SIZE;
+extern unsigned int MIN_LOS_SIZE;
 
 extern Boolean FORCE_FULL_COMPACT;
 extern Boolean MINOR_ALGORITHM;
@@ -46,6 +49,8 @@
 unsigned int min_heap_size_bytes = 32 * MB;
 unsigned int max_heap_size_bytes = 0;
 
+extern Boolean JVMTI_HEAP_ITERATION ;
+
 static int get_int_property(const char *property_name)
 {
     assert(property_name);
@@ -154,6 +159,10 @@
     MIN_NOS_SIZE = get_size_property("gc.min_nos_size");
   }
 
+  if (is_property_set("gc.min_los_size", VM_PROPERTIES) == 1) {
+    MIN_LOS_SIZE = get_size_property("gc.min_los_size");
+  }  
+
   if (is_property_set("gc.num_collectors", VM_PROPERTIES) == 1) {
     unsigned int num = get_int_property("gc.num_collectors");
     NUM_COLLECTORS = (num==0)? NUM_COLLECTORS:num;
@@ -214,6 +223,21 @@
   if (is_property_set("gc.verify", VM_PROPERTIES) == 1) {
     GC_VERIFY = get_boolean_property("gc.verify");
   }
+
+  if (is_property_set("gc.gen_nongen_switch", VM_PROPERTIES) == 1){
+    GEN_NONGEN_SWITCH= get_boolean_property("gc.gen_nongen_switch");
+    gc->generate_barrier = TRUE;
+  }
+
+  if (is_property_set("gc.heap_iteration", VM_PROPERTIES) == 1) {
+    JVMTI_HEAP_ITERATION = get_boolean_property("gc.heap_iteration");
+  }
+
+  if (is_property_set("gc.use_large_page", VM_PROPERTIES) == 1){
+    char* value = get_property("gc.use_large_page", VM_PROPERTIES);
+    large_page_hint = strdup(value);
+    destroy_property_value(value);
+  }
   
   return;
 }
@@ -222,16 +246,22 @@
 
 void gc_reclaim_heap(GC* gc, unsigned int gc_cause)
 { 
+  int64 start_time =  time_now();
+
   /* FIXME:: before mutators suspended, the ops below should be very careful
      to avoid racing with mutators. */
   gc->num_collections++;  
-
+  gc->cause = gc_cause;
   gc_decide_collection_kind((GC_Gen*)gc, gc_cause);
 
 
   //For_LOS_extend!
-  gc_space_tune(gc, gc_cause);
-
+#ifdef GC_FIXED_SIZE_TUNER
+  gc_space_tune_before_gc_simplified(gc, gc_cause);
+#else
+  gc_space_tune_prepare(gc, gc_cause);
+  gc_space_tune_before_gc(gc, gc_cause);
+#endif
 
 #ifdef MARK_BIT_FLIPPING
   if(gc->collect_kind == MINOR_COLLECTION)
@@ -254,18 +284,28 @@
 
   if(!IGNORE_FINREF )
     gc_set_obj_with_fin(gc);
-  
+
   gc_gen_reclaim_heap((GC_Gen*)gc);
+  
   gc_reset_interior_pointer_table();
     
   gc_metadata_verify(gc, FALSE);
 
+  int64 pause_time = time_now() - start_time;  
+  gc->time_collections += pause_time;
+  gc_gen_adapt((GC_Gen*)gc, pause_time);
+
   if(gc_is_gen_mode())
     gc_prepare_mutator_remset(gc);
   
   if(!IGNORE_FINREF ){
+    gc_put_finref_to_vm(gc);
     gc_reset_finref_metadata(gc);
     gc_activate_finref_threads((GC*)gc);
+#ifndef BUILD_IN_REFERENT
+  } else {
+    gc_clear_weakref_pools(gc);
+#endif
   }
 
   //For_LOS_extend!

Modified: harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_common.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_common.h?view=diff&rev=500803&r1=500802&r2=500803
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_common.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_common.h Sun Jan 28 06:41:08 2007
@@ -53,6 +53,9 @@
 #define BIT_SHIFT_TO_KILO 10 
 
 #define BIT_MASK_TO_BITS_PER_WORD ((1<<BIT_SHIFT_TO_BITS_PER_WORD)-1)
+#define BITS_OF_POINTER_SIZE_INT (sizeof(POINTER_SIZE_INT) << BIT_SHIFT_TO_BITS_PER_BYTE)
+#define BYTES_OF_POINTER_SIZE_INT (sizeof(POINTER_SIZE_INT))
+#define BIT_SHIFT_TO_BYTES_OF_POINTER_SIZE_INT ((sizeof(POINTER_SIZE_INT)==4)? 2: 3)
 
 #define GC_OBJ_SIZE_THRESHOLD (4*KB)
 
@@ -76,7 +79,8 @@
 enum Collection_Kind {
   MINOR_COLLECTION,
   MAJOR_COLLECTION,
-  FALLBACK_COLLECTION  
+  FALLBACK_COLLECTION,
+  EXTEND_COLLECTION
 };
 
 extern Boolean IS_FALLBACK_COMPACTION;  /* only for mark/fw bits debugging purpose */
@@ -104,7 +108,7 @@
 
 inline Partial_Reveal_Object** object_ref_iterator_get(int* iterator, Partial_Reveal_Object* obj)
 {
-  return (Partial_Reveal_Object**)((int)obj + *iterator);
+  return (Partial_Reveal_Object**)((POINTER_SIZE_INT)obj + *iterator);
 }
 
 inline int* object_ref_iterator_next(int* iterator)
@@ -133,15 +137,15 @@
 inline Boolean obj_mark_in_vt(Partial_Reveal_Object *obj) 
 {  
   Partial_Reveal_VTable* vt = obj_get_vt_raw(obj);
-  if((unsigned int)vt & CONST_MARK_BIT) return FALSE;
-  obj_set_vt(obj, (unsigned int)vt | CONST_MARK_BIT);
+  if((POINTER_SIZE_INT)vt & CONST_MARK_BIT) return FALSE;
+  obj_set_vt(obj, (POINTER_SIZE_INT)vt | CONST_MARK_BIT);
   return TRUE;
 }
 
 inline void obj_unmark_in_vt(Partial_Reveal_Object *obj) 
 { 
   Partial_Reveal_VTable* vt = obj_get_vt_raw(obj);
-  obj_set_vt(obj, (unsigned int)vt & ~CONST_MARK_BIT);
+  obj_set_vt(obj, (POINTER_SIZE_INT)vt & ~CONST_MARK_BIT);
 }
 
 inline Boolean obj_is_marked_or_fw_in_oi(Partial_Reveal_Object *obj)
@@ -285,6 +289,7 @@
 
   unsigned int collect_kind; /* MAJOR or MINOR */
   unsigned int last_collect_kind;
+  unsigned int cause;/*GC_CAUSE_LOS_IS_FULL, GC_CAUSE_NOS_IS_FULL, or GC_CAUSE_RUNTIME_FORCE_GC*/
   Boolean collect_result; /* succeed or fail */
 
   Boolean generate_barrier;
@@ -325,7 +330,7 @@
   //#define NOS_BOUNDARY ((void*)0x2ea20000)  //this is for 512M
   #define NOS_BOUNDARY ((void*)0x40000000) //this is for 256M
 
-	#define nos_boundary NOS_BOUNDARY
+  #define nos_boundary NOS_BOUNDARY
 
 #else /* STATIC_NOS_MAPPING */
 

Modified: harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_for_class.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_for_class.cpp?view=diff&rev=500803&r1=500802&r2=500803
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_for_class.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_for_class.cpp Sun Jan 28 06:41:08 2007
@@ -104,7 +104,9 @@
     Field_Handle fh = class_get_instance_field_recursive(ch, idx);
     if(field_is_reference(fh)) {
       int offset = field_get_offset(fh);
+#ifndef BUILD_IN_REFERENT
       if(is_reference && offset == gc_referent_offset) continue;
+#endif
       *new_ref_array = field_get_offset(fh);
       new_ref_array++;
     }
@@ -138,7 +140,7 @@
   gcvt_size = (gcvt_size + GCVT_ALIGN_MASK) & ~GCVT_ALIGN_MASK;
   gcvt = (GC_VTable_Info*) malloc(gcvt_size);
   assert(gcvt);
-  assert(!((unsigned int)gcvt % GCVT_ALIGNMENT));
+  assert(!((POINTER_SIZE_INT)gcvt % GCVT_ALIGNMENT));
 
   memset((void *)gcvt, 0, gcvt_size);
   gcvt->gc_clss = ch;
@@ -181,13 +183,13 @@
 
   /* these should be set last to use the gcvt pointer */
   if(gcvt->gc_number_of_ref_fields)
-    gcvt = (GC_VTable_Info*)((unsigned int)gcvt | GC_CLASS_FLAG_REFS);
+    gcvt = (GC_VTable_Info*)((POINTER_SIZE_INT)gcvt | GC_CLASS_FLAG_REFS);
   
   if(class_is_array(ch))
-    gcvt = (GC_VTable_Info*)((unsigned int)gcvt | GC_CLASS_FLAG_ARRAY);
+    gcvt = (GC_VTable_Info*)((POINTER_SIZE_INT)gcvt | GC_CLASS_FLAG_ARRAY);
     
   if(class_is_finalizable(ch))
-    gcvt = (GC_VTable_Info*)((unsigned int)gcvt | GC_CLASS_FLAG_FINALIZER);
+    gcvt = (GC_VTable_Info*)((POINTER_SIZE_INT)gcvt | GC_CLASS_FLAG_FINALIZER);
 
   vtable_set_gcvt(vt, gcvt);
 

Modified: harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_for_class.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_for_class.h?view=diff&rev=500803&r1=500802&r2=500803
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_for_class.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_for_class.h Sun Jan 28 06:41:08 2007
@@ -154,7 +154,7 @@
 {  assert(vt && vt->gcvt); return vt->gcvt; }
 
 inline GC_VTable_Info *vtable_get_gcvt(Partial_Reveal_VTable *vt) 
-{  assert(vt && vt->gcvt); return (GC_VTable_Info*)((unsigned int)vt->gcvt & GC_CLASS_FLAGS_MASK); }
+{  assert(vt && vt->gcvt); return (GC_VTable_Info*)((POINTER_SIZE_INT)vt->gcvt & GC_CLASS_FLAGS_MASK); }
 
 inline void vtable_set_gcvt(Partial_Reveal_VTable *vt, GC_VTable_Info *new_gcvt) 
 {  assert(vt && new_gcvt); vt->gcvt = new_gcvt; }
@@ -174,14 +174,14 @@
 inline Boolean object_has_ref_field(Partial_Reveal_Object *obj) 
 {
   GC_VTable_Info *gcvt = obj_get_gcvt_raw(obj);
-  return (unsigned int)gcvt & GC_CLASS_FLAG_REFS;   
+  return (POINTER_SIZE_INT)gcvt & GC_CLASS_FLAG_REFS;   
 }
 
 inline Boolean object_has_ref_field_before_scan(Partial_Reveal_Object *obj) 
 {
   Partial_Reveal_VTable *vt = obj_get_vt_raw(obj);  
   GC_VTable_Info *gcvt = vtable_get_gcvt_raw(vt);
-  return (unsigned int)gcvt & GC_CLASS_FLAG_REFS;   
+  return (POINTER_SIZE_INT)gcvt & GC_CLASS_FLAG_REFS;   
 }
 
 inline unsigned int object_ref_field_num(Partial_Reveal_Object *obj) 
@@ -193,7 +193,7 @@
 inline Boolean object_is_array(Partial_Reveal_Object *obj) 
 {
   GC_VTable_Info *gcvt = obj_get_gcvt_raw(obj);
-  return ((unsigned int)gcvt & GC_CLASS_FLAG_ARRAY);
+  return ((POINTER_SIZE_INT)gcvt & GC_CLASS_FLAG_ARRAY);
 } 
 
 inline Boolean obj_is_primitive_array(Partial_Reveal_Object *obj) 
@@ -244,7 +244,7 @@
 inline Boolean type_has_finalizer(Partial_Reveal_VTable *vt)
 {
   GC_VTable_Info *gcvt = vtable_get_gcvt_raw(vt);
-  return (unsigned int)gcvt & GC_CLASS_FLAG_FINALIZER;
+  return (POINTER_SIZE_INT)gcvt & GC_CLASS_FLAG_FINALIZER;
 }
 
 #endif //#ifndef _GC_TYPES_H_

Modified: harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_for_vm.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_for_vm.cpp?view=diff&rev=500803&r1=500802&r2=500803
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_for_vm.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_for_vm.cpp Sun Jan 28 06:41:08 2007
@@ -82,7 +82,10 @@
 {   
   Partial_Reveal_Object** p_ref = (Partial_Reveal_Object**)ref;
   Partial_Reveal_Object* p_obj = *p_ref;
-  if (p_obj == NULL) return;
+  /* we don't enumerate NULL reference and nos_boundary
+     FIXME:: nos_boundary is a static field in GCHelper.java for fast write barrier, not a real object reference 
+     this should be fixed that magic Address field should not be enumerated. */
+  if (p_obj == NULL || p_obj == nos_boundary ) return;
   assert( !obj_is_marked_in_vt(p_obj));
   /* for Minor_collection, it's possible for p_obj be forwarded in non-gen mark-forward GC. 
      The forward bit is actually last cycle's mark bit.
@@ -153,7 +156,6 @@
 int32 gc_get_hashcode(Managed_Object_Handle p_object) 
 {  return 23; }
 
-
 void gc_finalize_on_exit()
 {
   if(!IGNORE_FINREF )
@@ -169,3 +171,14 @@
  *   }
  * }
  */
+
+extern Boolean JVMTI_HEAP_ITERATION;
+void gc_iterate_heap() {
+    // data structures in not consistent for heap iteration
+    if (!JVMTI_HEAP_ITERATION) return;
+
+    gc_gen_iterate_heap((GC_Gen *)p_global_gc);
+}
+
+
+

Modified: harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_metadata.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_metadata.cpp?view=diff&rev=500803&r1=500802&r2=500803
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_metadata.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_metadata.cpp Sun Jan 28 06:41:08 2007
@@ -40,13 +40,13 @@
   void* metadata = STD_MALLOC(seg_size);
   memset(metadata, 0, seg_size);
   gc_metadata.segments[0] = metadata;
-  metadata = (void*)round_up_to_size((unsigned int)metadata, METADATA_BLOCK_SIZE_BYTES);
+  metadata = (void*)round_up_to_size((POINTER_SIZE_INT)metadata, METADATA_BLOCK_SIZE_BYTES);
   gc_metadata.num_alloc_segs = 1;
 
   unsigned int i=0;       
   unsigned int num_blocks =  GC_METADATA_SIZE_BYTES/METADATA_BLOCK_SIZE_BYTES;
   for(i=0; i<num_blocks; i++){
-    Vector_Block* block = (Vector_Block*)((unsigned int)metadata + i*METADATA_BLOCK_SIZE_BYTES);
+    Vector_Block* block = (Vector_Block*)((POINTER_SIZE_INT)metadata + i*METADATA_BLOCK_SIZE_BYTES);
     vector_block_init(block, METADATA_BLOCK_SIZE_BYTES);
   }
   
@@ -54,7 +54,7 @@
   unsigned num_tasks = num_blocks >> 1;
   gc_metadata.free_task_pool = sync_pool_create();
   for(i=0; i<num_tasks; i++){
-    unsigned int block = (unsigned int)metadata + i*METADATA_BLOCK_SIZE_BYTES;    
+    Vector_Block *block = (Vector_Block*)((POINTER_SIZE_INT)metadata + i*METADATA_BLOCK_SIZE_BYTES);
     vector_stack_init((Vector_Block*)block);
     pool_put_entry(gc_metadata.free_task_pool, (void*)block); 
   }
@@ -64,7 +64,7 @@
   gc_metadata.free_set_pool = sync_pool_create();
   /* initialize free rootset pool so that mutators can use them */  
   for(; i<num_blocks; i++){
-    unsigned int block = (unsigned int)metadata + i*METADATA_BLOCK_SIZE_BYTES;    
+    POINTER_SIZE_INT block = (POINTER_SIZE_INT)metadata + i*METADATA_BLOCK_SIZE_BYTES;    
     pool_put_entry(gc_metadata.free_set_pool, (void*)block); 
   }
 
@@ -106,7 +106,7 @@
     unlock(metadata->alloc_lock);
     return block;
   }
- 
+  
   unsigned int num_alloced = metadata->num_alloc_segs;
   if(num_alloced == GC_METADATA_SEGMENT_NUM){
     printf("Run out GC metadata, please give it more segments!\n");
@@ -116,36 +116,35 @@
   void *new_segment = STD_MALLOC(seg_size);
   memset(new_segment, 0, seg_size);
   metadata->segments[num_alloced] = new_segment;
-  new_segment = (void*)round_up_to_size((unsigned int)new_segment, METADATA_BLOCK_SIZE_BYTES);
+  new_segment = (void*)round_up_to_size((POINTER_SIZE_INT)new_segment, METADATA_BLOCK_SIZE_BYTES);
   metadata->num_alloc_segs = num_alloced + 1;
   
   unsigned int num_blocks =  GC_METADATA_EXTEND_SIZE_BYTES/METADATA_BLOCK_SIZE_BYTES;
 
   unsigned int i=0;
   for(i=0; i<num_blocks; i++){
-    Vector_Block* block = (Vector_Block*)((unsigned int)new_segment + i*METADATA_BLOCK_SIZE_BYTES);
+    Vector_Block* block = (Vector_Block*)((POINTER_SIZE_INT)new_segment + i*METADATA_BLOCK_SIZE_BYTES);
     vector_block_init(block, METADATA_BLOCK_SIZE_BYTES);
-    assert(vector_block_is_empty((Vector_Block *)block));
+    assert(vector_block_is_empty(block));
   }
 
   if( pool == gc_metadata.free_task_pool){  
     for(i=0; i<num_blocks; i++){
-      unsigned int block = (unsigned int)new_segment + i*METADATA_BLOCK_SIZE_BYTES;    
-      vector_stack_init((Vector_Block*)block);
-      pool_put_entry(gc_metadata.free_task_pool, (void*)block); 
+      Vector_Block *block = (Vector_Block *)((POINTER_SIZE_INT)new_segment + i*METADATA_BLOCK_SIZE_BYTES);
+      vector_stack_init(block);
+      pool_put_entry(gc_metadata.free_task_pool, (void*)block);
     }
   
   }else{ 
     assert( pool == gc_metadata.free_set_pool );
     for(i=0; i<num_blocks; i++){
-      unsigned int block = (unsigned int)new_segment + i*METADATA_BLOCK_SIZE_BYTES;    
+      POINTER_SIZE_INT block = (POINTER_SIZE_INT)new_segment + i*METADATA_BLOCK_SIZE_BYTES;    
       pool_put_entry(gc_metadata.free_set_pool, (void*)block); 
     }
   }
   
   block = pool_get_entry(pool);
   unlock(metadata->alloc_lock);
- 
   return block;
 }
 
@@ -160,7 +159,7 @@
   Vector_Block* root_set = pool_iterator_next(pool);
 
   while(root_set){
-    unsigned int* iter = vector_block_iterator_init(root_set);
+    POINTER_SIZE_INT* iter = vector_block_iterator_init(root_set);
     while(!vector_block_iterator_end(root_set,iter)){
       Partial_Reveal_Object** p_ref = (Partial_Reveal_Object** )*iter;
       iter = vector_block_iterator_advance(root_set,iter);
@@ -175,7 +174,7 @@
           /* Condition obj_is_moved(p_obj) is for preventing mistaking previous mark bit of large obj as fw bit when fallback happens.
            * Because until fallback happens, perhaps the large obj hasn't been marked. So its mark bit remains as the last time.
            * In major collection condition obj_is_fw_in_oi(p_obj) can be omitted,
-           * for whose which can be scanned in MOS & NOS must have been set fw bit in oi.
+           * since those which can be scanned in MOS & NOS must have been set fw bit in oi.
            */
           assert(address_belongs_to_gc_heap(obj_get_fw_in_oi(p_obj), gc));
           *p_ref = obj_get_fw_in_oi(p_obj);
@@ -197,7 +196,7 @@
   if( gc->collect_kind != MINOR_COLLECTION ) /* MINOR but not forwarding */
     gc_update_repointed_sets(gc, metadata->gc_rootset_pool);
   else
-  gc_set_pool_clear(metadata->gc_rootset_pool);
+    gc_set_pool_clear(metadata->gc_rootset_pool);
   
 #ifndef BUILD_IN_REFERENT
   gc_update_finref_repointed_refs(gc);
@@ -337,7 +336,6 @@
 
   if(verify_live_heap ){
     unsigned int free_pool_size = pool_size(metadata->free_set_pool);
-    printf("===========%s, free_pool_size = %d =============\n", is_before_gc?"before GC":"after GC", free_pool_size);
   }
   
   return;  

Modified: harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_metadata.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_metadata.h?view=diff&rev=500803&r1=500802&r2=500803
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_metadata.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_metadata.h Sun Jan 28 06:41:08 2007
@@ -30,7 +30,7 @@
 
 typedef struct GC_Metadata{
   void *segments[GC_METADATA_SEGMENT_NUM]; /* address array of malloced segments for free pool */
-  unsigned int num_alloc_segs; /* next available position in pool_segments array */
+  unsigned int num_alloc_segs; /* allocated segment number */
   SpinLock  alloc_lock;
     
   Pool* free_task_pool; /* list of free buffers for mark tasks */
@@ -107,7 +107,7 @@
   assert( p_ref >= gc_heap_base_address() && p_ref < gc_heap_ceiling_address()); 
 
   Vector_Block* root_set = mutator->rem_set;  
-  vector_block_add_entry(root_set, (unsigned int)p_ref);
+  vector_block_add_entry(root_set, (POINTER_SIZE_INT)p_ref);
   
   if( !vector_block_is_full(root_set)) return;
     
@@ -121,7 +121,7 @@
 //  assert( p_ref >= gc_heap_base_address() && p_ref < gc_heap_ceiling_address()); 
 
   Vector_Block* root_set = collector->rep_set;  
-  vector_block_add_entry(root_set, (unsigned int)p_ref);
+  vector_block_add_entry(root_set, (POINTER_SIZE_INT)p_ref);
   
   if( !vector_block_is_full(root_set)) return;
     
@@ -135,7 +135,7 @@
   //assert( p_ref >= gc_heap_base_address() && p_ref < gc_heap_ceiling_address()); 
 
   Vector_Block* root_set = collector->rem_set;  
-  vector_block_add_entry(root_set, (unsigned int)p_ref);
+  vector_block_add_entry(root_set, (POINTER_SIZE_INT)p_ref);
   
   if( !vector_block_is_full(root_set)) return;
     
@@ -149,7 +149,7 @@
   /* we don't have assert as others because p_task is a p_obj for marking,
      or a p_ref for trace forwarding. The latter can be a root set pointer */
   Vector_Block* trace_task = (Vector_Block*)collector->trace_stack;  
-  vector_stack_push(trace_task, (unsigned int)p_task);
+  vector_stack_push(trace_task, (POINTER_SIZE_INT)p_task);
   
   if( !vector_stack_is_full(trace_task)) return;
     
@@ -163,7 +163,7 @@
   assert( p_ref < gc_heap_base_address() || p_ref >= gc_heap_ceiling_address()); 
   
   Vector_Block* root_set = gc->root_set;  
-  vector_block_add_entry(root_set, (unsigned int)p_ref);
+  vector_block_add_entry(root_set, (POINTER_SIZE_INT)p_ref);
   
   if( !vector_block_is_full(root_set)) return;
     

Modified: harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_platform.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_platform.h?view=diff&rev=500803&r1=500802&r2=500803
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_platform.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_platform.h Sun Jan 28 06:41:08 2007
@@ -21,19 +21,24 @@
 #ifndef _GC_PLATFORM_H_
 #define _GC_PLATFORM_H_
 
+#include "port_vmem.h"
+
 #include <assert.h>
+
+#ifdef __linux__
 #include <ctype.h>
+#endif
 
 #include <apr_time.h>
 #include <apr_atomic.h>
 
 #include <open/hythread_ext.h>
 
+extern char* large_page_hint;
 
 #ifndef _DEBUG
 
 //#define RELEASE_DEBUG
-
 #ifdef RELEASE_DEBUG
 #undef assert
 #define assert(x) do{ if(!(x)) __asm{int 3}}while(0)
@@ -41,6 +46,16 @@
 
 #endif //_DEBUG
 
+#ifdef _WINDOWS_
+#define FORCE_INLINE __forceinline   
+#else 
+
+#ifdef __linux__
+#define FORCE_INLINE inline  __attribute__((always_inline))
+#endif
+
+#endif
+
 #define USEC_PER_SEC INT64_C(1000000)
 
 #define VmThreadHandle  void*
@@ -106,20 +121,31 @@
 inline void pool_destroy(apr_pool_t *p) 
 {  apr_pool_destroy(p); }
 
-#ifndef _WIN32
+#ifndef _WINDOWS_
 #include <sys/mman.h>
 #endif
 
+inline unsigned int vm_get_system_alloc_unit()
+{
+#ifdef _WINDOWS_  
+  SYSTEM_INFO si;
+  GetSystemInfo(&si);
+  return si.dwAllocationGranularity;
+#else 
+  return port_vmem_page_sizes()[0];
+#endif
+}
+
 inline void *vm_map_mem(void* start, unsigned int size) 
 {
   void* address;
-#ifdef _WIN32
+#ifdef _WINDOWS_
   address = VirtualAlloc(start, size, MEM_RESERVE|MEM_COMMIT, PAGE_READWRITE);
-#else
+#else 
   address = mmap(start, size, PROT_READ|PROT_WRITE, MAP_FIXED|MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
   if(address == MAP_FAILED) address = NULL;
     
-#endif /* ifdef _WIN32 else */
+#endif /* ifdef _WINDOWS_ else */
 
   return address;
 }
@@ -127,13 +153,13 @@
 inline Boolean vm_unmap_mem(void* start, unsigned int size) 
 {
   unsigned int result;
-#ifdef _WIN32
+#ifdef _WINDOWS_
   result = VirtualFree(start, 0, MEM_RELEASE);
 #else
   result = munmap(start, size);
-  if(result == -1) result = 0;
-    
-#endif /* ifdef _WIN32 else */
+  if(result == 0) result = TRUE;
+  else result = FALSE;  
+#endif /* ifdef _WINDOWS_ else */
 
   return result;
 }
@@ -141,13 +167,13 @@
 inline void *vm_alloc_mem(void* start, unsigned int size) 
 {
   void* address;
-#ifdef _WIN32
+#ifdef _WINDOWS_
   address = VirtualAlloc(start, size, MEM_RESERVE|MEM_COMMIT, PAGE_READWRITE);
 #else
   address = mmap(start, size, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
   if(address == MAP_FAILED) address = NULL;
     
-#endif /* ifdef _WIN32 else */
+#endif /* ifdef _WINDOWS_ else */
 
   return address;
 }
@@ -160,25 +186,36 @@
 inline void *vm_reserve_mem(void* start, unsigned int size) 
 {
   void* address;
-#ifdef _WIN32
+#ifdef _WINDOWS_
   address = VirtualAlloc(start, size, MEM_RESERVE, PAGE_READWRITE);
 #else
-  address = mmap(start, size, PROT_READ|PROT_WRITE, MAP_FIXED|MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
+  if(start == 0)
+    address = mmap(0, size, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
+  else
+    address = mmap(start, size, PROT_NONE, MAP_FIXED|MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
+  
   if(address == MAP_FAILED) address = NULL;
     
-#endif /* ifdef _WIN32 else */
+#endif /* ifdef _WINDOWS_ else */
 
   return address;
 }
 
+inline Boolean vm_release_mem(void* start, unsigned int size) 
+{
+  return vm_unmap_mem(start, size);
+}
+
 inline void *vm_commit_mem(void* start, unsigned int size) 
 {
   void* address;
-#ifdef _WIN32
+#ifdef _WINDOWS_
   address = VirtualAlloc(start, size, MEM_COMMIT, PAGE_READWRITE);
 #else
-    
-#endif /* ifdef _WIN32 else */
+  int result = mprotect(start, size, PROT_READ|PROT_WRITE);
+  if(result == 0) address = start;
+  else address = NULL;  
+#endif /* ifdef _WINDOWS_ else */
 
   return address;
 }
@@ -186,11 +223,14 @@
 inline Boolean vm_decommit_mem(void* start, unsigned int size) 
 {
   unsigned int result;
-#ifdef _WIN32
+#ifdef _WINDOWS_
   result = VirtualFree(start, size, MEM_DECOMMIT);
 #else
+  result = mprotect(start, size, PROT_NONE);
+  if(result == 0) result = TRUE;
+  else result = FALSE;  
     
-#endif /* ifdef _WIN32 else */
+#endif /* ifdef _WINDOWS_ else */
 
   return result;
 }
@@ -207,7 +247,7 @@
 }  
 
 #ifdef PLATFORM_POSIX
-#define max(x, y) ((x)>(y)?(x):(y))
+#define max(x, y) (((x)>(y))?(x):(y))
 #endif
 
 typedef volatile unsigned int SpinLock;

Modified: harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_space.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_space.h?view=diff&rev=500803&r1=500802&r2=500803
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_space.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_space.h Sun Jan 28 06:41:08 2007
@@ -23,6 +23,8 @@
 
 #include "gc_block.h"
 
+extern unsigned int SPACE_ALLOC_UNIT;
+
 struct GC;
 /* all Spaces inherit this Space structure */
 typedef struct Space{
@@ -36,6 +38,10 @@
   unsigned int collect_algorithm;
   GC* gc;
   Boolean move_object;
+  /*Size allocted after last collection. */
+  unsigned int alloced_size;
+  /*For_statistic*/  
+  unsigned int surviving_size;
 }Space;
 
 inline unsigned int space_committed_size(Space* space){ return space->committed_heap_size;}
@@ -65,6 +71,10 @@
   unsigned int collect_algorithm;
   GC* gc;
   Boolean move_object;
+  /*Size allocted after last collection. */
+  unsigned int alloced_size;
+  /*For_statistic*/  
+  unsigned int surviving_size;
   /* END of Space --> */
 
   Block* blocks; /* short-cut for mpsace blockheader access, not mandatory */
@@ -108,18 +118,18 @@
   unsigned int block_dec_count = changed_size >> GC_BLOCK_SHIFT_COUNT;
   void* new_base = (void*)&(space->blocks[space->num_managed_blocks - block_dec_count]);
  
-  void* decommit_base = (void*)round_down_to_size((unsigned int)new_base, SYSTEM_ALLOC_UNIT);
+  void* decommit_base = (void*)round_down_to_size((POINTER_SIZE_INT)new_base, SPACE_ALLOC_UNIT);
   
   assert( ((Block_Header*)decommit_base)->block_idx >= space->free_block_idx);
   
   void* old_end = (void*)&space->blocks[space->num_managed_blocks];
-  unsigned int decommit_size = (unsigned int)old_end - (unsigned int)decommit_base;
+  unsigned int decommit_size = (POINTER_SIZE_INT)old_end - (POINTER_SIZE_INT)decommit_base;
   assert(decommit_size && !(decommit_size%GC_BLOCK_SIZE_BYTES));
   
   Boolean result = vm_decommit_mem(decommit_base, decommit_size);
   assert(result == TRUE);
   
-  space->committed_heap_size = (unsigned int)decommit_base - (unsigned int)space->heap_start;
+  space->committed_heap_size = (POINTER_SIZE_INT)decommit_base - (POINTER_SIZE_INT)space->heap_start;
   space->num_managed_blocks = space->committed_heap_size >> GC_BLOCK_SHIFT_COUNT;
   
   Block_Header* new_last_block = (Block_Header*)&space->blocks[space->num_managed_blocks - 1];
@@ -132,16 +142,16 @@
   unsigned int block_inc_count = changed_size >> GC_BLOCK_SHIFT_COUNT;
   
   void* old_base = (void*)&space->blocks[space->num_managed_blocks];
-  void* commit_base = (void*)round_down_to_size((unsigned int)old_base, SYSTEM_ALLOC_UNIT);
-  unsigned int block_diff_count = ((unsigned int)old_base - (unsigned int)commit_base) >> GC_BLOCK_SHIFT_COUNT;
+  void* commit_base = (void*)round_down_to_size((POINTER_SIZE_INT)old_base, SPACE_ALLOC_UNIT);
+  unsigned int block_diff_count = ((POINTER_SIZE_INT)old_base - (POINTER_SIZE_INT)commit_base) >> GC_BLOCK_SHIFT_COUNT;
   block_inc_count += block_diff_count;
   
   unsigned int commit_size = block_inc_count << GC_BLOCK_SHIFT_COUNT;
   void* result = vm_commit_mem(commit_base, commit_size);
   assert(result == commit_base);
 
-  void* new_end = (void*)((unsigned int)commit_base + commit_size);
-  space->committed_heap_size = (unsigned int)new_end - (unsigned int)space->heap_start;
+  void* new_end = (void*)((POINTER_SIZE_INT)commit_base + commit_size);
+  space->committed_heap_size = (POINTER_SIZE_INT)new_end - (POINTER_SIZE_INT)space->heap_start;
   
   /* init the grown blocks */
   Block_Header* block = (Block_Header*)commit_base;

Modified: harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/interior_pointer.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/interior_pointer.cpp?view=diff&rev=500803&r1=500802&r2=500803
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/interior_pointer.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/interior_pointer.cpp Sun Jan 28 06:41:08 2007
@@ -25,9 +25,9 @@
 void gc_add_root_set_entry(Managed_Object_Handle *ref, Boolean is_pinned);
 
 typedef struct slot_offset_entry_struct{
-	void** slot;
-	unsigned int offset;
-	Partial_Reveal_Object *base; 
+  void** slot;
+  unsigned int offset;
+  Partial_Reveal_Object *base; 
 } slot_offset_entry;
 
 static std::vector<slot_offset_entry> interior_pointer_set;
@@ -38,49 +38,49 @@
 
 void add_root_set_entry_interior_pointer(void **slot, int offset, Boolean is_pinned)
 {
-	//check size;
-	if( interior_pointer_set.size() == interior_pointer_num_count ) 
-	{
-		unsigned int size = interior_pointer_num_count == 0 ? initial_vector_size : interior_pointer_set.size()*2;
-		interior_pointer_set.resize(size);
-	}
-
-	Partial_Reveal_Object* p_obj = (Partial_Reveal_Object*) ((Byte*)*slot - offset);
-	assert(p_obj->vt_raw);
-	slot_offset_entry* push_back_entry = (slot_offset_entry*)&interior_pointer_set[interior_pointer_num_count++];
-	push_back_entry->offset = offset;
-	push_back_entry->slot   = slot;
-	push_back_entry->base = p_obj;
+  //check size;
+  if( interior_pointer_set.size() == interior_pointer_num_count ) 
+  {
+    unsigned int size = interior_pointer_num_count == 0 ? initial_vector_size : interior_pointer_set.size()*2;
+    interior_pointer_set.resize(size);
+  }
+
+  Partial_Reveal_Object* p_obj = (Partial_Reveal_Object*) ((Byte*)*slot - offset);
+  assert(p_obj->vt_raw);
+  slot_offset_entry* push_back_entry = (slot_offset_entry*)&interior_pointer_set[interior_pointer_num_count++];
+  push_back_entry->offset = offset;
+  push_back_entry->slot   = slot;
+  push_back_entry->base = p_obj;
 }
 
 void gc_copy_interior_pointer_table_to_rootset()
 {
-	unsigned int i;
-	for( i = 0; i<interior_pointer_num_count; i++)
-	{
-		slot_offset_entry* entry_traverser = (slot_offset_entry*)&interior_pointer_set[i];
-		gc_add_root_set_entry((Managed_Object_Handle*)(&(entry_traverser->base)), FALSE);
-	}
+  unsigned int i;
+  for( i = 0; i<interior_pointer_num_count; i++)
+  {
+  slot_offset_entry* entry_traverser = (slot_offset_entry*)&interior_pointer_set[i];
+  gc_add_root_set_entry((Managed_Object_Handle*)(&(entry_traverser->base)), FALSE);
+  }
 }
 
 void update_rootset_interior_pointer()
 {
-	unsigned int i;
-	for( i = 0; i<interior_pointer_num_count; i++)
-	{
-		slot_offset_entry* entry_traverser = (slot_offset_entry*)&interior_pointer_set[i];
-		void** root_slot = entry_traverser->slot;
-		Partial_Reveal_Object* root_base = (Partial_Reveal_Object*)entry_traverser->base;
-		unsigned int root_offset = entry_traverser->offset;
-		void *new_slot_contents = (void *)((Byte*)root_base + root_offset);	
-		*root_slot = new_slot_contents;
-	}
+  unsigned int i;
+  for( i = 0; i<interior_pointer_num_count; i++)
+  {
+  slot_offset_entry* entry_traverser = (slot_offset_entry*)&interior_pointer_set[i];
+  void** root_slot = entry_traverser->slot;
+  Partial_Reveal_Object* root_base = (Partial_Reveal_Object*)entry_traverser->base;
+  unsigned int root_offset = entry_traverser->offset;
+  void *new_slot_contents = (void *)((Byte*)root_base + root_offset);
+  *root_slot = new_slot_contents;
+  }
        //can not reset the table here, for the rootset may be updated multi times
 }
 
 void gc_reset_interior_pointer_table()
 {
-	interior_pointer_num_count = 0;
-       //this function is for the case of out of space which need to call update_rootset_interior_pointer multi-times
+  interior_pointer_num_count = 0;
+  //this function is for the case of out of memory which need to call update_rootset_interior_pointer multi-times
 }
 

Added: harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/large_pages.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/large_pages.cpp?view=auto&rev=500803
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/large_pages.cpp (added)
+++ harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/large_pages.cpp Sun Jan 28 06:41:08 2007
@@ -0,0 +1,180 @@
+/*
+ *  Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+/**
+ * @author Yu-Nan He, 2007/01/18
+ */
+#include "gc_common.h"
+char* large_page_hint = NULL;
+
+#if defined (_WINDOWS_)
+Boolean set_privilege(HANDLE process, LPCTSTR priv_name, Boolean is_enable)
+{
+  HANDLE token;
+  TOKEN_PRIVILEGES tp;
+  bool res = OpenProcessToken(process, TOKEN_ADJUST_PRIVILEGES, &token);
+  if(!res){
+    return FALSE;
+  }
+  
+  tp.PrivilegeCount = 1;
+  tp.Privileges[0].Attributes = is_enable ? SE_PRIVILEGE_ENABLED : 0;
+  
+  res = LookupPrivilegeValue( NULL, priv_name, &tp.Privileges[0].Luid);
+  if(!res){
+    CloseHandle(token);
+    return FALSE;
+  }
+  
+  if (AdjustTokenPrivileges( token, FALSE, &tp, 0, NULL, 0) == ERROR_NOT_ALL_ASSIGNED) {
+    CloseHandle(token);
+    return FALSE;
+  }
+  return TRUE;
+}
+
+Boolean obtain_lock_memory_priv()
+{
+  HANDLE process = GetCurrentProcess();
+  return set_privilege(process, SE_LOCK_MEMORY_NAME, TRUE);
+}
+
+Boolean release_lock_memory_priv()
+{
+  HANDLE process = GetCurrentProcess();
+  return set_privilege(process, SE_LOCK_MEMORY_NAME, TRUE);
+}
+
+void* alloc_large_pages(size_t size, const char* hint)
+{
+  void* alloc_addr = NULL;
+  bool lock_memory_enable = obtain_lock_memory_priv();
+  
+  if(lock_memory_enable){
+    alloc_addr = VirtualAlloc(NULL, size, MEM_RESERVE | MEM_COMMIT | MEM_LARGE_PAGES, PAGE_READWRITE);    
+    release_lock_memory_priv();    
+    if(alloc_addr == NULL){
+      printf("GC large_page: No required number of large pages found. Please reboot.....\n");
+      return NULL;
+    }else
+      return alloc_addr;
+  }else{
+    printf("GC large_page: Check that you have permissions:\n");
+    printf("GC large_page: Control Panel->Administrative Tools->Local Security Settings->->User Rights Assignment->Lock pages in memory;\n");
+    printf("GC large_page: Start VM as soon after reboot as possible, because large pages become fragmented and unusable after a while;\n");
+    printf("GC large_page: Heap size should be multiple of large page size.\n");
+    return NULL;
+  }
+}
+
+#elif defined (__linux__)
+#include <fcntl.h>
+#include <unistd.h>
+
+static size_t proc_huge_page_size   = 4 * MB;
+static size_t proc_huge_pages_total = (size_t)-1;
+static size_t proc_huge_pages_free  = 0;
+static const char* str_HugePages_Total = "HugePages_Total:";
+static const char* str_HugePages_Free  = "HugePages_Free:";
+static const char* str_Hugepagesize    = "Hugepagesize:";
+
+
+static const char* parse_value(const char* buf, int len, const char* name, int name_len, size_t* value){
+  if (len < name_len) return NULL;
+  if (strncmp(buf, name, name_len)) return NULL;
+  buf += name_len;
+  char* endpos;
+  long int res = strtol(buf, &endpos, 10);
+  if (endpos == buf) return NULL;
+  *value = (size_t) res;
+  return endpos;
+}
+
+static void parse_proc_meminfo(size_t required_size){
+  FILE* f = fopen("/proc/meminfo", "r");
+  if (f == NULL){
+    printf("GC large_page: Can't open /proc/meminfo \n");
+    return;
+  }
+
+  size_t size = 128;
+  char* buf = (char*) malloc(size);
+  while (true){
+    ssize_t len = getline(&buf, &size, f);
+    if (len == -1) break;
+    parse_value(buf, len, str_HugePages_Total, strlen(str_HugePages_Total), &proc_huge_pages_total);
+    parse_value(buf, len, str_HugePages_Free, strlen(str_HugePages_Free), &proc_huge_pages_free);
+    const char* end =parse_value(buf, len, str_Hugepagesize, strlen(str_Hugepagesize), &proc_huge_page_size);
+    if (end && !strncmp(end, " kB", 3)) proc_huge_page_size *= KB;
+  }
+  if (buf) free(buf);
+  
+  if (proc_huge_pages_total == (size_t)-1){
+    printf("GC large_page: Large pages are not supported by kernel.\n");
+    printf("GC large_page: CONFIG_HUGETLB_PAGE and CONFIG_HUGETLBFS needs to be enabled.\n");
+  } else if (proc_huge_pages_total == 0){
+    printf("GC large_page: No large pages reserved,  Use following command: echo num> /proc/sys/vm/nr_hugepages.\n");
+    printf("GC large_page: Do it just after kernel boot before huge pages become fragmented.\n");
+  } else if (proc_huge_pages_free * proc_huge_page_size < required_size) {
+    if (proc_huge_pages_total * proc_huge_page_size >= required_size) {
+      printf("GC large_page: Not enough free large pages, some of reserved space is already busy.\n");
+    } else {
+      printf("GC large_page: Not enough reserved large pages.\n");
+    }
+  }
+}
+
+void* mmap_large_pages(size_t size, const char* path)
+{
+  const char* postfix = "/vm_heap";
+  char* buf = (char*) malloc(strlen(path) + strlen(postfix) + 1);
+  assert(buf);
+
+  strcpy(buf, path);
+  strcat(buf, postfix);
+
+  int fd = open(buf, O_CREAT | O_RDWR, 0700);
+  if (fd == -1){
+    printf("GC large_page: Can't open Mount hugetlbfs with: mount none /mnt/huge -t hugetlbfs.\n");
+    printf("GC large_page: Check you have appropriate permissions to /mnt/huge.\n");
+    printf("GC large_page: Use command line switch -Dgc.use_large_page=/mnt/huge.\n");
+    free(buf);
+    return NULL;
+  }
+  unlink(buf);
+
+  void* addr = mmap(0, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
+  if (addr == MAP_FAILED){
+    printf("GC large_page: Map failed.\n");
+    close(fd);
+    free(buf);
+    return NULL;
+  }
+  close(fd);
+  free(buf);
+  return addr;
+}
+
+void* alloc_large_pages(size_t size, const char* hint){
+  parse_proc_meminfo(size);
+  void* alloc_addr = mmap_large_pages(size, hint);
+  if(alloc_addr == NULL || ((POINTER_SIZE_INT)alloc_addr%proc_huge_page_size!=0)){
+    printf("GC large_page: Large pages allocation failed.\n");
+    return NULL;
+  }
+  return alloc_addr;
+}
+#endif

Modified: harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/mark_scan_pool.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/mark_scan_pool.cpp?view=diff&rev=500803&r1=500802&r2=500803
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/mark_scan_pool.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/mark_scan_pool.cpp Sun Jan 28 06:41:08 2007
@@ -23,7 +23,7 @@
 #include "../gen/gen.h"
 #include "../finalizer_weakref/finalizer_weakref.h"
 
-static void scan_slot(Collector* collector, Partial_Reveal_Object** p_ref)
+static FORCE_INLINE void scan_slot(Collector* collector, Partial_Reveal_Object** p_ref)
 {
   Partial_Reveal_Object* p_obj = *p_ref;
   if(p_obj==NULL) return;
@@ -35,7 +35,7 @@
 }
 
 
-static void scan_object(Collector* collector, Partial_Reveal_Object *p_obj)
+static FORCE_INLINE void scan_object(Collector* collector, Partial_Reveal_Object *p_obj)
 {
   if( !object_has_ref_field(p_obj) ) return;
   
@@ -46,7 +46,7 @@
     Partial_Reveal_Array* array = (Partial_Reveal_Array*)p_obj;
     unsigned int array_length = array->array_len;
   
-    p_ref = (Partial_Reveal_Object**)((int)array + (int)array_first_element_offset(array));
+    p_ref = (Partial_Reveal_Object**)((POINTER_SIZE_INT)array + (int)array_first_element_offset(array));
 
     for (unsigned int i = 0; i < array_length; i++) {
       scan_slot(collector, p_ref+i);
@@ -120,7 +120,7 @@
   /* first step: copy all root objects to mark tasks. 
       FIXME:: can be done sequentially before coming here to eliminate atomic ops */ 
   while(root_set){
-    unsigned int* iter = vector_block_iterator_init(root_set);
+    POINTER_SIZE_INT* iter = vector_block_iterator_init(root_set);
     while(!vector_block_iterator_end(root_set,iter)){
       Partial_Reveal_Object** p_ref = (Partial_Reveal_Object** )*iter;
       iter = vector_block_iterator_advance(root_set,iter);
@@ -152,7 +152,7 @@
   Vector_Block* mark_task = pool_get_entry(metadata->mark_task_pool);
   
   while(mark_task){
-    unsigned int* iter = vector_block_iterator_init(mark_task);
+    POINTER_SIZE_INT* iter = vector_block_iterator_init(mark_task);
     while(!vector_block_iterator_end(mark_task,iter)){
       Partial_Reveal_Object* p_obj = (Partial_Reveal_Object *)*iter;
       iter = vector_block_iterator_advance(mark_task,iter);
@@ -188,37 +188,7 @@
   return;
 }
 
-/* this is to resurrect p_obj and its decedants for some reason, here for finalizables */
-void resurrect_obj_tree_after_mark(Collector *collector, Partial_Reveal_Object *p_obj)
+void trace_obj_in_marking(Collector *collector, void *p_obj)
 {
-  GC *gc = collector->gc;
-  GC_Metadata* metadata = gc->metadata;
-  
-  obj_mark_in_vt(p_obj);
-  collector->trace_stack = free_task_pool_get_entry(metadata);
-  collector_tracestack_push(collector, p_obj);
-  pool_put_entry(metadata->mark_task_pool, collector->trace_stack);
-  
-//collector->rep_set = free_set_pool_get_entry(metadata); /* has got collector->rep_set in caller */
-  collector->trace_stack = free_task_pool_get_entry(metadata);
-  Vector_Block* mark_task = pool_get_entry(metadata->mark_task_pool);
-  while(mark_task){
-    unsigned int* iter = vector_block_iterator_init(mark_task);
-    while(!vector_block_iterator_end(mark_task,iter)){
-      Partial_Reveal_Object* p_obj = (Partial_Reveal_Object *)*iter;
-      trace_object(collector, p_obj);
-      iter = vector_block_iterator_advance(mark_task, iter);
-    } 
-    /* run out one task, put back to the pool and grab another task */
-    vector_stack_clear(mark_task);
-    pool_put_entry(metadata->free_task_pool, mark_task);
-    mark_task = pool_get_entry(metadata->mark_task_pool);      
-  }
-  
-  mark_task = (Vector_Block*)collector->trace_stack;
-  vector_stack_clear(mark_task);
-  pool_put_entry(metadata->free_task_pool, mark_task);   
-  collector->trace_stack = NULL;
-//pool_put_entry(metadata->collector_repset_pool, collector->rep_set); /* has got collector->rep_set in caller */
-//collector->rep_set = NULL; /* has got collector->rep_set in caller */
+  trace_object(collector, (Partial_Reveal_Object *)p_obj);
 }

Modified: harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/space_tuner.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/space_tuner.cpp?view=diff&rev=500803&r1=500802&r2=500803
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/space_tuner.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/space_tuner.cpp Sun Jan 28 06:41:08 2007
@@ -20,42 +20,194 @@
 
 #include "space_tuner.h"
 
-#define GC_LOS_MIN_VARY_SIZE ( 2 * 1024 * 1024 ) 
-
+#include <math.h>
 
 struct GC_Gen;
+struct Mspace;
+struct Lspace;
 Space* gc_get_mos(GC_Gen* gc);
 Space* gc_get_nos(GC_Gen* gc);
+Space* gc_get_los(GC_Gen* gc);
+unsigned int mspace_get_expected_threshold(Mspace* mspace);
+unsigned int lspace_get_failure_size(Lspace* lspace);
+    
+/*Now just prepare the alloc_size field of mspace, used to compute new los size.*/
+void gc_space_tune_prepare(GC* gc, unsigned int cause)
+{
+  if(gc->collect_kind == MINOR_COLLECTION)
+    return;
+  
+  Blocked_Space* mspace = (Blocked_Space*)gc_get_mos((GC_Gen*)gc);
+  Blocked_Space* fspace = (Blocked_Space*)gc_get_nos((GC_Gen*)gc);  
+  Space* lspace = (Space*)gc_get_los((GC_Gen*)gc);  
+  Space_Tuner* tuner = gc->tuner;
+
+  assert(fspace->free_block_idx > fspace->first_block_idx);
+  unsigned int nos_alloc_size = (fspace->free_block_idx - fspace->first_block_idx) * GC_BLOCK_SIZE_BYTES;
+  fspace->alloced_size = nos_alloc_size;
+  mspace->alloced_size += (unsigned int)((float)nos_alloc_size * fspace->survive_ratio);
+
+  /*For_statistic alloc speed: Speed could be represented by sum of alloced size.*/
+  tuner->speed_los += lspace->alloced_size;
+  tuner->speed_mos += mspace->alloced_size;
+
+  /*For_statistic wasted memory*/
+  unsigned int curr_used_los = lspace->surviving_size + lspace->alloced_size;
+  assert(curr_used_los < lspace->committed_heap_size);
+  unsigned int curr_wast_los = lspace->committed_heap_size - curr_used_los;
+  tuner->wast_los += curr_wast_los;
+  unsigned int curr_used_mos = mspace->surviving_size + mspace->alloced_size;
+  unsigned int curr_wast_mos = mspace_get_expected_threshold((Mspace*)mspace) - curr_used_mos;
+  tuner->wast_mos += curr_wast_mos;
+  tuner->current_dw = abs((int)tuner->wast_mos - (int)tuner->wast_los);
+
+  /*For_statistic ds in heuristic*/
+  tuner->current_ds = (unsigned int)((float)fspace->committed_heap_size * fspace->survive_ratio);
+
+  /*Fixme: Threshold should be computed by heuristic. tslow, total recycled heap size shold be statistic.*/
+  tuner->threshold = tuner->current_ds;
+  //For debug
+  if(tuner->threshold > 8 * MB) tuner->threshold = 8 * MB;
+
+  tuner->min_tuning_size = tuner->current_ds;
+  //For debug
+  if(tuner->min_tuning_size > 4 * MB) tuner->min_tuning_size = 4 * MB;  
+}
 
-void gc_space_tune(GC* gc, unsigned int cause)
+void gc_space_tune_before_gc(GC* gc, unsigned int cause)
+{
+  if(gc->collect_kind == MINOR_COLLECTION) return;
+
+  Space_Tuner* tuner = gc->tuner;
+
+  /*Only tune when LOS need extend*/  
+  if( tuner->wast_los > tuner->wast_mos ) return;
+
+  /*Needn't tune if dw does not reach threshold.*/  
+  if(tuner->current_dw < tuner->threshold)  return;
+
+  Blocked_Space* mspace = (Blocked_Space*)gc_get_mos((GC_Gen*)gc);
+  Blocked_Space* fspace = (Blocked_Space*)gc_get_nos((GC_Gen*)gc);
+  Space* lspace = (Space*)gc_get_los((GC_Gen*)gc);
+
+  unsigned int los_expect_survive_sz = (unsigned int)((float)(lspace->surviving_size + lspace->alloced_size) * lspace->survive_ratio);
+  unsigned int los_expect_free_sz = lspace->committed_heap_size - los_expect_survive_sz;
+  
+  unsigned int mos_expect_survive_sz = (unsigned int)((float)(mspace->surviving_size + mspace->alloced_size) * mspace->survive_ratio);
+  unsigned int mos_expect_free_sz = mspace_get_expected_threshold((Mspace*)mspace) - mos_expect_survive_sz;
+  
+  unsigned int total_free = los_expect_free_sz + mos_expect_free_sz;
+
+  float new_los_ratio = (float)tuner->speed_los / (float)(tuner->speed_los  + tuner->speed_mos);
+  unsigned int new_free_los_sz = (unsigned int)((float)total_free * new_los_ratio);
+  
+  if((int)new_free_los_sz - (int)los_expect_free_sz > (int)tuner->min_tuning_size){
+    tuner->kind = TRANS_FROM_MOS_TO_LOS;
+    tuner->tuning_size = round_up_to_size(new_free_los_sz - los_expect_free_sz, SPACE_ALLOC_UNIT);
+    tuner->least_tuning_size = round_up_to_size(lspace_get_failure_size((Lspace*)lspace), SPACE_ALLOC_UNIT);
+    tuner->conservative_tuning_size = round_up_to_size(((tuner->tuning_size + tuner->least_tuning_size) >> 1), SPACE_ALLOC_UNIT);
+    
+     unsigned int none_los_size;
+ #ifdef STATIC_NOS_MAPPING
+     none_los_size = mspace->committed_heap_size;
+ #else
+     /*Fixme: There should be a minimal remain size like heap_size >> 3.*/
+     none_los_size = mspace->committed_heap_size + fspace->committed_heap_size;
+ #endif
+
+     if(tuner->tuning_size < none_los_size) return;
+
+     tuner->tuning_size = tuner->conservative_tuning_size;
+
+     if(tuner->tuning_size < none_los_size) return;
+        
+     tuner->tuning_size = tuner->least_tuning_size;
+
+     if(tuner->tuning_size == 0) tuner->kind = TRANS_NOTHING;
+     
+     if(tuner->tuning_size < none_los_size) return;
+     
+     printf("Out of Memory!\n");
+     assert(0);
+     exit(0);    
+
+  }
+}
+
+void gc_space_tune_before_gc_simplified(GC* gc, unsigned int cause)
 {
   if((gc->collect_kind == MINOR_COLLECTION) || (cause != GC_CAUSE_LOS_IS_FULL) )
-  	return;
-  	
+    return;
+
   Space_Tuner* tuner = gc->tuner;
   tuner->kind = TRANS_FROM_MOS_TO_LOS;
 
   Blocked_Space* mspace = (Blocked_Space*)gc_get_mos((GC_Gen*)gc);
   Blocked_Space* fspace = (Blocked_Space*)gc_get_nos((GC_Gen*)gc);
+  Space* lspace = (Space*)gc_get_los((GC_Gen*)gc);
 
-  unsigned int mos_free_block_nr = (mspace->ceiling_block_idx - mspace->free_block_idx + 1);
-  unsigned int nos_used_block_nr = fspace->free_block_idx - fspace->first_block_idx;
-  unsigned int mos_wast_block_nr = mos_free_block_nr - nos_used_block_nr; 
-  unsigned int min_vary_block_nr =  (GC_LOS_MIN_VARY_SIZE >> GC_BLOCK_SHIFT_COUNT);
-  if( mos_wast_block_nr > min_vary_block_nr ){
-    tuner->tuning_size = min_vary_block_nr << GC_BLOCK_SHIFT_COUNT;
-  }else{
-    tuner->tuning_size = mos_wast_block_nr << GC_BLOCK_SHIFT_COUNT;
+  /*Fixme: this branch should be modified after the policy of gen major is decieded!*/
+  if(false){
+    unsigned int mos_free_sz = ((mspace->ceiling_block_idx - mspace->free_block_idx + 1) << GC_BLOCK_SHIFT_COUNT);
+    unsigned int nos_survive_sz = 
+                      (unsigned int)((float)((fspace->free_block_idx - fspace->first_block_idx) << GC_BLOCK_SHIFT_COUNT) * fspace->survive_ratio);
+    int mos_wast_sz = mos_free_sz - nos_survive_sz; 
+  
+    if( mos_wast_sz > GC_LOS_MIN_VARY_SIZE){
+      tuner->tuning_size = GC_LOS_MIN_VARY_SIZE;
+    }else if(mos_wast_sz > 0){
+      tuner->tuning_size = mos_wast_sz;
+    }else 
+      tuner->tuning_size = 0;
+    
   }
+  /*For non gen virable sized NOS*/
+  else
+  {
+    unsigned int los_fail_sz = lspace_get_failure_size((Lspace*)lspace);
+    
+    if(los_fail_sz > GC_LOS_MIN_VARY_SIZE){
+      /*Fixme: we should set the least_tuning_size after finding out the biggest free area in LOS, this number could be zero*/
+      tuner->tuning_size = los_fail_sz;
+      tuner->least_tuning_size = los_fail_sz;
+      tuner->conservative_tuning_size = los_fail_sz;
+    }else{
+      tuner->tuning_size = GC_LOS_MIN_VARY_SIZE;
+      tuner->least_tuning_size = los_fail_sz;         
+      tuner->conservative_tuning_size = ((tuner->tuning_size + tuner->min_tuning_size) >> 1);
+    }
+    
+    unsigned int none_los_size;
+#ifdef STATIC_NOS_MAPPING
+    none_los_size = mspace->committed_heap_size;
+#else
+    none_los_size = mspace->committed_heap_size + fspace->committed_heap_size;
+#endif
+
+    if(tuner->tuning_size > none_los_size){
+      tuner->tuning_size = tuner->conservative_tuning_size;
+    }
+    if(tuner->tuning_size > none_los_size){
+      tuner->tuning_size = tuner->least_tuning_size;
+    }
+    if(tuner->tuning_size > none_los_size){
+      printf("Out of Memory!\n");
+      assert(0);
+      exit(0);    
+    }
 
+  }
+  
+  /*Fixme: Should MOS heap_start must be 64k aligned?*/
+  tuner->tuning_size = round_down_to_size(tuner->tuning_size, SPACE_ALLOC_UNIT);
   if(tuner->tuning_size == 0) tuner->kind = TRANS_NOTHING;
 
-	return;  
+  return;  
 }
 
 void  gc_space_tuner_reset(GC* gc)
 {
-  if(gc->collect_kind != MINOR_COLLECTION){
+  if((gc->collect_kind != MINOR_COLLECTION) && (gc->tuner->kind != TRANS_NOTHING)){
     Space_Tuner* tuner = gc->tuner;
     memset(tuner, 0, sizeof(Space_Tuner));
   }

Modified: harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/space_tuner.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/space_tuner.h?view=diff&rev=500803&r1=500802&r2=500803
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/space_tuner.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/space_tuner.h Sun Jan 28 06:41:08 2007
@@ -24,6 +24,9 @@
 #include "gc_common.h"
 #include "gc_space.h"
 
+#define GC_LOS_MIN_VARY_SIZE ( 2 * MB ) 
+#define GC_FIXED_SIZE_TUNER
+
 //For_LOS_extend
 enum Transform_Kind {
   TRANS_NOTHING = 0,
@@ -32,13 +35,41 @@
 };
 
 typedef struct Space_Tuner{
-    /*fixme: Now we use static value of GC_LOS_MIN_VARY_SIZE. */
-    unsigned int tuning_threshold;
     Transform_Kind kind;
+
     unsigned int tuning_size;
+    unsigned int conservative_tuning_size;
+    unsigned int least_tuning_size;
+    unsigned int force_tune;
+    
+    /*LOS alloc speed sciecne last los variation*/    
+    unsigned int speed_los;
+    /*MOS alloc speed sciecne last los variation*/    
+    unsigned int speed_mos;
+
+    /*Total wasted memory of los science last los variation*/
+    unsigned int wast_los;
+    /*Total wasted memory of mos science last los variation*/
+    unsigned int wast_mos;
+
+    unsigned int current_dw;
+    /*NOS survive size of last minor, this could be the least meaningful space unit when talking about tuning.*/
+    unsigned int current_ds;
+
+    /*Threshold for deta wast*/
+    unsigned int threshold;
+    /*Minimun tuning size for los variation*/
+    unsigned int min_tuning_size;
+
+    /*Cost of normal major compaction*/
+    unsigned int fast_cost;
+    /*Cost of major compaction when changing LOS size*/    
+    unsigned int slow_cost;    
 }Space_Tuner;
 
-void gc_space_tune(GC* gc, unsigned int cause);
+void gc_space_tune_prepare(GC* gc, unsigned int cause);
+void gc_space_tune_before_gc(GC* gc, unsigned int cause);
+void gc_space_tune_before_gc_simplified(GC* gc, unsigned int cause);
 void gc_space_tuner_reset(GC* gc);
 void gc_space_tuner_initialize(GC* gc);
 



Mime
View raw message