Changeset 15141
- Timestamp:
- 11/01/19 15:53:04 (4 years ago)
- Location:
- trunk/abcl/src/org/armedbear/lisp
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/abcl/src/org/armedbear/lisp/compiler-pass1.lisp
r15098 r15141 674 674 (let* ((block (make-unwind-protect-node)) 675 675 (*block* block) 676 ;; a bit of jumping through hoops... 677 (unwinding-forms (p1-body (copy-tree (cddr form)))) 678 (unprotected-forms (p1-body (cddr form))) 676 677 ;; i believe this comment is misleading... 678 ;; - from an /opstack/ safety perspective, all forms (including cleanup) can have non-local returns 679 ;; original comment: (and unwinding-forms and unprotected-forms were above this line previously, meaning they 680 ;; did not fall under an unwind-protect /block/ and hence lead to stack inconsistency problems) 679 681 ;; ... because only the protected form is 680 682 ;; protected by the UNWIND-PROTECT block 681 683 (*blocks* (cons block *blocks*)) 684 685 ;; this may be ok to have /above/ the blocks decl, since these should not be present inside the 686 ;; exception handler and are therefore opstack safe 687 ;; my little test case passes either way (whether this is here or above) 688 ;; /but/ if the protected-form is marked as opstack unsafe, this should be too 689 ;; why is the protected form marked opstack unsafe? 690 (unwinding-forms (p1-body (copy-tree (cddr form)))) 691 692 ;; the unprotected-forms actually end up inside an exception handler and as such, /do/ need 693 ;; to be marked opstack unsafe (so this is now below the *blocks* decl) 694 ;; (this name is now misleading from an opstack safety perspective) 695 (unprotected-forms (p1-body (cddr form))) 696 682 697 (protected-form (p1 (cadr form)))) 683 698 (setf (unwind-protect-form block) -
trunk/abcl/src/org/armedbear/lisp/compiler-pass2.lisp
r15099 r15141 4243 4243 (fixnum-type-p type1) 4244 4244 (fixnum-type-p result-type)) 4245 (compile-form arg1 'stack :int)4246 4245 (cond ((plusp constant-shift) 4247 (compile-form arg2 'stack :int) 4248 (maybe-emit-clear-values arg1 arg2) 4246 (with-operand-accumulation 4247 ((compile-operand arg1 :int) 4248 (compile-operand arg2 :int) 4249 (maybe-emit-clear-values arg1 arg2))) 4249 4250 (emit 'ishl)) 4250 4251 ((minusp constant-shift) 4251 4252 (cond ((fixnump arg2) 4252 (emit-push-constant-int (- arg2))) 4253 (with-operand-accumulation 4254 ((compile-operand arg1 :int) 4255 (accumulate-operand (representation) 4256 (emit-push-constant-int (- arg2))) 4257 (maybe-emit-clear-values arg1)))) 4253 4258 (t 4254 (compile-form arg2 'stack :int) 4255 (emit 'ineg))) 4259 (with-operand-accumulation 4260 ((compile-operand arg1 :int) 4261 (accumulate-operand (representation :unsafe-p t) 4262 (compile-form arg2 'stack :int) 4263 (emit 'ineg)) 4264 (maybe-emit-clear-values arg1 arg2))))) 4256 4265 (maybe-emit-clear-values arg1 arg2) 4257 4266 (emit 'ishr)) 4258 4267 ((zerop constant-shift) 4268 (compile-form arg1 'stack :int) 4259 4269 (compile-form arg2 nil nil))) ; for effect 4260 4270 (convert-representation :int representation) … … 4265 4275 (java-long-type-p type1) 4266 4276 (java-long-type-p result-type)) 4267 (compile-form arg1 'stack :long)4268 4277 (cond ((plusp constant-shift) 4269 (compile-form arg2 'stack :int) 4270 (maybe-emit-clear-values arg1 arg2) 4278 (with-operand-accumulation 4279 ((compile-operand arg1 :long) 4280 (compile-operand arg2 :int) 4281 (maybe-emit-clear-values arg1 arg2))) 4271 4282 (emit 'lshl)) 4272 4283 ((minusp constant-shift) 4273 4284 (cond ((fixnump arg2) 4274 (emit-push-constant-int (- arg2))) 4285 (with-operand-accumulation 4286 ((compile-operand arg1 :long) 4287 (with-operand-accumulation (representation) 4288 (emit-push-constant-int (- arg2))) 4289 (maybe-emit-clear-values arg1)))) 4275 4290 (t 4276 (compile-form arg2 'stack :int) 4277 (emit 'ineg))) 4291 (with-operand-accumulation 4292 ((compile-operand arg1 :long) 4293 (accumulate-operand (representation :unsafe-p t) 4294 (compile-form arg2 'stack :int) 4295 (emit 'ineg)) 4296 (maybe-emit-clear-values arg1 arg2))))) 4278 4297 (maybe-emit-clear-values arg1 arg2) 4279 4298 (emit 'lshr)) 4280 4299 ((zerop constant-shift) 4300 (compile-form arg1 'stack :long) 4281 4301 (compile-form arg2 nil nil))) ; for effect 4282 4302 (convert-representation :long representation) … … 4294 4314 (java-long-type-p type1) 4295 4315 (java-long-type-p result-type)) 4296 (compile-forms-and-maybe-emit-clear-values arg1 'stack :long 4297 arg2 'stack :int) 4316 (with-operand-accumulation 4317 ((compile-operand arg1 :long) 4318 (compile-operand arg2 :int) 4319 (maybe-emit-clear-values arg1 arg2))) 4298 4320 (emit 'lshl) 4299 4321 (convert-representation :long representation)) … … 4301 4323 (java-long-type-p type1) 4302 4324 (java-long-type-p result-type)) 4303 (compile-forms-and-maybe-emit-clear-values arg1 'stack :long 4304 arg2 'stack :int) 4325 (with-operand-accumulation 4326 ((compile-operand arg1 :long) 4327 (compile-operand arg2 :int) 4328 (maybe-emit-clear-values arg1 arg2))) 4305 4329 (emit 'ineg) 4306 4330 (emit 'lshr) 4307 4331 (convert-representation :long representation)) 4308 4332 (t 4309 (compile-forms-and-maybe-emit-clear-values arg1 'stack nil 4310 arg2 'stack :int) 4333 (with-operand-accumulation 4334 ((compile-operand arg1 nil) 4335 (compile-operand arg2 :int) 4336 (maybe-emit-clear-values arg1 arg2))) 4311 4337 (emit-invokevirtual +lisp-object+ "ash" '(:int) +lisp-object+) 4312 4338 (fix-boxing representation result-type))) -
trunk/abcl/src/org/armedbear/lisp/jvm-instructions.lisp
r14903 r15141 503 503 (= (the fixnum (instruction-opcode (the instruction instruction))) 202))) 504 504 505 (defun constant-pool-index (instruction) 506 "If an instruction references an item in the constant pool, return 507 the index, otherwise return nil." 508 ;; 1 byte index 509 ;; 18 ldc 510 ;; 511 ;; 2 byte index 512 ;; 178 getstatic 513 ;; 179 putstatic 514 ;; 180 getfield 515 ;; 181 putfield 516 ;; 182 invokevirtual 517 ;; 183 invokespecial 518 ;; 184 invokestatic 519 ;; 185 invokeinterface 520 ;; 187 new 521 ;; 192 checkcast 522 ;; 193 instanceof 523 (when instruction 524 (case (instruction-opcode instruction) 525 (18 (first (instruction-args instruction))) 526 ((19 20 178 179 180 181 182 183 184 185 187 192 193) 527 (logior 528 (ash (first (instruction-args instruction)) 8) 529 (second (instruction-args instruction))))))) 530 505 531 (defun format-instruction-args (instruction pool) 506 (if (memql (instruction-opcode instruction) '(18 19 20 507 178 179 180 181 182 183 184 185 508 187 509 192 193)) 510 (let ((*print-readably* nil) 511 (*print-escape* nil)) 532 (let* ((*print-readably* nil) 533 (*print-escape* nil) 534 (pool-index (constant-pool-index instruction)) 535 (entry (when pool-index 536 (find-pool-entry pool pool-index)))) 537 (when entry 538 (return-from 539 format-instruction-args 512 540 (with-output-to-string (s) 513 541 (print-pool-constant pool 514 (find-pool-entry pool515 (car (instruction-args instruction)))s516 :package "org/armedbear/lisp"))) 517 518 (format nil "~S" (instruction-args instruction)))))542 entry 543 s 544 :package "org/armedbear/lisp"))))) 545 (when (instruction-args instruction) 546 (format nil "~S" (instruction-args instruction)))) 519 547 520 548 (defun print-code (code pool) … … 522 550 (dotimes (i (length code)) 523 551 (let ((instruction (elt code i))) 524 (format t "~3D ~A ~19T~A ~ A ~A~%"552 (format t "~3D ~A ~19T~A ~@[IStack: ~A~] ~@[IDepth: ~A~]~%" 525 553 i 526 554 (opcode-name (instruction-opcode instruction)) 527 555 (or (format-instruction-args instruction pool) "") 528 ( or (instruction-stack instruction) "")529 ( or (instruction-depth instruction) "")))))556 (instruction-stack instruction) 557 (instruction-depth instruction))))) 530 558 531 559 (defun print-code2 (code pool) … … 859 887 (defun analyze-stack (code exception-entry-points) 860 888 (declare (optimize speed)) 889 ;;(print-code code *pool*) 861 890 (let* ((code-length (length code))) 862 891 (declare (type vector code))
Note: See TracChangeset
for help on using the changeset viewer.