improve GLES jumptables

in the common case this saves one instructions per jump
(which will help with the i-cache).

this change also gets rid of the "use slow tls" option,
which was useless. So at least now architectures that don't have
assembly bindings will perform much better.

Change-Id: I31be6c06ad2136b50ef3a1ac14682d7812ad40d2
diff --git a/opengl/libs/hooks.h b/opengl/libs/hooks.h
index b2a684c..4b43198 100644
--- a/opengl/libs/hooks.h
+++ b/opengl/libs/hooks.h
@@ -32,13 +32,11 @@
 #include <GLES3/gl3.h>
 #include <GLES3/gl3ext.h>
 
-#if !defined(__arm__) && !defined(__mips__)
-#define USE_SLOW_BINDING            1
-#else
-#define USE_SLOW_BINDING            0
-#endif
+// set to 1 for debugging
+#define USE_SLOW_BINDING    0
+
 #undef NELEM
-#define NELEM(x)                    (sizeof(x)/sizeof(*(x)))
+#define NELEM(x)            (sizeof(x)/sizeof(*(x)))
 
 // maximum number of GL extensions that can be used simultaneously in
 // a given process. this limitation exists because we need to have
@@ -47,15 +45,7 @@
 #define MAX_NUMBER_OF_GL_EXTENSIONS 256
 
 
-#if defined(HAVE_ANDROID_OS) && !USE_SLOW_BINDING && __OPTIMIZE__
-#define USE_FAST_TLS_KEY            1
-#else
-#define USE_FAST_TLS_KEY            0
-#endif
-
-#if USE_FAST_TLS_KEY
-#   include <bionic_tls.h>  /* special private C library header */
-#endif
+#include <bionic_tls.h>  /* special private C library header */
 
 // ----------------------------------------------------------------------------
 namespace android {
@@ -84,7 +74,20 @@
 #undef EGL_ENTRY
 
 EGLAPI void setGlThreadSpecific(gl_hooks_t const *value);
-EGLAPI gl_hooks_t const* getGlThreadSpecific();
+
+// We have a dedicated TLS slot in bionic
+inline gl_hooks_t const * volatile * get_tls_hooks() {
+    volatile void *tls_base = __get_tls();
+    gl_hooks_t const * volatile * tls_hooks =
+            reinterpret_cast<gl_hooks_t const * volatile *>(tls_base);
+    return tls_hooks;
+}
+
+inline EGLAPI gl_hooks_t const* getGlThreadSpecific() {
+    gl_hooks_t const * volatile * tls_hooks = get_tls_hooks();
+    gl_hooks_t const* hooks = tls_hooks[TLS_SLOT_OPENGL_API];
+    return hooks;
+}
 
 // ----------------------------------------------------------------------------
 }; // namespace android