Bug 1390386 - Use uintptr for the thread-local. - r=daoshengmu draft
authorJeff Gilbert <jgilbert@mozilla.com>
Mon, 27 Nov 2017 15:42:16 -0800
changeset 703953 6ed1ffde0e76a3851c16669eb0cce1eed21a6094
parent 702519 c6719c25525dd30cbe1ec0aba8bf40418106715e
child 741938 58da3a70ac2989a7d9b474a425f0ea7a27f9fef6
push id91006
push userbmo:jgilbert@mozilla.com
push dateMon, 27 Nov 2017 23:44:27 +0000
reviewersdaoshengmu
bugs1390386
milestone59.0a1
Bug 1390386 - Use uintptr for the thread-local. - r=daoshengmu We're just doing a value comparison, so there's no reason this needs to be a pointer. MozReview-Commit-ID: 6ck2s2fsdq5
gfx/gl/GLContext.cpp
gfx/gl/GLContext.h
--- a/gfx/gl/GLContext.cpp
+++ b/gfx/gl/GLContext.cpp
@@ -55,17 +55,17 @@
 #endif
 
 namespace mozilla {
 namespace gl {
 
 using namespace mozilla::gfx;
 using namespace mozilla::layers;
 
-MOZ_THREAD_LOCAL(const GLContext*) GLContext::sCurrentContext;
+MOZ_THREAD_LOCAL(uintptr_t) GLContext::sCurrentContext;
 
 // If adding defines, don't forget to undefine symbols. See #undef block below.
 #define CORE_SYMBOL(x) { (PRFuncPtr*) &mSymbols.f##x, { #x, nullptr } }
 #define CORE_EXT_SYMBOL2(x,y,z) { (PRFuncPtr*) &mSymbols.f##x, { #x, #x #y, #x #z, nullptr } }
 #define EXT_SYMBOL2(x,y,z) { (PRFuncPtr*) &mSymbols.f##x, { #x #y, #x #z, nullptr } }
 #define EXT_SYMBOL3(x,y,z,w) { (PRFuncPtr*) &mSymbols.f##x, { #x #y, #x #z, #x #w, nullptr } }
 #define END_SYMBOLS { nullptr, { nullptr } }
 
@@ -291,17 +291,17 @@ GLContext::GLContext(CreateContextFlags 
     mWorkAroundDriverBugs(true),
     mSyncGLCallCount(0),
     mHeavyGLCallsSinceLastFlush(false)
 {
     mMaxViewportDims[0] = 0;
     mMaxViewportDims[1] = 0;
     mOwningThreadId = PlatformThread::CurrentId();
     MOZ_ALWAYS_TRUE( sCurrentContext.init() );
-    sCurrentContext.set(nullptr);
+    sCurrentContext.set(0);
 }
 
 GLContext::~GLContext() {
     NS_ASSERTION(IsDestroyed(), "GLContext implementation must call MarkDestroyed in destructor!");
 #ifdef MOZ_GL_DEBUG
     if (mSharedContext) {
         GLContext* tip = mSharedContext;
         while (tip->mSharedContext)
@@ -3029,31 +3029,31 @@ bool
 GLContext::MakeCurrent(bool aForce) const
 {
     if (MOZ_UNLIKELY( IsDestroyed() ))
         return false;
 
     if (MOZ_LIKELY( !aForce )) {
         bool isCurrent;
         if (mUseTLSIsCurrent) {
-            isCurrent = (sCurrentContext.get() == this);
+            isCurrent = (sCurrentContext.get() == reinterpret_cast<uintptr_t>(this));
         } else {
             isCurrent = IsCurrentImpl();
         }
         if (MOZ_LIKELY( isCurrent )) {
             MOZ_ASSERT(IsCurrentImpl());
             return true;
         }
     }
 
     if (!MakeCurrentImpl())
         return false;
 
     if (mUseTLSIsCurrent) {
-        sCurrentContext.set(this);
+        sCurrentContext.set(reinterpret_cast<uintptr_t>(this));
     }
     return true;
 }
 
 void
 GLContext::ResetSyncCallCount(const char* resetReason) const
 {
     if (ShouldSpew()) {
--- a/gfx/gl/GLContext.h
+++ b/gfx/gl/GLContext.h
@@ -191,17 +191,17 @@ enum class GLRenderer {
 
 class GLContext
     : public GLLibraryLoader
     , public GenericAtomicRefCounted
     , public SupportsWeakPtr<GLContext>
 {
 public:
     MOZ_DECLARE_WEAKREFERENCE_TYPENAME(GLContext)
-    static MOZ_THREAD_LOCAL(const GLContext*) sCurrentContext;
+    static MOZ_THREAD_LOCAL(uintptr_t) sCurrentContext;
 
     bool mImplicitMakeCurrent;
 
 // -----------------------------------------------------------------------------
 // basic getters
 public:
 
     /**