annotate agent/src/share/classes/sun/jvm/hotspot/utilities/LivenessPath.java @ 17467:55fb97c4c58d hs25-b65

8029233: Update copyright year to match last edit in jdk8 hotspot repository for 2013 Summary: Copyright year updated for files modified during 2013 Reviewed-by: twisti, iveresov
author mikael
date Tue, 24 Dec 2013 11:48:39 -0800
parents c18cbe5936b8
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
2 * Copyright (c) 2001, 2006, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
a61af66fc99e Initial load
duke
parents:
diff changeset
25 package sun.jvm.hotspot.utilities;
a61af66fc99e Initial load
duke
parents:
diff changeset
26
a61af66fc99e Initial load
duke
parents:
diff changeset
27 import java.io.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
28 import java.util.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
29 import sun.jvm.hotspot.oops.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
30
a61af66fc99e Initial load
duke
parents:
diff changeset
31 /** Describes a path from an object back to the root which is keeping
a61af66fc99e Initial load
duke
parents:
diff changeset
32 it alive. Elements of the path are (object, field) pairs, where
a61af66fc99e Initial load
duke
parents:
diff changeset
33 the object is expressed as a @link{sun.jvm.hotspot.oops.Oop}, and
a61af66fc99e Initial load
duke
parents:
diff changeset
34 where the field is expressed as a
a61af66fc99e Initial load
duke
parents:
diff changeset
35 @link{sun.jvm.hotspot.oops.FieldIdentifier}. If the element
a61af66fc99e Initial load
duke
parents:
diff changeset
36 reflects a root, the Oop will be null. If the element is the end
a61af66fc99e Initial load
duke
parents:
diff changeset
37 of the path, the FieldIdentifier will be null. */
a61af66fc99e Initial load
duke
parents:
diff changeset
38
a61af66fc99e Initial load
duke
parents:
diff changeset
39 public class LivenessPath {
a61af66fc99e Initial load
duke
parents:
diff changeset
40 LivenessPath() {
a61af66fc99e Initial load
duke
parents:
diff changeset
41 stack = new Stack();
a61af66fc99e Initial load
duke
parents:
diff changeset
42 }
a61af66fc99e Initial load
duke
parents:
diff changeset
43
a61af66fc99e Initial load
duke
parents:
diff changeset
44 /** Number of elements in the path */
a61af66fc99e Initial load
duke
parents:
diff changeset
45 public int size() {
a61af66fc99e Initial load
duke
parents:
diff changeset
46 return stack.size();
a61af66fc99e Initial load
duke
parents:
diff changeset
47 }
a61af66fc99e Initial load
duke
parents:
diff changeset
48
a61af66fc99e Initial load
duke
parents:
diff changeset
49 /** Fetch the element at the given index; 0-based */
a61af66fc99e Initial load
duke
parents:
diff changeset
50 public LivenessPathElement get(int index) throws ArrayIndexOutOfBoundsException {
a61af66fc99e Initial load
duke
parents:
diff changeset
51 return (LivenessPathElement) stack.get(index);
a61af66fc99e Initial load
duke
parents:
diff changeset
52 }
a61af66fc99e Initial load
duke
parents:
diff changeset
53
a61af66fc99e Initial load
duke
parents:
diff changeset
54 public void printOn(PrintStream tty) {
a61af66fc99e Initial load
duke
parents:
diff changeset
55 for (int j = 0; j < size(); j++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
56 LivenessPathElement el = get(j);
a61af66fc99e Initial load
duke
parents:
diff changeset
57 tty.print(" - ");
a61af66fc99e Initial load
duke
parents:
diff changeset
58 if (el.getObj() != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
59 Oop.printOopValueOn(el.getObj(), tty);
a61af66fc99e Initial load
duke
parents:
diff changeset
60 }
a61af66fc99e Initial load
duke
parents:
diff changeset
61 if (el.getField() != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
62 if (el.getObj() != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
63 tty.print(", field ");
a61af66fc99e Initial load
duke
parents:
diff changeset
64 }
a61af66fc99e Initial load
duke
parents:
diff changeset
65 tty.print(el.getField().getName());
a61af66fc99e Initial load
duke
parents:
diff changeset
66 }
a61af66fc99e Initial load
duke
parents:
diff changeset
67 tty.println();
a61af66fc99e Initial load
duke
parents:
diff changeset
68 }
a61af66fc99e Initial load
duke
parents:
diff changeset
69 }
a61af66fc99e Initial load
duke
parents:
diff changeset
70
a61af66fc99e Initial load
duke
parents:
diff changeset
71 /** Indicates whether this path is "complete", i.e., whether the
a61af66fc99e Initial load
duke
parents:
diff changeset
72 last element is a root. Convenience routine for LivenessAnalysis. */
a61af66fc99e Initial load
duke
parents:
diff changeset
73 boolean isComplete() {
a61af66fc99e Initial load
duke
parents:
diff changeset
74 if (size() == 0)
a61af66fc99e Initial load
duke
parents:
diff changeset
75 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
76 return peek().isRoot();
a61af66fc99e Initial load
duke
parents:
diff changeset
77 }
a61af66fc99e Initial load
duke
parents:
diff changeset
78
a61af66fc99e Initial load
duke
parents:
diff changeset
79 // Convenience routine for LivenessAnalysis
a61af66fc99e Initial load
duke
parents:
diff changeset
80 LivenessPathElement peek() {
a61af66fc99e Initial load
duke
parents:
diff changeset
81 return (LivenessPathElement) stack.peek();
a61af66fc99e Initial load
duke
parents:
diff changeset
82 }
a61af66fc99e Initial load
duke
parents:
diff changeset
83
a61af66fc99e Initial load
duke
parents:
diff changeset
84 // Convenience routine for LivenessAnalysis
a61af66fc99e Initial load
duke
parents:
diff changeset
85 void push(LivenessPathElement el) {
a61af66fc99e Initial load
duke
parents:
diff changeset
86 stack.push(el);
a61af66fc99e Initial load
duke
parents:
diff changeset
87 }
a61af66fc99e Initial load
duke
parents:
diff changeset
88
a61af66fc99e Initial load
duke
parents:
diff changeset
89 // Convenience routine for LivenessAnalysis
a61af66fc99e Initial load
duke
parents:
diff changeset
90 void pop() {
a61af66fc99e Initial load
duke
parents:
diff changeset
91 stack.pop();
a61af66fc99e Initial load
duke
parents:
diff changeset
92 }
a61af66fc99e Initial load
duke
parents:
diff changeset
93
a61af66fc99e Initial load
duke
parents:
diff changeset
94 // Make a copy of the contents of the path -- the
a61af66fc99e Initial load
duke
parents:
diff changeset
95 // LivenessPathElements are not duplicated, only the containing path
a61af66fc99e Initial load
duke
parents:
diff changeset
96 LivenessPath copy() {
a61af66fc99e Initial load
duke
parents:
diff changeset
97 LivenessPath dup = new LivenessPath();
a61af66fc99e Initial load
duke
parents:
diff changeset
98 for (int i = 0; i < stack.size(); i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
99 dup.stack.push(stack.get(i));
a61af66fc99e Initial load
duke
parents:
diff changeset
100 }
a61af66fc99e Initial load
duke
parents:
diff changeset
101 return dup;
a61af66fc99e Initial load
duke
parents:
diff changeset
102 }
a61af66fc99e Initial load
duke
parents:
diff changeset
103
a61af66fc99e Initial load
duke
parents:
diff changeset
104 //---------------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
105 // Internals only below this point
a61af66fc99e Initial load
duke
parents:
diff changeset
106 //
a61af66fc99e Initial load
duke
parents:
diff changeset
107 private Stack stack;
a61af66fc99e Initial load
duke
parents:
diff changeset
108 }