Andreas Gampe | e54d992 | 2016-10-11 19:55:37 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2016 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
Andreas Gampe | 06c42a5 | 2017-07-26 14:17:14 -0700 | [diff] [blame] | 17 | #ifndef ART_OPENJDKJVMTI_TI_HEAP_H_ |
| 18 | #define ART_OPENJDKJVMTI_TI_HEAP_H_ |
Andreas Gampe | e54d992 | 2016-10-11 19:55:37 -0700 | [diff] [blame] | 19 | |
| 20 | #include "jvmti.h" |
| 21 | |
Nicolas Geoffray | 4ac0e15 | 2019-09-18 06:14:50 +0000 | [diff] [blame^] | 22 | #include "base/locks.h" |
| 23 | |
| 24 | namespace art { |
| 25 | class Thread; |
| 26 | template<typename T> class ObjPtr; |
| 27 | namespace mirror { |
| 28 | class Object; |
| 29 | } // namespace mirror |
| 30 | } // namespace art |
| 31 | |
Andreas Gampe | e54d992 | 2016-10-11 19:55:37 -0700 | [diff] [blame] | 32 | namespace openjdkjvmti { |
| 33 | |
Alex Light | 72d7e94 | 2019-07-23 13:10:20 -0700 | [diff] [blame] | 34 | class EventHandler; |
Andreas Gampe | e54d992 | 2016-10-11 19:55:37 -0700 | [diff] [blame] | 35 | class ObjectTagTable; |
| 36 | |
| 37 | class HeapUtil { |
| 38 | public: |
| 39 | explicit HeapUtil(ObjectTagTable* tags) : tags_(tags) { |
| 40 | } |
| 41 | |
Andreas Gampe | aa8b60c | 2016-10-12 12:51:25 -0700 | [diff] [blame] | 42 | jvmtiError GetLoadedClasses(jvmtiEnv* env, jint* class_count_ptr, jclass** classes_ptr); |
| 43 | |
Alex Light | bbbcb53 | 2018-08-30 12:50:27 -0700 | [diff] [blame] | 44 | jvmtiError IterateOverInstancesOfClass(jvmtiEnv* env, |
| 45 | jclass klass, |
| 46 | jvmtiHeapObjectFilter filter, |
| 47 | jvmtiHeapObjectCallback cb, |
| 48 | const void* user_data); |
| 49 | |
Andreas Gampe | e54d992 | 2016-10-11 19:55:37 -0700 | [diff] [blame] | 50 | jvmtiError IterateThroughHeap(jvmtiEnv* env, |
| 51 | jint heap_filter, |
| 52 | jclass klass, |
| 53 | const jvmtiHeapCallbacks* callbacks, |
| 54 | const void* user_data); |
| 55 | |
Andreas Gampe | 70bfc8a | 2016-11-03 11:04:15 -0700 | [diff] [blame] | 56 | jvmtiError FollowReferences(jvmtiEnv* env, |
| 57 | jint heap_filter, |
| 58 | jclass klass, |
| 59 | jobject initial_object, |
| 60 | const jvmtiHeapCallbacks* callbacks, |
| 61 | const void* user_data); |
| 62 | |
Andreas Gampe | 8da6d03 | 2016-10-31 19:31:03 -0700 | [diff] [blame] | 63 | static jvmtiError ForceGarbageCollection(jvmtiEnv* env); |
| 64 | |
Andreas Gampe | e54d992 | 2016-10-11 19:55:37 -0700 | [diff] [blame] | 65 | ObjectTagTable* GetTags() { |
| 66 | return tags_; |
| 67 | } |
| 68 | |
Andreas Gampe | 9e38a50 | 2017-03-06 08:19:26 -0800 | [diff] [blame] | 69 | static void Register(); |
| 70 | static void Unregister(); |
| 71 | |
Andreas Gampe | e54d992 | 2016-10-11 19:55:37 -0700 | [diff] [blame] | 72 | private: |
| 73 | ObjectTagTable* tags_; |
| 74 | }; |
| 75 | |
Andreas Gampe | d73aba4 | 2017-05-03 21:40:26 -0700 | [diff] [blame] | 76 | class HeapExtensions { |
| 77 | public: |
Alex Light | 72d7e94 | 2019-07-23 13:10:20 -0700 | [diff] [blame] | 78 | static void Register(EventHandler* eh); |
| 79 | |
Andreas Gampe | d73aba4 | 2017-05-03 21:40:26 -0700 | [diff] [blame] | 80 | static jvmtiError JNICALL GetObjectHeapId(jvmtiEnv* env, jlong tag, jint* heap_id, ...); |
| 81 | static jvmtiError JNICALL GetHeapName(jvmtiEnv* env, jint heap_id, char** heap_name, ...); |
Andreas Gampe | 2eb25e4 | 2017-05-09 17:14:58 -0700 | [diff] [blame] | 82 | |
| 83 | static jvmtiError JNICALL IterateThroughHeapExt(jvmtiEnv* env, |
| 84 | jint heap_filter, |
| 85 | jclass klass, |
| 86 | const jvmtiHeapCallbacks* callbacks, |
| 87 | const void* user_data); |
Alex Light | c14ec8f | 2019-07-18 16:08:41 -0700 | [diff] [blame] | 88 | |
| 89 | static jvmtiError JNICALL ChangeArraySize(jvmtiEnv* env, jobject arr, jsize new_size); |
Alex Light | 72d7e94 | 2019-07-23 13:10:20 -0700 | [diff] [blame] | 90 | |
Nicolas Geoffray | 4ac0e15 | 2019-09-18 06:14:50 +0000 | [diff] [blame^] | 91 | static void ReplaceReference(art::Thread* self, |
| 92 | art::ObjPtr<art::mirror::Object> original, |
| 93 | art::ObjPtr<art::mirror::Object> replacement) |
| 94 | REQUIRES(art::Locks::mutator_lock_, |
| 95 | art::Roles::uninterruptible_); |
| 96 | |
Alex Light | 72d7e94 | 2019-07-23 13:10:20 -0700 | [diff] [blame] | 97 | private: |
| 98 | static EventHandler* gEventHandler; |
Andreas Gampe | d73aba4 | 2017-05-03 21:40:26 -0700 | [diff] [blame] | 99 | }; |
| 100 | |
Andreas Gampe | e54d992 | 2016-10-11 19:55:37 -0700 | [diff] [blame] | 101 | } // namespace openjdkjvmti |
| 102 | |
Andreas Gampe | 06c42a5 | 2017-07-26 14:17:14 -0700 | [diff] [blame] | 103 | #endif // ART_OPENJDKJVMTI_TI_HEAP_H_ |