Refactor allocation entrypoints.

Adds support for switching entrypoints during runtime. Enables
addition of new allocators with out requiring significant copy
paste. Slight speedup on ritzperf probably due to more inlining.

TODO: Ensuring that the entire allocation path is inlined so
that the switch statement in the allocation code is optimized
out.

Rosalloc measurements:
4583
4453
4439
4434
4751

After change:
4184
4287
4131
4335
4097

Change-Id: I1352a3cbcdf6dae93921582726324d91312df5c9
diff --git a/runtime/mirror/class-inl.h b/runtime/mirror/class-inl.h
index 406ab1b..4dcce1e 100644
--- a/runtime/mirror/class-inl.h
+++ b/runtime/mirror/class-inl.h
@@ -357,23 +357,20 @@
   DCHECK_GE(this->object_size_, sizeof(Object));
 }
 
-template <bool kIsMovable, bool kIsInstrumented>
-inline Object* Class::Alloc(Thread* self) {
+template <bool kIsInstrumented>
+inline Object* Class::Alloc(Thread* self, gc::AllocatorType allocator_type) {
   CheckObjectAlloc();
   gc::Heap* heap = Runtime::Current()->GetHeap();
-  if (kIsMovable) {
-    if (kIsInstrumented) {
-      return heap->AllocMovableObjectInstrumented(self, this, this->object_size_);
-    } else {
-      return heap->AllocMovableObjectUninstrumented(self, this, this->object_size_);
-    }
-  } else {
-    if (kIsInstrumented) {
-      return heap->AllocNonMovableObjectInstrumented(self, this, this->object_size_);
-    } else {
-      return heap->AllocNonMovableObjectUninstrumented(self, this, this->object_size_);
-    }
-  }
+  return heap->AllocObjectWithAllocator<kIsInstrumented>(self, this, this->object_size_,
+                                                         allocator_type);
+}
+
+inline Object* Class::AllocObject(Thread* self) {
+  return Alloc<true>(self, Runtime::Current()->GetHeap()->GetCurrentAllocator());
+}
+
+inline Object* Class::AllocNonMovableObject(Thread* self) {
+  return Alloc<true>(self, Runtime::Current()->GetHeap()->GetCurrentNonMovingAllocator());
 }
 
 }  // namespace mirror