Bug 1324130 - verify accessing the TLS fast-path cache succeeded in _pixman_implementation_lookup_composite. r=jmuizelaar a=jcristau
authorLee Salzman <lsalzman@mozilla.com>
Thu, 16 Feb 2017 13:24:39 -0500
changeset 376259 9a78c5da4fc8855bfe7c3d3234bd3c6e413b4517
parent 376258 d9a2140e577cdb677886ef34449db7b07f796da0
child 376260 db2e6ff03ae1c57ebd4b4dae874d744bd1b8a41b
push id6996
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 20:48:21 +0000
treeherdermozilla-beta@d89512dab048 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjmuizelaar, jcristau
bugs1324130
milestone53.0a2
Bug 1324130 - verify accessing the TLS fast-path cache succeeded in _pixman_implementation_lookup_composite. r=jmuizelaar a=jcristau MozReview-Commit-ID: A9FzMygQCB7
gfx/cairo/libpixman/src/pixman-implementation.c
--- a/gfx/cairo/libpixman/src/pixman-implementation.c
+++ b/gfx/cairo/libpixman/src/pixman-implementation.c
@@ -85,17 +85,25 @@ void
 {
     pixman_implementation_t *imp;
     cache_t *cache;
     int i;
 
     /* Check cache for fast paths */
     cache = PIXMAN_GET_THREAD_LOCAL (fast_path_cache);
 
-    for (i = 0; i < N_CACHED_FAST_PATHS; ++i)
+    /* Bug 1324130 - For compatibility with Windows XP, we have to use Tls
+     * functions for the per-thread fast-path cache instead of the safer
+     * __declspec(thread) mechanism. If the Tls functions fail to set up
+     * the storage for some reason, cache will end up null here. As a
+     * temporary workaround, just check that cache is not null before
+     * using it. The implementation lookup will still function without the
+     * fast-path cache, however, it will incur a slow linear search.
+     */
+    if (cache) for (i = 0; i < N_CACHED_FAST_PATHS; ++i)
     {
 	const pixman_fast_path_t *info = &(cache->cache[i].fast_path);
 
 	/* Note that we check for equality here, not whether
 	 * the cached fast path matches. This is to prevent
 	 * us from selecting an overly general fast path
 	 * when a more specific one would work.
 	 */
@@ -150,17 +158,17 @@ void
     }
 
     /* We should never reach this point */
     _pixman_log_error (FUNC, "No known composite function\n");
     *out_imp = NULL;
     *out_func = dummy_composite_rect;
 
 update_cache:
-    if (i)
+    if (cache && i)
     {
 	while (i--)
 	    cache->cache[i + 1] = cache->cache[i];
 
 	cache->cache[0].imp = *out_imp;
 	cache->cache[0].fast_path.op = op;
 	cache->cache[0].fast_path.src_format = src_format;
 	cache->cache[0].fast_path.src_flags = src_flags;