Commits

stephent  committed 68ed93d

[xemacs-hg @ 2003-10-10 11:50:56 by stephent]
E Benson bytecomp patch <87oewpmi1m.fsf_-_@tleepslib.sk.tsukuba.ac.jp>

  • Participants
  • Parent commits 92dd858

Comments (0)

Files changed (4)

File src/ChangeLog

+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
   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;
   }
   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))

File src/bytecode.c

   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))
     {
       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)