Branch: Tag:

2003-08-07

2003-08-07 23:11:22 by Martin Stjernholm <mast@lysator.liu.se>

Fixed bug where the machine code could be zapped a teeny tiny bit too
early to handle the returned address from return opcodes when
OPCODE_RETURN_JUMPADDR is used.

Rev: src/interpret.c:1.322

2:   || This file is part of Pike. For copyright information see COPYRIGHT.   || Pike is distributed under GPL, LGPL and MPL. See the file COPYING   || for more information. - || $Id: interpret.c,v 1.321 2003/08/07 18:38:10 mast Exp $ + || $Id: interpret.c,v 1.322 2003/08/07 23:11:22 mast Exp $   */      #include "global.h" - RCSID("$Id: interpret.c,v 1.321 2003/08/07 18:38:10 mast Exp $"); + RCSID("$Id: interpret.c,v 1.322 2003/08/07 23:11:22 mast Exp $");   #include "interpret.h"   #include "object.h"   #include "program.h"
1689:      void low_return(void)   { + #if defined (PIKE_USE_MACHINE_CODE) && defined (OPCODE_RETURN_JUMPADDR) +  /* If the function that returns is the only ref to the current +  * object and its program then the program would be freed in +  * destruct_objects_to_destruct below. However, we're still +  * executing in an opcode in its code so we need prog->program to +  * stick around for a little while more to handle the returned +  * address. We therefore add a ref to the current object so that +  * it'll live through this function. */ +  struct object *o = Pike_fp->current_object; +  add_ref (o); + #endif +     basic_low_return();    if(save_sp+1 > Pike_sp)    {
1704:    }    if(Pike_interpreter.trace_level>1) trace_return_value();    } +  + #if defined (PIKE_USE_MACHINE_CODE) && defined (OPCODE_RETURN_JUMPADDR) +  free_object (o); + #endif   }      void low_return_pop(void)   { -  + #if defined (PIKE_USE_MACHINE_CODE) && defined (OPCODE_RETURN_JUMPADDR) +  /* See note above. */ +  struct object *o = Pike_fp->current_object; +  add_ref (o); + #endif +     basic_low_return();       if(save_sp < Pike_sp)
1716:    /* consider using a flag for immediate destruct instead... */    destruct_objects_to_destruct();    } +  + #if defined (PIKE_USE_MACHINE_CODE) && defined (OPCODE_RETURN_JUMPADDR) +  sub_ref (o); + #endif   }