Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Xiph.Org
aom-rav1e
Commits
9ed0e071
Commit
9ed0e071
authored
Apr 22, 2015
by
Johann
Committed by
Gerrit Code Review
Apr 22, 2015
Browse files
Merge "vpx_mem: remove memory manager code"
parents
a6e9ae90
e5eda53e
Changes
18
Expand all
Hide whitespace changes
Inline
Side-by-side
configure
View file @
9ed0e071
...
...
@@ -296,7 +296,6 @@ CONFIG_LIST="
codec_srcs
debug_libs
fast_unaligned
mem_manager
mem_tracker
mem_checks
...
...
vpx_mem/include/vpx_mem_intrnl.h
View file @
9ed0e071
...
...
@@ -13,15 +13,6 @@
#define VPX_MEM_INCLUDE_VPX_MEM_INTRNL_H_
#include "./vpx_config.h"
#ifndef CONFIG_MEM_MANAGER
# if defined(VXWORKS)
# define CONFIG_MEM_MANAGER 1
/*include heap manager functionality,*/
/*default: enabled on vxworks*/
# else
# define CONFIG_MEM_MANAGER 0
/*include heap manager functionality*/
# endif
#endif
/*CONFIG_MEM_MANAGER*/
#ifndef CONFIG_MEM_TRACKER
# define CONFIG_MEM_TRACKER 1
/*include xvpx_* calls in the lib*/
#endif
...
...
vpx_mem/memory_manager/hmm_alloc.c
deleted
100644 → 0
View file @
a6e9ae90
/*
* Copyright (c) 2010 The WebM project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
/* This code is in the public domain.
** Version: 1.1 Author: Walt Karas
*/
#include "hmm_intrnl.h"
void
*
U
(
alloc
)(
U
(
descriptor
)
*
desc
,
U
(
size_aau
)
n
)
{
#ifdef HMM_AUDIT_FAIL
if
(
desc
->
avl_tree_root
)
AUDIT_BLOCK
(
PTR_REC_TO_HEAD
(
desc
->
avl_tree_root
))
#endif
if
(
desc
->
last_freed
)
{
#ifdef HMM_AUDIT_FAIL
AUDIT_BLOCK
(
desc
->
last_freed
)
#endif
U
(
into_free_collection
)(
desc
,
(
head_record
*
)(
desc
->
last_freed
));
desc
->
last_freed
=
0
;
}
/* Add space for block header. */
n
+=
HEAD_AAUS
;
/* Convert n from number of address alignment units to block alignment
** units. */
n
=
DIV_ROUND_UP
(
n
,
HMM_BLOCK_ALIGN_UNIT
);
if
(
n
<
MIN_BLOCK_BAUS
)
n
=
MIN_BLOCK_BAUS
;
{
/* Search for the first node of the bin containing the smallest
** block big enough to satisfy request. */
ptr_record
*
ptr_rec_ptr
=
U
(
avl_search
)(
(
U
(
avl_avl
)
*
)
&
(
desc
->
avl_tree_root
),
(
U
(
size_bau
))
n
,
AVL_GREATER_EQUAL
);
/* If an approprate bin is found, satisfy the allocation request,
** otherwise return null pointer. */
return
(
ptr_rec_ptr
?
U
(
alloc_from_bin
)(
desc
,
ptr_rec_ptr
,
(
U
(
size_bau
))
n
)
:
0
);
}
}
vpx_mem/memory_manager/hmm_base.c
deleted
100644 → 0
View file @
a6e9ae90
/*
* Copyright (c) 2010 The WebM project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
/* This code is in the public domain.
** Version: 1.1 Author: Walt Karas
*/
#include "hmm_intrnl.h"
void
U
(
init
)(
U
(
descriptor
)
*
desc
)
{
desc
->
avl_tree_root
=
0
;
desc
->
last_freed
=
0
;
}
/* Remove a free block from a bin's doubly-linked list when it is not,
** the first block in the bin.
*/
void
U
(
dll_remove
)(
/* Pointer to pointer record in the block to be removed. */
ptr_record
*
to_remove
)
{
to_remove
->
prev
->
next
=
to_remove
->
next
;
if
(
to_remove
->
next
)
to_remove
->
next
->
prev
=
to_remove
->
prev
;
}
/* Put a block into the free collection of a heap.
*/
void
U
(
into_free_collection
)(
/* Pointer to heap descriptor. */
U
(
descriptor
)
*
desc
,
/* Pointer to head record of block. */
head_record
*
head_ptr
)
{
ptr_record
*
ptr_rec_ptr
=
HEAD_TO_PTR_REC
(
head_ptr
);
ptr_record
*
bin_front_ptr
=
U
(
avl_insert
)((
U
(
avl_avl
)
*
)
&
(
desc
->
avl_tree_root
),
ptr_rec_ptr
);
if
(
bin_front_ptr
!=
ptr_rec_ptr
)
{
/* The block was not inserted into the AVL tree because there is
** already a bin for the size of the block. */
MARK_SUCCESSIVE_BLOCK_IN_FREE_BIN
(
head_ptr
)
ptr_rec_ptr
->
self
=
ptr_rec_ptr
;
/* Make the block the new second block in the bin's doubly-linked
** list. */
ptr_rec_ptr
->
prev
=
bin_front_ptr
;
ptr_rec_ptr
->
next
=
bin_front_ptr
->
next
;
bin_front_ptr
->
next
=
ptr_rec_ptr
;
if
(
ptr_rec_ptr
->
next
)
ptr_rec_ptr
->
next
->
prev
=
ptr_rec_ptr
;
}
else
/* Block is first block in new bin. */
ptr_rec_ptr
->
next
=
0
;
}
/* Allocate a block from a given bin. Returns a pointer to the payload
** of the removed block. The "last freed" pointer must be null prior
** to calling this function.
*/
void
*
U
(
alloc_from_bin
)(
/* Pointer to heap descriptor. */
U
(
descriptor
)
*
desc
,
/* Pointer to pointer record of first block in bin. */
ptr_record
*
bin_front_ptr
,
/* Number of BAUs needed in the allocated block. If the block taken
** from the bin is significantly larger than the number of BAUs needed,
** the "extra" BAUs are split off to form a new free block. */
U
(
size_bau
)
n_baus
)
{
head_record
*
head_ptr
;
U
(
size_bau
)
rem_baus
;
if
(
bin_front_ptr
->
next
)
{
/* There are multiple blocks in this bin. Use the 2nd block in
** the bin to avoid needless change to the AVL tree.
*/
ptr_record
*
ptr_rec_ptr
=
bin_front_ptr
->
next
;
head_ptr
=
PTR_REC_TO_HEAD
(
ptr_rec_ptr
);
#ifdef AUDIT_FAIL
AUDIT_BLOCK
(
head_ptr
)
#endif
U
(
dll_remove
)(
ptr_rec_ptr
);
}
else
{
/* There is only one block in the bin, so it has to be removed
** from the AVL tree.
*/
head_ptr
=
PTR_REC_TO_HEAD
(
bin_front_ptr
);
U
(
avl_remove
)(
(
U
(
avl_avl
)
*
)
&
(
desc
->
avl_tree_root
),
BLOCK_BAUS
(
head_ptr
));
}
MARK_BLOCK_ALLOCATED
(
head_ptr
)
rem_baus
=
BLOCK_BAUS
(
head_ptr
)
-
n_baus
;
if
(
rem_baus
>=
MIN_BLOCK_BAUS
)
{
/* Since there are enough "extra" BAUs, split them off to form
** a new free block.
*/
head_record
*
rem_head_ptr
=
(
head_record
*
)
BAUS_FORWARD
(
head_ptr
,
n_baus
);
/* Change the next block's header to reflect the fact that the
** block preceeding it is now smaller.
*/
SET_PREV_BLOCK_BAUS
(
BAUS_FORWARD
(
head_ptr
,
head_ptr
->
block_size
),
rem_baus
)
head_ptr
->
block_size
=
n_baus
;
rem_head_ptr
->
previous_block_size
=
n_baus
;
rem_head_ptr
->
block_size
=
rem_baus
;
desc
->
last_freed
=
rem_head_ptr
;
}
return
(
HEAD_TO_PTR_REC
(
head_ptr
));
}
/* Take a block out of the free collection.
*/
void
U
(
out_of_free_collection
)(
/* Descriptor of heap that block is in. */
U
(
descriptor
)
*
desc
,
/* Pointer to head of block to take out of free collection. */
head_record
*
head_ptr
)
{
ptr_record
*
ptr_rec_ptr
=
HEAD_TO_PTR_REC
(
head_ptr
);
if
(
ptr_rec_ptr
->
self
==
ptr_rec_ptr
)
/* Block is not the front block in its bin, so all we have to
** do is take it out of the bin's doubly-linked list. */
U
(
dll_remove
)(
ptr_rec_ptr
);
else
{
ptr_record
*
next
=
ptr_rec_ptr
->
next
;
if
(
next
)
/* Block is the front block in its bin, and there is at least
** one other block in the bin. Substitute the next block for
** the front block. */
U
(
avl_subst
)((
U
(
avl_avl
)
*
)
&
(
desc
->
avl_tree_root
),
next
);
else
/* Block is the front block in its bin, but there is no other
** block in the bin. Eliminate the bin. */
U
(
avl_remove
)(
(
U
(
avl_avl
)
*
)
&
(
desc
->
avl_tree_root
),
BLOCK_BAUS
(
head_ptr
));
}
}
void
U
(
free
)(
U
(
descriptor
)
*
desc
,
void
*
payload_ptr
)
{
/* Flags if coalesce with adjacent block. */
int
coalesce
;
head_record
*
fwd_head_ptr
;
head_record
*
free_head_ptr
=
PTR_REC_TO_HEAD
(
payload_ptr
);
desc
->
num_baus_can_shrink
=
0
;
#ifdef HMM_AUDIT_FAIL
AUDIT_BLOCK
(
free_head_ptr
)
/* Make sure not freeing an already free block. */
if
(
!
IS_BLOCK_ALLOCATED
(
free_head_ptr
))
HMM_AUDIT_FAIL
if
(
desc
->
avl_tree_root
)
/* Audit root block in AVL tree. */
AUDIT_BLOCK
(
PTR_REC_TO_HEAD
(
desc
->
avl_tree_root
))
#endif
fwd_head_ptr
=
(
head_record
*
)
BAUS_FORWARD
(
free_head_ptr
,
free_head_ptr
->
block_size
);
if
(
free_head_ptr
->
previous_block_size
)
{
/* Coalesce with backward block if possible. */
head_record
*
bkwd_head_ptr
=
(
head_record
*
)
BAUS_BACKWARD
(
free_head_ptr
,
free_head_ptr
->
previous_block_size
);
#ifdef HMM_AUDIT_FAIL
AUDIT_BLOCK
(
bkwd_head_ptr
)
#endif
if
(
bkwd_head_ptr
==
(
head_record
*
)(
desc
->
last_freed
))
{
desc
->
last_freed
=
0
;
coalesce
=
1
;
}
else
if
(
IS_BLOCK_ALLOCATED
(
bkwd_head_ptr
))
coalesce
=
0
;
else
{
U
(
out_of_free_collection
)(
desc
,
bkwd_head_ptr
);
coalesce
=
1
;
}
if
(
coalesce
)
{
bkwd_head_ptr
->
block_size
+=
free_head_ptr
->
block_size
;
SET_PREV_BLOCK_BAUS
(
fwd_head_ptr
,
BLOCK_BAUS
(
bkwd_head_ptr
))
free_head_ptr
=
bkwd_head_ptr
;
}
}
if
(
fwd_head_ptr
->
block_size
==
0
)
{
/* Block to be freed is last block before dummy end-of-chunk block. */
desc
->
end_of_shrinkable_chunk
=
BAUS_FORWARD
(
fwd_head_ptr
,
DUMMY_END_BLOCK_BAUS
);
desc
->
num_baus_can_shrink
=
BLOCK_BAUS
(
free_head_ptr
);
if
(
PREV_BLOCK_BAUS
(
free_head_ptr
)
==
0
)
/* Free block is the entire chunk, so shrinking can eliminate
** entire chunk including dummy end block. */
desc
->
num_baus_can_shrink
+=
DUMMY_END_BLOCK_BAUS
;
}
else
{
/* Coalesce with forward block if possible. */
#ifdef HMM_AUDIT_FAIL
AUDIT_BLOCK
(
fwd_head_ptr
)
#endif
if
(
fwd_head_ptr
==
(
head_record
*
)(
desc
->
last_freed
))
{
desc
->
last_freed
=
0
;
coalesce
=
1
;
}
else
if
(
IS_BLOCK_ALLOCATED
(
fwd_head_ptr
))
coalesce
=
0
;
else
{
U
(
out_of_free_collection
)(
desc
,
fwd_head_ptr
);
coalesce
=
1
;
}
if
(
coalesce
)
{
free_head_ptr
->
block_size
+=
fwd_head_ptr
->
block_size
;
fwd_head_ptr
=
(
head_record
*
)
BAUS_FORWARD
(
fwd_head_ptr
,
BLOCK_BAUS
(
fwd_head_ptr
));
SET_PREV_BLOCK_BAUS
(
fwd_head_ptr
,
BLOCK_BAUS
(
free_head_ptr
))
if
(
fwd_head_ptr
->
block_size
==
0
)
{
/* Coalesced block to be freed is last block before dummy
** end-of-chunk block. */
desc
->
end_of_shrinkable_chunk
=
BAUS_FORWARD
(
fwd_head_ptr
,
DUMMY_END_BLOCK_BAUS
);
desc
->
num_baus_can_shrink
=
BLOCK_BAUS
(
free_head_ptr
);
if
(
PREV_BLOCK_BAUS
(
free_head_ptr
)
==
0
)
/* Free block is the entire chunk, so shrinking can
** eliminate entire chunk including dummy end block. */
desc
->
num_baus_can_shrink
+=
DUMMY_END_BLOCK_BAUS
;
}
}
}
if
(
desc
->
last_freed
)
{
/* There is a last freed block, but it is not adjacent to the
** block being freed by this call to free, so put the last
** freed block into the free collection.
*/
#ifdef HMM_AUDIT_FAIL
AUDIT_BLOCK
(
desc
->
last_freed
)
#endif
U
(
into_free_collection
)(
desc
,
(
head_record
*
)(
desc
->
last_freed
));
}
desc
->
last_freed
=
free_head_ptr
;
}
void
U
(
new_chunk
)(
U
(
descriptor
)
*
desc
,
void
*
start
,
U
(
size_bau
)
n_baus
)
{
#ifdef HMM_AUDIT_FAIL
if
(
desc
->
avl_tree_root
)
/* Audit root block in AVL tree. */
AUDIT_BLOCK
(
PTR_REC_TO_HEAD
(
desc
->
avl_tree_root
))
#endif
#undef HEAD_PTR
#define HEAD_PTR ((head_record *) start)
/* Make the chunk one big free block followed by a dummy end block.
*/
n_baus
-=
DUMMY_END_BLOCK_BAUS
;
HEAD_PTR
->
previous_block_size
=
0
;
HEAD_PTR
->
block_size
=
n_baus
;
U
(
into_free_collection
)(
desc
,
HEAD_PTR
);
/* Set up the dummy end block. */
start
=
BAUS_FORWARD
(
start
,
n_baus
);
HEAD_PTR
->
previous_block_size
=
n_baus
;
HEAD_PTR
->
block_size
=
0
;
#undef HEAD_PTR
}
#ifdef HMM_AUDIT_FAIL
/* Function that does audit fail actions defined my preprocessor symbol,
** and returns a dummy integer value.
*/
int
U
(
audit_block_fail_dummy_return
)(
void
)
{
HMM_AUDIT_FAIL
/* Dummy return. */
return
(
0
);
}
#endif
/* AVL Tree instantiation. */
#ifdef HMM_AUDIT_FAIL
/* The AVL tree generic package passes an ACCESS of 1 when it "touches"
** a child node for the first time during a particular operation. I use
** this feature to audit only one time (per operation) the free blocks
** that are tree nodes. Since the root node is not a child node, it has
** to be audited directly.
*/
/* The pain you feel while reading these macros will not be in vain. It
** will remove all doubt from you mind that C++ inline functions are
** a very good thing.
*/
#define AVL_GET_LESS(H, ACCESS) \
(((ACCESS) ? AUDIT_BLOCK_AS_EXPR(PTR_REC_TO_HEAD(H)) : 0), (H)->self)
#define AVL_GET_GREATER(H, ACCESS) \
(((ACCESS) ? AUDIT_BLOCK_AS_EXPR(PTR_REC_TO_HEAD(H)) : 0), (H)->prev)
#else
#define AVL_GET_LESS(H, ACCESS) ((H)->self)
#define AVL_GET_GREATER(H, ACCESS) ((H)->prev)
#endif
#define AVL_SET_LESS(H, LH) (H)->self = (LH);
#define AVL_SET_GREATER(H, GH) (H)->prev = (GH);
/* high bit of high bit of
** block_size previous_block_size balance factor
** ----------- ------------------- --------------
** 0 0 n/a (block allocated)
** 0 1 1
** 1 0 -1
** 1 1 0
*/
#define AVL_GET_BALANCE_FACTOR(H) \
((((head_record *) (PTR_REC_TO_HEAD(H)))->block_size & \
HIGH_BIT_BAU_SIZE) ? \
(((head_record *) (PTR_REC_TO_HEAD(H)))->previous_block_size & \
HIGH_BIT_BAU_SIZE ? 0 : -1) : 1)
#define AVL_SET_BALANCE_FACTOR(H, BF) \
{ \
register head_record *p = \
(head_record *) PTR_REC_TO_HEAD(H); \
register int bal_f = (BF); \
\
if (bal_f <= 0) \
p->block_size |= HIGH_BIT_BAU_SIZE; \
else \
p->block_size &= ~HIGH_BIT_BAU_SIZE; \
if (bal_f >= 0) \
p->previous_block_size |= HIGH_BIT_BAU_SIZE; \
else \
p->previous_block_size &= ~HIGH_BIT_BAU_SIZE; \
}
#define COMPARE_KEY_KEY(K1, K2) ((K1) == (K2) ? 0 : ((K1) > (K2) ? 1 : -1))
#define AVL_COMPARE_KEY_NODE(K, H) \
COMPARE_KEY_KEY(K, BLOCK_BAUS(PTR_REC_TO_HEAD(H)))
#define AVL_COMPARE_NODE_NODE(H1, H2) \
COMPARE_KEY_KEY(BLOCK_BAUS(PTR_REC_TO_HEAD(H1)), \
BLOCK_BAUS(PTR_REC_TO_HEAD(H2)))
#define AVL_NULL ((ptr_record *) 0)
#define AVL_IMPL_MASK \
( AVL_IMPL_INSERT | AVL_IMPL_SEARCH | AVL_IMPL_REMOVE | AVL_IMPL_SUBST )
#include "cavl_impl.h"
vpx_mem/memory_manager/hmm_dflt_abort.c
deleted
100644 → 0
View file @
a6e9ae90
/*
* Copyright (c) 2010 The WebM project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
/* This code is in the public domain.
** Version: 1.1 Author: Walt Karas
*/
/* The function in this file performs default actions if self-auditing
** finds heap corruption. Don't rely on this code to handle the
** case where HMM is being used to implement the malloc and free standard
** library functions. Rewrite the function if necessary to avoid using
** I/O and execution termination functions that call malloc or free.
** In Unix, for example, you would replace the fputs calls with calls
** to the write system call using file handle number 2.
*/
#include "hmm_intrnl.h"
#include <stdio.h>
#include <stdlib.h>
static
int
entered
=
0
;
/* Print abort message, file and line. Terminate execution.
*/
void
hmm_dflt_abort
(
const
char
*
file
,
const
char
*
line
)
{
/* Avoid use of printf(), which is more likely to use heap. */
if
(
entered
)
/* The standard I/O functions called a heap function and caused
** an indirect recursive call to this function. So we'll have
** to just exit without printing a message. */
while
(
1
);
entered
=
1
;
fputs
(
"
\n
_abort - Heap corruption
\n
"
"File: "
,
stderr
);
fputs
(
file
,
stderr
);
fputs
(
" Line: "
,
stderr
);
fputs
(
line
,
stderr
);
fputs
(
"
\n\n
"
,
stderr
);
fputs
(
"hmm_dflt_abort: while(1)!!!
\n
"
,
stderr
);
fflush
(
stderr
);
while
(
1
);
}
vpx_mem/memory_manager/hmm_grow.c
deleted
100644 → 0
View file @
a6e9ae90
/*
* Copyright (c) 2010 The WebM project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
/* This code is in the public domain.
** Version: 1.1 Author: Walt Karas
*/
#include "hmm_intrnl.h"
void
U
(
grow_chunk
)(
U
(
descriptor
)
*
desc
,
void
*
end
,
U
(
size_bau
)
n_baus
)
{
#undef HEAD_PTR
#define HEAD_PTR ((head_record *) end)
end
=
BAUS_BACKWARD
(
end
,
DUMMY_END_BLOCK_BAUS
);
#ifdef HMM_AUDIT_FAIL
if
(
HEAD_PTR
->
block_size
!=
0
)
/* Chunk does not have valid dummy end block. */
HMM_AUDIT_FAIL
#endif
/* Create a new block that absorbs the old dummy end block. */
HEAD_PTR
->
block_size
=
n_baus
;
/* Set up the new dummy end block. */
{
head_record
*
dummy
=
(
head_record
*
)
BAUS_FORWARD
(
end
,
n_baus
);
dummy
->
previous_block_size
=
n_baus
;
dummy
->
block_size
=
0
;
}
/* Simply free the new block, allowing it to coalesce with any
** free block at that was the last block in the chunk prior to
** growth.
*/
U
(
free
)(
desc
,
HEAD_TO_PTR_REC
(
end
));
#undef HEAD_PTR
}
vpx_mem/memory_manager/hmm_largest.c
deleted
100644 → 0
View file @
a6e9ae90
/*
* Copyright (c) 2010 The WebM project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
/* This code is in the public domain.
** Version: 1.1 Author: Walt Karas
*/
#include "hmm_intrnl.h"
U
(
size_aau
)
U
(
largest_available
)(
U
(
descriptor
)
*
desc
)
{
U
(
size_bau
)
largest
;
if
(
!
(
desc
->
avl_tree_root
))
largest
=
0
;
else
{
#ifdef HMM_AUDIT_FAIL
/* Audit root block in AVL tree. */
AUDIT_BLOCK
(
PTR_REC_TO_HEAD
(
desc
->
avl_tree_root
))