From: alexrp Date: Mon, 9 Jul 2012 23:14:53 +0000 (+0200) Subject: Use a critical region in mono_gc_alloc_array. X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=commitdiff_plain;h=96b0bddf7165ddb03f8f0a267d39cb60ad55f637;p=mono.git Use a critical region in mono_gc_alloc_array. --- diff --git a/mono/metadata/sgen-alloc.c b/mono/metadata/sgen-alloc.c index 7896c31292a..86095e5d042 100644 --- a/mono/metadata/sgen-alloc.c +++ b/mono/metadata/sgen-alloc.c @@ -474,6 +474,22 @@ mono_gc_alloc_array (MonoVTable *vtable, size_t size, uintptr_t max_length, uint MonoArray *arr; MonoArrayBounds *bounds; +#ifndef DISABLE_CRITICAL_REGION + TLAB_ACCESS_INIT; + ENTER_CRITICAL_REGION; + arr = mono_gc_try_alloc_obj_nolock (vtable, size); + if (arr) { + /*This doesn't require fencing since EXIT_CRITICAL_REGION already does it for us*/ + arr->max_length = max_length; + + bounds = (MonoArrayBounds*)((char*)arr + size - bounds_size); + arr->bounds = bounds; + EXIT_CRITICAL_REGION; + return arr; + } + EXIT_CRITICAL_REGION; +#endif + LOCK_GC; arr = mono_gc_alloc_obj_nolock (vtable, size);