Visit methods in stack frames during root visits.

This is necessary for a Baker-style read barrier to-space invariant to
hold. That is, an object either needs to be marked/forwarded as root
or it must be accessed only through a read barrier by mutators. Since
stack frames have direct pointers to methods that a mutator can access
without a read barrier, stack frame methods have to be visited as
root, which makes sense as stack frames are thread roots. This is the
case even if methods do not move as they have to be marked 'gray' for
the objects pointed to by them, which can move, to be recursively
marked/forwarded.

This also puts us in the right direction toward moving methods (and
fields) in the future.

Bug: 12687968
Change-Id: Id32b913c021a140073deea9149a8782e8f308303
diff --git a/runtime/stack.h b/runtime/stack.h
index 963983a..2e32f51 100644
--- a/runtime/stack.h
+++ b/runtime/stack.h
@@ -306,6 +306,11 @@
     return method_;
   }
 
+  mirror::ArtMethod** GetMethodAddress() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
+    DCHECK(method_ != nullptr);
+    return &method_;
+  }
+
   mirror::Object* GetThisObject() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
 
   mirror::Object* GetThisObject(uint16_t num_ins) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
@@ -389,12 +394,7 @@
 #endif
   // Link to previous shadow frame or NULL.
   ShadowFrame* link_;
-#if defined(ART_USE_PORTABLE_COMPILER)
-  // TODO: make const in the portable case.
   mirror::ArtMethod* method_;
-#else
-  mirror::ArtMethod* const method_;
-#endif
   uint32_t dex_pc_;
   uint32_t vregs_[0];
 
@@ -518,6 +518,16 @@
     }
   }
 
+  mirror::ArtMethod** GetMethodAddress() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
+    if (cur_shadow_frame_ != nullptr) {
+      return cur_shadow_frame_->GetMethodAddress();
+    } else if (cur_quick_frame_ != nullptr) {
+      return cur_quick_frame_;
+    } else {
+      return nullptr;
+    }
+  }
+
   bool IsShadowFrame() const {
     return cur_shadow_frame_ != nullptr;
   }