[armedbear-cvs] r12297 - branches/fast-boot-preloading/abcl/src/org/armedbear/lisp

Erik Huelsmann ehuelsmann at common-lisp.net
Tue Dec 8 21:46:37 UTC 2009


Author: ehuelsmann
Date: Tue Dec  8 16:46:36 2009
New Revision: 12297

Log:
Implement preloader functionality which allows delaying reflection of compiled function classes.


Added:
   branches/fast-boot-preloading/abcl/src/org/armedbear/lisp/AutoloadedFunctionProxy.java   (contents, props changed)
Modified:
   branches/fast-boot-preloading/abcl/src/org/armedbear/lisp/Autoload.java
   branches/fast-boot-preloading/abcl/src/org/armedbear/lisp/CompiledClosure.java
   branches/fast-boot-preloading/abcl/src/org/armedbear/lisp/Lisp.java
   branches/fast-boot-preloading/abcl/src/org/armedbear/lisp/Load.java
   branches/fast-boot-preloading/abcl/src/org/armedbear/lisp/Symbol.java
   branches/fast-boot-preloading/abcl/src/org/armedbear/lisp/compile-file.lisp
   branches/fast-boot-preloading/abcl/src/org/armedbear/lisp/compiler-pass2.lisp

Modified: branches/fast-boot-preloading/abcl/src/org/armedbear/lisp/Autoload.java
==============================================================================
--- branches/fast-boot-preloading/abcl/src/org/armedbear/lisp/Autoload.java	(original)
+++ branches/fast-boot-preloading/abcl/src/org/armedbear/lisp/Autoload.java	Tue Dec  8 16:46:36 2009
@@ -664,6 +664,13 @@
         autoload(PACKAGE_SYS, "std-allocate-instance", "StandardObjectFunctions", true);
         autoload(PACKAGE_SYS, "zip", "zip", true);
 
+        autoload(PACKAGE_SYS, "proxy-preloaded-function",
+                 "AutoloadedFunctionProxy", false);
+        autoload(PACKAGE_SYS, "make-function-preloading-context",
+                 "AutoloadedFunctionProxy", false);
+        autoload(PACKAGE_SYS, "function-preload",
+                 "AutoloadedFunctionProxy", false);
+
         autoload(Symbol.COPY_LIST, "copy_list");
 
         autoload(Symbol.SET_CHAR, "StringFunctions");

Added: branches/fast-boot-preloading/abcl/src/org/armedbear/lisp/AutoloadedFunctionProxy.java
==============================================================================
--- (empty file)
+++ branches/fast-boot-preloading/abcl/src/org/armedbear/lisp/AutoloadedFunctionProxy.java	Tue Dec  8 16:46:36 2009
@@ -0,0 +1,268 @@
+/*
+ * AutoloadedFunctionProxy.java
+ *
+ * Copyright (C) 2009 Erik Huelsmann
+ * $Id$
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ * As a special exception, the copyright holders of this library give you
+ * permission to link this library with independent modules to produce an
+ * executable, regardless of the license terms of these independent
+ * modules, and to copy and distribute the resulting executable under
+ * terms of your choice, provided that you also meet, for each linked
+ * independent module, the terms and conditions of the license of that
+ * module.  An independent module is a module which is not derived from
+ * or based on this library.  If you modify this library, you may extend
+ * this exception to your version of the library, but you are not
+ * obligated to do so.  If you do not wish to do so, delete this
+ * exception statement from your version.
+ */
+
+package org.armedbear.lisp;
+
+import static org.armedbear.lisp.Lisp.*;
+
+import java.util.Hashtable;
+
+
+
+public class AutoloadedFunctionProxy extends Function {
+
+    final private Symbol symbol;
+    final private String name;
+    final private LispObject cache;
+    final private LispObject pack;
+    final private LispObject anonymousPackage;
+    final private boolean isSetfFunction;
+    Function fun = null;
+
+    public AutoloadedFunctionProxy(Symbol symbol, LispObject name,
+                                   LispObject cache, LispObject pack,
+                                   LispObject anonymousPackage,
+                                   boolean setfFunction) {
+        super();
+        this.symbol = symbol;
+        this.name = name.getStringValue();
+        this.cache = cache;
+        this.pack = pack;
+        //        Debug.trace("proxying ... " + name.getStringValue());
+        Debug.assertTrue(! (cache instanceof Nil));
+        this.anonymousPackage = anonymousPackage;
+        this.isSetfFunction = setfFunction;
+    }
+
+    final private synchronized Function load() {
+        if (fun != null)
+            return fun;
+
+        LispThread thread = LispThread.currentThread();
+        SpecialBindingsMark mark = thread.markSpecialBindings();
+
+        thread.bindSpecial(AUTOLOADING_CACHE, cache);
+        thread.bindSpecial(Load._FASL_ANONYMOUS_PACKAGE_, anonymousPackage);
+        thread.bindSpecial(Symbol._PACKAGE_, pack);
+        byte[] classbytes =
+            (byte[])((Hashtable)cache.javaInstance()).get(name);
+        try {
+            fun = loadClassBytes(classbytes);
+        }
+        catch (Throwable t) {
+            Debug.trace(t);
+        } // ### fixme
+        finally {
+            thread.resetSpecialBindings(mark);
+        }
+
+        if (symbol != null) {
+            if (isSetfFunction)
+                put(symbol, Symbol.SETF_FUNCTION, fun);
+            else
+                symbol.setSymbolFunction(fun);
+        }
+
+        return fun;
+    }
+
+    @Override
+    public LispObject execute()
+    {
+        return load().execute();
+    }
+
+    @Override
+    public LispObject execute(LispObject arg)
+    {
+        return load().execute(arg);
+    }
+
+    @Override
+    public LispObject execute(LispObject first, LispObject second)
+
+    {
+        return load().execute(first, second);
+    }
+
+    @Override
+    public LispObject execute(LispObject first, LispObject second,
+                              LispObject third)
+
+    {
+        return load().execute(first, second, third);
+    }
+
+    @Override
+    public LispObject execute(LispObject first, LispObject second,
+                              LispObject third, LispObject fourth)
+
+    {
+        return load().execute(first, second, third, fourth);
+    }
+
+    @Override
+    public LispObject execute(LispObject first, LispObject second,
+                              LispObject third, LispObject fourth,
+                              LispObject fifth)
+
+    {
+        return load().execute(first, second, third, fourth, fifth);
+    }
+
+    @Override
+    public LispObject execute(LispObject first, LispObject second,
+                              LispObject third, LispObject fourth,
+                              LispObject fifth, LispObject sixth)
+
+    {
+        return load().execute(first, second, third, fourth, fifth, sixth);
+    }
+
+    @Override
+    public LispObject execute(LispObject first, LispObject second,
+                              LispObject third, LispObject fourth,
+                              LispObject fifth, LispObject sixth,
+                              LispObject seventh)
+
+    {
+        return load().execute(first, second, third, fourth, fifth, sixth,
+                              seventh);
+    }
+
+    @Override
+    public LispObject execute(LispObject first, LispObject second,
+                              LispObject third, LispObject fourth,
+                              LispObject fifth, LispObject sixth,
+                              LispObject seventh, LispObject eighth)
+
+    {
+        return load().execute(first, second, third, fourth, fifth, sixth,
+                              seventh, eighth);
+    }
+
+    @Override
+    public LispObject execute(LispObject[] args)
+    {
+        return load().execute(args);
+    }
+
+    @SuppressWarnings("unchecked")
+    final public static LispObject loadPreloadedFunction(String name) {
+      LispThread thread = LispThread.currentThread();
+      LispObject value = AUTOLOADING_CACHE.symbolValue(thread);
+
+      if (value instanceof Nil)
+          return loadCompiledFunction(name);
+
+      Hashtable cache = (Hashtable)value.javaInstance();
+      byte[] bytes = (byte[])cache.get(name);
+      try {
+        return loadClassBytes(bytes);
+      }
+      catch (VerifyError e)
+      {
+        return error(new LispError("Class verification failed: " +
+                                   e.getMessage()));
+      }
+      catch (Throwable t)
+      {
+        Debug.trace(t);
+      }
+      return error(new FileError("Can't read file off stream."));
+    }
+
+    final static LispObject makePreloadingContext() {
+        return new JavaObject(new Hashtable());
+    }
+
+    final private static Primitive PROXY_PRELOADED_FUNCTION
+        = new Primitive("proxy-preloaded-function", PACKAGE_SYS, false,
+                        "symbol name")
+    {
+      @Override
+      final public LispObject execute(LispObject symbol, LispObject name) {
+        LispThread thread = LispThread.currentThread();
+        Symbol sym;
+        LispObject fun;
+        boolean setfFun = false;
+
+        if (symbol instanceof Symbol)
+            sym = (Symbol)symbol;
+        else if (isValidSetfFunctionName(symbol)) {
+            sym = (Symbol)symbol.cadr();
+            setfFun = true;
+        } else {
+            checkSymbol(symbol); // generate an error
+            return null; // not reached
+        }
+
+        LispObject cache = AUTOLOADING_CACHE.symbolValue(thread);
+        LispObject pack = Symbol._PACKAGE_.symbolValue(thread);
+
+        if (cache instanceof Nil)
+            return loadCompiledFunction(name.getStringValue());
+        else {
+            fun = new AutoloadedFunctionProxy(sym, name, cache, pack,
+                                              Load._FASL_ANONYMOUS_PACKAGE_.symbolValue(thread),
+                                              setfFun);
+            if (setfFun)
+                put(sym, Symbol.SETF_FUNCTION, fun);
+            else
+                sym.setSymbolFunction(fun);
+        }
+
+        return fun;
+      }
+   };
+
+
+  final private static Primitive FUNCTION_PRELOAD
+    = new Primitive("function-preload", PACKAGE_SYS, false, "name")
+  {
+    @SuppressWarnings("unchecked")
+    @Override
+    final public LispObject execute(LispObject name) {
+      String namestring = name.getStringValue();
+      LispThread thread = LispThread.currentThread();
+      Hashtable cache
+          = (Hashtable)AUTOLOADING_CACHE.symbolValue(thread).javaInstance();
+
+      byte[] bytes = readFunctionBytes(namestring);
+      cache.put(namestring, bytes);
+
+      return T;
+    }
+  };
+
+}

Modified: branches/fast-boot-preloading/abcl/src/org/armedbear/lisp/CompiledClosure.java
==============================================================================
--- branches/fast-boot-preloading/abcl/src/org/armedbear/lisp/CompiledClosure.java	(original)
+++ branches/fast-boot-preloading/abcl/src/org/armedbear/lisp/CompiledClosure.java	Tue Dec  8 16:46:36 2009
@@ -219,11 +219,13 @@
         namestring = ((Pathname)arg).getNamestring();
       else if (arg instanceof AbstractString)
         namestring = arg.getStringValue();
-      if (namestring != null)
-        return loadCompiledFunction(namestring);
+      if (namestring != null) {
+          //    Debug.trace("autoloading preloaded ... " + namestring);
+        return AutoloadedFunctionProxy.loadPreloadedFunction(namestring);
+      }
       if(arg instanceof JavaObject) {
 	  try {
-	      return loadCompiledFunction((byte[]) arg.javaInstance(byte[].class));
+	      return loadClassBytes((byte[]) arg.javaInstance(byte[].class));
 	  } catch(Throwable t) {
 	      Debug.trace(t);
 	      return error(new LispError("Unable to load " + arg.writeToString()));

Modified: branches/fast-boot-preloading/abcl/src/org/armedbear/lisp/Lisp.java
==============================================================================
--- branches/fast-boot-preloading/abcl/src/org/armedbear/lisp/Lisp.java	(original)
+++ branches/fast-boot-preloading/abcl/src/org/armedbear/lisp/Lisp.java	Tue Dec  8 16:46:36 2009
@@ -1224,6 +1224,26 @@
   public static final LispObject loadCompiledFunction(final String namestring)
 
   {
+    try {
+      byte[] bytes = readFunctionBytes(namestring);
+      if (bytes != null)
+        return loadClassBytes(bytes);
+    }
+    catch (VerifyError e)
+    {
+      return error(new LispError("Class verification failed: " +
+                                 e.getMessage()));
+    }
+    catch (Throwable t)
+      {
+        Debug.trace(t);
+      }
+    return error(new FileError("File not found: " + namestring,
+                                new Pathname(namestring)));
+  }
+
+  public static final byte[] readFunctionBytes(final String namestring)
+  {
     final LispThread thread = LispThread.currentThread();
     final boolean absolute = Utilities.isFilenameAbsolute(namestring);
     LispObject device = NIL;
@@ -1296,8 +1316,7 @@
                               {
                                 long size = entry.getSize();
                                 InputStream in = zipFile.getInputStream(entry);
-                                LispObject obj = loadCompiledFunction(in, (int) size);
-                                return obj != null ? obj : NIL;
+                                return readFunctionBytes(in, (int) size);
                               }
                             else 
                               {
@@ -1305,13 +1324,10 @@
                                 entryName 
                                   = defaultPathname.name.getStringValue() 
                                   + "." +  "abcl";//defaultPathname.type.getStringValue();
-                                byte in[] 
-                                  = Utilities
-                                  .getZippedZipEntryAsByteArray(zipFile, 
+                                return Utilities
+                                  .getZippedZipEntryAsByteArray(zipFile,
                                                                 entryName,
                                                                 namestring);
-                                LispObject o = loadCompiledFunction(in);
-                                return o != null ? o : NIL;
                               }
                           }
                         finally
@@ -1323,8 +1339,9 @@
               }
             catch (VerifyError e)
               {
-                return error(new LispError("Class verification failed: " +
-                                            e.getMessage()));
+                error(new LispError("Class verification failed: " +
+                                    e.getMessage()));
+                return null; // not reached
               }
             catch (IOException e)
               {
@@ -1335,7 +1352,8 @@
                 Debug.trace(t);
               }
           }
-        return error(new LispError("Unable to load " + namestring));
+        error(new LispError("Unable to load " + namestring));
+        return null; // not reached
       }
     Pathname pathname = new Pathname(namestring);
     final File file = Utilities.getFile(pathname, defaultPathname);
@@ -1344,23 +1362,24 @@
         // The .cls file exists.
         try
           {
-            LispObject obj = loadCompiledFunction(new FileInputStream(file),
-                                                  (int) file.length());
+            byte[] bytes = readFunctionBytes(new FileInputStream(file),
+                                             (int) file.length());
             // FIXME close stream!
-            if (obj != null)
-              return obj;
+            if (bytes != null)
+              return bytes;
           }
         catch (VerifyError e)
           {
-            return error(new LispError("Class verification failed: " +
-                                        e.getMessage()));
+            error(new LispError("Class verification failed: " +
+                                e.getMessage()));
+            return null; // not reached
           }
         catch (Throwable t)
           {
             Debug.trace(t);
           }
-        return error(new LispError("Unable to load " +
-                                    pathname.writeToString()));
+        error(new LispError("Unable to load " + pathname.writeToString()));
+        return null; // not reached
       }
     try
       {
@@ -1372,12 +1391,13 @@
             ZipEntry entry = zipFile.getEntry(namestring);
             if (entry != null)
               {
-                LispObject obj = loadCompiledFunction(zipFile.getInputStream(entry),
-                                                      (int) entry.getSize());
-                if (obj != null)
-                  return obj;
+                byte[] bytes = readFunctionBytes(zipFile.getInputStream(entry),
+                                                 (int) entry.getSize());
+                if (bytes != null)
+                  return bytes;
                 Debug.trace("Unable to load " + namestring);
-                return error(new LispError("Unable to load " + namestring));
+                error(new LispError("Unable to load " + namestring));
+                return null; // not reached
               }
           }
         finally
@@ -1389,21 +1409,49 @@
       {
         Debug.trace(t);
       }
-    return error(new FileError("File not found: " + namestring,
-                                new Pathname(namestring)));
+    error(new FileError("File not found: " + namestring,
+                        new Pathname(namestring)));
+    return null; // not reached
   }
 
-    public static final LispObject makeCompiledFunctionFromClass(Class<?> c)
-	throws Exception {
+    public static final Function makeCompiledFunctionFromClass(Class<?> c) {
+      try {
 	if (c != null) {
-	    LispObject obj = (LispObject)c.newInstance();
+	    Function obj = (Function)c.newInstance();
 	    return obj;
         } else {
             return null;
         }
+      }
+      catch (InstantiationException e) {} // ### FIXME
+      catch (IllegalAccessException e) {} // ### FIXME
+
+      return null;
     }
 
-  private static final LispObject loadCompiledFunction(InputStream in, int size)
+
+  public static final LispObject loadCompiledFunction(InputStream in, int size)
+  {
+    try {
+      byte[] bytes = readFunctionBytes(in, size);
+      if (bytes != null)
+        return loadClassBytes(bytes);
+    }
+    catch (VerifyError e)
+    {
+      return error(new LispError("Class verification failed: " +
+                                 e.getMessage()));
+    }
+    catch (Throwable t)
+      {
+        Debug.trace(t);
+      }
+    return error(new FileError("Can't read file off stream."));
+  }
+
+
+
+  private static final byte[] readFunctionBytes(InputStream in, int size)
   {
     try
       {
@@ -1422,7 +1470,7 @@
         if (bytesRemaining > 0)
           Debug.trace("bytesRemaining = " + bytesRemaining);
 
-        return loadCompiledFunction(bytes);
+        return bytes;
       }
     catch (Throwable t)
       {
@@ -1431,15 +1479,20 @@
     return null;
   }
 
-    public static final LispObject loadCompiledFunction(byte[] bytes) throws Throwable {
-	return loadCompiledFunction(bytes, new JavaClassLoader());
+    public static final Function loadClassBytes(byte[] bytes)
+        throws Throwable
+    {
+	return loadClassBytes(bytes, new JavaClassLoader());
     }
 
-    public static final LispObject loadCompiledFunction(byte[] bytes, JavaClassLoader cl) throws Throwable {
+    public static final Function loadClassBytes(byte[] bytes,
+                                                JavaClassLoader cl)
+        throws Throwable
+    {
         Class<?> c = cl.loadClassFromByteArray(null, bytes, 0, bytes.length);
-	LispObject obj = makeCompiledFunctionFromClass(c);
-	if (obj instanceof Function) {
-	    ((Function)obj).setClassBytes(bytes);
+	Function obj = makeCompiledFunctionFromClass(c);
+	if (obj != null) {
+	    obj.setClassBytes(bytes);
 	}
 	return obj;
     }
@@ -2471,6 +2524,10 @@
   public static final Symbol _AUTOLOAD_VERBOSE_ =
     exportSpecial("*AUTOLOAD-VERBOSE*", PACKAGE_EXT, NIL);
 
+  // ### *preloading-cache*
+ public static final Symbol AUTOLOADING_CACHE =
+   internSpecial("*AUTOLOADING-CACHE*", PACKAGE_SYS, NIL);
+
   // ### *compile-file-type*
   public static final String COMPILE_FILE_TYPE = "abcl";
   public static final Symbol _COMPILE_FILE_TYPE_ =

Modified: branches/fast-boot-preloading/abcl/src/org/armedbear/lisp/Load.java
==============================================================================
--- branches/fast-boot-preloading/abcl/src/org/armedbear/lisp/Load.java	(original)
+++ branches/fast-boot-preloading/abcl/src/org/armedbear/lisp/Load.java	Tue Dec  8 16:46:36 2009
@@ -44,6 +44,7 @@
 import java.io.InputStream;
 import java.net.URL;
 import java.net.URLDecoder;
+import java.util.Hashtable;
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipException;
 import java.util.zip.ZipFile;
@@ -608,6 +609,8 @@
         LispObject result = NIL;
         try {
             thread.bindSpecial(_FASL_ANONYMOUS_PACKAGE_, new Package());
+            thread.bindSpecial(AUTOLOADING_CACHE,
+                               AutoloadedFunctionProxy.makePreloadingContext());
             while (true) {
                 LispObject obj = in.faslRead(false, EOF, true, thread);
                 if (obj == EOF)

Modified: branches/fast-boot-preloading/abcl/src/org/armedbear/lisp/Symbol.java
==============================================================================
--- branches/fast-boot-preloading/abcl/src/org/armedbear/lisp/Symbol.java	(original)
+++ branches/fast-boot-preloading/abcl/src/org/armedbear/lisp/Symbol.java	Tue Dec  8 16:46:36 2009
@@ -3030,10 +3030,14 @@
     PACKAGE_SYS.addInternalSymbol("FORMAT-CONTROL");
   public static final Symbol FSET =
     PACKAGE_SYS.addInternalSymbol("FSET");
+  public static final Symbol FUNCTION_PRELOAD =
+    PACKAGE_SYS.addInternalSymbol("FUNCTION-PRELOAD");
   public static final Symbol INSTANCE =
     PACKAGE_SYS.addInternalSymbol("INSTANCE");
   public static final Symbol MACROEXPAND_MACRO =
     PACKAGE_SYS.addInternalSymbol("MACROEXPAND-MACRO");
+  public static final Symbol MAKE_FUNCTION_PRELOADING_CONTEXT =
+    PACKAGE_SYS.addInternalSymbol("MAKE-FUNCTION-PRELOADING-CONTEXT");
   public static final Symbol NAME =
     PACKAGE_SYS.addInternalSymbol("NAME");
   public static final Symbol OBJECT =
@@ -3042,6 +3046,8 @@
     PACKAGE_SYS.addInternalSymbol("OPERANDS");
   public static final Symbol OPERATION =
     PACKAGE_SYS.addInternalSymbol("OPERATION");
+  public static final Symbol PROXY_PRELOADED_FUNCTION =
+    PACKAGE_SYS.addInternalSymbol("PROXY-PRELOADED-FUNCTION");
   public static final Symbol _SOURCE =
     PACKAGE_SYS.addInternalSymbol("%SOURCE");
   public static final Symbol SOCKET_STREAM =

Modified: branches/fast-boot-preloading/abcl/src/org/armedbear/lisp/compile-file.lisp
==============================================================================
--- branches/fast-boot-preloading/abcl/src/org/armedbear/lisp/compile-file.lisp	(original)
+++ branches/fast-boot-preloading/abcl/src/org/armedbear/lisp/compile-file.lisp	Tue Dec  8 16:46:36 2009
@@ -160,7 +160,7 @@
                      (compiled-function
                       (setf form
                             `(fset ',name
-                                   (load-compiled-function ,(file-namestring classfile))
+                                   (proxy-preloaded-function ',name ,(file-namestring classfile))
                                    ,*source-position*
                                    ',lambda-list
                                    ,doc))
@@ -484,6 +484,8 @@
          (type (pathname-type output-file))
          (temp-file (merge-pathnames (make-pathname :type (concatenate 'string type "-tmp"))
                                      output-file))
+         (temp-file2 (merge-pathnames (make-pathname :type (concatenate 'string type "-tmp2"))
+                                     output-file))
          (warnings-p nil)
          (failure-p nil))
     (with-open-file (in input-file :direction :input)
@@ -510,15 +512,6 @@
                   *forms-for-output*)
               (jvm::with-saved-compiler-policy
                   (jvm::with-file-compilation
-                      (write "; -*- Mode: Lisp -*-" :escape nil :stream out)
-                    (%stream-terpri out)
-                    (let ((*package* (find-package '#:cl)))
-                      (write (list 'init-fasl :version *fasl-version*)
-                             :stream out)
-                      (%stream-terpri out)
-                      (write (list 'setq '*source* *compile-file-truename*)
-                             :stream out)
-                      (%stream-terpri out))
                     (handler-bind ((style-warning #'(lambda (c)
                                                       (setf warnings-p t)
                                                       ;; let outer handlers
@@ -544,7 +537,34 @@
                     (finalize-fasl-output)
                     (dolist (name *fbound-names*)
                       (fmakunbound name)))))))
-        (rename-file temp-file output-file)
+        (with-open-file (in temp-file :direction :input)
+          (with-open-file (out temp-file2 :direction :output
+                               :if-does-not-exist :create
+                               :if-exists :supersede)
+            ;; write header
+            (write "; -*- Mode: Lisp -*-" :escape nil :stream out)
+            (%stream-terpri out)
+            (let ((*package* (find-package '#:cl))
+                  (count-sym (gensym)))
+              (write (list 'init-fasl :version *fasl-version*)
+                     :stream out)
+              (%stream-terpri out)
+              (write (list 'setq '*source* *compile-file-truename*)
+                     :stream out)
+              (%stream-terpri out)
+              (dump-form `(dotimes (,count-sym ,*class-number*)
+                            (function-preload
+                             (%format nil "~A-~D.cls" ,(pathname-name output-file)
+                                      (1+ ,count-sym)))) out)
+              (%stream-terpri out))
+
+
+            ;; copy remaining content
+            (loop for line = (read-line in nil :eof)
+               while (not (eq line :eof))
+               do (write-line line out))))
+        (delete-file temp-file)
+        (rename-file temp-file2 output-file)
 
         (when *compile-file-zip*
           (let* ((type ;; Don't use ".zip", it'll result in an extension

Modified: branches/fast-boot-preloading/abcl/src/org/armedbear/lisp/compiler-pass2.lisp
==============================================================================
--- branches/fast-boot-preloading/abcl/src/org/armedbear/lisp/compiler-pass2.lisp	(original)
+++ branches/fast-boot-preloading/abcl/src/org/armedbear/lisp/compiler-pass2.lisp	Tue Dec  8 16:46:36 2009
@@ -2070,7 +2070,7 @@
      ;; fixme *declare-inline*
      (declare-field g +lisp-object+ +field-access-default+)
      (emit 'ldc (pool-string (file-namestring pathname)))
-     (emit-invokestatic +lisp-class+ "loadCompiledFunction"
+     (emit-invokestatic "org/armedbear/lisp/AutoloadedFunctionProxy" "loadPreloadedFunction"
 			(list +java-string+) +lisp-object+)
      (emit 'putstatic *this-class* g +lisp-object+)
      (setf *static-code* *code*)




More information about the armedbear-cvs mailing list