Ignore:
Timestamp:
06/27/10 21:38:09 (12 years ago)
Author:
astalla
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/abcl/src/org/armedbear/lisp/Function.java

    r12749 r12771  
    4141    private int callCount;
    4242    private int hotCount;
    43 
    44     protected Function() {}
     43    /**
     44     * The value of *load-truename* which was current when this function
     45     * was loaded, used for fetching the class bytes in case of disassebly.
     46     */
     47    private final LispObject loadedFrom;
     48
     49    protected Function() {
     50  LispObject loadTruename = Symbol.LOAD_TRUENAME.symbolValueNoThrow();
     51  loadedFrom = loadTruename != null ? loadTruename : NIL;
     52    }
    4553
    4654    public Function(String name)
    4755    {
     56  this();
    4857        if (name != null) {
    4958            Symbol symbol = Symbol.addFunction(name.toUpperCase(), this);
     
    5665    public Function(Symbol symbol, String arglist)
    5766    {
     67  this();
    5868        symbol.setSymbolFunction(this);
    5969        if (cold)
     
    6575    public Function(Symbol symbol, String arglist, String docstring)
    6676    {
     77  this();
    6778        symbol.setSymbolFunction(this);
    6879        if (cold)
     
    101112                    String arglist, String docstring)
    102113    {
     114  this();
    103115        if (arglist instanceof String)
    104116            setLambdaList(new SimpleString(arglist));
     
    121133    public Function(LispObject name)
    122134    {
     135  this();
    123136        setLambdaName(name);
    124137    }
     
    126139    public Function(LispObject name, LispObject lambdaList)
    127140    {
     141  this();
    128142        setLambdaName(name);
    129143        setLambdaList(lambdaList);
     
    183197      ClassLoader c = getClass().getClassLoader();
    184198      if(c instanceof FaslClassLoader) {
    185     return new JavaObject(((FaslClassLoader) c).getFunctionClassBytes(this));
     199    final LispThread thread = LispThread.currentThread();
     200    SpecialBindingsMark mark = thread.markSpecialBindings();
     201    try {
     202        thread.bindSpecial(Symbol.LOAD_TRUENAME, loadedFrom);
     203        return new JavaObject(((FaslClassLoader) c).getFunctionClassBytes(this));
     204    } catch(Throwable t) {
     205        //This is because unfortunately getFunctionClassBytes uses
     206        //Debug.assertTrue(false) to signal errors
     207        if(t instanceof ControlTransfer) {
     208      throw (ControlTransfer) t;
     209        } else {
     210      return NIL;
     211        }
     212    } finally {
     213        thread.resetSpecialBindings(mark);
     214    }   
    186215      } else {
    187216    return NIL;
Note: See TracChangeset for help on using the changeset viewer.