[svn:parrot] r49056 - branches/string_gc_encapsulate/src/gc
bacek at svn.parrot.org
bacek at svn.parrot.org
Thu Sep 16 12:39:03 UTC 2010
Author: bacek
Date: Thu Sep 16 12:39:03 2010
New Revision: 49056
URL: https://trac.parrot.org/parrot/changeset/49056
Log:
More split String GC allocations for buffers to be less dependend from Memory_Pools
Modified:
branches/string_gc_encapsulate/src/gc/gc_ms.c
branches/string_gc_encapsulate/src/gc/gc_private.h
branches/string_gc_encapsulate/src/gc/string_gc.c
Modified: branches/string_gc_encapsulate/src/gc/gc_ms.c
==============================================================================
--- branches/string_gc_encapsulate/src/gc/gc_ms.c Thu Sep 16 12:11:05 2010 (r49055)
+++ branches/string_gc_encapsulate/src/gc/gc_ms.c Thu Sep 16 12:39:03 2010 (r49056)
@@ -403,11 +403,11 @@
interp->gc_sys->allocate_pmc_attributes = gc_ms_allocate_pmc_attributes;
interp->gc_sys->free_pmc_attributes = gc_ms_free_pmc_attributes;
- interp->gc_sys->allocate_string_storage = Parrot_gc_str_allocate_string_storage;
- interp->gc_sys->reallocate_string_storage = Parrot_gc_str_reallocate_string_storage;
+ interp->gc_sys->allocate_string_storage = gc_ms_allocate_string_storage;
+ interp->gc_sys->reallocate_string_storage = gc_ms_reallocate_string_storage;
- interp->gc_sys->allocate_buffer_storage = Parrot_gc_str_allocate_buffer_storage;
- interp->gc_sys->reallocate_buffer_storage = Parrot_gc_str_reallocate_buffer_storage;
+ interp->gc_sys->allocate_buffer_storage = gc_ms_allocate_buffer_storage;
+ interp->gc_sys->reallocate_buffer_storage = gc_ms_reallocate_buffer_storage;
interp->gc_sys->allocate_fixed_size_storage = gc_ms_allocate_fixed_size_storage;
interp->gc_sys->free_fixed_size_storage = gc_ms_free_fixed_size_storage;
@@ -577,6 +577,30 @@
Parrot_gc_str_compact_pool(interp, &interp->mem_pools->string_gc);
}
+void
+gc_ms_allocate_string_storage(PARROT_INTERP, ARGIN(STRING *str), size_t size)
+{
+ Parrot_gc_str_allocate_string_storage(interp, &interp->mem_pools->string_gc, str, size);
+}
+
+void
+gc_ms_reallocate_string_storage(PARROT_INTERP, ARGIN(STRING *str), size_t size)
+{
+ Parrot_gc_str_reallocate_string_storage(interp, &interp->mem_pools->string_gc, str, size);
+}
+
+void
+gc_ms_allocate_buffer_storage(PARROT_INTERP, ARGIN(Buffer *str), size_t size)
+{
+ Parrot_gc_str_allocate_buffer_storage(interp, &interp->mem_pools->string_gc, str, size);
+}
+
+void
+gc_ms_reallocate_buffer_storage(PARROT_INTERP, ARGIN(Buffer *str), size_t size)
+{
+ Parrot_gc_str_reallocate_buffer_storage(interp, &interp->mem_pools->string_gc, str, size);
+}
+
/*
=item C<static void gc_ms_mark_special(PARROT_INTERP, PMC *pmc)>
Modified: branches/string_gc_encapsulate/src/gc/gc_private.h
==============================================================================
--- branches/string_gc_encapsulate/src/gc/gc_private.h Thu Sep 16 12:11:05 2010 (r49055)
+++ branches/string_gc_encapsulate/src/gc/gc_private.h Thu Sep 16 12:39:03 2010 (r49056)
@@ -605,10 +605,22 @@
/* HEADERIZER BEGIN: src/gc/gc_ms.c */
/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
+void gc_ms_allocate_buffer_storage(PARROT_INTERP,
+ ARGIN(Buffer *str),
+ size_t size)
+ __attribute__nonnull__(1)
+ __attribute__nonnull__(2);
+
PARROT_CANNOT_RETURN_NULL
void * gc_ms_allocate_fixed_size_storage(PARROT_INTERP, size_t size)
__attribute__nonnull__(1);
+void gc_ms_allocate_string_storage(PARROT_INTERP,
+ ARGIN(STRING *str),
+ size_t size)
+ __attribute__nonnull__(1)
+ __attribute__nonnull__(2);
+
void gc_ms_compact_memory_pool(PARROT_INTERP)
__attribute__nonnull__(1);
@@ -629,12 +641,30 @@
__attribute__nonnull__(2)
FUNC_MODIFIES(*pmc);
+void gc_ms_reallocate_buffer_storage(PARROT_INTERP,
+ ARGIN(Buffer *str),
+ size_t size)
+ __attribute__nonnull__(1)
+ __attribute__nonnull__(2);
+
+void gc_ms_reallocate_string_storage(PARROT_INTERP,
+ ARGIN(STRING *str),
+ size_t size)
+ __attribute__nonnull__(1)
+ __attribute__nonnull__(2);
+
void Parrot_gc_ms_init(PARROT_INTERP)
__attribute__nonnull__(1);
+#define ASSERT_ARGS_gc_ms_allocate_buffer_storage __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
+ PARROT_ASSERT_ARG(interp) \
+ , PARROT_ASSERT_ARG(str))
#define ASSERT_ARGS_gc_ms_allocate_fixed_size_storage \
__attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp))
+#define ASSERT_ARGS_gc_ms_allocate_string_storage __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
+ PARROT_ASSERT_ARG(interp) \
+ , PARROT_ASSERT_ARG(str))
#define ASSERT_ARGS_gc_ms_compact_memory_pool __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp))
#define ASSERT_ARGS_gc_ms_free_fixed_size_storage __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
@@ -647,6 +677,14 @@
__attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp) \
, PARROT_ASSERT_ARG(pmc))
+#define ASSERT_ARGS_gc_ms_reallocate_buffer_storage \
+ __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
+ PARROT_ASSERT_ARG(interp) \
+ , PARROT_ASSERT_ARG(str))
+#define ASSERT_ARGS_gc_ms_reallocate_string_storage \
+ __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
+ PARROT_ASSERT_ARG(interp) \
+ , PARROT_ASSERT_ARG(str))
#define ASSERT_ARGS_Parrot_gc_ms_init __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp))
/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
@@ -679,17 +717,21 @@
FUNC_MODIFIES(*pool);
void Parrot_gc_str_allocate_buffer_storage(PARROT_INTERP,
+ ARGIN(String_GC *gc),
ARGOUT(Buffer *buffer),
size_t size)
__attribute__nonnull__(1)
__attribute__nonnull__(2)
+ __attribute__nonnull__(3)
FUNC_MODIFIES(*buffer);
void Parrot_gc_str_allocate_string_storage(PARROT_INTERP,
+ ARGIN(String_GC *gc),
ARGOUT(STRING *str),
size_t size)
__attribute__nonnull__(1)
__attribute__nonnull__(2)
+ __attribute__nonnull__(3)
FUNC_MODIFIES(*str);
void Parrot_gc_str_compact_pool(PARROT_INTERP, ARGIN(String_GC *gc))
@@ -709,17 +751,21 @@
FUNC_MODIFIES(*gc);
void Parrot_gc_str_reallocate_buffer_storage(PARROT_INTERP,
+ ARGIN(String_GC *gc),
ARGMOD(Buffer *buffer),
size_t newsize)
__attribute__nonnull__(1)
__attribute__nonnull__(2)
+ __attribute__nonnull__(3)
FUNC_MODIFIES(*buffer);
void Parrot_gc_str_reallocate_string_storage(PARROT_INTERP,
+ ARGIN(String_GC *gc),
ARGMOD(STRING *str),
size_t newsize)
__attribute__nonnull__(1)
__attribute__nonnull__(2)
+ __attribute__nonnull__(3)
FUNC_MODIFIES(*str);
#define ASSERT_ARGS_Parrot_gc_str_alloc_new_block __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
@@ -729,10 +775,12 @@
#define ASSERT_ARGS_Parrot_gc_str_allocate_buffer_storage \
__attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp) \
+ , PARROT_ASSERT_ARG(gc) \
, PARROT_ASSERT_ARG(buffer))
#define ASSERT_ARGS_Parrot_gc_str_allocate_string_storage \
__attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp) \
+ , PARROT_ASSERT_ARG(gc) \
, PARROT_ASSERT_ARG(str))
#define ASSERT_ARGS_Parrot_gc_str_compact_pool __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp) \
@@ -747,10 +795,12 @@
#define ASSERT_ARGS_Parrot_gc_str_reallocate_buffer_storage \
__attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp) \
+ , PARROT_ASSERT_ARG(gc) \
, PARROT_ASSERT_ARG(buffer))
#define ASSERT_ARGS_Parrot_gc_str_reallocate_string_storage \
__attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp) \
+ , PARROT_ASSERT_ARG(gc) \
, PARROT_ASSERT_ARG(str))
/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
/* HEADERIZER END: src/gc/string_gc.c */
Modified: branches/string_gc_encapsulate/src/gc/string_gc.c
==============================================================================
--- branches/string_gc_encapsulate/src/gc/string_gc.c Thu Sep 16 12:11:05 2010 (r49055)
+++ branches/string_gc_encapsulate/src/gc/string_gc.c Thu Sep 16 12:39:03 2010 (r49056)
@@ -101,8 +101,8 @@
/*
-=item C<void Parrot_gc_str_allocate_buffer_storage(PARROT_INTERP, Buffer
-*buffer, size_t size)>
+=item C<void Parrot_gc_str_allocate_buffer_storage(PARROT_INTERP, String_GC *gc,
+Buffer *buffer, size_t size)>
Allocates a chunk of memory of at least size C<size> for the given Buffer.
buffer is guaranteed to be properly aligned for things like C<FLOATVALS>,
@@ -114,25 +114,27 @@
void
Parrot_gc_str_allocate_buffer_storage(PARROT_INTERP,
- ARGOUT(Buffer *buffer), size_t size)
+ ARGIN(String_GC *gc),
+ ARGOUT(Buffer *buffer),
+ size_t size)
{
ASSERT_ARGS(Parrot_gc_str_allocate_buffer_storage)
const size_t new_size = ALIGNED_STRING_SIZE(size);
Buffer_bufstart(buffer) = (void *)aligned_mem(buffer,
(char *)mem_allocate(interp,
- interp->mem_pools, new_size, interp->mem_pools->string_gc.memory_pool));
+ interp->mem_pools, new_size, gc->memory_pool));
/* Save pool used to allocate into buffer header */
- *Buffer_poolptr(buffer) = interp->mem_pools->string_gc.memory_pool->top_block;
+ *Buffer_poolptr(buffer) = gc->memory_pool->top_block;
Buffer_buflen(buffer) = new_size - sizeof (void *);
}
/*
-=item C<void Parrot_gc_str_reallocate_buffer_storage(PARROT_INTERP, Buffer
-*buffer, size_t newsize)>
+=item C<void Parrot_gc_str_reallocate_buffer_storage(PARROT_INTERP, String_GC
+*gc, Buffer *buffer, size_t newsize)>
Reallocate the Buffer's buffer memory to the given size. The
allocated buffer will not shrink. If the buffer was allocated with
@@ -145,13 +147,15 @@
*/
void
-Parrot_gc_str_reallocate_buffer_storage(PARROT_INTERP, ARGMOD(Buffer *buffer),
- size_t newsize)
+Parrot_gc_str_reallocate_buffer_storage(PARROT_INTERP,
+ ARGIN(String_GC *gc),
+ ARGMOD(Buffer *buffer),
+ size_t newsize)
{
ASSERT_ARGS(Parrot_gc_str_reallocate_buffer_storage)
size_t copysize;
char *mem;
- Variable_Size_Pool * const pool = interp->mem_pools->string_gc.memory_pool;
+ Variable_Size_Pool * const pool = gc->memory_pool;
size_t new_size, needed, old_size;
/* we don't shrink buffers */
@@ -196,13 +200,13 @@
Buffer_buflen(buffer) = new_size;
/* Save pool used to allocate into buffer header */
- *Buffer_poolptr(buffer) = interp->mem_pools->string_gc.memory_pool->top_block;
+ *Buffer_poolptr(buffer) = gc->memory_pool->top_block;
}
/*
-=item C<void Parrot_gc_str_allocate_string_storage(PARROT_INTERP, STRING *str,
-size_t size)>
+=item C<void Parrot_gc_str_allocate_string_storage(PARROT_INTERP, String_GC *gc,
+STRING *str, size_t size)>
Allocate the STRING's buffer memory to the given size. The allocated
buffer maybe slightly bigger than the given C<size>. This function
@@ -214,8 +218,10 @@
*/
void
-Parrot_gc_str_allocate_string_storage(PARROT_INTERP, ARGOUT(STRING *str),
- size_t size)
+Parrot_gc_str_allocate_string_storage(PARROT_INTERP,
+ ARGIN(String_GC *gc),
+ ARGOUT(STRING *str),
+ size_t size)
{
ASSERT_ARGS(Parrot_gc_str_allocate_string_storage)
size_t new_size;
@@ -229,8 +235,8 @@
return;
pool = PObj_constant_TEST(str)
- ? interp->mem_pools->string_gc.constant_string_pool
- : interp->mem_pools->string_gc.memory_pool;
+ ? gc->constant_string_pool
+ : gc->memory_pool;
new_size = ALIGNED_STRING_SIZE(size);
mem = (char *)mem_allocate(interp, interp->mem_pools, new_size, pool);
@@ -245,8 +251,8 @@
/*
-=item C<void Parrot_gc_str_reallocate_string_storage(PARROT_INTERP, STRING *str,
-size_t newsize)>
+=item C<void Parrot_gc_str_reallocate_string_storage(PARROT_INTERP, String_GC
+*gc, STRING *str, size_t newsize)>
Reallocate the STRING's buffer memory to the given size. The allocated
buffer will not shrink. This function sets also C<str-E<gt>strstart> to the
@@ -257,8 +263,10 @@
*/
void
-Parrot_gc_str_reallocate_string_storage(PARROT_INTERP, ARGMOD(STRING *str),
- size_t newsize)
+Parrot_gc_str_reallocate_string_storage(PARROT_INTERP,
+ ARGIN(String_GC *gc),
+ ARGMOD(STRING *str),
+ size_t newsize)
{
ASSERT_ARGS(Parrot_gc_str_reallocate_string_storage)
size_t copysize;
@@ -267,8 +275,8 @@
Variable_Size_Pool * const pool =
PObj_constant_TEST(str)
- ? interp->mem_pools->string_gc.constant_string_pool
- : interp->mem_pools->string_gc.memory_pool;
+ ? gc->constant_string_pool
+ : gc->memory_pool;
/* if the requested size is smaller then buflen, we are done */
if (newsize <= Buffer_buflen(str))
More information about the parrot-commits
mailing list