[svn:parrot] r49053 - branches/string_gc_encapsulate/src/gc
bacek at svn.parrot.org
bacek at svn.parrot.org
Thu Sep 16 11:01:23 UTC 2010
Author: bacek
Date: Thu Sep 16 11:01:23 2010
New Revision: 49053
URL: https://trac.parrot.org/parrot/changeset/49053
Log:
Implement Parrot_gc_str_free_buffer_storage for freeing allocated resources
Modified:
branches/string_gc_encapsulate/src/gc/gc_private.h
branches/string_gc_encapsulate/src/gc/mark_sweep.c
branches/string_gc_encapsulate/src/gc/string_gc.c
Modified: branches/string_gc_encapsulate/src/gc/gc_private.h
==============================================================================
--- branches/string_gc_encapsulate/src/gc/gc_private.h Thu Sep 16 11:00:43 2010 (r49052)
+++ branches/string_gc_encapsulate/src/gc/gc_private.h Thu Sep 16 11:01:23 2010 (r49053)
@@ -694,6 +694,13 @@
__attribute__nonnull__(1)
__attribute__nonnull__(2);
+void Parrot_gc_str_free_buffer_storage(SHIM_INTERP,
+ ARGIN(String_GC *gc),
+ ARGMOD(Buffer *b))
+ __attribute__nonnull__(2)
+ __attribute__nonnull__(3)
+ FUNC_MODIFIES(*b);
+
void Parrot_gc_str_reallocate_buffer_storage(PARROT_INTERP,
ARGMOD(Buffer *buffer),
size_t newsize)
@@ -719,6 +726,10 @@
#define ASSERT_ARGS_Parrot_gc_str_compact_pool __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp) \
, PARROT_ASSERT_ARG(gc))
+#define ASSERT_ARGS_Parrot_gc_str_free_buffer_storage \
+ __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
+ PARROT_ASSERT_ARG(gc) \
+ , PARROT_ASSERT_ARG(b))
#define ASSERT_ARGS_Parrot_gc_str_reallocate_buffer_storage \
__attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp) \
Modified: branches/string_gc_encapsulate/src/gc/mark_sweep.c
==============================================================================
--- branches/string_gc_encapsulate/src/gc/mark_sweep.c Thu Sep 16 11:00:43 2010 (r49052)
+++ branches/string_gc_encapsulate/src/gc/mark_sweep.c Thu Sep 16 11:01:23 2010 (r49053)
@@ -31,13 +31,13 @@
/* HEADERIZER BEGIN: static */
/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
-static void free_buffer(SHIM_INTERP,
- SHIM(Memory_Pools *mem_pools),
- ARGMOD(Fixed_Size_Pool *pool),
+static void free_buffer(PARROT_INTERP,
+ ARGIN(Memory_Pools *mem_pools),
+ SHIM(Fixed_Size_Pool *pool),
ARGMOD(Buffer *b))
- __attribute__nonnull__(3)
+ __attribute__nonnull__(1)
+ __attribute__nonnull__(2)
__attribute__nonnull__(4)
- FUNC_MODIFIES(*pool)
FUNC_MODIFIES(*b);
static void free_pmc_in_pool(PARROT_INTERP,
@@ -78,7 +78,8 @@
FUNC_MODIFIES(*mem_pools);
#define ASSERT_ARGS_free_buffer __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
- PARROT_ASSERT_ARG(pool) \
+ PARROT_ASSERT_ARG(interp) \
+ , PARROT_ASSERT_ARG(mem_pools) \
, PARROT_ASSERT_ARG(b))
#define ASSERT_ARGS_free_pmc_in_pool __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp) \
@@ -657,39 +658,18 @@
*/
static void
-free_buffer(SHIM_INTERP,
- SHIM(Memory_Pools *mem_pools),
- ARGMOD(Fixed_Size_Pool *pool),
+free_buffer(PARROT_INTERP,
+ ARGIN(Memory_Pools *mem_pools),
+ SHIM(Fixed_Size_Pool *pool),
ARGMOD(Buffer *b))
{
ASSERT_ARGS(free_buffer)
- Variable_Size_Pool * const mem_pool = (Variable_Size_Pool *)pool->mem_pool;
/* If there is no allocated buffer - bail out */
if (!Buffer_buflen(b))
return;
- /* XXX Jarkko reported that on irix pool->mem_pool was NULL, which really
- * shouldn't happen */
- if (mem_pool) {
- /* Update Memory_Block usage */
- if (PObj_is_movable_TESTALL(b)) {
- INTVAL *buffer_flags = Buffer_bufflagsptr(b);
-
- /* Mask low 2 bits used for flags */
- Memory_Block * block = Buffer_pool(b);
-
- PARROT_ASSERT(block);
-
- /* We can have shared buffers. Don't count them (yet) */
- if (!(*buffer_flags & Buffer_shared_FLAG)) {
- block->freed += ALIGNED_STRING_SIZE(Buffer_buflen(b));
- }
-
- }
- }
-
- Buffer_buflen(b) = 0;
+ Parrot_gc_str_free_buffer_storage(interp, &mem_pools->string_gc, b);
}
Modified: branches/string_gc_encapsulate/src/gc/string_gc.c
==============================================================================
--- branches/string_gc_encapsulate/src/gc/string_gc.c Thu Sep 16 11:00:43 2010 (r49052)
+++ branches/string_gc_encapsulate/src/gc/string_gc.c Thu Sep 16 11:01:23 2010 (r49053)
@@ -266,6 +266,50 @@
/*
+=item C<void Parrot_gc_str_free_buffer_storage(PARROT_INTERP, String_GC *gc,
+Buffer *b)>
+
+Frees a buffer, returning it to the memory pool for Parrot to possibly
+reuse later.
+
+=cut
+
+*/
+
+void
+Parrot_gc_str_free_buffer_storage(SHIM_INTERP,
+ ARGIN(String_GC *gc),
+ ARGMOD(Buffer *b))
+{
+ ASSERT_ARGS(free_buffer)
+ Variable_Size_Pool * const mem_pool = gc->memory_pool;
+
+ /* If there is no allocated buffer - bail out */
+ if (!Buffer_buflen(b))
+ return;
+
+ if (mem_pool) {
+ /* Update Memory_Block usage */
+ if (PObj_is_movable_TESTALL(b)) {
+ INTVAL *buffer_flags = Buffer_bufflagsptr(b);
+
+ /* Mask low 2 bits used for flags */
+ Memory_Block * block = Buffer_pool(b);
+
+ PARROT_ASSERT(block);
+
+ /* We can have shared buffers. Don't count them (yet) */
+ if (!(*buffer_flags & Buffer_shared_FLAG)) {
+ block->freed += ALIGNED_STRING_SIZE(Buffer_buflen(b));
+ }
+
+ }
+ }
+
+ Buffer_buflen(b) = 0;
+}
+/*
+
=back
=head1 SEE ALSO
More information about the parrot-commits
mailing list