[armedbear-cvs] r13007 - trunk/abcl/src/org/armedbear/lisp

Erik Huelsmann ehuelsmann at common-lisp.net
Sat Nov 6 12:37:28 UTC 2010


Author: ehuelsmann
Date: Sat Nov  6 08:37:25 2010
New Revision: 13007

Log:
Eliminate ~80k exceptions (ClassNotFoundException) during
Maxima compilation by making our FaslClassLoader handle its
own classes first.

Modified:
   trunk/abcl/src/org/armedbear/lisp/FaslClassLoader.java

Modified: trunk/abcl/src/org/armedbear/lisp/FaslClassLoader.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/FaslClassLoader.java	(original)
+++ trunk/abcl/src/org/armedbear/lisp/FaslClassLoader.java	Sat Nov  6 08:37:25 2010
@@ -52,11 +52,43 @@
 		this.loader = (LispObject) loadClass(baseName + "_0").newInstance();
 	    } catch(Exception e) {
 		//e.printStackTrace();
-		Debug.trace("useLoaderFunction = true but couldn't fully init FASL loader, will fall back to reflection!");
+		Debug.trace("useLoaderFunction = true but couldn't fully init FASL loader ("+baseName+"), will fall back to reflection!");
 	    }
 	}
     }
 
+    @Override
+    protected Class<?> loadClass(String name, boolean resolve)
+            throws ClassNotFoundException {
+        /* First we check if we should load the class ourselves,
+         * allowing the default handlers to kick in if we don't...
+         *
+         * This strategy eliminates ClassNotFound exceptions inside
+         * the inherited loadClass() eliminated ~80k exceptions during
+         * Maxima compilation. Generally, creation of an exception object
+         * is a pretty heavy operation, because it processes the call stack,
+         * which - in ABCL - is pretty deep, most of the time.
+         */
+        if (name.startsWith(baseName + "_")) {
+            String internalName = "org/armedbear/lisp/" + name;
+            Class<?> c = this.findLoadedClass(internalName);
+
+            if (c == null)
+                c = findClass(name);
+
+            if (c != null) {
+                if (resolve)
+                    resolveClass(c);
+
+                return c;
+            }
+        }
+
+        // Fall through to our super's default handling
+        return super.loadClass(name, resolve);
+    }
+
+    @Override
     protected Class<?> findClass(String name) throws ClassNotFoundException {
 	try {
 	    byte[] b = getFunctionClassBytes(name);




More information about the armedbear-cvs mailing list