mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-02-17 01:34:21 +00:00
Fix problems identified by dl in review <https://info.ravenbrook.com/mail/2014/06/05/14-49-13/0/>.
Copied from Perforce Change: 186445 ServerID: perforce.ravenbrook.com
This commit is contained in:
parent
299bfb2992
commit
220e23a758
3 changed files with 17 additions and 5 deletions
|
|
@ -7,6 +7,17 @@
|
|||
* free but never allocated as alloc starts searching after the tables.
|
||||
* TractOfAddr uses the fact that these pages are marked as free in order
|
||||
* to detect "references" to these pages as being bogus.
|
||||
*
|
||||
* .chunk.at.base: The chunks are stored in a balanced binary tree.
|
||||
* Looking up an address in this tree is on the critical path, and
|
||||
* therefore vital that it runs quickly. It is an implementation
|
||||
* detail of chunks that they are always stored at the base of the
|
||||
* region of address space they represent. Thus chunk happens to
|
||||
* always be the same as chunk->base. We take advantage of this in the
|
||||
* tree search by using chunk as its own key (instead of looking up
|
||||
* chunk->base): this saves a dereference and perhaps a cache miss.
|
||||
* See ChunkKey and ChunkCompare for this optimization. The necessary
|
||||
* property is asserted in ChunkCheck.
|
||||
*/
|
||||
|
||||
#include "tract.h"
|
||||
|
|
@ -117,7 +128,7 @@ Bool ChunkCheck(Chunk chunk)
|
|||
|
||||
CHECKL(chunk->base != (Addr)0);
|
||||
CHECKL(chunk->base < chunk->limit);
|
||||
/* .chunk.at.base: check chunk structure is at its own base */
|
||||
/* check chunk structure is at its own base: see .chunk.at.base. */
|
||||
CHECKL(chunk->base == (Addr)chunk);
|
||||
CHECKL((Addr)(chunk+1) <= chunk->limit);
|
||||
CHECKL(ChunkSizeToPages(chunk, ChunkSize(chunk)) == chunk->pages);
|
||||
|
|
@ -276,6 +287,7 @@ Compare ChunkCompare(Tree tree, TreeKey key)
|
|||
AVERT_CRITICAL(Tree, tree);
|
||||
AVER_CRITICAL(tree != TreeEMPTY);
|
||||
|
||||
/* See .chunk.at.base. */
|
||||
chunk = ChunkOfTree(tree);
|
||||
AVERT_CRITICAL(Chunk, chunk);
|
||||
|
||||
|
|
|
|||
|
|
@ -85,9 +85,9 @@ Compare TreeFind(Tree *treeReturn, Tree root, TreeKey key, TreeCompare compare)
|
|||
Tree node, parent;
|
||||
Compare cmp = CompareEQUAL;
|
||||
|
||||
AVERT(Tree, root);
|
||||
AVER(treeReturn != NULL);
|
||||
AVER(FUNCHECK(compare));
|
||||
AVERT_CRITICAL(Tree, root);
|
||||
AVER_CRITICAL(treeReturn != NULL);
|
||||
AVER_CRITICAL(FUNCHECK(compare));
|
||||
/* key is arbitrary */
|
||||
|
||||
parent = NULL;
|
||||
|
|
|
|||
|
|
@ -138,7 +138,7 @@ extern void TreeBalance(Tree *treeIO);
|
|||
*
|
||||
* root is an lvalue storing a pointer to the root of the tree. It is
|
||||
* evaluated twice.
|
||||
* treeref and nextref are variable of type Tree*.
|
||||
* treeref and nextref are variables of type Tree*.
|
||||
* tree and next are variables of type Tree.
|
||||
*
|
||||
* In the body of the loop, tree and next are the current and next
|
||||
|
|
|
|||
Loading…
Reference in a new issue