Title: [291007] trunk/Source/bmalloc
Revision
291007
Author
[email protected]
Date
2022-03-08 12:48:22 -0800 (Tue, 08 Mar 2022)

Log Message

[libpas] Report more actionable crash in pas_enumerator
https://bugs.webkit.org/show_bug.cgi?id=237572

Reviewed by Saam Barati.

1. Adds PAS_ASSERT_WITH_DETAIL, which can report more detailed crash information than PAS_ASSERT
   while it is not efficient as much as PAS_ASSERT. We use it only in pas_enumerator related code
   to report more actionable crash from these code. It is OK since pas_enumerator is not used usually,
   which will be used only when vmmap is attached.
2. Extract enumerate_large_map, enumerate_small_large_map, and enumerate_tiny_large_map to report
   which part of these functions can crash (in very rare case).
3. Ensure pas_thread_local_cache_create's thread_local_cache is exposed after setting up all the data.

* libpas/src/libpas/pas_enumerable_range_list.c:
(pas_enumerable_range_list_append):
(pas_enumerable_range_list_iterate):
(pas_enumerable_range_list_iterate_remote):
* libpas/src/libpas/pas_enumerate_bitfit_heaps.c:
(view_callback):
(enumerate_bitfit_heap_callback):
* libpas/src/libpas/pas_enumerate_initially_unaccounted_pages.c:
(range_list_iterate_add_unaccounted_callback):
(range_list_iterate_exclude_accounted_callback):
* libpas/src/libpas/pas_enumerate_large_heaps.c:
(range_list_iterate_add_large_payload_callback):
(record_span):
(large_map_hashtable_entry_callback):
(small_large_map_hashtable_entry_callback):
(tiny_large_map_hashtable_entry_callback):
(enumerate_large_map):
(enumerate_small_large_map):
(enumerate_tiny_large_map):
(pas_enumerate_large_heaps):
* libpas/src/libpas/pas_enumerate_segregated_heaps.c:
(local_allocator_map_entry_is_empty_or_deleted):
(local_allocator_map_entry_is_empty):
(local_allocator_map_entry_is_deleted):
(collect_shared_page_directories_heap_callback):
(enumerate_exclusive_view):
(enumerate_shared_view):
(enumerate_partial_view):
(shared_page_directory_view_callback):
(size_directory_view_callback):
(consider_allocator):
(pas_enumerate_segregated_heaps):
* libpas/src/libpas/pas_enumerate_unaccounted_pages_as_meta.c:
(pas_enumerate_unaccounted_pages_as_meta):
* libpas/src/libpas/pas_enumerator.c:
(pas_enumerator_create):
(pas_enumerator_read_compact):
(pas_enumerator_read):
(pas_enumerator_add_unaccounted_pages):
(pas_enumerator_exclude_accounted_page):
(pas_enumerator_exclude_accounted_pages):
(pas_enumerator_record):
(pas_enumerator_record_page_payload_and_meta):
* libpas/src/libpas/pas_enumerator.h:
(pas_enumerator_record_kind_get_string):
* libpas/src/libpas/pas_enumerator_region.c:
(pas_enumerator_region_allocate):
* libpas/src/libpas/pas_thread_local_cache.c:
(pas_thread_local_cache_create):
* libpas/src/libpas/pas_utils.c:
(pas_assertion_failed_no_inline):
* libpas/src/libpas/pas_utils.h:
(pas_zero_memory):

Modified Paths

Diff

Modified: trunk/Source/bmalloc/ChangeLog (291006 => 291007)


--- trunk/Source/bmalloc/ChangeLog	2022-03-08 20:46:24 UTC (rev 291006)
+++ trunk/Source/bmalloc/ChangeLog	2022-03-08 20:48:22 UTC (rev 291007)
@@ -1,3 +1,72 @@
+2022-03-08  Yusuke Suzuki  <[email protected]>
+
+        [libpas] Report more actionable crash in pas_enumerator
+        https://bugs.webkit.org/show_bug.cgi?id=237572
+
+        Reviewed by Saam Barati.
+
+        1. Adds PAS_ASSERT_WITH_DETAIL, which can report more detailed crash information than PAS_ASSERT
+           while it is not efficient as much as PAS_ASSERT. We use it only in pas_enumerator related code
+           to report more actionable crash from these code. It is OK since pas_enumerator is not used usually,
+           which will be used only when vmmap is attached.
+        2. Extract enumerate_large_map, enumerate_small_large_map, and enumerate_tiny_large_map to report
+           which part of these functions can crash (in very rare case).
+        3. Ensure pas_thread_local_cache_create's thread_local_cache is exposed after setting up all the data.
+
+        * libpas/src/libpas/pas_enumerable_range_list.c:
+        (pas_enumerable_range_list_append):
+        (pas_enumerable_range_list_iterate):
+        (pas_enumerable_range_list_iterate_remote):
+        * libpas/src/libpas/pas_enumerate_bitfit_heaps.c:
+        (view_callback):
+        (enumerate_bitfit_heap_callback):
+        * libpas/src/libpas/pas_enumerate_initially_unaccounted_pages.c:
+        (range_list_iterate_add_unaccounted_callback):
+        (range_list_iterate_exclude_accounted_callback):
+        * libpas/src/libpas/pas_enumerate_large_heaps.c:
+        (range_list_iterate_add_large_payload_callback):
+        (record_span):
+        (large_map_hashtable_entry_callback):
+        (small_large_map_hashtable_entry_callback):
+        (tiny_large_map_hashtable_entry_callback):
+        (enumerate_large_map):
+        (enumerate_small_large_map):
+        (enumerate_tiny_large_map):
+        (pas_enumerate_large_heaps):
+        * libpas/src/libpas/pas_enumerate_segregated_heaps.c:
+        (local_allocator_map_entry_is_empty_or_deleted):
+        (local_allocator_map_entry_is_empty):
+        (local_allocator_map_entry_is_deleted):
+        (collect_shared_page_directories_heap_callback):
+        (enumerate_exclusive_view):
+        (enumerate_shared_view):
+        (enumerate_partial_view):
+        (shared_page_directory_view_callback):
+        (size_directory_view_callback):
+        (consider_allocator):
+        (pas_enumerate_segregated_heaps):
+        * libpas/src/libpas/pas_enumerate_unaccounted_pages_as_meta.c:
+        (pas_enumerate_unaccounted_pages_as_meta):
+        * libpas/src/libpas/pas_enumerator.c:
+        (pas_enumerator_create):
+        (pas_enumerator_read_compact):
+        (pas_enumerator_read):
+        (pas_enumerator_add_unaccounted_pages):
+        (pas_enumerator_exclude_accounted_page):
+        (pas_enumerator_exclude_accounted_pages):
+        (pas_enumerator_record):
+        (pas_enumerator_record_page_payload_and_meta):
+        * libpas/src/libpas/pas_enumerator.h:
+        (pas_enumerator_record_kind_get_string):
+        * libpas/src/libpas/pas_enumerator_region.c:
+        (pas_enumerator_region_allocate):
+        * libpas/src/libpas/pas_thread_local_cache.c:
+        (pas_thread_local_cache_create):
+        * libpas/src/libpas/pas_utils.c:
+        (pas_assertion_failed_no_inline):
+        * libpas/src/libpas/pas_utils.h:
+        (pas_zero_memory):
+
 2022-03-01  Basuke Suzuki  <[email protected]>
 
         [libpas] Add missing PlayStation implementation.

Modified: trunk/Source/bmalloc/libpas/src/libpas/pas_enumerable_range_list.c (291006 => 291007)


--- trunk/Source/bmalloc/libpas/src/libpas/pas_enumerable_range_list.c	2022-03-08 20:46:24 UTC (rev 291006)
+++ trunk/Source/bmalloc/libpas/src/libpas/pas_enumerable_range_list.c	2022-03-08 20:48:22 UTC (rev 291007)
@@ -47,7 +47,7 @@
     if (!chunk || chunk->num_entries >= PAS_ENUMERABLE_RANGE_LIST_CHUNK_SIZE) {
         pas_enumerable_range_list_chunk* new_chunk;
         
-        PAS_ASSERT(!chunk || chunk->num_entries == PAS_ENUMERABLE_RANGE_LIST_CHUNK_SIZE);
+        PAS_ASSERT_WITH_DETAIL(!chunk || chunk->num_entries == PAS_ENUMERABLE_RANGE_LIST_CHUNK_SIZE);
 
         new_chunk = pas_immortal_heap_allocate(sizeof(pas_enumerable_range_list_chunk),
                                                "pas_enumerable_range_list_chunk",
@@ -59,7 +59,7 @@
         chunk = new_chunk;
     }
 
-    PAS_ASSERT(chunk->num_entries < PAS_ENUMERABLE_RANGE_LIST_CHUNK_SIZE);
+    PAS_ASSERT_WITH_DETAIL(chunk->num_entries < PAS_ENUMERABLE_RANGE_LIST_CHUNK_SIZE);
 
     chunk->entries[chunk->num_entries] = range;
     pas_compiler_fence();
@@ -78,7 +78,7 @@
          chunk = pas_compact_atomic_enumerable_range_list_chunk_ptr_load(&chunk->next)) {
         size_t index;
 
-        PAS_ASSERT(chunk->num_entries <= PAS_ENUMERABLE_RANGE_LIST_CHUNK_SIZE);
+        PAS_ASSERT_WITH_DETAIL(chunk->num_entries <= PAS_ENUMERABLE_RANGE_LIST_CHUNK_SIZE);
 
         for (index = chunk->num_entries; index--;) {
             pas_range range;
@@ -113,7 +113,7 @@
                                                                                 &chunk->next)) {
         size_t index;
 
-        PAS_ASSERT(chunk->num_entries <= PAS_ENUMERABLE_RANGE_LIST_CHUNK_SIZE);
+        PAS_ASSERT_WITH_DETAIL(chunk->num_entries <= PAS_ENUMERABLE_RANGE_LIST_CHUNK_SIZE);
 
         for (index = chunk->num_entries; index--;) {
             pas_range range;

Modified: trunk/Source/bmalloc/libpas/src/libpas/pas_enumerate_bitfit_heaps.c (291006 => 291007)


--- trunk/Source/bmalloc/libpas/src/libpas/pas_enumerate_bitfit_heaps.c	2022-03-08 20:46:24 UTC (rev 291006)
+++ trunk/Source/bmalloc/libpas/src/libpas/pas_enumerate_bitfit_heaps.c	2022-03-08 20:48:22 UTC (rev 291007)
@@ -74,11 +74,11 @@
     if (!view->is_owned)
         return true;
 
-    PAS_ASSERT(page_boundary);
+    PAS_ASSERT_WITH_DETAIL(page_boundary);
 
     page = (pas_bitfit_page*)page_config->base.page_header_for_boundary_remote(
         enumerator, (void*)page_boundary);
-    PAS_ASSERT(page);
+    PAS_ASSERT_WITH_DETAIL(page);
 
     page = pas_enumerator_read(enumerator, page, pas_bitfit_page_header_size(*page_config));
     if (!page)
@@ -159,7 +159,7 @@
     pas_bitfit_heap* bitfit_heap;
     pas_bitfit_page_config_variant variant;
     
-    PAS_ASSERT(!arg);
+    PAS_ASSERT_WITH_DETAIL(!arg);
 
     bitfit_heap = pas_compact_atomic_bitfit_heap_ptr_load_remote(
         enumerator, &heap->segregated_heap.bitfit_heap);

Modified: trunk/Source/bmalloc/libpas/src/libpas/pas_enumerate_initially_unaccounted_pages.c (291006 => 291007)


--- trunk/Source/bmalloc/libpas/src/libpas/pas_enumerate_initially_unaccounted_pages.c	2022-03-08 20:46:24 UTC (rev 291006)
+++ trunk/Source/bmalloc/libpas/src/libpas/pas_enumerate_initially_unaccounted_pages.c	2022-03-08 20:48:22 UTC (rev 291007)
@@ -38,7 +38,7 @@
                                                         pas_range range,
                                                         void* arg)
 {
-    PAS_ASSERT(!arg);
+    PAS_ASSERT_WITH_DETAIL(!arg);
     pas_enumerator_add_unaccounted_pages(enumerator, (void*)range.begin, pas_range_size(range));
     return true;
 }
@@ -47,7 +47,7 @@
                                                           pas_range range,
                                                           void* arg)
 {
-    PAS_ASSERT(!arg);
+    PAS_ASSERT_WITH_DETAIL(!arg);
     pas_enumerator_exclude_accounted_pages(enumerator, (void*)range.begin, pas_range_size(range));
     return true;
 }

Modified: trunk/Source/bmalloc/libpas/src/libpas/pas_enumerate_large_heaps.c (291006 => 291007)


--- trunk/Source/bmalloc/libpas/src/libpas/pas_enumerate_large_heaps.c	2022-03-08 20:46:24 UTC (rev 291006)
+++ trunk/Source/bmalloc/libpas/src/libpas/pas_enumerate_large_heaps.c	2022-03-08 20:48:22 UTC (rev 291007)
@@ -42,14 +42,13 @@
 
     payloads = arg;
 
-    PAS_ASSERT(!pas_range_is_empty(range));
+    PAS_ASSERT_WITH_DETAIL(!pas_range_is_empty(range));
 
     pas_range_begin_min_heap_add(payloads, range, &enumerator->allocation_config);
     return true;
 }
 
-static void record_span(pas_enumerator* enumerator,
-                        pas_range range)
+static PAS_NEVER_INLINE void record_span(pas_enumerator* enumerator, pas_range range)
 {
     static const bool verbose = false;
     if (verbose)
@@ -61,7 +60,7 @@
 static bool large_map_hashtable_entry_callback(
     pas_enumerator* enumerator, pas_large_map_entry* entry, void* arg)
 {
-    PAS_ASSERT(!arg);
+    PAS_ASSERT_WITH_DETAIL(!arg);
     
     pas_enumerator_record(
         enumerator, (void*)entry->begin, entry->end - entry->begin, pas_enumerator_object_record);
@@ -75,7 +74,7 @@
     uintptr_t begin;
     uintptr_t end;
     
-    PAS_ASSERT(!arg);
+    PAS_ASSERT_WITH_DETAIL(!arg);
 
     begin = pas_small_large_map_entry_begin(*entry);
     end = pas_small_large_map_entry_end(*entry);
@@ -104,7 +103,7 @@
 static bool tiny_large_map_hashtable_entry_callback(
     pas_enumerator* enumerator, pas_first_level_tiny_large_map_entry* entry, void* arg)
 {
-    PAS_ASSERT(!arg);
+    PAS_ASSERT_WITH_DETAIL(!arg);
     
     return pas_tiny_large_map_second_level_hashtable_for_each_entry_remote(
         enumerator, entry->hashtable,
@@ -112,6 +111,36 @@
         tiny_large_map_second_level_hashtable_entry_callback, (void*)entry->base);
 }
 
+static PAS_NEVER_INLINE bool enumerate_large_map(pas_enumerator* enumerator)
+{
+    return pas_large_map_hashtable_for_each_entry_remote(
+        enumerator,
+        enumerator->root->large_map_hashtable_instance,
+        enumerator->root->large_map_hashtable_instance_in_flux_stash,
+        large_map_hashtable_entry_callback,
+        NULL);
+}
+
+static PAS_NEVER_INLINE bool enumerate_small_large_map(pas_enumerator* enumerator)
+{
+    return pas_small_large_map_hashtable_for_each_entry_remote(
+        enumerator,
+        enumerator->root->small_large_map_hashtable_instance,
+        enumerator->root->small_large_map_hashtable_instance_in_flux_stash,
+        small_large_map_hashtable_entry_callback,
+        NULL);
+}
+
+static PAS_NEVER_INLINE bool enumerate_tiny_large_map(pas_enumerator* enumerator)
+{
+    return pas_tiny_large_map_hashtable_for_each_entry_remote(
+        enumerator,
+        enumerator->root->tiny_large_map_hashtable_instance,
+        enumerator->root->tiny_large_map_hashtable_instance_in_flux_stash,
+        tiny_large_map_hashtable_entry_callback,
+        NULL);
+}
+
 bool pas_enumerate_large_heaps(pas_enumerator* enumerator)
 {
     static const bool verbose = false;
@@ -137,7 +166,7 @@
         uintptr_t page;
 
         for (page = range.begin; page < range.end; page += enumerator->root->page_malloc_alignment) {
-            PAS_ASSERT(page);
+            PAS_ASSERT_WITH_DETAIL(page);
 
             if (verbose)
                 pas_log("Looking at page %p\n", (void*)page);
@@ -158,28 +187,13 @@
     record_span(enumerator, span);
 
     if (enumerator->record_object) {
-        if (!pas_large_map_hashtable_for_each_entry_remote(
-                enumerator,
-                enumerator->root->large_map_hashtable_instance,
-                enumerator->root->large_map_hashtable_instance_in_flux_stash,
-                large_map_hashtable_entry_callback,
-                NULL))
+        if (!enumerate_large_map(enumerator))
             return false;
-        
-        if (!pas_small_large_map_hashtable_for_each_entry_remote(
-                enumerator,
-                enumerator->root->small_large_map_hashtable_instance,
-                enumerator->root->small_large_map_hashtable_instance_in_flux_stash,
-                small_large_map_hashtable_entry_callback,
-                NULL))
+
+        if (!enumerate_small_large_map(enumerator))
             return false;
-        
-        if (!pas_tiny_large_map_hashtable_for_each_entry_remote(
-                enumerator,
-                enumerator->root->tiny_large_map_hashtable_instance,
-                enumerator->root->tiny_large_map_hashtable_instance_in_flux_stash,
-                tiny_large_map_hashtable_entry_callback,
-                NULL))
+
+        if (!enumerate_tiny_large_map(enumerator))
             return false;
     }
 

Modified: trunk/Source/bmalloc/libpas/src/libpas/pas_enumerate_segregated_heaps.c (291006 => 291007)


--- trunk/Source/bmalloc/libpas/src/libpas/pas_enumerate_segregated_heaps.c	2022-03-08 20:46:24 UTC (rev 291006)
+++ trunk/Source/bmalloc/libpas/src/libpas/pas_enumerate_segregated_heaps.c	2022-03-08 20:48:22 UTC (rev 291007)
@@ -86,7 +86,7 @@
 static inline bool local_allocator_map_entry_is_empty_or_deleted(local_allocator_map_entry entry)
 {
     if (entry.page_boundary <= 1) {
-        PAS_ASSERT(!entry.head);
+        PAS_ASSERT_WITH_DETAIL(!entry.head);
         return true;
     }
     return false;
@@ -95,7 +95,7 @@
 static inline bool local_allocator_map_entry_is_empty(local_allocator_map_entry entry)
 {
     if (!entry.page_boundary) {
-        PAS_ASSERT(!entry.head);
+        PAS_ASSERT_WITH_DETAIL(!entry.head);
         return true;
     }
     return false;
@@ -104,7 +104,7 @@
 static inline bool local_allocator_map_entry_is_deleted(local_allocator_map_entry entry)
 {
     if (entry.page_boundary == 1) {
-        PAS_ASSERT(!entry.head);
+        PAS_ASSERT_WITH_DETAIL(!entry.head);
         return true;
     }
     return false;
@@ -197,7 +197,7 @@
     context = arg;
 
     config = pas_heap_config_kind_get_config(heap->config_kind);
-    PAS_ASSERT(config);
+    PAS_ASSERT_WITH_DETAIL(config);
 
     return config->for_each_shared_page_directory_remote(
         enumerator, &heap->segregated_heap,
@@ -342,7 +342,7 @@
 
     page = (pas_segregated_page*)page_config->base.page_header_for_boundary_remote(
         enumerator, (void*)page_boundary);
-    PAS_ASSERT(page);
+    PAS_ASSERT_WITH_DETAIL(page);
 
     page = pas_enumerator_read(
         enumerator, page, pas_segregated_page_header_size(*page_config, pas_segregated_page_exclusive_role));
@@ -354,9 +354,9 @@
         allocator = NULL;
     else {
         /* Exclusives can only have one allocator allocating in them at a time. */
-        PAS_ASSERT(!allocator_node->next);
+        PAS_ASSERT_WITH_DETAIL(!allocator_node->next);
         allocator = allocator_node->allocator;
-        PAS_ASSERT(allocator);
+        PAS_ASSERT_WITH_DETAIL(allocator);
     }
 
     if (verbose)
@@ -403,7 +403,7 @@
         if (view->is_owned) {
             page = (pas_segregated_page*)page_config->base.page_header_for_boundary_remote(
                 enumerator, (void*)page_boundary);
-            PAS_ASSERT(page);
+            PAS_ASSERT_WITH_DETAIL(page);
             
             page = pas_enumerator_read(
                 enumerator, page,
@@ -417,7 +417,7 @@
     }
 
     if (!page_boundary) {
-        PAS_ASSERT(!view->is_owned);
+        PAS_ASSERT_WITH_DETAIL(!view->is_owned);
         return true;
     }
 
@@ -431,7 +431,7 @@
         uintptr_t payload_begin;
         uintptr_t payload_end;
         
-        PAS_ASSERT(page);
+        PAS_ASSERT_WITH_DETAIL(page);
         
         payload_begin = pas_round_up_to_power_of_2(page_config->shared_payload_offset,
                                                    pas_segregated_page_config_min_align(*page_config));
@@ -471,7 +471,7 @@
     page_config = pas_segregated_page_config_kind_get_config(directory->base.page_config_kind);
 
     shared_view = pas_compact_segregated_shared_view_ptr_load_remote(enumerator, &view->shared_view);
-    PAS_ASSERT(shared_view);
+    PAS_ASSERT_WITH_DETAIL(shared_view);
     if (!shared_view->is_owned)
         return true;
 
@@ -483,7 +483,7 @@
 
     page = (pas_segregated_page*)page_config->base.page_header_for_boundary_remote(
         enumerator, (void*)page_boundary);
-    PAS_ASSERT(page);
+    PAS_ASSERT_WITH_DETAIL(page);
     
     page = pas_enumerator_read(
         enumerator, page, pas_segregated_page_header_size(*page_config, pas_segregated_page_shared_role));
@@ -541,7 +541,7 @@
 
     data = ""
 
-    PAS_ASSERT(pas_segregated_view_get_kind(view) == pas_segregated_shared_view_kind);
+    PAS_ASSERT_WITH_DETAIL(pas_segregated_view_get_kind(view) == pas_segregated_shared_view_kind);
 
     return enumerate_shared_view(
         enumerator, pas_segregated_view_get_ptr(view), data->directory, data->context);
@@ -566,7 +566,7 @@
     default:
         pas_log("Invalid view kind in size directory: %s\n",
                 pas_segregated_view_kind_get_string(pas_segregated_view_get_kind(view)));
-        PAS_ASSERT(!"Should not be reached");
+        PAS_ASSERT_WITH_DETAIL(!"Should not be reached");
         return true;
     }
 }
@@ -590,9 +590,7 @@
     return true;
 }
 
-static void consider_allocator(pas_enumerator* enumerator,
-                               enumeration_context* context,
-                               pas_local_allocator* allocator)
+static PAS_NEVER_INLINE void consider_allocator(pas_enumerator* enumerator, enumeration_context* context, pas_local_allocator* allocator)
 {
     local_allocator_map_add_result add_result;
     pas_segregated_page_config* page_config;
@@ -605,7 +603,7 @@
     if (verbose)
         pas_log("Have allocator %p in page_ish = %p\n", allocator, (void*)allocator->page_ish);
     
-    PAS_ASSERT(!pas_local_allocator_config_kind_is_bitfit(allocator->config_kind));
+    PAS_ASSERT_WITH_DETAIL(!pas_local_allocator_config_kind_is_bitfit(allocator->config_kind));
     
     page_config = pas_segregated_page_config_kind_get_config(
         pas_local_allocator_config_kind_get_segregated_page_config_kind(allocator->config_kind));
@@ -732,7 +730,7 @@
                 } else {
                     pas_segregated_size_directory* directory;
                     
-                    PAS_ASSERT(pas_is_wrapped_local_view_cache_node(layout_node));
+                    PAS_ASSERT_WITH_DETAIL(pas_is_wrapped_local_view_cache_node(layout_node));
 
                     directory = pas_unwrap_local_view_cache_node(layout_node);
 

Modified: trunk/Source/bmalloc/libpas/src/libpas/pas_enumerate_unaccounted_pages_as_meta.c (291006 => 291007)


--- trunk/Source/bmalloc/libpas/src/libpas/pas_enumerate_unaccounted_pages_as_meta.c	2022-03-08 20:46:24 UTC (rev 291006)
+++ trunk/Source/bmalloc/libpas/src/libpas/pas_enumerate_unaccounted_pages_as_meta.c	2022-03-08 20:48:22 UTC (rev 291007)
@@ -53,7 +53,7 @@
         if (pas_ptr_hash_set_entry_is_empty_or_deleted(page))
             continue;
 
-        PAS_ASSERT(page);
+        PAS_ASSERT_WITH_DETAIL(page);
 
         pas_ptr_min_heap_add(&ptr_heap, page, &enumerator->allocation_config);
     }
@@ -62,7 +62,7 @@
     span_end = NULL;
     while ((page = pas_ptr_min_heap_take_min(&ptr_heap))) {
         if (span_end != page) {
-            PAS_ASSERT(page > span_end);
+            PAS_ASSERT_WITH_DETAIL(page > span_end);
             pas_enumerator_record(
                 enumerator,
                 span_begin,

Modified: trunk/Source/bmalloc/libpas/src/libpas/pas_enumerator.c (291006 => 291007)


--- trunk/Source/bmalloc/libpas/src/libpas/pas_enumerator.c	2022-03-08 20:46:24 UTC (rev 291006)
+++ trunk/Source/bmalloc/libpas/src/libpas/pas_enumerator.c	2022-03-08 20:48:22 UTC (rev 291007)
@@ -99,8 +99,8 @@
     if (!result->root)
         goto fail;
 
-    PAS_ASSERT(result->root->magic == PAS_ROOT_MAGIC);
-    PAS_ASSERT(result->root->num_heap_configs == pas_heap_config_kind_num_kinds);
+    PAS_ASSERT_WITH_DETAIL(result->root->magic == PAS_ROOT_MAGIC);
+    PAS_ASSERT_WITH_DETAIL(result->root->num_heap_configs == pas_heap_config_kind_num_kinds);
 
     compact_heap_base = reader(
         result, result->root->compact_heap_reservation_base, sizeof(uintptr_t), reader_arg);
@@ -157,13 +157,13 @@
 
         config = pas_heap_config_kind_get_config(config_kind);
 
-        PAS_ASSERT(config);
+        PAS_ASSERT_WITH_DETAIL(config);
 
         remote_config = reader(result, configs[config->kind], sizeof(pas_heap_config), reader_arg);
         if (!remote_config)
             goto fail;
 
-        PAS_ASSERT(remote_config->kind == config->kind);
+        PAS_ASSERT_WITH_DETAIL(remote_config->kind == config->kind);
 
         if (!config->prepare_to_enumerate)
             continue;
@@ -197,9 +197,9 @@
     if ((uintptr_t)remote_address < (uintptr_t)PAS_INTERNAL_MIN_ALIGN)
         return remote_address;
     
-    PAS_ASSERT(remote_address >= (void*)((uintptr_t)enumerator->compact_heap_remote_base +
+    PAS_ASSERT_WITH_DETAIL(remote_address >= (void*)((uintptr_t)enumerator->compact_heap_remote_base +
                                          enumerator->compact_heap_guard_size));
-    PAS_ASSERT(remote_address < (void*)((uintptr_t)enumerator->compact_heap_remote_base +
+    PAS_ASSERT_WITH_DETAIL(remote_address < (void*)((uintptr_t)enumerator->compact_heap_remote_base +
                                         enumerator->compact_heap_size));
     return (void*)(
         (uintptr_t)enumerator->compact_heap_copy_base
@@ -212,7 +212,7 @@
 {
     void* compact_heap_end;
 
-    PAS_ASSERT(remote_address);
+    PAS_ASSERT_WITH_DETAIL(remote_address);
 
     compact_heap_end = (void*)(
         (uintptr_t)enumerator->compact_heap_remote_base + enumerator->compact_heap_size);
@@ -219,7 +219,7 @@
     
     if (remote_address >= enumerator->compact_heap_remote_base
         && remote_address < compact_heap_end) {
-        PAS_ASSERT((uintptr_t)remote_address + size <= (uintptr_t)compact_heap_end);
+        PAS_ASSERT_WITH_DETAIL((uintptr_t)remote_address + size <= (uintptr_t)compact_heap_end);
         return pas_enumerator_read_compact(enumerator, remote_address);
     }
 
@@ -235,11 +235,11 @@
 {
     size_t offset;
 
-    PAS_ASSERT(pas_is_aligned((uintptr_t)remote_address, enumerator->root->page_malloc_alignment));
-    PAS_ASSERT(pas_is_aligned(size, enumerator->root->page_malloc_alignment));
+    PAS_ASSERT_WITH_DETAIL(pas_is_aligned((uintptr_t)remote_address, enumerator->root->page_malloc_alignment));
+    PAS_ASSERT_WITH_DETAIL(pas_is_aligned(size, enumerator->root->page_malloc_alignment));
 
     /* Catch bogus sizes, in case we did some overflow or weird subtraction. */
-    PAS_ASSERT((uint64_t)size < ((uint64_t)1 << PAS_ADDRESS_BITS));
+    PAS_ASSERT_WITH_DETAIL((uint64_t)size < ((uint64_t)1 << PAS_ADDRESS_BITS));
 
     for (offset = 0; offset < size; offset += enumerator->root->page_malloc_alignment) {
         pas_ptr_hash_set_set(enumerator->unaccounted_pages,
@@ -253,7 +253,7 @@
 {
     static const bool verbose = false;
     bool result;
-    PAS_ASSERT(pas_is_aligned((uintptr_t)remote_address, enumerator->root->page_malloc_alignment));
+    PAS_ASSERT_WITH_DETAIL(pas_is_aligned((uintptr_t)remote_address, enumerator->root->page_malloc_alignment));
     result = pas_ptr_hash_set_remove(
         enumerator->unaccounted_pages, remote_address, NULL, &enumerator->allocation_config);
     if (verbose) {
@@ -271,11 +271,11 @@
 {
     size_t offset;
 
-    PAS_ASSERT(pas_is_aligned((uintptr_t)remote_address, enumerator->root->page_malloc_alignment));
-    PAS_ASSERT(pas_is_aligned(size, enumerator->root->page_malloc_alignment));
+    PAS_ASSERT_WITH_DETAIL(pas_is_aligned((uintptr_t)remote_address, enumerator->root->page_malloc_alignment));
+    PAS_ASSERT_WITH_DETAIL(pas_is_aligned(size, enumerator->root->page_malloc_alignment));
 
     /* Catch bogus sizes, in case we did some overflow or weird subtraction. */
-    PAS_ASSERT((uint64_t)size < ((uint64_t)1 << PAS_ADDRESS_BITS));
+    PAS_ASSERT_WITH_DETAIL((uint64_t)size < ((uint64_t)1 << PAS_ADDRESS_BITS));
 
     for (offset = 0; offset < size; offset += enumerator->root->page_malloc_alignment)
         pas_enumerator_exclude_accounted_page(enumerator, (void*)((uintptr_t)remote_address + offset));
@@ -290,7 +290,7 @@
         return;
 
     /* Catch bogus sizes, in case we did some overflow or weird subtraction. */
-    PAS_ASSERT((uint64_t)size < ((uint64_t)1 << PAS_ADDRESS_BITS));
+    PAS_ASSERT_WITH_DETAIL((uint64_t)size < ((uint64_t)1 << PAS_ADDRESS_BITS));
     
     switch (kind) {
     case pas_enumerator_meta_record:
@@ -328,9 +328,9 @@
                                                  uintptr_t payload_begin,
                                                  uintptr_t payload_end)
 {
-    PAS_ASSERT(payload_begin < page_size);
-    PAS_ASSERT(payload_end <= page_size);
-    PAS_ASSERT(payload_begin < payload_end);
+    PAS_ASSERT_WITH_DETAIL(payload_begin < page_size);
+    PAS_ASSERT_WITH_DETAIL(payload_end <= page_size);
+    PAS_ASSERT_WITH_DETAIL(payload_begin < payload_end);
 
     /* We assume, correctly for now, that non-payload areas of the page are always committed if the page
        is committed. */
@@ -345,7 +345,7 @@
 
     if (enumerator->record_payload) {
         if (page_size == granule_size) {
-            PAS_ASSERT(!use_counts);
+            PAS_ASSERT_WITH_DETAIL(!use_counts);
             pas_enumerator_record(enumerator,
                                   (void*)(page_boundary + payload_begin),
                                   payload_end - payload_begin,
@@ -354,8 +354,8 @@
             uintptr_t granule_index;
             pas_range span;
 
-            PAS_ASSERT(page_size > granule_size);
-            PAS_ASSERT(use_counts);
+            PAS_ASSERT_WITH_DETAIL(page_size > granule_size);
+            PAS_ASSERT_WITH_DETAIL(use_counts);
 
             span = pas_range_create(payload_begin, payload_begin);
             

Modified: trunk/Source/bmalloc/libpas/src/libpas/pas_enumerator.h (291006 => 291007)


--- trunk/Source/bmalloc/libpas/src/libpas/pas_enumerator.h	2022-03-08 20:46:24 UTC (rev 291006)
+++ trunk/Source/bmalloc/libpas/src/libpas/pas_enumerator.h	2022-03-08 20:48:22 UTC (rev 291007)
@@ -65,7 +65,7 @@
     case pas_enumerator_object_record:
         return "object";
     }
-    PAS_ASSERT(!"Should not be reached");
+    PAS_ASSERT_WITH_DETAIL(!"Should not be reached");
     return NULL;
 }
 

Modified: trunk/Source/bmalloc/libpas/src/libpas/pas_enumerator_region.c (291006 => 291007)


--- trunk/Source/bmalloc/libpas/src/libpas/pas_enumerator_region.c	2022-03-08 20:46:24 UTC (rev 291006)
+++ trunk/Source/bmalloc/libpas/src/libpas/pas_enumerator_region.c	2022-03-08 20:48:22 UTC (rev 291007)
@@ -49,14 +49,14 @@
 
         allocation_size = PAS_OFFSETOF(pas_enumerator_region, payload) + size;
 
-        PAS_ASSERT(pas_is_aligned(allocation_size, PAS_INTERNAL_MIN_ALIGN));
+        PAS_ASSERT_WITH_DETAIL(pas_is_aligned(allocation_size, PAS_INTERNAL_MIN_ALIGN));
 
         allocation_result = pas_page_malloc_try_allocate_without_deallocating_padding(
             allocation_size, pas_alignment_create_trivial());
 
-        PAS_ASSERT(allocation_result.result);
-        PAS_ASSERT(allocation_result.result == allocation_result.left_padding);
-        PAS_ASSERT(!allocation_result.left_padding_size);
+        PAS_ASSERT_WITH_DETAIL(allocation_result.result);
+        PAS_ASSERT_WITH_DETAIL(allocation_result.result == allocation_result.left_padding);
+        PAS_ASSERT_WITH_DETAIL(!allocation_result.left_padding_size);
 
         new_region = allocation_result.result;
         new_region->previous = region;
@@ -69,8 +69,8 @@
         region = new_region;
     }
 
-    PAS_ASSERT(region);
-    PAS_ASSERT(region->size - region->offset >= size);
+    PAS_ASSERT_WITH_DETAIL(region);
+    PAS_ASSERT_WITH_DETAIL(region->size - region->offset >= size);
 
     result = (char*)region->payload + region->offset;
     region->offset += size;

Modified: trunk/Source/bmalloc/libpas/src/libpas/pas_thread_local_cache.c (291006 => 291007)


--- trunk/Source/bmalloc/libpas/src/libpas/pas_thread_local_cache.c	2022-03-08 20:46:24 UTC (rev 291006)
+++ trunk/Source/bmalloc/libpas/src/libpas/pas_thread_local_cache.c	2022-03-08 20:48:22 UTC (rev 291007)
@@ -220,7 +220,6 @@
     thread_local_cache = allocate_cache(allocator_index_upper_bound);
     
     thread_local_cache->node = pas_thread_local_cache_node_allocate();
-    thread_local_cache->node->cache = thread_local_cache;
 
     if (verbose) {
         pas_log("[%d] TLC %p created with thread %p\n", getpid(), thread_local_cache, (void*)pthread_self());
@@ -227,9 +226,10 @@
         dump_thread_diagnostics(pthread_self());
     }
     thread_local_cache->thread = pthread_self();
+
+    pas_compiler_fence();
+    thread_local_cache->allocator_index_upper_bound = allocator_index_upper_bound;
     
-    thread_local_cache->allocator_index_upper_bound = allocator_index_upper_bound;
-
     pas_local_allocator_construct_unselected(
         (pas_local_allocator*)pas_thread_local_cache_get_local_allocator_direct_unchecked(
             thread_local_cache, PAS_LOCAL_ALLOCATOR_UNSELECTED_INDEX));
@@ -237,6 +237,9 @@
     for (PAS_THREAD_LOCAL_CACHE_LAYOUT_EACH_ALLOCATOR(layout_node))
         pas_thread_local_cache_layout_node_commit_and_construct(layout_node, thread_local_cache);
 
+    pas_compiler_fence();
+    thread_local_cache->node->cache = thread_local_cache;
+
     pas_thread_local_cache_set(thread_local_cache);
     
     return thread_local_cache;

Modified: trunk/Source/bmalloc/libpas/src/libpas/pas_utils.c (291006 => 291007)


--- trunk/Source/bmalloc/libpas/src/libpas/pas_utils.c	2022-03-08 20:46:24 UTC (rev 291006)
+++ trunk/Source/bmalloc/libpas/src/libpas/pas_utils.c	2022-03-08 20:48:22 UTC (rev 291007)
@@ -55,6 +55,11 @@
 }
 #endif /* PAS_ENABLE_TESTING */
 
+void pas_assertion_failed_no_inline(const char* filename, int line, const char* function, const char* _expression_)
+{
+    pas_panic("%s:%d: %s: assertion %s failed.\n", filename, line, function, _expression_);
+}
+
 void pas_panic_on_out_of_memory_error()
 {
     __builtin_trap();

Modified: trunk/Source/bmalloc/libpas/src/libpas/pas_utils.h (291006 => 291007)


--- trunk/Source/bmalloc/libpas/src/libpas/pas_utils.h	2022-03-08 20:46:24 UTC (rev 291006)
+++ trunk/Source/bmalloc/libpas/src/libpas/pas_utils.h	2022-03-08 20:48:22 UTC (rev 291007)
@@ -48,8 +48,6 @@
 
 #include "pas_utils_prefix.h"
 
-#define pas_zero_memory bzero
-
 #define PAS_BEGIN_EXTERN_C __PAS_BEGIN_EXTERN_C
 #define PAS_END_EXTERN_C __PAS_END_EXTERN_C
 
@@ -160,6 +158,11 @@
 #define PAS_TYPEOF(a) typeof (a)
 #endif
 
+PAS_ALWAYS_INLINE void pas_zero_memory(void* memory, size_t size)
+{
+    memset(memory, 0, size);
+}
+
 /* NOTE: panic format string must have \n at the end. */
 PAS_API PAS_NO_RETURN void pas_panic(const char* format, ...) PAS_FORMAT_PRINTF(1, 2);
 
@@ -192,6 +195,8 @@
 }
 #endif /* PAS_ENABLE_TESTING -> so end of !PAS_ENABLE_TESTING */
 
+PAS_API PAS_NO_RETURN PAS_NEVER_INLINE void pas_assertion_failed_no_inline(const char* filename, int line, const char* function, const char* _expression_);
+
 PAS_IGNORE_WARNINGS_BEGIN("missing-noreturn")
 static PAS_ALWAYS_INLINE void pas_assertion_failed_noreturn_silencer(
     const char* filename, int line, const char* function, const char* _expression_)
@@ -221,6 +226,15 @@
         pas_assertion_failed_noreturn_silencer(__FILE__, __LINE__, __PRETTY_FUNCTION__, #exp); \
     } while (0)
 
+#define PAS_ASSERT_WITH_DETAIL(exp) \
+    do { \
+        if (!PAS_ENABLE_ASSERT) \
+            break; \
+        if (PAS_LIKELY(exp)) \
+            break; \
+        pas_assertion_failed_no_inline(__FILE__, __LINE__, __PRETTY_FUNCTION__, #exp); \
+    } while (0)
+
 static inline bool pas_is_power_of_2(uintptr_t value)
 {
     return value && !(value & (value - 1));
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to