code/room: Completely rewrite MAP-ALLOCATED-OBJECTS.
[sbcl.git] / src / runtime / gencgc.c
index 5829b5a..f755b80 100644 (file)
@@ -221,7 +221,7 @@ static inline boolean protect_page_p(page_index_t page, generation_index_t gener
 
 /* To map addresses to page structures the address of the first page
  * is needed. */
-static void *heap_base = NULL;
+void *heap_base = NULL;
 
 /* Calculate the start address for the given page number. */
 inline void *
@@ -4130,6 +4130,9 @@ gencgc_pickup_dynamic(void)
     void *alloc_ptr = (void *)get_alloc_pointer();
     lispobj *prev=(lispobj *)page_address(page);
     generation_index_t gen = PSEUDO_STATIC_GENERATION;
+
+    bytes_allocated = 0;
+
     do {
         lispobj *first,*ptr= (lispobj *)page_address(page);
 
@@ -4143,6 +4146,8 @@ gencgc_pickup_dynamic(void)
           page_table[page].write_protected_cleared = 0;
           page_table[page].dont_move = 0;
           page_table[page].need_to_zero = 1;
+
+          bytes_allocated += GENCGC_CARD_BYTES;
         }
 
         if (!gencgc_partial_pickup) {
@@ -4158,8 +4163,7 @@ gencgc_pickup_dynamic(void)
 
     last_free_page = page;
 
-    generations[gen].bytes_allocated = npage_bytes(page);
-    bytes_allocated = npage_bytes(page);
+    generations[gen].bytes_allocated = bytes_allocated;
 
     gc_alloc_update_all_page_tables();
     write_protect_generation_pages(gen);
@@ -4306,9 +4310,7 @@ general_alloc(sword_t nbytes, int page_type_flag)
 lispobj AMD64_SYSV_ABI *
 alloc(long nbytes)
 {
-#ifdef LISP_FEATURE_WIN32
-    /* WIN32 is currently the only platform where inline allocation is
-     * not pseudo atomic. */
+#ifdef LISP_FEATURE_SB_SAFEPOINT_STRICTLY
     struct thread *self = arch_os_get_current_thread();
     int was_pseudo_atomic = get_pseudo_atomic_atomic(self);
     if (!was_pseudo_atomic)
@@ -4319,7 +4321,7 @@ alloc(long nbytes)
 
     lispobj *result = general_alloc(nbytes, BOXED_PAGE_FLAG);
 
-#ifdef LISP_FEATURE_WIN32
+#ifdef LISP_FEATURE_SB_SAFEPOINT_STRICTLY
     if (!was_pseudo_atomic)
         clear_pseudo_atomic_atomic(self);
 #endif
@@ -4434,8 +4436,12 @@ void gc_alloc_update_all_page_tables(void)
 {
     /* Flush the alloc regions updating the tables. */
     struct thread *th;
-    for_each_thread(th)
+    for_each_thread(th) {
         gc_alloc_update_page_tables(BOXED_PAGE_FLAG, &th->alloc_region);
+#if defined(LISP_FEATURE_SB_SAFEPOINT_STRICTLY) && !defined(LISP_FEATURE_WIN32)
+        gc_alloc_update_page_tables(BOXED_PAGE_FLAG, &th->sprof_alloc_region);
+#endif
+    }
     gc_alloc_update_page_tables(UNBOXED_PAGE_FLAG, &unboxed_region);
     gc_alloc_update_page_tables(BOXED_PAGE_FLAG, &boxed_region);
 }