[arm] Fast tls implementation for android marshmallow
authorVlad Brezae <brezaevlad@gmail.com>
Fri, 20 Nov 2015 14:51:21 +0000 (16:51 +0200)
committerVlad Brezae <brezaevlad@gmail.com>
Fri, 4 Dec 2015 21:20:38 +0000 (16:20 -0500)
mono/mini/mini-arm-tls.S
mono/mini/mini-arm-tls.h

index f22a88d0cba75f812089388a3dc5404f346fee45..7e26b7c2e291ff815fac10a95d2388d44a82f42f 100644 (file)
@@ -124,5 +124,37 @@ DECLARE_GLOBAL_SYMBOL mono_fallback_set_tls_key
        pop     {pc}
 #endif
 
+
+       /* Additional tls getters/setters */
+
+#if defined(TARGET_ANDROID)
+       .align 4
+DECLARE_GLOBAL_SYMBOL mono_fast_get_tls_key2
+       bic     r0, r0, #0x80000000
+       mrc     15, 0, r1, cr13, cr0, #3
+       lsls    r0, r0, #3
+       ldr     r1, [r1, #4]
+       add     r0, r1
+       ldr     r0, [r0, #0x68]
+       bx      lr
+DECLARE_GLOBAL_SYMBOL mono_fast_get_tls_key2_end
+
+       /*
+        * In order to use this fast setter we need to make sure that the key was
+        * already set at least once using the pthread api, otherwise it will not
+        * interwork with the api.
+        */
+       .align 4
+DECLARE_GLOBAL_SYMBOL mono_fast_set_tls_key2
+       bic     r0, r0, #0x80000000
+       mrc     15, 0, r2, cr13, cr0, #3
+       lsls    r0, r0, #3
+       ldr     r2, [r2, #4]
+       add     r0, r2
+       str     r1, [r0, #0x68]
+       bx      lr
+DECLARE_GLOBAL_SYMBOL mono_fast_set_tls_key2_end
+#endif
+
 #endif
 
index a61d699cf17f0bc629f7435ddaeff0aac160b8cc..57d584ffe4e02525d5b35441773b9c88fc684e86 100644 (file)
@@ -5,6 +5,8 @@
 
 int mono_fast_get_tls_key (int);
 void mono_fast_set_tls_key (int, int);
+int mono_fast_get_tls_key2 (int);
+void mono_fast_set_tls_key2 (int, int);
 
 /* Fallback tls getters/setters */
 
@@ -15,6 +17,8 @@ void mono_fallback_set_tls_key (int, int);
 
 void mono_fast_get_tls_key_end (void);
 void mono_fast_set_tls_key_end (void);
+void mono_fast_get_tls_key2_end (void);
+void mono_fast_set_tls_key2_end (void);
 
 
 /* Structure that maps a possible  tls implementation to the corresponding thunks */
@@ -38,7 +42,8 @@ static MonoTlsImplementation known_tls_implementations [] = {
        { (guint32[]) {0xe2403003, 0xe353003c, 0xe92d4010, 0xe1a04000, 0x9a000001, 0xe3a00000, 0xe8bd8010, 0xe3e00a0f, 0xe240101f, 0xe12fff31, 0xe7900104, 0xe8bd8010}, 48, TRUE, mono_fast_get_tls_key, mono_fast_get_tls_key_end, mono_fast_set_tls_key, mono_fast_set_tls_key_end}, /* 1.5 */
        { (guint32[]) {0xe2402003, 0xe1a03000, 0xe352003c, 0x8a000002, 0xee1d0f70, 0xe7900103, 0xe12fff1e}, 28, FALSE, mono_fast_get_tls_key, mono_fast_get_tls_key_end, mono_fast_set_tls_key, mono_fast_set_tls_key_end}, /* 4.2 */
        { (guint32[]) {0xe2403007, 0xe3530084, 0x8a000002, 0xee1d1f70, 0xe7910100, 0xe12fff1e, 0xe3a00000, 0xe12fff1e}, 32, FALSE, mono_fast_get_tls_key, mono_fast_get_tls_key_end, mono_fast_set_tls_key, mono_fast_set_tls_key_end}, /* 4.4 */
-       { (guint32[]) {0x2b8c1fc3, 0xee1dd804, 0xf8511f70, 0x47700020, 0x47702000}, 20, FALSE, mono_fast_get_tls_key, mono_fast_get_tls_key_end, mono_fast_set_tls_key, mono_fast_set_tls_key_end} /* 5.0 */
+       { (guint32[]) {0x2b8c1fc3, 0xee1dd804, 0xf8511f70, 0x47700020, 0x47702000}, 20, FALSE, mono_fast_get_tls_key, mono_fast_get_tls_key_end, mono_fast_set_tls_key, mono_fast_set_tls_key_end}, /* 5.0 */
+       { (guint32[]) {0xb5104b0f, 0xda114298, 0xf020490e, 0xee1d4000, 0x00c24f70, 0xf8514479, 0x68631030, 0xd50707cc, 0x6e54441a, 0xd103428c, 0xbd106e90}, 44, FALSE, mono_fast_get_tls_key2, mono_fast_get_tls_key2_end, mono_fast_set_tls_key2, mono_fast_set_tls_key2_end} /* 6.0 */
 #endif
 };