Fixed memory leak associated with TLS.
We used to allocate thread-local memory on each compile.
If the compile did not happen on the same thread as ShInitialize,
we leaked the thread-local memory.
It turns out that there is no need to allocate any thread-local
memory. This patch cleans up all the unnecessary junk around TLS.
BUG=crbug.com/181691
R=kbr@chromium.org
Review URL: https://codereview.appspot.com/11679046
Conflicts:
src/compiler/ConstantUnion.h
src/compiler/ShaderLang.cpp
src/compiler/Types.h
src/compiler/ValidateLimitations.cpp
diff --git a/src/compiler/PoolAlloc.h b/src/compiler/PoolAlloc.h
index a8a59c6..edd249c 100644
--- a/src/compiler/PoolAlloc.h
+++ b/src/compiler/PoolAlloc.h
@@ -219,14 +219,8 @@
// different times. But a simple use is to have a global pop
// with everyone using the same global allocator.
//
-extern TPoolAllocator& GetGlobalPoolAllocator();
+extern TPoolAllocator* GetGlobalPoolAllocator();
extern void SetGlobalPoolAllocator(TPoolAllocator* poolAllocator);
-#define GlobalPoolAllocator GetGlobalPoolAllocator()
-
-struct TThreadGlobalPools
-{
- TPoolAllocator* globalPoolAllocator;
-};
//
// This STL compatible allocator is intended to be used as the allocator
@@ -253,7 +247,7 @@
pointer address(reference x) const { return &x; }
const_pointer address(const_reference x) const { return &x; }
- pool_allocator() : allocator(&GlobalPoolAllocator) { }
+ pool_allocator() : allocator(GetGlobalPoolAllocator()) { }
pool_allocator(TPoolAllocator& a) : allocator(&a) { }
pool_allocator(const pool_allocator<T>& p) : allocator(p.allocator) { }