Author: petdance
Date: Sat Jun 9 14:28:07 2007
New Revision: 18895
Modified:
trunk/config/gen/makefiles/root.in
trunk/include/parrot/dod.h
trunk/include/parrot/headers.h
trunk/src/gc/dod.c
trunk/src/gc/gc_gms.c
trunk/src/headers.c
Log:
headerized dod.c and fixed some attribs elsewhere along the wya
Modified: trunk/config/gen/makefiles/root.in
==============================================================================
--- trunk/config/gen/makefiles/root.in (original)
+++ trunk/config/gen/makefiles/root.in Sat Jun 9 14:28:07 2007
@@ -1829,6 +1829,7 @@
# Slowing working my way up to having everything headerized in
$(HEADERIZER_O_FILES)
HEADERIZER_O_FILES = \
src/datatypes.o \
+ src/gc/dod.o \
src/gc/memory.o \
src/gc/register.o \
src/gc/resources.o \
Modified: trunk/include/parrot/dod.h
==============================================================================
--- trunk/include/parrot/dod.h (original)
+++ trunk/include/parrot/dod.h Sat Jun 9 14:28:07 2007
@@ -1,15 +1,11 @@
/* dod.h
- * Copyright (C) 2001-2003, The Perl Foundation.
+ * Copyright (C) 2001-2007, The Perl Foundation.
* SVN Info
* $Id$
* Overview:
* Handles dead object destruction of the various headers
- * Data Structure and Algorithms:
- *
* History:
* Initial version by Mike Lambert on 2002.05.27
- * Notes:
- * References:
*/
#pragma once
@@ -55,17 +51,54 @@
set, i.e. registers */
};
-PARROT_API void Parrot_do_dod_run(Interp *, UINTVAL flags);
-void trace_system_areas(Interp *);
-void trace_mem_block(Interp *, size_t, size_t);
+/* HEADERIZER BEGIN: src/gc/dod.c */
+
+PARROT_API void Parrot_do_dod_run( Interp *interp /*NN*/, UINTVAL flags )
+ __attribute__nonnull__(1);
+
+void clear_cow( Interp *interp, Small_Object_Pool *pool /*NN*/, int cleanup )
+ __attribute__nonnull__(2);
+
+void Parrot_dod_clear_live_bits( Interp *interp /*NN*/ )
+ __attribute__nonnull__(1);
+
+void Parrot_dod_ms_run( Interp *interp /*NN*/, int flags )
+ __attribute__nonnull__(1);
+
+void Parrot_dod_ms_run_init( Interp *interp /*NN*/ )
+ __attribute__nonnull__(1);
+
+void Parrot_dod_profile_end( Interp *interp /*NN*/, int what )
+ __attribute__nonnull__(1);
+
+void Parrot_dod_profile_start( Interp *interp /*NN*/ )
+ __attribute__nonnull__(1);
-void free_unused_pobjects(Interp *interp,
- struct Small_Object_Pool *pool);
+void Parrot_dod_sweep( Interp *interp /*NN*/, Small_Object_Pool *pool /*NN*/ )
+ __attribute__nonnull__(1)
+ __attribute__nonnull__(2);
-void used_cow(Interp *interp,
- struct Small_Object_Pool *pool, int cleanup);
-void clear_cow(Interp *interp,
- struct Small_Object_Pool *pool, int cleanup);
+int Parrot_dod_trace_children( Interp *interp, size_t how_many );
+int Parrot_dod_trace_root( Interp *interp /*NN*/, int trace_stack )
+ __attribute__nonnull__(1);
+
+void pobject_lives( Interp *interp /*NN*/, PObj *obj /*NN*/ )
+ __attribute__nonnull__(1)
+ __attribute__nonnull__(2);
+
+void trace_mem_block( Interp *interp /*NN*/,
+ size_t lo_var_ptr,
+ size_t hi_var_ptr )
+ __attribute__nonnull__(1);
+
+void used_cow( Interp *interp, Small_Object_Pool *pool /*NN*/, int cleanup )
+ __attribute__nonnull__(2);
+
+/* HEADERIZER END: src/gc/dod.c */
+
+
+/* cpu_dep.c */
+void trace_system_areas(Interp *);
/* mark a PObj live during DOD */
Modified: trunk/include/parrot/headers.h
==============================================================================
--- trunk/include/parrot/headers.h (original)
+++ trunk/include/parrot/headers.h Sat Jun 9 14:28:07 2007
@@ -80,7 +80,9 @@
__attribute__pure__
__attribute__warn_unused_result__;
-int is_buffer_ptr( Interp *interp, void *ptr );
+int is_buffer_ptr( Interp *interp /*NN*/, void *ptr )
+ __attribute__nonnull__(1);
+
int is_pmc_ptr( Interp *interp, void *ptr );
Small_Object_Pool * make_bufferlike_pool( Interp *interp /*NN*/,
size_t buffer_size )
Modified: trunk/src/gc/dod.c
==============================================================================
--- trunk/src/gc/dod.c (original)
+++ trunk/src/gc/dod.c Sat Jun 9 14:28:07 2007
@@ -16,18 +16,17 @@
There's also a verbose mode for garbage collection.
-=head2 Functions
-
-=over 4
-
-=cut
+=head1 FUNCTIONS
*/
#define DOD_C_SOURCE
#include "parrot/parrot.h"
+#include "parrot/dod.h"
#include <assert.h>
+/* HEADER: include/parrot/dod.h */
+
/* Set this to 1 to see if unanchored objects are found in system areas.
* Please note: these objects might be bogus
*/
@@ -38,12 +37,12 @@
int CONSERVATIVE_POINTER_CHASING = 0;
#endif
-static size_t find_common_mask(size_t val1, size_t val2);
+static size_t find_common_mask(size_t val1, size_t val2)
+ __attribute__pure__;
/*
-=item C<static void
-mark_special(Parrot_Interp interp, PMC* obj)>
+FUNCDOC: mark_special
Mark a special PMC. If it has a C<PMC_EXT> structure, append or prepend
the C<next_for_GC> pointer; otherwise, do the custom mark directly.
@@ -51,12 +50,10 @@
This should really be inline, so if inline isn't available, it would
be better if it were a macro.
-=cut
-
*/
static void
-mark_special(Parrot_Interp interp, PMC *obj)
+mark_special(Interp *interp /*NN*/, PMC *obj /*NN*/)
{
int hi_prio;
Arenas *arena_base;
@@ -136,7 +133,7 @@
/* XXX This should really use the same header, with different guts #ifdeffed */
void
-pobject_lives(Parrot_Interp interp, PObj *obj)
+pobject_lives(Interp *interp /*NN*/, PObj *obj /*NN*/)
{
/* if object is live or on free list return */
if (PObj_is_live_or_free_TESTALL(obj)) {
@@ -188,14 +185,7 @@
/*
-=item C<static int
-trace_active_PMCs(Parrot_Interp interp, int trace_stack)>
-
-Do a full trace run and mark all the PMCs as active if they are. Returns
-whether the run completed, that is, whether it's safe to proceed with GC.
-
-=item C<int
-Parrot_dod_trace_root(Parrot_Interp interp, int trace_stack)>
+FUNCDOC: Parrot_dod_trace_root
Trace the root set. Returns 0 if it's a lazy DOD run and all objects
that need timely destruction were found.
@@ -206,12 +196,10 @@
1 ... trace whole root set
2 ... trace system areas only
-=cut
-
*/
int
-Parrot_dod_trace_root(Parrot_Interp interp, int trace_stack)
+Parrot_dod_trace_root(Interp *interp /*NN*/, int trace_stack)
{
Arenas * const arena_base = interp->arena_base;
parrot_context_t *ctx;
@@ -314,8 +302,18 @@
return 1;
}
+
+/*
+
+FUNCDOC: trace_active_PMCs
+
+Do a full trace run and mark all the PMCs as active if they are. Returns
+whether the run completed, that is, whether it's safe to proceed with GC.
+
+*/
+
static int
-trace_active_PMCs(Parrot_Interp interp, int trace_stack)
+trace_active_PMCs(Interp *interp, int trace_stack)
{
if (!Parrot_dod_trace_root(interp, trace_stack))
return 0;
@@ -327,17 +325,14 @@
/*
-=item C<int
-Parrot_dod_trace_children(Parrot_Interp interp, size_t how_many)>
+FUNCDOC: Parrot_dod_trace_children
Returns whether the tracing process completed.
-=cut
-
*/
int
-Parrot_dod_trace_children(Parrot_Interp interp, size_t how_many)
+Parrot_dod_trace_children(Interp *interp, size_t how_many)
{
Arenas * const arena_base = interp->arena_base;
const int lazy_dod = arena_base->lazy_dod;
@@ -434,17 +429,14 @@
/*
-=item C<void
-clear_cow(Parrot_Interp interp, Small_Object_Pool *pool, int cleanup)>
+FUNCDOC: clear_cow
Clear the COW ref count.
-=cut
-
*/
void
-clear_cow(Parrot_Interp interp, Small_Object_Pool *pool, int cleanup)
+clear_cow(Interp *interp, Small_Object_Pool *pool /*NN*/, int cleanup)
{
const UINTVAL object_size = pool->object_size;
Small_Object_Arena *cur_arena;
@@ -480,24 +472,21 @@
/*
-=item C<void
-used_cow(Parrot_Interp interp, Small_Object_Pool *pool, int cleanup)>
+FUNCDOC: used_cow
Find other users of COW's C<bufstart>.
-=cut
-
*/
void
-used_cow(Parrot_Interp interp, Small_Object_Pool *pool, int cleanup)
+used_cow(Interp *interp, Small_Object_Pool *pool /*NN*/, int cleanup)
{
UINTVAL object_size = pool->object_size;
Small_Object_Arena *cur_arena;
for (cur_arena = pool->last_Arena;
NULL != cur_arena; cur_arena = cur_arena->prev) {
- Buffer *b = cur_arena->start_objects;
+ const Buffer *b = cur_arena->start_objects;
UINTVAL i;
for (i = 0; i < cur_arena->used; i++) {
@@ -523,19 +512,16 @@
/*
-=item C<void
-Parrot_dod_sweep(Parrot_Interp interp, Small_Object_Pool *pool)>
+FUNCDOC: Parrot_dod_sweep
Put any buffers/PMCs that are now unused onto the pool's free list. If
C<GC_IS_MALLOC>, bufstart gets freed too, if possible. Avoid buffers that
are immune from collection (i.e. constant).
-=cut
-
*/
void
-Parrot_dod_sweep(Parrot_Interp interp, Small_Object_Pool *pool)
+Parrot_dod_sweep(Interp *interp /*NN*/, Small_Object_Pool *pool /*NN*/)
{
Arenas * const arena_base = interp->arena_base;
UINTVAL i, total_used = 0;
@@ -693,12 +679,10 @@
/*
-=item C<static size_t find_common_mask(size_t val1, size_t val2)>
+FUNCDOC: find_common_mask
Find a mask covering the longest common bit-prefix of C<val1> and C<val2>.
-=cut
-
*/
static size_t
@@ -731,17 +715,14 @@
/*
-=item C<void
-trace_mem_block(Parrot_Interp interp, size_t lo_var_ptr, size_t hi_var_ptr)>
+FUNCDOC: trace_mem_block
Traces the memory block between C<lo_var_ptr> and C<hi_var_ptr>.
-=cut
-
*/
void
-trace_mem_block(Parrot_Interp interp, size_t lo_var_ptr, size_t hi_var_ptr)
+trace_mem_block(Interp *interp /*NN*/, size_t lo_var_ptr, size_t hi_var_ptr)
{
size_t prefix;
ptrdiff_t cur_var_ptr;
@@ -804,8 +785,10 @@
*/
+/* interp is unused and can be removed */
static void
-clear_live_bits(Parrot_Interp interp, Small_Object_Pool * const pool) {
+clear_live_bits(Interp *interp /*NULLOK*/, Small_Object_Pool * const pool)
+{
Small_Object_Arena *arena;
const UINTVAL object_size = pool->object_size;
@@ -822,7 +805,7 @@
}
void
-Parrot_dod_clear_live_bits(Parrot_Interp interp)
+Parrot_dod_clear_live_bits(Interp *interp /*NN*/)
{
Small_Object_Pool * const pool = interp->arena_base->pmc_pool;
clear_live_bits(interp, pool);
@@ -830,17 +813,14 @@
/*
-=item C<void
-Parrot_dod_profile_start(Parrot_Interp interp)>
+FUNCDOC: Parrot_dod_profile_start
Records the start time of a DOD run when profiling is enabled.
-=cut
-
*/
void
-Parrot_dod_profile_start(Parrot_Interp interp)
+Parrot_dod_profile_start(Interp *interp /*NN*/)
{
if (Interp_flags_TEST(interp, PARROT_PROFILE_FLAG))
interp->profile->dod_time = Parrot_floatval_time();
@@ -848,18 +828,15 @@
/*
-=item C<void
-Parrot_dod_profile_end(Parrot_Interp interp, int what)>
+FUNCDOC: Parrot_dod_profile_end
Records the end time of the DOD part C<what> run when profiling is enabled.
Also record start time of next part.
-=cut
-
*/
void
-Parrot_dod_profile_end(Parrot_Interp interp, int what)
+Parrot_dod_profile_end(Interp *interp /*NN*/, int what)
{
if (Interp_flags_TEST(interp, PARROT_PROFILE_FLAG)) {
RunProfile * const profile = interp->profile;
@@ -883,27 +860,14 @@
/*
-=item C<void
-Parrot_do_dod_run(Parrot_Interp interp, UINTVAL flags)>
-
-Call the configured garbage collector to reclaim unused headers.
-
-=item C<void
-Parrot_dod_ms_run(Parrot_Interp interp, UINTVAL flags)>
-
-Run the stop-the-world mark & sweep collector.
-
-=item C<void
-Parrot_dod_ms_run_init(Parrot_Interp interp)>
+FUNCDOC: Parrot_dod_ms_run_init
Prepare for a mark & sweep DOD run.
-=cut
-
*/
void
-Parrot_dod_ms_run_init(Parrot_Interp interp)
+Parrot_dod_ms_run_init(Interp *interp /*NN*/)
{
Arenas * const arena_base = interp->arena_base;
@@ -914,7 +878,7 @@
}
static int
-sweep_cb(Parrot_Interp interp, Small_Object_Pool *pool, int flag, void *arg)
+sweep_cb(Interp *interp /*NN*/, Small_Object_Pool *pool /*NN*/, int flag, void
*arg)
{
int * const total_free = (int *) arg;
@@ -938,8 +902,16 @@
return 0;
}
+/*
+
+FUNCDOC: Parrot_dod_ms_run
+
+Run the stop-the-world mark & sweep collector.
+
+*/
+
void
-Parrot_dod_ms_run(Parrot_Interp interp, int flags)
+Parrot_dod_ms_run(Interp *interp /*NN*/, int flags)
{
Arenas * const arena_base = interp->arena_base;
@@ -1021,8 +993,18 @@
return;
}
+
+/*
+
+FUNCDOC: Parrot_do_dod_run
+
+Call the configured garbage collector to reclaim unused headers.
+
+*/
+
+PARROT_API
void
-Parrot_do_dod_run(Parrot_Interp interp, UINTVAL flags)
+Parrot_do_dod_run(Interp *interp /*NN*/, UINTVAL flags)
{
interp->arena_base->do_dod_run(interp, flags);
parrot_gc_context(interp);
@@ -1030,8 +1012,6 @@
/*
-=back
-
=head1 SEE ALSO
F<include/parrot/dod.h>, F<src/cpu_dep.c>, F<docs/dev/dod.dev> and
@@ -1041,8 +1021,6 @@
Initial version by Mike Lambert on 2002.05.27.
-=cut
-
*/
/*
Modified: trunk/src/gc/gc_gms.c
==============================================================================
--- trunk/src/gc/gc_gms.c (original)
+++ trunk/src/gc/gc_gms.c Sat Jun 9 14:28:07 2007
@@ -982,8 +982,9 @@
*/
+PARROT_API
void
-parrot_gc_gms_pobject_lives(Interp* interp, PObj *obj)
+parrot_gc_gms_pobject_lives(Interp* interp /*NN*/, PObj *obj /*NN*/)
{
Gc_gms_hdr *h;
int priority;
Modified: trunk/src/headers.c
==============================================================================
--- trunk/src/headers.c (original)
+++ trunk/src/headers.c Sat Jun 9 14:28:07 2007
@@ -452,7 +452,7 @@
*/
int
-is_buffer_ptr(Interp *interp, void *ptr) /* XXX Const this */
+is_buffer_ptr(Interp *interp /*NN*/, void *ptr) /* XXX Const this */
{
UINTVAL i;
Arenas * const arena_base = interp->arena_base;