Changeset 12859
- Timestamp:
- 08/04/10 20:25:03 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/generic-class-file/abcl/src/org/armedbear/lisp/compiler-pass2.lisp
r12858 r12859 510 510 (apply #'%emit 'putstatic (u2 index)))) 511 511 512 (declaim (inline emit-getfield emit-putfield)) 513 (defknown emit-getfield (t t t) t) 514 (defun emit-getfield (class-name field-name type) 515 (let* ((index (if (null *current-code-attribute*) 516 (pool-field class-name field-name type) 517 (pool-add-field-ref *pool* class-name field-name type)))) 518 (apply #'%emit 'getfield (u2 index)))) 519 520 (defknown emit-putfield (t t t) t) 521 (defun emit-putfield (class-name field-name type) 522 (let* ((index (if (null *current-code-attribute*) 523 (pool-field class-name field-name type) 524 (pool-add-field-ref *pool* class-name field-name type)))) 525 (apply #'%emit 'putfield (u2 index)))) 526 527 528 512 529 (defvar type-representations '((:int fixnum) 513 530 (:long (integer #.most-negative-java-long … … 553 570 (t 554 571 (emit 'checkcast +lisp-character+) 555 (emit 'getfield +lisp-character+ "value" :char))))572 (emit-getfield +lisp-character+ "value" :char)))) 556 573 557 574 ;; source type / … … 842 859 (t 843 860 (emit 'checkcast +lisp-fixnum+) 844 (emit 'getfield +lisp-fixnum+ "value" :int))))861 (emit-getfield +lisp-fixnum+ "value" :int)))) 845 862 846 863 (defknown emit-unbox-long () t) … … 857 874 (t 858 875 (emit 'checkcast +lisp-single-float+) 859 (emit 'getfield +lisp-single-float+ "value" :float))))876 (emit-getfield +lisp-single-float+ "value" :float)))) 860 877 861 878 (defknown emit-unbox-double () t) … … 867 884 (t 868 885 (emit 'checkcast +lisp-double-float+) 869 (emit 'getfield +lisp-double-float+ "value" :double))))886 (emit-getfield +lisp-double-float+ "value" :double)))) 870 887 871 888 (defknown fix-boxing (t t) t) … … 878 895 (< *safety* 3)) 879 896 (emit 'checkcast +lisp-fixnum+) 880 (emit 'getfield +lisp-fixnum+ "value" :int))897 (emit-getfield +lisp-fixnum+ "value" :int)) 881 898 (t 882 899 (emit-invokevirtual +lisp-object+ "intValue" nil :int)))) … … 1162 1179 ;; getfield, putfield class-name field-name type-name 1163 1180 (define-resolver (180 181) (instruction) 1164 (let* ((args (instruction-args instruction)) 1165 (index (pool-field (first args) 1166 (second args) (third args)))) 1167 (inst (instruction-opcode instruction) (u2 index)))) 1181 ;; we used to create the pool-field here; that moved to the emit-* layer 1182 instruction) 1168 1183 1169 1184 ;; new, anewarray, checkcast, instanceof class-name … … 1191 1206 1192 1207 (defun resolve-instructions (code) 1193 (let ((vector (make-array 512 :fill-pointer 0 :adjustable t))) 1194 (dotimes (index (length code) vector) 1208 (let* ((len (length code)) 1209 (vector (make-array (ash len 1) :fill-pointer 0 :adjustable t))) 1210 (dotimes (index len vector) 1195 1211 (declare (type (unsigned-byte 16) index)) 1196 1212 (let ((instruction (svref code index))) … … 1201 1217 (inst 'aload *thread*) 1202 1218 (inst 'aconst_null) 1203 (inst 'putfield ( list+lisp-thread+ "_values"1204 +lisp-object-array+)))))1219 (inst 'putfield (u2 (pool-field +lisp-thread+ "_values" 1220 +lisp-object-array+)))))) 1205 1221 (dolist (instruction instructions) 1206 1222 (vector-push-extend (resolve-instruction instruction) vector)))) … … 3740 3756 ;; Save multiple values returned by first subform. 3741 3757 (emit-push-current-thread) 3742 (emit 'getfield +lisp-thread+ "_values" +lisp-object-array+)3758 (emit-getfield +lisp-thread+ "_values" +lisp-object-array+) 3743 3759 (astore values-register) 3744 3760 (dolist (subform subforms) … … 3747 3763 (emit-push-current-thread) 3748 3764 (aload values-register) 3749 (emit 'putfield +lisp-thread+ "_values" +lisp-object-array+)3765 (emit-putfield +lisp-thread+ "_values" +lisp-object-array+) 3750 3766 ;; Result. 3751 3767 (aload result-register) … … 3946 3962 ;; Store values from values form in values register. 3947 3963 (emit-push-current-thread) 3948 (emit 'getfield +lisp-thread+ "_values" +lisp-object-array+)3964 (emit-getfield +lisp-thread+ "_values" +lisp-object-array+) 3949 3965 (emit-move-from-stack values-register) 3950 3966 ;; Did we get just one value? … … 4121 4137 (emit 'aaload) 4122 4138 (emit-swap representation nil) 4123 (emit 'putfield +lisp-closure-binding+ "value" +lisp-object+))4139 (emit-putfield +lisp-closure-binding+ "value" +lisp-object+)) 4124 4140 ((variable-environment variable) 4125 4141 (assert (not *file-compilation*)) … … 4153 4169 (emit-push-constant-int (variable-closure-index variable)) 4154 4170 (emit 'aaload) 4155 (emit 'getfield +lisp-closure-binding+ "value" +lisp-object+))4171 (emit-getfield +lisp-closure-binding+ "value" +lisp-object+)) 4156 4172 ((variable-environment variable) 4157 4173 (assert (not *file-compilation*)) … … 4412 4428 (astore go-register) 4413 4429 ;; Get the tag. 4414 (emit 'getfield +lisp-go+ "tagbody" +lisp-object+) ; Stack depth is still 1.4430 (emit-getfield +lisp-go+ "tagbody" +lisp-object+) ; Stack depth is still 1. 4415 4431 (emit-push-variable (tagbody-id-variable block)) 4416 4432 (emit 'if_acmpne RETHROW) ;; Not this TAGBODY 4417 4433 (aload go-register) 4418 (emit 'getfield +lisp-go+ "tag" +lisp-object+) ; Stack depth is still 1.4434 (emit-getfield +lisp-go+ "tag" +lisp-object+) ; Stack depth is still 1. 4419 4435 (astore tag-register) 4420 4436 ;; Don't actually generate comparisons for tags … … 4587 4603 ;; The Return object is on the runtime stack. Stack depth is 1. 4588 4604 (emit 'dup) ; Stack depth is 2. 4589 (emit 'getfield +lisp-return+ "tag" +lisp-object+) ; Still 2.4605 (emit-getfield +lisp-return+ "tag" +lisp-object+) ; Still 2. 4590 4606 (emit-push-variable (block-id-variable block)) 4591 4607 ;; If it's not the block we're looking for... … … 4597 4613 (emit 'athrow) 4598 4614 (label THIS-BLOCK) 4599 (emit 'getfield +lisp-return+ "result" +lisp-object+)4615 (emit-getfield +lisp-return+ "result" +lisp-object+) 4600 4616 (emit-move-from-stack target) ; Stack depth is 0. 4601 4617 ;; Finally... … … 7124 7140 (variable-block variable)))) 7125 7141 (aload (variable-binding-register variable)) 7126 (emit 'getfield +lisp-special-binding+ "value"7142 (emit-getfield +lisp-special-binding+ "value" 7127 7143 +lisp-object+)) 7128 7144 (t … … 7204 7220 (compile-forms-and-maybe-emit-clear-values value-form 'stack nil) 7205 7221 (emit 'dup_x1) ;; copy past th 7206 (emit 'putfield +lisp-special-binding+ "value"7222 (emit-putfield +lisp-special-binding+ "value" 7207 7223 +lisp-object+)) 7208 7224 ((and (consp value-form) … … 7312 7328 (compile-forms-and-maybe-emit-clear-values arg 'stack nil) 7313 7329 (emit 'checkcast +lisp-symbol+) 7314 (emit 'getfield +lisp-symbol+ "name" +lisp-simple-string+)7330 (emit-getfield +lisp-symbol+ "name" +lisp-simple-string+) 7315 7331 (emit-move-from-stack target representation)) 7316 7332 (t … … 7571 7587 ;; The Throw object is on the runtime stack. Stack depth is 1. 7572 7588 (emit 'dup) ; Stack depth is 2. 7573 (emit 'getfield +lisp-throw+ "tag" +lisp-object+) ; Still 2.7589 (emit-getfield +lisp-throw+ "tag" +lisp-object+) ; Still 2. 7574 7590 (aload tag-register) ; Stack depth is 3. 7575 7591 ;; If it's not the tag we're looking for, we branch to the start of the … … 7648 7664 (unless (single-valued-p protected-form) 7649 7665 (emit-push-current-thread) 7650 (emit 'getfield +lisp-thread+ "_values" +lisp-object-array+)7666 (emit-getfield +lisp-thread+ "_values" +lisp-object-array+) 7651 7667 (astore values-register)) 7652 7668 (label END-PROTECTED-RANGE)) … … 7661 7677 (astore exception-register) 7662 7678 (emit-push-current-thread) 7663 (emit 'getfield +lisp-thread+ "_values" +lisp-object-array+)7679 (emit-getfield +lisp-thread+ "_values" +lisp-object-array+) 7664 7680 (astore values-register) 7665 7681 (let ((*register* *register*)) … … 7669 7685 (emit-push-current-thread) 7670 7686 (aload values-register) 7671 (emit 'putfield +lisp-thread+ "_values" +lisp-object-array+)7687 (emit-putfield +lisp-thread+ "_values" +lisp-object-array+) 7672 7688 (aload exception-register) 7673 7689 (emit 'athrow) ; Re-throw exception. … … 7677 7693 (emit-push-current-thread) 7678 7694 (aload values-register) 7679 (emit 'putfield +lisp-thread+ "_values" +lisp-object-array+))7695 (emit-putfield +lisp-thread+ "_values" +lisp-object-array+)) 7680 7696 ;; Result. 7681 7697 (aload result-register) … … 7968 7984 (progn 7969 7985 (aload 0) 7970 (emit 'getfield +lisp-compiled-closure+ "ctx"7986 (emit-getfield +lisp-compiled-closure+ "ctx" 7971 7987 +closure-binding-array+) 7972 7988 (when local-closure-vars
Note: See TracChangeset
for help on using the changeset viewer.