- /*First case, we overflowed the tlab, get a new one*/
- if (G_UNLIKELY (new_next >= TLAB_REAL_END)) {
+ real_end = TLAB_REAL_END;
+ available_in_tlab = real_end - (char*)p;
+
+ if (G_LIKELY (new_next < real_end)) {
+ TLAB_NEXT = new_next;
+ } else if (available_in_tlab > SGEN_MAX_NURSERY_WASTE) {
+ /* Allocate directly from the nursery */
+ p = mono_sgen_nursery_alloc (size);
+ if (!p)
+ return NULL;
+
+ if (nursery_clear_policy == CLEAR_AT_TLAB_CREATION)
+ memset (p, 0, size);
+ } else {