Loading...
--- libmalloc/libmalloc-140.50.6/src/magazine_malloc.h
+++ libmalloc/libmalloc-166.251.2/src/magazine_malloc.h
@@ -38,9 +38,20 @@
 boolean_t
 scalable_zone_statistics(malloc_zone_t *zone, malloc_statistics_t *stats, unsigned subzone);
 
-MALLOC_NOINLINE __printflike(5, 6)
-void
-szone_error(uint32_t debug_flags, int is_corruption, const char *msg, const void *ptr, const char *fmt, ...);
+MALLOC_NOEXPORT
+extern int max_magazines;
+
+MALLOC_NOEXPORT
+extern int max_medium_magazines;
+
+MALLOC_NOEXPORT
+extern int recirc_retained_regions;
+
+MALLOC_NOEXPORT
+extern bool magazine_medium_enabled;
+
+MALLOC_NOEXPORT
+extern uint64_t magazine_medium_active_threshold;
 
 // MARK: magazine_malloc utility functions
 
@@ -85,6 +96,10 @@
 szone_pressure_relief(szone_t *szone, size_t goal);
 
 MALLOC_NOEXPORT
+boolean_t
+szone_claimed_address(szone_t *szone, void *ptr);
+
+MALLOC_NOEXPORT
 void *
 szone_realloc(szone_t *szone, void *ptr, size_t new_size);
 
@@ -104,7 +119,8 @@
 
 MALLOC_NOEXPORT
 boolean_t
-tiny_check_region(rack_t *rack, region_t region);
+tiny_check_region(rack_t *rack, region_t region, size_t region_index,
+		unsigned counter);
 
 MALLOC_NOEXPORT
 void
@@ -116,7 +132,7 @@
 
 MALLOC_NOEXPORT
 boolean_t
-tiny_free_list_check(rack_t *rack, grain_t slot);
+tiny_free_list_check(rack_t *rack, grain_t slot, unsigned counter);
 
 MALLOC_NOEXPORT
 boolean_t
@@ -148,6 +164,10 @@
 tiny_memalign(szone_t *szone, size_t alignment, size_t size, size_t span);
 
 MALLOC_NOEXPORT
+boolean_t
+tiny_claimed_address(rack_t *rack, void *ptr);
+
+MALLOC_NOEXPORT
 void *
 tiny_try_shrink_in_place(rack_t *rack, void *ptr, size_t old_size, size_t new_good_size);
 
@@ -164,6 +184,14 @@
 tiny_size(rack_t *rack, const void *ptr);
 
 MALLOC_NOEXPORT
+unsigned
+tiny_batch_malloc(szone_t *szone, size_t size, void **results, unsigned count);
+
+MALLOC_NOEXPORT
+void
+tiny_batch_free(szone_t *szone, void **to_be_freed, unsigned count);
+
+MALLOC_NOEXPORT
 void
 print_tiny_free_list(rack_t *rack);
 
@@ -171,11 +199,18 @@
 void
 print_tiny_region(boolean_t verbose, region_t region, size_t bytes_at_start, size_t bytes_at_end);
 
+#if CONFIG_MADVISE_PRESSURE_RELIEF
+MALLOC_NOEXPORT
+void
+tiny_madvise_pressure_relief(rack_t *rack);
+#endif // CONFIG_MADVISE_PRESSURE_RELIEF
+
 // MARK: small region allocation functions
 
 MALLOC_NOEXPORT
 boolean_t
-small_check_region(rack_t *rack, region_t region);
+small_check_region(rack_t *rack, region_t region, size_t region_index,
+		unsigned counter);
 
 MALLOC_NOEXPORT
 void
@@ -187,7 +222,7 @@
 
 MALLOC_NOEXPORT
 boolean_t
-small_free_list_check(rack_t *rack, grain_t slot);
+small_free_list_check(rack_t *rack, grain_t slot, unsigned counter);
 
 MALLOC_NOEXPORT
 size_t
@@ -211,6 +246,10 @@
 small_memalign(szone_t *szone, size_t alignment, size_t size, size_t span);
 
 MALLOC_NOEXPORT
+boolean_t
+small_claimed_address(rack_t *rack, void *ptr);
+
+MALLOC_NOEXPORT
 void *
 small_try_shrink_in_place(rack_t *rack, void *ptr, size_t old_size, size_t new_good_size);
 
@@ -233,6 +272,90 @@
 MALLOC_NOEXPORT
 void
 print_small_region(szone_t *szone, boolean_t verbose, region_t region, size_t bytes_at_start, size_t bytes_at_end);
+
+#if CONFIG_MADVISE_PRESSURE_RELIEF
+MALLOC_NOEXPORT
+void
+small_madvise_pressure_relief(rack_t *rack);
+#endif // CONFIG_MADVISE_PRESSURE_RELIEF
+
+// MARK: medium region allocation functions
+
+MALLOC_NOEXPORT
+boolean_t
+medium_check_region(rack_t *rack, region_t region, size_t region_index,
+		unsigned counter);
+
+MALLOC_NOEXPORT
+void
+medium_finalize_region(rack_t *rack, magazine_t *medium_mag_ptr);
+
+MALLOC_NOEXPORT
+int
+medium_free_detach_region(rack_t *rack, magazine_t *medium_mag_ptr, region_t r);
+
+MALLOC_NOEXPORT
+boolean_t
+medium_free_list_check(rack_t *rack, grain_t slot, unsigned counter);
+
+MALLOC_NOEXPORT
+size_t
+medium_free_reattach_region(rack_t *rack, magazine_t *medium_mag_ptr, region_t r);
+
+MALLOC_NOEXPORT
+void
+medium_free_scan_madvise_free(rack_t *rack, magazine_t *depot_ptr, region_t r);
+
+MALLOC_NOEXPORT
+kern_return_t
+medium_in_use_enumerator(task_t task, void *context, unsigned type_mask, szone_t *szone, memory_reader_t reader,
+		vm_range_recorder_t recorder);
+
+MALLOC_NOEXPORT
+void *
+medium_malloc_should_clear(rack_t *rack, msize_t msize, boolean_t cleared_requested);
+
+MALLOC_NOEXPORT
+void *
+medium_memalign(szone_t *szone, size_t alignment, size_t size, size_t span);
+
+MALLOC_NOEXPORT
+boolean_t
+medium_claimed_address(rack_t *rack, void *ptr);
+
+MALLOC_NOEXPORT
+void *
+medium_try_shrink_in_place(rack_t *rack, void *ptr, size_t old_size, size_t new_good_size);
+
+MALLOC_NOEXPORT
+boolean_t
+medium_try_realloc_in_place(rack_t *rack, void *ptr, size_t old_size, size_t new_size);
+
+MALLOC_NOEXPORT
+void
+free_medium(rack_t *rack, void *ptr, region_t medium_region, size_t known_size);
+
+MALLOC_NOEXPORT
+size_t
+medium_size(rack_t *rack, const void *ptr);
+
+MALLOC_NOEXPORT
+void
+print_medium_free_list(rack_t *rack);
+
+MALLOC_NOEXPORT
+void
+print_medium_region(szone_t *szone, boolean_t verbose, region_t region, size_t bytes_at_start, size_t bytes_at_end);
+
+MALLOC_NOEXPORT
+void
+print_medium_region_vis(szone_t *szone, region_t region);
+
+#if CONFIG_MADVISE_PRESSURE_RELIEF
+MALLOC_NOEXPORT
+void
+medium_madvise_pressure_relief(rack_t *rack);
+#endif // CONFIG_MADVISE_PRESSURE_RELIEF
 
 // MARK: large region allocator functions
 
@@ -266,6 +389,10 @@
 large_malloc(szone_t *szone, size_t num_kernel_pages, unsigned char alignment, boolean_t cleared_requested);
 
 MALLOC_NOEXPORT
+boolean_t
+large_claimed_address(szone_t *szone, void *ptr);
+
+MALLOC_NOEXPORT
 void *
 szone_malloc_should_clear(szone_t *szone, size_t size, boolean_t cleared_requested);
 
@@ -273,6 +400,7 @@
 
 #define MALLOC_STOCK_LOGGING_LITE_ZONE_NAME "MallocStackLoggingLiteZone"
 
+// These enable/disable stack logging lite for malloc allocations, not VM-only lite mode
 MALLOC_NOEXPORT
 void
 enable_stack_logging_lite();