Common Lisp Package: COM.INFORMATIMAGO.COMMON-LISP.HEAP.HEAP

This package implements a heap for 'common' data in shared memory segments. There is a garbage collector, and lisp data types. See also: COM.INFORMATIMAGO.COMMON-LISP.HEAP.MEMORY License: AGPL3 Copyright Pascal J. Bourguignon 2004 - 2012 This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/>

README:

FUNCTION

Public

COMMON-INITIALIZE (MEMORY)

DOES: Initialize the memory instance as a shared heap. MEMORY: A subclass of COM.INFORMATIMAGO.COMMON-LISP.HEAP.MEMORY:MEMORY. NOTE: MEMORY objects are byte-addressed, however the various sized operations are only called on naturally aligned addresses: a peek-uint64 will be called only with addresses multiple of 8. (However, this heap usually addresses 64-bit words, gc-store and gc-load convert the heap addresses into the memory byte addresses, and cvm-svoperate does similarly, but may address 8-bit, 16-bit, 32-bit or 64-bit words depending on the size of the data types).

GET-COMMON (SYMBOL)

DOES: Copies the value of the common variable from the common heap to the lisp heap and return this lisp value. SYMBOL: The name of the common variable. It'll be a symbol macro.

SET-COMMON (SYMBOL VALUE)

DOES: Copies the given lisp VALUE into the common variable in the common heap. Return this lisp value. SYMBOL: The name of the common variable. It'll be a symbol macro. VALUE: The lisp value to be copied into the common heap and bound to the common variable.

Private

BITS-TO-WORDS (BITS)

64 bit/word

CELL-TYPE-LABEL (VALUE)

Produce the name of the constant having the given VALUE.

CFI-MAKE-SYMBOL (SYM)

SYM: The ct-address of a cvm symbol RETURN: An interned lisp symbol whose plist, value and function are updated with copies of those of SYM.

CVM-SVOPERATE (GC-ADDRESS INDEX OPERATION &OPTIONAL VALUE)

DO: Perform a peek or a poke of the slot at INDEX in the array or structure at the GC-ADDRESS. GC-ADDRESS: A heap address (addressing 64-bit words), which is the base of the array or structure. INDEX: An index into te slots of the array or structure. The element size is taken from the gc-address element-type field. OPERATION: (member :peek :poke) indicates the operation to execute. VALUE: When OPERATION is :poke then the value to be stored. RETURN: When OPERATION is :peek, the value of the slot.

GC-CHECK-FREE-BLOCK-LIST (FBLN FBL &KEY (STREAM *STANDARD-OUTPUT*) (DUMP-FREE NIL) (BITMAP NIL))

RETURN: the number of blocs, the total size of blocks. RAISE: simple-error conditions when an invariant is invalidated.

GC-INITIALIZE (MEMORY)

DO: Initialize the heap in *gc-memory*.

UPDATE-COMMON-VARIABLES

DOES: Defines a symbol-macro for the common variables available in the common heap that don't have beed defined in this process.

Undocumented

CFI-COPY-FROM-COMMON (CVM-VALUE &KEY TYPECODE)

CFI-COPY-TREE (LTREE)

CFI-SYMBOL-COPY-FROM-COMMON (LISP-SYMBOL CVM-SYMBOL)

CVM-ADDRESS-P (OBJECT)

CVM-ARRAY-P (ADDRESS)

CVM-BIT-P (OBJECT)

CVM-BIT-SIZE-OF-UNBOXED-TYPE (TYPECODE)

CVM-BIT-VALUE (OBJECT)

CVM-CAR (CONS)

CVM-CDR (CONS)

CVM-CHARACTER-CODE (OBJECT)

CVM-CHARACTER-P (OBJECT)

CVM-CONS-P (CONS)

CVM-DEREF (OBJECT)

CVM-ELEMENT-TYPE (ADDRESS)

CVM-EQ (OBJ1 OBJ2)

CVM-FILL-POINTER (ADDRESS)

CVM-FIXNUM-P (OBJECT)

CVM-FIXNUM-VALUE (OBJECT)

CVM-FORM-ADDRESS (ADDRESS)

CVM-FORM-BIT (BIT)

CVM-FORM-CHARACTER (CODE)

CVM-FORM-FIXNUM (VALUE)

CVM-FORM-FREE-BLOCK (SIZE NEXT)

CVM-FORM-HEAD (TYPE SIZE)

CVM-FORM-READABLE (ADDRESS)

CVM-FORM-SINGLE-FLOAT (VALUE)

CVM-FREE-BLOCK-NEXT (OBJECT)

CVM-FREE-BLOCK-P (OBJECT)

CVM-FREE-BLOCK-SET-NEXT (ADDRESS NEW-NEXT)

CVM-FREE-BLOCK-SET-SIZE (ADDRESS NEW-SIZE)

CVM-FREE-BLOCK-SIZE (OBJECT)

CVM-HH-FREE-BLOCKS (SELF)

CVM-HH-NEW-GENERATION (SELF)

CVM-HH-P (SELF)

CVM-HH-RESERVED (SELF)

CVM-HH-ROOT (SELF)

CVM-HH-SET-FREE-BLOCKS (SELF VALUE)

CVM-HH-SET-NEW-GENERATION (SELF VALUE)

CVM-HH-SET-RESERVED (SELF VALUE)

CVM-HH-SET-ROOT (SELF VALUE)

CVM-HH-SET-SIZE (SELF VALUE)

CVM-HH-SIZE (SELF)

CVM-INITIALIZE-VECTOR (ADDRESS CELL-TYPE ELEMENT-TYPE DIMENSION &KEY FILL-POINTER CLASS)

CVM-LENGTH (ADDRESS)

CVM-LIST-ALL-PACKAGES

CVM-LIST-DELETE-EQ (LIST ITEM)

CVM-LIST-ELT (LIST INDEX)

CVM-LIST-LENGTH (LIST)

CVM-LIST-NREVERSE (LIST)

CVM-MAKE-CONS (CAR-OBJECT CDR-OBJECT)

CVM-MAKE-LIST (&KEY LENGTH INITIAL-ELEMENT INITIAL-CONTENTS)

CVM-MAKE-PACKAGE (NAME &KEY (NICKNAMES +CVM-NIL+) (USES +CVM-NIL+))

CVM-MAKE-STRING (&KEY CONTENTS TYPE LENGTH FILL-POINTER)

CVM-MAKE-STRUCTURE (CLASS NBFIELDS)

CVM-MAKE-SYMBOL (NAME PACKAGE &KEY (VALUE +CVM-UNBOUND+) #'+CVM-UNBOUND+ (PLIST +CVM-NIL+))

CVM-MAKE-VECTOR (ELEMENT-TYPE DIMENSION)

CVM-MAKE-VECTOR-FP (ELEMENT-TYPE DIMENSION &KEY (FILL-POINTER +CVM-NIL+))

CVM-MEMBER-EQ (ITEM LIST)

CVM-NULL (OBJECT)

CVM-PACKAGE-EXTERNALS (SELF)

CVM-PACKAGE-NAME (SELF)

CVM-PACKAGE-NICKNAMES (SELF)

CVM-PACKAGE-P (SELF)

CVM-PACKAGE-SET-EXTERNALS (SELF VALUE)

CVM-PACKAGE-SET-NAME (SELF VALUE)

CVM-PACKAGE-SET-NICKNAMES (SELF VALUE)

CVM-PACKAGE-SET-SYMBOLS (SELF VALUE)

CVM-PACKAGE-SET-USES (SELF VALUE)

CVM-PACKAGE-SYMBOLS (SELF)

CVM-PACKAGE-USES (SELF)

CVM-READABLE-P (OBJECT)

CVM-ROWS (ADDRESS)

CVM-SET-FILL-POINTER (ADDRESS FILL-POINTER)

CVM-SETCAR (CONS VALUE)

CVM-SETCDR (CONS VALUE)

CVM-SINGLE-FLOAT-P (OBJECT)

CVM-SINGLE-FLOAT-VALUE (OBJECT)

CVM-SIZE-OF (OBJECT)

CVM-STRING-P (ADDRESS)

CVM-STRING-VALUE (ADDRESS)

CVM-STRING= (STRA STRB)

CVM-STRUCTURE-P (ADDRESS)

CVM-STRUCTURE-REF (ADDRESS INDEX)

CVM-STRUCTURE-STORE (ADDRESS INDEX VALUE)

CVM-SVREF (ADDRESS INDEX)

CVM-SVSET (ADDRESS INDEX VALUE)

CVM-SYMBOL-BOUND-P (SYM)

CVM-SYMBOL-FBOUND-P (SYM)

CVM-SYMBOL-FMAKUNBOUND (SYM)

CVM-SYMBOL-FUNCTION (SELF)

CVM-SYMBOL-MAKUNBOUND (SYM)

CVM-SYMBOL-NAME (SELF)

CVM-SYMBOL-P (SELF)

CVM-SYMBOL-PACKAGE (SELF)

CVM-SYMBOL-PLIST (SELF)

CVM-SYMBOL-SET-FUNCTION (SELF VALUE)

CVM-SYMBOL-SET-NAME (SELF VALUE)

CVM-SYMBOL-SET-PACKAGE (SELF VALUE)

CVM-SYMBOL-SET-PLIST (SELF VALUE)

CVM-SYMBOL-SET-VALUE (SELF VALUE)

CVM-SYMBOL-VALUE (SELF)

CVM-TYPE-CODE (OBJECT)

CVM-TYPE-OF (OBJECT)

CVM-UNBOUND-P (OBJECT)

CVM-VECTOR-FP-P (ADDRESS)

CVM-VECTOR-P (ADDRESS)

CVM-VECTOR-POP (VECTOR)

CVM-VECTOR-PUSH (NEW-ELEMENT VECTOR)

FB-EXTRACT (FREE-BLOCKS PREVIOUS OLD-BLOCK SIZE)

FB-INSERT (FREE-BLOCKS NEW-BLOCK)

FB-SEARCH-BIG-BLOCK (FREE-LIST SIZE)

FLOAT-32-TO-IEEE-754 (FLOAT)

FLOAT-64-TO-IEEE-754 (FLOAT)

GC-ALLOCATE (SIZE)

GC-ALLOCATE-INTERNAL (SIZE)

GC-BITMAP-ALLOCATED-P (BITMAP ADDRESS)

GC-BITMAP-CLEAR-P (BITMAP ADDRESS)

GC-BITMAP-FREE-P (BITMAP ADDRESS)

GC-BITMAP-SET-ALLOCATED (BITMAP ADDRESS)

GC-BITMAP-SET-ALLOCATED-RANGE (BITMAP ADDRESS SIZE)

GC-BITMAP-SET-FREE (BITMAP ADDRESS)

GC-BITMAP-SET-VISITED (BITMAP ADDRESS)

GC-BITMAP-SET-VISITED-RANGE (BITMAP ADDRESS SIZE)

GC-BITMAP-VISITED-P (BITMAP ADDRESS)

GC-CHECK (&KEY (STREAM *STANDARD-OUTPUT*) (ALLOW-FREE-BLOCKS NIL) (DUMP-ALL NIL) (DUMP-BITMAP NIL) (DUMP-HEADER NIL) (DUMP-FREE NIL) (DUMP-ALLOCATED NIL) (DUMP-DATA NIL))

GC-CHECK-INTERNAL (&KEY (STREAM *STANDARD-OUTPUT*) (ALLOW-FREE-BLOCKS NIL) (DUMP-ALL NIL) (DUMP-BITMAP NIL) (DUMP-HEADER NIL) (DUMP-FREE NIL) (DUMP-ALLOCATED NIL) (DUMP-DATA NIL))

GC-CHECK-TREE (ROOT-ADDRESS &KEY (STREAM *STANDARD-OUTPUT*) (ALLOW-FREE-BLOCKS NIL) (BITMAP NIL) (DUMP-ALLOCATED NIL) (DUMP-DATA NIL))

GC-CLEAR-MARK (OBJECT)

GC-COLLECT-GARBAGE

GC-COLLECT-INTERNAL

GC-DELETE-FROM-ROOT (ITEM)

GC-DUMP-BLOCK (GC-ADDRESS SIZE STREAM &KEY (MARGIN ))

GC-DUMP-CELL (ADDRESS &KEY (STREAM *STANDARD-OUTPUT*) (CONTENTS T) (MARGIN ))

GC-DUMP-OBJECT (OBJECT &KEY (STREAM *STANDARD-OUTPUT*) (COMMENT ) (ADDRESS NIL))

GC-DUMP-ROOT (&KEY (STREAM *STANDARD-OUTPUT*))

GC-INITIALIZED-P

GC-LOAD (GC-ADDRESS)

GC-MAKE-BITMAP

GC-MARK (ADDRESS)

GC-MARKED (OBJECT)

GC-PEEK-FUNCTION (BIT-SIZE)

GC-POKE-FUNCTION (BIT-SIZE)

GC-PUSH-ROOT (SYM)

GC-RESET-GENERATION

GC-SET-MARK (OBJECT)

GC-SIGN (SIGNATURE)

GC-SIGNATURE

GC-STORE (GC-ADDRESS OBJECT)

GC-SWEEP

GEN-WITH-GENERATION (BINDINGS BODY)

IEEE-754-TO-FLOAT-32 (IEEE)

IEEE-754-TO-FLOAT-64 (IEEE)

LD-GET (VALUE)

LD-LCACHE (L-VALUE)

LD-PUT (VALUE CVM-VALUE)

TEST-DOUBLE-TO-IEEE (&REST ARGS)

TEST-IEEE-READ-DOUBLE

TEST-IEEE-READ-SINGLE

TEST-SINGLE-TO-IEEE (&REST ARGS)

MACRO

Public

DEFCOMMON (SYMBOL &OPTIONAL VALUE DOCSTRING)

DOES: Defines a common variable, ie. a variable whose value is stored in the common heap. Everytime the variable is read, the value is copied from the common heap into the lisp heap, and vice-versa everytime it's written. SYMBOL: The name of the common variable. It'll be a symbol macro. VALUE: The initial value copied to the common variable. DOCSTRING: A variable documentation string attached to the SYMBOL. NOTE: A common variable named *COMMON-VARIABLES* contains a list of all common variables names (symbols). NOTE: Copying is done taking into account circles. The copying for the following object types is implemented: (signed-byte 56) single-float nil cons character string symbol ; only the package and name package ; only the name. keeps the list of common variables ; in the package.

WITH-COMMON-LOCK (&BODY BODY)

Execute the BODY with the *GC-MEMORY* locked with the WITH-MEMORY macro.

Private

DEFENUM (NAME-AND-OPTIONS &REST CONSTANTS)

Define an named enumeration type, a set of constants with integer values, and a lable function to produce the name of the constants from the numerical value.

WSIOSBP (&BODY BODY)

Like with-standard-io-syntax but with the current package. The *PACKAGE* is kept bound to the current package.

Undocumented

%AND (&REST CONJONCTIONS)

CVM-DEFINE-STRUCTURE (NAME TYPE &REST FIELDS)

CVM-DO-SYMBOLS ((VSYM PACKAGE) &BODY BODY)

CVM-DOLIST ((VAR LIST &OPTIONAL (RESULT NIL)) &BODY BODY)

CVM-POP (LIST)

CVM-PUSH (ITEM LIST)

GEN-IEEE-ENCODING (NAME TYPE EXPONENT-BITS MANTISSA-BITS)

UNLESS-DEBUG (WHAT &BODY BODY)

WHEN-DEBUG (WHAT &BODY BODY)

WITH-GC-LOCK (&BODY BODY)

WITH-GENERATION (BINDINGS &BODY BODY)

WITH-LOOP-DETECTION (&BODY BODY)

GENERIC-FUNCTION

Private

Undocumented

CFI-COPY-TO-COMMON (VALUE)

CVM-DELETE-PACKAGE (PACKAGE)

CVM-FIND-PACKAGE (NAME)

CVM-FIND-SYMBOL (NAME PACKAGE)

CVM-INTERN (NAME PACKAGE)

VARIABLE

Private

*CHECK-ARGS*

See the keyword arguments of gc-check

+COMPLEX-ELEMENT-TYPES+

array element types that are 'boxed'.

+REFERENCED-CELL-TYPES+

Cell types that can be referenced by a ct-address or ct-readable.

Undocumented

*DEBUG*

*DEFINED-COMMON-VARIABLES*

*GC-HEAP-BASE*

*GC-HEAP-SIZE*

*GC-MEMORY*

*GC-PACKAGE*

*GC-SYMBOL*

*LD-VALUES*

+ADDRESS-CELL-TYPES+

+BYTE-32+

+BYTE-56+

+CHARACTER-TYPES+

+EX-CONS+

+EX-MARK+

+FB-NEXT+

+FB-SIZE+

+IN-CONS+

+IN-MARK+

+SIMPLE-TYPES+

+TYPE-CODE+

CONSTANT

Private

+DEBUG+

Possible items: :*debug* check *DEBUG* at run-time. :range check gc-address range. :check check heap invariants. :ng trace the new-generation stack. :ld trace circle detection (calls to ld-put and ld-get). :objects trace object allocations. :gc debugging garbage collector. :allocate debugging allocator. :gcct debugging checking code. :bitmap debugging debugging code. :emulated-shared-memory Don't use shm, use a lisp vector for common memory. (Use it only in +DEBUG+, not in *DEBUG*).

+FB-BIG+

Index of big-block free-list (this is the max index for free-blocks).

+NG-SIZE+

Size of the new generation vector (max index = 30)

CT-ADDRESS

CELL-TYPE enumeration value.

CT-ARRAY

CELL-TYPE enumeration value.

CT-BIT

CELL-TYPE enumeration value.

CT-CHARACTER-16

CELL-TYPE enumeration value.

CT-CHARACTER-24

CELL-TYPE enumeration value.

CT-CHARACTER-32

CELL-TYPE enumeration value.

CT-CHARACTER-8

CELL-TYPE enumeration value.

CT-FLOAT-16

CELL-TYPE enumeration value.

CT-FLOAT-24

CELL-TYPE enumeration value.

CT-FLOAT-32

CELL-TYPE enumeration value.

CT-FLOAT-40

CELL-TYPE enumeration value.

CT-FLOAT-48

CELL-TYPE enumeration value.

CT-FLOAT-56

CELL-TYPE enumeration value.

CT-FLOAT-64

CELL-TYPE enumeration value.

CT-FLOAT-8

CELL-TYPE enumeration value.

CT-FREE-BLOCK

CELL-TYPE enumeration value.

CT-NIL

CELL-TYPE enumeration value.

CT-READABLE

CELL-TYPE enumeration value.

CT-SIGNED-BYTE-16

CELL-TYPE enumeration value.

CT-SIGNED-BYTE-24

CELL-TYPE enumeration value.

CT-SIGNED-BYTE-32

CELL-TYPE enumeration value.

CT-SIGNED-BYTE-40

CELL-TYPE enumeration value.

CT-SIGNED-BYTE-48

CELL-TYPE enumeration value.

CT-SIGNED-BYTE-56

CELL-TYPE enumeration value.

CT-SIGNED-BYTE-64

CELL-TYPE enumeration value.

CT-SIGNED-BYTE-8

CELL-TYPE enumeration value.

CT-STRUCTURE

CELL-TYPE enumeration value.

CT-T

CELL-TYPE enumeration value.

CT-UNBOUND

CELL-TYPE enumeration value.

CT-UNSIGNED-BYTE-16

CELL-TYPE enumeration value.

CT-UNSIGNED-BYTE-24

CELL-TYPE enumeration value.

CT-UNSIGNED-BYTE-32

CELL-TYPE enumeration value.

CT-UNSIGNED-BYTE-40

CELL-TYPE enumeration value.

CT-UNSIGNED-BYTE-48

CELL-TYPE enumeration value.

CT-UNSIGNED-BYTE-56

CELL-TYPE enumeration value.

CT-UNSIGNED-BYTE-64

CELL-TYPE enumeration value.

CT-UNSIGNED-BYTE-8

CELL-TYPE enumeration value.

CT-VECTOR

CELL-TYPE enumeration value.

CT-VECTOR-FP

CELL-TYPE enumeration value.

Undocumented

+CVM-NIL+

+CVM-T+

+CVM-UNBOUND+

+GC-EXPECTED-FREE-BLOCK+

+GC-HEAP-HEADER+

+GC-START+

+HH-FREE-BLOCKS+

+HH-NEW-GENERATION+

+HH-RESERVED+

+HH-ROOT+

+HH-SIZE+

+PACKAGE-EXTERNALS+

+PACKAGE-NAME+

+PACKAGE-NICKNAMES+

+PACKAGE-SYMBOLS+

+PACKAGE-USES+

+SYMBOL-FUNCTION+

+SYMBOL-NAME+

+SYMBOL-PACKAGE+

+SYMBOL-PLIST+

+SYMBOL-VALUE+

CT-CONS

CT-MARK