This is the mail archive of the java-discuss@sourceware.cygnus.com mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

smarter marking



It looks as though we're unconditionally marking every object's Class
object.  The code for marking classes contains 5 loops.  It seems like
a good idea to only mark them if they haven't been marked before.

This seems possible with a minor change to the gc's interface.  I
haven't tried this yet.  I just thought I'd see what people think
first.


Index: boehm-gc/gc_mark.h
===================================================================
RCS file: /cvs/java/libgcj/boehm-gc/gc_mark.h,v
retrieving revision 1.3
diff -u -r1.3 gc_mark.h
--- gc_mark.h	1999/11/01 23:15:51	1.3
+++ gc_mark.h	1999/12/12 21:07:44
@@ -139,9 +139,8 @@
 
 /* Push the contents of current onto the mark stack if it is a valid	*/
 /* ptr to a currently unmarked object.  Mark it.			*/
-/* If we assumed a standard-conforming compiler, we could probably	*/
-/* generate the exit_label transparently.				*/
-# define PUSH_CONTENTS(current, mark_stack_top, mark_stack_limit, \
+/* Jump to exit_label if we're not marking an object.                   */
+# define PUSH_CONTENTS_WITH_EXIT(current, mark_stack_top, mark_stack_limit, \
 		       source, exit_label) \
 { \
     register int displ;  /* Displacement in block; first bytes, then words */ \
@@ -177,6 +176,17 @@
     } \
     PUSH_OBJ(((word *)(HBLKPTR(current)) + displ), hhdr, \
     	     mark_stack_top, mark_stack_limit) \
+}
+
+/* Push the contents of current onto the mark stack if it is a valid	*/
+/* ptr to a currently unmarked object.  Mark it.			*/
+/* If we assumed a standard-conforming compiler, we could probably	*/
+/* generate the exit_label transparently.				*/
+# define PUSH_CONTENTS(current, mark_stack_top, mark_stack_limit, \
+		       source, exit_label) \
+{ \
+    PUSH_CONTENTS_WITH_EXIT(current, mark_stack_top, mark_stack_limit, \
+                            source, exit_label); \
   exit_label: ; \
 }
 
Index: libjava/boehm.cc
===================================================================
RCS file: /cvs/java/libgcj/libjava/boehm.cc,v
retrieving revision 1.11
diff -u -r1.11 boehm.cc
--- boehm.cc	1999/11/05 17:34:32	1.11
+++ boehm.cc	1999/12/12 21:07:44
@@ -91,9 +91,12 @@
   // Every object has a sync_info pointer.
   word w = (word) obj->sync_info;
   MAYBE_MARK (w, mark_stack_ptr, mark_stack_limit, obj, o1label);
-  // Mark the object's class.
-  w = (word) klass;
-  MAYBE_MARK (w, mark_stack_ptr, mark_stack_limit, obj, o2label);
+  // Mark the object's class.  Jump to the `done' label if it's already
+  // been marked.
+  if ((ptr_t) (klass) >= GC_least_plausible_heap_addr
+      && (ptr_t) (klass) <= GC_greatest_plausible_heap_addr)
+    PUSH_CONTENTS_WITH_EXIT (klass, mark_stack_ptr, 
+			     mark_stack_limit, obj, done)
 
   if (klass == &ClassClass)
     {
@@ -262,6 +265,7 @@
 	}
     }
 
+ done:
   return mark_stack_ptr;
 }
 

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]