blob: 382d80f5762a0ecc6f03cf8ea996790cdb21cb97 [file] [log] [blame]
Andreas Gampee54d9922016-10-11 19:55:37 -07001/*
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 Gampe06c42a52017-07-26 14:17:14 -070017#ifndef ART_OPENJDKJVMTI_TI_HEAP_H_
18#define ART_OPENJDKJVMTI_TI_HEAP_H_
Andreas Gampee54d9922016-10-11 19:55:37 -070019
20#include "jvmti.h"
21
22namespace openjdkjvmti {
23
24class ObjectTagTable;
25
26class HeapUtil {
27 public:
28 explicit HeapUtil(ObjectTagTable* tags) : tags_(tags) {
29 }
30
Andreas Gampeaa8b60c2016-10-12 12:51:25 -070031 jvmtiError GetLoadedClasses(jvmtiEnv* env, jint* class_count_ptr, jclass** classes_ptr);
32
Alex Lightbbbcb532018-08-30 12:50:27 -070033 jvmtiError IterateOverInstancesOfClass(jvmtiEnv* env,
34 jclass klass,
35 jvmtiHeapObjectFilter filter,
36 jvmtiHeapObjectCallback cb,
37 const void* user_data);
38
Andreas Gampee54d9922016-10-11 19:55:37 -070039 jvmtiError IterateThroughHeap(jvmtiEnv* env,
40 jint heap_filter,
41 jclass klass,
42 const jvmtiHeapCallbacks* callbacks,
43 const void* user_data);
44
Andreas Gampe70bfc8a2016-11-03 11:04:15 -070045 jvmtiError FollowReferences(jvmtiEnv* env,
46 jint heap_filter,
47 jclass klass,
48 jobject initial_object,
49 const jvmtiHeapCallbacks* callbacks,
50 const void* user_data);
51
Andreas Gampe8da6d032016-10-31 19:31:03 -070052 static jvmtiError ForceGarbageCollection(jvmtiEnv* env);
53
Andreas Gampee54d9922016-10-11 19:55:37 -070054 ObjectTagTable* GetTags() {
55 return tags_;
56 }
57
Andreas Gampe9e38a502017-03-06 08:19:26 -080058 static void Register();
59 static void Unregister();
60
Andreas Gampee54d9922016-10-11 19:55:37 -070061 private:
62 ObjectTagTable* tags_;
63};
64
Andreas Gamped73aba42017-05-03 21:40:26 -070065class HeapExtensions {
66 public:
67 static jvmtiError JNICALL GetObjectHeapId(jvmtiEnv* env, jlong tag, jint* heap_id, ...);
68 static jvmtiError JNICALL GetHeapName(jvmtiEnv* env, jint heap_id, char** heap_name, ...);
Andreas Gampe2eb25e42017-05-09 17:14:58 -070069
70 static jvmtiError JNICALL IterateThroughHeapExt(jvmtiEnv* env,
71 jint heap_filter,
72 jclass klass,
73 const jvmtiHeapCallbacks* callbacks,
74 const void* user_data);
Andreas Gamped73aba42017-05-03 21:40:26 -070075};
76
Andreas Gampee54d9922016-10-11 19:55:37 -070077} // namespace openjdkjvmti
78
Andreas Gampe06c42a52017-07-26 14:17:14 -070079#endif // ART_OPENJDKJVMTI_TI_HEAP_H_