[svn:parrot] r49156 - branches/gc_massacre/src/gc
bacek at svn.parrot.org
bacek at svn.parrot.org
Sun Sep 19 08:57:43 UTC 2010
Author: bacek
Date: Sun Sep 19 08:57:43 2010
New Revision: 49156
URL: https://trac.parrot.org/parrot/changeset/49156
Log:
Start using String GC in GC MS2
Modified:
branches/gc_massacre/src/gc/gc_ms2.c
Modified: branches/gc_massacre/src/gc/gc_ms2.c
==============================================================================
--- branches/gc_massacre/src/gc/gc_ms2.c Sun Sep 19 08:56:47 2010 (r49155)
+++ branches/gc_massacre/src/gc/gc_ms2.c Sun Sep 19 08:57:43 2010 (r49156)
@@ -33,6 +33,9 @@
/* Fixed-size allocator */
struct Fixed_Allocator *fixed_size_allocator;
+ /* String GC */
+ struct String_GC string_gc;
+
/* Number of allocated objects before trigger gc */
size_t gc_threshold;
@@ -61,11 +64,10 @@
static void failed_allocation(unsigned int line, unsigned long size);
static void gc_ms2_allocate_buffer_storage(PARROT_INTERP,
- ARGMOD(Buffer *buffer),
+ ARGIN(Buffer *str),
size_t size)
__attribute__nonnull__(1)
- __attribute__nonnull__(2)
- FUNC_MODIFIES(*buffer);
+ __attribute__nonnull__(2);
PARROT_MALLOC
PARROT_CAN_RETURN_NULL
@@ -103,11 +105,10 @@
__attribute__nonnull__(1);
static void gc_ms2_allocate_string_storage(PARROT_INTERP,
- ARGMOD(STRING *str),
+ ARGIN(STRING *str),
size_t size)
__attribute__nonnull__(1)
- __attribute__nonnull__(2)
- FUNC_MODIFIES(*str);
+ __attribute__nonnull__(2);
static void gc_ms2_block_GC_mark(PARROT_INTERP)
__attribute__nonnull__(1);
@@ -192,11 +193,10 @@
FUNC_MODIFIES(*pmc);
static void gc_ms2_reallocate_buffer_storage(PARROT_INTERP,
- ARGMOD(Buffer *buffer),
+ ARGIN(Buffer *str),
size_t size)
__attribute__nonnull__(1)
- __attribute__nonnull__(2)
- FUNC_MODIFIES(*buffer);
+ __attribute__nonnull__(2);
PARROT_MALLOC
PARROT_CANNOT_RETURN_NULL
@@ -212,11 +212,10 @@
size_t oldsize);
static void gc_ms2_reallocate_string_storage(PARROT_INTERP,
- ARGMOD(STRING *str),
+ ARGIN(STRING *str),
size_t size)
__attribute__nonnull__(1)
- __attribute__nonnull__(2)
- FUNC_MODIFIES(*str);
+ __attribute__nonnull__(2);
static void gc_ms2_sweep_pmc_cb(PARROT_INTERP, ARGIN(PObj *obj))
__attribute__nonnull__(1)
@@ -245,7 +244,7 @@
#define ASSERT_ARGS_gc_ms2_allocate_buffer_storage \
__attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp) \
- , PARROT_ASSERT_ARG(buffer))
+ , PARROT_ASSERT_ARG(str))
#define ASSERT_ARGS_gc_ms2_allocate_bufferlike_header \
__attribute__unused__ int _ASSERT_ARGS_CHECK = (0)
#define ASSERT_ARGS_gc_ms2_allocate_fixed_size_storage \
@@ -321,7 +320,7 @@
#define ASSERT_ARGS_gc_ms2_reallocate_buffer_storage \
__attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp) \
- , PARROT_ASSERT_ARG(buffer))
+ , PARROT_ASSERT_ARG(str))
#define ASSERT_ARGS_gc_ms2_reallocate_memory_chunk \
__attribute__unused__ int _ASSERT_ARGS_CHECK = (0)
#define ASSERT_ARGS_gc_ms2_reallocate_memory_chunk_zeroed \
@@ -413,11 +412,11 @@
=item C<static void gc_ms2_reallocate_string_storage(PARROT_INTERP, STRING *str,
size_t size)>
-=item C<static void gc_ms2_allocate_buffer_storage(PARROT_INTERP, Buffer
-*buffer, size_t size)>
+=item C<static void gc_ms2_allocate_buffer_storage(PARROT_INTERP, Buffer *str,
+size_t size)>
-=item C<static void gc_ms2_reallocate_buffer_storage(PARROT_INTERP, Buffer
-*buffer, size_t size)>
+=item C<static void gc_ms2_reallocate_buffer_storage(PARROT_INTERP, Buffer *str,
+size_t size)>
=item C<static void* gc_ms2_allocate_fixed_size_storage(PARROT_INTERP, size_t
size)>
@@ -476,86 +475,6 @@
}
}
-
-static void
-gc_ms2_allocate_string_storage(PARROT_INTERP, ARGMOD(STRING *str), size_t size)
-{
- ASSERT_ARGS(gc_ms2_allocate_string_storage)
- MarkSweep_GC *self = (MarkSweep_GC *)interp->gc_sys->gc_private;
-
- /* Packfiles requires aligned strings. */
- size = (size + WORD_ALIGN_1) & WORD_ALIGN_MASK;
- Buffer_buflen(str) = size;
-
- if (size > 0) {
- char * const mem = (char *)mem_internal_allocate(size);
-
- Buffer_bufstart(str) = str->strstart = mem;
- /*
- * FIXME Packfile pack garbage from string tail...
- */
- memset(mem, 0, size);
-
- /* Increase memory used */
- self->stats.memory_allocated += size;
- self->stats.mem_used_last_collect += size;
- }
- else {
- Buffer_bufstart(str) = NULL;
- }
-}
-
-static void
-gc_ms2_reallocate_string_storage(PARROT_INTERP, ARGMOD(STRING *str), size_t size)
-{
- ASSERT_ARGS(gc_ms2_reallocate_string_storage)
- MarkSweep_GC *self = (MarkSweep_GC *)interp->gc_sys->gc_private;
- char * const mem = (char *)mem_internal_realloc(Buffer_bufstart(str), size);
-
- self->stats.memory_allocated += size - Buffer_buflen(str);
- self->stats.mem_used_last_collect += size - Buffer_buflen(str);
-
- Buffer_bufstart(str) = str->strstart = mem;
- Buffer_buflen(str) = size;
-}
-
-
-static void
-gc_ms2_allocate_buffer_storage(PARROT_INTERP, ARGMOD(Buffer *buffer), size_t size)
-{
- ASSERT_ARGS(gc_ms2_allocate_buffer_storage)
- MarkSweep_GC *self = (MarkSweep_GC *)interp->gc_sys->gc_private;
- char *mem;
-
- Buffer_buflen(buffer) = 0;
- Buffer_bufstart(buffer) = NULL;
-
- if (size == 0)
- return;
-
- self->stats.memory_allocated += size;
- self->stats.mem_used_last_collect += size;
-
- mem = (char *)mem_internal_allocate(size);
-
- Buffer_bufstart(buffer) = mem;
- Buffer_buflen(buffer) = size;
-}
-
-static void
-gc_ms2_reallocate_buffer_storage(PARROT_INTERP, ARGMOD(Buffer *buffer), size_t size)
-{
- ASSERT_ARGS(gc_ms2_reallocate_buffer_storage)
- MarkSweep_GC *self = (MarkSweep_GC *)interp->gc_sys->gc_private;
- char * const mem = (char *)mem_internal_realloc(Buffer_bufstart(buffer), size);
-
- self->stats.memory_allocated += size - Buffer_buflen(buffer);
- self->stats.mem_used_last_collect += size - Buffer_buflen(buffer);
-
- Buffer_bufstart(buffer) = mem;
- Buffer_buflen(buffer) = size;
-}
-
PARROT_CAN_RETURN_NULL
static void*
gc_ms2_allocate_fixed_size_storage(PARROT_INTERP, size_t size)
@@ -668,8 +587,8 @@
interp->gc_sys->allocate_string_storage = gc_ms2_allocate_string_storage;
interp->gc_sys->reallocate_string_storage = gc_ms2_reallocate_string_storage;
- interp->gc_sys->allocate_buffer_storage = gc_ms2_allocate_string_storage;
- interp->gc_sys->reallocate_buffer_storage = gc_ms2_reallocate_string_storage;
+ interp->gc_sys->allocate_buffer_storage = gc_ms2_allocate_buffer_storage;
+ interp->gc_sys->reallocate_buffer_storage = gc_ms2_reallocate_buffer_storage;
interp->gc_sys->allocate_fixed_size_storage = gc_ms2_allocate_fixed_size_storage;
interp->gc_sys->free_fixed_size_storage = gc_ms2_free_fixed_size_storage;
@@ -911,6 +830,57 @@
/*
+item C<void gc_ms_allocate_string_storage(PARROT_INTERP, STRING *str, size_t
+size)>
+
+=item C<void gc_ms_reallocate_string_storage(PARROT_INTERP, STRING *str, size_t
+size)>
+
+=item C<void gc_ms_allocate_buffer_storage(PARROT_INTERP, Buffer *str, size_t
+size)>
+
+=item C<void gc_ms_reallocate_buffer_storage(PARROT_INTERP, Buffer *str, size_t
+size)>
+
+Functions for allocating strings/buffers storage.
+
+=cut
+*/
+
+static void
+gc_ms2_allocate_string_storage(PARROT_INTERP, ARGIN(STRING *str), size_t size)
+{
+ ASSERT_ARGS(gc_ms_allocate_string_storage)
+ MarkSweep_GC *self = (MarkSweep_GC *)interp->gc_sys->gc_private;
+ Parrot_gc_str_allocate_string_storage(interp, &self->string_gc, str, size);
+}
+
+static void
+gc_ms2_reallocate_string_storage(PARROT_INTERP, ARGIN(STRING *str), size_t size)
+{
+ ASSERT_ARGS(gc_ms_reallocate_string_storage)
+ MarkSweep_GC *self = (MarkSweep_GC *)interp->gc_sys->gc_private;
+ Parrot_gc_str_reallocate_string_storage(interp, &self->string_gc, str, size);
+}
+
+static void
+gc_ms2_allocate_buffer_storage(PARROT_INTERP, ARGIN(Buffer *str), size_t size)
+{
+ ASSERT_ARGS(gc_ms_allocate_buffer_storage)
+ MarkSweep_GC *self = (MarkSweep_GC *)interp->gc_sys->gc_private;
+ Parrot_gc_str_allocate_buffer_storage(interp, &self->string_gc, str, size);
+}
+
+static void
+gc_ms2_reallocate_buffer_storage(PARROT_INTERP, ARGIN(Buffer *str), size_t size)
+{
+ ASSERT_ARGS(gc_ms_reallocate_buffer_storage)
+ MarkSweep_GC *self = (MarkSweep_GC *)interp->gc_sys->gc_private;
+ Parrot_gc_str_reallocate_buffer_storage(interp, &self->string_gc, str, size);
+}
+
+/*
+
=item C<static void gc_ms2_mark_pobj_header(PARROT_INTERP, PObj * obj)>
Mark PObj as live.
More information about the parrot-commits
mailing list