[armedbear-cvs] r12771 - trunk/abcl/src/org/armedbear/lisp
Alessio Stalla
astalla at common-lisp.net
Sun Jun 27 21:38:10 UTC 2010
Author: astalla
Date: Sun Jun 27 17:38:09 2010
New Revision: 12771
Log:
Fixed the handling of disassemble: functions store the *load-truename* they were loaded from, and use that to try to load bytecode for disassembly. If the loading fails, NIL is returned (it crashed hard before this fix).
Modified:
trunk/abcl/src/org/armedbear/lisp/Function.java
Modified: trunk/abcl/src/org/armedbear/lisp/Function.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/Function.java (original)
+++ trunk/abcl/src/org/armedbear/lisp/Function.java Sun Jun 27 17:38:09 2010
@@ -40,11 +40,20 @@
private LispObject propertyList = NIL;
private int callCount;
private int hotCount;
-
- protected Function() {}
+ /**
+ * The value of *load-truename* which was current when this function
+ * was loaded, used for fetching the class bytes in case of disassebly.
+ */
+ private final LispObject loadedFrom;
+
+ protected Function() {
+ LispObject loadTruename = Symbol.LOAD_TRUENAME.symbolValueNoThrow();
+ loadedFrom = loadTruename != null ? loadTruename : NIL;
+ }
public Function(String name)
{
+ this();
if (name != null) {
Symbol symbol = Symbol.addFunction(name.toUpperCase(), this);
if (cold)
@@ -55,6 +64,7 @@
public Function(Symbol symbol, String arglist)
{
+ this();
symbol.setSymbolFunction(this);
if (cold)
symbol.setBuiltInFunction(true);
@@ -64,6 +74,7 @@
public Function(Symbol symbol, String arglist, String docstring)
{
+ this();
symbol.setSymbolFunction(this);
if (cold)
symbol.setBuiltInFunction(true);
@@ -100,6 +111,7 @@
public Function(String name, Package pkg, boolean exported,
String arglist, String docstring)
{
+ this();
if (arglist instanceof String)
setLambdaList(new SimpleString(arglist));
if (name != null) {
@@ -120,11 +132,13 @@
public Function(LispObject name)
{
+ this();
setLambdaName(name);
}
public Function(LispObject name, LispObject lambdaList)
{
+ this();
setLambdaName(name);
setLambdaList(lambdaList);
}
@@ -182,7 +196,22 @@
} else {
ClassLoader c = getClass().getClassLoader();
if(c instanceof FaslClassLoader) {
- return new JavaObject(((FaslClassLoader) c).getFunctionClassBytes(this));
+ final LispThread thread = LispThread.currentThread();
+ SpecialBindingsMark mark = thread.markSpecialBindings();
+ try {
+ thread.bindSpecial(Symbol.LOAD_TRUENAME, loadedFrom);
+ return new JavaObject(((FaslClassLoader) c).getFunctionClassBytes(this));
+ } catch(Throwable t) {
+ //This is because unfortunately getFunctionClassBytes uses
+ //Debug.assertTrue(false) to signal errors
+ if(t instanceof ControlTransfer) {
+ throw (ControlTransfer) t;
+ } else {
+ return NIL;
+ }
+ } finally {
+ thread.resetSpecialBindings(mark);
+ }
} else {
return NIL;
}
More information about the armedbear-cvs
mailing list