Author: Nicolas Truessel <[email protected]>
Branch: quad-color-gc
Changeset: r86312:9561ef30edb5
Date: 2016-08-19 14:23 +0200
http://bitbucket.org/pypy/pypy/changeset/9561ef30edb5/

Log:    Update qcgc codebase

diff --git a/rpython/translator/c/src/qcgc/gc_state.h 
b/rpython/translator/c/src/qcgc/gc_state.h
--- a/rpython/translator/c/src/qcgc/gc_state.h
+++ b/rpython/translator/c/src/qcgc/gc_state.h
@@ -24,6 +24,7 @@
  */
 struct qcgc_state {
        shadow_stack_t *shadow_stack;
+       shadow_stack_t *prebuilt_objects;
        size_t gray_stack_size;
        gc_phase_t phase;
 } qcgc_state;
diff --git a/rpython/translator/c/src/qcgc/object.h 
b/rpython/translator/c/src/qcgc/object.h
--- a/rpython/translator/c/src/qcgc/object.h
+++ b/rpython/translator/c/src/qcgc/object.h
@@ -5,6 +5,7 @@
 #include <stdint.h>
 
 #define QCGC_GRAY_FLAG 0x01
+#define QCGC_PREBUILT_OBJECT 0x02
 
 typedef struct object_s {
        uint32_t flags;
diff --git a/rpython/translator/c/src/qcgc/qcgc.c 
b/rpython/translator/c/src/qcgc/qcgc.c
--- a/rpython/translator/c/src/qcgc/qcgc.c
+++ b/rpython/translator/c/src/qcgc/qcgc.c
@@ -22,6 +22,7 @@
 
 void qcgc_initialize(void) {
        qcgc_state.shadow_stack = 
qcgc_shadow_stack_create(QCGC_SHADOWSTACK_SIZE);
+       qcgc_state.prebuilt_objects = qcgc_shadow_stack_create(16); //XXX
        qcgc_state.gray_stack_size = 0;
        qcgc_state.phase = GC_PAUSE;
        qcgc_allocator_initialize();
@@ -57,7 +58,10 @@
 #endif
        if ((object->flags & QCGC_GRAY_FLAG) == 0) {
                object->flags |= QCGC_GRAY_FLAG;
-               if (qcgc_state.phase != GC_PAUSE) {
+               if ((object->flags & QCGC_PREBUILT_OBJECT) != 0) {
+                       // Save prebuilt object into list
+                       qcgc_shadow_stack_push(qcgc_state.prebuilt_objects, 
object);
+               } else if (qcgc_state.phase != GC_PAUSE) {
                        if (qcgc_arena_get_blocktype((cell_t *) object) == 
BLOCK_BLACK) {
                                // This was black before, push it to gray stack 
again
                                arena_t *arena = qcgc_arena_addr((cell_t *) 
object);
@@ -134,6 +138,11 @@
                qcgc_push_object(qcgc_state.shadow_stack->items[i]);
        }
 
+       // Trace all prebuilt objects
+       for (size_t i = 0; i < qcgc_state.prebuilt_objects->count; i++) {
+               qcgc_trace_cb(qcgc_state.prebuilt_objects->items[i], 
&qcgc_push_object);
+       }
+
        while(qcgc_state.gray_stack_size > 0) {
                for (size_t i = 0; i < qcgc_allocator_state.arenas->count; i++) 
{
                        arena_t *arena = qcgc_allocator_state.arenas->items[i];
@@ -167,6 +176,11 @@
                qcgc_push_object(qcgc_state.shadow_stack->items[i]);
        }
 
+       // Trace all prebuilt objects
+       for (size_t i = 0; i < qcgc_state.prebuilt_objects->count; i++) {
+               qcgc_trace_cb(qcgc_state.prebuilt_objects->items[i], 
&qcgc_push_object);
+       }
+
        for (size_t i = 0; i < qcgc_allocator_state.arenas->count; i++) {
                arena_t *arena = qcgc_allocator_state.arenas->items[i];
                size_t initial_stack_size = arena->gray_stack->index;
@@ -210,6 +224,9 @@
        assert(qcgc_state.phase == GC_MARK);
 #endif
        if (object != NULL) {
+               if ((object->flags & QCGC_PREBUILT_OBJECT) != 0) {
+                       return;
+               }
                if (qcgc_arena_get_blocktype((cell_t *) object) == BLOCK_WHITE) 
{
                        object->flags |= QCGC_GRAY_FLAG;
                        qcgc_arena_set_blocktype((cell_t *) object, 
BLOCK_BLACK);
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to