[svn:parrot] r49675 - branches/generational_gc/src/gc
bacek at svn.parrot.org
bacek at svn.parrot.org
Mon Oct 25 20:04:29 UTC 2010
Author: bacek
Date: Mon Oct 25 20:04:29 2010
New Revision: 49675
URL: https://trac.parrot.org/parrot/changeset/49675
Log:
Introduce pool_is_maybe_owned function for quick preliminary check for pointer. Will be used in GC.is_string_ptr or .is_pmc_ptr
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 Mon Oct 25 19:27:32 2010 (r49674)
+++ branches/generational_gc/src/gc/fixed_allocator.c Mon Oct 25 20:04:29 2010 (r49675)
@@ -50,6 +50,13 @@
__attribute__nonnull__(1)
FUNC_MODIFIES(*pool);
+static int pool_is_maybe_owned(
+ ARGMOD(Pool_Allocator *pool),
+ ARGIN(void *ptr))
+ __attribute__nonnull__(1)
+ __attribute__nonnull__(2)
+ FUNC_MODIFIES(*pool);
+
static int pool_is_owned(ARGMOD(Pool_Allocator *pool), ARGIN(void *ptr))
__attribute__nonnull__(1)
__attribute__nonnull__(2)
@@ -67,6 +74,9 @@
PARROT_ASSERT_ARG(pool))
#define ASSERT_ARGS_pool_free __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(pool))
+#define ASSERT_ARGS_pool_is_maybe_owned __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
+ PARROT_ASSERT_ARG(pool) \
+ , PARROT_ASSERT_ARG(ptr))
#define ASSERT_ARGS_pool_is_owned __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(pool) \
, PARROT_ASSERT_ARG(ptr))
@@ -231,7 +241,12 @@
=item C<int Parrot_gc_pool_is_owned(PARROT_INTERP, Pool_Allocator *pool, void
*ptr)>
-check for pool validity
+check that pointer is owned by pool.
+
+=item C<int Parrot_gc_pool_is_maybe_owned(PARROT_INTERP, Pool_Allocator *pool,
+void *ptr)>
+
+check that pointer is probably owned by pool.
=item C<size_t Parrot_gc_pool_allocated_size(PARROT_INTERP, Pool_Allocator
*pool)>
@@ -313,6 +328,15 @@
}
PARROT_EXPORT
+int
+Parrot_gc_pool_is_maybe_owned(SHIM_INTERP, ARGMOD(Pool_Allocator *pool), ARGMOD(void *ptr))
+{
+ ASSERT_ARGS(Parrot_gc_pool_is_owned)
+ return pool_is_maybe_owned(pool, ptr);
+}
+
+
+PARROT_EXPORT
size_t
Parrot_gc_pool_allocated_size(SHIM_INTERP, ARGIN(Pool_Allocator *pool))
{
@@ -344,6 +368,8 @@
=item C<static int pool_is_owned(Pool_Allocator *pool, void *ptr)>
+=item C<static int pool_is_maybe_owned(Pool_Allocator *pool, void *ptr)>
+
Static implementation of public methods.
=cut
@@ -415,6 +441,15 @@
++pool->num_free_objects;
}
+static int
+pool_is_maybe_owned(ARGMOD(Pool_Allocator *pool), ARGIN(void *ptr))
+{
+ ASSERT_ARGS(pool_is_owned)
+ Pool_Allocator_Arena *arena = pool->top_arena;
+ size_t a_size;
+
+ return (ptr >= pool->lo_arena_ptr && ptr < pool->hi_arena_ptr);
+}
static int
pool_is_owned(ARGMOD(Pool_Allocator *pool), ARGIN(void *ptr))
Modified: branches/generational_gc/src/gc/fixed_allocator.h
==============================================================================
--- branches/generational_gc/src/gc/fixed_allocator.h Mon Oct 25 19:27:32 2010 (r49674)
+++ branches/generational_gc/src/gc/fixed_allocator.h Mon Oct 25 20:04:29 2010 (r49675)
@@ -117,6 +117,15 @@
FUNC_MODIFIES(*pool);
PARROT_EXPORT
+int Parrot_gc_pool_is_maybe_owned(SHIM_INTERP,
+ ARGMOD(Pool_Allocator *pool),
+ ARGMOD(void *ptr))
+ __attribute__nonnull__(2)
+ __attribute__nonnull__(3)
+ FUNC_MODIFIES(*pool)
+ FUNC_MODIFIES(*ptr);
+
+PARROT_EXPORT
int Parrot_gc_pool_is_owned(SHIM_INTERP,
ARGMOD(Pool_Allocator *pool),
ARGMOD(void *ptr))
@@ -157,6 +166,9 @@
PARROT_ASSERT_ARG(pool))
#define ASSERT_ARGS_Parrot_gc_pool_free __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(pool))
+#define ASSERT_ARGS_Parrot_gc_pool_is_maybe_owned __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
+ PARROT_ASSERT_ARG(pool) \
+ , PARROT_ASSERT_ARG(ptr))
#define ASSERT_ARGS_Parrot_gc_pool_is_owned __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(pool) \
, PARROT_ASSERT_ARG(ptr))
More information about the parrot-commits
mailing list