# HG changeset patch # User stephent # Date 1065786665 0 # Node ID 68ed93de81b77c5007c4de325e0996113371770c # Parent 92dd8587c4856388afa75c8b47cb3146da37ebc3 [xemacs-hg @ 2003-10-10 11:50:56 by stephent] E Benson bytecomp patch <87oewpmi1m.fsf_-_@tleepslib.sk.tsukuba.ac.jp> diff -r 92dd8587c485 -r 68ed93de81b7 src/ChangeLog --- a/src/ChangeLog Fri Oct 10 10:51:11 2003 +0000 +++ b/src/ChangeLog Fri Oct 10 11:51:05 2003 +0000 @@ -1,3 +1,19 @@ +2003-07-25 Eric Benson + + Delay the allocation and initialization of the args array in + compiled_function objects from creation until first use, thus + avoiding a bug in the portable dumper. See mail with subject + "Symbol's value as variable is void: region" in the July 2003 + xemacs-beta archives. + * alloc.c (make_compiled_function): initialize args, max_args, + min_args, and args_in_array to zero. + (Fmake_byte_code): Removed allocation and initialization of args + array. + * bytecode.c (optimize_compiled_function): Added allocation and + initialization of args array. + * eval.c (function_argcount): Added call to + optimize_compiled_function. + 2003-10-07 Jerry James * emodules.c (vars_of_module): Make Vmodule_extensions visible to diff -r 92dd8587c485 -r 68ed93de81b7 src/alloc.c --- a/src/alloc.c Fri Oct 10 10:51:11 2003 +0000 +++ b/src/alloc.c Fri Oct 10 11:51:05 2003 +0000 @@ -1505,6 +1505,7 @@ f->instructions = Qzero; f->constants = Qzero; f->arglist = Qnil; + f->args = f->max_args = f->min_args = f->args_in_array = 0; f->doc_and_interactive = Qnil; #ifdef COMPILED_FUNCTION_ANNOTATION_HACK f->annotated = Qnil; @@ -1559,48 +1560,6 @@ } f->arglist = arglist; - { - int minargs = 0, maxargs = 0, totalargs = 0; - int optional_p = 0, rest_p = 0, i = 0; - { - LIST_LOOP_2 (arg, arglist) - { - if (EQ (arg, Qand_optional)) - optional_p = 1; - else if (EQ (arg, Qand_rest)) - rest_p = 1; - else - { - if (rest_p) - { - maxargs = MANY; - totalargs++; - break; - } - if (!optional_p) - minargs++; - maxargs++; - totalargs++; - } - } - } - - if (totalargs) - f->args = xnew_array (Lisp_Object, totalargs); - - { - LIST_LOOP_2 (arg, arglist) - { - if (!EQ (arg, Qand_optional) && !EQ (arg, Qand_rest)) - f->args[i++] = arg; - } - } - - f->max_args = maxargs; - f->min_args = minargs; - f->args_in_array = totalargs; - } - /* `instructions' is a string or a cons (string . int) for a lazy-loaded function. */ if (CONSP (instructions)) diff -r 92dd8587c485 -r 68ed93de81b7 src/bytecode.c --- a/src/bytecode.c Fri Oct 10 10:51:11 2003 +0000 +++ b/src/bytecode.c Fri Oct 10 11:51:05 2003 +0000 @@ -1724,6 +1724,48 @@ int varbind_count; Opbyte *program; + { + int minargs = 0, maxargs = 0, totalargs = 0; + int optional_p = 0, rest_p = 0, i = 0; + { + LIST_LOOP_2 (arg, f->arglist) + { + if (EQ (arg, Qand_optional)) + optional_p = 1; + else if (EQ (arg, Qand_rest)) + rest_p = 1; + else + { + if (rest_p) + { + maxargs = MANY; + totalargs++; + break; + } + if (!optional_p) + minargs++; + maxargs++; + totalargs++; + } + } + } + + if (totalargs) + f->args = xnew_array (Lisp_Object, totalargs); + + { + LIST_LOOP_2 (arg, f->arglist) + { + if (!EQ (arg, Qand_optional) && !EQ (arg, Qand_rest)) + f->args[i++] = arg; + } + } + + f->max_args = maxargs; + f->min_args = minargs; + f->args_in_array = totalargs; + } + /* If we have not actually read the bytecode string and constants vector yet, fetch them from the file. */ if (CONSP (f->instructions)) diff -r 92dd8587c485 -r 68ed93de81b7 src/eval.c --- a/src/eval.c Fri Oct 10 10:51:11 2003 +0000 +++ b/src/eval.c Fri Oct 10 11:51:05 2003 +0000 @@ -3966,6 +3966,11 @@ { Lisp_Compiled_Function *f = XCOMPILED_FUNCTION (function); + if (!OPAQUEP (f->instructions)) + /* Lazily munge the instructions into a more efficient form */ + /* Needed to set max_args */ + optimize_compiled_function (function); + if (function_min_args_p) return make_int (f->min_args); else if (f->max_args == MANY)