harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wjwashb...@apache.org
Subject svn commit: r468252 [2/2] - in /incubator/harmony/enhanced/drlvm/trunk/vm/gc_gen/src: common/ gen/ mark_compact/ mark_sweep/ thread/ trace_forward/
Date Fri, 27 Oct 2006 03:48:44 GMT
Modified: incubator/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_sweep/lspace.h
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_sweep/lspace.h?view=diff&rev=468252&r1=468251&r2=468252
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_sweep/lspace.h (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_sweep/lspace.h Thu Oct 26 20:48:43 2006
@@ -1,77 +1,79 @@
-/*
- *  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 Xiao-Feng Li, 2006/10/05
- */
-
-#ifndef _LSPACE_H_
-#define _LSPACE_H_
-
-#include "../common/gc_common.h"
-#include "../thread/thread_alloc.h"
-
-typedef struct Lspace{
+/*
+ *  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 Xiao-Feng Li, 2006/10/05
+ */
+
+#ifndef _LSPACE_H_
+#define _LSPACE_H_
+
+#include "../common/gc_common.h"
+#include "../thread/thread_alloc.h"
+
+typedef struct Lspace{
   /* <-- 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;
-  GC* gc;
-  Boolean move_object;
+  unsigned int num_collections;
+  GC* gc;
+  Boolean move_object;
   Boolean (*mark_object_func)(Lspace* space, Partial_Reveal_Object* p_obj);
   void (*save_reloc_func)(Lspace* space, Partial_Reveal_Object** p_ref);
-  void (*update_reloc_func)(Lspace* space);
-  /* END of Space --> */
-
-  void* alloc_free;
-    
-  unsigned int* mark_table;
-
+  void (*update_reloc_func)(Lspace* space);
+  /* END of Space --> */
+
+  void* alloc_free;
+    
+  unsigned int* mark_table;
+
   /* support other space moving collection */
-  SlotVector* reloc_table;
-
-}Lspace;
-
-void lspace_initialize(GC* gc, void* reserved_base, unsigned int lspace_size);
-void lspace_destruct(Lspace* lspace);
-Managed_Object_Handle lspace_alloc(unsigned int size, Alloc_Context* alloc_ctx);
-void lspace_collection(Lspace* lspace);
-
-inline unsigned int lspace_free_memory_size(Lspace* lspace){ /* FIXME:: */ return 0; }
-
-/* The assumption is the offset below is always aligned at word size, because both numbers are aligned */
-#define ADDRESS_OFFSET_IN_LSPACE_BODY(lspace, p_obj) ((unsigned int)p_obj - (unsigned int)space_heap_start((Space*)lspace))
-#define OBJECT_BIT_INDEX_TO_LSPACE_MARKBIT_TABLE(lspace, p_obj)    (ADDRESS_OFFSET_IN_LSPACE_BODY(lspace, p_obj) >> BIT_SHIFT_TO_KILO)
-#define OBJECT_WORD_INDEX_TO_LSPACE_MARKBIT_TABLE(lspace, p_obj)   (OBJECT_BIT_INDEX_TO_LSPACE_MARKBIT_TABLE(lspace, p_obj) >> BIT_SHIFT_TO_BITS_PER_WORD)
-#define OBJECT_WORD_OFFSET_IN_LSPACE_MARKBIT_TABLE(lspace, p_obj)  (OBJECT_BIT_INDEX_TO_LSPACE_MARKBIT_TABLE(lspace, p_obj) & BIT_MASK_TO_BITS_PER_WORD)
-
-inline Boolean lspace_object_is_marked(Lspace* lspace, Partial_Reveal_Object* p_obj)
-{
-  assert( obj_belongs_to_space(p_obj, (Space*)lspace));
-  unsigned int word_index = OBJECT_WORD_INDEX_TO_LSPACE_MARKBIT_TABLE(lspace, p_obj);
-  unsigned int bit_offset_in_word = OBJECT_WORD_OFFSET_IN_LSPACE_MARKBIT_TABLE(lspace, p_obj);
- 
-  unsigned int markbits = lspace->mark_table[word_index];
-  return markbits & (1<<bit_offset_in_word);
-}
-
-Boolean lspace_mark_object(Lspace* lspace, Partial_Reveal_Object* p_obj);
+  SlotVector* reloc_table;
+
+}Lspace;
+
+void lspace_initialize(GC* gc, void* reserved_base, unsigned int lspace_size);
+void lspace_destruct(Lspace* lspace);
+Managed_Object_Handle lspace_alloc(unsigned int size, Allocator* allocator);
+void lspace_collection(Lspace* lspace);
+
+inline unsigned int lspace_free_memory_size(Lspace* lspace){ /* FIXME:: */ return 0; }
+
+/* The assumption is the offset below is always aligned at word size, because both numbers are aligned */
+#define ADDRESS_OFFSET_IN_LSPACE_BODY(lspace, p_obj) ((unsigned int)p_obj - (unsigned int)space_heap_start((Space*)lspace))
+#define OBJECT_BIT_INDEX_TO_LSPACE_MARKBIT_TABLE(lspace, p_obj)    (ADDRESS_OFFSET_IN_LSPACE_BODY(lspace, p_obj) >> BIT_SHIFT_TO_KILO)
+#define OBJECT_WORD_INDEX_TO_LSPACE_MARKBIT_TABLE(lspace, p_obj)   (OBJECT_BIT_INDEX_TO_LSPACE_MARKBIT_TABLE(lspace, p_obj) >> BIT_SHIFT_TO_BITS_PER_WORD)
+#define OBJECT_WORD_OFFSET_IN_LSPACE_MARKBIT_TABLE(lspace, p_obj)  (OBJECT_BIT_INDEX_TO_LSPACE_MARKBIT_TABLE(lspace, p_obj) & BIT_MASK_TO_BITS_PER_WORD)
+
+inline Boolean lspace_object_is_marked(Lspace* lspace, Partial_Reveal_Object* p_obj)
+{
+  assert( obj_belongs_to_space(p_obj, (Space*)lspace));
+  unsigned int word_index = OBJECT_WORD_INDEX_TO_LSPACE_MARKBIT_TABLE(lspace, p_obj);
+  unsigned int bit_offset_in_word = OBJECT_WORD_OFFSET_IN_LSPACE_MARKBIT_TABLE(lspace, p_obj);
+ 
+  unsigned int markbits = lspace->mark_table[word_index];
+  return markbits & (1<<bit_offset_in_word);
+}
+
+Boolean lspace_mark_object(Lspace* lspace, Partial_Reveal_Object* p_obj);
 void lspace_save_reloc(Lspace* space, Partial_Reveal_Object** p_ref);
-void lspace_update_reloc(Lspace* lspace);
-
-#endif /*_LSPACE_H_ */
\ No newline at end of file
+void lspace_update_reloc(Lspace* lspace);
+
+void reset_lspace_after_copy_nursery(Lspace* lspace);
+
+#endif /*_LSPACE_H_ */

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/thread/collector.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/thread/collector.cpp?view=diff&rev=468252&r1=468251&r2=468252
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/thread/collector.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/thread/collector.cpp Thu Oct 26 20:48:43 2006
@@ -1,196 +1,196 @@
-/*
- *  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 Xiao-Feng Li, 2006/10/05
- */
-
-#include "open/vm_util.h"
-
-#include "collector.h"
-#include "../mark_compact/mspace.h"
-
-static void collector_reset_thread(Collector *collector) 
-{
-  collector->task_func = NULL;
-
-	vm_reset_event(collector->task_assigned_event);
-	vm_reset_event(collector->task_finished_event);
-	
-	alloc_context_reset((Alloc_Context*)collector);
-	
-	return;
-}
-
-static void wait_collector_to_finish(Collector *collector) 
-{
-	vm_wait_event(collector->task_finished_event);
-}
-
-static void notify_collector_to_work(Collector* collector)
-{
-	vm_set_event(collector->task_assigned_event);  
-}
-
-static void collector_wait_for_task(Collector *collector) 
-{
-	vm_wait_event(collector->task_assigned_event);
-}
-
-static void collector_notify_work_done(Collector *collector) 
-{
-	vm_set_event(collector->task_finished_event);
-}
-
-void gc_preprocess_collector(Collector*);
-void gc_postprocess_collector(Collector*);
-static void assign_collector_with_task(GC* gc, TaskType task_func, Space* space)
-{
-  unsigned int num_collectors_to_activate = gc->num_collectors;
-  for(unsigned int i=0; i<num_collectors_to_activate; i++)
-  {
-    Collector* collector = gc->collectors[i];
-    
-    gc_preprocess_collector(collector);
+/*
+ *  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 Xiao-Feng Li, 2006/10/05
+ */
+
+#include "open/vm_util.h"
+
+#include "collector.h"
+#include "../mark_compact/mspace.h"
+
+static void collector_reset_thread(Collector *collector) 
+{
+  collector->task_func = NULL;
+
+	vm_reset_event(collector->task_assigned_event);
+	vm_reset_event(collector->task_finished_event);
+	
+	alloc_context_reset((Allocator*)collector);
+	
+	return;
+}
+
+static void wait_collector_to_finish(Collector *collector) 
+{
+	vm_wait_event(collector->task_finished_event);
+}
+
+static void notify_collector_to_work(Collector* collector)
+{
+	vm_set_event(collector->task_assigned_event);  
+}
+
+static void collector_wait_for_task(Collector *collector) 
+{
+	vm_wait_event(collector->task_assigned_event);
+}
+
+static void collector_notify_work_done(Collector *collector) 
+{
+	vm_set_event(collector->task_finished_event);
+}
+
+void gc_preprocess_collector(Collector*);
+void gc_postprocess_collector(Collector*);
+static void assign_collector_with_task(GC* gc, TaskType task_func, Space* space)
+{
+  unsigned int num_collectors_to_activate = gc->num_collectors;
+  for(unsigned int i=0; i<num_collectors_to_activate; i++)
+  {
+    Collector* collector = gc->collectors[i];
+    
+    gc_preprocess_collector(collector);
     collector_reset_thread(collector);
-    collector->task_func = task_func;
-    collector->collect_space = space;
-    notify_collector_to_work(collector);
-  }
-  gc->num_active_collectors = num_collectors_to_activate;
-
-}
-
-static void wait_collection_finish(GC* gc)
-{
-  unsigned int num_active_collectors = gc->num_active_collectors;
-  for(unsigned int i=0; i<num_active_collectors; i++)
-  {
-    Collector* collector = gc->collectors[i];
-    wait_collector_to_finish(collector);
-    gc_postprocess_collector(collector);
-  }
-  gc->num_active_collectors = 0;
-
-}
-
-static int collector_thread_func(void *arg) 
-{
-	Collector *collector = (Collector *)arg;
-	assert(collector);
-	
-	while(true){
-		/* Waiting for newly assigned task */
-		collector_wait_for_task(collector);	
-		
-		/* waken up and check for new task */
-    TaskType task_func = collector->task_func;
-    if(task_func == NULL) return 1;
-      
-    task_func(collector);
-    
-		collector_notify_work_done(collector);
-	}
-
-	return 0;
-}
-
-static void collector_init_thread(Collector *collector) 
-{
-	collector->trace_stack = new TraceStack(); /* only for MINOR_COLLECTION */
-	collector->mark_stack = new MarkStack(); /* only for MAJOR_COLLECTION */
-
-	collector->last_cycle_remset = new RemslotSet();
-  collector->last_cycle_remset->reserve(GC_NUM_ROOTS_HINT);
-	collector->last_cycle_remset->clear();
-
-	collector->this_cycle_remset = new RemslotSet();
-  collector->this_cycle_remset->reserve(GC_NUM_ROOTS_HINT);
-	collector->this_cycle_remset->clear();
-
-	int status = vm_create_event(&collector->task_assigned_event,0,1);
-	assert(status == THREAD_OK);
-
-	status = vm_create_event(&collector->task_finished_event,0,1);
-	assert(status == THREAD_OK);
-
-	status = (unsigned int)vm_create_thread(NULL,
-                            			0, 0, 0,
-                            			collector_thread_func,
-                            			(void*)collector);
-
-	assert(status == THREAD_OK);
-	
-	return;
-}
-
-static void collector_terminate_thread(Collector* collector)
-{
-  collector->task_func = NULL; /* NULL to notify thread exit */
-	notify_collector_to_work(collector);
-  vm_thread_yield(); /* give collector time to die */
-  
-  delete collector->trace_stack;
-	delete collector->last_cycle_remset;
-	delete collector->this_cycle_remset;
-	
-	return;
-}
-
-void collector_destruct(GC* gc) 
-{
-  for(unsigned int i=0; i<gc->num_collectors; i++)
-  {
-    Collector* collector = gc->collectors[i];
-		collector_terminate_thread(collector);
-  	STD_FREE(collector);
-   
-  }
-  
-  STD_FREE(gc->collectors);
-  return;
-}
-
-struct GC_Gen;
-unsigned int gc_get_processor_num(GC_Gen*);
-void collector_initialize(GC* gc)
-{
- 	unsigned int nthreads = gc_get_processor_num((GC_Gen*)gc);
-	
-	gc->num_collectors = 1; //FIXME:: nthreads;
-	gc->collectors = (Collector **) STD_MALLOC(sizeof(Collector *) * nthreads);	
-	assert(gc->collectors);
-
-	for (unsigned int i = 0; i < nthreads; i++) {
-		Collector* collector = (Collector *)STD_MALLOC(sizeof(Collector));
-		assert(collector);
-		
-		collector->gc = gc;
-		collector_init_thread(collector);
-		
-		gc->collectors[i] = collector;
-	}
-
-  return;
-}
-
-void collector_execute_task(GC* gc, TaskType task_func, Space* space)
-{
+    collector->task_func = task_func;
+    collector->collect_space = space;
+    notify_collector_to_work(collector);
+  }
+  gc->num_active_collectors = num_collectors_to_activate;
+
+}
+
+static void wait_collection_finish(GC* gc)
+{
+  unsigned int num_active_collectors = gc->num_active_collectors;
+  for(unsigned int i=0; i<num_active_collectors; i++)
+  {
+    Collector* collector = gc->collectors[i];
+    wait_collector_to_finish(collector);
+    gc_postprocess_collector(collector);
+  }
+  gc->num_active_collectors = 0;
+
+}
+
+static int collector_thread_func(void *arg) 
+{
+	Collector *collector = (Collector *)arg;
+	assert(collector);
+	
+	while(true){
+		/* Waiting for newly assigned task */
+		collector_wait_for_task(collector);	
+		
+		/* waken up and check for new task */
+    TaskType task_func = collector->task_func;
+    if(task_func == NULL) return 1;
+      
+    task_func(collector);
+    
+		collector_notify_work_done(collector);
+	}
+
+	return 0;
+}
+
+static void collector_init_thread(Collector *collector) 
+{
+	collector->trace_stack = new TraceStack(); /* only for MINOR_COLLECTION */
+	collector->mark_stack = new MarkStack(); /* only for MAJOR_COLLECTION */
+
+	collector->last_cycle_remset = new RemslotSet();
+  collector->last_cycle_remset->reserve(GC_NUM_ROOTS_HINT);
+	collector->last_cycle_remset->clear();
+
+	collector->this_cycle_remset = new RemslotSet();
+  collector->this_cycle_remset->reserve(GC_NUM_ROOTS_HINT);
+	collector->this_cycle_remset->clear();
+
+	int status = vm_create_event(&collector->task_assigned_event,0,1);
+	assert(status == THREAD_OK);
+
+	status = vm_create_event(&collector->task_finished_event,0,1);
+	assert(status == THREAD_OK);
+
+	status = (unsigned int)vm_create_thread(NULL,
+                            			0, 0, 0,
+                            			collector_thread_func,
+                            			(void*)collector);
+
+	assert(status == THREAD_OK);
+	
+	return;
+}
+
+static void collector_terminate_thread(Collector* collector)
+{
+  collector->task_func = NULL; /* NULL to notify thread exit */
+	notify_collector_to_work(collector);
+  vm_thread_yield(); /* give collector time to die */
+  
+  delete collector->trace_stack;
+	delete collector->last_cycle_remset;
+	delete collector->this_cycle_remset;
+	
+	return;
+}
+
+void collector_destruct(GC* gc) 
+{
+  for(unsigned int i=0; i<gc->num_collectors; i++)
+  {
+    Collector* collector = gc->collectors[i];
+		collector_terminate_thread(collector);
+  	STD_FREE(collector);
+   
+  }
+  
+  STD_FREE(gc->collectors);
+  return;
+}
+
+struct GC_Gen;
+unsigned int gc_get_processor_num(GC_Gen*);
+void collector_initialize(GC* gc)
+{
+ 	unsigned int nthreads = gc_get_processor_num((GC_Gen*)gc);
+	
+	gc->num_collectors = 1; //FIXME:: nthreads;
+	gc->collectors = (Collector **) STD_MALLOC(sizeof(Collector *) * nthreads);	
+	assert(gc->collectors);
+
+	for (unsigned int i = 0; i < nthreads; i++) {
+		Collector* collector = (Collector *)STD_MALLOC(sizeof(Collector));
+		assert(collector);
+		
+		collector->gc = gc;
+		collector_init_thread(collector);
+		
+		gc->collectors[i] = collector;
+	}
+
+  return;
+}
+
+void collector_execute_task(GC* gc, TaskType task_func, Space* space)
+{
   assign_collector_with_task(gc, task_func, space);
-  wait_collection_finish(gc);
-  
+  wait_collection_finish(gc);
+  
   return;
-}
+}

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/thread/collector.h
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/thread/collector.h?view=diff&rev=468252&r1=468251&r2=468252
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/thread/collector.h (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/thread/collector.h Thu Oct 26 20:48:43 2006
@@ -1,59 +1,59 @@
-/*
- *  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 Xiao-Feng Li, 2006/10/05
- */
-
-#ifndef _COLLECTOR_H_
-#define _COLLECTOR_H_
-
-#include "../common/gc_common.h"
-
-typedef struct Collector{
-  /* <-- first couple of fields are overloaded as Alloc_Context */
-  void *free;
-  void *ceiling;
-  void *curr_alloc_block;
-  Space* alloc_space;
-  GC* gc;
-  VmThreadHandle thread_handle;   /* This thread; */
-  /* End of Alloc_Context --> */
-
-  Space* collect_space;
-  /* collector has remsets to remember those stored during copying */  
-  RemslotSet* last_cycle_remset;   /* remembered in last cycle, used in this cycle as roots */
-  RemslotSet* this_cycle_remset;   /* remembered in this cycle, will switch with last_remslot */
-
-  TraceStack *trace_stack;
-  MarkStack *mark_stack;
-  
-  VmEventHandle task_assigned_event;
-  VmEventHandle task_finished_event;
-  
-  void(*task_func)(void*) ;   /* current task */
- 
-}Collector;
-
-void collector_destruct(GC* gc);
-void collector_initialize(GC* gc);
-void collector_reset(GC* gc);
-
-void collector_execute_task(GC* gc, TaskType task_func, Space* space);
-
-Partial_Reveal_Object* collector_forward_object(Collector* collector, Partial_Reveal_Object* p_obj);
-
-#endif //#ifndef _COLLECTOR_H_
+/*
+ *  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 Xiao-Feng Li, 2006/10/05
+ */
+
+#ifndef _COLLECTOR_H_
+#define _COLLECTOR_H_
+
+#include "../common/gc_common.h"
+
+typedef struct Collector{
+  /* <-- first couple of fields are overloaded as Allocator */
+  void *free;
+  void *ceiling;
+  void *alloc_block;
+  Space* alloc_space;
+  GC* gc;
+  VmThreadHandle thread_handle;   /* This thread; */
+  /* End of Allocator --> */
+
+  Space* collect_space;
+  /* collector has remsets to remember those stored during copying */  
+  RemslotSet* last_cycle_remset;   /* remembered in last cycle, used in this cycle as roots */
+  RemslotSet* this_cycle_remset;   /* remembered in this cycle, will switch with last_remslot */
+
+  TraceStack *trace_stack;
+  MarkStack *mark_stack;
+  
+  VmEventHandle task_assigned_event;
+  VmEventHandle task_finished_event;
+  
+  void(*task_func)(void*) ;   /* current task */
+ 
+}Collector;
+
+void collector_destruct(GC* gc);
+void collector_initialize(GC* gc);
+void collector_reset(GC* gc);
+
+void collector_execute_task(GC* gc, TaskType task_func, Space* space);
+
+Partial_Reveal_Object* collector_forward_object(Collector* collector, Partial_Reveal_Object* p_obj);
+
+#endif //#ifndef _COLLECTOR_H_

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/thread/collector_alloc.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/thread/collector_alloc.cpp?view=diff&rev=468252&r1=468251&r2=468252
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/thread/collector_alloc.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/thread/collector_alloc.cpp Thu Oct 26 20:48:43 2006
@@ -1,57 +1,57 @@
-/*
- *  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 Xiao-Feng Li, 2006/10/05
- */
-
-#include "thread_alloc.h"
-
-void* mos_alloc(unsigned size, Alloc_Context *alloc_ctx);
-
-/* NOS forward obj to MOS in MINOR_COLLECTION */
-Partial_Reveal_Object* collector_forward_object(Collector* collector, Partial_Reveal_Object* p_obj)
-{
-  Partial_Reveal_VTable* vt = obj_get_vtraw(p_obj);
-
-  /* forwarded by somebody else */
-  if ((unsigned int)vt & FORWARDING_BIT_MASK){
-     assert(!obj_is_marked_in_vt(p_obj));
-     return NULL;
-  }
-    
-  /* else, take the obj by setting the forwarding flag atomically 
-     we don't put a simple bit in vt because we need compute obj size later. */
-  if ((unsigned int)vt != atomic_cas32((unsigned int*)obj_get_vtraw_addr(p_obj), ((unsigned int)vt|FORWARDING_BIT_MASK), (unsigned int)vt)) {
-    /* forwarded by other */
-    assert( obj_is_forwarded_in_vt(p_obj) && !obj_is_marked_in_vt(p_obj));
-    return NULL;
-  }
-
-  /* we hold the object, now forward it */
-  unsigned int size = vm_object_size(p_obj);
-  Partial_Reveal_Object* p_targ_obj = (Partial_Reveal_Object*)mos_alloc(size, (Alloc_Context*)collector);  
-  /* mos should always has enough space to hold nos during collection */
-  assert(p_targ_obj); 
-  memcpy(p_targ_obj, p_obj, size);
-
-  /* because p_obj has forwarding flag in its vt, we set it here */
-  obj_set_forwarding_pointer_in_vt(p_obj, p_targ_obj);
-  obj_set_vt(p_targ_obj, (Allocation_Handle)vt);
+/*
+ *  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 Xiao-Feng Li, 2006/10/05
+ */
+
+#include "thread_alloc.h"
+
+void* mos_alloc(unsigned size, Allocator *allocator);
+
+/* NOS forward obj to MOS in MINOR_COLLECTION */
+Partial_Reveal_Object* collector_forward_object(Collector* collector, Partial_Reveal_Object* p_obj)
+{
+  Partial_Reveal_VTable* vt = obj_get_vtraw(p_obj);
+
+  /* forwarded by somebody else */
+  if ((unsigned int)vt & FORWARDING_BIT_MASK){
+     assert(!obj_is_marked_in_vt(p_obj));
+     return NULL;
+  }
+    
+  /* else, take the obj by setting the forwarding flag atomically 
+     we don't put a simple bit in vt because we need compute obj size later. */
+  if ((unsigned int)vt != atomic_cas32((unsigned int*)obj_get_vtraw_addr(p_obj), ((unsigned int)vt|FORWARDING_BIT_MASK), (unsigned int)vt)) {
+    /* forwarded by other */
+    assert( obj_is_forwarded_in_vt(p_obj) && !obj_is_marked_in_vt(p_obj));
+    return NULL;
+  }
+
+  /* we hold the object, now forward it */
+  unsigned int size = vm_object_size(p_obj);
+  Partial_Reveal_Object* p_targ_obj = (Partial_Reveal_Object*)mos_alloc(size, (Allocator*)collector);  
+  /* mos should always has enough space to hold nos during collection */
+  assert(p_targ_obj); 
+  memcpy(p_targ_obj, p_obj, size);
+
+  /* because p_obj has forwarding flag in its vt, we set it here */
+  obj_set_forwarding_pointer_in_vt(p_obj, p_targ_obj);
+  obj_set_vt(p_targ_obj, (Allocation_Handle)vt);
   
   return p_targ_obj;  
- 
-}
\ No newline at end of file
+ 
+}

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/thread/mutator.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/thread/mutator.cpp?view=diff&rev=468252&r1=468251&r2=468252
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/thread/mutator.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/thread/mutator.cpp Thu Oct 26 20:48:43 2006
@@ -1,85 +1,79 @@
-/*
- *  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 Xiao-Feng Li, 2006/10/05
- */
-
-#include "mutator.h"
-#include "../trace_forward/fspace.h"
-
-struct GC_Gen;
-Space* gc_get_nos(GC_Gen* gc);
-void mutator_initialize(GC* gc, void *gc_information) 
-{
-  /* FIXME:: NOTE: gc_info is uncleared */
-  Mutator *mutator = (Mutator *) gc_information;
-  mutator->free = NULL;
-  mutator->ceiling = NULL;
-  mutator->curr_alloc_block = NULL;
-  mutator->alloc_space = gc_get_nos((GC_Gen*)gc);
-  mutator->gc = gc;
-  
-  assert(mutator->remslot == NULL);
-  mutator->remslot = new RemslotSet();
-  mutator->remslot->clear();
-    
-  assert(mutator->remobj == NULL);
-  mutator->remobj = new RemobjSet();
-  mutator->remobj->clear();
-
-  lock(gc->mutator_list_lock);     // vvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
-
-  mutator->next = (Mutator *)gc->mutator_list;
-  gc->mutator_list = mutator;
-
-  unlock(gc->mutator_list_lock); // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-  
-  gc->num_mutators++;
-  return;
-}
-
-void mutator_destruct(GC* gc, void *gc_information)
-{
-
-  Mutator *mutator = (Mutator *)gc_information;
-
-  lock(gc->mutator_list_lock);     // vvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
-
-  Fspace* fspace = (Fspace*)mutator->alloc_space;
-  fspace->remslot_sets->push_back(mutator->remslot);
-  mutator->remslot = NULL;
-  fspace->remobj_sets->push_back(mutator->remobj);
-  mutator->remobj = NULL;
-
-  volatile Mutator *temp = gc->mutator_list;
-  if (temp == mutator) {  /* it is at the head of the list */
-    gc->mutator_list = temp->next;
-  } else {
-    while (temp->next != mutator) {
-      temp = temp->next;
-      assert(temp);
-    }
-    temp->next = mutator->next;
-  }
-
-  unlock(gc->mutator_list_lock); // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-  gc->num_mutators--;
-  return;
-}
-
-
+/*
+ *  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 Xiao-Feng Li, 2006/10/05
+ */
+
+#include "mutator.h"
+#include "../trace_forward/fspace.h"
+
+struct GC_Gen;
+Space* gc_get_nos(GC_Gen* gc);
+void mutator_initialize(GC* gc, void *gc_information) 
+{
+  /* FIXME:: NOTE: gc_info is uncleared */
+  Mutator *mutator = (Mutator *) gc_information;
+  mutator->free = NULL;
+  mutator->ceiling = NULL;
+  mutator->alloc_block = NULL;
+  mutator->alloc_space = gc_get_nos((GC_Gen*)gc);
+  mutator->gc = gc;
+  
+  assert(mutator->remslot == NULL);
+  mutator->remslot = new RemslotSet();
+  mutator->remslot->clear();
+    
+  lock(gc->mutator_list_lock);     // vvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
+
+  mutator->next = (Mutator *)gc->mutator_list;
+  gc->mutator_list = mutator;
+
+  unlock(gc->mutator_list_lock); // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+  
+  gc->num_mutators++;
+  return;
+}
+
+void mutator_destruct(GC* gc, void *gc_information)
+{
+
+  Mutator *mutator = (Mutator *)gc_information;
+
+  lock(gc->mutator_list_lock);     // vvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
+
+  Fspace* fspace = (Fspace*)mutator->alloc_space;
+  fspace->remslot_sets->push_back(mutator->remslot);
+  mutator->remslot = NULL;
+
+  volatile Mutator *temp = gc->mutator_list;
+  if (temp == mutator) {  /* it is at the head of the list */
+    gc->mutator_list = temp->next;
+  } else {
+    while (temp->next != mutator) {
+      temp = temp->next;
+      assert(temp);
+    }
+    temp->next = mutator->next;
+  }
+
+  unlock(gc->mutator_list_lock); // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+  gc->num_mutators--;
+  return;
+}
+
+

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/thread/mutator.h
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/thread/mutator.h?view=diff&rev=468252&r1=468251&r2=468252
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/thread/mutator.h (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/thread/mutator.h Thu Oct 26 20:48:43 2006
@@ -1,46 +1,45 @@
-/*
- *  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 Xiao-Feng Li, 2006/10/05
- */
-
-#ifndef _MUTATOR_H_
-#define _MUTATOR_H_
-
-#include "../common/gc_common.h"
-
-/* Mutator thread local information for GC */
-typedef struct Mutator {
-  /* <-- first couple of fields are overloaded as Alloc_Context */
-	void*	free;
-	void*	ceiling;
-  void* curr_alloc_block;
-  Space* alloc_space;
-  GC* gc;
-  VmThreadHandle thread_handle;   /* This thread; */
-  /* END of Alloc_Context --> */
-  
-  RemslotSet *remslot;
-  RemobjSet *remobj;
-  Mutator *next;  /* The gc info area associated with the next active thread. */
-} Mutator;
-
-void mutator_initialize(GC* gc, void* tls_gc_info);
-void mutator_destruct(GC* gc, void* tls_gc_info); 
-void mutator_reset(GC *gc);
-
-#endif /*ifndef _MUTATOR_H_ */
\ No newline at end of file
+/*
+ *  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 Xiao-Feng Li, 2006/10/05
+ */
+
+#ifndef _MUTATOR_H_
+#define _MUTATOR_H_
+
+#include "../common/gc_common.h"
+
+/* Mutator thread local information for GC */
+typedef struct Mutator {
+  /* <-- first couple of fields are overloaded as Allocator */
+	void*	free;
+	void*	ceiling;
+  void* alloc_block;
+  Space* alloc_space;
+  GC* gc;
+  VmThreadHandle thread_handle;   /* This thread; */
+  /* END of Allocator --> */
+  
+  RemslotSet *remslot;
+  Mutator *next;  /* The gc info area associated with the next active thread. */
+} Mutator;
+
+void mutator_initialize(GC* gc, void* tls_gc_info);
+void mutator_destruct(GC* gc, void* tls_gc_info); 
+void mutator_reset(GC *gc);
+
+#endif /*ifndef _MUTATOR_H_ */

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/thread/mutator_alloc.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/thread/mutator_alloc.cpp?view=diff&rev=468252&r1=468251&r2=468252
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/thread/mutator_alloc.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/thread/mutator_alloc.cpp Thu Oct 26 20:48:43 2006
@@ -32,9 +32,9 @@
   assert(ah);
 
   if ( size > GC_OBJ_SIZE_THRESHOLD )
-    p_obj = (Managed_Object_Handle)los_alloc(size, (Alloc_Context*)gc_tls);
+    p_obj = (Managed_Object_Handle)los_alloc(size, (Allocator*)gc_tls);
   else
-    p_obj = (Managed_Object_Handle)nos_alloc(size, (Alloc_Context*)gc_tls);
+    p_obj = (Managed_Object_Handle)nos_alloc(size, (Allocator*)gc_tls);
   
   assert(p_obj);
   obj_set_vt((Partial_Reveal_Object*)p_obj, ah);
@@ -55,7 +55,7 @@
   
   /* Try to allocate an object from the current Thread Local Block */
   Managed_Object_Handle p_obj = NULL;
-  p_obj = (Managed_Object_Handle)thread_local_alloc(size, (Alloc_Context*)gc_tls);
+  p_obj = (Managed_Object_Handle)thread_local_alloc(size, (Allocator*)gc_tls);
   if(p_obj == NULL) return NULL;
    
   obj_set_vt((Partial_Reveal_Object*)p_obj, ah);

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/thread/thread_alloc.h
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/thread/thread_alloc.h?view=diff&rev=468252&r1=468251&r2=468252
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/thread/thread_alloc.h (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/thread/thread_alloc.h Thu Oct 26 20:48:43 2006
@@ -21,37 +21,37 @@
 #ifndef _THREAD_ALLOC_H_
 #define _THREAD_ALLOC_H_
 
-#include "../common/gc_common.h"
+#include "../common/gc_block.h"
 
-typedef struct Alloc_Context{
+typedef struct Allocator{
   void *free;
   void *ceiling;
-  void *curr_alloc_block;
+  Block *alloc_block;
   Space* alloc_space;
   GC   *gc;
   VmThreadHandle thread_handle;   /* This thread; */
-}Alloc_Context;
+}Allocator;
 
-inline Partial_Reveal_Object* thread_local_alloc(unsigned int size, Alloc_Context* alloc_ctx)
+inline Partial_Reveal_Object* thread_local_alloc(unsigned int size, Allocator* allocator)
 {
-    Partial_Reveal_Object* p_return_obj=(Partial_Reveal_Object*)alloc_ctx->free;
+    Partial_Reveal_Object* p_return_obj=(Partial_Reveal_Object*)allocator->free;
     unsigned int new_free = size+(unsigned int)p_return_obj;
 		    
-    if (new_free <= (unsigned int)alloc_ctx->ceiling){
-    	alloc_ctx->free=(void*)new_free;
+    if (new_free <= (unsigned int)allocator->ceiling){
+    	allocator->free=(void*)new_free;
     	return p_return_obj;
     }
 
     return NULL;
 }
 
-inline void alloc_context_reset(Alloc_Context* alloc_ctx)
+inline void alloc_context_reset(Allocator* allocator)
 {
-  alloc_ctx->free = NULL;
-  alloc_ctx->ceiling = NULL;
-  alloc_ctx->curr_alloc_block = NULL;
+  allocator->free = NULL;
+  allocator->ceiling = NULL;
+  allocator->alloc_block = NULL;
   
   return;
 }
 
-#endif /* #ifndef _THREAD_ALLOC_H_ */
\ No newline at end of file
+#endif /* #ifndef _THREAD_ALLOC_H_ */

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/trace_forward/fspace.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/trace_forward/fspace.cpp?view=diff&rev=468252&r1=468251&r2=468252
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/trace_forward/fspace.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/trace_forward/fspace.cpp Thu Oct 26 20:48:43 2006
@@ -30,13 +30,107 @@
 Boolean forward_first_half;;
 void* object_forwarding_boundary=NULL;
 
+void fspace_save_reloc(Fspace* fspace, Partial_Reveal_Object** p_ref)
+{
+  Block_Header* block = GC_BLOCK_HEADER(p_ref);
+  block->reloc_table->push_back(p_ref);
+  return;
+}
 
-void fspace_destruct(Fspace *fspace) 
+void  fspace_update_reloc(Fspace* fspace)
 {
-  port_vmem_decommit(fspace->heap_start, fspace->committed_heap_size, fspace->gc->allocated_memory);
-  STD_FREE(fspace->mark_table);
-  STD_FREE(fspace);  
- 
+  SlotVector* reloc_table;
+  /* update refs in fspace */
+  Block* blocks = fspace->blocks;
+  for(unsigned int i=0; i < fspace->num_managed_blocks; i++){
+    Block_Header* block = (Block_Header*)&(blocks[i]);
+    reloc_table = block->reloc_table;
+    for(unsigned int j=0; j < reloc_table->size(); j++){
+      Partial_Reveal_Object** p_ref = (*reloc_table)[j];
+      Partial_Reveal_Object* p_target_obj = get_forwarding_pointer_in_obj_info(*p_ref);
+      *p_ref = p_target_obj;
+    }
+    reloc_table->clear();
+  }
+  
+  return;  
+}  
+
+Boolean fspace_mark_object(Fspace* fspace, Partial_Reveal_Object *p_obj)
+{  
+  obj_mark_in_vt(p_obj);
+
+  unsigned int obj_word_index = OBJECT_WORD_INDEX_TO_MARKBIT_TABLE(p_obj);
+  unsigned int obj_offset_in_word = OBJECT_WORD_OFFSET_IN_MARKBIT_TABLE(p_obj); 	
+	
+  unsigned int *p_word = &(GC_BLOCK_HEADER(p_obj)->mark_table[obj_word_index]);
+  unsigned int word_mask = (1<<obj_offset_in_word);
+	
+  unsigned int result = (*p_word)|word_mask;
+	
+  if( result==(*p_word) ) return FALSE;
+  
+  *p_word = result; 
+  
+   return TRUE;
+}
+
+Boolean fspace_object_is_marked(Partial_Reveal_Object *p_obj, Fspace* fspace)
+{
+  assert(p_obj);
+  
+#ifdef _DEBUG //TODO:: Cleanup
+  unsigned int obj_word_index = OBJECT_WORD_INDEX_TO_MARKBIT_TABLE(p_obj);
+  unsigned int obj_offset_in_word = OBJECT_WORD_OFFSET_IN_MARKBIT_TABLE(p_obj); 	
+	
+  unsigned int *p_word = &(GC_BLOCK_HEADER(p_obj)->mark_table[obj_word_index]);
+  unsigned int word_mask = (1<<obj_offset_in_word);
+	
+  unsigned int result = (*p_word)|word_mask;
+	
+  if( result==(*p_word) )
+    assert( obj_is_marked_in_vt(p_obj));
+  else 
+    assert(!obj_is_marked_in_vt(p_obj));
+    
+#endif
+
+  return (obj_is_marked_in_vt(p_obj));
+    
+}
+
+static void fspace_destruct_blocks(Fspace* fspace)
+{ 
+  Block* blocks = (Block*)fspace->blocks; 
+  for(unsigned int i=0; i < fspace->num_managed_blocks; i++){
+    Block_Header* block = (Block_Header*)&(blocks[i]);
+    delete block->reloc_table;
+    block->reloc_table = NULL;
+  }
+  
+  return;
+}
+
+static void fspace_init_blocks(Fspace* fspace)
+{ 
+  Block* blocks = (Block*)fspace->heap_start; 
+  Block_Header* last_block = (Block_Header*)blocks;
+  unsigned int start_idx = fspace->first_block_idx;
+  for(unsigned int i=0; i < fspace->num_managed_blocks; i++){
+    Block_Header* block = (Block_Header*)&(blocks[i]);
+    block->free = (void*)((unsigned int)block + GC_BLOCK_HEADER_SIZE_BYTES);
+    block->ceiling = (void*)((unsigned int)block + GC_BLOCK_SIZE_BYTES); 
+    block->base = block->free;
+    block->block_idx = i + start_idx;
+    block->status = BLOCK_FREE;  
+    block->reloc_table = new SlotVector();
+    last_block->next = block;
+    last_block = block;
+  }
+  last_block->next = NULL;
+  fspace->blocks = blocks;
+   
+  return;
 }
 
 struct GC_Gen;
@@ -47,133 +141,109 @@
   Fspace* fspace = (Fspace *)STD_MALLOC(sizeof(Fspace));
   assert(fspace);
   memset(fspace, 0, sizeof(Fspace));
+    
+  fspace->reserved_heap_size = fspace_size;
+  fspace->num_total_blocks = fspace_size >> GC_BLOCK_SHIFT_COUNT;
 
   void* reserved_base = start;
   int status = port_vmem_commit(&reserved_base, fspace_size, gc->allocated_memory); 
   assert(status == APR_SUCCESS && reserved_base == start);
-  
+    
   memset(reserved_base, 0, fspace_size);
-
-  fspace->block_size_bytes = GC_BLOCK_SIZE_BYTES;
-  fspace->committed_heap_size = fspace->reserved_heap_size = fspace_size;
+  fspace->committed_heap_size = fspace_size;
+  fspace->heap_start = reserved_base;
+  fspace->heap_end = (void *)((unsigned int)reserved_base + fspace->reserved_heap_size);
+  fspace->num_managed_blocks = fspace_size >> GC_BLOCK_SHIFT_COUNT;
   
-  fspace->heap_start = (void *)start;
-  fspace->heap_end = (void *)((POINTER_SIZE_INT) start + fspace_size);
-
-  fspace->num_collections = 0;
-    
-  fspace->alloc_free = fspace->heap_start;
-  fspace->alloc_ceiling = fspace->heap_end;
-  forward_first_half = TRUE;
-  object_forwarding_boundary = (void *)((((POINTER_SIZE_INT)start + (unsigned int)(fspace_size*NURSERY_OBJECT_FORWARDING_RATIO))>>7)<<7);
-
-  /* mark_table: 1. MAJOR_COLLECTION mark and copy nursery, 2. MINOR_COLLECTION mark non-forwarded part */
-  fspace->mark_table_size = fspace_size>>5;
-  fspace->mark_table = (unsigned int*)STD_MALLOC(fspace->mark_table_size); 
-  fspace->mark_table_half_boundary = fspace->mark_table + (((unsigned int)(fspace_size*NURSERY_OBJECT_FORWARDING_RATIO))>>7);
-  memset(fspace->mark_table, 0, fspace->mark_table_size);
-
+  fspace->first_block_idx = GC_BLOCK_INDEX_FROM(gc->heap_start, reserved_base);
+  fspace->ceiling_block_idx = fspace->first_block_idx + fspace->num_managed_blocks - 1;
+  
+  fspace->num_used_blocks = 0;
+  fspace->free_block_idx = fspace->first_block_idx;
+  
+  fspace_init_blocks(fspace);
+  
+  fspace->obj_info_map = new ObjectMap();
   fspace->mark_object_func = fspace_mark_object;
   fspace->save_reloc_func = fspace_save_reloc;
   fspace->update_reloc_func = fspace_update_reloc;
 
-  fspace->remslot_sets = new std::vector<RemslotSet *>();
-  fspace->remobj_sets = new std::vector<RemobjSet *>();
-  fspace->rem_sets_lock = FREE_LOCK;
-
-  fspace->reloc_table = new SlotVector();
-  fspace->obj_info_map = new ObjectMap();
-
   fspace->move_object = TRUE;
+  fspace->num_collections = 0;
   fspace->gc = gc;
   gc_set_nos((GC_Gen*)gc, (Space*)fspace);
+  /* above is same as Mspace init --> */
+  
+  fspace->remslot_sets = new std::vector<RemslotSet *>();
+  fspace->rem_sets_lock = FREE_LOCK;
 
   nos_boundary = fspace->heap_end;
 
-  return;
-}
-
-Boolean fspace_mark_object(Fspace* fspace, Partial_Reveal_Object *p_obj)
-{
-  assert(obj_belongs_to_space(p_obj, (Space*)fspace));
-  
-  //offset in byte
-  unsigned int offset = (POINTER_SIZE_INT)p_obj - (POINTER_SIZE_INT)fspace->heap_start; 
-  assert( ((offset>>2)<<2)==offset);
-  
-  offset >>= 2; //offset in word
-  unsigned int bit_off_in_word = offset - ((offset>>5)<<5);
-  unsigned int* pos = fspace->mark_table + (offset>>5);
-
-  if( NURSERY_OBJECT_FORWARDING_RATIO != FORWARD_ALL && fspace->gc->collect_kind != MAJOR_COLLECTION )
-    assert(forward_first_half?(pos >= fspace->mark_table_half_boundary):(pos<fspace->mark_table_half_boundary));
-  
-  unsigned int word = *pos;
-  unsigned int result = word | (1<<bit_off_in_word);
-  if(word == result) return FALSE;
+  forward_first_half = TRUE;
+  object_forwarding_boundary = (void*)&fspace->blocks[fspace->first_block_idx + (unsigned int)(fspace->num_managed_blocks * NURSERY_OBJECT_FORWARDING_RATIO)];
 
-  *pos = result;
-  obj_mark_in_vt(p_obj);
-  
-  return TRUE;
+  return;
 }
 
-void fspace_clear_mark_bits(Fspace* fspace)
+void fspace_destruct(Fspace *fspace) 
 {
-  unsigned int* mark_table = fspace->mark_table;
-  unsigned int* fspace_marked_half = (unsigned int*)fspace->heap_start;
-  unsigned int* table_end = fspace->mark_table_half_boundary;
-  Partial_Reveal_Object* p_obj = NULL;
-  
-  if( forward_first_half ){
-    //forward frist half, so the second half is marked
-    table_end = (unsigned int*)((POINTER_SIZE_INT)mark_table + fspace->mark_table_size);
-    mark_table = fspace->mark_table_half_boundary; 
-    fspace_marked_half = (unsigned int*)object_forwarding_boundary;
-  }
-  
-  unsigned j=0;
-  while( (mark_table + j) < table_end){
-    unsigned int markbits = *(mark_table+j);
-    if(!markbits){ j++; continue; }
-    unsigned int k=0;
-    while(k<32){
-      if( !(markbits& (1<<k)) ){ k++; continue;}
-      p_obj = (Partial_Reveal_Object*)(fspace_marked_half + (j<<5) + k);
-      
-      Partial_Reveal_VTable* vt = obj_get_vtraw(p_obj);
-      Allocation_Handle ah = (Allocation_Handle)vt;
-      assert(!(ah & FORWARDING_BIT_MASK));
-      assert(ah & MARK_BIT_MASK);
-      
-      obj_unmark_in_vt(p_obj);
-      //*(mark_table+j) &= ~(1<<k); //we do it in chunck
-      
-      k++;
-    }   
-    j++;;
-  }
-
-  memset(mark_table, 0, (POINTER_SIZE_INT)table_end-(POINTER_SIZE_INT)mark_table);
+  fspace_destruct_blocks(fspace);
+  port_vmem_decommit(fspace->heap_start, fspace->committed_heap_size, fspace->gc->allocated_memory);
+  STD_FREE(fspace);  
+ 
 }
  
 void reset_fspace_for_allocation(Fspace* fspace)
 { 
   if( NURSERY_OBJECT_FORWARDING_RATIO == FORWARD_ALL ||
-            fspace->gc->collect_kind == MAJOR_COLLECTION ){
-    fspace->alloc_free = fspace->heap_start;
-    fspace->alloc_ceiling = fspace->heap_end;    
+            fspace->gc->collect_kind == MAJOR_COLLECTION )
+  {
+    fspace->free_block_idx = fspace->first_block_idx;
+    fspace->ceiling_block_idx = fspace->first_block_idx + fspace->num_managed_blocks - 1;  
     forward_first_half = TRUE; /* only useful for not-FORWARD_ALL*/
   }else{    
     if(forward_first_half){
-      fspace->alloc_free = fspace->heap_start;
-      fspace->alloc_ceiling = object_forwarding_boundary;
+      fspace->free_block_idx = fspace->first_block_idx;
+      fspace->ceiling_block_idx = ((Block_Header*)object_forwarding_boundary)->block_idx - 1;
     }else{
-      fspace->alloc_free = object_forwarding_boundary;
-      fspace->alloc_ceiling = fspace->heap_end;
+      fspace->free_block_idx = ((Block_Header*)object_forwarding_boundary)->block_idx;
+      fspace->ceiling_block_idx = fspace->first_block_idx + fspace->num_managed_blocks - 1;
     }
     forward_first_half = ~forward_first_half;
-    /* clear all the marking bits of the remaining objects in fspace */
-    fspace_clear_mark_bits(fspace); 
   }
+
+  unsigned int first_idx = fspace->free_block_idx;
+  unsigned int last_idx = fspace->ceiling_block_idx;
+  Block* blocks = fspace->blocks;
+  unsigned int num_freed = 0;
+  for(unsigned int i = first_idx; i <= last_idx; i++){
+    Block_Header* block = (Block_Header*)&(blocks[i]);
+    if(block->status == BLOCK_FREE) continue;
+    block_clear_mark_table(block); 
+    block->status = BLOCK_FREE; 
+    block->free = GC_BLOCK_BODY(block);
+    num_freed ++;
+  }
+  fspace->num_used_blocks = fspace->num_used_blocks - num_freed;
+
+}
+
+void collector_execute_task(GC* gc, TaskType task_func, Space* space);
+
+/* world is stopped when starting fspace_collection */      
+void fspace_collection(Fspace *fspace)
+{
+  fspace->num_collections++;  
+  
+  GC* gc = fspace->gc;
+
+  if(gc_requires_barriers()){ 
+    /* generational GC. Only trace (mark) nos */
+    collector_execute_task(gc, (TaskType)trace_forward_fspace, (Space*)fspace);
+  }else{
+    /* non-generational GC. Mark the whole heap (nos, mos, and los) */
+    collector_execute_task(gc, (TaskType)mark_copy_fspace, (Space*)fspace);
+  }
+  
+  return; 
 }

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/trace_forward/fspace.h
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/trace_forward/fspace.h?view=diff&rev=468252&r1=468251&r2=468252
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/trace_forward/fspace.h (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/trace_forward/fspace.h Thu Oct 26 20:48:43 2006
@@ -47,60 +47,57 @@
   void (*save_reloc_func)(Fspace* space, Partial_Reveal_Object** p_ref);
   void (*update_reloc_func)(Fspace* space);
   /* END of Space --> */
-    
-  /* places to start and stop alloc */
-  volatile void* alloc_free;
-  void* alloc_ceiling;
-    
-  unsigned int block_size_bytes;
+
+  Block* blocks; /* short-cut for mpsace blockheader access, not mandatory */
   
-  unsigned int* mark_table; //table to keep mark_bits of fspace
-  unsigned int mark_table_size;
-  unsigned int* mark_table_half_boundary;
+  /* FIXME:: the block indices should be replaced with block header addresses */
+  unsigned int first_block_idx;
+  unsigned int ceiling_block_idx;
+  volatile unsigned int free_block_idx;
   
+  unsigned int num_used_blocks;
+  unsigned int num_managed_blocks;
+  unsigned int num_total_blocks;
+
+  /* during compaction, save non-zero obj_info who's overwritten by forwarding pointer */
+  ObjectMap*  obj_info_map; 
+  /* END of Blocked_Space --> */
+    
   /* saved remsets of collectors */
   /* saved remsets of exited mutators */
   std::vector<RemslotSet *> *remslot_sets;
-  std::vector<RemobjSet *> *remobj_sets;
   SpinLock rem_sets_lock;
-
-  /* support other space moving collection */
-  SlotVector* reloc_table;
-  ObjectMap*  obj_info_map; 
   
 } Fspace;
 
 void fspace_initialize(GC* gc, void* start, unsigned int fspace_size);
 void fspace_destruct(Fspace *fspace);
 
-inline unsigned int fspace_free_memory_size(Fspace* fspace)
-{ return (unsigned int)fspace->alloc_ceiling - (unsigned int)fspace->alloc_free; }
+inline Boolean fspace_has_free_block(Fspace* fspace){ return fspace->free_block_idx <= fspace->ceiling_block_idx; }
+inline unsigned int fspace_free_memory_size(Fspace* fspace){ return GC_BLOCK_SIZE_BYTES * (fspace->ceiling_block_idx - fspace->free_block_idx + 1);  }
+inline Boolean fspace_used_memory_size(Fspace* fspace){ return GC_BLOCK_SIZE_BYTES * fspace->num_used_blocks; }
 
-inline unsigned int fspace_used_memory_size(Fspace* fspace)
-{ return (unsigned int)fspace->alloc_free - (unsigned int)fspace->heap_start; }
 
-void* fspace_alloc(unsigned size, Alloc_Context *alloc_ctx);
+void* fspace_alloc(unsigned size, Allocator *allocator);
 
 Boolean fspace_mark_object(Fspace* fspace, Partial_Reveal_Object *p_obj);
-void fspace_clear_mark_bits(Fspace* fspace);
-
 void fspace_save_reloc(Fspace* fspace, Partial_Reveal_Object** p_ref);
 void fspace_update_reloc(Fspace* fspace);
-void fspace_restore_obj_info(Fspace* fspace);
+void reset_fspace_for_allocation(Fspace* fspace);
+
+inline Block_Header* fspace_get_first_copy_block(Fspace* fspace)
+{  return (Block_Header*)fspace->blocks; }
+
+inline Block_Header* fspace_get_next_copy_block(Fspace* fspace, Block_Header* block)
+{  return block->next; }
+
+
+Boolean fspace_compute_object_target(Collector* collector, Fspace* fspace);
 void fspace_copy_collect(Collector* collector, Fspace* fspace); 
-void space_copy_remset_slots(Fspace* space, RootSet* copy_rootset);
-void space_update_remsets(Fspace* space);
 
-void fspace_collection(Fspace* fspace);
-void reset_fspace_for_allocation(Fspace* fspace);
+void trace_forward_fspace(Collector* collector); 
+void mark_copy_fspace(Collector* collector); 
 
-inline unsigned int fspace_allocated_size(Fspace* fspace)
-{ 
-  return (unsigned int)fspace->alloc_ceiling - (unsigned int)fspace->alloc_free;
-}
+void fspace_collection(Fspace* fspace);
   
-inline Boolean fspace_has_free_block(Fspace* fspace)
-{
-  return ((POINTER_SIZE_INT)fspace->alloc_free + fspace->block_size_bytes) <= (POINTER_SIZE_INT)fspace->alloc_ceiling;  
-}
 #endif // _FROM_SPACE_H_

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/trace_forward/fspace_alloc.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/trace_forward/fspace_alloc.cpp?view=diff&rev=468252&r1=468251&r2=468252
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/trace_forward/fspace_alloc.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/trace_forward/fspace_alloc.cpp Thu Oct 26 20:48:43 2006
@@ -20,66 +20,71 @@
 
 #include "fspace.h"
 
-static Boolean fspace_alloc_block(Fspace* fspace, Alloc_Context *alloc_ctx)
+static Boolean fspace_alloc_block(Fspace* fspace, Allocator* allocator)
 {
-         
-  void* old_free_pos = (void*)fspace->alloc_free;
-  void* new_free_pos = (void*)((POINTER_SIZE_INT)old_free_pos + fspace->block_size_bytes);
-  while ( fspace_has_free_block(fspace) ){
-    /* There are enough space to hold a TLB in fspace, try to get it */
-    POINTER_SIZE_INT temp = atomic_cas32((volatile uint32 *)&fspace->alloc_free, \
-                            (POINTER_SIZE_INT)new_free_pos, (POINTER_SIZE_INT)old_free_pos);
-      
-    if(temp != (POINTER_SIZE_INT)old_free_pos){
-      old_free_pos = (void*)fspace->alloc_free;
-      new_free_pos = (void*)((POINTER_SIZE_INT)old_free_pos + fspace->block_size_bytes);
+  Block_Header* alloc_block = (Block_Header* )allocator->alloc_block;
+  /* put back the used block */
+  if(alloc_block != NULL){ /* it is NULL at first time */
+    assert(alloc_block->status == BLOCK_IN_USE);
+    alloc_block->status = BLOCK_USED;
+    alloc_block->free = allocator->free;
+  }
+
+  /* now try to get a new block */
+  unsigned int old_free_idx = fspace->free_block_idx;
+  unsigned int new_free_idx = old_free_idx+1;
+  while(old_free_idx <= fspace->ceiling_block_idx){   
+    unsigned int allocated_idx = atomic_cas32(&fspace->free_block_idx, new_free_idx, old_free_idx);
+    if(allocated_idx != old_free_idx){     /* if failed */  
+      old_free_idx = fspace->free_block_idx;
+      new_free_idx = old_free_idx+1;
       continue;
     }
+    /* ok, got one */
+    alloc_block = (Block_Header*)&(fspace->blocks[allocated_idx - fspace->first_block_idx]);
+    assert(alloc_block->status == BLOCK_FREE);
+    alloc_block->status = BLOCK_IN_USE;
+    fspace->num_used_blocks++;
+    memset(alloc_block->free, 0, GC_BLOCK_BODY_SIZE_BYTES);
     
-    alloc_ctx->free = (char*)old_free_pos;
-    alloc_ctx->ceiling = (char*)old_free_pos + fspace->block_size_bytes;
-    memset(old_free_pos, 0, fspace->block_size_bytes);
+    /* set allocation context */
+    allocator->free = alloc_block->free;
+    allocator->ceiling = alloc_block->ceiling;
+    allocator->alloc_block = (Block*)alloc_block; 
     
     return TRUE;
   }
+
+  return FALSE;
   
-  return FALSE;      
 }
+
 /* FIXME:: the collection should be seperated from the alloation */
 struct GC_Gen;
-Space* gc_get_nos(GC_Gen* gc);
 void gc_gen_reclaim_heap(GC_Gen* gc, unsigned int cause);
 
-void* fspace_alloc(unsigned size, Alloc_Context *alloc_ctx) 
+void* fspace_alloc(unsigned size, Allocator *allocator) 
 {
   void*  p_return = NULL;
 
   /* First, try to allocate object from TLB (thread local block) */
-  p_return = thread_local_alloc(size, alloc_ctx);
+  p_return = thread_local_alloc(size, allocator);
   if (p_return)  return p_return;
-  
-  /* grab another TLB */
-  Fspace* fspace = (Fspace*)alloc_ctx->alloc_space;
 
-retry_grab_block:
-  if ( !fspace_has_free_block(fspace)) {    /* can not get a new TLB, activate GC */ 
+  /* ran out local block, grab a new one*/  
+  Fspace* fspace = (Fspace*)allocator->alloc_space;
+  while( !fspace_alloc_block(fspace, allocator)){
     vm_gc_lock_enum();
     /* after holding lock, try if other thread collected already */
     if ( !fspace_has_free_block(fspace) ) {  
-      gc_gen_reclaim_heap((GC_Gen*)alloc_ctx->gc, GC_CAUSE_NOS_IS_FULL); 
+      gc_gen_reclaim_heap((GC_Gen*)allocator->gc, GC_CAUSE_NOS_IS_FULL); 
     }    
     vm_gc_unlock_enum();  
   }
-
-  Boolean ok = fspace_alloc_block(fspace, alloc_ctx);
-  if(ok){
-    p_return = thread_local_alloc(size, alloc_ctx);
-    assert(p_return);              
-    return p_return;
-  }
-
-  /* failed to get a TLB atomically */
-  goto retry_grab_block;
+  
+  p_return = thread_local_alloc(size, allocator);
+  
+  return p_return;
   
 }
 

Added: incubator/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/trace_forward/fspace_collect_copy.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/trace_forward/fspace_collect_copy.cpp?view=auto&rev=468252
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/trace_forward/fspace_collect_copy.cpp (added)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/trace_forward/fspace_collect_copy.cpp Thu Oct 26 20:48:43 2006
@@ -0,0 +1,154 @@
+/*
+ *  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 Xiao-Feng Li, 2006/10/05
+ */
+
+#include "fspace.h"
+#include "../mark_compact/mspace.h"
+#include "../mark_sweep/lspace.h"
+#include "../thread/collector.h"
+
+/* copying of fspace is only for MAJOR_COLLECTION or non-generational partial copy collection */
+static Block_Header* mspace_get_first_target_block_for_nos(Mspace* mspace)
+{  
+  return (Block_Header*)&mspace->blocks[mspace->free_block_idx-mspace->first_block_idx];
+}
+
+static Block_Header* mspace_get_next_target_block_for_nos(Mspace* mspace, Block_Header* block)
+{ return block->next; }
+
+static void fspace_restore_obj_info(Fspace* fspace)
+{
+  ObjectMap* objmap = fspace->obj_info_map;
+  ObjectMap::iterator obj_iter;
+  for( obj_iter=objmap->begin(); obj_iter!=objmap->end(); obj_iter++){
+    Partial_Reveal_Object* p_target_obj = obj_iter->first;
+    Obj_Info_Type obj_info = obj_iter->second;
+    set_obj_info(p_target_obj, obj_info);     
+  }
+  objmap->clear();
+  return;  
+}
+
+struct GC_Gen;
+Space* gc_get_mos(GC_Gen* gc);
+
+Boolean fspace_compute_object_target(Collector* collector, Fspace* fspace)
+{  
+  Mspace* mspace = (Mspace*)gc_get_mos((GC_Gen*)collector->gc);
+  Block_Header* dest_block = mspace_get_first_target_block_for_nos(mspace);    
+  Block_Header* curr_block = fspace_get_first_copy_block(fspace);
+
+  void* dest_addr = GC_BLOCK_BODY(dest_block);
+ 
+  while( curr_block ){
+    unsigned int mark_bit_idx;
+    Partial_Reveal_Object* p_obj = block_get_first_marked_object(curr_block, &mark_bit_idx);
+    
+    while( p_obj ){
+      assert( obj_is_marked_in_vt(p_obj));
+            
+      unsigned int obj_size = vm_object_size(p_obj);
+      
+      if( ((unsigned int)dest_addr + obj_size) > (unsigned int)GC_BLOCK_END(dest_block)){
+        dest_block->free = dest_addr;
+        dest_block = mspace_get_next_target_block_for_nos(mspace, dest_block);
+        if(dest_block == NULL) return FALSE;
+        dest_addr = GC_BLOCK_BODY(dest_block);
+      }
+      assert(((unsigned int)dest_addr + obj_size) <= (unsigned int)GC_BLOCK_END(dest_block));
+      
+      Obj_Info_Type obj_info = get_obj_info(p_obj);
+      if( obj_info != 0 ) {
+        fspace->obj_info_map->insert(ObjectMap::value_type((Partial_Reveal_Object*)dest_addr, obj_info));
+      }
+      set_forwarding_pointer_in_obj_info(p_obj, dest_addr);
+
+      /* FIXME: should use alloc to handle alignment requirement */
+      dest_addr = (void *) WORD_SIZE_ROUND_UP((unsigned int) dest_addr + obj_size);
+      p_obj = block_get_next_marked_object(curr_block, &mark_bit_idx);
+  
+    }
+    curr_block = fspace_get_next_copy_block(fspace, curr_block);
+  }
+  
+  mspace->free_block_idx = dest_block->block_idx+1;
+  
+  return TRUE;
+}   
+
+#include "../verify/verify_live_heap.h"
+
+void fspace_copy_collect(Collector* collector, Fspace* fspace) 
+{  
+  Block_Header* curr_block = fspace_get_first_copy_block(fspace);
+  
+  while( curr_block ){
+    unsigned int mark_bit_idx;
+    Partial_Reveal_Object* p_obj = block_get_first_marked_object(curr_block, &mark_bit_idx);
+    
+    while( p_obj ){
+      assert( obj_is_marked_in_vt(p_obj));
+      obj_unmark_in_vt(p_obj);
+      
+      unsigned int obj_size = vm_object_size(p_obj);
+      Partial_Reveal_Object *p_target_obj = get_forwarding_pointer_in_obj_info(p_obj);
+      memmove(p_target_obj, p_obj, obj_size);
+
+      if (verify_live_heap)
+        /* we forwarded it, we need remember it for verification */
+        event_collector_move_obj(p_obj, p_target_obj, collector);
+
+      set_obj_info(p_target_obj, 0);
+ 
+      p_obj = block_get_next_marked_object(curr_block, &mark_bit_idx);  
+    }
+        
+    curr_block = fspace_get_next_copy_block(fspace, curr_block);
+  }
+  
+  fspace_restore_obj_info(fspace);
+  reset_fspace_for_allocation(fspace);  
+  
+  return;
+}
+
+void gc_gen_update_repointed_refs(Collector* collector);
+
+void mark_copy_fspace(Collector* collector) 
+{  
+  GC* gc = collector->gc;
+  Fspace* fspace = (Fspace*)collector->collect_space;
+  
+  /* FIXME:: Single-threaded mark-copying for fspace currently */
+
+  /* Pass 1: mark all live objects in heap, and save all the slots that 
+             have references  that are going to be repointed */
+  mark_scan_heap(collector);
+
+  /* Pass 2: assign each live fspace object a new location */
+  fspace_compute_object_target(collector, fspace);  
+
+  gc_gen_update_repointed_refs(collector);
+
+  /* FIXME:: Pass 2 and 3 can be merged into one pass */
+  /* Pass 3: copy live fspace object to new location */
+  fspace_copy_collect(collector, fspace);        
+    
+  return;
+}

Added: incubator/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/trace_forward/fspace_collect_forward.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/trace_forward/fspace_collect_forward.cpp?view=auto&rev=468252
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/trace_forward/fspace_collect_forward.cpp (added)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/trace_forward/fspace_collect_forward.cpp Thu Oct 26 20:48:43 2006
@@ -0,0 +1,200 @@
+/*
+ *  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 Xiao-Feng Li, 2006/10/05
+ */
+
+#include "fspace.h"
+#include "../thread/collector.h"
+
+static Boolean fspace_object_to_be_forwarded(Partial_Reveal_Object *p_obj, Fspace *fspace)
+{
+  assert(obj_belongs_to_space(p_obj, (Space*)fspace));  
+  return forward_first_half? (p_obj < object_forwarding_boundary):(p_obj>=object_forwarding_boundary);
+}
+
+static void scan_slot(Collector* collector, Partial_Reveal_Object **p_ref) 
+{
+  Partial_Reveal_Object *p_obj = *p_ref;
+  TraceStack *ts = collector->trace_stack;
+
+  if (p_obj == NULL) return;  
+    
+  /* the slot can be in tspace or fspace, we don't care.
+     we care only if the reference in the slot is pointing to fspace */
+  if (obj_belongs_to_space(p_obj, collector->collect_space)) {
+    ts->push(p_ref);
+  } 
+
+  return;
+}
+
+static void scan_object(Collector* collector, Partial_Reveal_Object *p_obj) 
+{
+  if (!object_has_slots(p_obj)) return;
+  
+  void *slot;
+  
+  /* scan array object */
+  if (object_is_array(p_obj)) {
+    Partial_Reveal_Object* array = p_obj;
+    assert(!obj_is_primitive_array(array));
+    
+    int32 array_length = vector_get_length((Vector_Handle) array);
+    for (int i = 0; i < array_length; i++) {
+      slot = vector_get_element_address_ref((Vector_Handle) array, i);
+      scan_slot(collector, (Partial_Reveal_Object **)slot);
+    }   
+    return;
+  }
+
+  /* scan non-array object */
+  int *offset_scanner = init_object_scanner(p_obj);
+  while (true) {
+    slot = offset_get_ref(offset_scanner, p_obj);
+    if (slot == NULL) break;
+  
+    scan_slot(collector, (Partial_Reveal_Object **)slot);
+    offset_scanner = offset_next_ref(offset_scanner);
+  }
+
+  return;
+}
+
+/*  At this point, p_ref can be in anywhere like root, and other spaces,  
+ *  but *p_ref must be in fspace, since only slot which points to 
+ *  object in fspace could be added into TraceStack */
+#include "../verify/verify_live_heap.h"
+
+static void trace_object(Collector* collector, Partial_Reveal_Object **p_ref) 
+{
+  Space* space = collector->collect_space; 
+  Partial_Reveal_Object *p_obj = *p_ref;
+
+  assert(p_obj); 
+  assert(obj_belongs_to_space(p_obj, space));
+
+  /* Fastpath: object has already been forwarded, update the ref slot */
+  if(obj_is_forwarded_in_vt(p_obj)) {
+    assert(!obj_is_marked_in_vt(p_obj));
+    *p_ref = obj_get_forwarding_pointer_in_vt(p_obj);    
+    return;
+  }
+
+  /* only mark the objects that will remain in fspace */
+  if (!fspace_object_to_be_forwarded(p_obj, (Fspace*)space)) {
+    assert(!obj_is_forwarded_in_vt(p_obj));
+    /* this obj remains in fspace, remember its ref slot for next GC. */
+    if( !address_belongs_to_space(p_ref, space) )
+      collector->this_cycle_remset->push_back(p_ref); 
+
+    if(fspace_mark_object((Fspace*)space, p_obj)) 
+      scan_object(collector, p_obj);
+    
+    return;
+  }
+    
+  /* following is the logic for forwarding */  
+  Partial_Reveal_Object* p_target_obj = collector_forward_object(collector, p_obj);
+  
+  /* if it is forwarded by other already, it is ok */
+  if(!p_target_obj){
+    *p_ref = obj_get_forwarding_pointer_in_vt(p_obj);  
+     return;
+  }  
+  /* otherwise, we successfully forwarded */
+  *p_ref = p_target_obj;  
+
+  /* we forwarded it, we need remember it for verification. FIXME:: thread id */
+  if(verify_live_heap) {
+    event_collector_move_obj(p_obj, p_target_obj, collector);
+  }
+
+  scan_object(collector, p_target_obj); 
+  return;
+}
+
+/* trace the root references from root set and remember sets */
+void trace_root(Collector* collector, Partial_Reveal_Object **ref) 
+{   
+  assert(*ref); 
+  assert(obj_belongs_to_space(*ref, collector->collect_space));
+
+  TraceStack *ts = collector->trace_stack;   
+  ts->push(ref);
+
+  while(!ts->empty()) {
+    Partial_Reveal_Object **p_ref = ts->top();
+    ts->pop();
+    assert(p_ref);
+    trace_object(collector, p_ref);   
+  }
+}
+
+static void collector_trace_remsets(Collector* collector)
+{
+  Fspace* fspace = (Fspace*)collector->collect_space;
+  
+  HashSet remslot_hash;
+
+  /* find root slots saved by 1. active mutators, 2. exited mutators, 3. last cycle collectors */
+  for(unsigned int i=0; i< fspace->remslot_sets->size(); i++) {
+    RemslotSet* remslot = (*fspace->remslot_sets)[i];
+    for (unsigned int j = 0; j < remslot->size(); j++) {
+      Partial_Reveal_Object **ref = (*remslot)[j];
+      assert(ref);
+      if(*ref == NULL) continue;  
+      if (obj_belongs_to_space(*ref, (Space*)fspace)) {
+        if (remslot_hash.find(ref) == remslot_hash.end()) {
+          remslot_hash.insert(ref);
+          trace_root(collector, ref);
+        }
+      }
+    }
+    remslot->clear();  
+  }
+  fspace->remslot_sets->clear();
+    
+  return;
+}
+
+void update_rootset_interior_pointer();
+
+static void update_relocated_refs(Collector* collector)
+{
+  update_rootset_interior_pointer();
+}
+
+void trace_forward_fspace(Collector* collector) 
+{  
+  GC* gc = collector->gc;
+  Fspace* space = (Fspace*)collector->collect_space;
+  
+  /* FIXME:: Single-threaded trace-forwarding for fspace currently */
+
+  space->remslot_sets->push_back(gc->root_set);
+  collector_trace_remsets(collector);
+
+  update_relocated_refs(collector);
+  reset_fspace_for_allocation(space);  
+
+  return;
+  
+}
+
+
+

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/trace_forward/fspace_copy.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/trace_forward/fspace_copy.cpp?view=diff&rev=468252&r1=468251&r2=468252
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/trace_forward/fspace_copy.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/trace_forward/fspace_copy.cpp Thu Oct 26 20:48:43 2006
@@ -1,174 +0,0 @@
-/*
- *  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 Xiao-Feng Li, 2006/10/05
- */
-
-#include "fspace.h"
-
-/* copying of fspace is only for MAJOR_COLLECTION */
-
-static void slot_update_to_forwarding_pointer(Partial_Reveal_Object **p_ref, Partial_Reveal_Object *p_obj)
-{
-  /* if obj is marked in MAJOR_COLLECTION, it is alive, and has forwarding pointer */
-  if(!obj_is_marked_in_vt(p_obj)) return;
-    
-  *p_ref = get_forwarding_pointer_in_obj_info(p_obj);  
-}
-
-static void object_update_slots(Fspace* space, Partial_Reveal_Object *p_obj) 
-{
-  if(obj_belongs_to_space(p_obj, (Space*)space)) return;
-  
-  if(!object_has_slots(p_obj)) return;
-
-  if(object_is_array(p_obj)){
-    assert(!obj_is_primitive_array(p_obj));
-
-    int32 array_length = vector_get_length((Vector_Handle) p_obj);
-    for (int i = 0; i < array_length; i++) {
-      Partial_Reveal_Object** p_ref = (Partial_Reveal_Object**)vector_get_element_address_ref((Vector_Handle) p_obj, i);
-      Partial_Reveal_Object* p_obj = *p_ref;
-      if(p_obj == NULL) continue;
-      if (obj_belongs_to_space(p_obj, (Space*)space)){
-        slot_update_to_forwarding_pointer(p_ref, p_obj);
-      }
-    }
-  }else{
-    int *offset_scanner = init_object_scanner(p_obj);
-    while (true) {
-      Partial_Reveal_Object** p_ref = (Partial_Reveal_Object**)offset_get_ref(offset_scanner, p_obj);
-      if (p_ref == NULL) break;
-      Partial_Reveal_Object* p_obj = *p_ref;
-      if(p_obj != NULL && obj_belongs_to_space(p_obj, (Space*)space)){
-        slot_update_to_forwarding_pointer(p_ref, p_obj);
-      }
-      offset_scanner = offset_next_ref(offset_scanner);
-    }
-  }
-}
-
-void space_update_remsets(Fspace* space)
-{
-  
-  for(unsigned int i=0; i< space->remslot_sets->size(); i++) {
-    RemslotSet* remslot = (*space->remslot_sets)[i];
-    for (unsigned int j = 0; j < remslot->size(); j++) {
-      Partial_Reveal_Object** p_ref = (*remslot)[j];
-      assert(p_ref);
-      Partial_Reveal_Object* p_obj = *p_ref;
-      if(p_obj == NULL) continue;  
-      if (obj_belongs_to_space(p_obj, (Space*)space)){
-        /* if obj is marked in MAJOR_COLLECTION, it is alive, and has forwarding pointer */
-        if(obj_is_marked_in_vt(p_obj)){
-          *p_ref = get_forwarding_pointer_in_obj_info(p_obj);
-        }
-      }
-    }
-    remslot->clear();
-  }
-  space->remslot_sets->clear();
-
-  for(unsigned int i=0; i<space->remobj_sets->size(); i++) {
-    RemobjSet *remobj = (*space->remobj_sets)[i];
-    for(unsigned int j=0; j<remobj->size(); j++) {
-      Partial_Reveal_Object *obj = (*remobj)[j];
-      object_update_slots(space, obj);
-    }
-    remobj->clear();
-  }
-  space->remobj_sets->clear();
-
-  return;
-
-}
-
-void fspace_save_reloc(Fspace* fspace, Partial_Reveal_Object** p_ref)
-{
-    fspace->reloc_table->push_back(p_ref);  
-}
-
-void fspace_update_reloc(Fspace* fspace)
-{
-  SlotVector* reloc_table;
-  
-  reloc_table = fspace->reloc_table;
-  for(unsigned int j=0; j < reloc_table->size(); j++){
-    Partial_Reveal_Object** p_ref = (*reloc_table)[j];
-    Partial_Reveal_Object* p_target_obj = get_forwarding_pointer_in_obj_info(*p_ref);
-    *p_ref = p_target_obj;
-  }
-  reloc_table->clear();
-  return;
-}
-
-void fspace_restore_obj_info(Fspace* fspace)
-{
-  ObjectMap* objmap = fspace->obj_info_map;
-  ObjectMap::iterator obj_iter;
-  for( obj_iter=objmap->begin(); obj_iter!=objmap->end(); obj_iter++){
-    Partial_Reveal_Object* p_target_obj = obj_iter->first;
-    Obj_Info_Type obj_info = obj_iter->second;
-    set_obj_info(p_target_obj, obj_info);     
-  }
-  objmap->clear();
-  return;  
-}
-
-#include "../verify/verify_live_heap.h"
-
-void fspace_copy_collect(Collector* collector, Fspace* fspace) 
-{  
-  unsigned int* mark_table = fspace->mark_table;
-  unsigned int* table_end = (unsigned int*)((POINTER_SIZE_INT)mark_table + fspace->mark_table_size);
-  unsigned int* fspace_start = (unsigned int*)fspace->heap_start;
-  Partial_Reveal_Object* p_obj = NULL;
-    
-  unsigned j=0;
-  while( (mark_table + j) < table_end){
-    unsigned int markbits = *(mark_table+j);
-    if(!markbits){ j++; continue; }
-    unsigned int k=0;
-    while(k<32){
-      if( !(markbits& (1<<k)) ){ k++; continue;}
-      p_obj = (Partial_Reveal_Object*)(fspace_start + (j<<5) + k);
-      assert(obj_is_marked_in_vt(p_obj));
-      obj_unmark_in_vt(p_obj);
-      Partial_Reveal_Object* p_target_obj = get_forwarding_pointer_in_obj_info(p_obj);
-      unsigned int obj_size = vm_object_size(p_obj);
-      memmove(p_target_obj, p_obj, obj_size);
-
-      if (verify_live_heap){
-          /* we forwarded it, we need remember it for verification */
-          event_collector_move_obj(p_obj, p_target_obj, collector);
-      }
-     
-      set_obj_info(p_target_obj, 0);
- 
-      k++;
-    }   
-    j++;;
-  }
-
-  /* different from partial trace_forwarding, we clear the mark bits 
-    (both in vt and table) in this function */
-  memset(mark_table, 0, fspace->mark_table_size);  
-    
-  reset_fspace_for_allocation(fspace);  
-
-  return;
-}

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/trace_forward/fspace_forward.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/trace_forward/fspace_forward.cpp?view=diff&rev=468252&r1=468251&r2=468252
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/trace_forward/fspace_forward.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/trace_forward/fspace_forward.cpp Thu Oct 26 20:48:43 2006
@@ -1,256 +0,0 @@
-/*
- *  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 Xiao-Feng Li, 2006/10/05
- */
-
-#include "fspace.h"
-#include "../thread/collector.h"
-#include "../common/interior_pointer.h"
-
-static Boolean fspace_object_to_be_forwarded(Partial_Reveal_Object *p_obj, Fspace *fspace)
-{
-  assert(obj_belongs_to_space(p_obj, (Space*)fspace));  
-  return forward_first_half? (p_obj < object_forwarding_boundary):(p_obj>=object_forwarding_boundary);
-}
-
-static void scan_slot(Collector* collector, Partial_Reveal_Object **p_ref) 
-{
-  Partial_Reveal_Object *p_obj = *p_ref;
-  TraceStack *ts = collector->trace_stack;
-
-  if (p_obj == NULL) return;  
-    
-  /* the slot can be in tspace or fspace, we don't care.
-     we care only if the reference in the slot is pointing to fspace */
-  if (obj_belongs_to_space(p_obj, collector->collect_space)) {
-    ts->push(p_ref);
-  } 
-
-  return;
-}
-
-static void scan_object(Collector* collector, Partial_Reveal_Object *p_obj) 
-{
-  if (!object_has_slots(p_obj)) return;
-  
-  void *slot;
-  
-  /* scan array object */
-  if (object_is_array(p_obj)) {
-    Partial_Reveal_Object* array = p_obj;
-    assert(!obj_is_primitive_array(array));
-    
-    int32 array_length = vector_get_length((Vector_Handle) array);
-    for (int i = 0; i < array_length; i++) {
-      slot = vector_get_element_address_ref((Vector_Handle) array, i);
-      scan_slot(collector, (Partial_Reveal_Object **)slot);
-    }   
-    return;
-  }
-
-  /* scan non-array object */
-  int *offset_scanner = init_object_scanner(p_obj);
-  while (true) {
-    slot = offset_get_ref(offset_scanner, p_obj);
-    if (slot == NULL) break;
-  
-    scan_slot(collector, (Partial_Reveal_Object **)slot);
-    offset_scanner = offset_next_ref(offset_scanner);
-  }
-
-  return;
-}
-
-/*  At this point, p_ref can be in anywhere like root, and other spaces,  
- *  but *p_ref must be in fspace, since only slot which points to 
- *  object in fspace could be added into TraceStack */
-#include "../verify/verify_live_heap.h"
-
-static void trace_object(Collector* collector, Partial_Reveal_Object **p_ref) 
-{
-  Space* space = collector->collect_space; 
-  Partial_Reveal_Object *p_obj = *p_ref;
-
-  assert(p_obj); 
-  assert(obj_belongs_to_space(p_obj, space));
-
-  /* Fastpath: object has already been forwarded, update the ref slot */
-  if(obj_is_forwarded_in_vt(p_obj)) {
-    assert(!obj_is_marked_in_vt(p_obj));
-    *p_ref = obj_get_forwarding_pointer_in_vt(p_obj);    
-    return;
-  }
-
-  /* only mark the objects that will remain in fspace */
-  if (!fspace_object_to_be_forwarded(p_obj, (Fspace*)space)) {
-    assert(!obj_is_forwarded_in_vt(p_obj));
-    /* this obj remains in fspace, remember its ref slot for next GC. */
-    if( !address_belongs_to_space(p_ref, space) ){
-      collector->this_cycle_remset->push_back(p_ref); 
-    }
-
-    if(!obj_is_marked_in_vt(p_obj)){ 
-      fspace_mark_object((Fspace*)space, p_obj); 
-      scan_object(collector, p_obj);
-    }
-    return;
-  }
-    
-  /* following is the logic for forwarding */  
-  Partial_Reveal_Object* p_target_obj = collector_forward_object(collector, p_obj);
-  
-  /* if it is forwarded by other already, it is ok */
-  if(!p_target_obj){
-    *p_ref = obj_get_forwarding_pointer_in_vt(p_obj);  
-     return;
-  }  
-  /* otherwise, we successfully forwarded */
-  *p_ref = p_target_obj;  
-
-  /* we forwarded it, we need remember it for verification. FIXME:: thread id */
-  if(verify_live_heap) {
-    event_collector_move_obj(p_obj, p_target_obj, collector);
-  }
-
-  scan_object(collector, p_target_obj); 
-  return;
-}
-
-/* trace the root references from root set and remember sets */
-void trace_root(Collector* collector, Partial_Reveal_Object **ref) 
-{   
-  assert(*ref); 
-  assert(obj_belongs_to_space(*ref, collector->collect_space));
-
-  TraceStack *ts = collector->trace_stack;   
-  ts->push(ref);
-
-  while(!ts->empty()) {
-    Partial_Reveal_Object **p_ref = ts->top();
-    ts->pop();
-    assert(p_ref);
-    trace_object(collector, p_ref);   
-  }
-}
-
-static void scan_object_slot(Collector* collector, Partial_Reveal_Object *p_obj) 
-{
-  Space* space = collector->collect_space;
-  
-  if ( obj_belongs_to_space(p_obj, space)) return;
-  
-  if (!object_has_slots(p_obj)) return;
-
-  if (object_is_array(p_obj)) {
-    assert(!obj_is_primitive_array(p_obj));
-
-    int32 array_length = vector_get_length((Vector_Handle) p_obj);
-    for (int i = 0; i < array_length; i++) {
-      Partial_Reveal_Object** slot = (Partial_Reveal_Object**)vector_get_element_address_ref((Vector_Handle) p_obj, i);
-      if (obj_belongs_to_space(*slot, space))
-        trace_root(collector, slot);
-    } 
-  } else {
-    int *offset_scanner = init_object_scanner(p_obj);
-    while (true) {
-      Partial_Reveal_Object** slot = (Partial_Reveal_Object**)offset_get_ref(offset_scanner, p_obj);
-      if (slot == NULL) break;
-      if ((*slot != NULL) && (obj_belongs_to_space(*slot, space)))
-        trace_root(collector, slot);
-
-      offset_scanner = offset_next_ref(offset_scanner);
-    }
-  }
-  return;
-}
-
-static void collector_scan_remsets(Collector* collector)
-{
-  Fspace* fspace = (Fspace*)collector->collect_space;
-  
-  HashSet remslot_hash;
-
-  /* find root slots saved by 1. active mutators, 2. exited mutators, 3. last cycle collectors */
-  for(unsigned int i=0; i< fspace->remslot_sets->size(); i++) {
-    RemslotSet* remslot = (*fspace->remslot_sets)[i];
-    for (unsigned int j = 0; j < remslot->size(); j++) {
-      Partial_Reveal_Object **ref = (*remslot)[j];
-      assert(ref);
-      if(*ref == NULL) continue;  
-      if (obj_belongs_to_space(*ref, (Space*)fspace)) {
-        if (remslot_hash.find(ref) == remslot_hash.end()) {
-          remslot_hash.insert(ref);
-          trace_root(collector, ref);
-        }
-      }
-    }
-    remslot->clear();  
-  }
-  fspace->remslot_sets->clear();
-
-  HashSet remobj_hash;
-
-  /* find root slots from the remobjs saved by 1. active mutators 2. exited mutators */
-  for(unsigned int i=0; i<fspace->remobj_sets->size(); i++) {
-    RemobjSet *remobj = (*fspace->remobj_sets)[i];
-    for(unsigned int j=0; j<remobj->size(); j++) {
-      Partial_Reveal_Object *obj = (*remobj)[j];
-      if (remobj_hash.find(obj) == remobj_hash.end()) {
-        remobj_hash.insert(obj);
-        scan_object_slot(collector, obj);
-      }
-    }
-    remobj->clear();
-  }
-  fspace->remobj_sets->clear();
-    
-  return;
-}
-
-static void update_relocated_refs(Collector* collector)
-{
-	update_rootset_interior_pointer();
-}
-
-static void trace_forward_fspace(Collector* collector) 
-{  
-  GC* gc = collector->gc;
-  Fspace* space = (Fspace*)collector->collect_space;
-  
-  /* FIXME:: Single-threaded trace-forwarding for fspace currently */
-
-  space->remslot_sets->push_back(gc->root_set);
-  collector_scan_remsets(collector);
-  update_relocated_refs(collector);  
-  reset_fspace_for_allocation(space);  
-
-  return;
-  
-}
-
-/* world is stopped when starting fspace_collection */      
-void fspace_collection(Fspace *fspace)
-{
-  fspace->num_collections++;  
-  
-  GC* gc = fspace->gc;
-  
-  collector_execute_task(gc, (TaskType)trace_forward_fspace, (Space*)fspace);
-  
-  return; 
-}



Mime
View raw message