|
Java example source code file (LivenessAnalysis.java)
The LivenessAnalysis.java Java example source code/* * Copyright (c) 2001, 2006, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. * */ package sun.jvm.hotspot.utilities; import java.io.*; import java.util.*; import sun.jvm.hotspot.debugger.*; import sun.jvm.hotspot.gc_interface.*; import sun.jvm.hotspot.memory.*; import sun.jvm.hotspot.oops.*; import sun.jvm.hotspot.runtime.*; /** Finds all paths from roots to the specified set of objects. NOTE: currently only a subset of the roots known to the VM is exposed to the SA: objects on the stack, static fields in classes, and JNI handles. These should be most of the user-level roots keeping objects alive. */ public class LivenessAnalysis { // Used for debugging this code private static final boolean DEBUG = false; private LivenessAnalysis() {} public static LivenessPathList computeAllLivenessPaths(Oop target) { LivenessPathList list = computeAllLivenessPaths(target, true); if ((list == null) || (list.size() == 0)) { // Dead object return null; } return list; } //--------------------------------------------------------------------------- // Internals only below this point // // Returns true if a new path was completed, otherwise false // indicating there were no more paths to complete. // // The trimPathsThroughPopularObjects flag alters the behavior of // the returned results. If true, then if multiple paths to // different roots all go through a particular popular object, those // paths will be truncated and only one (arbitrary one) will be be // returned. On the other hand, if the target object itself is // popular and there are multiple distinct paths to it (indicating // that there are multiple objects pointing directly to it) then all // of those paths will be reported. private static LivenessPathList computeAllLivenessPaths(Oop target, boolean trimPathsThroughPopularObjects) { ReversePtrs rev = VM.getVM().getRevPtrs(); if (rev == null) { throw new RuntimeException("LivenessAnalysis requires ReversePtrs to have been computed"); } // Currently the reverse pointer analysis returns non-null results // only for live objects if (rev.get(target) == null) { // Object is dead return null; } // HashSet of Oops acting as a bit mask indicating which ones have // already been traversed Set/*<Oop>*/ visitedOops = new HashSet/* Other Java examples (source code examples)Here is a short list of links related to this Java LivenessAnalysis.java source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.