[svn:parrot] r49594 - branches/generational_gc/src/gc
bacek at svn.parrot.org
bacek at svn.parrot.org
Wed Oct 20 06:24:59 UTC 2010
Author: bacek
Date: Wed Oct 20 06:24:59 2010
New Revision: 49594
URL: https://trac.parrot.org/parrot/changeset/49594
Log:
Add calculation of Pool_Allocator allocated memory
Modified:
branches/generational_gc/src/gc/fixed_allocator.c
branches/generational_gc/src/gc/fixed_allocator.h
Modified: branches/generational_gc/src/gc/fixed_allocator.c
==============================================================================
--- branches/generational_gc/src/gc/fixed_allocator.c Wed Oct 20 05:31:50 2010 (r49593)
+++ branches/generational_gc/src/gc/fixed_allocator.c Wed Oct 20 06:24:59 2010 (r49594)
@@ -211,6 +211,11 @@
check for pool validity
+=item C<size_t Parrot_gc_pool_allocated_size(PARROT_INTERP, Pool_Allocator
+*pool)>
+
+Calculate size of memory allocated by pool.
+
=back
=cut
@@ -285,6 +290,21 @@
return pool_is_owned(pool, ptr);
}
+PARROT_EXPORT
+size_t
+Parrot_gc_pool_allocated_size(SHIM_INTERP, ARGIN(Pool_Allocator *pool))
+{
+ ASSERT_ARGS(Parrot_gc_pool_allocated_size)
+ Pool_Allocator_Arena *arena = pool->top_arena;
+ int count = 0;
+ while (arena) {
+ count++;
+ arena = arena->next;
+ }
+
+ return count * arena_size(pool);
+}
+
/*
Modified: branches/generational_gc/src/gc/fixed_allocator.h
==============================================================================
--- branches/generational_gc/src/gc/fixed_allocator.h Wed Oct 20 05:31:50 2010 (r49593)
+++ branches/generational_gc/src/gc/fixed_allocator.h Wed Oct 20 06:24:59 2010 (r49594)
@@ -94,6 +94,11 @@
FUNC_MODIFIES(* pool);
PARROT_EXPORT
+size_t Parrot_gc_pool_allocated_size(SHIM_INTERP,
+ ARGIN(Pool_Allocator *pool))
+ __attribute__nonnull__(2);
+
+PARROT_EXPORT
void Parrot_gc_pool_destroy(SHIM_INTERP, ARGMOD(Pool_Allocator *pool))
__attribute__nonnull__(2)
FUNC_MODIFIES(*pool);
@@ -136,6 +141,8 @@
#define ASSERT_ARGS_Parrot_gc_pool_allocate __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp) \
, PARROT_ASSERT_ARG(pool))
+#define ASSERT_ARGS_Parrot_gc_pool_allocated_size __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
+ PARROT_ASSERT_ARG(pool))
#define ASSERT_ARGS_Parrot_gc_pool_destroy __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(pool))
#define ASSERT_ARGS_Parrot_gc_pool_free __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
More information about the parrot-commits
mailing list