- 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/jvm-instructions.lisp
r12869 r12870 819 819 changed))) 820 820 821 822 (declaim (ftype (function (t) hash-table) hash-labels)) 823 (defun label-target-instructions (code) 824 (let ((ht (make-hash-table :test 'eq)) 825 (code (coerce code 'vector)) 826 (pending-labels '())) 827 (dotimes (i (length code)) 828 (declare (type (unsigned-byte 16) i)) 829 (let ((instruction (aref code i))) 830 (cond ((label-p instruction) 831 (push (instruction-label instruction) pending-labels)) 832 (t 833 ;; Not a label. 834 (when pending-labels 835 (dolist (label pending-labels) 836 (setf (gethash label ht) instruction)) 837 (setf pending-labels nil)))))) 838 ht)) 839 840 (defun optimize-jumps (code) 841 (let* ((code (coerce code 'vector)) 842 (ht (label-target-instructions code)) 843 (changed nil)) 844 (dotimes (i (length code)) 845 (declare (type (unsigned-byte 16) i)) 846 (let ((instruction (aref code i))) 847 (when (and instruction (= (instruction-opcode instruction) 167)) ; GOTO 848 ;; we're missing conditional jumps here? 849 (let* ((target-label (car (instruction-args instruction))) 850 (next-instruction (gethash1 target-label ht))) 851 (when next-instruction 852 (case (instruction-opcode next-instruction) 853 ((167 200) ;; GOTO 854 (setf (instruction-args instruction) 855 (instruction-args next-instruction) 856 changed t)) 857 (176 ; ARETURN 858 (setf (instruction-opcode instruction) 176 859 (instruction-args instruction) nil 860 changed t)))))))) 861 (values code changed))) 862 821 863 (defun code-bytes (code) 822 864 (let ((length 0)
Note: See TracChangeset
for help on using the changeset viewer.