Merge branch 'dev' into dev-slice

This commit is contained in:
Daan Leijen 2021-02-01 15:47:37 -08:00
commit ba84aa2783
2 changed files with 10 additions and 3 deletions

View file

@ -831,7 +831,7 @@ static inline void* mi_tls_slot(size_t slot) mi_attr_noexcept {
res = tcb[slot]; res = tcb[slot];
#elif defined(__aarch64__) #elif defined(__aarch64__)
void** tcb; UNUSED(ofs); void** tcb; UNUSED(ofs);
#if defined(__APPLE__) // issue #343 #if defined(__APPLE__) // M1, issue #343
__asm__ volatile ("mrs %0, tpidrro_el0" : "=r" (tcb)); __asm__ volatile ("mrs %0, tpidrro_el0" : "=r" (tcb));
#else #else
__asm__ volatile ("mrs %0, tpidr_el0" : "=r" (tcb)); __asm__ volatile ("mrs %0, tpidr_el0" : "=r" (tcb));
@ -858,7 +858,7 @@ static inline void mi_tls_slot_set(size_t slot, void* value) mi_attr_noexcept {
tcb[slot] = value; tcb[slot] = value;
#elif defined(__aarch64__) #elif defined(__aarch64__)
void** tcb; UNUSED(ofs); void** tcb; UNUSED(ofs);
#if defined(__APPLE__) // issue #343 #if defined(__APPLE__) // M1, issue #343
__asm__ volatile ("mrs %0, tpidrro_el0" : "=r" (tcb)); __asm__ volatile ("mrs %0, tpidrro_el0" : "=r" (tcb));
#else #else
__asm__ volatile ("mrs %0, tpidr_el0" : "=r" (tcb)); __asm__ volatile ("mrs %0, tpidr_el0" : "=r" (tcb));
@ -868,8 +868,13 @@ static inline void mi_tls_slot_set(size_t slot, void* value) mi_attr_noexcept {
} }
static inline uintptr_t _mi_thread_id(void) mi_attr_noexcept { static inline uintptr_t _mi_thread_id(void) mi_attr_noexcept {
// in all our targets, slot 0 is the pointer to the thread control block #if defined(__aarch64__) && defined(__APPLE__) // M1
// on macOS on the M1, slot 0 does not seem to work, so we fall back to portable C for now. See issue #354
return (uintptr_t)&_mi_heap_default;
#else
// in all our other targets, slot 0 is the pointer to the thread control block
return (uintptr_t)mi_tls_slot(0); return (uintptr_t)mi_tls_slot(0);
#endif
} }
#else #else
// otherwise use standard C // otherwise use standard C

View file

@ -359,7 +359,9 @@ static void mi_heap_absorb(mi_heap_t* heap, mi_heap_t* from) {
// turns out to be ok as `_mi_heap_delayed_free` only visits the list and calls a // turns out to be ok as `_mi_heap_delayed_free` only visits the list and calls a
// the regular `_mi_free_delayed_block` which is safe. // the regular `_mi_free_delayed_block` which is safe.
_mi_heap_delayed_free(from); _mi_heap_delayed_free(from);
#if !defined(_MSC_VER) || (_MSC_VER > 1900) // somehow the following line gives an error in VS2015, issue #353
mi_assert_internal(mi_atomic_load_ptr_relaxed(mi_block_t,&from->thread_delayed_free) == NULL); mi_assert_internal(mi_atomic_load_ptr_relaxed(mi_block_t,&from->thread_delayed_free) == NULL);
#endif
// and reset the `from` heap // and reset the `from` heap
mi_heap_reset_pages(from); mi_heap_reset_pages(from);