2022-04-27 Ross Kirsling Unreviewed libpas build fix for PlayStation. https://bugs.webkit.org/show_bug.cgi?id=239834 * libpas/src/libpas/pas_random.h: (pas_get_random): Temporarily disable path on PlayStation. 2022-04-25 Brandon Stewart [libpas] Implement secure random numbers https://bugs.webkit.org/show_bug.cgi?id=239735 Reviewed by Yusuke Suzuki. We currently have a cheesy random and secure random, which use the same implementation for generating random numbers. (We are going to ignore the mock testing code here). This patch introduces a fast random and secure random. The fast random maintains the same properties as the previous implementation, while secure random will use the cryptographically secure arc4random_uniform to give better randomness. arc4random() can be quite an expensive operation and based on discussing with Yusuke he found heavy performance penalties when using this in JSC. Our secure random shall only be used in cases where true randomness is needed. We have 2 spots where we currently use secure random we shall just migrate those over to using fast random. * libpas/src/libpas/pas_baseline_allocator_table.c: (pas_baseline_allocator_table_get_random_index): * libpas/src/libpas/pas_dynamic_primitive_heap_map.c: (pas_dynamic_primitive_heap_map_find_slow): * libpas/src/libpas/pas_random.c: * libpas/src/libpas/pas_random.h: (pas_get_random): * libpas/src/libpas/pas_segregated_shared_page_directory.c: (find_first_eligible_consider_view): * libpas/src/test/IsoHeapPartialAndBaselineTests.cpp: (std::testTwoBaselinesEvictions): 2022-04-18 Elliott Williams [XCBuild] Use XCBuild for all command-line and project builds https://bugs.webkit.org/show_bug.cgi?id=238916 Reviewed by Alexey Proskuryakov. * bmalloc.xcodeproj/project.pbxproj: 2022-04-12 Elliott Williams [Xcode] In open-source builds, disable bitcode in xcconfigs instead of build-webkit https://bugs.webkit.org/show_bug.cgi?id=239262 Reviewed by Alexey Proskuryakov. * Configurations/Base.xcconfig: 2022-04-12 Elliott Williams Reland "[XCBuild] Enable dependency validation by default" https://bugs.webkit.org/show_bug.cgi?id=238901 Reviewed by Alexey Proskuryakov. * Configurations/DebugRelease.xcconfig: In open-source builds, disable VALIDATE_DEPENDENCIES when there is no PRODUCT_TYPE (i.e. not building a native target). 2022-04-12 Brandon Stewart [libpas] Update macOS build to c++20 and add bmalloc api test cases https://bugs.webkit.org/show_bug.cgi?id=239105 Reviewed by Yusuke Suzuki and Yusuke Suzuki. Update libpas build config to c++20. Add several basic bmalloc api tests. * libpas/CMakeLists.txt: * libpas/libpas.xcodeproj/project.pbxproj: * libpas/src/test/BmallocTests.cpp: Added. (std::testBmallocAllocate): (std::testBmallocDeallocate): (addBmallocTests): * libpas/src/test/PGMTests.cpp: * libpas/src/test/TestHarness.cpp: (main): 2022-04-08 Elliott Williams [Xcode] Avoid targeting 32-bit iOS and Mac architectures https://bugs.webkit.org/show_bug.cgi?id=238971 Reviewed by Alexey Proskuryakov. * Configurations/DebugRelease.xcconfig: 2022-04-08 Elliott Williams Unreviewed, reverting r292591. Causing spurious EWS errors Reverted changeset: "[XCBuild] Enable dependency validation by default" https://bugs.webkit.org/show_bug.cgi?id=238901 https://commits.webkit.org/r292591 2022-04-07 Elliott Williams [XCBuild] Enable dependency validation by default https://bugs.webkit.org/show_bug.cgi?id=238901 Reviewed by Alexey Proskuryakov. * Configurations/DebugRelease.xcconfig: 2022-04-06 Yusuke Suzuki [libpas] Run TLC decommit rarely https://bugs.webkit.org/show_bug.cgi?id=238855 Reviewed by Saam Barati. We were running libpas TLC decommit every time. But it is too frequent. We should capture IsoHeap allocation pattern with much more longer period, and perform TLC decommit in such a low-frequency rate. This patch changes it so that we run it only once a 128 scavenger run. It is roughly once a 13 seconds. * libpas/src/libpas/pas_scavenger.c: (scavenger_thread_main): (pas_scavenger_clear_all_caches): * libpas/src/libpas/pas_thread_local_cache.c: (pas_thread_local_cache_for_all): * libpas/src/libpas/pas_thread_local_cache.h: * libpas/src/test/TLCDecommitTests.cpp: (std::testTLCDecommit): (std::testTLCDecommitThenDestroyImpl): (std::testTLCDecommitThenDeallocate): 2022-04-06 Commit Queue Unreviewed, reverting r292450. https://bugs.webkit.org/show_bug.cgi?id=238883 Membuster regression Reverted changeset: "[libpas] Run TLC decommit rarely" https://bugs.webkit.org/show_bug.cgi?id=238855 https://commits.webkit.org/r292450 2022-04-05 Yusuke Suzuki [libpas] Run TLC decommit rarely https://bugs.webkit.org/show_bug.cgi?id=238855 Reviewed by Saam Barati. We were running libpas TLC decommit every time. But it is too frequent. We should capture IsoHeap allocation pattern with much more longer period, and perform TLC decommit in such a low-frequency rate. This patch changes it so that we run it only once a 128 scavenger run. It is roughly once a 13 seconds. * libpas/src/libpas/pas_scavenger.c: (scavenger_thread_main): (pas_scavenger_clear_all_caches): * libpas/src/libpas/pas_thread_local_cache.c: (pas_thread_local_cache_for_all): * libpas/src/libpas/pas_thread_local_cache.h: * libpas/src/test/TLCDecommitTests.cpp: (std::testTLCDecommit): (std::testTLCDecommitThenDestroyImpl): (std::testTLCDecommitThenDeallocate): 2022-04-05 Basuke Suzuki [PlayStation] Enable libpas. https://bugs.webkit.org/show_bug.cgi?id=238753 Reviewed by Yusuke Suzuki. PlayStation platform is ready to enable it finally. * PlatformPlayStation.cmake: * bmalloc/BPlatform.h: * libpas/src/libpas/pas_config.h: * libpas/src/libpas/pas_page_malloc.c: (pas_page_malloc_try_allocate_without_deallocating_padding): (commit_impl): * libpas/src/libpas/pas_platform.h: * libpas/src/libpas/pas_thread_local_cache.c: 2022-04-04 Yusuke Suzuki [libpas] Do not need to call pthread_set_qos_class_self_np repeatedly https://bugs.webkit.org/show_bug.cgi?id=238785 Reviewed by Mark Lam. Let's remember previously set QOS class and avoid resetting it if the value is not changed. * bmalloc/bmalloc.cpp: (bmalloc::api::setScavengerThreadQOSClass): * libpas/src/libpas/pas_scavenger.c: (pas_scavenger_set_requested_qos_class): (scavenger_thread_main): * libpas/src/libpas/pas_scavenger.h: 2022-03-29 Brandon Stewart Rename Libpas README to README.md https://bugs.webkit.org/show_bug.cgi?id=238517 Reviewed by Yusuke Suzuki. Libpas README does not correctly display markdown output on github.com without .md file extension. * libpas/ReadMe.md: Renamed from Source/bmalloc/libpas/README. 2022-03-26 Yusuke Suzuki Use unary static_assert https://bugs.webkit.org/show_bug.cgi?id=238412 Reviewed by Mark Lam. * bmalloc/Algorithm.h: (bmalloc::isPowerOfTwo): * bmalloc/Gigacage.h: * bmalloc/IsoHeapImpl.h: 2022-03-21 Alex Christensen Dust off Mac CMake build https://bugs.webkit.org/show_bug.cgi?id=238121 Reviewed by Yusuke Suzuki. * PlatformMac.cmake: 2022-03-15 Mark Lam Remove unused directory local variable in pas_enumerate_segregated_heaps. https://bugs.webkit.org/show_bug.cgi?id=237931 Reviewed by Geoffrey Garen. Also remove the call to pas_unwrap_local_view_cache_node(). It doesn't add any value. The only thing of substance that it does is a PAS_ASSERT that turns out to be redundant because pas_enumerate_segregated_heaps() already asserts the same thing before calling pas_unwrap_local_view_cache_node(). * libpas/src/libpas/pas_enumerate_segregated_heaps.c: (pas_enumerate_segregated_heaps): 2022-03-14 Elliott Williams bmalloc.xcodeproj: Remove duplicate file reference https://bugs.webkit.org/show_bug.cgi?id=237845 Reviewed by Simon Fraser. pas_thread_local_cache_layout_node_kind.h was listed twice in the same group, probably due to a merge conflict resolution typo. Dedupe it. * bmalloc.xcodeproj/project.pbxproj: 2022-03-12 Tim Horton Adopt FALLBACK_PLATFORM_NAME in place of FALLBACK_PLATFORM https://bugs.webkit.org/show_bug.cgi?id=237809 Reviewed by Per Arne Vollan. * Configurations/SDKVariant.xcconfig: 2022-03-11 Yusuke Suzuki Unreviewed, ASan specific build fix https://bugs.webkit.org/show_bug.cgi?id=237572 * libpas/src/libpas/pas_utils.h: (pas_zero_memory): 2022-03-09 Yusuke Suzuki [libpas] We should gurantee that in-flux-stash is fully baked when pointing table is set https://bugs.webkit.org/show_bug.cgi?id=237697 rdar://89116983 Reviewed by Mark Lam. To support enumerating hashtable which can be in the middle of resizing, we have in-flux-stash: this small stash is used to keep old table and size while resizing. However, Mark pointed that pas_tiny_large_map_hashtable_for_each_entry_remote's assertion is firing, which is ensuring that table's underlying pointer should be NULL when the size is 0. But in-flux-stash, we did not guarantee that in-flux-stash data is consistent when it is exposed to the enumerator (when setting hashtable_being_resized). This patch inserts pas_compiler_fence when exposing and unexposing in-flux-stash. pas_compiler_fence is enough (pas_store_store_fence is not necessary) because pas_enumerator runs after suspending the process. Thus, data structure's consistency between instruction boundary is enough. * libpas/src/libpas/pas_hashtable.h: 2022-03-08 Yusuke Suzuki [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 [libpas] Add missing PlayStation implementation. https://bugs.webkit.org/show_bug.cgi?id=237341 Reviewed by Yusuke Suzuki. * libpas/src/libpas/pas_monotonic_time.c: (pas_get_current_monotonic_time_nanoseconds): 2022-02-25 Basuke Suzuki [libpas] Suppress cast-align warnings https://bugs.webkit.org/show_bug.cgi?id=237179 Reviewed by Yusuke Suzuki. Ignore cast-align warnings for libpas target. * CMakeLists.txt: * libpas/src/libpas/bmalloc_heap_inlines.h: 2022-02-23 Basuke Suzuki [libpas] PlayStation uses 16k page size. https://bugs.webkit.org/show_bug.cgi?id=237096 Reviewed by Yusuke Suzuki. Match the granule default size to system page size for our platform. * libpas/src/libpas/pas_internal_config.h: == Rolled over to ChangeLog-2022-02-22 ==