[runtime] Add a few mono mono_class_is_... accessors. (#3891)
[mono.git] / mono / mini / mini-arm-tls.S
index f22a88d0cba75f812089388a3dc5404f346fee45..c8fa1c9519b8a3cd82b81e7b38120ab20f2c0fbd 100644 (file)
@@ -2,6 +2,7 @@
  * mini-arm-tls.S: tls getters and setters for arm platforms
  *
  * Copyright 2015 Xamarin, Inc.
+        * Licensed under the MIT license. See LICENSE file in the project root for full license information.
  */
 
 #include <config.h>
@@ -57,21 +58,20 @@ DECLARE_GLOBAL_SYMBOL mono_fast_get_tls_key_end
 
        .align 4
 DECLARE_GLOBAL_SYMBOL mono_fallback_get_tls_key
-#if defined(__linux__) && defined(HAVE_KW_THREAD)
-       mov     r1, r0
-       mvn     r0, #0xf000
-       sub     r0, r0, #31
+#if defined(__linux__) && defined(HAVE_KW_THREAD) && defined(__ARM_EABI__)
        push    {lr}
-       blx     r0
+       mov     r1, r0
+       bl      __aeabi_read_tp
        ldr     r0, [r0, r1]
        pop     {pc}
-#else
-       push    {lr}
-#if defined(TARGET_IOS)
+#elif defined(TARGET_IOS)
+       push    {r7, lr}
+       mov     r7, sp
        bl      _pthread_getspecific
+       pop     {r7, pc}
 #elif defined(TARGET_ANDROID)
+       push    {lr}
        bl      pthread_getspecific
-#endif
        pop     {pc}
 #endif
        /*
@@ -106,23 +106,54 @@ DECLARE_GLOBAL_SYMBOL mono_fast_set_tls_key_end
 
        .align 4
 DECLARE_GLOBAL_SYMBOL mono_fallback_set_tls_key
-#if defined(__linux__) && defined(HAVE_KW_THREAD)
-       mov     r2, r0
-       mvn     r0, #0xf000
-       sub     r0, r0, #31
+#if defined(__linux__) && defined(HAVE_KW_THREAD) && defined(__ARM_EABI__)
        push    {lr}
-       blx     r0
+       mov     r2, r0
+       bl      __aeabi_read_tp
        str     r1, [r0, r2]
        pop     {pc}
-#else
-       push    {lr}
-#if defined(TARGET_IOS)
+#elif defined(TARGET_IOS)
+       push    {r7, lr}
+       mov     r7, sp
        bl      _pthread_setspecific
+       pop     {r7, pc}
 #elif defined(TARGET_ANDROID)
+       push    {lr}
        bl      pthread_setspecific
-#endif
        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     p15, 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     p15, 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