;;; MAP-ALLOCATED-OBJECTS
#!+gencgc
(progn
- (define-alien-type nil
+ (define-alien-type (struct page)
(struct page
- (flags unsigned-int)
- (gen int)
- (bytes-used int)
- (start long)))
+ (start long)
+ (bytes-used (unsigned 16))
+ (flags (unsigned 8))
+ (gen (signed 8))))
(declaim (inline find-page-index))
(define-alien-routine "find_page_index" long (index long))
(define-alien-variable "page_table"
;; bitfields?
(let ((alloc-flag (ldb (byte 3 2)
(slot page 'flags)))
- (bytes-used (slot page 'bytes-used)))
+ (bytes-used (slot page 'bytes-used)))
;; If the page is not free and the current
;; pointer is still below the allocation offset
;; of the page
#ifndef _GC_H_
#define _GC_H_
typedef signed long page_index_t;
-typedef signed int generation_index_t;
+typedef signed char generation_index_t;
extern void gc_init(void);
extern void gc_initialize_pointers(void);
int gencgc_handle_wp_violation(void *);
\f
struct page {
+ /* The name of this field is not well-chosen for its actual use.
+ * This is the offset from the start of the page to the start
+ * of the alloc_region which contains/contained it. It's negative or 0
+ */
+ long first_object_offset;
+
+ /* the number of bytes of this page that are used. This may be less
+ * than the actual bytes used for pages within the current
+ * allocation regions. It should be 0 for all unallocated pages (not
+ * hard to achieve).
+ *
+ * Currently declared as an unsigned short to make the struct size
+ * smaller. This means that GENCGC-PAGE-SIZE is constrained to fit
+ * inside a short.
+ */
+ unsigned short bytes_used;
+
+#if USHRT_MAX < PAGE_BYTES
+#error "PAGE_BYTES too large"
+#endif
- unsigned int
+ unsigned
/* This is set when the page is write-protected. This should
* always reflect the actual write_protect status of a page.
* (If the page is written into, we catch the exception, make
* allocation region pages - this allows the space of an object to
* be easily determined. */
generation_index_t gen;
-
- /* the number of bytes of this page that are used. This may be less
- * than the actual bytes used for pages within the current
- * allocation regions. It should be 0 for all unallocated pages (not
- * hard to achieve). */
- int bytes_used;
-
- /* The name of this field is not well-chosen for its actual use.
- * This is the offset from the start of the page to the start
- * of the alloc_region which contains/contained it. It's negative or 0
- */
- long first_object_offset;
};
+
/* values for the page.allocated field */
\f