Path: blob/master/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/compiler/OopMapStream.java
41161 views
/*1* Copyright (c) 2000, 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*22*/2324package sun.jvm.hotspot.compiler;2526import sun.jvm.hotspot.code.*;2728public class OopMapStream {29private CompressedReadStream stream;30private ImmutableOopMap oopMap;31private int mask;32private int size;33private int position;34private OopMapValue omv;35private boolean omvValid;3637public OopMapStream(ImmutableOopMap oopMap) {38this(oopMap, (OopMapValue.OopTypes[]) null);39}4041public OopMapStream(ImmutableOopMap oopMap, OopMapValue.OopTypes type) {42this(oopMap, (OopMapValue.OopTypes[]) null);43mask = type.getValue();44}4546public OopMapStream(ImmutableOopMap oopMap, OopMapValue.OopTypes[] types) {47stream = new CompressedReadStream(oopMap.getData());48mask = computeMask(types);49size = (int) oopMap.getCount();50position = 0;51omv = new OopMapValue();52omvValid = false;53}5455public boolean isDone() {56if (!omvValid) {57findNext();58}59return !omvValid;60}6162public void next() {63findNext();64}6566public OopMapValue getCurrent() {67return omv;68}6970//--------------------------------------------------------------------------------71// Internals only below this point72//7374private int computeMask(OopMapValue.OopTypes[] types) {75mask = 0;76if (types != null) {77for (int i = 0; i < types.length; i++) {78mask |= types[i].getValue();79}80}81return mask;82}8384private void findNext() {85while (position++ < size) {86omv.readFrom(stream);87if ((omv.getType().getValue() & mask) > 0) {88omvValid = true;89return;90}91}92omvValid = false;93}94}959697