// // bit 0 is the least significative bit // The stream encodes the first come bit in the least significant bit of each byte // void BitStreamWriter::Write( size_t data, int count ) { _ASSERTE( count > 0 ); _ASSERT( count <= sizeof( size_t )*8 ); // Increment it now as we change count later on m_BitCount += count; if( count > m_FreeBitsInCurrentSlot ) { if( m_FreeBitsInCurrentSlot > 0 ) { WriteInCurrentSlot( data, m_FreeBitsInCurrentSlot ); count -= m_FreeBitsInCurrentSlot; data >>= m_FreeBitsInCurrentSlot; } _ASSERTE( count > 0 ); // Initialize the next slot if( ++m_pCurrentSlot >= m_OutOfBlockSlot ) { // Get a new memory block AllocMemoryBlock(); } InitCurrentSlot(); // Write the remainder WriteInCurrentSlot( data, count ); m_FreeBitsInCurrentSlot -= count; }
BitStreamWriter::BitStreamWriter( IJitAllocator* pAllocator ) { m_pAllocator = pAllocator; m_BitCount = 0; #ifdef _DEBUG m_MemoryBlocksCount = 0; #endif // We are going to need at least one memory block, so we pre-allocate it AllocMemoryBlock(); InitCurrentSlot(); }
DBStack::DBStack(const uptr size) { AllocMemoryBlock(size); }