annotate agent/src/share/classes/sun/jvm/hotspot/utilities/IntervalNode.java @ 8764:8552f0992748

8008796: SA: Oop.iterateFields() should support CompressedKlassPointers again Summary: add a missing change from JDK-7054512 so that Oop.iterateFields() works with UseCompressedKlassPointers Reviewed-by: coleenp, roland Contributed-by: yunda.mly@taobao.com
author kmo
date Fri, 15 Mar 2013 22:07:42 -0700
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) 2000, 2003, 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 /** Derived from the example in Section 15.3 of CLR. */
a61af66fc99e Initial load
duke
parents:
diff changeset
28
a61af66fc99e Initial load
duke
parents:
diff changeset
29 import java.util.Comparator;
a61af66fc99e Initial load
duke
parents:
diff changeset
30
a61af66fc99e Initial load
duke
parents:
diff changeset
31 public class IntervalNode extends RBNode {
a61af66fc99e Initial load
duke
parents:
diff changeset
32 private Interval interval;
a61af66fc99e Initial load
duke
parents:
diff changeset
33 private Comparator endpointComparator;
a61af66fc99e Initial load
duke
parents:
diff changeset
34 private Object minEndpoint;
a61af66fc99e Initial load
duke
parents:
diff changeset
35 private Object maxEndpoint;
a61af66fc99e Initial load
duke
parents:
diff changeset
36
a61af66fc99e Initial load
duke
parents:
diff changeset
37 public IntervalNode(Interval interval, Comparator endpointComparator, Object data) {
a61af66fc99e Initial load
duke
parents:
diff changeset
38 super(data);
a61af66fc99e Initial load
duke
parents:
diff changeset
39 this.interval = interval;
a61af66fc99e Initial load
duke
parents:
diff changeset
40 this.endpointComparator = endpointComparator;
a61af66fc99e Initial load
duke
parents:
diff changeset
41 }
a61af66fc99e Initial load
duke
parents:
diff changeset
42
a61af66fc99e Initial load
duke
parents:
diff changeset
43 public void copyFrom(RBNode arg) {
a61af66fc99e Initial load
duke
parents:
diff changeset
44 IntervalNode argNode = (IntervalNode) arg;
a61af66fc99e Initial load
duke
parents:
diff changeset
45 this.interval = argNode.interval;
a61af66fc99e Initial load
duke
parents:
diff changeset
46 }
a61af66fc99e Initial load
duke
parents:
diff changeset
47
a61af66fc99e Initial load
duke
parents:
diff changeset
48 public Interval getInterval() {
a61af66fc99e Initial load
duke
parents:
diff changeset
49 return interval;
a61af66fc99e Initial load
duke
parents:
diff changeset
50 }
a61af66fc99e Initial load
duke
parents:
diff changeset
51
a61af66fc99e Initial load
duke
parents:
diff changeset
52 public Object getMinEndpoint() {
a61af66fc99e Initial load
duke
parents:
diff changeset
53 return minEndpoint;
a61af66fc99e Initial load
duke
parents:
diff changeset
54 }
a61af66fc99e Initial load
duke
parents:
diff changeset
55
a61af66fc99e Initial load
duke
parents:
diff changeset
56 public Object getMaxEndpoint() {
a61af66fc99e Initial load
duke
parents:
diff changeset
57 return maxEndpoint;
a61af66fc99e Initial load
duke
parents:
diff changeset
58 }
a61af66fc99e Initial load
duke
parents:
diff changeset
59
a61af66fc99e Initial load
duke
parents:
diff changeset
60 public boolean update() {
a61af66fc99e Initial load
duke
parents:
diff changeset
61 Object newMaxEndpoint = computeMaxEndpoint();
a61af66fc99e Initial load
duke
parents:
diff changeset
62 Object newMinEndpoint = computeMinEndpoint();
a61af66fc99e Initial load
duke
parents:
diff changeset
63
a61af66fc99e Initial load
duke
parents:
diff changeset
64 if ((maxEndpoint != newMaxEndpoint) || (minEndpoint != newMinEndpoint)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
65 maxEndpoint = newMaxEndpoint;
a61af66fc99e Initial load
duke
parents:
diff changeset
66 minEndpoint = newMinEndpoint;
a61af66fc99e Initial load
duke
parents:
diff changeset
67 return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
68 }
a61af66fc99e Initial load
duke
parents:
diff changeset
69
a61af66fc99e Initial load
duke
parents:
diff changeset
70 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
71 }
a61af66fc99e Initial load
duke
parents:
diff changeset
72
a61af66fc99e Initial load
duke
parents:
diff changeset
73 // Computes maximum endpoint without setting it in this node
a61af66fc99e Initial load
duke
parents:
diff changeset
74 public Object computeMinEndpoint() {
a61af66fc99e Initial load
duke
parents:
diff changeset
75 IntervalNode left = (IntervalNode) getLeft();
a61af66fc99e Initial load
duke
parents:
diff changeset
76 if (left != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
77 return left.getMinEndpoint();
a61af66fc99e Initial load
duke
parents:
diff changeset
78 }
a61af66fc99e Initial load
duke
parents:
diff changeset
79 return interval.getLowEndpoint();
a61af66fc99e Initial load
duke
parents:
diff changeset
80 }
a61af66fc99e Initial load
duke
parents:
diff changeset
81
a61af66fc99e Initial load
duke
parents:
diff changeset
82 // Computes maximum endpoint without setting it in this node
a61af66fc99e Initial load
duke
parents:
diff changeset
83 public Object computeMaxEndpoint() {
a61af66fc99e Initial load
duke
parents:
diff changeset
84 Object curMax = interval.getHighEndpoint();
a61af66fc99e Initial load
duke
parents:
diff changeset
85 if (getLeft() != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
86 IntervalNode left = (IntervalNode) getLeft();
a61af66fc99e Initial load
duke
parents:
diff changeset
87 if (endpointComparator.compare(left.getMaxEndpoint(), curMax) > 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
88 curMax = left.getMaxEndpoint();
a61af66fc99e Initial load
duke
parents:
diff changeset
89 }
a61af66fc99e Initial load
duke
parents:
diff changeset
90 }
a61af66fc99e Initial load
duke
parents:
diff changeset
91
a61af66fc99e Initial load
duke
parents:
diff changeset
92 if (getRight() != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
93 IntervalNode right = (IntervalNode) getRight();
a61af66fc99e Initial load
duke
parents:
diff changeset
94 if (endpointComparator.compare(right.getMaxEndpoint(), curMax) > 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
95 curMax = right.getMaxEndpoint();
a61af66fc99e Initial load
duke
parents:
diff changeset
96 }
a61af66fc99e Initial load
duke
parents:
diff changeset
97 }
a61af66fc99e Initial load
duke
parents:
diff changeset
98 return curMax;
a61af66fc99e Initial load
duke
parents:
diff changeset
99 }
a61af66fc99e Initial load
duke
parents:
diff changeset
100
a61af66fc99e Initial load
duke
parents:
diff changeset
101 public String toString() {
a61af66fc99e Initial load
duke
parents:
diff changeset
102 String res = interval.toString();
a61af66fc99e Initial load
duke
parents:
diff changeset
103 Object d = getData();
a61af66fc99e Initial load
duke
parents:
diff changeset
104 if (d != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
105 res += " " + d;
a61af66fc99e Initial load
duke
parents:
diff changeset
106 }
a61af66fc99e Initial load
duke
parents:
diff changeset
107 return res;
a61af66fc99e Initial load
duke
parents:
diff changeset
108 }
a61af66fc99e Initial load
duke
parents:
diff changeset
109 }