Bug 1331792 - Stop using MOZ_MAKE_COMPILER_ASSUME_IS_UNREACHABLE in functions called from destructors to better work around VC++ compiler warnings. r=gfx?
authorKartikaya Gupta <kgupta@mozilla.com>
Fri, 20 Jan 2017 14:46:58 -0500
changeset 342154 d4698098ca0d9e2f29bc5407edd968b73bc0ebfa
parent 342153 e2f537aca0433d40905e101756309f2545165b85
child 342155 d295888faea067587708534300861dcba5a38928
push id31345
push userkwierso@gmail.com
push dateFri, 10 Feb 2017 20:35:09 +0000
treeherdermozilla-central@a288fe35e494 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgfx
bugs1331792
milestone53.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 1331792 - Stop using MOZ_MAKE_COMPILER_ASSUME_IS_UNREACHABLE in functions called from destructors to better work around VC++ compiler warnings. r=gfx? MozReview-Commit-ID: Jh0OooS3ijl
gfx/webrender_bindings/RendererOGL.cpp
gfx/webrender_bindings/WebRenderAPI.cpp
gfx/webrender_bindings/webrender_ffi.h
--- a/gfx/webrender_bindings/RendererOGL.cpp
+++ b/gfx/webrender_bindings/RendererOGL.cpp
@@ -34,23 +34,17 @@ RendererOGL::RendererOGL(RefPtr<RenderTh
   MOZ_ASSERT(mWrRenderer);
   MOZ_ASSERT(mBridge);
   MOZ_COUNT_CTOR(RendererOGL);
 }
 
 RendererOGL::~RendererOGL()
 {
   MOZ_COUNT_DTOR(RendererOGL);
-#ifdef MOZ_ENABLE_WEBRENDER
-  // Need to wrap this in an ifdef otherwise VC++ emits a warning (treated as error)
-  // in the non-webrender targets.
-  // We should be able to remove this #ifdef if/when we remove the
-  // MOZ_MAKE_COMPILER_ASSUME_IS_UNREACHABLE annotations in webrender.h
   wr_renderer_delete(mWrRenderer);
-#endif
 }
 
 void
 RendererOGL::Update()
 {
   wr_renderer_update(mWrRenderer);
 }
 
--- a/gfx/webrender_bindings/WebRenderAPI.cpp
+++ b/gfx/webrender_bindings/WebRenderAPI.cpp
@@ -149,23 +149,17 @@ WebRenderAPI::Create(bool aEnableProfile
 
 WebRenderAPI::~WebRenderAPI()
 {
   layers::SynchronousTask task("Destroy WebRenderAPI");
   auto event = MakeUnique<RemoveRenderer>(&task);
   RunOnRenderThread(Move(event));
   task.Wait();
 
-#ifdef MOZ_ENABLE_WEBRENDER
-  // Need to wrap this in an ifdef otherwise VC++ emits a warning (treated as error)
-  // in the non-webrender targets.
-  // We should be able to remove this #ifdef if/when we remove the
-  // MOZ_MAKE_COMPILER_ASSUME_IS_UNREACHABLE annotations in webrender.h
   wr_api_delete(mWrApi);
-#endif
 }
 
 void
 WebRenderAPI::SetRootDisplayList(gfx::Color aBgColor,
                                  Epoch aEpoch,
                                  LayerSize aViewportSize,
                                  DisplayListBuilder& aBuilder)
 {
@@ -257,36 +251,30 @@ WebRenderAPI::SetProfilerEnabled(bool aE
 {
   auto event = MakeUnique<EnableProfiler>(aEnabled);
   RunOnRenderThread(Move(event));
 }
 
 void
 WebRenderAPI::RunOnRenderThread(UniquePtr<RendererEvent>&& aEvent)
 {
-#ifdef MOZ_ENABLE_WEBRENDER
-  // ifdef this out so that calling this function from a destructor does
-  // not break windows builds...
   auto event = reinterpret_cast<uintptr_t>(aEvent.release());
   wr_api_send_external_event(mWrApi, event);
-#endif
 }
 
 DisplayListBuilder::DisplayListBuilder(const LayerIntSize& aSize, PipelineId aId)
 {
   MOZ_COUNT_CTOR(DisplayListBuilder);
   mWrState = wr_state_new(aSize.width, aSize.height, aId.mHandle);
 }
 
 DisplayListBuilder::~DisplayListBuilder()
 {
   MOZ_COUNT_DTOR(DisplayListBuilder);
-#ifdef MOZ_ENABLE_WEBRENDER
   wr_state_delete(mWrState);
-#endif
 }
 
 void
 DisplayListBuilder::Begin(const LayerIntSize& aSize)
 {
   wr_dp_begin(mWrState, aSize.width, aSize.height);
 }
 
--- a/gfx/webrender_bindings/webrender_ffi.h
+++ b/gfx/webrender_bindings/webrender_ffi.h
@@ -261,22 +261,31 @@ struct WrExternalImageIdHandler
   UnlockExternalImageCallback unlock_func;
   ReleaseExternalImageCallback release_func;
 };
 
 // -----
 // Functions exposed by the webrender API
 // -----
 
+// Some useful defines to stub out webrender binding functions for when we
+// build gecko without webrender. We try to tell the compiler these functions
+// are unreachable in that case, but VC++ emits a warning if it finds any
+// unreachable functions invoked from destructors. That warning gets turned into
+// an error and causes the build to fail. So for wr_* functions called by
+// destructors in C++ classes, use WR_DESTRUCTOR_SAFE_FUNC instead, which omits
+// the unreachable annotation.
 #ifdef MOZ_ENABLE_WEBRENDER
 #  define WR_INLINE
 #  define WR_FUNC
+#  define WR_DESTRUCTOR_SAFE_FUNC
 #else
 #  define WR_INLINE inline
 #  define WR_FUNC { MOZ_MAKE_COMPILER_ASSUME_IS_UNREACHABLE("WebRender disabled"); }
+#  define WR_DESTRUCTOR_SAFE_FUNC {}
 #endif
 
 // Structs defined in Rust, but opaque to C++ code.
 struct WrWindowState;
 struct WrRenderer;
 struct WrState;
 struct WrAPI;
 
@@ -294,34 +303,34 @@ WR_FUNC;
 
 WR_INLINE bool
 wr_renderer_current_epoch(WrRenderer* renderer, WrPipelineId pipeline_id,
                           WrEpoch* out_epoch)
 WR_FUNC;
 
 WR_INLINE void
 wr_renderer_delete(WrRenderer* renderer)
-WR_FUNC;
+WR_DESTRUCTOR_SAFE_FUNC;
 
 WR_INLINE void
 wr_gl_init(void* aGLContext)
 WR_FUNC;
 
 WR_INLINE void
 wr_window_new(WrWindowId window_id, bool enable_profiler, WrAPI** out_api,
               WrRenderer** out_renderer)
 WR_FUNC;
 
 WR_INLINE void
 wr_window_remove_pipeline(WrWindowState* window, WrState* state)
 WR_FUNC;
 
 WR_INLINE void
 wr_api_delete(WrAPI* api)
-WR_FUNC;
+WR_DESTRUCTOR_SAFE_FUNC;
 
 WR_INLINE WrImageKey
 wr_api_add_image(WrAPI* api, uint32_t width, uint32_t height,
                  uint32_t stride, WrImageFormat format, uint8_t *bytes,
                  size_t size)
 WR_FUNC;
 
 WR_INLINE WrImageKey
@@ -343,17 +352,17 @@ wr_api_set_root_pipeline(WrAPI* api, WrP
 WR_FUNC;
 
 WR_INLINE void
 wr_api_set_root_display_list(WrAPI* api, WrState* state, uint32_t epoch, float w, float h)
 WR_FUNC;
 
 WR_INLINE void
 wr_api_send_external_event(WrAPI* api, uintptr_t evt)
-WR_FUNC;
+WR_DESTRUCTOR_SAFE_FUNC;
 
 WR_INLINE void
 wr_window_init_pipeline_epoch(WrWindowState* window, WrPipelineId pipeline, uint32_t width, uint32_t height)
 WR_FUNC;
 
 WR_INLINE WrFontKey
 wr_api_add_raw_font(WrAPI* api, uint8_t* font_buffer, size_t buffer_size)
 WR_FUNC;
@@ -370,17 +379,17 @@ wr_init_window(WrPipelineId root_pipelin
 WR_FUNC;
 
 WR_INLINE WrState*
 wr_state_new(uint32_t width, uint32_t height, WrPipelineId pipeline_id)
 WR_FUNC;
 
 WR_INLINE void
 wr_state_delete(WrState* state)
-WR_FUNC;
+WR_DESTRUCTOR_SAFE_FUNC;
 
 WR_INLINE void
 wr_destroy(WrWindowState* wrWindow, WrState* WrState)
 WR_FUNC;
 
 WR_INLINE WrImageKey
 wr_add_image(WrWindowState* wrWindow, uint32_t width, uint32_t height,
              uint32_t stride, WrImageFormat format, uint8_t *bytes, size_t size)
@@ -480,11 +489,12 @@ wr_readback_into_buffer(WrWindowState* w
 WR_FUNC;
 
 // TODO: Remove.
 WR_INLINE void
 wr_profiler_set_enabled(WrWindowState* wrWindow, bool enabled)
 WR_FUNC;
 
 #undef WR_FUNC
+#undef WR_DESTRUCTOR_SAFE_FUNC
 } // extern "C"
 
 #endif // WR_h