ART: Add ThreadStart & ThreadEnd

Add support for ThreadStart and ThreadEnd events. Add tests.

Bug: 31684920
Test: m test-art-host-run-test-924-threads
Change-Id: I516993402747ffdc9a7d66985b21b95c059be107
diff --git a/runtime/runtime.cc b/runtime/runtime.cc
index 4936a2f..1218a98 100644
--- a/runtime/runtime.cc
+++ b/runtime/runtime.cc
@@ -735,6 +735,13 @@
                             GetInstructionSetString(kRuntimeISA));
   }
 
+  // Send the initialized phase event. Send it before starting daemons, as otherwise
+  // sending thread events becomes complicated.
+  {
+    ScopedObjectAccess soa(self);
+    callbacks_->NextRuntimePhase(RuntimePhaseCallback::RuntimePhase::kInit);
+  }
+
   StartDaemonThreads();
 
   {
@@ -756,12 +763,6 @@
                  0);
   }
 
-  // Send the initialized phase event.
-  {
-    ScopedObjectAccess soa(self);
-    callbacks_->NextRuntimePhase(RuntimePhaseCallback::RuntimePhase::kInit);
-  }
-
   return true;
 }