Rebase against 18883a76762afab3e18e1279a9666240e19d4d03.

This commit is contained in:
Zebediah Figura
2019-04-08 17:01:18 -05:00
parent be0910e9a9
commit 52a77f6b00
16 changed files with 163 additions and 385 deletions

View File

@@ -1,4 +1,4 @@
From ff5a1ffd966ca678a579f2b1da63290ae107d71c Mon Sep 17 00:00:00 2001
From 6c2c2f49eddd7133f6854845f54349ea2511250b Mon Sep 17 00:00:00 2001
From: Sebastian Lackner <sebastian@fds-team.de>
Date: Sat, 22 Jul 2017 07:21:45 +0200
Subject: [PATCH] ntdll: Improve heap allocation performance. (v2)
@@ -9,10 +9,10 @@ Subject: [PATCH] ntdll: Improve heap allocation performance. (v2)
2 files changed, 234 insertions(+), 96 deletions(-)
diff --git a/configure.ac b/configure.ac
index b4b3c7c55d..0c9bfe4628 100644
index ad4f0e05a..f8a1c8de4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2829,6 +2829,15 @@ then
@@ -2745,6 +2745,15 @@ then
AC_DEFINE(HAVE___BUILTIN_CLZ, 1, [Define to 1 if you have the `__builtin_clz' built-in function.])
fi
@@ -29,7 +29,7 @@ index b4b3c7c55d..0c9bfe4628 100644
AC_CACHE_CHECK([for __builtin_popcount], ac_cv_have___builtin_popcount,
AC_LINK_IFELSE([AC_LANG_PROGRAM(,[[return __builtin_popcount(1)]])],
diff --git a/dlls/ntdll/heap.c b/dlls/ntdll/heap.c
index 3f1afd6f0f..a06ba32024 100644
index 3eaeea2d1..4b694ed7e 100644
--- a/dlls/ntdll/heap.c
+++ b/dlls/ntdll/heap.c
@@ -3,6 +3,7 @@
@@ -200,13 +200,13 @@ index 3f1afd6f0f..a06ba32024 100644
static inline ULONG get_protection_type( DWORD flags )
{
@@ -344,13 +361,31 @@ static void HEAP_Dump( HEAP *heap )
DPRINTF( "Next: %p Sub-heaps:", LIST_ENTRY( heap->entry.next, HEAP, entry ) );
LIST_FOR_EACH_ENTRY( subheap, &heap->subheap_list, SUBHEAP, entry ) DPRINTF( " %p", subheap );
TRACE( "Next: %p Sub-heaps:", LIST_ENTRY( heap->entry.next, HEAP, entry ) );
LIST_FOR_EACH_ENTRY( subheap, &heap->subheap_list, SUBHEAP, entry ) TRACE( " %p", subheap );
- DPRINTF( "\nFree lists:\n Block Stat Size Id\n" );
+ DPRINTF( "\nFree lists:\n" );
- TRACE( "\nFree lists:\n Block Stat Size Id\n" );
+ TRACE( "\nFree lists:\n" );
for (i = 0; i < HEAP_NB_FREE_LISTS; i++)
- DPRINTF( "%p free %08lx prev=%p next=%p\n",
- TRACE( "%p free %08lx prev=%p next=%p\n",
- &heap->freeList[i].arena, i < HEAP_NB_SMALL_FREE_LISTS ?
- HEAP_MIN_ARENA_SIZE + i * ALIGNMENT : HEAP_freeListSizes[i - HEAP_NB_SMALL_FREE_LISTS],
- LIST_ENTRY( heap->freeList[i].arena.entry.prev, ARENA_FREE, entry ),
@@ -214,24 +214,24 @@ index 3f1afd6f0f..a06ba32024 100644
+ {
+ BOOL empty = !(heap->freeMask[ HEAP_FREEMASK_INDEX( i ) ] & HEAP_FREEMASK_BIT( i ));
+
+ DPRINTF( "free %08x: ", HEAP_FREELIST_SIZE( i ) );
+ TRACE( "free %08x: ", HEAP_FREELIST_SIZE( i ) );
+ if (!empty && !list_empty( &heap->freeList[i] ))
+ {
+ DPRINTF( "head=%p tail=%p\n",
+ TRACE( "head=%p tail=%p\n",
+ LIST_ENTRY( heap->freeList[i].next, ARENA_FREE, entry.list ),
+ LIST_ENTRY( heap->freeList[i].prev, ARENA_FREE, entry.list ));
+ }
+ else if (empty && list_empty( &heap->freeList[i] ))
+ {
+ DPRINTF( "(empty)\n" );
+ TRACE( "(empty)\n" );
+ }
+ else
+ {
+ DPRINTF( "(corrupted)\n" );
+ TRACE( "(corrupted)\n" );
+ }
+ }
+
+ DPRINTF( "free %08x: root=%p\n",
+ TRACE( "free %08x: root=%p\n",
+ HEAP_FREELIST_SIZE( HEAP_NB_FREE_LISTS ),
+ heap->freeTree.root ? LIST_ENTRY( heap->freeTree.root, ARENA_FREE, entry.tree ) : NULL);
@@ -241,14 +241,14 @@ index 3f1afd6f0f..a06ba32024 100644
if (*(DWORD *)ptr & ARENA_FLAG_FREE)
{
ARENA_FREE *pArena = (ARENA_FREE *)ptr;
- DPRINTF( "%p %08x free %08x prev=%p next=%p\n",
- TRACE( "%p %08x free %08x prev=%p next=%p\n",
- pArena, pArena->magic,
- pArena->size & ARENA_SIZE_MASK,
- LIST_ENTRY( pArena->entry.prev, ARENA_FREE, entry ),
- LIST_ENTRY( pArena->entry.next, ARENA_FREE, entry ) );
+ if ((pArena->size & ARENA_FLAG_FREE) == ARENA_FLAG_FREE_LIST)
+ {
+ DPRINTF( "%p %08x free %08x prev=%p next=%p\n",
+ TRACE( "%p %08x free %08x prev=%p next=%p\n",
+ pArena, pArena->magic, pArena->size & ARENA_SIZE_MASK,
+ LIST_ENTRY( pArena->entry.list.prev, ARENA_FREE, entry.list ),
+ LIST_ENTRY( pArena->entry.list.next, ARENA_FREE, entry.list ) );
@@ -264,12 +264,12 @@ index 3f1afd6f0f..a06ba32024 100644
+ if (pArena->entry.tree.right)
+ right = WINE_RB_ENTRY_VALUE( pArena->entry.tree.right, ARENA_FREE, entry.tree );
+
+ DPRINTF( "%p %08x free %08x parent=%p left=%p right=%p\n",
+ TRACE( "%p %08x free %08x parent=%p left=%p right=%p\n",
+ pArena, pArena->magic, pArena->size & ARENA_SIZE_MASK, parent, left, right );
+ }
+ else
+ {
+ DPRINTF( "%p %08x free %08x corrupted\n",
+ TRACE( "%p %08x free %08x corrupted\n",
+ pArena, pArena->magic, pArena->size & ARENA_SIZE_MASK );
+ }
ptr += sizeof(*pArena) + (pArena->size & ARENA_SIZE_MASK);
@@ -556,5 +556,5 @@ index 3f1afd6f0f..a06ba32024 100644
subheap->heap, prev, pArena );
return FALSE;
--
2.18.0
2.21.0