smarter marking
Anthony Green
green@cygnus.com
Sun Dec 12 13:26:00 GMT 1999
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;
}
More information about the Java
mailing list