diff options
author | Alex Light <allight@google.com> | 2017-04-18 15:20:38 -0700 |
---|---|---|
committer | Alex Light <allight@google.com> | 2017-04-19 09:44:25 -0700 |
commit | d78ddec5f8eaf1f27e9043f6f42be90149ccb966 (patch) | |
tree | e3c21f93e419ba35486cf8f641d816523a06b9a3 /runtime/runtime_callbacks.cc | |
parent | 66f43b988ad84568a46c1760b314723e9229e6d0 (diff) | |
download | art-d78ddec5f8eaf1f27e9043f6f42be90149ccb966.tar.gz art-d78ddec5f8eaf1f27e9043f6f42be90149ccb966.tar.bz2 art-d78ddec5f8eaf1f27e9043f6f42be90149ccb966.zip |
Implement can_generate_native_method_bind capability
This capability lets one observe and even replace the implementations
of native methods when they are bound.
Test: ./test.py --host -j40
Bug: 37432636
Change-Id: I2432a8e4da1a677e8011ce495296f4ab9f42eb3e
Diffstat (limited to 'runtime/runtime_callbacks.cc')
-rw-r--r-- | runtime/runtime_callbacks.cc | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/runtime/runtime_callbacks.cc b/runtime/runtime_callbacks.cc index 25324b52d1..16d6c13722 100644 --- a/runtime/runtime_callbacks.cc +++ b/runtime/runtime_callbacks.cc @@ -18,6 +18,7 @@ #include <algorithm> +#include "art_method.h" #include "base/macros.h" #include "class_linker.h" #include "thread.h" @@ -131,4 +132,25 @@ void RuntimeCallbacks::NextRuntimePhase(RuntimePhaseCallback::RuntimePhase phase } } +void RuntimeCallbacks::AddMethodCallback(MethodCallback* cb) { + method_callbacks_.push_back(cb); +} + +void RuntimeCallbacks::RemoveMethodCallback(MethodCallback* cb) { + Remove(cb, &method_callbacks_); +} + +void RuntimeCallbacks::RegisterNativeMethod(ArtMethod* method, + const void* in_cur_method, + /*out*/void** new_method) { + void* cur_method = const_cast<void*>(in_cur_method); + *new_method = cur_method; + for (MethodCallback* cb : method_callbacks_) { + cb->RegisterNativeMethod(method, cur_method, new_method); + if (*new_method != nullptr) { + cur_method = *new_method; + } + } +} + } // namespace art |