Give WalkStack's callback a way to terminate early.

Also combine WalkStack and WalkStackUntilUpcall.

Change-Id: Ida25665de72e5fd8e17946886a387b27cf841457
diff --git a/src/dalvik_system_VMStack.cc b/src/dalvik_system_VMStack.cc
index bcfe29b..a83ad45 100644
--- a/src/dalvik_system_VMStack.cc
+++ b/src/dalvik_system_VMStack.cc
@@ -59,18 +59,15 @@
   struct ClosestUserClassLoaderVisitor : public Thread::StackVisitor {
     ClosestUserClassLoaderVisitor(Object* bootstrap, Object* system)
       : bootstrap(bootstrap), system(system), class_loader(NULL) {}
-    virtual void VisitFrame(const Frame& f, uintptr_t) {
-      if (class_loader != NULL) {
-        // If we already found a result, nothing to do.
-        // TODO: need SmartFrame (Thread::WalkStack-like iterator).
-        // (or change VisitFrame to let us return bool to stop visiting)
-        return;
-      }
+    bool VisitFrame(const Frame& f, uintptr_t) {
+      DCHECK(class_loader == NULL);
       Class* c = f.GetMethod()->GetDeclaringClass();
       Object* cl = c->GetClassLoader();
       if (cl != NULL && cl != bootstrap && cl != system) {
         class_loader = cl;
+        return false;
       }
+      return true;
     }
     Object* bootstrap;
     Object* system;