# New Ticket Created by  Jürgen Bömmels 
# Please include the string:  [perl #23292]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org/rt2/Ticket/Display.html?id=23292 >


Hello,

It took me some minutes to find out how ARENA_DOD_FLAGS work. I added
a section to memory_internals.pod that others hopefully need a few
minutes less to figure out what its good for.



-- attachment  1 ------------------------------------------------------
url: http://rt.perl.org/rt2/attach/62600/46091/72fbf7/memory_internals.diff

Index: docs/memory_internals.pod
===================================================================
RCS file: /cvs/public/parrot/docs/memory_internals.pod,v
retrieving revision 1.5
diff -u -r1.5 memory_internals.pod
--- docs/memory_internals.pod	30 Dec 2002 12:21:20 -0000	1.5
+++ docs/memory_internals.pod	11 Aug 2003 20:11:48 -0000
@@ -107,6 +107,46 @@
 I<strstart> and I<bufused>, inserted at the ellipses, you get a I<STRING>.
 Adding a I<vtable> (and some other structure members) yields a I<PMC>.
 
+=head2 ARENA_DOD_FLAGS
+
+Only four flags need to be checked during a DOD run: C<PObj_live_FLAG>,
+C<PObj_on_free_list_FLAG>, C<PObj_is_special_PMC_FLAG> and 
+C<PObj_needs_early_DOD_FLAG>. Normaly these flags are stored in PObj->flags,
+each PMC must be accessed during the DOD run.
+
+An alternative aproach is to store the DOD-Flags in the Arenas as a packed
+array of bits. This aproach will be used if the preprocessor variable 
+C<ARENA_DOD_FLAGS> is defined to 1. Here the I<struct Small_Object_Arena> is
+extend with a pointer to the packed bitarray
+
+    struct Small_Object_Arena {
+        UINTVAL *dod_flags;
+        size_t object_size;
+        ...
+    };
+
+The memory for this Small_Object_Arena is allocated at the beginning of big
+aligned block of memory (currently 4MiB), the objects in this arena come also
+from this memory block. Therefor the arena of an object can be found by simply
+masking out the lower bits of the pointer to the object
+
+    arena = object & ARENA_MASK;
+
+The macro C<GET_ARENA> does the exactly this including the necessary type
+casts to remove warnings. The dod_flags are accessed by getting the element
+number in the arena (this is possible because the object_size is fixed and
+stored in the I<struct Small_Object_Arena>), creating the appropriate
+bitmask by shifting and access the right element of dod_flags[].
+
+    n = (object - arena->start_objects) / arena->object_size;
+    arena->dod_flags[n >> ARENA_FLAG_SHIFT] 
+        & flag << ((n & ARENA_FLAG_MASK) << 2)
+
+To simplify this the macros C<DOD_flag_SET>, C<DOD_flag_CLEAR> and
+C<DOD_flag_TEST> are introduced. As these macros are also defined in the case
+non ARENA_DOD_FLAGS these macros are a protable way of manipulating the 
+DOD_FLAGS
+
 =head1 Variable sized items
 
 These items never live alone, they are part of a I<Buffer> structure,
@@ -198,7 +238,6 @@
 
 =head1 Simplified Figure
 
-=item
                              +--------+
       +------------------<---| Arenas |<-----------+
       |                      +--------+-->--+      |

Reply via email to