Ignore:
Timestamp:
08/07/10 10:14:30 (13 years ago)
Author:
ehuelsmann
Message:

Move OPTIMIZE-2B (renaming it to OPTIMIZE-JUMPS)
to jvm-instructions.lisp.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/generic-class-file/abcl/src/org/armedbear/lisp/compiler-pass2.lisp

    r12869 r12870  
    964964      t)))
    965965
    966 (declaim (ftype (function (t) hash-table) hash-labels))
    967 (defun hash-labels (code)
    968   (let ((ht (make-hash-table :test 'eq))
    969         (code (coerce code 'vector))
    970         (pending-labels '()))
    971     (dotimes (i (length code))
    972       (declare (type (unsigned-byte 16) i))
    973       (let ((instruction (aref code i)))
    974         (cond ((label-p instruction)
    975                (push (instruction-label instruction) pending-labels))
    976               (t
    977                ;; Not a label.
    978                (when pending-labels
    979                  (dolist (label pending-labels)
    980                    (setf (gethash label ht) instruction))
    981                  (setf pending-labels nil))))))
    982     ht))
    983 
    984 (defun optimize-2b ()
    985   (let* ((code (coerce *code* 'vector))
    986          (ht (hash-labels code))
    987          (changed nil))
    988     (dotimes (i (length code))
    989       (declare (type (unsigned-byte 16) i))
    990       (let ((instruction (aref code i)))
    991         (when (and instruction (= (instruction-opcode instruction) 167)) ; GOTO
    992           (let* ((target-label (car (instruction-args instruction)))
    993                  (next-instruction (gethash1 target-label ht)))
    994             (when next-instruction
    995               (case (instruction-opcode next-instruction)
    996                 (167 ; GOTO
    997                  (setf (instruction-args instruction)
    998                        (instruction-args next-instruction)
    999                        changed t))
    1000                 (176 ; ARETURN
    1001                  (setf (instruction-opcode instruction) 176
    1002                        (instruction-args instruction) nil
    1003                        changed t))))))))
    1004     (when changed
    1005       (setf *code* code)
    1006       t)))
    1007 
    1008966;; CLEAR-VALUES CLEAR-VALUES => CLEAR-VALUES
    1009967;; GETSTATIC POP => nothing
     
    10461004            (*code* changed-p)
    10471005          (delete-unused-labels *code*
    1048                                 (append
     1006                                (nconc
    10491007                                 (mapcar #'handler-from *handlers*)
    10501008                                 (mapcar #'handler-to *handlers*)
    10511009                                 (mapcar #'handler-code *handlers*))))
    10521010        (setf changed-p (or (optimize-2) changed-p))
    1053         (setf changed-p (or (optimize-2b) changed-p))
     1011        (if changed-p
     1012            (setf *code* (optimize-jumps *code*))
     1013            (multiple-value-setq
     1014                (*code* changed-p)
     1015              (optimize-jumps *code*)))
    10541016        (setf changed-p (or (optimize-3) changed-p))
    10551017        (if changed-p
Note: See TracChangeset for help on using the changeset viewer.