Changeset 11861


Ignore:
Timestamp:
05/14/09 18:17:08 (13 years ago)
Author:
ehuelsmann
Message:

Work in progress on changing the closure array over from variables to bindings.

Location:
branches/closure-fixes/abcl/src/org/armedbear/lisp
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • branches/closure-fixes/abcl/src/org/armedbear/lisp/ClosureTemplateFunction.java

    r11711 r11861  
    3838{
    3939
    40   public LispObject[] ctx;
     40  public ClosureBinding[] ctx;
    4141
    4242  public ClosureTemplateFunction(LispObject lambdaList)
     
    4646  }
    4747
    48   final public ClosureTemplateFunction setContext(LispObject[] context)
     48  final public ClosureTemplateFunction setContext(ClosureBinding[] context)
    4949  {
    5050    ctx = context;
     
    157157
    158158  // Zero args.
    159   public LispObject _execute(LispObject[] context) throws ConditionThrowable
     159  public LispObject _execute(ClosureBinding[] context) throws ConditionThrowable
    160160  {
    161161    LispObject[] args = new LispObject[0];
     
    164164
    165165  // One arg.
    166   public LispObject _execute(LispObject[] context, LispObject first)
     166  public LispObject _execute(ClosureBinding[] context, LispObject first)
    167167    throws ConditionThrowable
    168168  {
     
    173173
    174174  // Two args.
    175   public LispObject _execute(LispObject[] context, LispObject first,
     175  public LispObject _execute(ClosureBinding[] context, LispObject first,
    176176                            LispObject second)
    177177    throws ConditionThrowable
     
    184184
    185185  // Three args.
    186   public LispObject _execute(LispObject[] context, LispObject first,
     186  public LispObject _execute(ClosureBinding[] context, LispObject first,
    187187                            LispObject second, LispObject third)
    188188    throws ConditionThrowable
     
    196196
    197197  // Four args.
    198   public LispObject _execute(LispObject[] context, LispObject first,
     198  public LispObject _execute(ClosureBinding[] context, LispObject first,
    199199                            LispObject second, LispObject third,
    200200                            LispObject fourth)
     
    210210
    211211  // Five args.
    212   public LispObject _execute(LispObject[] context, LispObject first,
     212  public LispObject _execute(ClosureBinding[] context, LispObject first,
    213213                            LispObject second, LispObject third,
    214214                            LispObject fourth, LispObject fifth)
     
    225225
    226226  // Six args.
    227   public LispObject _execute(LispObject[] context, LispObject first,
     227  public LispObject _execute(ClosureBinding[] context, LispObject first,
    228228                            LispObject second, LispObject third,
    229229                            LispObject fourth, LispObject fifth,
     
    242242
    243243  // Seven args.
    244   public LispObject _execute(LispObject[] context, LispObject first,
     244  public LispObject _execute(ClosureBinding[] context, LispObject first,
    245245                            LispObject second, LispObject third,
    246246                            LispObject fourth, LispObject fifth,
     
    260260
    261261  // Eight args.
    262   public LispObject _execute(LispObject[] context, LispObject first,
     262  public LispObject _execute(ClosureBinding[] context, LispObject first,
    263263                            LispObject second, LispObject third,
    264264                            LispObject fourth, LispObject fifth,
     
    280280
    281281  // Arg array.
    282   public LispObject _execute(LispObject[] context, LispObject[] args)
     282  public LispObject _execute(ClosureBinding[] context, LispObject[] args)
    283283    throws ConditionThrowable
    284284  {
  • branches/closure-fixes/abcl/src/org/armedbear/lisp/CompiledClosure.java

    r11514 r11861  
    3737{
    3838    private final ClosureTemplateFunction ctf;
    39     private final LispObject[] context;
     39    private final ClosureBinding[] context;
    4040
    41     public CompiledClosure(ClosureTemplateFunction ctf, LispObject[] context)
     41    public CompiledClosure(ClosureTemplateFunction ctf, ClosureBinding[] context)
    4242    {
    4343        super(ctf.getLambdaName(), ctf.getLambdaList());
  • branches/closure-fixes/abcl/src/org/armedbear/lisp/Lisp.java

    r11777 r11861  
    11871187
    11881188  public static final LispObject makeCompiledClosure(LispObject template,
    1189                                                      LispObject[] context)
     1189                                                     ClosureBinding[] context)
    11901190    throws ConditionThrowable
    11911191  {
  • branches/closure-fixes/abcl/src/org/armedbear/lisp/compiler-pass2.lisp

    r11857 r11861  
    206206(defconstant +lisp-object+ "Lorg/armedbear/lisp/LispObject;")
    207207(defconstant +lisp-object-array+ "[Lorg/armedbear/lisp/LispObject;")
     208(defconstant +closure-binding-array+ "[Lorg/armedbear/lisp/ClosureBinding;")
    208209(defconstant +lisp-symbol-class+ "org/armedbear/lisp/Symbol")
    209210(defconstant +lisp-symbol+ "Lorg/armedbear/lisp/Symbol;")
     
    30483049               (aload (compiland-closure-register compiland))
    30493050               (emit-invokestatic +lisp-class+ "makeCompiledClosure"
    3050                                   (list +lisp-object+ +lisp-object-array+)
     3051                                  (list +lisp-object+ +closure-binding-array+)
    30513052                                  +lisp-object+)))))
    30523053    (process-args args)
     
    39203921                             (list +lisp-symbol+ +lisp-object+) nil))
    39213922        ((variable-closure-index variable)
     3923         (emit 'new "org/armedbear/lisp/ClosureBinding")
     3924         (emit 'dup)
     3925         (emit-invokespecial-init "org/armedbear/lisp/ClosureBinding"
     3926                                 (list +lisp-object+))
    39223927         (aload (compiland-closure-register *current-compiland*))
    39233928         (emit 'swap) ; array value
     
    41964201            ((variable-closure-index variable)
    41974202             (aload (compiland-closure-register *current-compiland*))
     4203             (emit-push-constant-int (variable-closure-index variable))
     4204             (emit 'aaload)
    41984205             (emit-swap representation nil)
    4199              (emit-push-constant-int (variable-closure-index variable))
    4200              (emit-swap representation :int)
    4201              (emit-array-store (variable-representation variable)))
     4206             (emit 'putfield "org/armedbear/lisp/ClosureBinding" "value"
     4207                   "Lorg/armedbear/lisp/LispObject;"))
    42024208            (t
    42034209             ;;###FIXME: We might want to address the "temp-register" case too.
     
    42054211
    42064212(defun emit-push-variable (variable)
    4207   (flet ((emit-array-store (representation)
     4213  (flet ((emit-array-load (representation)
    42084214           (emit (ecase representation
    42094215                       ((:int :boolean :char)
     
    42254231           (aload (compiland-argument-register *current-compiland*))
    42264232           (emit-push-constant-int (variable-index variable))
    4227            (emit-array-store (variable-representation variable)))
     4233           (emit-array-load (variable-representation variable)))
    42284234          ((variable-closure-index variable)
    42294235           (aload (compiland-closure-register *current-compiland*))
    42304236           (emit-push-constant-int (variable-closure-index variable))
    4231            (emit-array-store (variable-representation variable)))
     4237           (emit 'aaload)
     4238           (emit 'getfield "org/armedbear/lisp/ClosureBinding" "value"
     4239                 "Lorg/armedbear/lisp/LispObject;"))
    42324240          (t ;;###FIXME: We might want to address the "temp-register" case too.
    42334241           (assert nil)))))
     
    48704878      (aload (compiland-closure-register parent))
    48714879      (emit-invokestatic +lisp-class+ "makeCompiledClosure"
    4872        (list +lisp-object+ +lisp-object-array+)
     4880       (list +lisp-object+ +closure-binding-array+)
    48734881       +lisp-object+)))
    48744882  (emit-move-to-variable (local-function-variable local-function)))
     
    50185026           (aload (compiland-closure-register *current-compiland*))
    50195027           (emit-invokestatic +lisp-class+ "makeCompiledClosure"
    5020                               (list +lisp-object+ +lisp-object-array+)
     5028                              (list +lisp-object+ +closure-binding-array+)
    50215029                              +lisp-object+)
    50225030           (emit 'checkcast +lisp-compiled-closure-class+)) ; Stack: compiled-closure
     
    50505058                             (aload (compiland-closure-register *current-compiland*))
    50515059                             (emit-invokestatic +lisp-class+ "makeCompiledClosure"
    5052                                                 (list +lisp-object+ +lisp-object-array+)
     5060                                                (list +lisp-object+ +closure-binding-array+)
    50535061                                                +lisp-object+)))))
    50545062                  (emit-move-from-stack target))
     
    78877895        (return-from analyze-args
    78887896                     (if *closure-variables*
    7889                          (get-descriptor (list +lisp-object-array+ +lisp-object-array+)
    7890                                           +lisp-object+)
     7897                         (get-descriptor (list +closure-binding-array+
     7898                                               +lisp-object-array+)
     7899                                         +lisp-object+)
    78917900                         (get-descriptor (list +lisp-object-array+)
    7892                                           +lisp-object+))))
     7901                                         +lisp-object+))))
    78937902      (cond (*closure-variables*
    78947903             (return-from analyze-args
    78957904                          (cond ((<= arg-count call-registers-limit)
    7896                                  (get-descriptor (list* +lisp-object-array+
     7905                                 (get-descriptor (list* +closure-binding-array+
    78977906                                                        (lisp-object-arg-types arg-count))
    78987907                                                 +lisp-object+))
    78997908                                (t (setf *using-arg-array* t)
    79007909                                   (setf (compiland-arity compiland) arg-count)
    7901                                    (get-descriptor (list +lisp-object-array+ +lisp-object-array+) ;; FIXME
     7910                                   (get-descriptor (list +closure-binding-array+ +lisp-object-array+) ;; FIXME
    79027911                                                   +lisp-object+)))))
    79037912            (t
     
    81068115             (dformat t "p2-compiland ~S anewarray 1~%"
    81078116                      (compiland-name compiland))
    8108              (emit 'anewarray "org/armedbear/lisp/LispObject")))
     8117             (emit 'anewarray "org/armedbear/lisp/ClosureBinding")))
    81098118      (dolist (variable closure-args)
    81108119        (dformat t "moving variable ~S~%" (variable-name variable))
     
    81158124               (emit-push-constant-int (variable-closure-index variable))
    81168125               (aload (variable-register variable))
     8126               (emit 'new "org/armedbear/lisp/ClosureBinding")
     8127               (emit 'dup)
     8128               (emit-invokespecial-init "org/armedbear/lisp/ClosureBinding"
     8129                                       (list "Lorg/armedbear/lisp/LisObject;"))
    81178130               (emit 'aastore)
    81188131               (setf (variable-register variable) nil))
     
    81238136               (emit-push-constant-int (variable-index variable))
    81248137               (emit 'aaload)
     8138               (emit 'new "org/armedbear/lisp/ClosureBinding")
     8139               (emit 'dup)
     8140               (emit-invokespecial-init "org/armedbear/lisp/ClosureBinding"
     8141                                       (list "Lorg/armedbear/lisp/LisObject;"))
    81258142               (emit 'aastore)
    81268143               (setf (variable-index variable) nil))))
Note: See TracChangeset for help on using the changeset viewer.