# HG changeset patch # User michaels # Date 1061043518 0 # Node ID 5cec7ab01719afcfb2b0d02b7d0d19965a30d10a # Parent b7261453102e2dbde4eb9ed30ea6ce1da0465c5c [xemacs-hg @ 2003-08-16 14:18:36 by michaels] 2003-08-12 Mike Sperber * bytecode.c (GCPRO_STACK): Added. (execute_optimized_program): Use GCPRO_STACK, fixing a space leak: Formerly, the byte-code engine would always hold on to the entire stack memory area, including the stuff above the top. Now, we adjust the GCPRO record via GCPRO_STACK just before a GC may occur. diff -r b7261453102e -r 5cec7ab01719 src/ChangeLog --- a/src/ChangeLog Fri Aug 15 21:52:30 2003 +0000 +++ b/src/ChangeLog Sat Aug 16 14:18:38 2003 +0000 @@ -1,3 +1,12 @@ +2003-08-12 Mike Sperber + + * bytecode.c (GCPRO_STACK): Added. + (execute_optimized_program): Use GCPRO_STACK, fixing a space leak: + Formerly, the byte-code engine would always hold on to the entire + stack memory area, including the stuff above the top. Now, we + adjust the GCPRO record via GCPRO_STACK just before a GC may + occur. + 2003-07-31 René Kyllingstad * event-msw.c (mswindows_enqueue_mouse_button_event): diff -r b7261453102e -r 5cec7ab01719 src/bytecode.c --- a/src/bytecode.c Fri Aug 15 21:52:30 2003 +0000 +++ b/src/bytecode.c Sat Aug 16 14:18:38 2003 +0000 @@ -447,6 +447,8 @@ but don't pop it. */ #define TOP (*stack_ptr) +#define GCPRO_STACK (gcpro1.nvars = stack_ptr - stack_beg) + /* The actual interpreter for byte code. This function has been seriously optimized for performance. Don't change the constructs unless you are willing to do @@ -460,8 +462,8 @@ { /* This function can GC */ REGISTER const Opbyte *program_ptr = (Opbyte *) program; - REGISTER Lisp_Object *stack_ptr - = alloca_array (Lisp_Object, stack_depth + 1); + Lisp_Object *stack_beg = alloca_array (Lisp_Object, stack_depth + 1); + REGISTER Lisp_Object *stack_ptr = stack_beg; int speccount = specpdl_depth (); struct gcpro gcpro1; @@ -471,23 +473,11 @@ #endif #ifdef ERROR_CHECK_BYTE_CODE - Lisp_Object *stack_beg = stack_ptr; Lisp_Object *stack_end = stack_beg + stack_depth; #endif - /* Initialize all the objects on the stack to Qnil, - so we can GCPRO the whole stack. - The first element of the stack is actually a dummy. */ - { - int i; - Lisp_Object *p; - for (i = stack_depth, p = stack_ptr; i--;) - *++p = Qnil; - } - GCPRO1 (stack_ptr[1]); - gcpro1.nvars = stack_depth; - + while (1) { REGISTER Opcode opcode = (Opcode) READ_UINT_1; @@ -512,7 +502,10 @@ if (opcode >= Bconstant) PUSH (constants_data[opcode - Bconstant]); else - stack_ptr = execute_rare_opcode (stack_ptr, program_ptr, opcode); + { + GCPRO_STACK; + stack_ptr = execute_rare_opcode (stack_ptr, program_ptr, opcode); + } break; case Bvarref: @@ -597,6 +590,7 @@ case Bcall+7: n = (opcode < Bcall+6 ? opcode - Bcall : opcode == Bcall+6 ? READ_UINT_1 : READ_UINT_2); + GCPRO_STACK; DISCARD (n); #ifdef BYTE_CODE_METER if (byte_metering_on && SYMBOLP (TOP))