[svn:parrot] r38560 - in branches/gc_api: include/parrot src src/gc
whiteknight at svn.parrot.org
whiteknight at svn.parrot.org
Fri May 8 00:27:36 UTC 2009
Author: whiteknight
Date: Fri May 8 00:27:35 2009
New Revision: 38560
URL: https://trac.parrot.org/parrot/changeset/38560
Log:
[gc_api] change src/stacks.c to not be monkeying around in the internals of the gc
Modified:
branches/gc_api/include/parrot/gc_api.h
branches/gc_api/include/parrot/stacks.h
branches/gc_api/src/gc/api.c
branches/gc_api/src/stacks.c
Modified: branches/gc_api/include/parrot/gc_api.h
==============================================================================
--- branches/gc_api/include/parrot/gc_api.h Fri May 8 00:07:51 2009 (r38559)
+++ branches/gc_api/include/parrot/gc_api.h Fri May 8 00:27:35 2009 (r38560)
@@ -82,6 +82,13 @@
__attribute__nonnull__(3)
FUNC_MODIFIES(*b);
+void Parrot_gc_free_bufferlike_header(PARROT_INTERP,
+ ARGMOD(PObj *obj),
+ size_t size)
+ __attribute__nonnull__(1)
+ __attribute__nonnull__(2)
+ FUNC_MODIFIES(*obj);
+
void Parrot_gc_free_pmc(PARROT_INTERP,
SHIM(Small_Object_Pool *pool),
ARGMOD(PObj *p))
@@ -137,6 +144,10 @@
|| PARROT_ASSERT_ARG(b)
#define ASSERT_ARGS_Parrot_gc_free_buffer_malloc __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(b)
+#define ASSERT_ARGS_Parrot_gc_free_bufferlike_header \
+ __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+ PARROT_ASSERT_ARG(interp) \
+ || PARROT_ASSERT_ARG(obj)
#define ASSERT_ARGS_Parrot_gc_free_pmc __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp) \
|| PARROT_ASSERT_ARG(p)
Modified: branches/gc_api/include/parrot/stacks.h
==============================================================================
--- branches/gc_api/include/parrot/stacks.h Fri May 8 00:07:51 2009 (r38559)
+++ branches/gc_api/include/parrot/stacks.h Fri May 8 00:27:35 2009 (r38560)
@@ -29,7 +29,6 @@
typedef struct Stack_Chunk {
UnionVal cache;
Parrot_UInt flags;
- struct Small_Object_Pool *pool;
const char *name;
struct Stack_Chunk *prev;
Parrot_UInt refcount;
Modified: branches/gc_api/src/gc/api.c
==============================================================================
--- branches/gc_api/src/gc/api.c Fri May 8 00:07:51 2009 (r38559)
+++ branches/gc_api/src/gc/api.c Fri May 8 00:27:35 2009 (r38560)
@@ -223,7 +223,7 @@
/*
-=item C<void * new_bufferlike_header(PARROT_INTERP, size_t size)>
+=item C<void * Parrot_gc_new_bufferlike_header(PARROT_INTERP, size_t size)>
Returns a new buffer-like header from the appropriate sized pool.
A "bufferlike object" is an object that is considered to be isomorphic to the
@@ -245,6 +245,23 @@
return get_free_buffer(interp, pool);
}
+/*
+
+=item C<void Parrot_gc_free_bufferlike_header(PARROT_INTERP, PObj *obj, size_t
+size)>
+
+=cut
+
+*/
+
+void
+Parrot_gc_free_bufferlike_header(PARROT_INTERP, ARGMOD(PObj *obj),
+ size_t size)
+{
+ Small_Object_Pool * const pool = get_bufferlike_pool(interp, size);
+ pool->add_free_object(interp, pool, obj);
+}
+
/*
Modified: branches/gc_api/src/stacks.c
==============================================================================
--- branches/gc_api/src/stacks.c Fri May 8 00:07:51 2009 (r38559)
+++ branches/gc_api/src/stacks.c Fri May 8 00:27:35 2009 (r38560)
@@ -74,13 +74,12 @@
cst_new_stack_chunk(PARROT_INTERP, ARGIN(const Stack_Chunk_t *chunk))
{
ASSERT_ARGS(cst_new_stack_chunk)
- Small_Object_Pool * const pool = chunk->pool;
- Stack_Chunk_t * const new_chunk = (Stack_Chunk_t *)pool->get_free_object(interp, pool);
+ Stack_Chunk_t * const new_chunk =
+ (Stack_Chunk_t *)Parrot_gc_new_bufferlike_header(interp, sizeof(Stack_Chunk_t));
PObj_bufstart(new_chunk) = NULL;
PObj_buflen(new_chunk) = 0;
- new_chunk->pool = chunk->pool;
new_chunk->name = chunk->name;
return new_chunk;
@@ -104,12 +103,11 @@
new_stack(PARROT_INTERP, ARGIN(const char *name))
{
ASSERT_ARGS(new_stack)
- Small_Object_Pool * const pool = get_bufferlike_pool(interp, sizeof (Stack_Chunk_t));
- Stack_Chunk_t * const chunk = (Stack_Chunk_t *)(pool->get_free_object)(interp, pool);
+ Stack_Chunk_t * const chunk =
+ (Stack_Chunk_t *)Parrot_gc_new_bufferlike_header(interp, sizeof(Stack_Chunk_t));
chunk->prev = chunk; /* mark the top of the stack */
chunk->name = name;
- chunk->pool = pool; /* cache the pool pointer, for ease */
return chunk;
}
@@ -371,10 +369,8 @@
}
/* recycle this chunk to the free list if it's otherwise unreferenced */
- if (cur_chunk->refcount <= 0) {
- Small_Object_Pool * const pool = cur_chunk->pool;
- pool->add_free_object(interp, pool, (PObj *)cur_chunk);
- }
+ if (cur_chunk->refcount <= 0)
+ Parrot_gc_free_bufferlike_header(interp, (PObj *)cur_chunk, sizeof (Stack_Chunk_t));
return where;
}
More information about the parrot-commits
mailing list