Implement EnableCollection, DisableCollection, IsCollected, and fix Exit.

Rewrites the object registry to not just be one big leak. We use jweaks
by default, which means (a) the GC doesn't need to know anything about us
and (b) we don't cause unnecessary heap retention. We promote to regular
JNI global references if the debugger asks us to.

The problem with VirtualMachine.Exit turned out to be that you're supposed
to send a success reply to the command before exiting. This is a bit awkward
with our current division of responsibilities, but it lets us pass another
test.

Also log a summary of our replies when -verbose:jdwp is in effect, not
just the requests.

Change-Id: Idb33e99fe7d8bee7a79152d81fee42e2af00852b
diff --git a/src/jdwp/jdwp_main.cc b/src/jdwp/jdwp_main.cc
index 9e6825c..cbac920 100644
--- a/src/jdwp/jdwp_main.cc
+++ b/src/jdwp/jdwp_main.cc
@@ -104,7 +104,9 @@
       event_thread_lock_("JDWP event thread lock"),
       event_thread_cond_("JDWP event thread condition variable", event_thread_lock_),
       event_thread_id_(0),
-      ddm_is_active_(false) {
+      ddm_is_active_(false),
+      should_exit_(false),
+      exit_status_(0) {
 }
 
 /*
@@ -351,6 +353,10 @@
         break;
       }
 
+      if (should_exit_) {
+        exit(exit_status_);
+      }
+
       if (first && !(*transport_->awaitingHandshake)(this)) {
         /* handshake worked, tell the interpreter that we're active */
         first = false;
@@ -462,6 +468,12 @@
   return now - last;
 }
 
+void JdwpState::ExitAfterReplying(int exit_status) {
+  LOG(WARNING) << "Debugger told VM to exit with status " << exit_status;
+  should_exit_ = true;
+  exit_status_ = exit_status;
+}
+
 std::ostream& operator<<(std::ostream& os, const JdwpLocation& rhs) {
   os << "JdwpLocation["
      << Dbg::GetClassName(rhs.class_id) << "." << Dbg::GetMethodName(rhs.method_id)