[svn:parrot] r39729 - in branches/context_pmc: include/parrot src src/gc src/pmc
coke at svn.parrot.org
coke at svn.parrot.org
Tue Jun 23 00:26:47 UTC 2009
Author: coke
Date: Tue Jun 23 00:26:46 2009
New Revision: 39729
URL: https://trac.parrot.org/parrot/changeset/39729
Log:
Remove Parrot_context_ref_trace & CTX_LEAK_DEBUG
Modified:
branches/context_pmc/include/parrot/interpreter.h
branches/context_pmc/include/parrot/register.h
branches/context_pmc/src/gc/alloc_register.c
branches/context_pmc/src/pmc/continuation.pmc
branches/context_pmc/src/sub.c
Modified: branches/context_pmc/include/parrot/interpreter.h
==============================================================================
--- branches/context_pmc/include/parrot/interpreter.h Mon Jun 22 23:47:11 2009 (r39728)
+++ branches/context_pmc/include/parrot/interpreter.h Tue Jun 23 00:26:46 2009 (r39729)
@@ -186,13 +186,6 @@
INTVAL *regs_i;
} Regs_ni;
-/* If CTX_LEAK_DEBUG is enabled, then turning on PARROT_CTX_DESTROY_DEBUG_FLAG
- will print tons of detail about when Parrot_Context structures are allocated
- and deallocated to stderr. If CTX_LEAK_DEBUG is disabled, then all of the
- relevant code is omitted, and PARROT_CTX_DESTROY_DEBUG_FLAG has no effect.
- */
-#define CTX_LEAK_DEBUG 1
-
struct Parrot_Context {
/* common header with Interp_Context */
struct Parrot_Context *caller_ctx; /* caller context */
@@ -701,11 +694,7 @@
PARROT_EXPORT void disable_event_checking(PARROT_INTERP);
PARROT_EXPORT void enable_event_checking(PARROT_INTERP);
-#if CTX_LEAK_DEBUG
-# define Parrot_context_ref(a, b) Parrot_context_ref_trace((a), (b), __FILE__, __LINE__)
-#else /* !CTX_LEAK_DEBUG */
-# define Parrot_context_ref(a, b) (((b)->ref_count++), (b))
-#endif /* CTX_LEAK_DEBUG */
+#define Parrot_context_ref(a, b) (((b)->ref_count++), (b))
#else /* !PARROT_IN_CORE */
Modified: branches/context_pmc/include/parrot/register.h
==============================================================================
--- branches/context_pmc/include/parrot/register.h Mon Jun 22 23:47:11 2009 (r39728)
+++ branches/context_pmc/include/parrot/register.h Tue Jun 23 00:26:46 2009 (r39729)
@@ -79,16 +79,6 @@
void Parrot_clear_s(PARROT_INTERP)
__attribute__nonnull__(1);
-PARROT_EXPORT
-PARROT_CANNOT_RETURN_NULL
-Parrot_Context * Parrot_context_ref_trace(PARROT_INTERP,
- ARGMOD(Parrot_Context *ctx),
- ARGIN(const char *file),
- int line)
- __attribute__nonnull__(1)
- __attribute__nonnull__(2)
- __attribute__nonnull__(3)
- FUNC_MODIFIES(*ctx);
PARROT_EXPORT
void Parrot_free_context(PARROT_INTERP,
@@ -146,10 +136,6 @@
PARROT_ASSERT_ARG(interp)
#define ASSERT_ARGS_Parrot_clear_s __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp)
-#define ASSERT_ARGS_Parrot_context_ref_trace __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(ctx) \
- || PARROT_ASSERT_ARG(file)
#define ASSERT_ARGS_Parrot_free_context __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp) \
|| PARROT_ASSERT_ARG(ctx)
Modified: branches/context_pmc/src/gc/alloc_register.c
==============================================================================
--- branches/context_pmc/src/gc/alloc_register.c Mon Jun 22 23:47:11 2009 (r39728)
+++ branches/context_pmc/src/gc/alloc_register.c Tue Jun 23 00:26:46 2009 (r39729)
@@ -21,17 +21,6 @@
#include "parrot/register.h"
#include "../pmc/pmc_sub.h"
-
-/* set CTX_LEAK_DEBUG_FULL to 1 for enhanced context debugging.
- * When set (1) freed contexts are "poisoned" so that any dangling
- * references produce segfaults, and (2) contexts are not recycled
- * so that later allocations don't suddenly restore a dangling
- * reference to a "working" condition.
- */
-#define CTX_LEAK_DEBUG_FULL 0
-
-
-
/* HEADERIZER HFILE: include/parrot/register.h */
/* HEADERIZER BEGIN: static */
@@ -396,13 +385,6 @@
Parrot_Context * const ctx = CONTEXT(interp);
Parrot_Context * const old = ctx->caller_ctx;
-#if CTX_LEAK_DEBUG
- if (ctx->ref_count > 0 &&
- Interp_debug_TEST(interp, PARROT_CTX_DESTROY_DEBUG_FLAG)) {
- fprintf(stderr, "[force recycle of context %p (%d refs)]\n",
- (void *)ctx, ctx->ref_count);
- }
-#endif
ctx->ref_count = 0;
Parrot_free_context(interp, ctx, 0);
@@ -488,12 +470,6 @@
ctx->n_regs_used[REGNO_STR] = number_regs_used[REGNO_STR];
ctx->n_regs_used[REGNO_PMC] = number_regs_used[REGNO_PMC];
-#if CTX_LEAK_DEBUG
- if (Interp_debug_TEST(interp, PARROT_CTX_DESTROY_DEBUG_FLAG)) {
- fprintf(stderr, "[alloc ctx %p]\n", ctx);
- }
-#endif
-
ctx->regs_mem_size = reg_alloc;
/* regs start past the context */
@@ -563,17 +539,8 @@
* calling chain (such as a continuation or outer scope) wants to
* preserve the context. The field is decremented when
* Parrot_free_context is called with the C<deref> flag set true.
- * To trace context handling and check for leaks,
- * (a) disable NDEBUG, (b) enable CTX_LEAK_DEBUG in interpreter.h,
- * and (c) execute "debug 0x80" in a (preferably small) test case.
- *
*/
if (deref) {
-#if CTX_LEAK_DEBUG
- if (Interp_debug_TEST(interp, PARROT_CTX_DESTROY_DEBUG_FLAG)) {
- fprintf(stderr, "[reference to context %p released]\n", (void*)ctx);
- }
-#endif
ctx->ref_count--;
}
@@ -610,21 +577,6 @@
ctx->n_regs_used[REGNO_STR] = 0;
ctx->n_regs_used[REGNO_PMC] = 0;
-#if CTX_LEAK_DEBUG_FULL
- /* for debugging, poison the freed context in case anything
- * tries to use it later. */
- ctx->current_results = (opcode_t *)0xbeefcafe;
- ctx->results_signature = (PMC *)0xbeefcafe;
- ctx->lex_pad = (PMC *)0xbeefcafe;
- ctx->outer_ctx = (Parrot_Context *)0xbeefcafe;
- ctx->current_cont = (PMC *)0xbeefcafe;
- ctx->current_object = (PMC *)0xbeefcafe;
- ctx->current_HLL = -1;
- ctx->handlers = (PMC *)0xbeefcafe;
- ctx->constants = (struct PackFile_Constant **)0xbeefcafe;
- ctx->current_namespace = (PMC *)0xbeefcafe;
-#endif
-
/* don't put the same context on the free list multiple times; we don't
* have the re-use versus multiple ref count semantics right yet */
if (ctx->ref_count < 0)
@@ -637,10 +589,6 @@
ptr = ctx;
slot = CALCULATE_SLOT_NUM(ctx->regs_mem_size);
-#if CTX_LEAK_DEBUG_FULL
- slot = 0;
-#endif
-
PARROT_ASSERT(slot < interp->ctx_mem.n_free_slots);
*(void **)ptr = interp->ctx_mem.free_list[slot];
interp->ctx_mem.free_list[slot] = ptr;
@@ -650,41 +598,6 @@
/*
-=item C<Parrot_Context * Parrot_context_ref_trace(PARROT_INTERP, Parrot_Context
-*ctx, const char *file, int line)>
-
-Helper function to trace references when CTX_LEAK_DEBUG is set.
-
-=cut
-
-*/
-
-PARROT_EXPORT
-PARROT_CANNOT_RETURN_NULL
-Parrot_Context *
-Parrot_context_ref_trace(PARROT_INTERP, ARGMOD(Parrot_Context *ctx),
- ARGIN(const char *file), int line)
-{
- ASSERT_ARGS(Parrot_context_ref_trace)
- if (Interp_debug_TEST(interp, PARROT_CTX_DESTROY_DEBUG_FLAG)) {
- const char *name = "unknown";
- Parrot_sub *sub;
-
- PMC_get_sub(interp, ctx->current_sub, sub);
- if (ctx->current_sub)
- name = (char *)(sub->name->strstart);
-
- fprintf(stderr, "[reference to context %p ('%s') taken at %s:%d]\n",
- (void *)ctx, name, file, line);
- }
-
- ctx->ref_count++;
- return ctx;
-}
-
-
-/*
-
=item C<void Parrot_set_context_threshold(PARROT_INTERP, Parrot_Context *ctx)>
Marks the context as possible threshold.
Modified: branches/context_pmc/src/pmc/continuation.pmc
==============================================================================
--- branches/context_pmc/src/pmc/continuation.pmc Mon Jun 22 23:47:11 2009 (r39728)
+++ branches/context_pmc/src/pmc/continuation.pmc Tue Jun 23 00:26:46 2009 (r39729)
@@ -107,14 +107,6 @@
VTABLE void destroy() {
Parrot_cont * const cc = PMC_cont(SELF);
if (cc) {
-#if CTX_LEAK_DEBUG
- if (Interp_debug_TEST(interp, PARROT_CTX_DESTROY_DEBUG_FLAG)) {
- fprintf(stderr,
- "[destroy cont %p, to_ctx %p, from_ctx %p]\n",
- (void *)SELF, (void *)cc->to_ctx, (void *)cc->from_ctx);
- }
-
-#endif
if (cc->from_ctx)
Parrot_free_context(interp, cc->from_ctx, 1);
Modified: branches/context_pmc/src/sub.c
==============================================================================
--- branches/context_pmc/src/sub.c Mon Jun 22 23:47:11 2009 (r39728)
+++ branches/context_pmc/src/sub.c Tue Jun 23 00:26:46 2009 (r39729)
@@ -544,17 +544,6 @@
if (VTABLE_exists_keyed_str(interp, lex_pad, lex_name))
return lex_pad;
-#if CTX_LEAK_DEBUG
- if (outer == ctx) {
- /* This is a bug; a context can never be its own :outer context.
- * Detecting it avoids an unbounded loop, which is difficult to
- * debug, though we'd rather not pay the cost of detection in a
- * production release.
- */
- Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
- "Bug: Context %p :outer points back to itself.", ctx);
- }
-#endif
ctx = outer;
}
}
@@ -679,12 +668,6 @@
Parrot_Context *to_ctx = cc->to_ctx;
Parrot_Context *from_ctx = CONTEXT(interp);
-#if CTX_LEAK_DEBUG
- if (Interp_debug_TEST(interp, PARROT_CTX_DESTROY_DEBUG_FLAG))
- fprintf(stderr,
- "[invoke cont %p, to_ctx %p, from_ctx %p (refs %d)]\n",
- (const void *)pmc, (void *)to_ctx, (void *)from_ctx, (int)from_ctx->ref_count);
-#endif
if (!to_ctx)
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
"Continuation invoked after deactivation.");
More information about the parrot-commits
mailing list