Bug 1390386 - Remove old TLS current-context check. - r=daoshengmu
authorJeff Gilbert <jgilbert@mozilla.com>
Fri, 11 Aug 2017 13:41:31 -0700
changeset 445869 3ccf02d862c888c1a7fb0d3420571e61ff9aba05
parent 445868 6d4669e3d2da831012f20e1d56747529e486ffbc
child 445870 3b910891a85bf4c99f765b76e695e1430b4253e2
push id8527
push userCallek@gmail.com
push dateThu, 11 Jan 2018 21:05:50 +0000
treeherdermozilla-beta@95342d212a7a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdaoshengmu
bugs1390386
milestone59.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1390386 - Remove old TLS current-context check. - r=daoshengmu MozReview-Commit-ID: 18GSNztjkTM
gfx/gl/GLContext.cpp
gfx/gl/GLContext.h
gfx/thebes/gfxPlatform.cpp
--- a/gfx/gl/GLContext.cpp
+++ b/gfx/gl/GLContext.cpp
@@ -55,20 +55,16 @@
 #endif
 
 namespace mozilla {
 namespace gl {
 
 using namespace mozilla::gfx;
 using namespace mozilla::layers;
 
-#ifdef MOZ_GL_DEBUG
-unsigned GLContext::sCurrentGLContextTLS = -1;
-#endif
-
 MOZ_THREAD_LOCAL(const GLContext*) 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 } }
@@ -3030,30 +3026,16 @@ GetBytesPerTexel(GLenum format, GLenum t
 }
 
 bool
 GLContext::MakeCurrent(bool aForce) const
 {
     if (MOZ_UNLIKELY( IsDestroyed() ))
         return false;
 
-#ifdef MOZ_GL_DEBUG
-    PR_SetThreadPrivate(sCurrentGLContextTLS, (void*)this);
-
-    // XXX this assertion is disabled because it's triggering on Mac;
-    // we need to figure out why and reenable it.
-#if 0
-    // IsOwningThreadCurrent is a bit of a misnomer;
-    // the "owning thread" is the creation thread,
-    // and the only thread that can own this.  We don't
-    // support contexts used on multiple threads.
-    NS_ASSERTION(IsOwningThreadCurrent(),
-                 "MakeCurrent() called on different thread than this context was created on!");
-#endif
-#endif
     if (mUseTLSIsCurrent && !aForce && sCurrentContext.get() == this) {
         MOZ_ASSERT(IsCurrent());
         return true;
     }
 
     if (!MakeCurrentImpl(aForce))
         return false;
 
@@ -3082,24 +3064,16 @@ GLContext::BeforeGLCall_Debug(const char
 {
     MOZ_ASSERT(mDebugFlags);
 
     FlushErrors();
 
     if (mDebugFlags & DebugFlagTrace) {
         printf_stderr("[gl:%p] > %s\n", this, funcName);
     }
-
-    GLContext* tlsContext = (GLContext*)PR_GetThreadPrivate(sCurrentGLContextTLS);
-    if (this != tlsContext) {
-        printf_stderr("Fatal: %s called on non-current context %p. The"
-                      " current context for this thread is %p.\n",
-                      funcName, this, tlsContext);
-        MOZ_CRASH("GFX: GLContext is not current.");
-    }
 }
 
 void
 GLContext::AfterGLCall_Debug(const char* const funcName) const
 {
     MOZ_ASSERT(mDebugFlags);
 
     // calling fFinish() immediately after every GL call makes sure that if this GL command crashes,
--- a/gfx/gl/GLContext.h
+++ b/gfx/gl/GLContext.h
@@ -3307,22 +3307,16 @@ public:
 // -----------------------------------------------------------------------------
 // Everything that isn't standard GL APIs
 protected:
     typedef gfx::SurfaceFormat SurfaceFormat;
 
     virtual bool MakeCurrentImpl(bool aForce) const = 0;
 
 public:
-#ifdef MOZ_GL_DEBUG
-    static void StaticInit() {
-        PR_NewThreadPrivateIndex(&sCurrentGLContextTLS, nullptr);
-    }
-#endif
-
     bool MakeCurrent(bool aForce = false) const;
 
     virtual bool Init() = 0;
 
     virtual bool SetupLookupFunction() = 0;
 
     virtual void ReleaseSurface() {}
 
@@ -3456,25 +3450,16 @@ public:
 protected:
     RefPtr<GLContext> mSharedContext;
 
     // The thread id which this context was created.
     PlatformThreadId mOwningThreadId;
 
     GLContextSymbols mSymbols;
 
-#ifdef MOZ_GL_DEBUG
-    // Non-zero debug flags will check that we don't send call
-    // to a GLContext that isn't current on the current
-    // thread.
-    // Store the current context when binding to thread local
-    // storage to support debug flags on an arbitrary thread.
-    static unsigned sCurrentGLContextTLS;
-#endif
-
     UniquePtr<GLBlitHelper> mBlitHelper;
     UniquePtr<GLReadTexImageHelper> mReadTexImageHelper;
 
 public:
     GLBlitHelper* BlitHelper();
     GLBlitTextureImageHelper* BlitTextureImageHelper();
     GLReadTexImageHelper* ReadTexImageHelper();
 
--- a/gfx/thebes/gfxPlatform.cpp
+++ b/gfx/thebes/gfxPlatform.cpp
@@ -766,20 +766,16 @@ gfxPlatform::Init()
 
 #ifdef USE_SKIA
     SkGraphics::Init();
 #  ifdef MOZ_ENABLE_FREETYPE
     SkInitCairoFT(gPlatform->FontHintingEnabled());
 #  endif
 #endif
 
-#ifdef MOZ_GL_DEBUG
-    GLContext::StaticInit();
-#endif
-
     InitLayersIPC();
 
     gPlatform->PopulateScreenInfo();
     gPlatform->ComputeTileSize();
 
     nsresult rv;
     rv = gfxPlatformFontList::Init();
     if (NS_FAILED(rv)) {