Changeset 12279


Ignore:
Timestamp:
11/15/09 21:07:24 (12 years ago)
Author:
ehuelsmann
Message:

Make car()/cdr()/setCar()/setCdr()/EQ() non-virtual,

dispatching where required on instanceof.

Note: Our findings are that virtual calls are slower than

instanceof checks (followed by a cast if necessary),
meaning that for small numbers of instanceof comparisons
the construct now committed will be faster.

Patch by: vvoutilainen

Location:
trunk/abcl/src/org/armedbear/lisp
Files:
3 edited

Legend:

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

    r12272 r12279  
    125125
    126126  @Override
    127   public final LispObject car()
    128   {
    129     return car;
    130   }
    131 
    132   @Override
    133   public final LispObject cdr()
    134   {
    135     return cdr;
    136   }
    137 
    138   @Override
    139   public final void setCar(LispObject obj)
    140   {
    141     car = obj;
    142   }
    143 
    144   @Override
    145127  public LispObject RPLACA(LispObject obj)
    146128  {
    147129    car = obj;
    148130    return this;
    149   }
    150 
    151   @Override
    152   public final void setCdr(LispObject obj)
    153   {
    154     cdr = obj;
    155131  }
    156132
  • trunk/abcl/src/org/armedbear/lisp/LispObject.java

    r12254 r12279  
    125125
    126126
    127   public LispObject car()
    128   {
     127  public final LispObject car()
     128  {
     129    if (this instanceof Cons) {
     130      return ((Cons)this).car;
     131    } else if (this == NIL) {
     132      return NIL;
     133    }
    129134    return type_error(this, Symbol.LIST);
    130135  }
    131136
    132   public void setCar(LispObject obj)
    133   {
     137  public final void setCar(LispObject obj)
     138  {
     139      if (this instanceof Cons) {
     140          ((Cons)this).car = obj;
     141          return;
     142      }
    134143    type_error(this, Symbol.CONS);
    135144  }
     
    140149  }
    141150
    142   public LispObject cdr()
    143   {
     151  public final LispObject cdr()
     152  {
     153    if (this instanceof Cons) {
     154      return ((Cons)this).cdr;
     155    } else if (this instanceof Nil) {
     156      return NIL;
     157    }
    144158    return type_error(this, Symbol.LIST);
    145159  }
    146160
    147   public void setCdr(LispObject obj)
    148   {
     161  public final void setCdr(LispObject obj)
     162  {
     163      if (this instanceof Cons) {
     164          ((Cons)this).cdr = obj;
     165          return;
     166      }
     167
    149168    type_error(this, Symbol.CONS);
    150169  }
     
    183202  }
    184203
    185   public LispObject EQ(LispObject obj)
     204  final public LispObject EQ(LispObject obj)
    186205  {
    187206    return this == obj ? T : NIL;
  • trunk/abcl/src/org/armedbear/lisp/Nil.java

    r12254 r12279  
    106106
    107107    @Override
    108     public LispObject car()
    109     {
    110         return this;
    111     }
    112 
    113     @Override
    114     public LispObject cdr()
    115     {
    116         return this;
    117     }
    118 
    119     @Override
    120108    public final LispObject cadr()
    121109    {
Note: See TracChangeset for help on using the changeset viewer.