Changeset 9928


Ignore:
Timestamp:
Jul 7, 2008, 9:02:53 PM (11 years ago)
Author:
gz
Message:

r8227-r8230 from trunk (static cons support)

Location:
branches/working-0711/ccl
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/working-0711/ccl/level-0/PPC/ppc-misc.lisp

    r7624 r9928  
    980980  (li arg_z t)
    981981  (blr))
     982
     983(defppclapfunction %atomic-pop-static-cons ()
     984  (li imm0 (+ target::nil-value (target::kernel-global static-conses)))
     985  @again
     986  (lrarx arg_z rzero imm0)
     987  (cmpri arg_z target::nil-value)
     988  (be @lose)
     989  (%cdr arg_z arg_y)
     990  (strcx. arg_y rzero imm0)
     991  (bne @again)
     992  @lose
     993  (blr))
    982994 
    983995
  • branches/working-0711/ccl/level-0/X86/x86-misc.lisp

    r9578 r9928  
    814814 
    815815
     816(defx86lapfunction %atomic-pop-static-cons ()
     817  @again
     818  (movq (@ (+ x8664::nil-value (x8664::kernel-global static-conses))) (% rax))
     819  (testq ($ x8664::nil-value) (% rax))
     820  (jz @lose)
     821  (%cdr rax temp0)
     822  (lock)
     823  (cmpxchgq (% temp0) (@ (+ x8664::nil-value (x8664::kernel-global static-conses))))
     824  (jnz @again)
     825  @lose
     826  (movq (% rax) (% arg_z))
     827  (single-value-return))
    816828 
    817829
  • branches/working-0711/ccl/lib/ccl-export-syms.lisp

    r9855 r9928  
    401401     *fasl-save-doc-strings*
    402402     *fasl-save-definitions*
     403     *static-cons-chunk*
     404     static-cons
    403405
    404406     compiler-let
  • branches/working-0711/ccl/lib/misc.lisp

    r9152 r9928  
    847847        (format out "~&~a~36t~12d~48t~16d" (aref *heap-utilization-vector-type-names* i)  count sizes)))))
    848848                           
    849 
    850 
     849;; The number of words to allocate for static conses when the user requests
     850;; one and we don't have any left over
     851(defparameter *static-cons-chunk* 1048576)
     852
     853(defun initialize-static-cons ()
     854  "Activates collection of garbage conses in the static-conses
     855   list and allocates initial static conses."
     856  ; There might be a race here when multiple threads call this
     857  ; function.  However, the discarded static conses will become
     858  ; garbage and be added right back to the list.  No harm here
     859  ; except for additional garbage collections.
     860  (%set-kernel-global 'static-conses nil)
     861  (allocate-static-conses))
     862
     863(defun allocate-static-conses ()
     864  "Allocates some memory, freezes it and lets it become garbage.
     865   This will add the memory to the list of free static conses."
     866  (let ((l (make-array *static-cons-chunk*)))
     867    (declare (ignore l))
     868    (freeze))
     869  (gc))
     870
     871(defun static-cons (car-value cdr-value)
     872  "Allocates a cons cell that doesn't move on garbage collection,
     873   and thus doesn't trigger re-hashing when used as a key in a hash
     874   table.  Usage is equivalent to regular CONS."
     875  (when (eq (%get-kernel-global 'static-conses) 0)
     876    (initialize-static-cons))
     877  (let ((cell (%atomic-pop-static-cons)))
     878    (if cell
     879      (progn
     880        (setf (car cell) car-value)
     881        (setf (cdr cell) cdr-value)
     882        cell)
     883      (progn
     884        (allocate-static-conses)
     885        (static-cons car-value cdr-value)))))
     886       
     887
Note: See TracChangeset for help on using the changeset viewer.