Changeset 11892


Ignore:
Timestamp:
05/17/09 14:38:44 (9 years ago)
Author:
ehuelsmann
Message:

Re-use fields of objects declared previously
within the same class file, instead of creating
separate fields for every reference.

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

Legend:

Unmodified
Added
Removed
  • trunk/abcl/src/org/armedbear/lisp/compiler-pass2.lisp

    r11891 r11892  
    21982198
    21992199The field type of the object is specified by OBJ-REF."
    2200   (let ((key (symbol-name (gensym "OBJ"))))
    2201     (remember key obj)
    2202     (let* ((g1 (declare-string key))
    2203            (g2 (symbol-name (gensym "O2BJ"))))
    2204       (let* ((*code* *static-code*))
    2205       (declare-field g2 obj-ref)
    2206       (emit 'getstatic *this-class* g1 +lisp-simple-string+)
    2207       (emit-invokestatic +lisp-class+ "recall"
    2208                          (list +lisp-simple-string+) +lisp-object+)
    2209       (when (and obj-class (string/= obj-class +lisp-object-class+))
    2210         (emit 'checkcast obj-class))
    2211       (emit 'putstatic *this-class* g2 obj-ref)
    2212       (setf *static-code* *code*)
    2213       g2))))
     2200  (let ((field-name (gethash1 obj *declared-objects*)))
     2201    (if field-name
     2202        field-name
     2203      (let ((key (symbol-name (gensym "OBJ"))))
     2204        (remember key obj)
     2205        (let* ((g1 (declare-string key))
     2206               (g2 (symbol-name (gensym "O2BJ")))
     2207               (*code* *static-code*))
     2208          (declare-field g2 obj-ref)
     2209          (emit 'getstatic *this-class* g1 +lisp-simple-string+)
     2210          (emit-invokestatic +lisp-class+ "recall"
     2211                             (list +lisp-simple-string+) +lisp-object+)
     2212          (when (and obj-class (string/= obj-class +lisp-object-class+))
     2213            (emit 'checkcast obj-class))
     2214          (emit 'putstatic *this-class* g2 obj-ref)
     2215          (setf *static-code* *code*)
     2216          (setf (gethash obj *declared-objects*) g2))))))
    22142217
    22152218(defun declare-lambda (obj)
  • trunk/abcl/src/org/armedbear/lisp/jvm.lisp

    r11880 r11892  
    8888(defvar *declared-floats* nil)
    8989(defvar *declared-doubles* nil)
     90(defvar *declared-objects* nil)
    9091
    9192(defstruct (class-file (:constructor %make-class-file))
     
    106107  (integers (make-hash-table :test 'eql))
    107108  (floats (make-hash-table :test 'eql))
    108   (doubles (make-hash-table :test 'eql)))
     109  (doubles (make-hash-table :test 'eql))
     110  (objects (make-hash-table :test 'eq)))
    109111
    110112(defun class-name-from-filespec (filespec)
     
    138140            (*declared-integers*  (class-file-integers ,var))
    139141            (*declared-floats*    (class-file-floats ,var))
    140             (*declared-doubles*   (class-file-doubles ,var)))
     142            (*declared-doubles*   (class-file-doubles ,var))
     143            (*declared-objects*   (class-file-objects ,var)))
    141144       (progn ,@body)
    142145       (setf (class-file-pool ,var)         *pool*
     
    150153             (class-file-integers ,var)     *declared-integers*
    151154             (class-file-floats ,var)       *declared-floats*
    152              (class-file-doubles ,var)      *declared-doubles*))))
     155             (class-file-doubles ,var)      *declared-doubles*
     156             (class-file-objects ,var)      *declared-objects*))))
    153157
    154158(defstruct compiland
Note: See TracChangeset for help on using the changeset viewer.