Implement finalization.

Also make System.gc no longer a no-op. This replaces some of the
MemberOffsets exposed by Heap with intention-revealing functions
that we'll want to share between all the actual GC implementations,
but there's still more to be done.

Change-Id: I57ba26c0416fbbfe20142b7b6e27108684add7f9
diff --git a/src/object.cc b/src/object.cc
index ce37470..35d8c8a 100644
--- a/src/object.cc
+++ b/src/object.cc
@@ -23,20 +23,6 @@
 
 namespace art {
 
-void Object::AddFinalizerReference() {
-  Thread* self = Thread::Current();
-
-  // TODO: cache these somewhere.
-  ClassLinker* class_linker = Runtime::Current()->GetClassLinker();
-  Class* java_lang_ref_FinalizerReference = class_linker->FindSystemClass("Ljava/lang/ref/FinalizerReference;");
-  CHECK(java_lang_ref_FinalizerReference != NULL);
-  Method* m = java_lang_ref_FinalizerReference->FindDirectMethod("add", "(Ljava/lang/Object;)V");
-  CHECK(m != NULL);
-
-  LOG(INFO) << "Object::AddFinalizerReference invoking FinalizerReference.add for " << (void*) this;
-  m->Invoke(self, NULL, reinterpret_cast<byte*>(this), NULL);
-}
-
 Object* Object::Clone() {
   Class* c = GetClass();
   DCHECK(!c->IsClassClass());
@@ -57,7 +43,7 @@
   memcpy(dst_bytes + offset, src_bytes + offset, num_bytes - offset);
 
   if (c->IsFinalizable()) {
-    copy->AddFinalizerReference();
+    Heap::AddFinalizerReference(copy);
   }
 
   return copy;