home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / pcl / src-16f.lha / compiler / rt / alloc.lisp < prev    next >
Encoding:
Text File  |  1991-11-06  |  4.9 KB  |  140 lines

  1. ;;; -*- Package: rt -*-
  2. ;;;
  3. ;;; **********************************************************************
  4. ;;; This code was written as part of the Spice Lisp project at
  5. ;;; Carnegie-Mellon University, and has been placed in the public domain.
  6. ;;; If you want to use this code or any part of Spice Lisp, please contact
  7. ;;; Scott Fahlman (FAHLMAN@CMUC). 
  8. ;;; **********************************************************************
  9. ;;;
  10. ;;; $Header: alloc.lisp,v 1.4 91/10/22 16:43:17 wlott Exp $
  11. ;;;
  12. ;;; Allocation VOPs for the IBM RT port.
  13. ;;;
  14. ;;; Written by William Lott.
  15. ;;; Converted by Bill Chiles.
  16. ;;;
  17.  
  18. (in-package "RT")
  19.  
  20.  
  21.  
  22. ;;;; LIST and LIST*
  23.  
  24. (define-vop (list-or-list*)
  25.   (:args (things :more t))
  26.   (:temporary (:scs (descriptor-reg) :type list) ptr)
  27.   (:temporary (:scs (descriptor-reg)) temp)
  28.   (:temporary (:scs (descriptor-reg) :type list :to (:result 0) :target result)
  29.           res)
  30.   (:temporary (:scs (non-descriptor-reg) :type random) ndescr)
  31.   (:temporary (:scs (word-pointer-reg)) alloc)
  32.   (:info num)
  33.   (:results (result :scs (descriptor-reg)))
  34.   (:variant-vars star)
  35.   (:policy :safe)
  36.   (:generator 0
  37.     (cond ((zerop num)
  38.        (move result null-tn))
  39.       ((and star (= num 1))
  40.        (move result (tn-ref-tn things)))
  41.       (t
  42.        (macrolet
  43.            ((store-car (tn list &optional (slot cons-car-slot))
  44.           `(let ((reg
  45.               (sc-case ,tn
  46.                 ((any-reg descriptor-reg) ,tn)
  47.                 (null null-tn)
  48.                 (control-stack
  49.                  (load-stack-tn temp ,tn)
  50.                  temp))))
  51.              (storew reg ,list ,slot list-pointer-type))))
  52.          (let ((cons-cells (if star (1- num) num)))
  53.            (pseudo-atomic (ndescr)
  54.          (load-symbol-value alloc *allocation-pointer*)
  55.          (inst cal res alloc list-pointer-type)
  56.          (inst cal alloc alloc (* (pad-data-block cons-size)
  57.                       cons-cells))
  58.          (store-symbol-value alloc *allocation-pointer*)
  59.          (move ptr res)
  60.          (dotimes (i (1- cons-cells))
  61.            (store-car (tn-ref-tn things) ptr)
  62.            (setf things (tn-ref-across things))
  63.            (inst cal ptr ptr (pad-data-block cons-size))
  64.            (storew ptr ptr
  65.                (- cons-cdr-slot cons-size)
  66.                list-pointer-type))
  67.          (store-car (tn-ref-tn things) ptr)
  68.          (cond (star
  69.             (setf things (tn-ref-across things))
  70.             (store-car (tn-ref-tn things) ptr cons-cdr-slot))
  71.                (t
  72.             (storew null-tn ptr
  73.                 cons-cdr-slot list-pointer-type)))
  74.          (assert (null (tn-ref-across things)))
  75.          (move result res))
  76.            (load-symbol-value ndescr *internal-gc-trigger*)
  77.            (inst tlt ndescr alloc)))))))
  78.  
  79. (define-vop (list list-or-list*)
  80.   (:variant nil))
  81.  
  82. (define-vop (list* list-or-list*)
  83.   (:variant t))
  84.  
  85.  
  86.  
  87. ;;;; Special purpose inline allocators.
  88.  
  89. (define-vop (allocate-code-object)
  90.   (:args (boxed-arg :scs (any-reg))
  91.      (unboxed-arg :scs (any-reg) :target unboxed))
  92.   (:results (result :scs (descriptor-reg)))
  93.   (:temporary (:scs (non-descriptor-reg)) ndescr)
  94.   (:temporary (:scs (word-pointer-reg)) alloc)
  95.   (:temporary (:scs (any-reg) :from (:argument 0)) boxed)
  96.   (:temporary (:scs (non-descriptor-reg) :from (:argument 1)) unboxed)
  97.   (:generator 100
  98.     (inst li ndescr (lognot lowtag-mask))
  99.     (inst cal boxed boxed-arg (fixnum (1+ vm:code-trace-table-offset-slot)))
  100.     (inst n boxed ndescr)
  101.     (move unboxed unboxed-arg)
  102.     (inst sr unboxed word-shift)
  103.     (inst a unboxed lowtag-mask)
  104.     (inst n unboxed ndescr)
  105.     (pseudo-atomic (ndescr)
  106.       (load-symbol-value alloc *allocation-pointer*)
  107.       (inst cal result alloc other-pointer-type)
  108.       (inst cas alloc boxed alloc)
  109.       (inst cas alloc unboxed alloc)
  110.       (store-symbol-value alloc *allocation-pointer*)
  111.       (move ndescr boxed)
  112.       (inst sl ndescr (- type-bits word-shift))
  113.       (inst oil ndescr code-header-type)
  114.       (storew ndescr result 0 other-pointer-type)
  115.       (storew unboxed result code-code-size-slot other-pointer-type)
  116.       (storew null-tn result code-entry-points-slot other-pointer-type)
  117.       (storew null-tn result code-debug-info-slot other-pointer-type))
  118.     (load-symbol-value ndescr *internal-gc-trigger*)
  119.     (inst tlt ndescr alloc)))
  120.  
  121. (define-vop (make-symbol)
  122.   (:args (name :scs (descriptor-reg) :to :eval))
  123.   (:temporary (:scs (sap-reg)) temp)
  124.   (:temporary (:scs (word-pointer-reg)) alloc)
  125.   (:results (result :scs (descriptor-reg) :from :argument))
  126.   (:policy :fast-safe)
  127.   (:translate make-symbol)
  128.   (:generator 37
  129.     (with-fixed-allocation (result temp alloc symbol-header-type symbol-size)
  130.       (inst li temp unbound-marker-type)
  131.       (storew temp result symbol-value-slot other-pointer-type)
  132.       (storew temp result symbol-function-slot other-pointer-type)
  133.       (storew temp result symbol-setf-function-slot other-pointer-type)
  134.       (inst cai temp (make-fixup "undefined_tramp" :foreign))
  135.       (storew temp result symbol-raw-function-addr-slot
  136.           other-pointer-type)
  137.       (storew null-tn result symbol-plist-slot other-pointer-type)
  138.       (storew name result symbol-name-slot other-pointer-type)
  139.       (storew null-tn result symbol-package-slot other-pointer-type))))
  140.