changeset 1737:68ed93de81b7

[xemacs-hg @ 2003-10-10 11:50:56 by stephent] E Benson bytecomp patch <87oewpmi1m.fsf_-_@tleepslib.sk.tsukuba.ac.jp>
author stephent
date Fri, 10 Oct 2003 11:51:05 +0000
parents 92dd8587c485
children f43f9ca6c7d9
files src/ChangeLog src/alloc.c src/bytecode.c src/eval.c
diffstat 4 files changed, 64 insertions(+), 42 deletions(-) [+]
line wrap: on
line diff
--- 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  <eric_a_benson@yahoo.com>
+
+	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  <james@xemacs.org>
 
 	* emodules.c (vars_of_module): Make Vmodule_extensions visible to
--- 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))
--- 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))
--- 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)