You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by xl...@apache.org on 2007/07/04 05:01:03 UTC

svn commit: r553050 [1/2] - in /harmony/enhanced/drlvm/trunk: build/make/components/vm/ vm/gc_gen/src/common/ vm/gc_gen/src/finalizer_weakref/ vm/gc_gen/src/gen/ vm/gc_gen/src/los/ vm/gc_gen/src/mark_compact/ vm/gc_gen/src/mark_sweep/ vm/gc_gen/src/thr...

Author: xli
Date: Tue Jul  3 20:01:01 2007
New Revision: 553050

URL: http://svn.apache.org/viewvc?view=rev&rev=553050
Log:
HARMONY-4325 : 01_mark_sweep.patch for Tick project 

Added:
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/los/
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/los/free_area_pool.cpp   (with props)
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/los/free_area_pool.h   (with props)
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/los/lspace.cpp   (with props)
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/los/lspace.h   (with props)
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/los/lspace_alloc_collect.cpp   (with props)
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_sweep/sspace.cpp   (with props)
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_sweep/sspace.h   (with props)
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_sweep/sspace_alloc.cpp   (with props)
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_sweep/sspace_chunk.cpp   (with props)
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_sweep/sspace_chunk.h   (with props)
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_sweep/sspace_mark.cpp   (with props)
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_sweep/sspace_mark_sweep.cpp   (with props)
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_sweep/sspace_mark_sweep.h   (with props)
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_sweep/sspace_sweep.cpp   (with props)
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_sweep/sspace_verify.cpp   (with props)
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_sweep/sspace_verify.h   (with props)
Removed:
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_sweep/free_area_pool.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
Modified:
    harmony/enhanced/drlvm/trunk/build/make/components/vm/gc_gen.xml
    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_metadata.cpp
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/space_tuner.cpp
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/finalizer_weakref/finalizer_weakref.cpp
    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/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_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_collect_compact.h
    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/thread/collector.h
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/thread/mutator.h
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/verify/verifier_common.cpp
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/verify/verifier_scanner.cpp
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/verify/verify_gc_effect.cpp
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/verify/verify_gc_effect.h
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/verify/verify_live_heap.cpp
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/verify/verify_mutator_effect.cpp

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=553050&r1=553049&r2=553050
==============================================================================
--- harmony/enhanced/drlvm/trunk/build/make/components/vm/gc_gen.xml (original)
+++ harmony/enhanced/drlvm/trunk/build/make/components/vm/gc_gen.xml Tue Jul  3 20:01:01 2007
@@ -1,126 +1,127 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<!--
-    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: Marina V. Goldburt, Dmitry B. Yershov
-Version: $Revision: 1.2 $
--->
-<!--
-    This is build descriptor for the component "vm.gc_gen".
-
-    Please refer to make/components/README.txt for details about the component
-    build descriptor structure.
-  -->
-
-<project name="vm.gc_gen">
-    <target name="init" depends="common_vm">
-        <property name="build.depends" value="extra.apr,vm.vmcore,vm.hythr,vm.kernel_classes" />
-        <property name="outtype" value="shared" />
-        <property name="libname" value="gc_gen" />
-        <property name="src" location="${build.vm.home}" />
-
-        <compiler id="cpp.compiler" extends="common.cpp.compiler">
-            <includepath>
-                <pathelement location="${extra.apr.includes}" />
-            </includepath>
-
-            <includepath>
-                <dirset dir="${build.vm.home}">
-                    <include name="include" />
-                    <include name="vmcore/include" />
-                    <include name="vm/interface" />
-                    <select os="win">
-                        <include name="vmcore/src/util/win/include" />
-                    </select>
-                    <select osfamily="unix">
-                        <include name="vmcore/src/util/linux/include" />
-                    </select>
-                </dirset>
-            </includepath>
-
-            <fileset dir="${src}/gc_gen/src">
-                <select arch="ia32,em64t,ipf">
-                <include name="common/*.cpp" />            
-                <include name="gen/*.cpp" />            
-                <include name="mark_compact/*.cpp" />            
-                <include name="mark_sweep/*.cpp" />            
-                <include name="thread/*.cpp" />            
-                <include name="trace_forward/*.cpp" />            
-                <include name="utils/*.cpp" /> 
-                <include name="jni/*.cpp" /> 
-                <include name="verify/*.cpp" />             
-                <include name="finalizer_weakref/*.cpp" />
-                </select>
-            </fileset>
-
-            <defineset define="BUILDING_GC" />
-
-            <select os="win">
-                <defineset define="_USRDLL" />
-            </select>
-
-            <select os="win" cfg="release" cxx="icl">
-                <compilerarg value="/Qip" />
-            </select>
-        </compiler>
-
-        <select os="win" arch="ipf">
-            <fileset id="asm.fileset"
-                     dir="${build.vm.home}/gc_gen/src">
-                <include name="ini_ipf_low_level.asm" />
-            </fileset>
-        </select>
-
-        <linker id="linker" extends="common.linker">
-            <select os="win">
-                <syslibset libs="advapi32,odbc32,ws2_32,mswsock" />
-                <libset libs="${vm.vmcore.lib}" dir="${vm.vmcore.libdir}" />
-            </select>
-
-            <select os="win" arch="ipf">
-                <syslibset libs="AdvAPI32" />
-            </select>
-
-            <select os="win" cfg="debug">
-                <linkerarg value="/NODEFAULTLIB:libcmtd.lib" />
-                <syslibset libs="msvcrtd" />
-            </select>
-
-            <libset libs="${vm.hythr.lib}" dir="${vm.hythr.libdir}" />
-            <select os="lnx">
-                <linkerarg value="-Bsymbolic" />
-            </select>
-        </linker>
-
-        <!-- Java helpers -->
-        <property name="build.java.depends" value=""/>
-
-        <property name="java.source.dir"
-                  location="${build.vm.home}/gc_gen/javasrc"/>
-
-        <path id="java.class.path">
-            <pathelement location="${java.build.dir}"/>
-
-            <fileset dir="${external.dep.CLASSLIB.jardir}" includes="*.jar" />
-            <pathelement location="${vm.kernel_classes.jardir}/kernel.jar"/>
-            <fileset dir="${build.VMMAGIC.home}" includes="vmmagic-20070207.jar" />
-        </path>
-
-        <property name="jarname" value="gc_gen.jar"/>
-        <property name="srcjarname" value="gc_gen-src.jar"/>
-
-    </target>
-</project>
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+    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: Marina V. Goldburt, Dmitry B. Yershov
+Version: $Revision: 1.2 $
+-->
+<!--
+    This is build descriptor for the component "vm.gc_gen".
+
+    Please refer to make/components/README.txt for details about the component
+    build descriptor structure.
+  -->
+
+<project name="vm.gc_gen">
+    <target name="init" depends="common_vm">
+        <property name="build.depends" value="extra.apr,vm.vmcore,vm.hythr,vm.kernel_classes" />
+        <property name="outtype" value="shared" />
+        <property name="libname" value="gc_gen" />
+        <property name="src" location="${build.vm.home}" />
+
+        <compiler id="cpp.compiler" extends="common.cpp.compiler">
+            <includepath>
+                <pathelement location="${extra.apr.includes}" />
+            </includepath>
+
+            <includepath>
+                <dirset dir="${build.vm.home}">
+                    <include name="include" />
+                    <include name="vmcore/include" />
+                    <include name="vm/interface" />
+                    <select os="win">
+                        <include name="vmcore/src/util/win/include" />
+                    </select>
+                    <select osfamily="unix">
+                        <include name="vmcore/src/util/linux/include" />
+                    </select>
+                </dirset>
+            </includepath>
+
+            <fileset dir="${src}/gc_gen/src">
+                <select arch="ia32,em64t,ipf">
+                <include name="common/*.cpp" />
+                <include name="gen/*.cpp" />
+                <include name="mark_compact/*.cpp" />
+                <include name="mark_sweep/*.cpp" />
+                <include name="los/*.cpp" />
+                <include name="thread/*.cpp" />
+                <include name="trace_forward/*.cpp" />
+                <include name="utils/*.cpp" />
+                <include name="jni/*.cpp" />
+                <include name="verify/*.cpp" />
+                <include name="finalizer_weakref/*.cpp" />
+                </select>
+            </fileset>
+
+            <defineset define="BUILDING_GC" />
+
+            <select os="win">
+                <defineset define="_USRDLL" />
+            </select>
+
+            <select os="win" cfg="release" cxx="icl">
+                <compilerarg value="/Qip" />
+            </select>
+        </compiler>
+
+        <select os="win" arch="ipf">
+            <fileset id="asm.fileset"
+                     dir="${build.vm.home}/gc_gen/src">
+                <include name="ini_ipf_low_level.asm" />
+            </fileset>
+        </select>
+
+        <linker id="linker" extends="common.linker">
+            <select os="win">
+                <syslibset libs="advapi32,odbc32,ws2_32,mswsock" />
+                <libset libs="${vm.vmcore.lib}" dir="${vm.vmcore.libdir}" />
+            </select>
+
+            <select os="win" arch="ipf">
+                <syslibset libs="AdvAPI32" />
+            </select>
+
+            <select os="win" cfg="debug">
+                <linkerarg value="/NODEFAULTLIB:libcmtd.lib" />
+                <syslibset libs="msvcrtd" />
+            </select>
+
+            <libset libs="${vm.hythr.lib}" dir="${vm.hythr.libdir}" />
+            <select os="lnx">
+                <linkerarg value="-Bsymbolic" />
+            </select>
+        </linker>
+
+        <!-- Java helpers -->
+        <property name="build.java.depends" value=""/>
+
+        <property name="java.source.dir"
+                  location="${build.vm.home}/gc_gen/javasrc"/>
+
+        <path id="java.class.path">
+            <pathelement location="${java.build.dir}"/>
+
+            <fileset dir="${external.dep.CLASSLIB.jardir}" includes="*.jar" />
+            <pathelement location="${vm.kernel_classes.jardir}/kernel.jar"/>
+            <fileset dir="${build.VMMAGIC.home}" includes="vmmagic-20070207.jar" />
+        </path>
+
+        <property name="jarname" value="gc_gen.jar"/>
+        <property name="srcjarname" value="gc_gen-src.jar"/>
+
+    </target>
+</project>

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=553050&r1=553049&r2=553050
==============================================================================
--- 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 Tue Jul  3 20:01:01 2007
@@ -355,4 +355,3 @@
 #endif //#ifndef _BLOCK_H_
 
 
-

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=553050&r1=553049&r2=553050
==============================================================================
--- 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 Tue Jul  3 20:01:01 2007
@@ -335,4 +335,3 @@
   return;
 }
 
-

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=553050&r1=553049&r2=553050
==============================================================================
--- 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 Tue Jul  3 20:01:01 2007
@@ -109,6 +109,7 @@
   GC_CAUSE_NIL,
   GC_CAUSE_NOS_IS_FULL,
   GC_CAUSE_LOS_IS_FULL,
+  GC_CAUSE_POS_IS_FULL,
   GC_CAUSE_RUNTIME_FORCE_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=553050&r1=553049&r2=553050
==============================================================================
--- 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 Tue Jul  3 20:01:01 2007
@@ -368,4 +368,3 @@
 }
 
 
-

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=553050&r1=553049&r2=553050
==============================================================================
--- 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 Tue Jul  3 20:01:01 2007
@@ -163,7 +163,7 @@
 }
 
 #include "../thread/collector.h"
-#include "../mark_sweep/lspace.h"
+#include "../los/lspace.h"
 
 static POINTER_SIZE_INT non_los_live_obj_size;
 static  POINTER_SIZE_INT los_live_obj_size;
@@ -518,6 +518,5 @@
   STD_FREE(tuner->interim_blocks);
   return;
 }
-
 
 

Modified: harmony/enhanced/drlvm/trunk/vm/gc_gen/src/finalizer_weakref/finalizer_weakref.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/finalizer_weakref/finalizer_weakref.cpp?view=diff&rev=553050&r1=553049&r2=553050
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/gc_gen/src/finalizer_weakref/finalizer_weakref.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/gc_gen/src/finalizer_weakref/finalizer_weakref.cpp Tue Jul  3 20:01:01 2007
@@ -24,7 +24,7 @@
 #include "../thread/mutator.h"
 #include "../common/gc_metadata.h"
 #include "../trace_forward/fspace.h"
-#include "../mark_sweep/lspace.h"
+#include "../los/lspace.h"
 #include "../gen/gen.h"
 #include "../common/space_tuner.h"
 

Modified: harmony/enhanced/drlvm/trunk/vm/gc_gen/src/gen/gen.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/gen/gen.cpp?view=diff&rev=553050&r1=553049&r2=553050
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/gc_gen/src/gen/gen.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/gc_gen/src/gen/gen.cpp Tue Jul  3 20:01:01 2007
@@ -270,9 +270,11 @@
 Space* gc_get_nos(GC_Gen* gc){ return (Space*)gc->nos;}
 Space* gc_get_mos(GC_Gen* gc){ return (Space*)gc->mos;}
 Space* gc_get_los(GC_Gen* gc){ return (Space*)gc->los;}
+Space* gc_get_pos(GC_Gen* gc) { return NULL; }
 void gc_set_nos(GC_Gen* gc, Space* nos){ gc->nos = (Fspace*)nos;}
 void gc_set_mos(GC_Gen* gc, Space* mos){ gc->mos = (Mspace*)mos;}
 void gc_set_los(GC_Gen* gc, Space* los){ gc->los = (Lspace*)los;}
+void gc_set_pos(GC_Gen* gc, Space* pos) {}
 
 void* mos_alloc(unsigned size, Allocator *allocator){return mspace_alloc(size, allocator);}
 void* nos_alloc(unsigned size, Allocator *allocator){return fspace_alloc(size, allocator);}

Modified: harmony/enhanced/drlvm/trunk/vm/gc_gen/src/gen/gen.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/gen/gen.h?view=diff&rev=553050&r1=553049&r2=553050
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/gc_gen/src/gen/gen.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/gc_gen/src/gen/gen.h Tue Jul  3 20:01:01 2007
@@ -26,7 +26,7 @@
 #include "../thread/gc_thread.h"
 #include "../trace_forward/fspace.h"
 #include "../mark_compact/mspace.h"
-#include "../mark_sweep/lspace.h"
+#include "../los/lspace.h"
 #include "../finalizer_weakref/finalizer_weakref_metadata.h"
 
 enum Write_Barrier_Kind{
@@ -155,9 +155,11 @@
 Space* gc_get_nos(GC_Gen* gc);
 Space* gc_get_mos(GC_Gen* gc);
 Space* gc_get_los(GC_Gen* gc);
+Space* gc_get_pos(GC_Gen* gc);
 void gc_set_nos(GC_Gen* gc, Space* nos);
 void gc_set_mos(GC_Gen* gc, Space* mos);
 void gc_set_los(GC_Gen* gc, Space* los);
+void gc_set_pos(GC_Gen* gc, Space* pos);
 
 unsigned int gc_get_processor_num(GC_Gen* gc);
 
@@ -179,6 +181,5 @@
 extern Boolean GEN_NONGEN_SWITCH ;
 
 #endif /* ifndef _GC_GEN_H_ */
-
 
 

Added: harmony/enhanced/drlvm/trunk/vm/gc_gen/src/los/free_area_pool.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/los/free_area_pool.cpp?view=auto&rev=553050
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/gc_gen/src/los/free_area_pool.cpp (added)
+++ harmony/enhanced/drlvm/trunk/vm/gc_gen/src/los/free_area_pool.cpp Tue Jul  3 20:01:01 2007
@@ -0,0 +1,68 @@
+/*
+ *  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 Ji Qi, 2006/10/05
+ */
+
+#include "free_area_pool.h"
+
+void free_area_pool_init(Free_Area_Pool* pool)
+{
+  for(unsigned int i = 0; i < NUM_FREE_LIST; i ++){
+    Bidir_List* list = (Bidir_List*)(&pool->sized_area_list[i]);
+    list->next = list->prev = list;
+    ((Lockable_Bidir_List*)list)->lock = 0;
+    ((Lockable_Bidir_List*)list)->zero = 0;
+  }
+  
+  memset((void*)pool->list_bit_flag, 0, NUM_FLAG_WORDS << BIT_SHIFT_TO_BYTES_PER_WORD);
+  return;
+}
+
+void free_area_pool_reset(Free_Area_Pool* pool)
+{
+  free_area_pool_init(pool);
+}
+
+Free_Area* free_pool_find_size_area(Free_Area_Pool* pool, POINTER_SIZE_INT size)
+{
+  assert(size >= GC_OBJ_SIZE_THRESHOLD);
+  
+  size = ALIGN_UP_TO_KILO(size);
+  unsigned int index = pool_list_index_with_size(size);
+  /* Get first list index that is not empty */
+  index = pool_list_get_next_flag(pool, index);
+  assert(index <= NUM_FREE_LIST);
+  
+  /*No free area left*/
+  if(index == NUM_FREE_LIST) 
+  return NULL; 
+  
+  Bidir_List* list = (Bidir_List*)&pool->sized_area_list[index];
+  Free_Area* area = (Free_Area*)list->next;
+  
+  if(index != MAX_LIST_INDEX)
+  return area;
+  
+  /* Else, for last bucket MAX_LIST_INDEX, we must traverse it */
+  while(  area != (Free_Area*)list ){
+    if(area->size >= size)	return area;
+    area = (Free_Area*)(area->next);
+  }
+  
+  return NULL;
+}

Propchange: harmony/enhanced/drlvm/trunk/vm/gc_gen/src/los/free_area_pool.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/drlvm/trunk/vm/gc_gen/src/los/free_area_pool.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/los/free_area_pool.h?view=auto&rev=553050
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/gc_gen/src/los/free_area_pool.h (added)
+++ harmony/enhanced/drlvm/trunk/vm/gc_gen/src/los/free_area_pool.h Tue Jul  3 20:01:01 2007
@@ -0,0 +1,130 @@
+/*
+ *  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 Ji Qi, 2006/10/05
+ */
+
+#ifndef _BUDDY_H_
+#define _BUDDY_H_
+
+#include "../common/gc_common.h"
+#include "../utils/bit_ops.h"
+#include "../utils/bidir_list.h"
+
+#define ADDRESS_IS_KB_ALIGNED(addr) (!(((POINTER_SIZE_INT)addr) & ((1 << BIT_SHIFT_TO_KILO)-1)))
+#define ALIGN_UP_TO_KILO(addr) (((POINTER_SIZE_INT)(addr) + (KB - 1)) & (~(KB- 1)))
+#define ALIGN_DOWN_TO_KILO(addr) ((POINTER_SIZE_INT)(addr) & (~(KB- 1)))
+
+#define NUM_FREE_LIST 128
+
+typedef struct Lockable_Bidir_List{
+  /* <-- First couple of fields overloadded as Bidir_List */
+  POINTER_SIZE_INT zero;
+  Bidir_List* next;
+  Bidir_List* prev;
+  /* END of Bidir_List --> */
+  SpinLock lock;	
+}Lockable_Bidir_List;
+
+typedef struct Free_Area{
+  /* <-- First couple of fields overloadded as Bidir_List */
+  POINTER_SIZE_INT zero;
+  Bidir_List* next;
+  Bidir_List* prev;
+  /* END of Bidir_List --> */
+  POINTER_SIZE_INT size;
+}Free_Area;
+
+/* this is the only interface for new area creation. If the new area size is smaller than threshold, return NULL*/
+inline Free_Area* free_area_new(void* start, POINTER_SIZE_INT size)
+{
+  assert(ADDRESS_IS_KB_ALIGNED(start));
+  assert(ADDRESS_IS_KB_ALIGNED(size));
+
+  Free_Area* area = (Free_Area*)start;
+  area->zero = 0;
+  area->next = area->prev = (Bidir_List*)area;
+  area->size = size;
+  
+  if( size < GC_OBJ_SIZE_THRESHOLD) return NULL;
+  else return area;
+}
+
+#define NUM_FLAG_WORDS (NUM_FREE_LIST >> BIT_SHIFT_TO_BITS_PER_WORD)
+
+typedef struct Free_Area_Pool{
+  Lockable_Bidir_List sized_area_list[NUM_FREE_LIST];
+  /* each list corresponds to one bit in below vector */
+  POINTER_SIZE_INT list_bit_flag[NUM_FLAG_WORDS];
+}Free_Area_Pool;
+
+#define MAX_LIST_INDEX (NUM_FREE_LIST - 1)
+
+inline void pool_list_set_flag(Free_Area_Pool* pool, unsigned int index)
+{
+  words_set_bit(pool->list_bit_flag, NUM_FLAG_WORDS, index);
+}
+
+inline void pool_list_clear_flag(Free_Area_Pool* pool, unsigned int index)
+{
+  words_clear_bit(pool->list_bit_flag, NUM_FLAG_WORDS, index);
+}
+
+inline unsigned int pool_list_get_next_flag(Free_Area_Pool* pool, unsigned int start_idx)
+{
+  return words_get_next_set_lsb(pool->list_bit_flag, NUM_FLAG_WORDS, start_idx);
+}
+
+inline unsigned int pool_list_index_with_size(POINTER_SIZE_INT size)
+{
+  assert(size >= GC_OBJ_SIZE_THRESHOLD);
+  
+  unsigned int index;
+  index = (unsigned int) (size >> BIT_SHIFT_TO_KILO);
+  if(index > MAX_LIST_INDEX) index = MAX_LIST_INDEX;
+  return index;
+}
+
+inline Free_Area* free_pool_add_area(Free_Area_Pool* pool, Free_Area* free_area)
+{
+  assert( free_area->size >= GC_OBJ_SIZE_THRESHOLD);
+  
+  unsigned int index = pool_list_index_with_size(free_area->size);
+  bidir_list_add_item((Bidir_List*)&(pool->sized_area_list[index]), (Bidir_List*)free_area);
+  
+  /* set bit flag of the list */
+  pool_list_set_flag(pool, index);
+  return free_area;
+}
+
+inline void free_pool_remove_area(Free_Area_Pool* pool, Free_Area* free_area)
+{
+  unsigned int index = pool_list_index_with_size(free_area->size);
+  bidir_list_remove_item((Bidir_List*)free_area);
+  
+  /* set bit flag of the list */
+  Bidir_List* list = (Bidir_List*)&(pool->sized_area_list[index]);
+  if(list->next == list){
+  	pool_list_clear_flag(pool, index);		
+  }
+}
+
+void free_area_pool_init(Free_Area_Pool* p_buddy);
+void free_area_pool_reset(Free_Area_Pool* p_buddy);
+Free_Area* free_pool_find_size_area(Free_Area_Pool* pool, unsigned int size);
+
+#endif /*ifdef _BUDDY_H_*/

Propchange: harmony/enhanced/drlvm/trunk/vm/gc_gen/src/los/free_area_pool.h
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/drlvm/trunk/vm/gc_gen/src/los/lspace.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/los/lspace.cpp?view=auto&rev=553050
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/gc_gen/src/los/lspace.cpp (added)
+++ harmony/enhanced/drlvm/trunk/vm/gc_gen/src/los/lspace.cpp Tue Jul  3 20:01:01 2007
@@ -0,0 +1,122 @@
+/*
+ *  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 Ji Qi, 2006/10/05
+ */
+
+#include "lspace.h"
+
+void* los_boundary = NULL;
+Boolean* p_global_lspace_move_obj;
+
+struct GC_Gen;
+void gc_set_los(GC_Gen* gc, Space* lspace);
+
+extern POINTER_SIZE_INT min_los_size_bytes;
+extern POINTER_SIZE_INT min_none_los_size_bytes;
+void lspace_initialize(GC* gc, void* start, POINTER_SIZE_INT lspace_size)
+{
+  Lspace* lspace = (Lspace*)STD_MALLOC( sizeof(Lspace));
+  assert(lspace);
+  memset(lspace, 0, sizeof(Lspace));
+
+  /* commit mspace mem */    
+  void* reserved_base = start;
+  POINTER_SIZE_INT committed_size = lspace_size;
+  if(!large_page_hint)
+    vm_commit_mem(reserved_base, lspace_size);
+  memset(reserved_base, 0, lspace_size);
+
+  min_los_size_bytes -= LOS_HEAD_RESERVE_FOR_HEAP_NULL;
+  lspace->committed_heap_size = committed_size - LOS_HEAD_RESERVE_FOR_HEAP_NULL;
+  lspace->reserved_heap_size = gc->reserved_heap_size - min_none_los_size_bytes - LOS_HEAD_RESERVE_FOR_HEAP_NULL;
+  lspace->heap_start = (void*)((POINTER_SIZE_INT)reserved_base + LOS_HEAD_RESERVE_FOR_HEAP_NULL);
+  lspace->heap_end = (void *)((POINTER_SIZE_INT)reserved_base + committed_size);
+
+  lspace->gc = gc;
+  /*LOS_Shrink:*/
+  lspace->move_object = FALSE;
+
+  /*Treat with free area buddies*/
+  lspace->free_pool = (Free_Area_Pool*)STD_MALLOC(sizeof(Free_Area_Pool));
+  free_area_pool_init(lspace->free_pool);
+  Free_Area* initial_fa = (Free_Area*)lspace->heap_start;
+  initial_fa->size = lspace->committed_heap_size;
+  free_pool_add_area(lspace->free_pool, initial_fa);
+
+  lspace->num_collections = 0;
+  lspace->time_collections = 0;
+  lspace->survive_ratio = 0.5f;
+
+  gc_set_los((GC_Gen*)gc, (Space*)lspace);
+  p_global_lspace_move_obj = &(lspace->move_object);
+  los_boundary = lspace->heap_end;
+
+  return;
+}
+
+void lspace_destruct(Lspace* lspace)
+{
+  STD_FREE(lspace);
+  lspace = NULL;
+  return;
+}
+
+#include "../common/fix_repointed_refs.h"
+
+/* this is minor collection, lspace is not swept, so we need clean markbits */
+void lspace_fix_after_copy_nursery(Collector* collector, Lspace* lspace)
+{
+  unsigned int mark_bit_idx = 0;
+  Partial_Reveal_Object* p_obj = lspace_get_first_marked_object(lspace, &mark_bit_idx);
+  while( p_obj){
+    assert(obj_is_marked_in_vt(p_obj));
+    obj_unmark_in_vt(p_obj);
+    object_fix_ref_slots(p_obj);
+    p_obj = lspace_get_next_marked_object(lspace, &mark_bit_idx);
+  }
+}
+
+void lspace_fix_repointed_refs(Collector* collector, Lspace* lspace)
+{
+  unsigned int start_pos = 0;
+  Partial_Reveal_Object* p_obj = lspace_get_first_marked_object(lspace, &start_pos);
+  while( p_obj){
+    assert(obj_is_marked_in_vt(p_obj));
+    object_fix_ref_slots(p_obj);
+    p_obj = lspace_get_next_marked_object(lspace, &start_pos);
+  }
+}
+
+void lspace_collection(Lspace* lspace)
+{
+  /* heap is marked already, we need only sweep here. */
+  lspace->num_collections ++;
+  lspace_reset_after_collection(lspace); 
+  /*When sliding compacting lspace, we don't need to sweep it anymore.
+  What's more, the assumption that the first word of one KB must be zero when iterating 
+  lspace in that function lspace_get_next_marked_object is not true*/  
+  if(!lspace->move_object) lspace_sweep(lspace);
+  else lspace->surviving_size = (POINTER_SIZE_INT)lspace->scompact_fa_start - (POINTER_SIZE_INT)lspace->heap_start;
+  lspace->move_object = FALSE;
+  return;
+}
+
+POINTER_SIZE_INT lspace_get_failure_size(Lspace* lspace)
+{
+  return lspace->failure_size;
+}

Propchange: harmony/enhanced/drlvm/trunk/vm/gc_gen/src/los/lspace.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/drlvm/trunk/vm/gc_gen/src/los/lspace.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/los/lspace.h?view=auto&rev=553050
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/gc_gen/src/los/lspace.h (added)
+++ harmony/enhanced/drlvm/trunk/vm/gc_gen/src/los/lspace.h Tue Jul  3 20:01:01 2007
@@ -0,0 +1,129 @@
+/*
+ *  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 Ji Qi, 2006/10/05
+ */
+
+#ifndef _LSPACE_H_
+#define _LSPACE_H_
+
+#include "../common/gc_common.h"
+#include "../thread/gc_thread.h"
+#include "free_area_pool.h"
+#ifdef USE_32BITS_HASHCODE
+#include "../common/hashcode.h"
+#endif
+
+/*Fixme: This macro is for handling HEAP_NULL issues caused by JIT OPT*/
+#ifdef COMPRESS_REFERENCE
+  #define LOS_HEAD_RESERVE_FOR_HEAP_NULL ( SPACE_ALLOC_UNIT )
+#else
+  #define LOS_HEAD_RESERVE_FOR_HEAP_NULL ( 0*KB )
+#endif
+
+typedef struct Lspace{
+  /* <-- first couple of fields are overloadded as Space */
+  void* heap_start;
+  void* heap_end;
+  POINTER_SIZE_INT reserved_heap_size;
+  POINTER_SIZE_INT committed_heap_size;
+  unsigned int num_collections;
+  int64 time_collections;
+  float survive_ratio;
+  unsigned int collect_algorithm;  
+  GC* gc;
+  /*LOS_Shrink:This field stands for sliding compact to lspace */
+  Boolean move_object;
+  /*For_statistic: size allocated science last time collect los, ie. last major*/
+  volatile POINTER_SIZE_INT alloced_size;
+  /*For_statistic: size survived after lspace_sweep*/  
+  POINTER_SIZE_INT surviving_size;
+  /* END of Space --> */
+
+  Free_Area_Pool* free_pool;
+  /*Size of allocation which caused lspace alloc failure.
+   *This one is used to assign area to failed collection inside gc.
+   *Resetted in every gc_assign_free_area_to_mutators
+   */
+  POINTER_SIZE_INT failure_size;
+  void* success_ptr;
+  
+  void* scompact_fa_start;
+  void* scompact_fa_end;
+}Lspace;
+
+void lspace_initialize(GC* gc, void* reserved_base, POINTER_SIZE_INT lspace_size);
+void lspace_destruct(Lspace* lspace);
+Managed_Object_Handle lspace_alloc(POINTER_SIZE_INT size, Allocator* allocator);
+void* lspace_try_alloc(Lspace* lspace, POINTER_SIZE_INT alloc_size);
+void lspace_sliding_compact(Collector* collector, Lspace* lspace);
+void lspace_compute_object_target(Collector* collector, Lspace* lspace);
+void lspace_sweep(Lspace* lspace);
+void lspace_reset_after_collection(Lspace* lspace);
+void lspace_collection(Lspace* lspace);
+
+inline POINTER_SIZE_INT lspace_free_memory_size(Lspace* lspace){ /* FIXME:: */ return 0; }
+inline POINTER_SIZE_INT lspace_committed_size(Lspace* lspace){ return lspace->committed_heap_size; }
+
+inline Partial_Reveal_Object* lspace_get_next_marked_object( Lspace* lspace, unsigned int* iterate_index)
+{
+    POINTER_SIZE_INT next_area_start = (POINTER_SIZE_INT)lspace->heap_start + (*iterate_index) * KB;
+    BOOLEAN reach_heap_end = 0;
+    unsigned int hash_extend_size = 0;
+
+    while(!reach_heap_end){
+        //FIXME: This while shoudl be if, try it!
+        while(!*((POINTER_SIZE_INT*)next_area_start)){
+            assert(((Free_Area*)next_area_start)->size);
+            next_area_start += ((Free_Area*)next_area_start)->size;
+        }
+        if(next_area_start < (POINTER_SIZE_INT)lspace->heap_end){
+            //If there is a living object at this addr, return it, and update iterate_index
+
+#ifdef USE_32BITS_HASHCODE
+            hash_extend_size  = (hashcode_is_attached((Partial_Reveal_Object*)next_area_start))?GC_OBJECT_ALIGNMENT:0;
+#endif
+
+            if(obj_is_marked_in_vt((Partial_Reveal_Object*)next_area_start)){
+                POINTER_SIZE_INT obj_size = ALIGN_UP_TO_KILO(vm_object_size((Partial_Reveal_Object*)next_area_start) + hash_extend_size);
+                *iterate_index = (unsigned int)((next_area_start + obj_size - (POINTER_SIZE_INT)lspace->heap_start) >> BIT_SHIFT_TO_KILO);
+                return (Partial_Reveal_Object*)next_area_start;
+            //If this is a dead object, go on to find  a living one.
+            }else{
+                POINTER_SIZE_INT obj_size = ALIGN_UP_TO_KILO(vm_object_size((Partial_Reveal_Object*)next_area_start)+ hash_extend_size);
+                next_area_start += obj_size;
+            }
+        }else{
+            reach_heap_end = 1;
+        } 
+    }
+    return NULL;
+
+}
+
+inline Partial_Reveal_Object* lspace_get_first_marked_object(Lspace* lspace, unsigned int* mark_bit_idx)
+{
+    return lspace_get_next_marked_object(lspace, mark_bit_idx);
+}
+
+void lspace_fix_after_copy_nursery(Collector* collector, Lspace* lspace);
+
+void lspace_fix_repointed_refs(Collector* collector, Lspace* lspace);
+
+POINTER_SIZE_INT lspace_get_failure_size(Lspace* lspace);
+
+#endif /*_LSPACE_H_ */

Propchange: harmony/enhanced/drlvm/trunk/vm/gc_gen/src/los/lspace.h
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/drlvm/trunk/vm/gc_gen/src/los/lspace_alloc_collect.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/los/lspace_alloc_collect.cpp?view=auto&rev=553050
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/gc_gen/src/los/lspace_alloc_collect.cpp (added)
+++ harmony/enhanced/drlvm/trunk/vm/gc_gen/src/los/lspace_alloc_collect.cpp Tue Jul  3 20:01:01 2007
@@ -0,0 +1,458 @@
+/*
+ *  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 Ji Qi, 2006/10/05
+ */
+
+#include "lspace.h"
+#include "../gen/gen.h"
+#include "../common/space_tuner.h"
+
+static void free_pool_lock_nr_list(Free_Area_Pool* pool, unsigned int list_index)
+{
+    Lockable_Bidir_List* list_head = &pool->sized_area_list[list_index];
+    lock(list_head->lock);
+}
+
+static void free_pool_unlock_nr_list(Free_Area_Pool* pool, unsigned int list_index)
+{
+    Lockable_Bidir_List* list_head = &pool->sized_area_list[list_index];
+    unlock(list_head->lock);
+}
+
+static unsigned int free_pool_nr_list_is_empty(Free_Area_Pool* pool, unsigned int list_index)
+{
+    Bidir_List* head = (Bidir_List*)(&pool->sized_area_list[list_index]);
+    return (head->next == head);
+}
+static void* free_pool_former_lists_atomic_take_area_piece(Free_Area_Pool* pool, unsigned int list_hint, POINTER_SIZE_INT size)
+{
+    Free_Area* free_area;
+    void* p_result;
+    POINTER_SIZE_SINT remain_size;
+    POINTER_SIZE_INT alloc_size = ALIGN_UP_TO_KILO(size);
+    unsigned int new_list_nr = 0;
+    Lockable_Bidir_List* head = &pool->sized_area_list[list_hint];
+
+    assert(list_hint < MAX_LIST_INDEX);
+
+    free_pool_lock_nr_list(pool, list_hint);
+    /*Other LOS allocation may race with this one, so check list status here.*/
+    if(free_pool_nr_list_is_empty(pool, list_hint)){
+        free_pool_unlock_nr_list(pool, list_hint);
+        return NULL;
+    }
+
+    free_area = (Free_Area*)(head->next);
+    /*if the list head is not NULL, it definitely satisfies the request. */   
+    remain_size = free_area->size - alloc_size;
+    assert(remain_size >= 0);
+    if( remain_size >= GC_OBJ_SIZE_THRESHOLD){
+        new_list_nr = pool_list_index_with_size(remain_size);
+        p_result = (void*)((POINTER_SIZE_INT)free_area + remain_size);
+        if(new_list_nr == list_hint){
+            free_area->size = remain_size;
+            free_pool_unlock_nr_list(pool, list_hint);
+            return p_result;
+        }else{
+            free_pool_remove_area(pool, free_area);
+            free_pool_unlock_nr_list(pool, list_hint);
+            free_area->size = remain_size;
+            free_pool_lock_nr_list(pool, new_list_nr);
+            free_pool_add_area(pool, free_area);
+            free_pool_unlock_nr_list(pool, new_list_nr);
+            return p_result;            
+        }
+    }
+    else
+    {
+        free_pool_remove_area(pool, free_area);
+        free_pool_unlock_nr_list(pool, list_hint);
+        p_result = (void*)((POINTER_SIZE_INT)free_area + remain_size);
+        if(remain_size > 0){
+            assert((remain_size >= KB) && (remain_size < GC_OBJ_SIZE_THRESHOLD));
+            free_area->size = remain_size;
+        }
+        return p_result;
+    }
+    assert(0);
+    return NULL;
+}
+
+static void* free_pool_last_list_atomic_take_area_piece(Free_Area_Pool* pool, POINTER_SIZE_INT size)
+{
+    void* p_result;
+    POINTER_SIZE_SINT remain_size = 0;
+    POINTER_SIZE_INT alloc_size = ALIGN_UP_TO_KILO(size);
+    Free_Area* free_area = NULL;
+    Free_Area* new_area = NULL;
+    unsigned int new_list_nr = 0;        
+    Lockable_Bidir_List* head = &(pool->sized_area_list[MAX_LIST_INDEX]);
+    
+    free_pool_lock_nr_list(pool, MAX_LIST_INDEX );
+    /*The last list is empty.*/
+    if(free_pool_nr_list_is_empty(pool, MAX_LIST_INDEX)){
+        free_pool_unlock_nr_list(pool, MAX_LIST_INDEX );                
+        return NULL;
+    }
+    
+    free_area = (Free_Area*)(head->next);
+    while(  free_area != (Free_Area*)head ){
+        remain_size = free_area->size - alloc_size;
+        if( remain_size >= GC_OBJ_SIZE_THRESHOLD){
+            new_list_nr = pool_list_index_with_size(remain_size);
+            p_result = (void*)((POINTER_SIZE_INT)free_area + remain_size);
+            if(new_list_nr == MAX_LIST_INDEX){
+                free_area->size = remain_size;
+                free_pool_unlock_nr_list(pool, MAX_LIST_INDEX);
+                return p_result;
+            }else{
+                free_pool_remove_area(pool, free_area);
+                free_pool_unlock_nr_list(pool, MAX_LIST_INDEX);
+                free_area->size = remain_size;
+                free_pool_lock_nr_list(pool, new_list_nr);
+                free_pool_add_area(pool, free_area);
+                free_pool_unlock_nr_list(pool, new_list_nr);
+                return p_result;            
+            }
+        }
+        else if(remain_size >= 0)
+        {
+            free_pool_remove_area(pool, free_area);
+            free_pool_unlock_nr_list(pool, MAX_LIST_INDEX);
+            p_result = (void*)((POINTER_SIZE_INT)free_area + remain_size);
+            if(remain_size > 0){
+                assert((remain_size >= KB) && (remain_size < GC_OBJ_SIZE_THRESHOLD));
+                free_area->size = remain_size;
+            }
+            return p_result;
+        }
+        else free_area = (Free_Area*)free_area->next;
+    }
+    /*No adequate area in the last list*/
+    free_pool_unlock_nr_list(pool, MAX_LIST_INDEX );
+    return NULL;
+}
+
+void* lspace_try_alloc(Lspace* lspace, POINTER_SIZE_INT alloc_size){
+  void* p_result = NULL;
+  Free_Area_Pool* pool = lspace->free_pool;  
+  unsigned int list_hint = pool_list_index_with_size(alloc_size);  
+  list_hint = pool_list_get_next_flag(pool, list_hint);  
+
+  while((!p_result) && (list_hint <= MAX_LIST_INDEX)){
+      /*List hint is not the last list, so look for it in former lists.*/
+      if(list_hint < MAX_LIST_INDEX){
+          p_result = free_pool_former_lists_atomic_take_area_piece(pool, list_hint, alloc_size);
+          if(p_result){
+              memset(p_result, 0, alloc_size);
+              POINTER_SIZE_INT vold = lspace->alloced_size;
+              POINTER_SIZE_INT vnew = vold + alloc_size;
+              while( vold != atomic_casptrsz(&lspace->alloced_size, vnew, vold) ){                      
+                  vold = lspace->alloced_size;
+                  vnew = vold + alloc_size;
+              }
+              return p_result;
+          }else{
+              list_hint ++;
+              list_hint = pool_list_get_next_flag(pool, list_hint);
+              continue;
+          }
+      }
+      /*List hint is the last list, so look for it in the last list.*/
+      else
+      {
+          p_result = free_pool_last_list_atomic_take_area_piece(pool, alloc_size);
+          if(p_result){
+              memset(p_result, 0, alloc_size);
+              POINTER_SIZE_INT vold = lspace->alloced_size;
+              POINTER_SIZE_INT vnew = vold + alloc_size;
+              while( vold != atomic_casptrsz(&lspace->alloced_size, vnew, vold) ){                      
+                  vold = lspace->alloced_size;
+                  vnew = vold + alloc_size;
+              }
+              return p_result;
+          }
+          else break;
+      }
+  }
+  return p_result;
+}
+
+void* lspace_alloc(POINTER_SIZE_INT size, Allocator *allocator)
+{
+    unsigned int try_count = 0;
+    void* p_result = NULL;
+    POINTER_SIZE_INT alloc_size = ALIGN_UP_TO_KILO(size);
+    Lspace* lspace = (Lspace*)gc_get_los((GC_Gen*)allocator->gc);
+    Free_Area_Pool* pool = lspace->free_pool;
+    
+    while( try_count < 2 ){
+        if(p_result = lspace_try_alloc(lspace, alloc_size))
+          return p_result;
+
+        /*Failled, no adequate area found in all lists, so GC at first, then get another try.*/   
+        if(try_count == 0){
+            vm_gc_lock_enum();
+            /*Check again if there is space for the obj, for maybe other mutator 
+            threads issus a GC in the time gap of waiting the gc lock*/
+            if(p_result = lspace_try_alloc(lspace, alloc_size)){
+              vm_gc_unlock_enum();
+              return p_result;            
+            }
+            lspace->failure_size = round_up_to_size(alloc_size, KB);
+
+            gc_reclaim_heap(allocator->gc, GC_CAUSE_LOS_IS_FULL);
+
+            if(lspace->success_ptr){
+              p_result = lspace->success_ptr;
+              lspace->success_ptr = NULL;
+              vm_gc_unlock_enum();
+              return p_result;
+            }
+            vm_gc_unlock_enum();
+            try_count ++;
+        }else{
+            try_count ++;
+        }
+    }
+    return NULL;
+}
+
+void lspace_compute_object_target(Collector* collector, Lspace* lspace)
+{
+  void* dest_addr = lspace->heap_start;
+  unsigned int iterate_index = 0;
+  Partial_Reveal_Object* p_obj = lspace_get_first_marked_object(lspace, &iterate_index);
+  
+  assert(!collector->rem_set);
+  collector->rem_set = free_set_pool_get_entry(collector->gc->metadata);
+#ifdef USE_32BITS_HASHCODE  
+  collector->hashcode_set = free_set_pool_get_entry(collector->gc->metadata);
+#endif
+  
+  while( p_obj ){
+    assert( obj_is_marked_in_vt(p_obj));
+    unsigned int obj_size = vm_object_size(p_obj);
+    assert(((POINTER_SIZE_INT)dest_addr + obj_size) <= (POINTER_SIZE_INT)lspace->heap_end);
+#ifdef USE_32BITS_HASHCODE 
+    obj_size += hashcode_is_attached(p_obj)? GC_OBJECT_ALIGNMENT : 0 ;
+    Obj_Info_Type obj_info = slide_compact_process_hashcode(p_obj, dest_addr, &obj_size, collector, null, null);
+#else
+    Obj_Info_Type obj_info = get_obj_info_raw(p_obj);
+#endif
+
+    if( obj_info != 0 ) {
+      collector_remset_add_entry(collector, (Partial_Reveal_Object **)dest_addr);
+      collector_remset_add_entry(collector, (Partial_Reveal_Object **)obj_info);
+    }
+      
+    obj_set_fw_in_oi(p_obj, dest_addr);
+    dest_addr = (void *)ALIGN_UP_TO_KILO(((POINTER_SIZE_INT) dest_addr + obj_size));
+    p_obj = lspace_get_next_marked_object(lspace, &iterate_index);
+  }
+
+  pool_put_entry(collector->gc->metadata->collector_remset_pool, collector->rem_set);
+  collector->rem_set = NULL;
+#ifdef USE_32BITS_HASHCODE 
+  pool_put_entry(collector->gc->metadata->collector_hashcode_pool, collector->hashcode_set);
+  collector->hashcode_set = NULL;
+#endif
+  
+  lspace->scompact_fa_start = dest_addr;
+  lspace->scompact_fa_end= lspace->heap_end;
+  return;
+}
+
+void lspace_sliding_compact(Collector* collector, Lspace* lspace)
+{
+  unsigned int iterate_index = 0;
+  Partial_Reveal_Object* p_obj = lspace_get_first_marked_object(lspace, &iterate_index);
+  Partial_Reveal_Object *p_target_obj = obj_get_fw_in_oi(p_obj); 
+
+  while( p_obj ){
+    assert( obj_is_marked_in_vt(p_obj));
+#ifdef USE_32BITS_HASHCODE
+    obj_clear_dual_bits_in_vt(p_obj); 
+#else
+    obj_unmark_in_vt(p_obj);
+#endif
+    
+    unsigned int obj_size = vm_object_size(p_obj);
+#ifdef USE_32BITS_HASHCODE 
+    obj_size += (obj_is_sethash_in_vt(p_obj))?GC_OBJECT_ALIGNMENT:0;    
+#endif
+    Partial_Reveal_Object *p_target_obj = obj_get_fw_in_oi(p_obj);
+    POINTER_SIZE_INT target_obj_end = (POINTER_SIZE_INT)p_target_obj + obj_size;
+    if( p_obj != p_target_obj){
+      memmove(p_target_obj, p_obj, obj_size);
+    }
+    set_obj_info(p_target_obj, 0);
+    p_obj = lspace_get_next_marked_object(lspace, &iterate_index);  
+  }
+
+  return;
+}
+
+void lspace_reset_after_collection(Lspace* lspace)
+{
+    GC* gc = lspace->gc;
+    Space_Tuner* tuner = gc->tuner;
+    POINTER_SIZE_INT trans_size = tuner->tuning_size;
+    POINTER_SIZE_INT new_fa_size = 0;
+    assert(!(trans_size%GC_BLOCK_SIZE_BYTES));
+    
+    /* Reset the pool first because its info is useless now. */
+    free_area_pool_reset(lspace->free_pool);
+
+    switch(tuner->kind){
+      case TRANS_FROM_MOS_TO_LOS:{
+        if(lspace->move_object){
+          assert(tuner->force_tune);
+          Block* mos_first_block = ((GC_Gen*)gc)->mos->blocks;
+          lspace->heap_end = (void*)mos_first_block;
+          assert(!(tuner->tuning_size % GC_BLOCK_SIZE_BYTES));
+          new_fa_size = (POINTER_SIZE_INT)lspace->scompact_fa_end - (POINTER_SIZE_INT)lspace->scompact_fa_start + tuner->tuning_size;
+          Free_Area* fa = free_area_new(lspace->scompact_fa_start,  new_fa_size);
+          if(new_fa_size >= GC_OBJ_SIZE_THRESHOLD) free_pool_add_area(lspace->free_pool, fa);
+        }else{
+          void* origin_end = lspace->heap_end;
+          lspace->heap_end = (void*)(((GC_Gen*)gc)->mos->blocks);
+          /*The assumption that the first word of one KB must be zero when iterating lspace in 
+          that function lspace_get_next_marked_object is not true*/
+          Free_Area* trans_fa = free_area_new(origin_end, trans_size);
+          if(trans_size >= GC_OBJ_SIZE_THRESHOLD) free_pool_add_area(lspace->free_pool, trans_fa);
+        }
+        lspace->committed_heap_size += trans_size;
+        break;
+      }
+      case TRANS_FROM_LOS_TO_MOS:{
+        assert(lspace->move_object);
+        assert(tuner->tuning_size);
+        Block* mos_first_block = ((GC_Gen*)gc)->mos->blocks;
+        assert( (POINTER_SIZE_INT)lspace->heap_end - trans_size == (POINTER_SIZE_INT)mos_first_block );
+        lspace->heap_end = (void*)mos_first_block;
+        lspace->committed_heap_size -= trans_size;
+        /*LOS_Shrink: We don't have to scan lspace to build free pool when slide compact LOS*/
+        assert((POINTER_SIZE_INT)lspace->scompact_fa_end > (POINTER_SIZE_INT)lspace->scompact_fa_start + tuner->tuning_size);
+        new_fa_size = (POINTER_SIZE_INT)lspace->scompact_fa_end - (POINTER_SIZE_INT)lspace->scompact_fa_start - tuner->tuning_size;
+        Free_Area* fa = free_area_new(lspace->scompact_fa_start,  new_fa_size);
+        if(new_fa_size >= GC_OBJ_SIZE_THRESHOLD) free_pool_add_area(lspace->free_pool, fa);
+        break;
+      }
+      default:{
+        if(lspace->move_object){
+          assert(tuner->kind == TRANS_NOTHING);
+          assert(!tuner->tuning_size);
+          new_fa_size = (POINTER_SIZE_INT)lspace->scompact_fa_end - (POINTER_SIZE_INT)lspace->scompact_fa_start;
+          Free_Area* fa = free_area_new(lspace->scompact_fa_start,  new_fa_size);
+          if(new_fa_size >= GC_OBJ_SIZE_THRESHOLD) free_pool_add_area(lspace->free_pool, fa);
+        }
+        break;
+      }
+    }
+
+    /*For_statistic los information.*/
+    lspace->alloced_size = 0;    
+    lspace->surviving_size = 0;
+
+    los_boundary = lspace->heap_end;
+}
+
+void lspace_sweep(Lspace* lspace)
+{
+  unsigned int mark_bit_idx = 0;
+  POINTER_SIZE_INT cur_size = 0;
+  void *cur_area_start, *cur_area_end;
+
+  /*If it is TRANS_FROM_MOS_TO_LOS now, we must clear the fa alread added in lspace_reset_after_collection*/
+  free_area_pool_reset(lspace->free_pool);
+
+  Partial_Reveal_Object* p_prev_obj = (Partial_Reveal_Object *)lspace->heap_start;
+  Partial_Reveal_Object* p_next_obj = lspace_get_first_marked_object(lspace, &mark_bit_idx);
+  if(p_next_obj){
+    obj_unmark_in_vt(p_next_obj);
+    /* we need this because, in hybrid situation of gen_mode and non_gen_mode, LOS will only be marked
+       in non_gen_mode, and not reset in gen_mode. When it switches back from gen_mode to non_gen_mode,
+       the last time marked object is thought to be already marked and not scanned for this cycle. */
+    obj_clear_dual_bits_in_oi(p_next_obj);
+    /*For_statistic: sum up the size of suvived large objects, useful to deciede los extention.*/
+unsigned int obj_size = vm_object_size(p_next_obj);
+#ifdef USE_32BITS_HASHCODE
+    obj_size += (hashcode_is_attached(p_next_obj))?GC_OBJECT_ALIGNMENT:0;
+#endif
+    lspace->surviving_size += ALIGN_UP_TO_KILO(obj_size);    
+  }
+
+  cur_area_start = (void*)ALIGN_UP_TO_KILO(p_prev_obj);
+  cur_area_end = (void*)ALIGN_DOWN_TO_KILO(p_next_obj);
+  unsigned int hash_extend_size = 0;
+
+  Free_Area* cur_area = NULL;
+  while(cur_area_end){
+    cur_area = NULL;
+    cur_size = (POINTER_SIZE_INT)cur_area_end - (POINTER_SIZE_INT)cur_area_start;
+      
+    if(cur_size){
+      //debug
+      assert(cur_size >= KB);
+      cur_area = free_area_new(cur_area_start, cur_size);
+      if( cur_area ) free_pool_add_area(lspace->free_pool, cur_area);
+    }
+    /* successfully create an area */
+
+    p_prev_obj = p_next_obj;
+    p_next_obj = lspace_get_next_marked_object(lspace, &mark_bit_idx);
+    if(p_next_obj){
+      obj_unmark_in_vt(p_next_obj);
+      obj_clear_dual_bits_in_oi(p_next_obj);
+      /*For_statistic: sum up the size of suvived large objects, useful to deciede los extention.*/
+      unsigned int obj_size = vm_object_size(p_next_obj);
+#ifdef USE_32BITS_HASHCODE
+      obj_size += (hashcode_is_attached(p_next_obj))?GC_OBJECT_ALIGNMENT:0;
+#endif
+      lspace->surviving_size += ALIGN_UP_TO_KILO(obj_size);
+    }
+
+#ifdef USE_32BITS_HASHCODE
+    hash_extend_size  = (hashcode_is_attached((Partial_Reveal_Object*)p_prev_obj))?GC_OBJECT_ALIGNMENT:0;
+#endif
+    cur_area_start = (void*)ALIGN_UP_TO_KILO((POINTER_SIZE_INT)p_prev_obj + vm_object_size(p_prev_obj) + hash_extend_size);
+    cur_area_end = (void*)ALIGN_DOWN_TO_KILO(p_next_obj);
+    
+  }
+
+   /* cur_area_end == NULL */
+  cur_area_end = (void*)ALIGN_DOWN_TO_KILO(lspace->heap_end);
+  cur_size = (POINTER_SIZE_INT)cur_area_end - (POINTER_SIZE_INT)cur_area_start;
+  if(cur_size){
+    //debug
+    assert(cur_size >= KB);
+    cur_area = free_area_new(cur_area_start, cur_size);
+    if( cur_area ) free_pool_add_area(lspace->free_pool, cur_area);
+  }  
+
+   mark_bit_idx = 0;
+   assert(!lspace_get_first_marked_object(lspace, &mark_bit_idx));
+
+  /*Update survive ratio here. If we tune LOS this time, the ratio is computed by the new committed size.*/
+  /*Fixme: We should keep the surviving size of last time, and set denominator to last_survive + current_alloc*/
+  lspace->survive_ratio = (float)lspace->surviving_size / (float)lspace->committed_heap_size;
+
+  return;
+
+}

Propchange: harmony/enhanced/drlvm/trunk/vm/gc_gen/src/los/lspace_alloc_collect.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_compact/fallback_mark_scan.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_compact/fallback_mark_scan.cpp?view=diff&rev=553050&r1=553049&r2=553050
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_compact/fallback_mark_scan.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_compact/fallback_mark_scan.cpp Tue Jul  3 20:01:01 2007
@@ -209,4 +209,3 @@
 }
 #endif
 
-

Modified: harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_compact/mspace.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_compact/mspace.cpp?view=diff&rev=553050&r1=553049&r2=553050
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_compact/mspace.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_compact/mspace.cpp Tue Jul  3 20:01:01 2007
@@ -167,4 +167,3 @@
 }
 
 
-

Modified: harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_compact/mspace_alloc.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_compact/mspace_alloc.cpp?view=diff&rev=553050&r1=553049&r2=553050
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_compact/mspace_alloc.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_compact/mspace_alloc.cpp Tue Jul  3 20:01:01 2007
@@ -75,4 +75,3 @@
   return p_return;
 }
 
-

Modified: harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_compact/mspace_collect_compact.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_compact/mspace_collect_compact.cpp?view=diff&rev=553050&r1=553049&r2=553050
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_compact/mspace_collect_compact.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_compact/mspace_collect_compact.cpp Tue Jul  3 20:01:01 2007
@@ -339,4 +339,3 @@
 
 
 
-

Modified: harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_compact/mspace_collect_compact.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_compact/mspace_collect_compact.h?view=diff&rev=553050&r1=553049&r2=553050
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_compact/mspace_collect_compact.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_compact/mspace_collect_compact.h Tue Jul  3 20:01:01 2007
@@ -54,4 +54,3 @@
 #endif /* _MSPACE_COLLECT_COMPACT_H_ */
 
 
-

Modified: harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_compact/mspace_extend_compact.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_compact/mspace_extend_compact.cpp?view=diff&rev=553050&r1=553049&r2=553050
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_compact/mspace_extend_compact.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_compact/mspace_extend_compact.cpp Tue Jul  3 20:01:01 2007
@@ -20,7 +20,7 @@
 
 #include "mspace_collect_compact.h"
 #include "../trace_forward/fspace.h"
-#include "../mark_sweep/lspace.h"
+#include "../los/lspace.h"
 #include "../finalizer_weakref/finalizer_weakref.h"
 #include "../gen/gen.h"
 #include "../common/fix_repointed_refs.h"

Modified: harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_compact/mspace_move_compact.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_compact/mspace_move_compact.cpp?view=diff&rev=553050&r1=553049&r2=553050
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_compact/mspace_move_compact.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_compact/mspace_move_compact.cpp Tue Jul  3 20:01:01 2007
@@ -20,7 +20,7 @@
 
 #include "mspace_collect_compact.h"
 #include "../trace_forward/fspace.h"
-#include "../mark_sweep/lspace.h"
+#include "../los/lspace.h"
 #include "../finalizer_weakref/finalizer_weakref.h"
 #ifdef USE_32BITS_HASHCODE
 #include "../common/hashcode.h"

Modified: harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_compact/mspace_slide_compact.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_compact/mspace_slide_compact.cpp?view=diff&rev=553050&r1=553049&r2=553050
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_compact/mspace_slide_compact.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_compact/mspace_slide_compact.cpp Tue Jul  3 20:01:01 2007
@@ -20,7 +20,7 @@
 
 #include "mspace_collect_compact.h"
 #include "../trace_forward/fspace.h"
-#include "../mark_sweep/lspace.h"
+#include "../los/lspace.h"
 #include "../finalizer_weakref/finalizer_weakref.h"
 
 

Added: harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_sweep/sspace.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_sweep/sspace.cpp?view=auto&rev=553050
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_sweep/sspace.cpp (added)
+++ harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_sweep/sspace.cpp Tue Jul  3 20:01:01 2007
@@ -0,0 +1,120 @@
+/*
+ *  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.
+ */
+
+#include "sspace.h"
+#include "sspace_chunk.h"
+#include "../gen/gen.h"
+#include "../common/gc_space.h"
+#include "sspace_verify.h"
+
+struct GC_Gen;
+
+void sspace_initialize(GC *gc, void *start, unsigned int sspace_size, unsigned int commit_size)
+{
+  /* With sspace in the heap, the heap must be composed of a single sspace or a sspace and a NOS.
+   * In either case, the reserved size and committed size of sspace must be the same.
+   * Because sspace has only mark-sweep collection, it is not possible to shrink sspace.
+   * So there is no need to use dynamic space resizing.
+   */
+  assert(sspace_size == commit_size);
+  
+  Sspace *sspace = (Sspace*)STD_MALLOC(sizeof(Sspace));
+  assert(sspace);
+  memset(sspace, 0, sizeof(Sspace));
+  
+  sspace->reserved_heap_size = sspace_size;
+  
+  void *reserved_base = start;
+  
+  /* commit sspace mem */
+  if(!large_page_hint)
+    vm_commit_mem(reserved_base, commit_size);
+  memset(reserved_base, 0, commit_size);
+  sspace->committed_heap_size = commit_size;
+  
+  sspace->heap_start = reserved_base;
+  sspace->heap_end = (void *)((POINTER_SIZE_INT)reserved_base + sspace_size);
+    
+  sspace->num_collections = 0;
+  sspace->time_collections = 0;
+  sspace->survive_ratio = 0.2f;
+
+  sspace->move_object = FALSE;
+  sspace->gc = gc;
+  
+  sspace_init_chunks(sspace);
+  
+  gc_set_pos((GC_Gen*)gc, (Space*)sspace);
+#ifdef SSPACE_VERIFY
+  sspace_verify_init(gc);
+#endif
+  return;
+}
+
+static void sspace_destruct_chunks(Sspace *sspace) { return; }
+
+void sspace_destruct(Sspace *sspace)
+{
+  //FIXME:: when map the to-half, the decommission start address should change
+  sspace_destruct_chunks(sspace);
+  STD_FREE(sspace);
+}
+
+void mutator_init_small_chunks(Mutator *mutator)
+{
+  unsigned int size = sizeof(Chunk_Header*) * (SMALL_LOCAL_CHUNK_NUM + MEDIUM_LOCAL_CHUNK_NUM);
+  Chunk_Header **chunks = (Chunk_Header**)STD_MALLOC(size);
+  memset(chunks, 0, size);
+  mutator->small_chunks = chunks;
+  mutator->medium_chunks = chunks + SMALL_LOCAL_CHUNK_NUM;
+}
+
+extern void mark_sweep_sspace(Collector *collector);
+
+void sspace_collection(Sspace *sspace) 
+{
+  GC *gc = sspace->gc;
+  sspace->num_collections++;
+  
+#ifdef SSPACE_ALLOC_INFO
+  sspace_alloc_info_summary();
+#endif
+#ifdef SSPACE_CHUNK_INFO
+  sspace_chunks_info(sspace, TRUE);
+#endif
+
+#ifdef SSPACE_VERIFY
+  sspace_verify_vtable_mark(gc);
+#endif
+
+#ifdef SSPACE_TIME
+  sspace_gc_time(gc, TRUE);
+#endif
+
+  pool_iterator_init(gc->metadata->gc_rootset_pool);
+  sspace_clear_chunk_list(gc);
+  
+  collector_execute_task(gc, (TaskType)mark_sweep_sspace, (Space*)sspace);
+
+#ifdef SSPACE_TIME
+  sspace_gc_time(gc, FALSE);
+#endif
+
+#ifdef SSPACE_CHUNK_INFO
+  sspace_chunks_info(sspace, FALSE);
+#endif
+
+}

Propchange: harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_sweep/sspace.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_sweep/sspace.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_sweep/sspace.h?view=auto&rev=553050
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_sweep/sspace.h (added)
+++ harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_sweep/sspace.h Tue Jul  3 20:01:01 2007
@@ -0,0 +1,74 @@
+/*
+ *  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.
+ */
+
+#ifndef _SWEEP_SPACE_H_
+#define _SWEEP_SPACE_H_
+
+#include "../thread/gc_thread.h"
+#include "../thread/collector_alloc.h"
+#include "../thread/mutator.h"
+#include "../common/gc_common.h"
+
+/*
+ * The sweep space accomodates objects collected by mark-sweep
+ */
+
+#define ONLY_SSPACE_IN_HEAP
+
+struct Free_Chunk_List;
+
+typedef struct Sspace {
+  /* <-- first couple of fields are overloadded as Space */
+  void *heap_start;
+  void *heap_end;
+  unsigned int reserved_heap_size;
+  unsigned int committed_heap_size;
+  unsigned int num_collections;
+  int64 time_collections;
+  float survive_ratio;
+  unsigned int collect_algorithm;
+  GC *gc;
+  Boolean move_object;
+  /* Size allocted after last collection. Not available in fspace now. */
+  unsigned int alloced_size;
+  /* For_statistic: not available now for fspace */
+  unsigned int surviving_size;
+  /* END of Space --> */
+  
+  Pool **small_pfc_pools;
+  Pool **medium_pfc_pools;
+  Pool **large_pfc_pools;
+  Free_Chunk_List *aligned_free_chunk_lists;
+  Free_Chunk_List *unaligned_free_chunk_lists;
+  Free_Chunk_List *hyper_free_chunk_list;
+} Sspace;
+
+void sspace_initialize(GC *gc, void *start, unsigned int sspace_size, unsigned int commit_size);
+void sspace_destruct(Sspace *sspace);
+
+void *sspace_fast_alloc(unsigned size, Allocator *allocator);
+void *sspace_alloc(unsigned size, Allocator *allocator);
+
+void sspace_reset_for_allocation(Sspace *sspace);
+
+void sspace_collection(Sspace *sspace);
+
+void mutator_init_small_chunks(Mutator *mutator);
+void collector_init_free_chunk_list(Collector *collector);
+
+POINTER_SIZE_INT sspace_free_memory_size(Sspace *sspace);
+
+#endif // _SWEEP_SPACE_H_

Propchange: harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_sweep/sspace.h
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_sweep/sspace_alloc.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_sweep/sspace_alloc.cpp?view=auto&rev=553050
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_sweep/sspace_alloc.cpp (added)
+++ harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_sweep/sspace_alloc.cpp Tue Jul  3 20:01:01 2007
@@ -0,0 +1,330 @@
+/*
+ *  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.
+ */
+
+#include "sspace.h"
+#include "sspace_chunk.h"
+#include "sspace_mark_sweep.h"
+#include "../gen/gen.h"
+
+static Boolean slot_is_alloc_in_table(POINTER_SIZE_INT *table, unsigned int slot_index)
+{
+  unsigned int color_bits_index = slot_index * COLOR_BITS_PER_OBJ;
+  unsigned int word_index = color_bits_index / BITS_PER_WORD;
+  unsigned int index_in_word = color_bits_index % BITS_PER_WORD;
+  
+  return table[word_index] & (cur_alloc_color << index_in_word);
+}
+
+static void alloc_slot_in_table(POINTER_SIZE_INT *table, unsigned int slot_index)
+{
+  assert(!slot_is_alloc_in_table(table, slot_index));
+  
+  unsigned int color_bits_index = slot_index * COLOR_BITS_PER_OBJ;
+  unsigned int word_index = color_bits_index / BITS_PER_WORD;
+  unsigned int index_in_word = color_bits_index % BITS_PER_WORD;
+  
+  table[word_index] |= cur_alloc_color << index_in_word;
+}
+
+static unsigned int first_free_index_in_color_word(POINTER_SIZE_INT word)
+{
+  unsigned int index = 0;
+  
+  while(index < BITS_PER_WORD){
+    if(!(word & (cur_mark_color << index)))
+      return index;
+    index += COLOR_BITS_PER_OBJ;
+  }
+  
+  assert(0);  /* There must be a free obj in this table word */
+  return MAX_SLOT_INDEX;
+}
+
+static Boolean next_free_index_in_color_word(POINTER_SIZE_INT word, unsigned int &index)
+{
+  while(index < BITS_PER_WORD){
+    if(!(word & (cur_alloc_color << index)))
+      return TRUE;
+    index += COLOR_BITS_PER_OBJ;
+  }
+  return FALSE;
+}
+
+static unsigned int composed_slot_index(unsigned int word_index, unsigned int index_in_word)
+{
+  unsigned int color_bits_index = word_index*BITS_PER_WORD + index_in_word;
+  return color_bits_index/COLOR_BITS_PER_OBJ;
+}
+
+static unsigned int next_free_slot_index_in_table(POINTER_SIZE_INT *table, unsigned int slot_index, unsigned int slot_num)
+{
+  assert(slot_is_alloc_in_table(table, slot_index));
+  
+  unsigned int max_word_index = ((slot_num-1) * COLOR_BITS_PER_OBJ) / BITS_PER_WORD;
+  Boolean found = FALSE;
+  
+  unsigned int color_bits_index = slot_index * COLOR_BITS_PER_OBJ;
+  unsigned int word_index = color_bits_index / BITS_PER_WORD;
+  unsigned int index_in_word = color_bits_index % BITS_PER_WORD;
+  
+  while(word_index < max_word_index){
+    found = next_free_index_in_color_word(table[word_index], index_in_word);
+    if(found)
+      return composed_slot_index(word_index, index_in_word);
+    ++word_index;
+    index_in_word = 0;
+   }
+  
+  index_in_word = 0;
+  found = next_free_index_in_color_word(table[word_index], index_in_word);
+  if(found)
+    return composed_slot_index(word_index, index_in_word);
+  
+  return MAX_SLOT_INDEX;
+}
+
+/* Used for collecting pfc */
+void chunk_set_slot_index(Chunk_Header* chunk, unsigned int first_free_word_index)
+{
+  unsigned int index_in_word = first_free_index_in_color_word(chunk->table[first_free_word_index]);
+  assert(index_in_word != MAX_SLOT_INDEX);
+  chunk->slot_index = composed_slot_index(first_free_word_index, index_in_word);
+}
+
+
+/* 1. No need of synchronization. This is a mutator local chunk no matter it is a small or medium obj chunk.
+ * 2. If this chunk runs out of space, clear the chunk pointer.
+ *    So it is important to give an argument which is a local chunk pointer of a mutator while invoking this func.
+ */
+static void *alloc_in_chunk(Chunk_Header* &chunk)
+{
+  POINTER_SIZE_INT *table = chunk->table;
+  unsigned int slot_index = chunk->slot_index;
+  
+  void *p_obj = (void*)((POINTER_SIZE_INT)chunk->base + ((POINTER_SIZE_INT)chunk->slot_size * slot_index));
+  alloc_slot_in_table(table, slot_index);
+  if(chunk->status & CHUNK_NEED_ZEROING)
+    memset(p_obj, 0, chunk->slot_size);
+#ifdef SSPACE_VERIFY
+  sspace_verify_free_area((POINTER_SIZE_INT*)p_obj, chunk->slot_size);
+#endif
+  
+  chunk->slot_index = next_free_slot_index_in_table(table, slot_index, chunk->slot_num);
+  if(chunk->slot_index == MAX_SLOT_INDEX){
+    chunk->status = CHUNK_USED | CHUNK_NORMAL;
+    chunk = NULL;
+  }
+  
+  return p_obj;
+}
+
+/* alloc small without-fin object in sspace without getting new free chunk */
+void *sspace_fast_alloc(unsigned size, Allocator *allocator)
+{
+  if(size > SUPER_OBJ_THRESHOLD) return NULL;
+  
+  if(size <= MEDIUM_OBJ_THRESHOLD){  /* small object */
+    size = SMALL_SIZE_ROUNDUP(size);
+    Chunk_Header **small_chunks = ((Mutator*)allocator)->small_chunks;
+    unsigned int index = SMALL_SIZE_TO_INDEX(size);
+    
+    if(!small_chunks[index]){
+      Sspace *sspace = (Sspace*)gc_get_pos((GC_Gen*)allocator->gc);
+      Chunk_Header *chunk = sspace_get_small_pfc(sspace, index);
+      //if(!chunk)
+        //chunk = sspace_steal_small_pfc(sspace, index);
+      if(!chunk) return NULL;
+      small_chunks[index] = chunk;
+    }
+    return alloc_in_chunk(small_chunks[index]);
+  } else if(size <= LARGE_OBJ_THRESHOLD){  /* medium object */
+    size = MEDIUM_SIZE_ROUNDUP(size);
+    Chunk_Header **medium_chunks = ((Mutator*)allocator)->medium_chunks;
+    unsigned int index = MEDIUM_SIZE_TO_INDEX(size);
+    
+    if(!medium_chunks[index]){
+      Sspace *sspace = (Sspace*)gc_get_pos((GC_Gen*)allocator->gc);
+      Chunk_Header *chunk = sspace_get_medium_pfc(sspace, index);
+      //if(!chunk)
+        //chunk = sspace_steal_medium_pfc(sspace, index);
+      if(!chunk) return NULL;
+      medium_chunks[index] = chunk;
+    }
+    return alloc_in_chunk(medium_chunks[index]);
+  } else {  /* large object */
+    assert(size <= SUPER_OBJ_THRESHOLD);
+    size = LARGE_SIZE_ROUNDUP(size);
+    unsigned int index = LARGE_SIZE_TO_INDEX(size);
+    Sspace *sspace = (Sspace*)gc_get_pos((GC_Gen*)allocator->gc);
+    Chunk_Header *chunk = sspace_get_large_pfc(sspace, index);
+    //if(!chunk)
+      //chunk = sspace_steal_large_pfc(sspace, index);
+    if(!chunk) return NULL;
+    void *p_obj = alloc_in_chunk(chunk);
+    if(chunk)
+      sspace_put_large_pfc(sspace, chunk, index);
+    return p_obj;
+  }
+}
+
+static void *alloc_small_obj(unsigned size, Allocator *allocator)
+{
+  assert(size <= MEDIUM_OBJ_THRESHOLD);
+  assert(!(size & SMALL_GRANULARITY_LOW_MASK));
+  
+  Chunk_Header **small_chunks = ((Mutator*)allocator)->small_chunks;
+  unsigned int index = SMALL_SIZE_TO_INDEX(size);
+  if(!small_chunks[index]){
+    Sspace *sspace = (Sspace*)gc_get_pos((GC_Gen*)allocator->gc);
+    Chunk_Header *chunk = sspace_get_small_pfc(sspace, index);
+    //if(!chunk)
+      //chunk = sspace_steal_small_pfc(sspace, index);
+    if(!chunk){
+      chunk = (Chunk_Header*)sspace_get_normal_free_chunk(sspace);
+      if(chunk){
+        normal_chunk_init(chunk, size);
+      } else {
+        /*chunk = sspace_steal_small_pfc(sspace, index);
+        if(!chunk)*/ return NULL;
+      }
+    }
+    chunk->status |= CHUNK_IN_USE | CHUNK_NORMAL;
+    small_chunks[index] = chunk;
+  }
+  
+  return alloc_in_chunk(small_chunks[index]);
+}
+
+static void *alloc_medium_obj(unsigned size, Allocator *allocator)
+{
+  assert((size > MEDIUM_OBJ_THRESHOLD) && (size <= LARGE_OBJ_THRESHOLD));
+  assert(!(size & MEDIUM_GRANULARITY_LOW_MASK));
+  
+  Chunk_Header **medium_chunks = ((Mutator*)allocator)->medium_chunks;
+  unsigned int index = MEDIUM_SIZE_TO_INDEX(size);
+  if(!medium_chunks[index]){
+    Sspace *sspace = (Sspace*)gc_get_pos((GC_Gen*)allocator->gc);
+    Chunk_Header *chunk = sspace_get_medium_pfc(sspace, index);
+    //if(!chunk)
+      //chunk = sspace_steal_medium_pfc(sspace, index);
+    if(!chunk){
+      chunk = (Chunk_Header*)sspace_get_normal_free_chunk(sspace);
+      if(chunk){
+        normal_chunk_init(chunk, size);
+      } else {
+        /*chunk = sspace_steal_medium_pfc(sspace, index);
+        if(!chunk) */return NULL;
+      }
+    }
+    chunk->status |= CHUNK_IN_USE | CHUNK_NORMAL;
+    medium_chunks[index] = chunk;
+  }
+  
+  return alloc_in_chunk(medium_chunks[index]);
+}
+
+/* FIXME:: this is a simple version. It may return NULL while there are still pfc in pool put by other mutators */
+static void *alloc_large_obj(unsigned size, Allocator *allocator)
+{
+  assert((size > LARGE_OBJ_THRESHOLD) && (size <= SUPER_OBJ_THRESHOLD));
+  assert(!(size & LARGE_GRANULARITY_LOW_MASK));
+  
+  Sspace *sspace = (Sspace*)gc_get_pos((GC_Gen*)allocator->gc);
+  unsigned int index = LARGE_SIZE_TO_INDEX(size);
+  Chunk_Header *chunk = sspace_get_large_pfc(sspace, index);
+  //if(!chunk)
+    //chunk = sspace_steal_large_pfc(sspace, index);
+  if(!chunk){
+    chunk = (Chunk_Header*)sspace_get_normal_free_chunk(sspace);
+    if(chunk){
+      normal_chunk_init(chunk, size);
+    } else {
+      /*chunk = sspace_steal_large_pfc(sspace, index);
+      if(!chunk)*/ return NULL;
+    }
+  }
+  chunk->status |= CHUNK_NORMAL;
+  
+  void *p_obj = alloc_in_chunk(chunk);
+  if(chunk)
+    sspace_put_large_pfc(sspace, chunk, index);
+  return p_obj;
+}
+
+static void *alloc_super_obj(unsigned size, Allocator *allocator)
+{
+  assert(size > SUPER_OBJ_THRESHOLD);
+  
+  Sspace *sspace = (Sspace*)gc_get_pos((GC_Gen*)allocator->gc);
+  unsigned int chunk_size = SUPER_SIZE_ROUNDUP(size);
+  assert(chunk_size > SUPER_OBJ_THRESHOLD);
+  assert(!(chunk_size & CHUNK_GRANULARITY_LOW_MASK));
+  
+  Chunk_Header *chunk;
+  if(chunk_size <= HYPER_OBJ_THRESHOLD)
+    chunk = (Chunk_Header*)sspace_get_abnormal_free_chunk(sspace, chunk_size);
+  else
+    chunk = (Chunk_Header*)sspace_get_hyper_free_chunk(sspace, chunk_size, FALSE);
+  
+  if(!chunk) return NULL;
+  abnormal_chunk_init(chunk, chunk_size, size);
+  chunk->status = CHUNK_IN_USE | CHUNK_ABNORMAL;
+  chunk->table[0] = cur_alloc_color;
+  set_super_obj_mask(chunk->base);
+  assert(get_obj_info_raw((Partial_Reveal_Object*)chunk->base) & SUPER_OBJ_MASK);
+  //printf("Obj: %x  size: %x\t", (POINTER_SIZE_INT)chunk->base, size);
+  return chunk->base;
+}
+
+static void *sspace_try_alloc(unsigned size, Allocator *allocator)
+{
+  if(size <= MEDIUM_OBJ_THRESHOLD)
+    return alloc_small_obj(SMALL_SIZE_ROUNDUP(size), allocator);
+  else if(size <= LARGE_OBJ_THRESHOLD)
+    return alloc_medium_obj(MEDIUM_SIZE_ROUNDUP(size), allocator);
+  else if(size <= SUPER_OBJ_THRESHOLD)
+    return alloc_large_obj(LARGE_SIZE_ROUNDUP(size), allocator);
+  else
+    return alloc_super_obj(size, allocator);
+}
+
+/* FIXME:: the collection should be seperated from the alloation */
+void *sspace_alloc(unsigned size, Allocator *allocator)
+{
+  void *p_obj = NULL;
+  
+  /* First, try to allocate object from TLB (thread local chunk) */
+  p_obj = sspace_try_alloc(size, allocator);
+  if(p_obj)  return p_obj;
+  
+  vm_gc_lock_enum();
+  /* after holding lock, try if other thread collected already */
+  p_obj = sspace_try_alloc(size, allocator);
+  if(p_obj){
+    vm_gc_unlock_enum();
+    return p_obj;
+  }
+  gc_reclaim_heap(allocator->gc, GC_CAUSE_POS_IS_FULL);
+  vm_gc_unlock_enum();
+
+#ifdef SSPACE_CHUNK_INFO
+  printf("Failure size: %x\n", size);
+#endif
+
+  p_obj = sspace_try_alloc(size, allocator);
+  
+  return p_obj;
+}

Propchange: harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_sweep/sspace_alloc.cpp
------------------------------------------------------------------------------
    svn:eol-style = native