Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/wolfpld/tracy.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBartosz Taudul <wolf.pld@gmail.com>2018-04-30 03:47:16 +0300
committerBartosz Taudul <wolf.pld@gmail.com>2018-04-30 03:47:16 +0300
commita2d3ad35f031285052dfda09699be202936475f0 (patch)
tree661d0bee6059ffdcb141e7b2853023c2700a3bba /server/TracySlab.hpp
parentb598300186d6f8d99d19a6fb6ca443b7a681621a (diff)
Force inline common slab allocation paths.
Diffstat (limited to 'server/TracySlab.hpp')
-rw-r--r--server/TracySlab.hpp26
1 files changed, 14 insertions, 12 deletions
diff --git a/server/TracySlab.hpp b/server/TracySlab.hpp
index 2b1c7d4a..d66a4a4a 100644
--- a/server/TracySlab.hpp
+++ b/server/TracySlab.hpp
@@ -30,15 +30,12 @@ public:
}
}
- void* AllocRaw( size_t size )
+ tracy_force_inline void* AllocRaw( size_t size )
{
assert( size <= BlockSize );
if( m_offset + size > BlockSize )
{
- m_ptr = new char[BlockSize];
- m_offset = 0;
- m_buffer.emplace_back( m_ptr );
- memUsage.fetch_add( BlockSize, std::memory_order_relaxed );
+ DoAlloc();
}
void* ret = m_ptr + m_offset;
m_offset += size;
@@ -52,10 +49,7 @@ public:
assert( size <= BlockSize );
if( m_offset + size > BlockSize )
{
- m_ptr = new char[BlockSize];
- m_offset = 0;
- m_buffer.emplace_back( m_ptr );
- memUsage.fetch_add( BlockSize, std::memory_order_relaxed );
+ DoAlloc();
}
void* ret = m_ptr + m_offset;
new( ret ) T;
@@ -64,18 +58,18 @@ public:
}
template<typename T>
- T* Alloc()
+ tracy_force_inline T* Alloc()
{
return (T*)AllocRaw( sizeof( T ) );
}
template<typename T>
- T* Alloc( size_t size )
+ tracy_force_inline T* Alloc( size_t size )
{
return (T*)AllocRaw( sizeof( T ) * size );
}
- void Unalloc( size_t size )
+ tracy_force_inline void Unalloc( size_t size )
{
assert( size <= m_offset );
m_offset -= size;
@@ -104,6 +98,14 @@ public:
Slab& operator=( Slab&& ) = delete;
private:
+ void DoAlloc()
+ {
+ m_ptr = new char[BlockSize];
+ m_offset = 0;
+ m_buffer.emplace_back( m_ptr );
+ memUsage.fetch_add( BlockSize, std::memory_order_relaxed );
+ }
+
char* m_ptr;
uint32_t m_offset;
std::vector<char*> m_buffer;