Consolidate updating of reflective Field/Method references
Previously we used several different visitors to update Field &
Method references for structural redefinition. We also did not visit
or update JVMTI based references.
This consolidates all the visitors to a single
Runtime::VisitReflectiveTargets function with a single
ReflectiveTargetVisitor type. This simplifies the code around
structural redefinition and ensures that the reflective value holders
are in charge of the actual replacement.
Support was also added for walking internal openjdkjvmti references
for things like field-read/modification events.
Test: ./test.py --host
Bug: 134162467
Change-Id: Ic5fc1db7db0a30f947a1a67259dc024e149ebd57
diff --git a/runtime/runtime.h b/runtime/runtime.h
index 120ca66..0b336c7 100644
--- a/runtime/runtime.h
+++ b/runtime/runtime.h
@@ -43,6 +43,7 @@
#include "offsets.h"
#include "process_state.h"
#include "quick/quick_method_frame_info.h"
+#include "reflective_value_visitor.h"
#include "runtime_stats.h"
namespace art {
@@ -397,6 +398,17 @@
void SweepSystemWeaks(IsMarkedVisitor* visitor)
REQUIRES_SHARED(Locks::mutator_lock_);
+ // Walk all reflective objects and visit their targets as well as any method/fields held by the
+ // runtime threads that are marked as being reflective.
+ void VisitReflectiveTargets(ReflectiveValueVisitor* visitor) REQUIRES(Locks::mutator_lock_);
+ // Helper for visiting reflective targets with lambdas for both field and method reflective
+ // targets.
+ template <typename FieldVis, typename MethodVis>
+ void VisitReflectiveTargets(FieldVis&& fv, MethodVis&& mv) REQUIRES(Locks::mutator_lock_) {
+ FunctionReflectiveValueVisitor frvv(fv, mv);
+ VisitReflectiveTargets(&frvv);
+ }
+
// Returns a special method that calls into a trampoline for runtime method resolution
ArtMethod* GetResolutionMethod();