1 /* 2 * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 package nsk.share.jvmti.unit; 25 26 public class Heap { 27 28 // --- Errors --- 29 30 public static final int JVMTI_ERROR_NONE = 0; 31 32 // --- Filter types --- 33 34 public static final int JVMTI_HEAP_OBJECT_TAGGED = 1; 35 public static final int JVMTI_HEAP_OBJECT_UNTAGGED = 2; 36 public static final int JVMTI_HEAP_OBJECT_EITHER = 3; 37 38 // --- Root types --- 39 40 public static final int JVMTI_HEAP_ROOT_JNI_GLOBAL = 1; 41 public static final int JVMTI_HEAP_ROOT_SYSTEM_CLASS = 2; 42 public static final int JVMTI_HEAP_ROOT_MONITOR = 3; 43 public static final int JVMTI_HEAP_ROOT_STACK_LOCAL = 4; 44 public static final int JVMTI_HEAP_ROOT_JNI_LOCAL = 5; 45 public static final int JVMTI_HEAP_ROOT_THREAD = 6; 46 public static final int JVMTI_HEAP_ROOT_OTHER = 7; 47 48 // --- Heap Functions --- 49 setTag(Object o, long tag)50 public static int setTag(Object o, long tag) { 51 return setTag0(o, tag); 52 } 53 getTag(Object o)54 public static long getTag(Object o) { 55 return getTag0(o); 56 } 57 iterateOverHeap(int filter_kind)58 public static int iterateOverHeap(int filter_kind) { 59 return iterateOverHeap0(filter_kind); 60 } 61 iterateOverInstancesOfClass(Class c, int filter_kind)62 public static int iterateOverInstancesOfClass(Class c, int filter_kind) { 63 return iterateOverInstancesOfClass0(c, filter_kind); 64 } 65 iterateOverReachableObjects()66 public static int iterateOverReachableObjects() { 67 return iterateOverReachableObjects0(); 68 } 69 iterateOverObjectsReachableFromObject(Object o)70 public static int iterateOverObjectsReachableFromObject(Object o) { 71 return iterateOverObjectsReachableFromObject0(o); 72 } 73 getObjectSize(Object o)74 public static native long getObjectSize(Object o); 75 76 // --- GetObjectsWithTags --- 77 getObjectsWithTags(int count, long array[])78 public static native int getObjectsWithTags(int count, long array[]); 79 tagResults()80 public static native long[] tagResults(); 81 objectResults()82 public static native Object[] objectResults(); 83 84 85 // --- Functions used by basic iteration tests 86 setTaggedObjectCountCallback()87 public static native void setTaggedObjectCountCallback(); setTotalObjectCountCallback()88 public static native void setTotalObjectCountCallback(); 89 zeroObjectCount()90 public static native void zeroObjectCount(); getObjectCount()91 public static native int getObjectCount(); 92 setKlassTagTestCallback()93 public static native void setKlassTagTestCallback(); 94 95 // --- Used by Heap Walking tests 96 newGlobalRef(Object o)97 public static native Object newGlobalRef(Object o); 98 setHeapRootCallback()99 public static native void setHeapRootCallback(); setStackRefCallback()100 public static native void setStackRefCallback(); setObjectRefCallback()101 public static native void setObjectRefCallback(); 102 103 // --- Functions used by object free tests 104 setObjectFreeCallback()105 public static native void setObjectFreeCallback(); zeroObjectFreeCount()106 public static native void zeroObjectFreeCount(); getObjectFreeCount()107 public static native int getObjectFreeCount(); 108 109 // --- Native methods --- 110 setTag0(Object o, long tag)111 private static native int setTag0(Object o, long tag); getTag0(Object o)112 private static native long getTag0(Object o); 113 iterateOverHeap0(int filter_kind)114 private static native int iterateOverHeap0(int filter_kind); iterateOverInstancesOfClass0(Class c, int filter_kind)115 private static native int iterateOverInstancesOfClass0(Class c, int filter_kind); 116 iterateOverReachableObjects0()117 private static native int iterateOverReachableObjects0(); iterateOverObjectsReachableFromObject0(Object o)118 private static native int iterateOverObjectsReachableFromObject0(Object o); 119 120 static { 121 System.loadLibrary("Heap"); 122 } 123 } 124