Skip to content

Commit

Permalink
unsigned long -> os_vm_size_t refactoring
Browse files Browse the repository at this point in the history
 Replace a number of GC related unsigned longs with os_vm_size_t, make it
 available in on the lisp-side as well, and use where appropriate.

 Makes BYTES-CONSED-BETWEEN-GCS and its SETF-version also support large
 nurseries.
  • Loading branch information
nikodemus committed Nov 19, 2011
1 parent 394b166 commit 3cd198e
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 23 deletions.
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ changes relative to sbcl-1.0.53:
systems with getaddrinfo().
** GET-HOST-BY-NAME and GET-HOST-BY-ADDRESS weren't thread or interrupt
safe outside systems with getaddrinfo().
* bug fix: on 64-bit systems setting the nursery size above 4Gb now works.
(lp#870868)

changes in sbcl-1.0.53 relative to sbcl-1.0.52:
* enhancement: on 64-bit targets, in src/compiler/generic/early-vm.lisp,
Expand Down
18 changes: 8 additions & 10 deletions src/code/gc.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
(declaim (inline dynamic-usage))
#!+gencgc
(defun dynamic-usage ()
(sb!alien:extern-alien "bytes_allocated" sb!alien:unsigned-long))
(sb!alien:extern-alien "bytes_allocated" os-vm-size-t))
#!-gencgc
(defun dynamic-usage ()
(the (unsigned-byte 32)
Expand Down Expand Up @@ -176,7 +176,7 @@ NIL as the pathname."
(native-pathname (cast val c-string)))))
(declaim (inline dynamic-space-size))
(defun dynamic-space-size ()
(sb!alien:extern-alien "dynamic_space_size" sb!alien:unsigned-long)))
(sb!alien:extern-alien "dynamic_space_size" os-vm-size-t)))

;;;; SUB-GC

Expand Down Expand Up @@ -340,13 +340,11 @@ NIL as the pathname."
#!+sb-doc
"The amount of memory that will be allocated before the next garbage
collection is initiated. This can be set with SETF."
(sb!alien:extern-alien "bytes_consed_between_gcs"
(sb!alien:unsigned 32)))
(sb!alien:extern-alien "bytes_consed_between_gcs" os-vm-size-t))

(defun (setf bytes-consed-between-gcs) (val)
(declare (type index val))
(setf (sb!alien:extern-alien "bytes_consed_between_gcs"
(sb!alien:unsigned 32))
(setf (sb!alien:extern-alien "bytes_consed_between_gcs" os-vm-size-t)
val))

(declaim (inline maybe-handle-pending-gc))
Expand Down Expand Up @@ -374,12 +372,12 @@ collection is initiated. This can be set with SETF."
(alloc-unboxed-start-page page-index-t)
(alloc-large-start-page page-index-t)
(alloc-large-unboxed-start-page page-index-t)
(bytes-allocated unsigned-long)
(gc-trigger unsigned-long)
(bytes-consed-between-gcs unsigned-long)
(bytes-allocated os-vm-size-t)
(gc-trigger os-vm-size-t)
(bytes-consed-between-gcs os-vm-size-t)
(number-of-gcs int)
(number-of-gcs-before-promotion int)
(cum-sum-bytes-allocated unsigned-long)
(cum-sum-bytes-allocated os-vm-size-t)
(minimum-age-before-gc double)))

#!+gencgc
Expand Down
3 changes: 1 addition & 2 deletions src/runtime/gc-common.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,7 @@ lispobj (*transother[256])(lispobj object);
long (*sizetab[256])(lispobj *where);
struct weak_pointer *weak_pointers;

unsigned long bytes_consed_between_gcs = 12*1024*1024;

os_vm_size_t bytes_consed_between_gcs = 12*1024*1024;

/*
* copying objects
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/gc.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@ extern void clear_auto_gc_trigger(void);

extern boolean maybe_gc(os_context_t *context);

extern unsigned long bytes_consed_between_gcs;
extern os_vm_size_t bytes_consed_between_gcs;

#endif /* _GC_H_ */
18 changes: 9 additions & 9 deletions src/runtime/gencgc.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ boolean gencgc_partial_pickup = 0;
*/

/* the total bytes allocated. These are seen by Lisp DYNAMIC-USAGE. */
unsigned long bytes_allocated = 0;
unsigned long auto_gc_trigger = 0;
os_vm_size_t bytes_allocated = 0;
os_vm_size_t auto_gc_trigger = 0;

/* the source and destination generations. These are set before a GC starts
* scavenging. */
Expand Down Expand Up @@ -285,13 +285,13 @@ struct generation {
page_index_t alloc_large_unboxed_start_page;

/* the bytes allocated to this generation */
unsigned long bytes_allocated;
os_vm_size_t bytes_allocated;

/* the number of bytes at which to trigger a GC */
unsigned long gc_trigger;
os_vm_size_t gc_trigger;

/* to calculate a new level for gc_trigger */
unsigned long bytes_consed_between_gc;
os_vm_size_t bytes_consed_between_gc;

/* the number of GCs since the last raise */
int num_gc;
Expand All @@ -305,7 +305,7 @@ struct generation {
* objects are added from a GC of a younger generation. Dividing by
* the bytes_allocated will give the average age of the memory in
* this generation since its last GC. */
unsigned long cum_sum_bytes_allocated;
os_vm_size_t cum_sum_bytes_allocated;

/* a minimum average memory age before a GC will occur helps
* prevent a GC when a large number of new live objects have been
Expand Down Expand Up @@ -507,7 +507,7 @@ write_generation_stats(FILE *file)
generations[i].num_gc,
generation_average_age(i));
}
fprintf(file," Total bytes allocated = %lu\n", bytes_allocated);
fprintf(file," Total bytes allocated = %lu\n", (unsigned long)bytes_allocated);
fprintf(file," Dynamic-space-size bytes = %lu\n", (unsigned long)dynamic_space_size);

fpu_restore(fpu_state);
Expand Down Expand Up @@ -3686,8 +3686,8 @@ garbage_collect_generation(generation_index_t generation, int raise)
/* As a check re-scavenge the newspace once; no new objects should
* be found. */
{
long old_bytes_allocated = bytes_allocated;
long bytes_allocated;
os_vm_size_t old_bytes_allocated = bytes_allocated;
os_vm_size_t bytes_allocated;

/* Start with a full scavenge. */
scavenge_newspace_generation_one_scan(new_space);
Expand Down
5 changes: 4 additions & 1 deletion tools-for-build/grovel-headers.c
Original file line number Diff line number Diff line change
Expand Up @@ -467,13 +467,16 @@ main(int argc, char *argv[])
printf("\n");
#endif

printf("(in-package \"SB!KERNEL\")\n\n");
#ifdef LISP_FEATURE_GENCGC
printf(";;; GENCGC related\n");
printf("(in-package \"SB!KERNEL\")\n");
DEFTYPE("page-index-t", page_index_t);
DEFTYPE("generation-index-t", generation_index_t);
printf("\n");
#endif

printf(";;; Our runtime types\n");
DEFTYPE("os-vm-size-t", os_vm_size_t);

return 0;
}

0 comments on commit 3cd198e

Please sign in to comment.