Rework the newly-allocated region logic in RegionSpace.

- Mark large (and large tail) regions as "newly allocated" in
  RegionSpace::AllocLarge when they are allocated for non-evac
  purposes, the same way non-large regions were already marked
  as "newly allocated" in RegionSpace::AllocateRegion when
  they were allocated for non-evac purposes.
- Clear the "newly allocated" status of regions only when
  setting them as (evac) from-space and non-evac from-space.

This addresses an issue with Sticky-Bit (Generational) CC collection,
where an assertion in ConcurrentCopying::VerifyNoMissingCardMarks
could fail when a recently allocated large region held a dead large
object holding a (presumably stale) object reference pointing to a
newly allocated (non-large) region.

Test: ART run-tests & gtests, libcore tests, JDWP tests (host & device)
Test: Device/emulator boot test
Bug: 67628039
Bug: 12687968
Change-Id: Idd20c159db9359ee783a421ec699d3e3aa450552
diff --git a/runtime/gc/collector/concurrent_copying.cc b/runtime/gc/collector/concurrent_copying.cc
index d0c10be..c9300b5 100644
--- a/runtime/gc/collector/concurrent_copying.cc
+++ b/runtime/gc/collector/concurrent_copying.cc
@@ -627,8 +627,6 @@
 
   void CheckReference(mirror::Object* ref, int32_t offset = -1) const
       REQUIRES_SHARED(Locks::mutator_lock_) {
-    // FIXME: This assertion is failing in 004-ThreadStress most of
-    // the time with Sticky-Bit (Generational) CC.
     CHECK(ref == nullptr || !cc_->region_space_->IsInNewlyAllocatedRegion(ref))
         << holder_->PrettyTypeOf() << "(" << holder_.Ptr() << ") references object "
         << ref->PrettyTypeOf() << "(" << ref << ") in newly allocated region at offset=" << offset;
@@ -1618,7 +1616,9 @@
   }
   space::RegionSpace::RegionType rtype = region_space_->GetRegionType(to_ref);
   bool add_to_live_bytes = false;
-  DCHECK(!region_space_->IsInNewlyAllocatedRegion(to_ref));
+  // Invariant: There should be no object from a newly-allocated
+  // region (either large or non-large) on the mark stack.
+  DCHECK(!region_space_->IsInNewlyAllocatedRegion(to_ref)) << to_ref;
   if (rtype == space::RegionSpace::RegionType::kRegionTypeUnevacFromSpace) {
     // Mark the bitmap only in the GC thread here so that we don't need a CAS.
     if (!kUseBakerReadBarrier ||