Skip to content
Browse files

Remove fastmarktable.

  • Loading branch information...
1 parent d076136 commit 48023660b2590cb871b83cedafd31308b549c235 Evan Weaver committed Mar 23, 2011
Showing with 56 additions and 125 deletions.
  1. +1 −1 common.mk
  2. +0 −83 fastmarktable.c
  3. +37 −29 marktable.c
  4. +18 −12 marktable.h
View
2 common.mk
@@ -400,7 +400,7 @@ gc.$(OBJEXT): {$(VPATH)}gc.c {$(VPATH)}ruby.h config.h \
{$(VPATH)}rubysig.h {$(VPATH)}st.h {$(VPATH)}node.h \
{$(VPATH)}env.h {$(VPATH)}re.h {$(VPATH)}regex.h \
{$(VPATH)}pointerset.h {$(VPATH)}marktable.h \
- {$(VPATH)}marktable.c {$(VPATH)}fastmarktable.c
+ {$(VPATH)}marktable.c
hash.$(OBJEXT): {$(VPATH)}hash.c {$(VPATH)}ruby.h config.h \
{$(VPATH)}defines.h {$(VPATH)}intern.h {$(VPATH)}missing.h \
{$(VPATH)}st.h {$(VPATH)}util.h {$(VPATH)}rubysig.h
View
83 fastmarktable.c
@@ -1,83 +0,0 @@
-/**
- * A mark table, used during a mark-and-sweep garbage collection cycle.
- *
- * This implementation is faster than marktable.c, but is *not*
- * copy-on-write friendly. It stores mark information directly inside objects.
- */
-#ifndef _FAST_MARK_TABLE_C_
-#define _FAST_MARK_TABLE_C_
-
-static void
-rb_fast_mark_table_init() {
-}
-
-static void
-rb_fast_mark_table_prepare() {
-}
-
-static void
-rb_fast_mark_table_finalize() {
-}
-
-static inline void
-rb_fast_mark_table_add(RVALUE *object) {
- object->as.basic.flags |= FL_MARK;
-}
-
-static inline void
-rb_fast_mark_table_heap_add(struct heaps_slot *hs, RVALUE *object) {
- object->as.basic.flags |= FL_MARK;
-}
-
-static inline int
-rb_fast_mark_table_contains(RVALUE *object) {
- return object->as.basic.flags & FL_MARK;
-}
-
-static inline int
-rb_fast_mark_table_heap_contains(struct heaps_slot *hs, RVALUE *object) {
- return object->as.basic.flags & FL_MARK;
-}
-
-static inline void
-rb_fast_mark_table_remove(RVALUE *object) {
- object->as.basic.flags &= ~FL_MARK;
-}
-
-static inline void
-rb_fast_mark_table_heap_remove(struct heaps_slot *hs, RVALUE *object) {
- object->as.basic.flags &= ~FL_MARK;
-}
-
-static inline void
-rb_fast_mark_table_add_filename(char *filename) {
- filename[-1] = 1;
-}
-
-static inline int
-rb_fast_mark_table_contains_filename(const char *filename) {
- return filename[-1];
-}
-
-static inline void
-rb_fast_mark_table_remove_filename(char *filename) {
- filename[-1] = 0;
-}
-
-static void
-rb_use_fast_mark_table() {
- rb_mark_table_init = rb_fast_mark_table_init;
- rb_mark_table_prepare = rb_fast_mark_table_prepare;
- rb_mark_table_finalize = rb_fast_mark_table_finalize;
- rb_mark_table_add = rb_fast_mark_table_add;
- rb_mark_table_heap_add = rb_fast_mark_table_heap_add;
- rb_mark_table_contains = rb_fast_mark_table_contains;
- rb_mark_table_heap_contains = rb_fast_mark_table_heap_contains;
- rb_mark_table_remove = rb_fast_mark_table_remove;
- rb_mark_table_heap_remove = rb_fast_mark_table_heap_remove;
- rb_mark_table_add_filename = rb_fast_mark_table_add_filename;
- rb_mark_table_contains_filename = rb_fast_mark_table_contains_filename;
- rb_mark_table_remove_filename = rb_fast_mark_table_remove_filename;
-}
-
-#endif /* _FAST_MARK_TABLE_C_ */
View
66 marktable.c
@@ -1,7 +1,7 @@
/**
* A mark table, used during a mark-and-sweep garbage collection cycle.
*
- * This implementation is somewhat slower than fastmarktable.c, but is
+ * This implementation is somewhat slower than default MRI, but is
* copy-on-write friendly. It stores mark information for objects in a bit
* field located at the beginning of the heap. Mark information for filenames
* are stored in a pointer set.
@@ -15,7 +15,6 @@
static PointerSet *mark_table = NULL;
static struct heaps_slot *last_heap = NULL;
-
static inline struct heaps_slot *
find_heap_slot_for_object(RVALUE *object)
{
@@ -79,27 +78,32 @@ find_position_in_bitfield(struct heaps_slot *hs, RVALUE *object,
static void
-rb_bf_mark_table_init()
+rb_mark_table_init()
{
if (mark_table == NULL) {
mark_table = pointer_set_new();
}
}
static void
-rb_bf_mark_table_prepare()
+rb_mark_table_prepare()
{
last_heap = NULL;
}
static void
-rb_bf_mark_table_finalize()
+rb_mark_table_reset(lifetime_t lifetime)
{
- /* Do nothing. */
+ int i;
+ for (i = 0; i < heaps_used; i++) {
+ if (heaps[i].lifetime == lifetime) {
+ MEMZERO(heaps[i].marks, int, heaps[i].marks_size);
+ }
+ }
}
static inline void
-rb_bf_mark_table_add(RVALUE *object)
+rb_mark_table_add(RVALUE *object)
{
struct heaps_slot *hs;
unsigned int bitfield_index, bitfield_offset;
@@ -114,15 +118,15 @@ rb_bf_mark_table_add(RVALUE *object)
}
static inline void
-rb_bf_mark_table_heap_add(struct heaps_slot *hs, RVALUE *object)
+rb_mark_table_heap_add(struct heaps_slot *hs, RVALUE *object)
{
unsigned int bitfield_index, bitfield_offset;
find_position_in_bitfield(hs, object, &bitfield_index, &bitfield_offset);
hs->marks[bitfield_index] |= (1 << bitfield_offset);
}
static inline int
-rb_bf_mark_table_contains(RVALUE *object)
+rb_mark_table_contains(RVALUE *object)
{
struct heaps_slot *hs;
unsigned int bitfield_index, bitfield_offset;
@@ -137,7 +141,7 @@ rb_bf_mark_table_contains(RVALUE *object)
}
static inline int
-rb_bf_mark_table_heap_contains(struct heaps_slot *hs, RVALUE *object)
+rb_mark_table_heap_contains(struct heaps_slot *hs, RVALUE *object)
{
unsigned int bitfield_index, bitfield_offset;
find_position_in_bitfield(hs, object, &bitfield_index, &bitfield_offset);
@@ -146,7 +150,7 @@ rb_bf_mark_table_heap_contains(struct heaps_slot *hs, RVALUE *object)
}
static inline void
-rb_bf_mark_table_remove(RVALUE *object)
+rb_mark_table_remove(RVALUE *object)
{
struct heaps_slot *hs;
unsigned int bitfield_index, bitfield_offset;
@@ -161,45 +165,49 @@ rb_bf_mark_table_remove(RVALUE *object)
}
static inline void
-rb_bf_mark_table_heap_remove(struct heaps_slot *hs, RVALUE *object)
+rb_mark_table_heap_remove(struct heaps_slot *hs, RVALUE *object)
{
unsigned int bitfield_index, bitfield_offset;
find_position_in_bitfield(hs, object, &bitfield_index, &bitfield_offset);
hs->marks[bitfield_index] &= ~(1 << bitfield_offset);
}
static inline void
-rb_bf_mark_table_add_filename(char *filename)
+rb_mark_table_add_filename(char *filename)
{
pointer_set_insert(mark_table, (void *) filename);
}
static inline int
-rb_bf_mark_table_contains_filename(const char *filename)
+rb_mark_table_contains_filename(const char *filename)
{
return pointer_set_contains(mark_table, (void *) filename);
}
static inline void
-rb_bf_mark_table_remove_filename(char *filename)
+rb_mark_table_remove_filename(char *filename)
{
pointer_set_delete(mark_table, (void *) filename);
}
-static void
-rb_use_bf_mark_table() {
- rb_mark_table_init = rb_bf_mark_table_init;
- rb_mark_table_prepare = rb_bf_mark_table_prepare;
- rb_mark_table_finalize = rb_bf_mark_table_finalize;
- rb_mark_table_add = rb_bf_mark_table_add;
- rb_mark_table_heap_add = rb_bf_mark_table_heap_add;
- rb_mark_table_contains = rb_bf_mark_table_contains;
- rb_mark_table_heap_contains = rb_bf_mark_table_heap_contains;
- rb_mark_table_remove = rb_bf_mark_table_remove;
- rb_mark_table_heap_remove = rb_bf_mark_table_heap_remove;
- rb_mark_table_add_filename = rb_bf_mark_table_add_filename;
- rb_mark_table_contains_filename = rb_bf_mark_table_contains_filename;
- rb_mark_table_remove_filename = rb_bf_mark_table_remove_filename;
+#ifdef GC_DEBUG
+static inline void
+rb_mark_table_add_source_pos(source_position_t *source_pos)
+{
+ pointer_set_insert(mark_table, (void *) source_pos);
+}
+
+static inline int
+rb_mark_table_contains_source_pos(const source_position_t *source_pos)
+{
+ return pointer_set_contains(mark_table, (void *) source_pos);
+}
+
+static inline void
+rb_mark_table_remove_source_pos(source_position_t *source_pos)
+{
+ pointer_set_delete(mark_table, (void *) source_pos);
}
+#endif
#endif /* _MARK_TABLE_C_ */
View
30 marktable.h
@@ -1,17 +1,23 @@
#ifndef _MARK_TABLE_H_
#define _MARK_TABLE_H_
-static void (*rb_mark_table_init)();
-static void (*rb_mark_table_prepare)();
-static void (*rb_mark_table_finalize)();
-static void (*rb_mark_table_add)(RVALUE *object);
-static void (*rb_mark_table_heap_add)(struct heaps_slot *hs, RVALUE *object);
-static int (*rb_mark_table_contains)(RVALUE *object);
-static int (*rb_mark_table_heap_contains)(struct heaps_slot *hs, RVALUE *object);
-static void (*rb_mark_table_remove)(RVALUE *object);
-static void (*rb_mark_table_heap_remove)(struct heaps_slot *hs, RVALUE *object);
-static void (*rb_mark_table_add_filename)(char *filename);
-static int (*rb_mark_table_contains_filename)(const char *filename);
-static void (*rb_mark_table_remove_filename)(char *filename);
+static void rb_mark_table_init();
+static void rb_mark_table_prepare();
+static void rb_mark_table_reset(lifetime_t lifetime);
+static void rb_mark_table_add(RVALUE *object);
+static void rb_mark_table_heap_add(struct heaps_slot *hs, RVALUE *object);
+static int rb_mark_table_contains(RVALUE *object);
+static int rb_mark_table_heap_contains(struct heaps_slot *hs, RVALUE *object);
+static void rb_mark_table_remove(RVALUE *object);
+static void rb_mark_table_heap_remove(struct heaps_slot *hs, RVALUE *object);
+static void rb_mark_table_add_filename(char *filename);
+static int rb_mark_table_contains_filename(const char *filename);
+static void rb_mark_table_remove_filename(char *filename);
+
+#ifdef GC_DEBUG
+static void rb_mark_table_add_source_pos(source_position_t *source_pos);
+static int rb_mark_table_contains_source_pos(const source_position_t *source_pos);
+static void rb_mark_table_remove_source_pos(source_position_t *source_pos);
+#endif
#endif /* _MARK_TABLE_H_ */

0 comments on commit 4802366

Please sign in to comment.
Something went wrong with that request. Please try again.