xo-arena: + src_fn argument in alloc_error + contributaries
This commit is contained in:
parent
c8ba4d42b8
commit
a3e72f33a5
9 changed files with 73 additions and 37 deletions
|
|
@ -48,20 +48,25 @@ namespace xo {
|
|||
uint32_t seq) : error_{err},
|
||||
error_seq_{seq} {}
|
||||
AllocError(error err,
|
||||
const char * src_fn,
|
||||
uint32_t seq,
|
||||
size_type req_z,
|
||||
size_type com_z,
|
||||
size_type rsv_z) : error_{err},
|
||||
error_seq_{seq},
|
||||
request_z_{req_z},
|
||||
committed_z_{com_z},
|
||||
reserved_z_{rsv_z} {}
|
||||
size_type rsv_z) : error_{err},
|
||||
src_fn_{src_fn},
|
||||
error_seq_{seq},
|
||||
request_z_{req_z},
|
||||
committed_z_{com_z},
|
||||
reserved_z_{rsv_z} {}
|
||||
|
||||
static const char * error_description(error x);
|
||||
|
||||
/** error code **/
|
||||
error error_ = error::ok;
|
||||
|
||||
/** source function. Typically injected with __PRETTY_FUNCTION__
|
||||
* somewhere suitable on stack
|
||||
**/
|
||||
const char * src_fn_ = nullptr;
|
||||
/** sequence# of this error.
|
||||
* Each error event within an allocator gets next sequence number
|
||||
**/
|
||||
|
|
|
|||
|
|
@ -203,19 +203,21 @@ namespace xo {
|
|||
|
||||
/** capture error information: advance error count + set last_error **/
|
||||
void capture_error(error err,
|
||||
const char * src_fn,
|
||||
size_type target_z = 0) const;
|
||||
|
||||
/** alloc driver. shared by alloc(), super_alloc(), sub_alloc() **/
|
||||
value_type _alloc(std::size_t req_z,
|
||||
alloc_mode mode,
|
||||
typeseq tseq,
|
||||
uint32_t age);
|
||||
uint32_t age,
|
||||
const char * src_fn);
|
||||
|
||||
/** expand committed space in arena @p d
|
||||
* to size at least @p z
|
||||
* to size at least @p z, on behalf of @p src_fn
|
||||
* In practice will round up to a multiple of @ref page_z_.
|
||||
**/
|
||||
bool expand(size_type z) noexcept;
|
||||
bool expand(size_type z, const char * src_fn) noexcept;
|
||||
|
||||
/** create initial guard **/
|
||||
void establish_initial_guard() noexcept;
|
||||
|
|
|
|||
|
|
@ -181,7 +181,7 @@ namespace xo {
|
|||
template <typename T>
|
||||
void
|
||||
DArenaVector<T>::reserve(size_type z) {
|
||||
store_.expand(z * sizeof(T));
|
||||
store_.expand(z * sizeof(T), __PRETTY_FUNCTION__);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
|
|
@ -193,7 +193,7 @@ namespace xo {
|
|||
if (z > size_) {
|
||||
// expand arena to accomodate
|
||||
|
||||
if (!store_.expand(req_z))
|
||||
if (!store_.expand(req_z, __PRETTY_FUNCTION__))
|
||||
return false;
|
||||
|
||||
// run ctors
|
||||
|
|
@ -258,7 +258,7 @@ namespace xo {
|
|||
size_type new_z = size_ + 1;
|
||||
size_type req_z = new_z * sizeof(T);
|
||||
|
||||
store_.expand(req_z);
|
||||
store_.expand(req_z, __PRETTY_FUNCTION__);
|
||||
}
|
||||
|
||||
// move elements [i .. z-1] right by one position.
|
||||
|
|
@ -283,7 +283,7 @@ namespace xo {
|
|||
size_type new_z = size_ + 1;
|
||||
size_type req_z = new_z * sizeof(T);
|
||||
|
||||
store_.expand(req_z);
|
||||
store_.expand(req_z, __PRETTY_FUNCTION__);
|
||||
}
|
||||
|
||||
// move elements [i .. z-1] right by one position.
|
||||
|
|
@ -322,7 +322,7 @@ namespace xo {
|
|||
size_type z = size_ + 1;
|
||||
size_type req_z = z * sizeof(T);
|
||||
|
||||
if (this->store_.expand(req_z)) {
|
||||
if (this->store_.expand(req_z, __PRETTY_FUNCTION__)) {
|
||||
T * addr = this->_address_of(size_);
|
||||
|
||||
new (addr) T{std::move(x)};
|
||||
|
|
@ -336,7 +336,7 @@ namespace xo {
|
|||
DArenaVector<T>::push_back(const T & x) {
|
||||
size_type z = size_ + 1;
|
||||
|
||||
if (this->store_.expand(z * sizeof(T))) {
|
||||
if (this->store_.expand(z * sizeof(T), __PRETTY_FUNCTION__)) {
|
||||
T * addr = this->_address_of(size_);
|
||||
|
||||
new (addr) T{x};
|
||||
|
|
|
|||
|
|
@ -20,12 +20,17 @@ namespace xo {
|
|||
inline std::ostream &
|
||||
operator<<(std::ostream & os, const AllocError & x) {
|
||||
os << "<AllocError"
|
||||
<< xtag("error", x.error_)
|
||||
<< xtag("seq", x.error_seq_)
|
||||
<< xtag("error", x.error_);
|
||||
|
||||
if (x.src_fn_)
|
||||
os << xtag("src_fn", x.src_fn_);
|
||||
|
||||
os << xtag("seq", x.error_seq_)
|
||||
<< xtag("req_z", x.request_z_)
|
||||
<< xtag("commit_z", x.committed_z_)
|
||||
<< xtag("resv_z", x.reserved_z_)
|
||||
<< ">";
|
||||
|
||||
return os;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue