- Timestamp:
- 08/07/10 10:14:30 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/generic-class-file/abcl/src/org/armedbear/lisp/compiler-pass2.lisp
r12869 r12870 964 964 t))) 965 965 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 (t977 ;; Not a label.978 (when pending-labels979 (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)) ; GOTO992 (let* ((target-label (car (instruction-args instruction)))993 (next-instruction (gethash1 target-label ht)))994 (when next-instruction995 (case (instruction-opcode next-instruction)996 (167 ; GOTO997 (setf (instruction-args instruction)998 (instruction-args next-instruction)999 changed t))1000 (176 ; ARETURN1001 (setf (instruction-opcode instruction) 1761002 (instruction-args instruction) nil1003 changed t))))))))1004 (when changed1005 (setf *code* code)1006 t)))1007 1008 966 ;; CLEAR-VALUES CLEAR-VALUES => CLEAR-VALUES 1009 967 ;; GETSTATIC POP => nothing … … 1046 1004 (*code* changed-p) 1047 1005 (delete-unused-labels *code* 1048 ( append1006 (nconc 1049 1007 (mapcar #'handler-from *handlers*) 1050 1008 (mapcar #'handler-to *handlers*) 1051 1009 (mapcar #'handler-code *handlers*)))) 1052 1010 (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*))) 1054 1016 (setf changed-p (or (optimize-3) changed-p)) 1055 1017 (if changed-p
Note: See TracChangeset
for help on using the changeset viewer.