Diff
Modified: trunk/Source/bmalloc/ChangeLog (283370 => 283371)
--- trunk/Source/bmalloc/ChangeLog 2021-10-01 15:35:47 UTC (rev 283370)
+++ trunk/Source/bmalloc/ChangeLog 2021-10-01 16:19:16 UTC (rev 283371)
@@ -1,3 +1,93 @@
+2021-09-30 Filip Pizlo <fpi...@apple.com>
+
+ [libpas] Change the names of libpas heap runtime configs to something simpler (intrinsic, primitive, typed, and flex) and add comments describing what they are (update to 32abc1fd5489e01aa1c504ae4654967047d3f072)
+ https://bugs.webkit.org/show_bug.cgi?id=231040
+
+ Reviewed by Saam Barati.
+
+ At some point a long time ago, libpas had sensible names for heap runtime configs: primitive
+ and typed. Then I added the "objc" category, not realizing that I was really adding support for
+ flexible array members. And then I added "intrinsic_primitive", but wow, what a mouthful.
+
+ This changes the heap names to:
+
+ intrinsic: singleton heaps for primitive data, like the normal fastMalloc heap
+ primitive: isoheaps for primitive data
+ typed: isoheaps for fixed-size types
+ flex: isoheaps for types with flexible array members
+
+ Also adds comments explaining the exact behaviors of these heaps.
+
+ Also exposes isoheaped array allocation through the bmalloc_heap API. That's not yet exposed
+ via the IsoHeap API, but the idea is that it will be -- just need to figure out a clean way to
+ do it.
+
+ * bmalloc.xcodeproj/project.pbxproj:
+ * bmalloc/bmalloc.cpp:
+ (bmalloc::api::enableMiniMode):
+ * libpas/common.sh:
+ * libpas/src/chaos/Chaos.cpp:
+ (main):
+ * libpas/src/libpas/bmalloc_heap.c:
+ (bmalloc_try_iso_allocate_array):
+ (bmalloc_iso_allocate_array):
+ (bmalloc_try_iso_allocate_array_with_alignment):
+ (bmalloc_iso_allocate_array_with_alignment):
+ * libpas/src/libpas/bmalloc_heap.h:
+ * libpas/src/libpas/bmalloc_heap_config.c:
+ * libpas/src/libpas/bmalloc_heap_inlines.h:
+ (bmalloc_try_reallocate_inline):
+ (bmalloc_reallocate_inline):
+ (bmalloc_try_iso_allocate_array_inline):
+ (bmalloc_try_iso_allocate_array_with_alignment_inline):
+ (bmalloc_iso_allocate_array_inline):
+ (bmalloc_iso_allocate_array_with_alignment_inline):
+ * libpas/src/libpas/hotbit_heap.c:
+ * libpas/src/libpas/hotbit_heap_config.c:
+ * libpas/src/libpas/hotbit_heap_inlines.h:
+ (hotbit_try_reallocate_inline):
+ * libpas/src/libpas/iso_heap.c:
+ (iso_try_allocate_for_flex):
+ (iso_try_allocate_for_objc): Deleted.
+ * libpas/src/libpas/iso_heap.h:
+ * libpas/src/libpas/iso_heap_config.c:
+ * libpas/src/libpas/iso_heap_inlines.h:
+ (iso_try_reallocate_common_primitive_inline):
+ (iso_reallocate_common_primitive_inline):
+ (iso_try_allocate_for_flex_inline):
+ (iso_try_allocate_for_objc_inline): Deleted.
+ * libpas/src/libpas/iso_heap_innards.h:
+ * libpas/src/libpas/iso_test_heap.c:
+ * libpas/src/libpas/iso_test_heap_config.c:
+ * libpas/src/libpas/jit_heap.c:
+ * libpas/src/libpas/minalign32_heap.c:
+ * libpas/src/libpas/minalign32_heap_config.c:
+ * libpas/src/libpas/pagesize64k_heap.c:
+ * libpas/src/libpas/pagesize64k_heap_config.c:
+ * libpas/src/libpas/pas_heap_config_utils.h:
+ * libpas/src/libpas/pas_heap_config_utils_inlines.h:
+ * libpas/src/libpas/pas_internal_config.h:
+ * libpas/src/libpas/pas_large_heap.c:
+ (pas_large_heap_construct):
+ * libpas/src/libpas/pas_try_allocate.h:
+ * libpas/src/libpas/pas_try_allocate_array.h:
+ * libpas/src/libpas/pas_try_allocate_intrinsic.h: Added.
+ (pas_try_allocate_intrinsic_impl_medium_slow_case):
+ (pas_try_allocate_intrinsic_impl_inline_only):
+ * libpas/src/libpas/pas_try_allocate_intrinsic_primitive.h: Removed.
+ * libpas/src/libpas/pas_try_allocate_primitive.h:
+ * libpas/src/libpas/pas_try_reallocate.h:
+ (pas_try_reallocate_intrinsic_allocate_callback):
+ (pas_try_reallocate_intrinsic):
+ (pas_try_reallocate_intrinsic_primitive_allocate_callback): Deleted.
+ (pas_try_reallocate_intrinsic_primitive): Deleted.
+ * libpas/src/libpas/thingy_heap.c:
+ (thingy_try_reallocate_primitive):
+ * libpas/src/libpas/thingy_heap_config.c:
+ * libpas/src/test/IsoHeapChaosTests.cpp:
+ (addIsoHeapChaosTests):
+ * libpas/src/test/TestHarness.cpp:
+
2021-09-29 Basuke Suzuki <basuke.suz...@sony.com>
[bmalloc] ChunkHash is not used since r261667
Modified: trunk/Source/bmalloc/bmalloc/bmalloc.cpp (283370 => 283371)
--- trunk/Source/bmalloc/bmalloc/bmalloc.cpp 2021-10-01 15:35:47 UTC (rev 283370)
+++ trunk/Source/bmalloc/bmalloc/bmalloc.cpp 2021-10-01 16:19:16 UTC (rev 283371)
@@ -200,8 +200,8 @@
pas_physical_page_sharing_pool_balancing_enabled_for_utility = true;
// Switch to bitfit allocation for anything that isn't isoheaped.
- bmalloc_intrinsic_primitive_runtime_config.base.max_segregated_object_size = 0;
- bmalloc_intrinsic_primitive_runtime_config.base.max_bitfit_object_size = UINT_MAX;
+ bmalloc_intrinsic_runtime_config.base.max_segregated_object_size = 0;
+ bmalloc_intrinsic_runtime_config.base.max_bitfit_object_size = UINT_MAX;
bmalloc_primitive_runtime_config.base.max_segregated_object_size = 0;
bmalloc_primitive_runtime_config.base.max_bitfit_object_size = UINT_MAX;
#endif
Modified: trunk/Source/bmalloc/bmalloc.xcodeproj/project.pbxproj (283370 => 283371)
--- trunk/Source/bmalloc/bmalloc.xcodeproj/project.pbxproj 2021-10-01 15:35:47 UTC (rev 283370)
+++ trunk/Source/bmalloc/bmalloc.xcodeproj/project.pbxproj 2021-10-01 16:19:16 UTC (rev 283371)
@@ -75,6 +75,7 @@
0F5FE7F125B6210D001859FC /* pas_compact_biasing_directory_ptr.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F5FE7DC25B6210D001859FC /* pas_compact_biasing_directory_ptr.h */; settings = {ATTRIBUTES = (Private, ); }; };
0F74B93E1F89713E00B935D3 /* CryptoRandom.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F74B93C1F89713E00B935D3 /* CryptoRandom.h */; settings = {ATTRIBUTES = (Private, ); }; };
0F74B93F1F89713E00B935D3 /* CryptoRandom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F74B93D1F89713E00B935D3 /* CryptoRandom.cpp */; };
+ 0F752D9227066FCB00ADF74D /* pas_try_allocate_intrinsic.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F752D9127066FCB00ADF74D /* pas_try_allocate_intrinsic.h */; settings = {ATTRIBUTES = (Private, ); }; };
0F75498224869740002A4C7D /* pas_allocator_index.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F7549802486973C002A4C7D /* pas_allocator_index.h */; settings = {ATTRIBUTES = (Private, ); }; };
0F75498324869742002A4C7D /* pas_compact_atomic_allocator_index_ptr.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F7549812486973C002A4C7D /* pas_compact_atomic_allocator_index_ptr.h */; settings = {ATTRIBUTES = (Private, ); }; };
0F7C92E226E57F75006AF012 /* pas_page_sharing_pool_scavenge_result.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F7C92D226E57F74006AF012 /* pas_page_sharing_pool_scavenge_result.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -461,7 +462,6 @@
0FC40B602451499400876DA0 /* pas_random.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FC40A842451498C00876DA0 /* pas_random.h */; settings = {ATTRIBUTES = (Private, ); }; };
0FC40B612451499400876DA0 /* pas_segregated_view_kind.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FC40A852451498C00876DA0 /* pas_segregated_view_kind.h */; settings = {ATTRIBUTES = (Private, ); }; };
0FC40B622451499400876DA0 /* pas_reallocate_heap_teleport_rule.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FC40A862451498C00876DA0 /* pas_reallocate_heap_teleport_rule.h */; settings = {ATTRIBUTES = (Private, ); }; };
- 0FC40B632451499400876DA0 /* pas_try_allocate_intrinsic_primitive.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FC40A872451498C00876DA0 /* pas_try_allocate_intrinsic_primitive.h */; settings = {ATTRIBUTES = (Private, ); }; };
0FC40B642451499400876DA0 /* pas_segregated_shared_view_inlines.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FC40A882451498C00876DA0 /* pas_segregated_shared_view_inlines.h */; settings = {ATTRIBUTES = (Private, ); }; };
0FC40B652451499400876DA0 /* pas_page_malloc.c in Sources */ = {isa = PBXBuildFile; fileRef = 0FC40A892451498C00876DA0 /* pas_page_malloc.c */; };
0FC40B662451499400876DA0 /* pas_reserved_memory_provider.c in Sources */ = {isa = PBXBuildFile; fileRef = 0FC40A8A2451498C00876DA0 /* pas_reserved_memory_provider.c */; };
@@ -722,6 +722,7 @@
0F5FE7DC25B6210D001859FC /* pas_compact_biasing_directory_ptr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = pas_compact_biasing_directory_ptr.h; path = libpas/src/libpas/pas_compact_biasing_directory_ptr.h; sourceTree = "<group>"; };
0F74B93C1F89713E00B935D3 /* CryptoRandom.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CryptoRandom.h; path = bmalloc/CryptoRandom.h; sourceTree = "<group>"; };
0F74B93D1F89713E00B935D3 /* CryptoRandom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CryptoRandom.cpp; path = bmalloc/CryptoRandom.cpp; sourceTree = "<group>"; };
+ 0F752D9127066FCB00ADF74D /* pas_try_allocate_intrinsic.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = pas_try_allocate_intrinsic.h; path = libpas/src/libpas/pas_try_allocate_intrinsic.h; sourceTree = "<group>"; };
0F7549802486973C002A4C7D /* pas_allocator_index.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = pas_allocator_index.h; path = libpas/src/libpas/pas_allocator_index.h; sourceTree = "<group>"; };
0F7549812486973C002A4C7D /* pas_compact_atomic_allocator_index_ptr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = pas_compact_atomic_allocator_index_ptr.h; path = libpas/src/libpas/pas_compact_atomic_allocator_index_ptr.h; sourceTree = "<group>"; };
0F7C92D226E57F74006AF012 /* pas_page_sharing_pool_scavenge_result.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = pas_page_sharing_pool_scavenge_result.h; path = libpas/src/libpas/pas_page_sharing_pool_scavenge_result.h; sourceTree = "<group>"; };
@@ -1112,7 +1113,6 @@
0FC40A842451498C00876DA0 /* pas_random.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = pas_random.h; path = libpas/src/libpas/pas_random.h; sourceTree = "<group>"; };
0FC40A852451498C00876DA0 /* pas_segregated_view_kind.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = pas_segregated_view_kind.h; path = libpas/src/libpas/pas_segregated_view_kind.h; sourceTree = "<group>"; };
0FC40A862451498C00876DA0 /* pas_reallocate_heap_teleport_rule.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = pas_reallocate_heap_teleport_rule.h; path = libpas/src/libpas/pas_reallocate_heap_teleport_rule.h; sourceTree = "<group>"; };
- 0FC40A872451498C00876DA0 /* pas_try_allocate_intrinsic_primitive.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = pas_try_allocate_intrinsic_primitive.h; path = libpas/src/libpas/pas_try_allocate_intrinsic_primitive.h; sourceTree = "<group>"; };
0FC40A882451498C00876DA0 /* pas_segregated_shared_view_inlines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = pas_segregated_shared_view_inlines.h; path = libpas/src/libpas/pas_segregated_shared_view_inlines.h; sourceTree = "<group>"; };
0FC40A892451498C00876DA0 /* pas_page_malloc.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = pas_page_malloc.c; path = libpas/src/libpas/pas_page_malloc.c; sourceTree = "<group>"; };
0FC40A8A2451498C00876DA0 /* pas_reserved_memory_provider.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = pas_reserved_memory_provider.c; path = libpas/src/libpas/pas_reserved_memory_provider.c; sourceTree = "<group>"; };
@@ -1864,7 +1864,7 @@
0F8A801C25CF938A00790B4A /* pas_tri_state.h */,
0FC40A522451498800876DA0 /* pas_try_allocate_array.h */,
0FC40A392451498600876DA0 /* pas_try_allocate_common.h */,
- 0FC40A872451498C00876DA0 /* pas_try_allocate_intrinsic_primitive.h */,
+ 0F752D9127066FCB00ADF74D /* pas_try_allocate_intrinsic.h */,
0FC40A2B2451498500876DA0 /* pas_try_allocate_primitive.h */,
0FC40A652451498900876DA0 /* pas_try_allocate.h */,
0FC40A302451498600876DA0 /* pas_try_reallocate.h */,
@@ -2109,6 +2109,7 @@
0F7EB8251F9541B000F1ABCB /* DeferredTriggerInlines.h in Headers */,
0F7EB8231F9541B000F1ABCB /* EligibilityResult.h in Headers */,
0F7EB8381F9541B000F1ABCB /* EligibilityResultInlines.h in Headers */,
+ 0F752D9227066FCB00ADF74D /* pas_try_allocate_intrinsic.h in Headers */,
14895D921A3A319C0006235D /* Environment.h in Headers */,
FE48BD3B2321E8D700F136D0 /* FailureAction.h in Headers */,
14DD78C818F48D7500950702 /* FixedVector.h in Headers */,
@@ -2497,7 +2498,6 @@
0FC40B422451499400876DA0 /* pas_try_allocate.h in Headers */,
0FC40B302451499400876DA0 /* pas_try_allocate_array.h in Headers */,
0FC40B182451499400876DA0 /* pas_try_allocate_common.h in Headers */,
- 0FC40B632451499400876DA0 /* pas_try_allocate_intrinsic_primitive.h in Headers */,
0FC40B0A2451499400876DA0 /* pas_try_allocate_primitive.h in Headers */,
0FC40B0F2451499400876DA0 /* pas_try_reallocate.h in Headers */,
0F5193F5266C42BF00483A2C /* pas_try_shrink.h in Headers */,
Modified: trunk/Source/bmalloc/libpas/common.sh (283370 => 283371)
--- trunk/Source/bmalloc/libpas/common.sh 2021-10-01 15:35:47 UTC (rev 283370)
+++ trunk/Source/bmalloc/libpas/common.sh 2021-10-01 16:19:16 UTC (rev 283371)
@@ -24,7 +24,7 @@
set -e
set -x
-config=Debug
+config=Release
sdk=macosx.internal
archs=blank
variants=all
Modified: trunk/Source/bmalloc/libpas/src/chaos/Chaos.cpp (283370 => 283371)
--- trunk/Source/bmalloc/libpas/src/chaos/Chaos.cpp 2021-10-01 15:35:47 UTC (rev 283370)
+++ trunk/Source/bmalloc/libpas/src/chaos/Chaos.cpp 2021-10-01 16:19:16 UTC (rev 283371)
@@ -362,10 +362,10 @@
}
if (!enableBitFit)
- iso_intrinsic_primitive_runtime_config.base.max_bitfit_object_size = 0;
+ iso_intrinsic_runtime_config.base.max_bitfit_object_size = 0;
if (!enableSegregated)
- iso_intrinsic_primitive_runtime_config.base.max_segregated_object_size = 0;
+ iso_intrinsic_runtime_config.base.max_segregated_object_size = 0;
pas_status_reporter_enabled = enableStatusReporter;
Modified: trunk/Source/bmalloc/libpas/src/libpas/bmalloc_heap.c (283370 => 283371)
--- trunk/Source/bmalloc/libpas/src/libpas/bmalloc_heap.c 2021-10-01 15:35:47 UTC (rev 283370)
+++ trunk/Source/bmalloc/libpas/src/libpas/bmalloc_heap.c 2021-10-01 16:19:16 UTC (rev 283371)
@@ -39,12 +39,12 @@
PAS_INTRINSIC_HEAP_SUPPORT_INITIALIZER;
pas_heap bmalloc_common_primitive_heap =
- PAS_INTRINSIC_PRIMITIVE_HEAP_INITIALIZER(
+ PAS_INTRINSIC_HEAP_INITIALIZER(
&bmalloc_common_primitive_heap,
PAS_SIMPLE_TYPE_CREATE(1, 1),
bmalloc_common_primitive_heap_support,
BMALLOC_HEAP_CONFIG,
- &bmalloc_intrinsic_primitive_runtime_config.base);
+ &bmalloc_intrinsic_runtime_config.base);
pas_allocator_counts bmalloc_allocator_counts;
@@ -105,6 +105,28 @@
return bmalloc_iso_allocate_inline(heap_ref);
}
+void* bmalloc_try_iso_allocate_array(pas_heap_ref* heap_ref, size_t count)
+{
+ return bmalloc_try_iso_allocate_array_inline(heap_ref, count);
+}
+
+void* bmalloc_iso_allocate_array(pas_heap_ref* heap_ref, size_t count)
+{
+ return bmalloc_iso_allocate_array_inline(heap_ref, count);
+}
+
+void* bmalloc_try_iso_allocate_array_with_alignment(
+ pas_heap_ref* heap_ref, size_t count, size_t alignment)
+{
+ return bmalloc_try_iso_allocate_array_with_alignment_inline(heap_ref, count, alignment);
+}
+
+void* bmalloc_iso_allocate_array_with_alignment(
+ pas_heap_ref* heap_ref, size_t count, size_t alignment)
+{
+ return bmalloc_iso_allocate_array_with_alignment_inline(heap_ref, count, alignment);
+}
+
pas_heap* bmalloc_heap_ref_get_heap(pas_heap_ref* heap_ref)
{
return pas_ensure_heap(heap_ref, pas_normal_heap_ref_kind,
Modified: trunk/Source/bmalloc/libpas/src/libpas/bmalloc_heap.h (283370 => 283371)
--- trunk/Source/bmalloc/libpas/src/libpas/bmalloc_heap.h 2021-10-01 15:35:47 UTC (rev 283370)
+++ trunk/Source/bmalloc/libpas/src/libpas/bmalloc_heap.h 2021-10-01 16:19:16 UTC (rev 283371)
@@ -55,6 +55,14 @@
PAS_API void* bmalloc_try_iso_allocate(pas_heap_ref* heap_ref);
PAS_API void* bmalloc_iso_allocate(pas_heap_ref* heap_ref);
+PAS_API void* bmalloc_try_iso_allocate_array(pas_heap_ref* heap_ref, size_t count);
+PAS_API void* bmalloc_iso_allocate_array(pas_heap_ref* heap_ref, size_t count);
+
+PAS_API void* bmalloc_try_iso_allocate_array_with_alignment(
+ pas_heap_ref* heap_ref, size_t count, size_t alignment);
+PAS_API void* bmalloc_iso_allocate_array_with_alignment(
+ pas_heap_ref* heap_ref, size_t count, size_t alignment);
+
PAS_API pas_heap* bmalloc_heap_ref_get_heap(pas_heap_ref* heap_ref);
PAS_API void* bmalloc_try_allocate_auxiliary(pas_primitive_heap_ref* heap_ref,
Modified: trunk/Source/bmalloc/libpas/src/libpas/bmalloc_heap_config.c (283370 => 283371)
--- trunk/Source/bmalloc/libpas/src/libpas/bmalloc_heap_config.c 2021-10-01 15:35:47 UTC (rev 283370)
+++ trunk/Source/bmalloc/libpas/src/libpas/bmalloc_heap_config.c 2021-10-01 16:19:16 UTC (rev 283371)
@@ -41,7 +41,7 @@
PAS_BASIC_HEAP_CONFIG_DEFINITIONS(
bmalloc, BMALLOC,
.allocate_page_should_zero = false,
- .intrinsic_primitive_view_cache_capacity = pas_heap_runtime_config_aggressive_view_cache_capacity);
+ .intrinsic_view_cache_capacity = pas_heap_runtime_config_aggressive_view_cache_capacity);
void bmalloc_heap_config_activate(void)
{
Modified: trunk/Source/bmalloc/libpas/src/libpas/bmalloc_heap_inlines.h (283370 => 283371)
--- trunk/Source/bmalloc/libpas/src/libpas/bmalloc_heap_inlines.h 2021-10-01 15:35:47 UTC (rev 283370)
+++ trunk/Source/bmalloc/libpas/src/libpas/bmalloc_heap_inlines.h 2021-10-01 16:19:16 UTC (rev 283371)
@@ -31,7 +31,8 @@
#include "bmalloc_heap_innards.h"
#include "pas_deallocate.h"
#include "pas_try_allocate.h"
-#include "pas_try_allocate_intrinsic_primitive.h"
+#include "pas_try_allocate_array.h"
+#include "pas_try_allocate_intrinsic.h"
#include "pas_try_allocate_primitive.h"
#include "pas_try_reallocate.h"
@@ -39,10 +40,10 @@
PAS_BEGIN_EXTERN_C;
-PAS_CREATE_TRY_ALLOCATE_INTRINSIC_PRIMITIVE(
+PAS_CREATE_TRY_ALLOCATE_INTRINSIC(
bmalloc_try_allocate_impl,
BMALLOC_HEAP_CONFIG,
- &bmalloc_intrinsic_primitive_runtime_config.base,
+ &bmalloc_intrinsic_runtime_config.base,
&bmalloc_allocator_counts,
pas_allocation_result_identity,
&bmalloc_common_primitive_heap,
@@ -51,10 +52,10 @@
/* Need to create a different set of allocation functions if we want to pass nontrivial alignment,
since in that case we do not want to use the fancy lookup path. */
-PAS_CREATE_TRY_ALLOCATE_INTRINSIC_PRIMITIVE(
+PAS_CREATE_TRY_ALLOCATE_INTRINSIC(
bmalloc_try_allocate_with_alignment_impl,
BMALLOC_HEAP_CONFIG,
- &bmalloc_intrinsic_primitive_runtime_config.base,
+ &bmalloc_intrinsic_runtime_config.base,
&bmalloc_allocator_counts,
pas_allocation_result_identity,
&bmalloc_common_primitive_heap,
@@ -61,10 +62,10 @@
&bmalloc_common_primitive_heap_support,
pas_intrinsic_heap_is_not_designated);
-PAS_CREATE_TRY_ALLOCATE_INTRINSIC_PRIMITIVE(
+PAS_CREATE_TRY_ALLOCATE_INTRINSIC(
bmalloc_allocate_impl,
BMALLOC_HEAP_CONFIG,
- &bmalloc_intrinsic_primitive_runtime_config.base,
+ &bmalloc_intrinsic_runtime_config.base,
&bmalloc_allocator_counts,
pas_allocation_result_crash_on_error,
&bmalloc_common_primitive_heap,
@@ -71,10 +72,10 @@
&bmalloc_common_primitive_heap_support,
pas_intrinsic_heap_is_designated);
-PAS_CREATE_TRY_ALLOCATE_INTRINSIC_PRIMITIVE(
+PAS_CREATE_TRY_ALLOCATE_INTRINSIC(
bmalloc_allocate_with_alignment_impl,
BMALLOC_HEAP_CONFIG,
- &bmalloc_intrinsic_primitive_runtime_config.base,
+ &bmalloc_intrinsic_runtime_config.base,
&bmalloc_allocator_counts,
pas_allocation_result_crash_on_error,
&bmalloc_common_primitive_heap,
@@ -127,7 +128,7 @@
bmalloc_try_reallocate_inline(void* old_ptr, size_t new_size,
pas_reallocate_free_mode free_mode)
{
- return (void*)pas_try_reallocate_intrinsic_primitive(
+ return (void*)pas_try_reallocate_intrinsic(
old_ptr,
&bmalloc_common_primitive_heap,
new_size,
@@ -141,7 +142,7 @@
bmalloc_reallocate_inline(void* old_ptr, size_t new_size,
pas_reallocate_free_mode free_mode)
{
- return (void*)pas_try_reallocate_intrinsic_primitive(
+ return (void*)pas_try_reallocate_intrinsic(
old_ptr,
&bmalloc_common_primitive_heap,
new_size,
@@ -175,6 +176,44 @@
return bmalloc_iso_allocate_impl(heap_ref).ptr;
}
+PAS_CREATE_TRY_ALLOCATE_ARRAY(
+ bmalloc_try_iso_allocate_array_impl,
+ BMALLOC_HEAP_CONFIG,
+ &bmalloc_typed_runtime_config.base,
+ &bmalloc_allocator_counts,
+ pas_allocation_result_identity);
+
+static PAS_ALWAYS_INLINE void* bmalloc_try_iso_allocate_array_inline(
+ pas_heap_ref* heap_ref, size_t count)
+{
+ return bmalloc_try_iso_allocate_array_impl(heap_ref, count, 1).ptr;
+}
+
+static PAS_ALWAYS_INLINE void* bmalloc_try_iso_allocate_array_with_alignment_inline(
+ pas_heap_ref* heap_ref, size_t count, size_t alignment)
+{
+ return bmalloc_try_iso_allocate_array_impl(heap_ref, count, alignment).ptr;
+}
+
+PAS_CREATE_TRY_ALLOCATE_ARRAY(
+ bmalloc_iso_allocate_array_impl,
+ BMALLOC_HEAP_CONFIG,
+ &bmalloc_typed_runtime_config.base,
+ &bmalloc_allocator_counts,
+ pas_allocation_result_crash_on_error);
+
+static PAS_ALWAYS_INLINE void* bmalloc_iso_allocate_array_inline(
+ pas_heap_ref* heap_ref, size_t count)
+{
+ return bmalloc_iso_allocate_array_impl(heap_ref, count, 1).ptr;
+}
+
+static PAS_ALWAYS_INLINE void* bmalloc_iso_allocate_array_with_alignment_inline(
+ pas_heap_ref* heap_ref, size_t count, size_t alignment)
+{
+ return bmalloc_iso_allocate_array_impl(heap_ref, count, alignment).ptr;
+}
+
PAS_CREATE_TRY_ALLOCATE_PRIMITIVE(
bmalloc_try_allocate_auxiliary_impl,
BMALLOC_HEAP_CONFIG,
Modified: trunk/Source/bmalloc/libpas/src/libpas/hotbit_heap.c (283370 => 283371)
--- trunk/Source/bmalloc/libpas/src/libpas/hotbit_heap.c 2021-10-01 15:35:47 UTC (rev 283370)
+++ trunk/Source/bmalloc/libpas/src/libpas/hotbit_heap.c 2021-10-01 16:19:16 UTC (rev 283371)
@@ -38,12 +38,12 @@
PAS_INTRINSIC_HEAP_SUPPORT_INITIALIZER;
pas_heap hotbit_common_primitive_heap =
- PAS_INTRINSIC_PRIMITIVE_HEAP_INITIALIZER(
+ PAS_INTRINSIC_HEAP_INITIALIZER(
&hotbit_common_primitive_heap,
PAS_SIMPLE_TYPE_CREATE(1, 1),
hotbit_common_primitive_heap_support,
HOTBIT_HEAP_CONFIG,
- &hotbit_intrinsic_primitive_runtime_config.base);
+ &hotbit_intrinsic_runtime_config.base);
pas_allocator_counts hotbit_allocator_counts;
Modified: trunk/Source/bmalloc/libpas/src/libpas/hotbit_heap_config.c (283370 => 283371)
--- trunk/Source/bmalloc/libpas/src/libpas/hotbit_heap_config.c 2021-10-01 15:35:47 UTC (rev 283370)
+++ trunk/Source/bmalloc/libpas/src/libpas/hotbit_heap_config.c 2021-10-01 16:19:16 UTC (rev 283371)
@@ -40,7 +40,7 @@
PAS_BASIC_HEAP_CONFIG_DEFINITIONS(
hotbit, HOTBIT,
.allocate_page_should_zero = false,
- .intrinsic_primitive_view_cache_capacity = pas_heap_runtime_config_aggressive_view_cache_capacity);
+ .intrinsic_view_cache_capacity = pas_heap_runtime_config_aggressive_view_cache_capacity);
void hotbit_heap_config_activate(void)
{
Modified: trunk/Source/bmalloc/libpas/src/libpas/hotbit_heap_inlines.h (283370 => 283371)
--- trunk/Source/bmalloc/libpas/src/libpas/hotbit_heap_inlines.h 2021-10-01 15:35:47 UTC (rev 283370)
+++ trunk/Source/bmalloc/libpas/src/libpas/hotbit_heap_inlines.h 2021-10-01 16:19:16 UTC (rev 283371)
@@ -30,7 +30,7 @@
#include "hotbit_heap_config.h"
#include "hotbit_heap_innards.h"
#include "pas_deallocate.h"
-#include "pas_try_allocate_intrinsic_primitive.h"
+#include "pas_try_allocate_intrinsic.h"
#include "pas_try_reallocate.h"
#if PAS_ENABLE_HOTBIT
@@ -37,10 +37,10 @@
PAS_BEGIN_EXTERN_C;
-PAS_CREATE_TRY_ALLOCATE_INTRINSIC_PRIMITIVE(
+PAS_CREATE_TRY_ALLOCATE_INTRINSIC(
hotbit_try_allocate_impl,
HOTBIT_HEAP_CONFIG,
- &hotbit_intrinsic_primitive_runtime_config.base,
+ &hotbit_intrinsic_runtime_config.base,
&hotbit_allocator_counts,
pas_allocation_result_identity,
&hotbit_common_primitive_heap,
@@ -49,10 +49,10 @@
/* Need to create a different set of allocation functions if we want to pass nontrivial alignment,
since in that case we do not want to use the fancy lookup path. */
-PAS_CREATE_TRY_ALLOCATE_INTRINSIC_PRIMITIVE(
+PAS_CREATE_TRY_ALLOCATE_INTRINSIC(
hotbit_try_allocate_with_alignment_impl,
HOTBIT_HEAP_CONFIG,
- &hotbit_intrinsic_primitive_runtime_config.base,
+ &hotbit_intrinsic_runtime_config.base,
&hotbit_allocator_counts,
pas_allocation_result_identity,
&hotbit_common_primitive_heap,
@@ -74,7 +74,7 @@
hotbit_try_reallocate_inline(void* old_ptr, size_t new_size,
pas_reallocate_free_mode free_mode)
{
- return (void*)pas_try_reallocate_intrinsic_primitive(
+ return (void*)pas_try_reallocate_intrinsic(
old_ptr,
&hotbit_common_primitive_heap,
new_size,
Modified: trunk/Source/bmalloc/libpas/src/libpas/iso_heap.c (283370 => 283371)
--- trunk/Source/bmalloc/libpas/src/libpas/iso_heap.c 2021-10-01 15:35:47 UTC (rev 283370)
+++ trunk/Source/bmalloc/libpas/src/libpas/iso_heap.c 2021-10-01 16:19:16 UTC (rev 283371)
@@ -36,7 +36,7 @@
#include "pas_ensure_heap_forced_into_reserved_memory.h"
#include "pas_try_allocate.h"
#include "pas_try_allocate_array.h"
-#include "pas_try_allocate_intrinsic_primitive.h"
+#include "pas_try_allocate_intrinsic.h"
#include "pas_try_allocate_primitive.h"
#include "pas_try_reallocate.h"
@@ -44,18 +44,18 @@
PAS_INTRINSIC_HEAP_SUPPORT_INITIALIZER;
pas_heap iso_common_primitive_heap =
- PAS_INTRINSIC_PRIMITIVE_HEAP_INITIALIZER(
+ PAS_INTRINSIC_HEAP_INITIALIZER(
&iso_common_primitive_heap,
PAS_SIMPLE_TYPE_CREATE(1, 1),
iso_common_primitive_heap_support,
ISO_HEAP_CONFIG,
- &iso_intrinsic_primitive_runtime_config.base);
+ &iso_intrinsic_runtime_config.base);
pas_allocator_counts iso_allocator_counts;
pas_dynamic_primitive_heap_map iso_primitive_dynamic_heap_map =
PAS_DYNAMIC_PRIMITIVE_HEAP_MAP_INITIALIZER(iso_primitive_heap_ref_construct);
-pas_dynamic_primitive_heap_map iso_objc_dynamic_heap_map =
+pas_dynamic_primitive_heap_map iso_flex_dynamic_heap_map =
PAS_DYNAMIC_PRIMITIVE_HEAP_MAP_INITIALIZER(iso_primitive_heap_ref_construct);
void* iso_try_allocate_common_primitive(size_t size)
@@ -264,9 +264,9 @@
return iso_reallocate_primitive_inline(old_ptr, heap_ref, new_size, free_mode);
}
-void* iso_try_allocate_for_objc(const void* cls, size_t size)
+void* iso_try_allocate_for_flex(const void* cls, size_t size)
{
- return iso_try_allocate_for_objc_inline(cls, size);
+ return iso_try_allocate_for_flex_inline(cls, size);
}
bool iso_has_object(void* ptr)
Modified: trunk/Source/bmalloc/libpas/src/libpas/iso_heap.h (283370 => 283371)
--- trunk/Source/bmalloc/libpas/src/libpas/iso_heap.h 2021-10-01 15:35:47 UTC (rev 283370)
+++ trunk/Source/bmalloc/libpas/src/libpas/iso_heap.h 2021-10-01 16:19:16 UTC (rev 283371)
@@ -117,7 +117,7 @@
PAS_API pas_heap* iso_primitive_heap_ref_get_heap(pas_primitive_heap_ref* heap_ref);
-PAS_API void* iso_try_allocate_for_objc(const void* cls, size_t size);
+PAS_API void* iso_try_allocate_for_flex(const void* cls, size_t size);
PAS_API bool iso_has_object(void*);
PAS_API size_t iso_get_allocation_size(void*);
Modified: trunk/Source/bmalloc/libpas/src/libpas/iso_heap_config.c (283370 => 283371)
--- trunk/Source/bmalloc/libpas/src/libpas/iso_heap_config.c 2021-10-01 15:35:47 UTC (rev 283370)
+++ trunk/Source/bmalloc/libpas/src/libpas/iso_heap_config.c 2021-10-01 16:19:16 UTC (rev 283371)
@@ -38,7 +38,7 @@
PAS_BASIC_HEAP_CONFIG_DEFINITIONS(
iso, ISO,
.allocate_page_should_zero = false,
- .intrinsic_primitive_view_cache_capacity = pas_heap_runtime_config_zero_view_cache_capacity);
+ .intrinsic_view_cache_capacity = pas_heap_runtime_config_zero_view_cache_capacity);
#endif /* PAS_ENABLE_ISO */
Modified: trunk/Source/bmalloc/libpas/src/libpas/iso_heap_inlines.h (283370 => 283371)
--- trunk/Source/bmalloc/libpas/src/libpas/iso_heap_inlines.h 2021-10-01 15:35:47 UTC (rev 283370)
+++ trunk/Source/bmalloc/libpas/src/libpas/iso_heap_inlines.h 2021-10-01 16:19:16 UTC (rev 283371)
@@ -35,7 +35,7 @@
#include "pas_has_object.h"
#include "pas_try_allocate.h"
#include "pas_try_allocate_array.h"
-#include "pas_try_allocate_intrinsic_primitive.h"
+#include "pas_try_allocate_intrinsic.h"
#include "pas_try_allocate_primitive.h"
#include "pas_try_reallocate.h"
@@ -43,10 +43,10 @@
PAS_BEGIN_EXTERN_C;
-PAS_CREATE_TRY_ALLOCATE_INTRINSIC_PRIMITIVE(
+PAS_CREATE_TRY_ALLOCATE_INTRINSIC(
iso_try_allocate_common_primitive_impl,
ISO_HEAP_CONFIG,
- &iso_intrinsic_primitive_runtime_config.base,
+ &iso_intrinsic_runtime_config.base,
&iso_allocator_counts,
pas_allocation_result_set_errno,
&iso_common_primitive_heap,
@@ -55,10 +55,10 @@
/* Need to create a different set of allocation functions if we want to pass nontrivial alignment,
since in that case we do not want to use the fancy lookup path. */
-PAS_CREATE_TRY_ALLOCATE_INTRINSIC_PRIMITIVE(
+PAS_CREATE_TRY_ALLOCATE_INTRINSIC(
iso_try_allocate_common_primitive_with_alignment_impl,
ISO_HEAP_CONFIG,
- &iso_intrinsic_primitive_runtime_config.base,
+ &iso_intrinsic_runtime_config.base,
&iso_allocator_counts,
pas_allocation_result_set_errno,
&iso_common_primitive_heap,
@@ -65,10 +65,10 @@
&iso_common_primitive_heap_support,
pas_intrinsic_heap_is_not_designated);
-PAS_CREATE_TRY_ALLOCATE_INTRINSIC_PRIMITIVE(
+PAS_CREATE_TRY_ALLOCATE_INTRINSIC(
iso_allocate_common_primitive_impl,
ISO_HEAP_CONFIG,
- &iso_intrinsic_primitive_runtime_config.base,
+ &iso_intrinsic_runtime_config.base,
&iso_allocator_counts,
pas_allocation_result_crash_on_error,
&iso_common_primitive_heap,
@@ -75,10 +75,10 @@
&iso_common_primitive_heap_support,
pas_intrinsic_heap_is_not_designated);
-PAS_CREATE_TRY_ALLOCATE_INTRINSIC_PRIMITIVE(
+PAS_CREATE_TRY_ALLOCATE_INTRINSIC(
iso_allocate_common_primitive_with_alignment_impl,
ISO_HEAP_CONFIG,
- &iso_intrinsic_primitive_runtime_config.base,
+ &iso_intrinsic_runtime_config.base,
&iso_allocator_counts,
pas_allocation_result_crash_on_error,
&iso_common_primitive_heap,
@@ -125,7 +125,7 @@
iso_try_reallocate_common_primitive_inline(void* old_ptr, size_t new_size,
pas_reallocate_free_mode free_mode)
{
- return (void*)pas_try_reallocate_intrinsic_primitive(
+ return (void*)pas_try_reallocate_intrinsic(
old_ptr,
&iso_common_primitive_heap,
new_size,
@@ -139,7 +139,7 @@
iso_reallocate_common_primitive_inline(void* old_ptr, size_t new_size,
pas_reallocate_free_mode free_mode)
{
- return (void*)pas_try_reallocate_intrinsic_primitive(
+ return (void*)pas_try_reallocate_intrinsic(
old_ptr,
&iso_common_primitive_heap,
new_size,
@@ -333,18 +333,18 @@
}
PAS_CREATE_TRY_ALLOCATE_PRIMITIVE(
- iso_try_allocate_for_objc_impl,
+ iso_try_allocate_for_flex_impl,
ISO_HEAP_CONFIG,
- &iso_objc_runtime_config.base,
+ &iso_flex_runtime_config.base,
&iso_allocator_counts,
pas_allocation_result_set_errno);
-static PAS_ALWAYS_INLINE void* iso_try_allocate_for_objc_inline(const void* cls, size_t size)
+static PAS_ALWAYS_INLINE void* iso_try_allocate_for_flex_inline(const void* cls, size_t size)
{
return (void*)pas_allocation_result_zero(
- iso_try_allocate_for_objc_impl(
+ iso_try_allocate_for_flex_impl(
pas_dynamic_primitive_heap_map_find(
- &iso_objc_dynamic_heap_map, cls, size),
+ &iso_flex_dynamic_heap_map, cls, size),
size, 1),
size).begin;
}
Modified: trunk/Source/bmalloc/libpas/src/libpas/iso_heap_innards.h (283370 => 283371)
--- trunk/Source/bmalloc/libpas/src/libpas/iso_heap_innards.h 2021-10-01 15:35:47 UTC (rev 283370)
+++ trunk/Source/bmalloc/libpas/src/libpas/iso_heap_innards.h 2021-10-01 16:19:16 UTC (rev 283371)
@@ -41,7 +41,7 @@
PAS_API extern pas_allocator_counts iso_allocator_counts;
PAS_API extern pas_dynamic_primitive_heap_map iso_primitive_dynamic_heap_map;
-PAS_API extern pas_dynamic_primitive_heap_map iso_objc_dynamic_heap_map;
+PAS_API extern pas_dynamic_primitive_heap_map iso_flex_dynamic_heap_map;
PAS_END_EXTERN_C;
Modified: trunk/Source/bmalloc/libpas/src/libpas/iso_test_heap.c (283370 => 283371)
--- trunk/Source/bmalloc/libpas/src/libpas/iso_test_heap.c 2021-10-01 15:35:47 UTC (rev 283370)
+++ trunk/Source/bmalloc/libpas/src/libpas/iso_test_heap.c 2021-10-01 16:19:16 UTC (rev 283371)
@@ -37,23 +37,23 @@
#include "pas_deallocate.h"
#include "pas_try_allocate.h"
#include "pas_try_allocate_array.h"
-#include "pas_try_allocate_intrinsic_primitive.h"
+#include "pas_try_allocate_intrinsic.h"
pas_intrinsic_heap_support iso_test_common_primitive_heap_support =
PAS_INTRINSIC_HEAP_SUPPORT_INITIALIZER;
pas_heap iso_test_common_primitive_heap =
- PAS_INTRINSIC_PRIMITIVE_HEAP_INITIALIZER(
+ PAS_INTRINSIC_HEAP_INITIALIZER(
&iso_test_common_primitive_heap,
PAS_SIMPLE_TYPE_CREATE(1, 1),
iso_test_common_primitive_heap_support,
ISO_TEST_HEAP_CONFIG,
- &iso_test_intrinsic_primitive_runtime_config.base);
+ &iso_test_intrinsic_runtime_config.base);
-PAS_CREATE_TRY_ALLOCATE_INTRINSIC_PRIMITIVE(
+PAS_CREATE_TRY_ALLOCATE_INTRINSIC(
test_allocate_common_primitive,
ISO_TEST_HEAP_CONFIG,
- &iso_test_intrinsic_primitive_runtime_config.base,
+ &iso_test_intrinsic_runtime_config.base,
&iso_allocator_counts,
pas_allocation_result_crash_on_error,
&iso_test_common_primitive_heap,
Modified: trunk/Source/bmalloc/libpas/src/libpas/iso_test_heap_config.c (283370 => 283371)
--- trunk/Source/bmalloc/libpas/src/libpas/iso_test_heap_config.c 2021-10-01 15:35:47 UTC (rev 283370)
+++ trunk/Source/bmalloc/libpas/src/libpas/iso_test_heap_config.c 2021-10-01 16:19:16 UTC (rev 283371)
@@ -38,7 +38,7 @@
PAS_BASIC_HEAP_CONFIG_DEFINITIONS(
iso_test, ISO_TEST,
.allocate_page_should_zero = false,
- .intrinsic_primitive_view_cache_capacity = pas_heap_runtime_config_zero_view_cache_capacity);
+ .intrinsic_view_cache_capacity = pas_heap_runtime_config_zero_view_cache_capacity);
#endif /* PAS_ENABLE_ISO_TEST */
Modified: trunk/Source/bmalloc/libpas/src/libpas/jit_heap.c (283370 => 283371)
--- trunk/Source/bmalloc/libpas/src/libpas/jit_heap.c 2021-10-01 15:35:47 UTC (rev 283370)
+++ trunk/Source/bmalloc/libpas/src/libpas/jit_heap.c 2021-10-01 16:19:16 UTC (rev 283371)
@@ -34,10 +34,10 @@
#include "jit_heap_config.h"
#include "pas_deallocate.h"
#include "pas_get_allocation_size.h"
-#include "pas_try_allocate_intrinsic_primitive.h"
+#include "pas_try_allocate_intrinsic.h"
#include "pas_try_shrink.h"
-pas_heap jit_common_primitive_heap = PAS_INTRINSIC_PRIMITIVE_HEAP_INITIALIZER(
+pas_heap jit_common_primitive_heap = PAS_INTRINSIC_HEAP_INITIALIZER(
&jit_common_primitive_heap,
NULL,
jit_common_primitive_heap_support,
@@ -60,7 +60,7 @@
pas_heap_lock_unlock();
}
-PAS_CREATE_TRY_ALLOCATE_INTRINSIC_PRIMITIVE(
+PAS_CREATE_TRY_ALLOCATE_INTRINSIC(
jit_try_allocate_common_primitive_impl,
JIT_HEAP_CONFIG,
&jit_heap_runtime_config,
Modified: trunk/Source/bmalloc/libpas/src/libpas/minalign32_heap.c (283370 => 283371)
--- trunk/Source/bmalloc/libpas/src/libpas/minalign32_heap.c 2021-10-01 15:35:47 UTC (rev 283370)
+++ trunk/Source/bmalloc/libpas/src/libpas/minalign32_heap.c 2021-10-01 16:19:16 UTC (rev 283371)
@@ -36,23 +36,23 @@
#include "pas_deallocate.h"
#include "pas_try_allocate.h"
#include "pas_try_allocate_array.h"
-#include "pas_try_allocate_intrinsic_primitive.h"
+#include "pas_try_allocate_intrinsic.h"
pas_intrinsic_heap_support minalign32_common_primitive_heap_support =
PAS_INTRINSIC_HEAP_SUPPORT_INITIALIZER;
pas_heap minalign32_common_primitive_heap =
- PAS_INTRINSIC_PRIMITIVE_HEAP_INITIALIZER(
+ PAS_INTRINSIC_HEAP_INITIALIZER(
&minalign32_common_primitive_heap,
PAS_SIMPLE_TYPE_CREATE(1, 1),
minalign32_common_primitive_heap_support,
MINALIGN32_HEAP_CONFIG,
- &minalign32_intrinsic_primitive_runtime_config.base);
+ &minalign32_intrinsic_runtime_config.base);
-PAS_CREATE_TRY_ALLOCATE_INTRINSIC_PRIMITIVE(
+PAS_CREATE_TRY_ALLOCATE_INTRINSIC(
test_allocate_common_primitive,
MINALIGN32_HEAP_CONFIG,
- &minalign32_intrinsic_primitive_runtime_config.base,
+ &minalign32_intrinsic_runtime_config.base,
&iso_allocator_counts,
pas_allocation_result_crash_on_error,
&minalign32_common_primitive_heap,
Modified: trunk/Source/bmalloc/libpas/src/libpas/minalign32_heap_config.c (283370 => 283371)
--- trunk/Source/bmalloc/libpas/src/libpas/minalign32_heap_config.c 2021-10-01 15:35:47 UTC (rev 283370)
+++ trunk/Source/bmalloc/libpas/src/libpas/minalign32_heap_config.c 2021-10-01 16:19:16 UTC (rev 283371)
@@ -40,7 +40,7 @@
PAS_BASIC_HEAP_CONFIG_DEFINITIONS(
minalign32, MINALIGN32,
.allocate_page_should_zero = false,
- .intrinsic_primitive_view_cache_capacity = pas_heap_runtime_config_aggressive_view_cache_capacity);
+ .intrinsic_view_cache_capacity = pas_heap_runtime_config_aggressive_view_cache_capacity);
void minalign32_heap_config_activate(void)
{
Modified: trunk/Source/bmalloc/libpas/src/libpas/pagesize64k_heap.c (283370 => 283371)
--- trunk/Source/bmalloc/libpas/src/libpas/pagesize64k_heap.c 2021-10-01 15:35:47 UTC (rev 283370)
+++ trunk/Source/bmalloc/libpas/src/libpas/pagesize64k_heap.c 2021-10-01 16:19:16 UTC (rev 283371)
@@ -36,23 +36,23 @@
#include "pas_deallocate.h"
#include "pas_try_allocate.h"
#include "pas_try_allocate_array.h"
-#include "pas_try_allocate_intrinsic_primitive.h"
+#include "pas_try_allocate_intrinsic.h"
pas_intrinsic_heap_support pagesize64k_common_primitive_heap_support =
PAS_INTRINSIC_HEAP_SUPPORT_INITIALIZER;
pas_heap pagesize64k_common_primitive_heap =
- PAS_INTRINSIC_PRIMITIVE_HEAP_INITIALIZER(
+ PAS_INTRINSIC_HEAP_INITIALIZER(
&pagesize64k_common_primitive_heap,
PAS_SIMPLE_TYPE_CREATE(1, 1),
pagesize64k_common_primitive_heap_support,
PAGESIZE64K_HEAP_CONFIG,
- &pagesize64k_intrinsic_primitive_runtime_config.base);
+ &pagesize64k_intrinsic_runtime_config.base);
-PAS_CREATE_TRY_ALLOCATE_INTRINSIC_PRIMITIVE(
+PAS_CREATE_TRY_ALLOCATE_INTRINSIC(
test_allocate_common_primitive,
PAGESIZE64K_HEAP_CONFIG,
- &pagesize64k_intrinsic_primitive_runtime_config.base,
+ &pagesize64k_intrinsic_runtime_config.base,
&iso_allocator_counts,
pas_allocation_result_crash_on_error,
&pagesize64k_common_primitive_heap,
Modified: trunk/Source/bmalloc/libpas/src/libpas/pagesize64k_heap_config.c (283370 => 283371)
--- trunk/Source/bmalloc/libpas/src/libpas/pagesize64k_heap_config.c 2021-10-01 15:35:47 UTC (rev 283370)
+++ trunk/Source/bmalloc/libpas/src/libpas/pagesize64k_heap_config.c 2021-10-01 16:19:16 UTC (rev 283371)
@@ -40,7 +40,7 @@
PAS_BASIC_HEAP_CONFIG_DEFINITIONS(
pagesize64k, PAGESIZE64K,
.allocate_page_should_zero = false,
- .intrinsic_primitive_view_cache_capacity = pas_heap_runtime_config_zero_view_cache_capacity);
+ .intrinsic_view_cache_capacity = pas_heap_runtime_config_zero_view_cache_capacity);
void pagesize64k_heap_config_activate(void)
{
Modified: trunk/Source/bmalloc/libpas/src/libpas/pas_heap_config_utils.h (283370 => 283371)
--- trunk/Source/bmalloc/libpas/src/libpas/pas_heap_config_utils.h 2021-10-01 15:35:47 UTC (rev 283370)
+++ trunk/Source/bmalloc/libpas/src/libpas/pas_heap_config_utils.h 2021-10-01 16:19:16 UTC (rev 283371)
@@ -350,10 +350,10 @@
PAS_API extern pas_page_header_table name ## _medium_page_header_table; \
PAS_API extern pas_page_header_table name ## _marge_page_header_table; \
PAS_API extern pas_basic_heap_page_caches name ## _page_caches; \
- PAS_API extern pas_basic_heap_runtime_config name ## _intrinsic_primitive_runtime_config; \
+ PAS_API extern pas_basic_heap_runtime_config name ## _intrinsic_runtime_config; \
PAS_API extern pas_basic_heap_runtime_config name ## _primitive_runtime_config; \
PAS_API extern pas_basic_heap_runtime_config name ## _typed_runtime_config; \
- PAS_API extern pas_basic_heap_runtime_config name ## _objc_runtime_config; \
+ PAS_API extern pas_basic_heap_runtime_config name ## _flex_runtime_config; \
\
PAS_API extern pas_basic_heap_config_root_data name ## _root_data; \
\
Modified: trunk/Source/bmalloc/libpas/src/libpas/pas_heap_config_utils_inlines.h (283370 => 283371)
--- trunk/Source/bmalloc/libpas/src/libpas/pas_heap_config_utils_inlines.h 2021-10-01 15:35:47 UTC (rev 283370)
+++ trunk/Source/bmalloc/libpas/src/libpas/pas_heap_config_utils_inlines.h 2021-10-01 16:19:16 UTC (rev 283371)
@@ -48,7 +48,7 @@
typedef struct {
bool allocate_page_should_zero;
- pas_heap_runtime_config_view_cache_capacity_for_object_size_callback intrinsic_primitive_view_cache_capacity;
+ pas_heap_runtime_config_view_cache_capacity_for_object_size_callback intrinsic_view_cache_capacity;
} pas_basic_heap_config_definitions_arguments;
#define PAS_BASIC_HEAP_CONFIG_DEFINITIONS(name, upcase_name, ...) \
@@ -56,7 +56,7 @@
PAS_BASIC_HEAP_PAGE_CACHES_INITIALIZER(PAS_SMALL_SHARED_PAGE_LOG_SHIFT, \
PAS_MEDIUM_SHARED_PAGE_LOG_SHIFT); \
\
- pas_basic_heap_runtime_config name ## _intrinsic_primitive_runtime_config = { \
+ pas_basic_heap_runtime_config name ## _intrinsic_runtime_config = { \
.base = { \
.lookup_kind = pas_segregated_heap_lookup_primitive, \
.sharing_mode = pas_share_pages, \
@@ -63,17 +63,17 @@
.statically_allocated = true, \
.is_part_of_heap = true, \
.directory_size_bound_for_partial_views = \
- PAS_INTRINSIC_PRIMITIVE_BOUND_FOR_PARTIAL_VIEWS, \
+ PAS_INTRINSIC_BOUND_FOR_PARTIAL_VIEWS, \
.directory_size_bound_for_baseline_allocators = \
- PAS_INTRINSIC_PRIMITIVE_BOUND_FOR_BASELINE_ALLOCATORS, \
+ PAS_INTRINSIC_BOUND_FOR_BASELINE_ALLOCATORS, \
.directory_size_bound_for_no_view_cache = \
- PAS_INTRINSIC_PRIMITIVE_BOUND_FOR_NO_VIEW_CACHE, \
+ PAS_INTRINSIC_BOUND_FOR_NO_VIEW_CACHE, \
.max_segregated_object_size = \
- PAS_INTRINSIC_PRIMITIVE_MAX_SEGREGATED_OBJECT_SIZE, \
+ PAS_INTRINSIC_MAX_SEGREGATED_OBJECT_SIZE, \
.max_bitfit_object_size = \
- PAS_INTRINSIC_PRIMITIVE_MAX_BITFIT_OBJECT_SIZE, \
+ PAS_INTRINSIC_MAX_BITFIT_OBJECT_SIZE, \
.view_cache_capacity_for_object_size = \
- ((pas_basic_heap_config_definitions_arguments){__VA_ARGS__}).intrinsic_primitive_view_cache_capacity, \
+ ((pas_basic_heap_config_definitions_arguments){__VA_ARGS__}).intrinsic_view_cache_capacity, \
}, \
.page_caches = &name ## _page_caches \
}; \
@@ -120,7 +120,7 @@
.page_caches = &name ## _page_caches \
}; \
\
- pas_basic_heap_runtime_config name ## _objc_runtime_config = { \
+ pas_basic_heap_runtime_config name ## _flex_runtime_config = { \
.base = { \
.lookup_kind = pas_segregated_heap_lookup_primitive, \
.sharing_mode = pas_share_pages, \
@@ -127,15 +127,15 @@
.statically_allocated = false, \
.is_part_of_heap = true, \
.directory_size_bound_for_partial_views = \
- PAS_OBJC_BOUND_FOR_PARTIAL_VIEWS, \
+ PAS_FLEX_BOUND_FOR_PARTIAL_VIEWS, \
.directory_size_bound_for_baseline_allocators = \
- PAS_OBJC_BOUND_FOR_BASELINE_ALLOCATORS, \
+ PAS_FLEX_BOUND_FOR_BASELINE_ALLOCATORS, \
.directory_size_bound_for_no_view_cache = \
- PAS_OBJC_BOUND_FOR_NO_VIEW_CACHE, \
+ PAS_FLEX_BOUND_FOR_NO_VIEW_CACHE, \
.max_segregated_object_size = \
- PAS_OBJC_MAX_SEGREGATED_OBJECT_SIZE, \
+ PAS_FLEX_MAX_SEGREGATED_OBJECT_SIZE, \
.max_bitfit_object_size = \
- PAS_OBJC_MAX_BITFIT_OBJECT_SIZE, \
+ PAS_FLEX_MAX_BITFIT_OBJECT_SIZE, \
.view_cache_capacity_for_object_size = pas_heap_runtime_config_zero_view_cache_capacity, \
}, \
.page_caches = &name ## _page_caches \
Modified: trunk/Source/bmalloc/libpas/src/libpas/pas_internal_config.h (283370 => 283371)
--- trunk/Source/bmalloc/libpas/src/libpas/pas_internal_config.h 2021-10-01 15:35:47 UTC (rev 283370)
+++ trunk/Source/bmalloc/libpas/src/libpas/pas_internal_config.h 2021-10-01 16:19:16 UTC (rev 283371)
@@ -152,12 +152,18 @@
#define PAS_UTILITY_MAX_SEGREGATED_OBJECT_SIZE UINT_MAX
#define PAS_UTILITY_MAX_BITFIT_OBJECT_SIZE 0
-#define PAS_INTRINSIC_PRIMITIVE_BOUND_FOR_PARTIAL_VIEWS 0
-#define PAS_INTRINSIC_PRIMITIVE_BOUND_FOR_BASELINE_ALLOCATORS 0
-#define PAS_INTRINSIC_PRIMITIVE_BOUND_FOR_NO_VIEW_CACHE 0
-#define PAS_INTRINSIC_PRIMITIVE_MAX_SEGREGATED_OBJECT_SIZE UINT_MAX
-#define PAS_INTRINSIC_PRIMITIVE_MAX_BITFIT_OBJECT_SIZE UINT_MAX
+/* Intrinsic heaps are for global, singleton, process-wide heaps -- so the "not isoheaped" heap, the
+ thing you get from regular malloc. */
+#define PAS_INTRINSIC_BOUND_FOR_PARTIAL_VIEWS 0
+#define PAS_INTRINSIC_BOUND_FOR_BASELINE_ALLOCATORS 0
+#define PAS_INTRINSIC_BOUND_FOR_NO_VIEW_CACHE 0
+#define PAS_INTRINSIC_MAX_SEGREGATED_OBJECT_SIZE UINT_MAX
+#define PAS_INTRINSIC_MAX_BITFIT_OBJECT_SIZE UINT_MAX
+/* This is for heaps that hold primitives but should be kept separate from the main heap. So, the
+ tuning has to be such that we are efficient for lots of small heaps. But, there's no restriction
+ on whether the data in the heap is reused in any particular way -- we run this with a type size
+ of 1. */
#define PAS_PRIMITIVE_BOUND_FOR_PARTIAL_VIEWS 0
#define PAS_PRIMITIVE_BOUND_FOR_BASELINE_ALLOCATORS 0
#define PAS_PRIMITIVE_BOUND_FOR_NO_VIEW_CACHE UINT_MAX
@@ -164,6 +170,11 @@
#define PAS_PRIMITIVE_MAX_SEGREGATED_OBJECT_SIZE UINT_MAX
#define PAS_PRIMITIVE_MAX_BITFIT_OBJECT_SIZE UINT_MAX
+/* This is for heaps that hold typed objects. These objects have a certain size. We may allocate
+ arrays of these objects. The type may tell us an alignment requirement in addition to a size.
+ The alignment requirement is taken together with the minalign argument (the allocator uses
+ whichever is bigger), but it's a bit more optimal to convey alignment using the alignment part
+ of the type than by passing it to minalign. */
#define PAS_TYPED_BOUND_FOR_PARTIAL_VIEWS 10
#define PAS_TYPED_BOUND_FOR_BASELINE_ALLOCATORS 0
#define PAS_TYPED_BOUND_FOR_NO_VIEW_CACHE UINT_MAX
@@ -170,11 +181,16 @@
#define PAS_TYPED_MAX_SEGREGATED_OBJECT_SIZE UINT_MAX
#define PAS_TYPED_MAX_BITFIT_OBJECT_SIZE 0
-#define PAS_OBJC_BOUND_FOR_PARTIAL_VIEWS 10
-#define PAS_OBJC_BOUND_FOR_BASELINE_ALLOCATORS 10
-#define PAS_OBJC_BOUND_FOR_NO_VIEW_CACHE UINT_MAX
-#define PAS_OBJC_MAX_SEGREGATED_OBJECT_SIZE UINT_MAX
-#define PAS_OBJC_MAX_BITFIT_OBJECT_SIZE 0
+/* This is for heaps of flexible array member objects. These are variable-sized objects of a certain
+ type. We should assume that different-sized instances can only be overlapped at the header.
+ Implementing these as segregated heaps is valid since sizes get segregated and different-sized
+ objects will only overlap at the header. However, FIXME: we need flex heaps to use a large heap
+ that won't overlap objects in these heaps as if they were arrays. */
+#define PAS_FLEX_BOUND_FOR_PARTIAL_VIEWS 10
+#define PAS_FLEX_BOUND_FOR_BASELINE_ALLOCATORS 10
+#define PAS_FLEX_BOUND_FOR_NO_VIEW_CACHE UINT_MAX
+#define PAS_FLEX_MAX_SEGREGATED_OBJECT_SIZE UINT_MAX
+#define PAS_FLEX_MAX_BITFIT_OBJECT_SIZE 0
#endif /* PAS_INTERNAL_CONFIG_H */
Modified: trunk/Source/bmalloc/libpas/src/libpas/pas_large_heap.c (283370 => 283371)
--- trunk/Source/bmalloc/libpas/src/libpas/pas_large_heap.c 2021-10-01 15:35:47 UTC (rev 283370)
+++ trunk/Source/bmalloc/libpas/src/libpas/pas_large_heap.c 2021-10-01 16:19:16 UTC (rev 283371)
@@ -43,7 +43,7 @@
void pas_large_heap_construct(pas_large_heap* heap)
{
/* Warning: anything you do here must be duplicated in
- pas_try_allocate_intrinsic_primitive.h. */
+ pas_try_allocate_intrinsic.h. */
pas_fast_large_free_heap_construct(&heap->free_heap);
heap->table_state = pas_heap_table_state_uninitialized;
Modified: trunk/Source/bmalloc/libpas/src/libpas/pas_try_allocate.h (283370 => 283371)
--- trunk/Source/bmalloc/libpas/src/libpas/pas_try_allocate.h 2021-10-01 15:35:47 UTC (rev 283370)
+++ trunk/Source/bmalloc/libpas/src/libpas/pas_try_allocate.h 2021-10-01 16:19:16 UTC (rev 283371)
@@ -40,6 +40,15 @@
PAS_BEGIN_EXTERN_C;
+/* This is for heaps that hold typed objects. These objects have a certain size. We may allocate
+ arrays of these objects, but the entrypoints in this header are for the case where we are allocating
+ just a single instance. We my allocate these objects with any alignment, but the entrypoints in this
+ header are for the case where we are allocating with the alignment that was specified in the
+ heap_ref's type.
+
+ If you want to allocate with nontrivial count (i.e. an array) or nontrivial alignment (i.e. memalign)
+ then use the pas_try_allocate_array.h entrypoints. */
+
typedef struct {
pas_heap_ref* heap_ref;
pas_heap_config config;
Modified: trunk/Source/bmalloc/libpas/src/libpas/pas_try_allocate_array.h (283370 => 283371)
--- trunk/Source/bmalloc/libpas/src/libpas/pas_try_allocate_array.h 2021-10-01 15:35:47 UTC (rev 283370)
+++ trunk/Source/bmalloc/libpas/src/libpas/pas_try_allocate_array.h 2021-10-01 16:19:16 UTC (rev 283371)
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018-2020 Apple Inc. All rights reserved.
+ * Copyright (c) 2018-2021 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -38,6 +38,19 @@
PAS_BEGIN_EXTERN_C;
+/* This is for heaps that hold typed objects. These objects have a certain size. We may allocate
+ arrays of these objects. The type may tell us an alignment requirement in addition to a size.
+ The alignment requirement is taken together with the minalign argument (the allocator uses
+ whichever is bigger), but it's a bit more optimal to convey alignment using the alignment part
+ of the type than by passing it to minalign.
+
+ The entrypoints in this file are for the most general case of allocating in the typed heap. You
+ can pass any count that is >= 1 and any alignment that is >= 1. Note that these entrypoints have
+ optimizations for alignment == 1 and you get the most benefit from those optimizations if you
+ really pass the constant "1" for alignment (this causes the special memalign logic to be statically
+ killed off by the compiler). If you know that count == 1 and alignment == 1, then you're better off
+ using the pas_try_allocate.h entrypoints. */
+
static PAS_ALWAYS_INLINE pas_typed_allocation_result
pas_try_allocate_array_impl(pas_heap_ref* heap_ref,
pas_heap* heap,
Added: trunk/Source/bmalloc/libpas/src/libpas/pas_try_allocate_intrinsic.h (0 => 283371)
--- trunk/Source/bmalloc/libpas/src/libpas/pas_try_allocate_intrinsic.h (rev 0)
+++ trunk/Source/bmalloc/libpas/src/libpas/pas_try_allocate_intrinsic.h 2021-10-01 16:19:16 UTC (rev 283371)
@@ -0,0 +1,338 @@
+/*
+ * Copyright (c) 2019-2021 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef PAS_TRY_ALLOCATE_INTRINSIC_H
+#define PAS_TRY_ALLOCATE_INTRINSIC_H
+
+#include "pas_designated_intrinsic_heap_inlines.h"
+#include "pas_heap.h"
+#include "pas_intrinsic_heap_support.h"
+#include "pas_try_allocate_common.h"
+
+PAS_BEGIN_EXTERN_C;
+
+/* This is for global, singleton, process-wide heaps -- so the "not isoheaped" heap, the thing
+ you get from regular malloc.
+
+ It is possible for a heap_config to have multiple intrinsic heaps, but generally speaking, a
+ heap_config will have a fixed number of intrinsic heaps and they will all be known to libpas
+ ahead of time.
+
+ It is possible for libpas to be configured with multiple heap_configs, so we may also have
+ multiple intrinsic heaps that way (each heap_config may have one intrinsic).
+
+ It is also possible for a heap_config to have no intrinsics. From a functionality standpoint,
+ primitive heaps can do everything that intrinsic heaps do, though primitives are optimized for
+ the possibility that clients of libpas will create any number of them. */
+
+#define PAS_INTRINSIC_SEGREGATED_HEAP_INITIALIZER(parent_heap_ptr, support, passed_runtime_config) { \
+ .runtime_config = (passed_runtime_config), \
+ .basic_size_directory_and_head = PAS_COMPACT_ATOMIC_PTR_INITIALIZER, \
+ .small_index_upper_bound = PAS_NUM_INTRINSIC_SIZE_CLASSES, \
+ .index_to_small_size_directory = (support).index_to_size_directory, \
+ .index_to_small_allocator_index = (support).index_to_allocator_index, \
+ .rare_data = PAS_COMPACT_ATOMIC_PTR_INITIALIZER, \
+ }
+
+#define PAS_INTRINSIC_HEAP_SEGREGATED_HEAP_FIELDS(heap_ptr, intrinsic_support, runtime_config) \
+ .segregated_heap = PAS_INTRINSIC_SEGREGATED_HEAP_INITIALIZER( \
+ heap_ptr, intrinsic_support, runtime_config), \
+
+#define PAS_INTRINSIC_HEAP_INITIALIZER(heap_ptr, primitive_type, intrinsic_support, passed_config, runtime_config) { \
+ .type = (pas_heap_type*)(primitive_type), \
+ PAS_INTRINSIC_HEAP_SEGREGATED_HEAP_FIELDS(heap_ptr, intrinsic_support, runtime_config) \
+ .large_heap = { \
+ .free_heap = PAS_FAST_LARGE_FREE_HEAP_INITIALIZER, \
+ .table_state = pas_heap_table_state_uninitialized, \
+ .index = 0 \
+ }, \
+ .heap_ref = NULL, \
+ .next_heap = PAS_COMPACT_PTR_INITIALIZER, \
+ .config_kind = (passed_config).kind, \
+ }
+
+static PAS_ALWAYS_INLINE pas_allocation_result
+pas_try_allocate_intrinsic_impl_medium_slow_case(
+ pas_heap* heap,
+ size_t size,
+ size_t alignment,
+ pas_intrinsic_heap_support* intrinsic_support,
+ pas_heap_config config,
+ pas_try_allocate_common_fast try_allocate_common_fast,
+ pas_try_allocate_common_slow try_allocate_common_slow,
+ pas_intrinsic_heap_designation_mode designation_mode)
+{
+ static const bool verbose = false;
+
+ size_t aligned_size;
+ size_t index;
+ pas_heap_ref fake_heap_ref;
+ pas_designated_index_result designated_index;
+ pas_thread_local_cache* cache;
+
+ PAS_ASSERT(alignment == 1 || !designation_mode);
+
+ if (verbose)
+ pas_log("in impl_medium_slow_case for %s\n", pas_heap_config_kind_get_string(config.kind));
+
+ if (!pas_is_power_of_2(alignment))
+ return pas_allocation_result_create_failure();
+
+ if (PAS_UNLIKELY(pas_debug_heap_is_enabled(config.kind)))
+ return pas_debug_heap_allocate(size, alignment);
+
+ if (verbose)
+ pas_log("not doing debug heap in impl_medium_slow_case for %s\n", pas_heap_config_kind_get_string(config.kind));
+
+ /* In the non-memalign case, we can happily handle zero-sized allocations with aligned_size
+ being 0. This works because the heap's 0 size class is just a copy of the minalign size
+ class. But we cannot do this properly if the 0 size class has to have some alignment. That's
+ because we expect that for a size class to satisfy some alignment, that size must itself
+ be aligned to that alignment. */
+ if (alignment == 1)
+ aligned_size = size;
+ else if (size < alignment)
+ aligned_size = alignment;
+ else
+ aligned_size = pas_round_up_to_power_of_2(size, alignment);
+
+ index = pas_segregated_heap_index_for_primitive_count(aligned_size,
+ config);
+
+ if (verbose) {
+ pas_log("aligned_size = %zu, index = %zu, alignment = %zu.\n",
+ aligned_size, index, alignment);
+ }
+
+ cache = pas_thread_local_cache_try_get();
+ if (PAS_LIKELY(cache)) {
+ unsigned allocator_index;
+ pas_local_allocator_result allocator_result;
+ pas_local_allocator* allocator;
+
+ designated_index = pas_designated_intrinsic_heap_designated_index(
+ index, designation_mode, config);
+ if (PAS_LIKELY(designated_index.did_succeed)) {
+ allocator_result = pas_local_allocator_result_create_success(
+ pas_thread_local_cache_get_local_allocator_impl(
+ cache,
+ designated_index.index * pas_designated_intrinsic_heap_num_allocator_indices(config)));
+ } else {
+ if (PAS_UNLIKELY(index >= PAS_NUM_INTRINSIC_SIZE_CLASSES)) {
+ allocator_index =
+ pas_segregated_heap_medium_allocator_index_for_index(
+ &heap->segregated_heap,
+ index,
+ pas_segregated_heap_medium_size_directory_search_within_size_class_progression,
+ pas_lock_is_not_held);
+ } else
+ allocator_index = intrinsic_support->index_to_allocator_index[index];
+
+ if (verbose)
+ pas_log("allocator_index = %u.\n", allocator_index);
+
+ allocator_result = pas_thread_local_cache_get_local_allocator(
+ cache, allocator_index, pas_lock_is_not_held);
+ }
+
+ allocator = (pas_local_allocator*)allocator_result.allocator;
+
+ PAS_TESTING_ASSERT(!allocator_result.did_succeed || allocator->object_size >= aligned_size);
+
+ /* This should be specialized out in the non-alignment case because of ALWAYS_INLINE and
+ alignment being the constant 1. */
+ if (alignment != 1 && allocator_result.did_succeed
+ && alignment > pas_local_allocator_alignment(allocator)) {
+ if (verbose) {
+ pas_log("Discarding good allocator result because alignment is inadequate "
+ "(%zu, needed %zu).\n",
+ pas_local_allocator_alignment(allocator), alignment);
+ }
+ allocator_result.did_succeed = false;
+ }
+
+ if (PAS_LIKELY(allocator_result.did_succeed)) {
+ return try_allocate_common_fast(
+ allocator, pas_trivial_size_thunk, (void*)aligned_size, alignment);
+ }
+ }
+
+ fake_heap_ref.type = heap->type;
+ fake_heap_ref.heap = heap;
+ fake_heap_ref.allocator_index = UINT_MAX;
+
+ return try_allocate_common_slow(&fake_heap_ref, aligned_size, aligned_size, alignment);
+}
+
+static PAS_ALWAYS_INLINE pas_allocation_result
+pas_try_allocate_intrinsic_impl_inline_only(
+ size_t size,
+ size_t alignment,
+ pas_intrinsic_heap_support* intrinsic_support,
+ pas_heap_config config,
+ pas_try_allocate_common_fast_inline_only try_allocate_common_fast_inline_only,
+ pas_intrinsic_heap_designation_mode designation_mode)
+{
+ static const bool verbose = false;
+
+ size_t aligned_size;
+ size_t index;
+ pas_designated_index_result designated_index;
+ pas_thread_local_cache* cache;
+ unsigned allocator_index;
+ pas_local_allocator_result allocator_result;
+ pas_local_allocator* allocator;
+
+ PAS_ASSERT(alignment == 1 || !designation_mode);
+
+ if (verbose)
+ pas_log("in impl_inline_only for %s\n", pas_heap_config_kind_get_string(config.kind));
+
+ if (!pas_is_power_of_2(alignment))
+ return pas_allocation_result_create_failure();
+
+ /* In the non-memalign case, we can happily handle zero-sized allocations with aligned_size
+ being 0. This works because the heap's 0 size class is just a copy of the minalign size
+ class. But we cannot do this properly if the 0 size class has to have some alignment. That's
+ because we expect that for a size class to satisfy some alignment, that size must itself
+ be aligned to that alignment. */
+ if (alignment == 1)
+ aligned_size = size;
+ else if (size < alignment)
+ aligned_size = alignment;
+ else
+ aligned_size = pas_round_up_to_power_of_2(size, alignment);
+
+ index = pas_segregated_heap_index_for_primitive_count(aligned_size,
+ config);
+
+ if (verbose) {
+ pas_log("aligned_size = %zu, index = %zu, alignment = %zu.\n",
+ aligned_size, index, alignment);
+ }
+
+ cache = pas_thread_local_cache_try_get();
+ if (PAS_UNLIKELY(!cache))
+ return pas_allocation_result_create_failure();
+
+ designated_index = pas_designated_intrinsic_heap_designated_index(
+ index, designation_mode, config);
+ if (PAS_LIKELY(designated_index.did_succeed)) {
+ allocator_result = pas_local_allocator_result_create_success(
+ pas_thread_local_cache_get_local_allocator_impl(
+ cache,
+ designated_index.index * pas_designated_intrinsic_heap_num_allocator_indices(config)));
+ } else {
+ if (PAS_UNLIKELY(index >= PAS_NUM_INTRINSIC_SIZE_CLASSES))
+ return pas_allocation_result_create_failure();
+
+ allocator_index = intrinsic_support->index_to_allocator_index[index];
+
+ if (verbose)
+ pas_log("allocator_index = %u.\n", allocator_index);
+
+ allocator_result = pas_thread_local_cache_try_get_local_allocator(cache, allocator_index);
+ }
+
+ if (PAS_UNLIKELY(!allocator_result.did_succeed))
+ return pas_allocation_result_create_failure();
+
+ allocator = (pas_local_allocator*)allocator_result.allocator;
+
+ PAS_TESTING_ASSERT(!allocator_result.did_succeed || allocator->object_size >= aligned_size);
+
+ /* This should be specialized out in the non-alignment case because of ALWAYS_INLINE and
+ alignment being the constant 1. */
+ if (alignment != 1 && alignment > pas_local_allocator_alignment(allocator)) {
+ if (verbose) {
+ pas_log("Discarding good allocator result because alignment is inadequate "
+ "(%zu, needed %zu).\n",
+ pas_local_allocator_alignment(allocator), alignment);
+ }
+ return pas_allocation_result_create_failure();
+ }
+
+ return try_allocate_common_fast_inline_only(allocator);
+}
+
+#define PAS_CREATE_TRY_ALLOCATE_INTRINSIC(name, heap_config, runtime_config, allocator_counts, result_filter, heap, heap_support, designation_mode) \
+ PAS_CREATE_TRY_ALLOCATE_COMMON( \
+ name ## _impl, \
+ pas_fake_heap_ref_kind, \
+ (heap_config), \
+ (runtime_config), \
+ (allocator_counts), \
+ pas_force_count_lookup, \
+ (result_filter)); \
+ \
+ static PAS_NEVER_INLINE pas_allocation_result \
+ name ## _medium_slow_case(size_t size, size_t alignment) \
+ { \
+ return pas_try_allocate_intrinsic_impl_medium_slow_case( \
+ (heap), size, alignment, (heap_support), (heap_config), \
+ name ## _impl_fast, name ## _impl_slow, (designation_mode)); \
+ } \
+ \
+ static PAS_ALWAYS_INLINE pas_allocation_result name ## _inline_only(size_t size, size_t alignment) \
+ { \
+ return pas_try_allocate_intrinsic_impl_inline_only( \
+ size, alignment, (heap_support), (heap_config), \
+ name ## _impl_fast_inline_only, (designation_mode)); \
+ } \
+ \
+ static PAS_ALWAYS_INLINE pas_allocation_result name(size_t size, size_t alignment) \
+ { \
+ static const bool verbose = false; \
+ pas_allocation_result result; \
+ result = name ## _inline_only(size, alignment); \
+ if (PAS_LIKELY(result.did_succeed)) { \
+ if (verbose) \
+ pas_log("Returning successful result (begin = %p)\n", (void*)result.begin); \
+ return result; \
+ } \
+ return name ## _medium_slow_case(size, alignment); \
+ } \
+ \
+ static PAS_UNUSED PAS_NEVER_INLINE pas_allocation_result \
+ name ## _for_realloc(size_t size) \
+ { \
+ static const bool verbose = false; \
+ pas_allocation_result result = name(size, 1); \
+ if (verbose) \
+ pas_log("result.begin = %p\n", result.begin); \
+ return result; \
+ } \
+ \
+ struct pas_dummy
+
+typedef pas_allocation_result (*pas_try_allocate_intrinsic)(size_t size,
+ size_t alignment);
+
+typedef pas_allocation_result (*pas_try_allocate_intrinsic_for_realloc)(size_t size);
+
+PAS_END_EXTERN_C;
+
+#endif /* PAS_TRY_ALLOCATE_INTRINSIC_H */
+
Deleted: trunk/Source/bmalloc/libpas/src/libpas/pas_try_allocate_intrinsic_primitive.h (283370 => 283371)
--- trunk/Source/bmalloc/libpas/src/libpas/pas_try_allocate_intrinsic_primitive.h 2021-10-01 15:35:47 UTC (rev 283370)
+++ trunk/Source/bmalloc/libpas/src/libpas/pas_try_allocate_intrinsic_primitive.h 2021-10-01 16:19:16 UTC (rev 283371)
@@ -1,324 +0,0 @@
-/*
- * Copyright (c) 2019-2021 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef PAS_TRY_ALLOCATE_INTRINSIC_PRIMITIVE_H
-#define PAS_TRY_ALLOCATE_INTRINSIC_PRIMITIVE_H
-
-#include "pas_designated_intrinsic_heap_inlines.h"
-#include "pas_heap.h"
-#include "pas_intrinsic_heap_support.h"
-#include "pas_try_allocate_common.h"
-
-PAS_BEGIN_EXTERN_C;
-
-#define PAS_INTRINSIC_SEGREGATED_HEAP_INITIALIZER(parent_heap_ptr, support, passed_runtime_config) { \
- .runtime_config = (passed_runtime_config), \
- .basic_size_directory_and_head = PAS_COMPACT_ATOMIC_PTR_INITIALIZER, \
- .small_index_upper_bound = PAS_NUM_INTRINSIC_SIZE_CLASSES, \
- .index_to_small_size_directory = (support).index_to_size_directory, \
- .index_to_small_allocator_index = (support).index_to_allocator_index, \
- .rare_data = PAS_COMPACT_ATOMIC_PTR_INITIALIZER, \
- }
-
-#define PAS_INTRINSIC_PRIMITIVE_HEAP_SEGREGATED_HEAP_FIELDS(heap_ptr, intrinsic_support, runtime_config) \
- .segregated_heap = PAS_INTRINSIC_SEGREGATED_HEAP_INITIALIZER( \
- heap_ptr, intrinsic_support, runtime_config), \
-
-#define PAS_INTRINSIC_PRIMITIVE_HEAP_INITIALIZER(heap_ptr, primitive_type, intrinsic_support, passed_config, runtime_config) { \
- .type = (pas_heap_type*)(primitive_type), \
- PAS_INTRINSIC_PRIMITIVE_HEAP_SEGREGATED_HEAP_FIELDS(heap_ptr, intrinsic_support, runtime_config) \
- .large_heap = { \
- .free_heap = PAS_FAST_LARGE_FREE_HEAP_INITIALIZER, \
- .table_state = pas_heap_table_state_uninitialized, \
- .index = 0 \
- }, \
- .heap_ref = NULL, \
- .next_heap = PAS_COMPACT_PTR_INITIALIZER, \
- .config_kind = (passed_config).kind, \
- }
-
-static PAS_ALWAYS_INLINE pas_allocation_result
-pas_try_allocate_intrinsic_primitive_impl_medium_slow_case(
- pas_heap* heap,
- size_t size,
- size_t alignment,
- pas_intrinsic_heap_support* intrinsic_support,
- pas_heap_config config,
- pas_try_allocate_common_fast try_allocate_common_fast,
- pas_try_allocate_common_slow try_allocate_common_slow,
- pas_intrinsic_heap_designation_mode designation_mode)
-{
- static const bool verbose = false;
-
- size_t aligned_size;
- size_t index;
- pas_heap_ref fake_heap_ref;
- pas_designated_index_result designated_index;
- pas_thread_local_cache* cache;
-
- PAS_ASSERT(alignment == 1 || !designation_mode);
-
- if (verbose)
- pas_log("in impl_medium_slow_case for %s\n", pas_heap_config_kind_get_string(config.kind));
-
- if (!pas_is_power_of_2(alignment))
- return pas_allocation_result_create_failure();
-
- if (PAS_UNLIKELY(pas_debug_heap_is_enabled(config.kind)))
- return pas_debug_heap_allocate(size, alignment);
-
- if (verbose)
- pas_log("not doing debug heap in impl_medium_slow_case for %s\n", pas_heap_config_kind_get_string(config.kind));
-
- /* In the non-memalign case, we can happily handle zero-sized allocations with aligned_size
- being 0. This works because the heap's 0 size class is just a copy of the minalign size
- class. But we cannot do this properly if the 0 size class has to have some alignment. That's
- because we expect that for a size class to satisfy some alignment, that size must itself
- be aligned to that alignment. */
- if (alignment == 1)
- aligned_size = size;
- else if (size < alignment)
- aligned_size = alignment;
- else
- aligned_size = pas_round_up_to_power_of_2(size, alignment);
-
- index = pas_segregated_heap_index_for_primitive_count(aligned_size,
- config);
-
- if (verbose) {
- pas_log("aligned_size = %zu, index = %zu, alignment = %zu.\n",
- aligned_size, index, alignment);
- }
-
- cache = pas_thread_local_cache_try_get();
- if (PAS_LIKELY(cache)) {
- unsigned allocator_index;
- pas_local_allocator_result allocator_result;
- pas_local_allocator* allocator;
-
- designated_index = pas_designated_intrinsic_heap_designated_index(
- index, designation_mode, config);
- if (PAS_LIKELY(designated_index.did_succeed)) {
- allocator_result = pas_local_allocator_result_create_success(
- pas_thread_local_cache_get_local_allocator_impl(
- cache,
- designated_index.index * pas_designated_intrinsic_heap_num_allocator_indices(config)));
- } else {
- if (PAS_UNLIKELY(index >= PAS_NUM_INTRINSIC_SIZE_CLASSES)) {
- allocator_index =
- pas_segregated_heap_medium_allocator_index_for_index(
- &heap->segregated_heap,
- index,
- pas_segregated_heap_medium_size_directory_search_within_size_class_progression,
- pas_lock_is_not_held);
- } else
- allocator_index = intrinsic_support->index_to_allocator_index[index];
-
- if (verbose)
- pas_log("allocator_index = %u.\n", allocator_index);
-
- allocator_result = pas_thread_local_cache_get_local_allocator(
- cache, allocator_index, pas_lock_is_not_held);
- }
-
- allocator = (pas_local_allocator*)allocator_result.allocator;
-
- PAS_TESTING_ASSERT(!allocator_result.did_succeed || allocator->object_size >= aligned_size);
-
- /* This should be specialized out in the non-alignment case because of ALWAYS_INLINE and
- alignment being the constant 1. */
- if (alignment != 1 && allocator_result.did_succeed
- && alignment > pas_local_allocator_alignment(allocator)) {
- if (verbose) {
- pas_log("Discarding good allocator result because alignment is inadequate "
- "(%zu, needed %zu).\n",
- pas_local_allocator_alignment(allocator), alignment);
- }
- allocator_result.did_succeed = false;
- }
-
- if (PAS_LIKELY(allocator_result.did_succeed)) {
- return try_allocate_common_fast(
- allocator, pas_trivial_size_thunk, (void*)aligned_size, alignment);
- }
- }
-
- fake_heap_ref.type = heap->type;
- fake_heap_ref.heap = heap;
- fake_heap_ref.allocator_index = UINT_MAX;
-
- return try_allocate_common_slow(&fake_heap_ref, aligned_size, aligned_size, alignment);
-}
-
-static PAS_ALWAYS_INLINE pas_allocation_result
-pas_try_allocate_intrinsic_primitive_impl_inline_only(
- size_t size,
- size_t alignment,
- pas_intrinsic_heap_support* intrinsic_support,
- pas_heap_config config,
- pas_try_allocate_common_fast_inline_only try_allocate_common_fast_inline_only,
- pas_intrinsic_heap_designation_mode designation_mode)
-{
- static const bool verbose = false;
-
- size_t aligned_size;
- size_t index;
- pas_designated_index_result designated_index;
- pas_thread_local_cache* cache;
- unsigned allocator_index;
- pas_local_allocator_result allocator_result;
- pas_local_allocator* allocator;
-
- PAS_ASSERT(alignment == 1 || !designation_mode);
-
- if (verbose)
- pas_log("in impl_inline_only for %s\n", pas_heap_config_kind_get_string(config.kind));
-
- if (!pas_is_power_of_2(alignment))
- return pas_allocation_result_create_failure();
-
- /* In the non-memalign case, we can happily handle zero-sized allocations with aligned_size
- being 0. This works because the heap's 0 size class is just a copy of the minalign size
- class. But we cannot do this properly if the 0 size class has to have some alignment. That's
- because we expect that for a size class to satisfy some alignment, that size must itself
- be aligned to that alignment. */
- if (alignment == 1)
- aligned_size = size;
- else if (size < alignment)
- aligned_size = alignment;
- else
- aligned_size = pas_round_up_to_power_of_2(size, alignment);
-
- index = pas_segregated_heap_index_for_primitive_count(aligned_size,
- config);
-
- if (verbose) {
- pas_log("aligned_size = %zu, index = %zu, alignment = %zu.\n",
- aligned_size, index, alignment);
- }
-
- cache = pas_thread_local_cache_try_get();
- if (PAS_UNLIKELY(!cache))
- return pas_allocation_result_create_failure();
-
- designated_index = pas_designated_intrinsic_heap_designated_index(
- index, designation_mode, config);
- if (PAS_LIKELY(designated_index.did_succeed)) {
- allocator_result = pas_local_allocator_result_create_success(
- pas_thread_local_cache_get_local_allocator_impl(
- cache,
- designated_index.index * pas_designated_intrinsic_heap_num_allocator_indices(config)));
- } else {
- if (PAS_UNLIKELY(index >= PAS_NUM_INTRINSIC_SIZE_CLASSES))
- return pas_allocation_result_create_failure();
-
- allocator_index = intrinsic_support->index_to_allocator_index[index];
-
- if (verbose)
- pas_log("allocator_index = %u.\n", allocator_index);
-
- allocator_result = pas_thread_local_cache_try_get_local_allocator(cache, allocator_index);
- }
-
- if (PAS_UNLIKELY(!allocator_result.did_succeed))
- return pas_allocation_result_create_failure();
-
- allocator = (pas_local_allocator*)allocator_result.allocator;
-
- PAS_TESTING_ASSERT(!allocator_result.did_succeed || allocator->object_size >= aligned_size);
-
- /* This should be specialized out in the non-alignment case because of ALWAYS_INLINE and
- alignment being the constant 1. */
- if (alignment != 1 && alignment > pas_local_allocator_alignment(allocator)) {
- if (verbose) {
- pas_log("Discarding good allocator result because alignment is inadequate "
- "(%zu, needed %zu).\n",
- pas_local_allocator_alignment(allocator), alignment);
- }
- return pas_allocation_result_create_failure();
- }
-
- return try_allocate_common_fast_inline_only(allocator);
-}
-
-#define PAS_CREATE_TRY_ALLOCATE_INTRINSIC_PRIMITIVE(name, heap_config, runtime_config, allocator_counts, result_filter, heap, heap_support, designation_mode) \
- PAS_CREATE_TRY_ALLOCATE_COMMON( \
- name ## _impl, \
- pas_fake_heap_ref_kind, \
- (heap_config), \
- (runtime_config), \
- (allocator_counts), \
- pas_force_count_lookup, \
- (result_filter)); \
- \
- static PAS_NEVER_INLINE pas_allocation_result \
- name ## _medium_slow_case(size_t size, size_t alignment) \
- { \
- return pas_try_allocate_intrinsic_primitive_impl_medium_slow_case( \
- (heap), size, alignment, (heap_support), (heap_config), \
- name ## _impl_fast, name ## _impl_slow, (designation_mode)); \
- } \
- \
- static PAS_ALWAYS_INLINE pas_allocation_result name ## _inline_only(size_t size, size_t alignment) \
- { \
- return pas_try_allocate_intrinsic_primitive_impl_inline_only( \
- size, alignment, (heap_support), (heap_config), \
- name ## _impl_fast_inline_only, (designation_mode)); \
- } \
- \
- static PAS_ALWAYS_INLINE pas_allocation_result name(size_t size, size_t alignment) \
- { \
- static const bool verbose = false; \
- pas_allocation_result result; \
- result = name ## _inline_only(size, alignment); \
- if (PAS_LIKELY(result.did_succeed)) { \
- if (verbose) \
- pas_log("Returning successful result (begin = %p)\n", (void*)result.begin); \
- return result; \
- } \
- return name ## _medium_slow_case(size, alignment); \
- } \
- \
- static PAS_UNUSED PAS_NEVER_INLINE pas_allocation_result \
- name ## _for_realloc(size_t size) \
- { \
- static const bool verbose = false; \
- pas_allocation_result result = name(size, 1); \
- if (verbose) \
- pas_log("result.begin = %p\n", result.begin); \
- return result; \
- } \
- \
- struct pas_dummy
-
-typedef pas_allocation_result (*pas_try_allocate_intrinsic_primitive)(size_t size,
- size_t alignment);
-
-typedef pas_allocation_result (*pas_try_allocate_intrinsic_primitive_for_realloc)(size_t size);
-
-PAS_END_EXTERN_C;
-
-#endif /* PAS_TRY_ALLOCATE_INTRINSIC_PRIMITIVE_H */
-
Modified: trunk/Source/bmalloc/libpas/src/libpas/pas_try_allocate_primitive.h (283370 => 283371)
--- trunk/Source/bmalloc/libpas/src/libpas/pas_try_allocate_primitive.h 2021-10-01 15:35:47 UTC (rev 283370)
+++ trunk/Source/bmalloc/libpas/src/libpas/pas_try_allocate_primitive.h 2021-10-01 16:19:16 UTC (rev 283371)
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019-2020 Apple Inc. All rights reserved.
+ * Copyright (c) 2019-2021 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -37,6 +37,24 @@
PAS_BEGIN_EXTERN_C;
+/* This header provides entrypoints for both primitive and flex heaps. You select the mode by passing
+ either the primitive heap_runtuime_config or the flex heap_runtime_config.
+
+ Primitive heaps are for objects that should be kept separate from the main heap but that otherwise
+ don't have any interesting type. So, they are like intrinsic heaps, but the tuning has to be such
+ that we are efficient for lots of small heaps. But, there's no restriction on whether the data in
+ the heap is reused in any particular way -- we run this with a type size of 1.
+
+ These have all the functionality of intrinsic heaps but are tuned to allow for there to be a
+ variable number of heaps. While libpas knows about every intrinsic heap that a heap_config may
+ have, libpas allows primitive heaps to be created by libpas clients.
+
+ Flex heaps are for flexible array members. Currently we tune them almost exactly like primitive
+ heaps except that bitfit is disabled for flex.
+
+ FIXME: Flex heaps should provide stronger isolation in the large heap. That can be achieved while
+ still keeping these entrypoints. It's just a different large heap reuse policy. */
+
static PAS_ALWAYS_INLINE pas_allocation_result
pas_try_allocate_primitive_impl(pas_primitive_heap_ref* heap_ref,
size_t size,
Modified: trunk/Source/bmalloc/libpas/src/libpas/pas_try_reallocate.h (283370 => 283371)
--- trunk/Source/bmalloc/libpas/src/libpas/pas_try_reallocate.h 2021-10-01 15:35:47 UTC (rev 283370)
+++ trunk/Source/bmalloc/libpas/src/libpas/pas_try_reallocate.h 2021-10-01 16:19:16 UTC (rev 283371)
@@ -33,7 +33,7 @@
#include "pas_reallocate_heap_teleport_rule.h"
#include "pas_try_allocate.h"
#include "pas_try_allocate_array.h"
-#include "pas_try_allocate_intrinsic_primitive.h"
+#include "pas_try_allocate_intrinsic.h"
#include "pas_try_allocate_primitive.h"
PAS_BEGIN_EXTERN_C;
@@ -367,40 +367,40 @@
}
typedef struct {
- pas_try_allocate_intrinsic_primitive_for_realloc try_allocate_intrinsic_primitive;
-} pas_try_reallocate_intrinsic_primitive_allocate_data;
+ pas_try_allocate_intrinsic_for_realloc try_allocate_intrinsic;
+} pas_try_reallocate_intrinsic_allocate_data;
static PAS_ALWAYS_INLINE pas_typed_allocation_result
-pas_try_reallocate_intrinsic_primitive_allocate_callback(
+pas_try_reallocate_intrinsic_allocate_callback(
pas_heap* heap,
size_t new_count,
void* arg)
{
- pas_try_reallocate_intrinsic_primitive_allocate_data* data;
+ pas_try_reallocate_intrinsic_allocate_data* data;
PAS_UNUSED_PARAM(heap);
- data = ""
+ data = ""
return pas_typed_allocation_result_create_with_intrinsic_allocation_result(
- data->try_allocate_intrinsic_primitive(new_count),
+ data->try_allocate_intrinsic(new_count),
NULL,
new_count);
}
static PAS_ALWAYS_INLINE pas_allocation_result
-pas_try_reallocate_intrinsic_primitive(
+pas_try_reallocate_intrinsic(
void* old_ptr,
pas_heap* heap,
size_t new_size,
pas_heap_config config,
- pas_try_allocate_intrinsic_primitive_for_realloc try_allocate_intrinsic_primitive,
+ pas_try_allocate_intrinsic_for_realloc try_allocate_intrinsic,
pas_reallocate_heap_teleport_rule teleport_rule,
pas_reallocate_free_mode free_mode)
{
- pas_try_reallocate_intrinsic_primitive_allocate_data data;
+ pas_try_reallocate_intrinsic_allocate_data data;
- data.try_allocate_intrinsic_primitive = try_allocate_intrinsic_primitive;
+ data.try_allocate_intrinsic = try_allocate_intrinsic;
return pas_typed_allocation_result_as_intrinsic_allocation_result(
pas_try_reallocate(
@@ -410,7 +410,7 @@
config,
teleport_rule,
free_mode,
- pas_try_reallocate_intrinsic_primitive_allocate_callback,
+ pas_try_reallocate_intrinsic_allocate_callback,
&data));
}
Modified: trunk/Source/bmalloc/libpas/src/libpas/thingy_heap.c (283370 => 283371)
--- trunk/Source/bmalloc/libpas/src/libpas/thingy_heap.c 2021-10-01 15:35:47 UTC (rev 283370)
+++ trunk/Source/bmalloc/libpas/src/libpas/thingy_heap.c 2021-10-01 16:19:16 UTC (rev 283371)
@@ -35,7 +35,7 @@
#include "pas_get_allocation_size.h"
#include "pas_try_allocate.h"
#include "pas_try_allocate_array.h"
-#include "pas_try_allocate_intrinsic_primitive.h"
+#include "pas_try_allocate_intrinsic.h"
#include "pas_try_reallocate.h"
#include "thingy_heap_config.h"
@@ -44,29 +44,29 @@
pas_intrinsic_heap_support thingy_primitive_heap_support = PAS_INTRINSIC_HEAP_SUPPORT_INITIALIZER;
pas_heap thingy_primitive_heap =
- PAS_INTRINSIC_PRIMITIVE_HEAP_INITIALIZER(
+ PAS_INTRINSIC_HEAP_INITIALIZER(
&thingy_primitive_heap,
THINGY_TYPE_PRIMITIVE,
thingy_primitive_heap_support,
THINGY_HEAP_CONFIG,
- &thingy_intrinsic_primitive_runtime_config.base);
+ &thingy_intrinsic_runtime_config.base);
pas_intrinsic_heap_support thingy_utility_heap_support = PAS_INTRINSIC_HEAP_SUPPORT_INITIALIZER;
pas_heap thingy_utility_heap =
- PAS_INTRINSIC_PRIMITIVE_HEAP_INITIALIZER(
+ PAS_INTRINSIC_HEAP_INITIALIZER(
&thingy_utility_heap,
THINGY_TYPE_PRIMITIVE,
thingy_utility_heap_support,
THINGY_HEAP_CONFIG,
- &thingy_intrinsic_primitive_runtime_config.base);
+ &thingy_intrinsic_runtime_config.base);
pas_allocator_counts thingy_allocator_counts;
-PAS_CREATE_TRY_ALLOCATE_INTRINSIC_PRIMITIVE(
+PAS_CREATE_TRY_ALLOCATE_INTRINSIC(
try_allocate_primitive,
THINGY_HEAP_CONFIG,
- &thingy_intrinsic_primitive_runtime_config.base,
+ &thingy_intrinsic_runtime_config.base,
&thingy_allocator_counts,
pas_allocation_result_identity,
&thingy_primitive_heap,
@@ -90,7 +90,7 @@
void* thingy_try_reallocate_primitive(void* old_ptr, size_t new_size)
{
- return (void*)pas_try_reallocate_intrinsic_primitive(
+ return (void*)pas_try_reallocate_intrinsic(
old_ptr,
&thingy_primitive_heap,
new_size,
@@ -165,10 +165,10 @@
&thingy_typed_runtime_config.base);
}
-PAS_CREATE_TRY_ALLOCATE_INTRINSIC_PRIMITIVE(
+PAS_CREATE_TRY_ALLOCATE_INTRINSIC(
utility_heap_allocate,
THINGY_HEAP_CONFIG,
- &thingy_intrinsic_primitive_runtime_config.base,
+ &thingy_intrinsic_runtime_config.base,
&thingy_allocator_counts,
pas_allocation_result_crash_on_error,
&thingy_utility_heap,
Modified: trunk/Source/bmalloc/libpas/src/libpas/thingy_heap_config.c (283370 => 283371)
--- trunk/Source/bmalloc/libpas/src/libpas/thingy_heap_config.c 2021-10-01 15:35:47 UTC (rev 283370)
+++ trunk/Source/bmalloc/libpas/src/libpas/thingy_heap_config.c 2021-10-01 16:19:16 UTC (rev 283371)
@@ -38,7 +38,7 @@
PAS_BASIC_HEAP_CONFIG_DEFINITIONS(
thingy, THINGY,
.allocate_page_should_zero = true,
- .intrinsic_primitive_view_cache_capacity = pas_heap_runtime_config_zero_view_cache_capacity);
+ .intrinsic_view_cache_capacity = pas_heap_runtime_config_zero_view_cache_capacity);
#endif /* PAS_ENABLE_THINGY */
Modified: trunk/Source/bmalloc/libpas/src/test/IsoHeapChaosTests.cpp (283370 => 283371)
--- trunk/Source/bmalloc/libpas/src/test/IsoHeapChaosTests.cpp 2021-10-01 15:35:47 UTC (rev 283370)
+++ trunk/Source/bmalloc/libpas/src/test/IsoHeapChaosTests.cpp 2021-10-01 16:19:16 UTC (rev 283371)
@@ -1063,7 +1063,7 @@
selectedHeapConfig = &bmalloc_heap_config;
selectedAllocateCommonPrimitive = bmalloc_allocate;
selectedAllocate = bmalloc_iso_allocate;
- selectedAllocateArray = nullptr;
+ selectedAllocateArray = bmalloc_iso_allocate_array_with_alignment;
selectedDeallocate = bmalloc_deallocate;
selectedCommonPrimitiveHeap = &bmalloc_common_primitive_heap;
selectedHeapRefGetHeap = bmalloc_heap_ref_get_heap;
Modified: trunk/Source/bmalloc/libpas/src/test/TestHarness.cpp (283370 => 283371)
--- trunk/Source/bmalloc/libpas/src/test/TestHarness.cpp 2021-10-01 15:35:47 UTC (rev 283370)
+++ trunk/Source/bmalloc/libpas/src/test/TestHarness.cpp 2021-10-01 16:19:16 UTC (rev 283371)
@@ -85,10 +85,10 @@
};
#define FOR_EACH_RUNTIME_CONFIG(name, callback) ({ \
- (callback)(name ## _intrinsic_primitive_runtime_config.base); \
+ (callback)(name ## _intrinsic_runtime_config.base); \
(callback)(name ## _primitive_runtime_config.base); \
(callback)(name ## _typed_runtime_config.base); \
- (callback)(name ## _objc_runtime_config.base); \
+ (callback)(name ## _flex_runtime_config.base); \
})
RuntimeConfigTestScope::RuntimeConfigTestScope(