Raymond Toy pushed to branch issue-69-compile-in-gc-assert at cmucl / cmucl

Commits:

2 changed files:

Changes:

  • src/code/gc.lisp
    ... ... @@ -72,14 +72,39 @@
    72 72
     (progn
    
    73 73
       (alien:def-alien-routine get_bytes_allocated_lower c-call:int)
    
    74 74
       (alien:def-alien-routine get_bytes_allocated_upper c-call:int)
    
    75
    -  ;; Controls GC assertions that are enabled in the runtime.  A value
    
    76
    -  ;; of 0 disables all assertions (the normal default).
    
    77
    -  (alien:def-alien-variable gc_assert_level c-call:int)
    
    78
    -  (setf (documentation 'gc-assert-level 'variable)
    
    79
    -	"Current GC assertion level.  Higher values enable more GC assertions")
    
    80 75
       (defun dynamic-usage ()
    
    81 76
         (dfixnum:dfixnum-pair-integer
    
    82
    -     (get_bytes_allocated_upper) (get_bytes_allocated_lower))))
    
    77
    +     (get_bytes_allocated_upper) (get_bytes_allocated_lower)))
    
    78
    +
    
    79
    +  ;; Controls GC assertions that are enabled in the runtime.  A value
    
    80
    +  ;; of 0 disables all assertions (the normal default).
    
    81
    +  (alien:def-alien-variable ("gc_assert_level" gc-assert-level) c-call:int)
    
    82
    +  (alien:def-alien-variable ("verify_after_free_heap" gc-verify-after-free-heap) c-call:int)
    
    83
    +  (alien:def-alien-variable ("pre_verify_gen_0" gc-verify-new-objects) c-call:int)
    
    84
    +  (alien:def-alien-variable ("verify_gens" gc-verify-generations) c-call:int)
    
    85
    +  (defun get-gc-assertions ()
    
    86
    +    (list :assert-level gc-assert-level
    
    87
    +	  :verify-after-free-heap (not (zerop gc-verify-after-free-heap))
    
    88
    +	  :verify-generations gc-verify-generations
    
    89
    +	  :verify-new-objects (not (zerop gc-verify-new-objects))))
    
    90
    +  (defun set-gc-assertions (&key (assert-level 0 assert-level-p)
    
    91
    +			      (verify-after-free-heap nil verify-after-free-heap-p)
    
    92
    +			      (verify-generations 6 verify-generations-p)
    
    93
    +			      (verify-new-objects nil verify-new-objects-p))
    
    94
    +    (declare (type (and fixnum unsigned-byte) assert-level)
    
    95
    +	     (type boolean verify-after-free-heap)
    
    96
    +	     (type (integer 0 6) verify-generation)
    
    97
    +	     (type boolean verify-new-objects))
    
    98
    +    (when assert-level-p
    
    99
    +      (setf gc-assert-level assert-level))
    
    100
    +    (when verify-after-free-heap-p
    
    101
    +      (setf gc-verify-after-free-heap (if verify-after-free-heap 1 0)))
    
    102
    +    (when verify-generations-p
    
    103
    +      (setf gc-verify-generations verify-generations))
    
    104
    +    (when verify-new-objects-p
    
    105
    +      (setf gc-verify-new-objects (if verify-new-objects 1 0)))
    
    106
    +    (values))
    
    107
    +  )
    
    83 108
     
    
    84 109
     #+cgc
    
    85 110
     (c-var-frob dynamic-usage "bytes_allocated")
    

  • src/lisp/gencgc.c
    ... ... @@ -260,15 +260,15 @@ int verify_gens = NUM_GENERATIONS;
    260 260
      * makes GC very, very slow, so don't enable this unless you really
    
    261 261
      * need it!)
    
    262 262
      */
    
    263
    -boolean pre_verify_gen_0 = FALSE;
    
    263
    +int pre_verify_gen_0 = FALSE;
    
    264 264
     
    
    265 265
     /*
    
    266 266
      * Enable checking for bad pointers after gc_free_heap called from purify.
    
    267 267
      */
    
    268 268
     #if 0 && defined(DARWIN)
    
    269
    -boolean verify_after_free_heap = TRUE;
    
    269
    +int verify_after_free_heap = TRUE;
    
    270 270
     #else
    
    271
    -boolean verify_after_free_heap = FALSE;
    
    271
    +int verify_after_free_heap = FALSE;
    
    272 272
     #endif
    
    273 273
     
    
    274 274
     /*
    
    ... ... @@ -8031,7 +8031,9 @@ collect_garbage(unsigned last_gen)
    8031 8031
     
    
    8032 8032
         /* Verify the new objects created by lisp code. */
    
    8033 8033
         if (pre_verify_gen_0) {
    
    8034
    -	fprintf(stderr, "Pre-Checking generation 0\n");
    
    8034
    +	if (gencgc_verbose > 0) {
    
    8035
    +	    fprintf(stderr, "Pre-Checking generation 0\n");
    
    8036
    +	}
    
    8035 8037
     	verify_generation(0);
    
    8036 8038
         }
    
    8037 8039