DexCachePair : Add an Assign method.

This prevents the logic for determining a slot from the type ID from
being scattered all over the place.

Bug: 30550796
Test: make test-art-host
Change-Id: I4ad6db8b730dc617fa8474a71c3794963b58279b
diff --git a/runtime/mirror/dex_cache-inl.h b/runtime/mirror/dex_cache-inl.h
index 41692da..8ffd2e1 100644
--- a/runtime/mirror/dex_cache-inl.h
+++ b/runtime/mirror/dex_cache-inl.h
@@ -44,10 +44,7 @@
 }
 
 inline void DexCache::SetResolvedString(uint32_t string_idx, mirror::String* resolved) {
-  DCHECK_LT(string_idx % NumStrings(), NumStrings());
-  GetStrings()[string_idx % NumStrings()].store(
-      StringDexCachePair(resolved, string_idx),
-      std::memory_order_relaxed);
+  StringDexCachePair::Assign(GetStrings(), string_idx, resolved, NumStrings());
   Runtime* const runtime = Runtime::Current();
   if (UNLIKELY(runtime->IsActiveTransaction())) {
     DCHECK(runtime->IsAotCompiler());
@@ -94,9 +91,8 @@
   DCHECK(Runtime::Current()->IsMethodHandlesEnabled());
   DCHECK_LT(proto_idx, NumResolvedMethodTypes());  // NOTE: Unchecked, i.e. not throwing AIOOB.
 
-  GetResolvedMethodTypes()[proto_idx % NumResolvedMethodTypes()].store(
-      MethodTypeDexCachePair(resolved, proto_idx), std::memory_order_relaxed);
-
+  MethodTypeDexCachePair::Assign(GetResolvedMethodTypes(), proto_idx, resolved,
+                                 NumResolvedMethodTypes());
   // TODO: Fine-grained marking, so that we don't need to go through all arrays in full.
   Runtime::Current()->GetHeap()->WriteBarrierEveryFieldOf(this);
 }