Release cache while holding thread lock.

Don't bother to hold thread lock while allocating cache.

From-SVN: r167784
This commit is contained in:
Ian Lance Taylor 2010-12-14 05:16:18 +00:00
parent 3a9ed12a58
commit cac7efc966

View File

@ -107,11 +107,11 @@ remove_current_thread (void)
if (list_entry->next != NULL) if (list_entry->next != NULL)
list_entry->next->prev = list_entry->prev; list_entry->next->prev = list_entry->prev;
runtime_MCache_ReleaseAll (mcache);
i = pthread_mutex_unlock (&__go_thread_ids_lock); i = pthread_mutex_unlock (&__go_thread_ids_lock);
__go_assert (i == 0); __go_assert (i == 0);
runtime_MCache_ReleaseAll (mcache);
runtime_lock (&runtime_mheap); runtime_lock (&runtime_mheap);
mstats.heap_alloc += mcache->local_alloc; mstats.heap_alloc += mcache->local_alloc;
mstats.heap_objects += mcache->local_objects; mstats.heap_objects += mcache->local_objects;
@ -225,14 +225,13 @@ __go_go (void (*pfn) (void*), void *arg)
newm->list_entry = list_entry; newm->list_entry = list_entry;
newm->mcache = runtime_allocmcache ();
/* Add the thread to the list of all threads, marked as tentative /* Add the thread to the list of all threads, marked as tentative
since it is not yet ready to go. */ since it is not yet ready to go. */
i = pthread_mutex_lock (&__go_thread_ids_lock); i = pthread_mutex_lock (&__go_thread_ids_lock);
__go_assert (i == 0); __go_assert (i == 0);
/* We use __go_thread_ids_lock as a lock for mheap.cachealloc. */
newm->mcache = runtime_allocmcache ();
if (__go_all_thread_ids != NULL) if (__go_all_thread_ids != NULL)
__go_all_thread_ids->prev = list_entry; __go_all_thread_ids->prev = list_entry;
list_entry->next = __go_all_thread_ids; list_entry->next = __go_all_thread_ids;