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/Common.h b/src/compiler/Common.h
index 532486a..46f9440 100644
--- a/src/compiler/Common.h
+++ b/src/compiler/Common.h
@@ -24,14 +24,14 @@
//
// Put POOL_ALLOCATOR_NEW_DELETE in base classes to make them use this scheme.
//
-#define POOL_ALLOCATOR_NEW_DELETE(A) \
- void* operator new(size_t s) { return (A).allocate(s); } \
- void* operator new(size_t, void *_Where) { return (_Where); } \
- void operator delete(void*) { } \
- void operator delete(void *, void *) { } \
- void* operator new[](size_t s) { return (A).allocate(s); } \
- void* operator new[](size_t, void *_Where) { return (_Where); } \
- void operator delete[](void*) { } \
+#define POOL_ALLOCATOR_NEW_DELETE() \
+ void* operator new(size_t s) { return GetGlobalPoolAllocator()->allocate(s); } \
+ void* operator new(size_t, void *_Where) { return (_Where); } \
+ void operator delete(void*) { } \
+ void operator delete(void *, void *) { } \
+ void* operator new[](size_t s) { return GetGlobalPoolAllocator()->allocate(s); } \
+ void* operator new[](size_t, void *_Where) { return (_Where); } \
+ void operator delete[](void*) { } \
void operator delete[](void *, void *) { }
//
@@ -42,7 +42,7 @@
typedef std::basic_ostringstream<char, std::char_traits<char>, TStringAllocator> TStringStream;
inline TString* NewPoolTString(const char* s)
{
- void* memory = GlobalPoolAllocator.allocate(sizeof(TString));
+ void* memory = GetGlobalPoolAllocator()->allocate(sizeof(TString));
return new(memory) TString(s);
}