Loading...
--- libmalloc/libmalloc-140.40.1/src/base.h
+++ libmalloc/libmalloc-409.60.6/src/base.h
@@ -47,8 +47,8 @@
 		__builtin_trap(); \
 })
 
-#define MALLOC_PRINTF_FATAL_ERROR(cause, message) ({ \
-		malloc_printf("*** FATAL ERROR - " message ".\n"); \
+#define MALLOC_REPORT_FATAL_ERROR(cause, message) ({ \
+		malloc_report(ASL_LEVEL_ERR, "*** FATAL ERROR - " message ".\n"); \
 		MALLOC_FATAL_ERROR((cause), message); \
 })
 
@@ -71,7 +71,7 @@
 #   define MALLOC_CACHE_LINE 128
 #   define MALLOC_NANO_CACHE_LINE 64
 #elif defined(__arm__) || defined(__arm64__)
-#   define MALLOC_CACHE_LINE 64
+# 	define MALLOC_CACHE_LINE 128
 #   define MALLOC_NANO_CACHE_LINE 64
 #else
 #   define MALLOC_CACHE_LINE 32
@@ -88,6 +88,8 @@
 #define MALLOC_PACKED __attribute__((packed))
 #define MALLOC_USED __attribute__((used))
 #define MALLOC_UNUSED __attribute__((unused))
+#define MALLOC_NORETURN __attribute__((noreturn))
+#define MALLOC_COLD __attribute__((cold))
 #define CHECK_MAGAZINE_PTR_LOCKED(szone, mag_ptr, fun) {}
 
 #define SCRIBBLE_BYTE 0xaa /* allocated scribble */
@@ -100,22 +102,43 @@
 #define vm_page_quanta_size (vm_page_size)
 #define vm_page_quanta_shift (vm_page_shift)
 
-// add a guard page before and after each VM region to help debug
-#define MALLOC_ADD_GUARD_PAGES (1 << 0)
+/*
+ * Large rounds allocation sizes up to MAX(vm_kernel_page_size, page_size).
+ * This provides better death row caching performance when vm_kernel_page_size > page_size.
+ * The kernel allocates pages of vm_kernel_page_size to back our allocations,
+ * so there is no additional physical page cost to doing this.
+ * Guard pages are the same size to ensure the full vm allocation size is a multiple of MAX(vm_kernel_page_size, page_size).
+ */
+#define large_vm_page_quanta_size (vm_kernel_page_size > vm_page_size ? vm_kernel_page_size : vm_page_size)
+#define large_vm_page_quanta_mask (vm_kernel_page_mask > vm_page_mask ? vm_kernel_page_mask : vm_page_mask)
+#define large_vm_page_quanta_shift (vm_kernel_page_shift > vm_page_shift ? vm_kernel_page_shift : vm_page_shift)
+
+#define trunc_large_page_quanta(x) ((x) & (~large_vm_page_quanta_mask))
+#define round_large_page_quanta(x) (trunc_large_page_quanta((x) + large_vm_page_quanta_mask))
+
+
+// add a guard page before each VM region to help debug
+#define MALLOC_ADD_PRELUDE_GUARD_PAGE (1 << 0)
+// add a guard page after each VM region to help debug
+#define MALLOC_ADD_POSTLUDE_GUARD_PAGE (1 << 1)
+// Mask both guard page flags
+#define MALLOC_ADD_GUARD_PAGE_FLAGS (MALLOC_ADD_PRELUDE_GUARD_PAGE|MALLOC_ADD_POSTLUDE_GUARD_PAGE)
+// apply guard pages to all regions
+#define MALLOC_GUARD_ALL (1 << 2)
+// Mask for guard page request flags
+#define MALLOC_ALL_GUARD_PAGE_FLAGS (MALLOC_ADD_GUARD_PAGE_FLAGS|MALLOC_GUARD_ALL)
 // do not protect prelude page
-#define MALLOC_DONT_PROTECT_PRELUDE (1 << 1)
+#define MALLOC_DONT_PROTECT_PRELUDE (1 << 3)
 // do not protect postlude page
-#define MALLOC_DONT_PROTECT_POSTLUDE (1 << 2)
+#define MALLOC_DONT_PROTECT_POSTLUDE (1 << 4)
 // write 0x55 onto free blocks
-#define MALLOC_DO_SCRIBBLE (1 << 3)
+#define MALLOC_DO_SCRIBBLE (1 << 5)
 // call abort() on any malloc error, such as double free or out of memory.
-#define MALLOC_ABORT_ON_ERROR (1 << 4)
+#define MALLOC_ABORT_ON_ERROR (1 << 6)
 // allocate objects such that they may be used with VM purgability APIs
-#define MALLOC_PURGEABLE (1 << 5)
+#define MALLOC_PURGEABLE (1 << 7)
 // call abort() on malloc errors, but not on out of memory.
-#define MALLOC_ABORT_ON_CORRUPTION (1 << 6)
-// expanded small-zone free list size (256 slots)
-#define MALLOC_EXTENDED_SMALL_SLOTS (1 << 7)
+#define MALLOC_ABORT_ON_CORRUPTION (1 << 8)
 
 /*
  * msize - a type to refer to the number of quanta of a tiny or small