Path: blob/master/test/lib/sun/hotspot/code/CodeBlob.java
66644 views
/*1* Copyright (c) 2014, 2021, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223package sun.hotspot.code;2425import sun.hotspot.WhiteBox;2627@Deprecated28public class CodeBlob {29private static final WhiteBox WB = WhiteBox.getWhiteBox();30public static CodeBlob[] getCodeBlobs(BlobType type) {31Object[] obj = WB.getCodeHeapEntries(type.id);32if (obj == null) {33return null;34}35CodeBlob[] result = new CodeBlob[obj.length];36for (int i = 0, n = result.length; i < n; ++i) {37result[i] = new CodeBlob((Object[]) obj[i]);38}39return result;40}41public static CodeBlob getCodeBlob(long addr) {42Object[] obj = WB.getCodeBlob(addr);43if (obj == null) {44return null;45}46return new CodeBlob(obj);47}48protected CodeBlob(Object[] obj) {49assert obj.length == 4;50name = (String) obj[0];51size = (Integer) obj[1];52int blob_type_index = (Integer) obj[2];53code_blob_type = BlobType.values()[blob_type_index];54assert code_blob_type.id == (Integer) obj[2];55address = (Long) obj[3];56}57public final String name;58public final int size;59public final BlobType code_blob_type;60public final long address;61@Override62public String toString() {63return "CodeBlob{"64+ "name=" + name65+ ", size=" + size66+ ", code_blob_type=" + code_blob_type67+ ", address=" + address68+ '}';69}70}717273