Improved JitAllocator to not reiterate the whole block on every allocation

This commit is contained in:
kobalicek
2021-01-02 01:31:15 +01:00
parent 45fe60f93d
commit 13876c4e5e
3 changed files with 443 additions and 325 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -207,12 +207,12 @@ public:
//! Release a memory returned by `alloc()`.
//!
//! \remarks This function is thread-safe.
ASMJIT_API Error release(void* ro) noexcept;
ASMJIT_API Error release(void* roPtr) noexcept;
//! Free extra memory allocated with `p` by restricting it to `newSize` size.
//!
//! \remarks This function is thread-safe.
ASMJIT_API Error shrink(void* ro, size_t newSize) noexcept;
ASMJIT_API Error shrink(void* roPtr, size_t newSize) noexcept;
//! \}

View File

@@ -1165,6 +1165,30 @@ public:
T _bitWord;
};
// ============================================================================
// [asmjit::Support - BitWordFlipIterator]
// ============================================================================
template<typename T>
class BitWordFlipIterator {
public:
inline explicit BitWordFlipIterator(T bitWord) noexcept
: _bitWord(bitWord) {}
inline void init(T bitWord) noexcept { _bitWord = bitWord; }
inline bool hasNext() const noexcept { return _bitWord != 0; }
inline uint32_t nextAndFlip() noexcept {
ASMJIT_ASSERT(_bitWord != 0);
uint32_t index = ctz(_bitWord);
_bitWord ^= T(1u) << index;
return index;
}
T _bitWord;
T _xorMask;
};
// ============================================================================
// [asmjit::Support - BitVectorOps]
// ============================================================================