Changeset 12062


Ignore:
Timestamp:
07/26/09 19:37:47 (14 years ago)
Author:
ehuelsmann
Message:

Revert r12061: What looked good in the profiler worked out badly in practice.

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

Legend:

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

    r12061 r12062  
    141141    throws ConditionThrowable
    142142  {
     143    LispObject stack = thread.getStack();
    143144    thread.pushStackFrame(fun, args);
    144145    thread._values = null;
     
    189190    finally
    190191      {
    191         thread.popStackFrame();
     192        thread.setStack(stack);
    192193      }
    193194    return result;
  • trunk/abcl/src/org/armedbear/lisp/LispThread.java

    r12061 r12062  
    3535
    3636import java.util.Iterator;
    37 import java.util.LinkedList;
    3837import java.util.concurrent.ConcurrentHashMap;
    3938
     
    449448    }
    450449
    451     private static class StackFrame
     450    private static class StackFrame extends LispObject
    452451    {
    453452        public final LispObject operator;
     
    536535    }
    537536
    538     private LinkedList<StackFrame> stack = new LinkedList<StackFrame>();
    539 
    540     @Deprecated
     537    private LispObject stack = NIL;
     538
    541539    public LispObject getStack()
    542540    {
    543         return NIL;
    544     }
    545 
    546     @Deprecated
     541        return stack;
     542    }
     543
    547544    public void setStack(LispObject stack)
    548545    {
     546        this.stack = stack;
    549547    }
    550548
     
    561559        throws ConditionThrowable
    562560    {
    563         stack.addLast(new StackFrame(operator));
     561        stack = new Cons((new StackFrame(operator)), stack);
    564562        doProfiling();
    565563    }
     
    568566        throws ConditionThrowable
    569567    {
    570         stack.addLast(new StackFrame(operator, arg));
     568        stack = new Cons((new StackFrame(operator, arg)), stack);
    571569        doProfiling();
    572570    }
     
    576574        throws ConditionThrowable
    577575    {
    578         stack.addLast(new StackFrame(operator, first, second));
     576        stack = new Cons((new StackFrame(operator, first, second)), stack);
    579577        doProfiling();
    580578    }
     
    584582        throws ConditionThrowable
    585583    {
    586         stack.addLast(new StackFrame(operator, first, second, third));
     584        stack = new Cons((new StackFrame(operator, first, second, third)),
     585                         stack);
    587586        doProfiling();
    588587    }
     
    591590        throws ConditionThrowable
    592591    {
    593         stack.addLast(new StackFrame(operator, args));
     592        stack = new Cons((new StackFrame(operator, args)), stack);
    594593        doProfiling();
    595594    }
    596595
    597     public final void popStackFrame()
    598     {
    599         stack.removeLast();
    600     }
    601 
    602596    public void resetStack()
    603597    {
    604         stack.clear();
     598        stack = NIL;
    605599    }
    606600
     
    611605            return function.execute();
    612606
     607        LispObject oldStack = stack;
    613608        pushStackFrame(function);
    614609        try {
     
    617612        finally {
    618613            doProfiling();
    619             popStackFrame();
     614            stack = oldStack;
    620615        }
    621616    }
     
    628623            return function.execute(arg);
    629624
     625        LispObject oldStack = stack;
    630626        pushStackFrame(function, arg);
    631627        try {
     
    634630        finally {
    635631            doProfiling();
    636             popStackFrame();
     632            stack = oldStack;
    637633        }
    638634    }
     
    646642            return function.execute(first, second);
    647643
     644        LispObject oldStack = stack;
    648645        pushStackFrame(function, first, second);
    649646        try {
     
    652649        finally {
    653650            doProfiling();
    654             popStackFrame();
     651            stack = oldStack;
    655652        }
    656653    }
     
    664661            return function.execute(first, second, third);
    665662
     663        LispObject oldStack = stack;
    666664        pushStackFrame(function, first, second, third);
    667665        try {
     
    670668        finally {
    671669            doProfiling();
    672             popStackFrame();
     670            stack = oldStack;
    673671        }
    674672    }
     
    683681            return function.execute(first, second, third, fourth);
    684682
     683        LispObject oldStack = stack;
    685684        pushStackFrame(function, first, second, third, fourth);
    686685        try {
     
    689688        finally {
    690689            doProfiling();
    691             popStackFrame();
     690            stack = oldStack;
    692691        }
    693692    }
     
    702701            return function.execute(first, second, third, fourth, fifth);
    703702
     703        LispObject oldStack = stack;
    704704        pushStackFrame(function, first, second, third, fourth, fifth);
    705705        try {
     
    708708        finally {
    709709            doProfiling();
    710             popStackFrame();
     710            stack = oldStack;
    711711        }
    712712    }
     
    722722            return function.execute(first, second, third, fourth, fifth, sixth);
    723723
     724        LispObject oldStack = stack;
    724725        pushStackFrame(function, first, second, third, fourth, fifth, sixth);
    725726        try {
     
    728729        finally {
    729730            doProfiling();
    730             popStackFrame();
     731            stack = oldStack;
    731732        }
    732733    }
     
    743744                                    seventh);
    744745
     746        LispObject oldStack = stack;
    745747        pushStackFrame(function, first, second, third, fourth, fifth, sixth,
    746748                                    seventh);
     
    751753        finally {
    752754            doProfiling();
    753             popStackFrame();
     755            stack = oldStack;
    754756        }
    755757    }
     
    766768                                    seventh, eighth);
    767769
     770        LispObject oldStack = stack;
    768771        pushStackFrame(function, first, second, third, fourth, fifth, sixth,
    769772                                    seventh, eighth);
     
    774777        finally {
    775778            doProfiling();
    776             popStackFrame();
     779            stack = oldStack;
    777780        }
    778781    }
     
    784787            return function.execute(args);
    785788
     789        LispObject oldStack = stack;
    786790        pushStackFrame(function, args);
    787791        try {
     
    790794        finally {
    791795            doProfiling();
    792             popStackFrame();
     796            stack = oldStack;
    793797        }
    794798    }
     
    801805    public void backtrace(int limit)
    802806    {
    803         if (! stack.isEmpty()) {
     807        if (stack != NIL) {
    804808            try {
    805809                int count = 0;
     
    808812                out._writeLine("Evaluation stack:");
    809813                out._finishOutput();
    810                 Iterator<StackFrame> i = stack.iterator();
    811                 while (i.hasNext()) {
     814                while (stack != NIL) {
    812815                    out._writeString("  ");
    813816                    out._writeString(String.valueOf(count));
    814817                    out._writeString(": ");
    815                     StackFrame frame = i.next();
     818                    StackFrame frame = (StackFrame) stack.car();
    816819                    pprint(frame.toList(), out.getCharPos(), out);
    817820                    out.terpri();
     
    819822                    if (limit > 0 && ++count == limit)
    820823                        break;
     824                    stack = stack.cdr();
    821825                }
    822826            }
     
    830834    {
    831835        LispObject result = NIL;
    832         if (! stack.isEmpty()) {
     836        if (stack != NIL) {
    833837            int count = 0;
    834838            try {
    835                 Iterator<StackFrame> i = stack.iterator();
    836                 while (i.hasNext()) {
    837                     StackFrame frame = i.next();
     839                LispObject s = stack;
     840                while (s != NIL) {
     841                    StackFrame frame = (StackFrame) s.car();
    838842                    if (frame != null) {
    839843                        result = result.push(frame.toList());
     
    841845                            break;
    842846                    }
     847                    s = s.cdr();
    843848                }
    844849            }
     
    852857    public void incrementCallCounts() throws ConditionThrowable
    853858    {
    854         Iterator<StackFrame> i = stack.iterator();
    855         while (i.hasNext()) {
    856             StackFrame frame = i.next();
     859        LispObject s = stack;
     860        while (s != NIL) {
     861            StackFrame frame = (StackFrame) s.car();
    857862            if (frame != null) {
    858863                LispObject operator = frame.operator;
     
    860865                    operator.incrementCallCount();
    861866            }
     867            s = s.cdr();
    862868        }
    863869    }
Note: See TracChangeset for help on using the changeset viewer.