Revert "Revert "Basic obsolete methods support""
This reverts commit b81a9840b44480bfeacd74b8d9f51e06f295411d.
There were 2 issues with the original CL's test 916-obsolete-jit that
caused it to sporadically fail.
First, when checking if we had jitted the function under test in
916-obsolete-jit we failed to check to see if the function 'doCall',
which is used to work-around bugs in our deoptimization & compilation
systems, had also been jitted.
In the case where the 'sayHi' function had been jitted but the
'doCall' function had not we would (correctly) fail to redefine the
'Transform' class since we would not be able to deoptimize the 'sayHi'
function since it is under a quick_to_interpreter_bridge (runtime)
frame.
Secondly, the function Main.isInterpretedFunction was incorrect and
would always return false, regardless of the actual state of the
function. This would cause the test to fail as the
quick_to_interpreter_bridge frame prevented deoptimization of the
obsoleted function. Usually the warm-up period was enough to make sure
the methods were jitted anyway but this was not guaranteed.
Both of these problems become more likely to occur on systems with
more cpu contention such as the buildbots.
Test: stress --cpu 60 &; while ./test/run-test --host --jit 916; do ; done
Reason for revert: Fixed bug in test that was causing failures.
Original Tests:
Test: ./test/run-test --host 914
Test: ./test/run-test --host 915
Test: ./test/run-test --host 916
Test: mma -j40 test-art-host
Test: ART_TEST_JIT=true \
ART_TEST_INTERPRETER=true mma -j40 test-art-host
Test: ./art/tools/run-jdwp-tests.sh --mode=host --variant=X64
Test: ./art/tools/run-jdwp-tests.sh --mode=host --variant=X64 --no-jit
Bug: 32369913
Bug: 33630159
Change-Id: If1a92e47b90965a7dc21c5826185debe62bd1554
diff --git a/runtime/openjdkjvmti/ti_redefine.h b/runtime/openjdkjvmti/ti_redefine.h
index 73cfc2b..9d23ce4 100644
--- a/runtime/openjdkjvmti/ti_redefine.h
+++ b/runtime/openjdkjvmti/ti_redefine.h
@@ -64,6 +64,8 @@
namespace openjdkjvmti {
// Class that can redefine a single class's methods.
+// TODO We should really make this be driven by an outside class so we can do multiple classes at
+// the same time and have less required cleanup.
class Redefiner {
public:
// Redefine the given class with the given dex data. Note this function does not take ownership of
@@ -124,6 +126,14 @@
// in the future. For now we will just take the memory hit.
bool EnsureClassAllocationsFinished() REQUIRES_SHARED(art::Locks::mutator_lock_);
+ // Ensure that obsolete methods are deoptimized. This is needed since optimized methods may have
+ // pointers to their ArtMethods stashed in registers that they then use to attempt to hit the
+ // DexCache.
+ void EnsureObsoleteMethodsAreDeoptimized()
+ REQUIRES(art::Locks::mutator_lock_)
+ REQUIRES(!art::Locks::thread_list_lock_,
+ !art::Locks::classlinker_classes_lock_);
+
art::mirror::ClassLoader* GetClassLoader() REQUIRES_SHARED(art::Locks::mutator_lock_);
// This finds the java.lang.DexFile we will add the native DexFile to as part of the classpath.
@@ -170,6 +180,13 @@
bool UpdateClass(art::ObjPtr<art::mirror::Class> mclass,
art::ObjPtr<art::mirror::DexCache> new_dex_cache)
REQUIRES(art::Locks::mutator_lock_);
+
+ bool FindAndAllocateObsoleteMethods(art::mirror::Class* art_klass)
+ REQUIRES(art::Locks::mutator_lock_);
+
+ void FillObsoleteMethodMap(art::mirror::Class* art_klass,
+ const std::unordered_map<art::ArtMethod*, art::ArtMethod*>& obsoletes)
+ REQUIRES(art::Locks::mutator_lock_);
};
} // namespace openjdkjvmti