E58B Cherry-pick b9a2b292d39d. rdar://problem/95204263 · beidson/WebKit@8f82fa7 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8f82fa7

Browse files
Mark Lamalancoon
authored andcommitted
Cherry-pick b9a2b29. rdar://problem/95204263
Add variadic PAS_ASSERT support. https://bugs.webkit.org/show_bug.cgi?id=241626 rdar://95204263 Reviewed by Keith Miller. This patch adds support for a variadic PAS_ASSERT, and uses it to gather more debugging info for asserts in pas_local_view_cache_stop and pas_segregated_heap_ensure_allocator_index. From manual local disassembly of pas_local_view_cache_stop, I verified that this patch only changes assertion fail reporting code in an out of line slow path. The change does perturb code size, and any changes in code may also cause clang to arbitrarily rearrange the order of some control flow diamonds (e.g. the cases in a switch statement). If no extra data is provided to the variadic PAS_ASSERT, it will emit exactly same code as it does previously when PAS_ASSERT was not variadic. This gives us confidence that any perturbations in code will only manifest in PAS_ASSERTs that we choose to add extra info for reporting assertion failures. Preliminary benchmark results appear to show that performance is neutral. * Source/bmalloc/libpas/src/libpas/pas_local_view_cache.c: (pas_local_view_cache_stop): * Source/bmalloc/libpas/src/libpas/pas_segregated_heap.c: (pas_segregated_heap_ensure_allocator_index): * Source/bmalloc/libpas/src/libpas/pas_utils.c: (pas_crash_with_info_impl1): (pas_crash_with_info_impl2): (pas_crash_with_info_impl3): (pas_crash_with_info_impl4): (pas_crash_with_info_impl5): (pas_crash_with_info_impl6): (pas_report_assertion_failed): * Source/bmalloc/libpas/src/libpas/pas_utils.h: (pas_assertion_failed): (pas_assertion_failed_noreturn_silencer1): (pas_assertion_failed_noreturn_silencer2): (pas_assertion_failed_noreturn_silencer3): (pas_assertion_failed_noreturn_silencer4): (pas_assertion_failed_noreturn_silencer5): (pas_assertion_failed_noreturn_silencer6): Canonical link: https://commits.webkit.org/251567@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@295562 268f45cc-cd09-0410-ab3c-d52691b4dbfc Canonical link: https://commits.webkit.org/250315.923@safari-7614.1.16.10-branch
1 parent c509de4 commit 8f82fa7

File tree

4 files changed

+277
-16
lines changed

4 files changed

+277
-16
lines changed

Source/bmalloc/libpas/src/libpas/pas_local_view_cache.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2021 Apple Inc. All rights reserved.
2+
* Copyright (c) 2021-2022 Apple Inc. All rights reserved.
33
*
44
* Redistribution and use in source and binary forms, with or without
55
* modification, are permitted provided that the following conditions
@@ -122,7 +122,7 @@ bool pas_local_view_cache_stop(pas_local_view_cache* cache,
122122
result = stop_impl(cache, page_lock_mode);
123123

124124
if (result) {
125-
PAS_ASSERT(pas_local_view_cache_get_state(cache) == pas_local_view_cache_not_full_state);
125+
PAS_ASSERT(pas_local_view_cache_get_state(cache) == pas_local_view_cache_not_full_state, pas_local_view_cache_get_state(cache));
126126
PAS_ASSERT(cache->top_index == cache->bottom_index);
127127

128128
pas_local_view_cache_set_state(cache, pas_local_view_cache_stopped_state);

Source/bmalloc/libpas/src/libpas/pas_segregated_heap.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -844,7 +844,7 @@ pas_segregated_heap_ensure_allocator_index(
844844

845845
pas_heap_lock_assert_held();
846846

847-
PAS_ASSERT(directory->object_size >= min_object_size_for_heap(heap, config));
847+
PAS_ASSERT(directory->object_size >= min_object_size_for_heap(heap, config), directory->object_size, min_object_size_for_heap(heap, config));
848848

849849
rematerialize_size_lookup_if_necessary(heap, config, cached_index);
850850

@@ -853,8 +853,8 @@ pas_segregated_heap_ensure_allocator_index(
853853

854854
parent_heap = pas_heap_for_segregated_heap(heap);
855855

856-
PAS_ASSERT(size <= directory->object_size);
857-
PAS_ASSERT(!pas_heap_config_is_utility(config));
856+
PAS_ASSERT(size <= directory->object_size, size, directory->object_size);
857+
PAS_ASSERT(!pas_heap_config_is_utility(config), pas_heap_config_is_utility(config));
858858

859859
if (verbose)
860860
pas_log("%p: In pas_segregated_heap_ensure_allocator_index, size = %zu\n", (void*)pthread_self(), size);
@@ -863,9 +863,9 @@ pas_segregated_heap_ensure_allocator_index(
863863
pas_log("index = %zu\n", index);
864864

865865
allocator_index = directory->allocator_index;
866-
PAS_ASSERT(allocator_index);
867-
PAS_ASSERT((pas_allocator_index)allocator_index == allocator_index);
868-
PAS_ASSERT(allocator_index < (unsigned)(pas_allocator_index)UINT_MAX);
866+
PAS_ASSERT(allocator_index, allocator_index);
867+
PAS_ASSERT((pas_allocator_index)allocator_index == allocator_index, allocator_index);
868+
PAS_ASSERT(allocator_index < (unsigned)(pas_allocator_index)UINT_MAX, allocator_index);
869869

870870
if (verbose)
871871
pas_log("allocator_index = %u\n", allocator_index);
@@ -879,7 +879,7 @@ pas_segregated_heap_ensure_allocator_index(
879879
"Caching as cached index!\n");
880880
}
881881
PAS_ASSERT(!parent_heap->heap_ref->allocator_index ||
882-
parent_heap->heap_ref->allocator_index == allocator_index);
882+
parent_heap->heap_ref->allocator_index == allocator_index, parent_heap->heap_ref->allocator_index, allocator_index);
883883
parent_heap->heap_ref->allocator_index = allocator_index;
884884
did_cache_allocator_index = true;
885885
}
@@ -891,11 +891,11 @@ pas_segregated_heap_ensure_allocator_index(
891891
pas_allocator_index* allocator_index_ptr;
892892
B018 pas_allocator_index old_allocator_index;
893893
ensure_size_lookup(heap, config);
894-
PAS_ASSERT(index < heap->small_index_upper_bound);
894+
PAS_ASSERT(index < heap->small_index_upper_bound, index, heap->small_index_upper_bound);
895895
allocator_index_ptr = heap->index_to_small_allocator_index + index;
896896
old_allocator_index = *allocator_index_ptr;
897897
PAS_ASSERT(!old_allocator_index ||
898-
old_allocator_index == allocator_index);
898+
old_allocator_index == allocator_index, old_allocator_index, allocator_index);
899899
*allocator_index_ptr = (pas_allocator_index)allocator_index;
900900
}
901901
} else {
@@ -906,10 +906,10 @@ pas_segregated_heap_ensure_allocator_index(
906906
heap, index,
907907
pas_segregated_heap_medium_size_directory_search_within_size_class_progression,
908908
pas_lock_is_held);
909-
PAS_ASSERT(medium_directory);
909+
PAS_ASSERT(medium_directory, medium_directory);
910910
PAS_ASSERT(
911911
pas_compact_atomic_segregated_size_directory_ptr_load(&medium_directory->directory)
912-
== directory);
912+
== directory, pas_compact_atomic_segregated_size_directory_ptr_load(&medium_directory->directory), directory);
913913

914914
medium_directory->allocator_index = (pas_allocator_index)allocator_index;
915915
}

Source/bmalloc/libpas/src/libpas/pas_utils.c

Lines changed: 75 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2018-2021 Apple Inc. All rights reserved.
2+
* Copyright (c) 2018-2022 Apple Inc. All rights reserved.
33
*
44
* Redistribution and use in source and binary forms, with or without
55
* modification, are permitted provided that the following conditions
@@ -65,6 +65,73 @@
6565

6666
#if PAS_X86_64 || PAS_ARM64
6767

68+
#if PAS_OS(DARWIN) && PAS_VA_OPT_SUPPORTED
69+
70+
PAS_NEVER_INLINE PAS_NO_RETURN void pas_crash_with_info_impl1(uint64_t reason, uint64_t misc1)
71+
{
72+
register uint64_t reasonGPR asm(CRASH_GPR0) = reason;
73+
register uint64_t misc1GPR asm(CRASH_GPR1) = misc1;
74+
__asm__ volatile (CRASH_INST : : "r"(reasonGPR), "r"(misc1GPR));
75+
__builtin_unreachable();
76+
}
77+
78+
PAS_NEVER_INLINE PAS_NO_RETURN void pas_crash_with_info_impl2(uint64_t reason, uint64_t misc1, uint64_t misc2)
79+
{
80+
register uint64_t reasonGPR asm(CRASH_GPR0) = reason;
81+
register uint64_t misc1GPR asm(CRASH_GPR1) = misc1;
82+
register uint64_t misc2GPR asm(CRASH_GPR2) = misc2;
83+
__asm__ volatile (CRASH_INST : : "r"(reasonGPR), "r"(misc1GPR), "r"(misc2GPR));
84+
__builtin_unreachable();
85+
}
86+
87+
PAS_NEVER_INLINE PAS_NO_RETURN void pas_crash_with_info_impl3(uint64_t reason, uint64_t misc1, uint64_t misc2, uint64_t misc3)
88+
{
89+
register uint64_t reasonGPR asm(CRASH_GPR0) = reason;
90+
register uint64_t misc1GPR asm(CRASH_GPR1) = misc1;
91+
register uint64_t misc2GPR asm(CRASH_GPR2) = misc2;
92+
register uint64_t misc3GPR asm(CRASH_GPR3) = misc3;
93+
__asm__ volatile (CRASH_INST : : "r"(reasonGPR), "r"(misc1GPR), "r"(misc2GPR), "r"(misc3GPR));
94+
__builtin_unreachable();
95+
}
96+
97+
PAS_NEVER_INLINE PAS_NO_RETURN void pas_crash_with_info_impl4(uint64_t reason, uint64_t misc1, uint64_t misc2, uint64_t misc3, uint64_t misc4)
98+
{
99+
register uint64_t reasonGPR asm(CRASH_GPR0) = reason;
100+
register uint64_t misc1GPR asm(CRASH_GPR1) = misc1;
101+
register uint64_t misc2GPR asm(CRASH_GPR2) = misc2;
102+
register uint64_t misc3GPR asm(CRASH_GPR3) = misc3;
103+
register uint64_t misc4GPR asm(CRASH_GPR4) = misc4;
104+
__asm__ volatile (CRASH_INST : : "r"(reasonGPR), "r"(misc1GPR), "r"(misc2GPR), "r"(misc3GPR), "r"(misc4GPR));
105+
__builtin_unreachable();
106+
}
107+
108+
PAS_NEVER_INLINE PAS_NO_RETURN void pas_crash_with_info_impl5(uint64_t reason, uint64_t misc1, uint64_t misc2, uint64_t misc3, uint64_t misc4, uint64_t misc5)
109+
{
110+
register uint64_t reasonGPR asm(CRASH_GPR0) = reason;
111+
register uint64_t misc1GPR asm(CRASH_GPR1) = misc1;
112+
register uint64_t misc2GPR asm(CRASH_GPR2) = misc2;
113+
register uint64_t misc3GPR asm(CRASH_GPR3) = misc3;
114+
register uint64_t misc4GPR asm(CRASH_GPR4) = misc4;
115+
register uint64_t misc5GPR asm(CRASH_GPR5) = misc5;
116+
__asm__ volatile (CRASH_INST : : "r"(reasonGPR), "r"(misc1GPR), "r"(misc2GPR), "r"(misc3GPR), "r"(misc4GPR), "r"(misc5GPR));
117+
__builtin_unreachable();
118+
}
119+
120+
PAS_NEVER_INLINE PAS_NO_RETURN void pas_crash_with_info_impl6(uint64_t reason, uint64_t misc1, uint64_t misc2, uint64_t misc3, uint64_t misc4, uint64_t misc5, uint64_t misc6)
121+
{
122+
register uint64_t reasonGPR asm(CRASH_GPR0) = reason;
123+
register uint64_t misc1GPR asm(CRASH_GPR1) = misc1;
124+
register uint64_t misc2GPR asm(CRASH_GPR2) = misc2;
125+
register uint64_t misc3GPR asm(CRASH_GPR3) = misc3;
126+
register uint64_t misc4GPR asm(CRASH_GPR4) = misc4;
127+
register uint64_t misc5GPR asm(CRASH_GPR5) = misc5;
128+
register uint64_t misc6GPR asm(CRASH_GPR6) = misc6;
129+
__asm__ volatile (CRASH_INST : : "r"(reasonGPR), "r"(misc1GPR), "r"(misc2GPR), "r"(misc3GPR), "r"(misc4GPR), "r"(misc5GPR), "r"(misc6GPR));
130+
__builtin_unreachable();
131+
}
132+
133+
#endif /* PAS_OS(DARWIN) && PAS_VA_OPT_SUPPORTED */
134+
68135
PAS_NEVER_INLINE PAS_NO_RETURN static void pas_crash_with_info_impl(uint64_t reason, uint64_t misc1, uint64_t misc2, uint64_t misc3, uint64_t misc4, uint64_t misc5, uint64_t misc6)
69136
{
70137
register uint64_t reasonGPR asm(CRASH_GPR0) = reason;
@@ -98,6 +165,13 @@ void pas_panic(const char* format, ...)
98165
}
99166

100167
#if PAS_ENABLE_TESTING
168+
PAS_NEVER_INLINE void pas_report_assertion_failed(
169+
const char* filename, int line, const char* function, const char* expression)
170+
{
171+
pas_log("[%d] pas panic: ", getpid());
172+
pas_log("%s:%d: %s: assertion %s failed.\n", filename, line, function, expression);
173+
}
174+
101175
void pas_assertion_failed(const char* filename, int line, const char* function, const char* expression)
102176
{
103177
pas_panic("%s:%d: %s: assertion %s failed.\n", filename, line, function, expression);

0 commit comments

Comments
 (0)
0