cvsuser     04/11/06 02:32:04

  Modified:    classes  continuation.pmc retcontinuation.pmc
               include/parrot sub.h
               ops      core.ops
               src      sub.c
  Log:
  indirect register frame 18 - fix invalidation of return continuations
  * invalidation was done in the wrong places
  * forgot to set code segment of recycled continuations
  * this was the cause for failures in the streams_16 test
  
  Revision  Changes    Path
  1.35      +8 -2      parrot/classes/continuation.pmc
  
  Index: continuation.pmc
  ===================================================================
  RCS file: /cvs/public/parrot/classes/continuation.pmc,v
  retrieving revision 1.34
  retrieving revision 1.35
  diff -u -r1.34 -r1.35
  --- continuation.pmc  2 Nov 2004 17:52:16 -0000       1.34
  +++ continuation.pmc  6 Nov 2004 10:32:01 -0000       1.35
  @@ -1,6 +1,6 @@
   /*
   Copyright: 2001-2003 The Perl Foundation.  All Rights Reserved.
  -$Id: continuation.pmc,v 1.34 2004/11/02 17:52:16 leo Exp $
  +$Id: continuation.pmc,v 1.35 2004/11/06 10:32:01 leo Exp $
   
   =head1 NAME
   
  @@ -52,6 +52,13 @@
           PMC_cont(SELF) = new_continuation(INTERP);
           PMC_struct_val(SELF) = NULL;
           PObj_custom_mark_destroy_SETALL(SELF);
  +        /*
  +         * Whenever we create a continuation, all return continuations
  +         * up the call chain maybe reuesed due to invoking the
  +         * continuation. To avoid that all return continuations are
  +         * converted to true continuations.
  +         */
  +        invalidate_retc_context(INTERP, &interpreter->ctx);
       }
   
   /*
  @@ -102,7 +109,6 @@
           memcpy(sub, cc_self, sizeof(struct Parrot_cont));
   
           PMC_struct_val(ret) = PMC_struct_val(SELF);
  -        invalidate_retc_context(INTERP, SELF);
           return ret;
       }
   
  
  
  
  1.22      +5 -7      parrot/classes/retcontinuation.pmc
  
  Index: retcontinuation.pmc
  ===================================================================
  RCS file: /cvs/public/parrot/classes/retcontinuation.pmc,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- retcontinuation.pmc       3 Nov 2004 14:29:56 -0000       1.21
  +++ retcontinuation.pmc       6 Nov 2004 10:32:01 -0000       1.22
  @@ -1,6 +1,6 @@
   /*
   Copyright: 2001-2003 The Perl Foundation.  All Rights Reserved.
  -$Id: retcontinuation.pmc,v 1.21 2004/11/03 14:29:56 leo Exp $
  +$Id: retcontinuation.pmc,v 1.22 2004/11/06 10:32:01 leo Exp $
   
   =head1 NAME
   
  @@ -57,12 +57,10 @@
   
   */
       PMC* clone() {
  -        PMC *ret = pmc_new(INTERP, enum_class_Continuation);
  -        struct Parrot_cont * sub;
  -        struct Parrot_cont *cc_self = PMC_cont(SELF);
  -        sub = PMC_cont(ret);
  -        memcpy(sub, cc_self, sizeof(struct Parrot_cont));
  -        PMC_struct_val(ret) = PMC_struct_val(SELF);
  +        PMC *ret = SUPER();
  +        ret->vtable = Parrot_base_vtables[enum_class_Continuation];
  +        SELF->vtable = Parrot_base_vtables[enum_class_Continuation];
  +        invalidate_retc_context(INTERP, &PMC_cont(ret)->ctx);
           return ret;
       }
   /*
  
  
  
  1.40      +2 -2      parrot/include/parrot/sub.h
  
  Index: sub.h
  ===================================================================
  RCS file: /cvs/public/parrot/include/parrot/sub.h,v
  retrieving revision 1.39
  retrieving revision 1.40
  diff -u -r1.39 -r1.40
  --- sub.h     3 Nov 2004 14:29:57 -0000       1.39
  +++ sub.h     6 Nov 2004 10:32:02 -0000       1.40
  @@ -1,7 +1,7 @@
   /* sub.h
    *  Copyright: 2001-2003 The Perl Foundation.  All Rights Reserved.
    *  CVS Info
  - *     $Id: sub.h,v 1.39 2004/11/03 14:29:57 leo Exp $
  + *     $Id: sub.h,v 1.40 2004/11/06 10:32:02 leo Exp $
    *  Overview:
    *  Data Structure and Algorithms:
    *     Subroutine, coroutine, closure and continuation structures
  @@ -78,7 +78,7 @@
   void copy_regs(Interp *, struct parrot_regs_t *caller_regs);
   void mark_reg_stack(Interp *, Stack_Chunk_t *);
   
  -void invalidate_retc_context(Interp *interpreter, PMC* self);
  +void invalidate_retc_context(Interp *interpreter, struct Parrot_Context *);
   void add_to_retc_cache(Interp *interpreter, PMC *pmc);
   void mark_retc_cache(Interp *);
   
  
  
  
  1.373     +2 -1      parrot/ops/core.ops
  
  Index: core.ops
  ===================================================================
  RCS file: /cvs/public/parrot/ops/core.ops,v
  retrieving revision 1.372
  retrieving revision 1.373
  diff -u -r1.372 -r1.373
  --- core.ops  30 Oct 2004 09:15:45 -0000      1.372
  +++ core.ops  6 Nov 2004 10:32:03 -0000       1.373
  @@ -445,7 +445,8 @@
   inline op updatecc() {
     struct Parrot_cont *cc =  PMC_cont(REG_PMC(1));
     /* update context */
  -  save_context(interpreter, &cc->ctx);
  +  cc->ctx.warns = interpreter->ctx.warns;
  +  cc->ctx.errors = interpreter->ctx.errors;
     goto NEXT();
   }
   
  
  
  
  1.79      +13 -8     parrot/src/sub.c
  
  Index: sub.c
  ===================================================================
  RCS file: /cvs/public/parrot/src/sub.c,v
  retrieving revision 1.78
  retrieving revision 1.79
  diff -u -r1.78 -r1.79
  --- sub.c     5 Nov 2004 11:23:00 -0000       1.78
  +++ sub.c     6 Nov 2004 10:32:04 -0000       1.79
  @@ -1,6 +1,6 @@
   /*
   Copyright: 2001-2003 The Perl Foundation.  All Rights Reserved.
  -$Id: sub.c,v 1.78 2004/11/05 11:23:00 leo Exp $
  +$Id: sub.c,v 1.79 2004/11/06 10:32:04 leo Exp $
   
   =head1 NAME
   
  @@ -177,7 +177,7 @@
               /*
                * invalidate return continuations
                */
  -            invalidate_retc_context(interpreter, sub);
  +            invalidate_retc_context(interpreter, ctx);
           }
           /*
            * construct stacks that have the interpreterreter stack
  @@ -395,12 +395,17 @@
       Caches *mc = interpreter->caches;
   
       if (mc->retc_cache) {
  +        struct Parrot_cont * cc;
  +
           continuation = mc->retc_cache;
           mc->retc_cache = PREV_RETC(mc->retc_cache);
           /* XXX expensive w. ARENA_DOD_FLAGS */
           PObj_custom_mark_SET(continuation);
           /* copy interpreter context into continuation */
  -        save_context(interpreter, &PMC_cont(continuation)->ctx);
  +        cc = PMC_cont(continuation);
  +        save_context(interpreter, &cc->ctx);
  +        /* set current segment */
  +        cc->seg = interpreter->code->cur_cs;
       }
       else {
           continuation = pmc_new(interpreter, enum_class_RetContinuation);
  @@ -458,7 +463,7 @@
   
   /*
   
  -=item C< void invalidate_retc_context(Interp *, PMC* self)>
  +=item C< void invalidate_retc_context(Interp *, struct Parrot_Context *ctx)>
   
   Make true Continuation from all RetContinuations up the call chain.
   
  @@ -466,15 +471,15 @@
   
   */
   void
  -invalidate_retc_context(Interp *interpreter, PMC* self)
  +invalidate_retc_context(Interp *interpreter, struct Parrot_Context *ctx)
   {
       struct Parrot_cont * cc;
       PMC *cont;
   
  -    cont = interpreter->ctx.current_cont;
  -    while (!PMC_IS_NULL(cont) && PMC_struct_val(cont)) {
  +    cont = ctx->current_cont;
  +    while (!PMC_IS_NULL(cont)) {
           /*
  -         * we could stop if we enocunter a true continuation, because
  +         * We could stop if we enocunter a true continuation, because
            * if one were created, everything up the chain would have been
            * invalidated earlier.
            * But as long as Continuation usage can be considered being rare,
  
  
  

Reply via email to