- Timestamp:
- 08/07/10 11:53:23 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/generic-class-file/abcl/src/org/armedbear/lisp/compiler-pass2.lisp
r12870 r12871 919 919 920 920 921 922 (defun optimize-2 ()923 (let* ((code (coerce *code* 'vector))924 (length (length code))925 (changed nil))926 (declare (type (unsigned-byte 16) length))927 ;; Since we're looking at this instruction and the next one, we can stop928 ;; one before the end.929 (dotimes (i (1- length))930 (declare (type (unsigned-byte 16) i))931 (let ((instruction (aref code i)))932 (when (and instruction (= (instruction-opcode instruction) 167)) ; GOTO933 (do* ((j (1+ i) (1+ j))934 (next-instruction (aref code j) (aref code j)))935 ((>= j length))936 (declare (type (unsigned-byte 16) j))937 (when next-instruction938 (cond ((= (instruction-opcode next-instruction) 167) ; GOTO939 (cond ((= j (1+ i))940 ;; Two GOTOs in a row: the second instruction is941 ;; unreachable.942 (setf (aref code j) nil)943 (setf changed t))944 ((eq (car (instruction-args next-instruction))945 (car (instruction-args instruction)))946 ;; We've reached another GOTO to the same destination.947 ;; We don't need the first GOTO; we can just fall948 ;; through to the second one.949 (setf (aref code i) nil)950 (setf changed t)))951 (return))952 ((= (instruction-opcode next-instruction) 202) ; LABEL953 (when (eq (car (instruction-args instruction))954 (car (instruction-args next-instruction)))955 ;; GOTO next instruction; we don't need this one.956 (setf (aref code i) nil)957 (setf changed t)958 (return)))959 (t960 ;; Not a GOTO or a label.961 (return))))))))962 (when changed963 (setf *code* (delete nil code))964 t)))965 966 921 ;; CLEAR-VALUES CLEAR-VALUES => CLEAR-VALUES 967 922 ;; GETSTATIC POP => nothing … … 972 927 (declare (type (unsigned-byte 16) i)) 973 928 (let* ((this-instruction (aref code i)) 974 (this-opcode (and this-instruction (instruction-opcode this-instruction))) 929 (this-opcode (and this-instruction 930 (instruction-opcode this-instruction))) 975 931 (next-instruction (aref code (1+ i))) 976 (next-opcode (and next-instruction (instruction-opcode next-instruction)))) 932 (next-opcode (and next-instruction 933 (instruction-opcode next-instruction)))) 977 934 (case this-opcode 978 935 (205 ; CLEAR-VALUES … … 984 941 (setf (aref code i) nil) 985 942 (setf (aref code (1+ i)) nil) 943 (setf changed t))) 944 (167 ; GOTO 945 (when (and (eql next-opcode 202) ; LABEL 946 (eq (car (instruction-args this-instruction)) 947 (car (instruction-args next-instruction)))) 948 (setf (aref code i) nil) 949 ;;(setf (aref code (1+ i)) nil) 986 950 (setf changed t)))))) 987 951 (when changed … … 1008 972 (mapcar #'handler-to *handlers*) 1009 973 (mapcar #'handler-code *handlers*)))) 1010 (setf changed-p (or (optimize-2) changed-p))1011 974 (if changed-p 1012 975 (setf *code* (optimize-jumps *code*))
Note: See TracChangeset
for help on using the changeset viewer.