Mercurial > hg > truffle
comparison agent/src/share/classes/sun/jvm/hotspot/runtime/StackValue.java @ 0:a61af66fc99e jdk7-b24
Initial load
author | duke |
---|---|
date | Sat, 01 Dec 2007 00:00:00 +0000 |
parents | |
children | b109e761e927 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:a61af66fc99e |
---|---|
1 /* | |
2 * Copyright 2000-2001 Sun Microsystems, Inc. All Rights Reserved. | |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, | |
20 * CA 95054 USA or visit www.sun.com if you need additional information or | |
21 * have any questions. | |
22 * | |
23 */ | |
24 | |
25 package sun.jvm.hotspot.runtime; | |
26 | |
27 import java.io.*; | |
28 import sun.jvm.hotspot.debugger.*; | |
29 import sun.jvm.hotspot.utilities.*; | |
30 | |
31 public class StackValue { | |
32 private int type; | |
33 private OopHandle handleValue; | |
34 private long integerValue; | |
35 | |
36 public StackValue() { | |
37 type = BasicType.getTConflict(); | |
38 } | |
39 | |
40 public StackValue(OopHandle h) { | |
41 handleValue = h; | |
42 type = BasicType.getTObject(); | |
43 } | |
44 | |
45 public StackValue(long i) { | |
46 integerValue = i; | |
47 type = BasicType.getTInt(); | |
48 } | |
49 | |
50 /** This returns one of the "enum" values in BasicType.java */ | |
51 public int getType() { | |
52 return type; | |
53 } | |
54 | |
55 public OopHandle getObject() { | |
56 if (Assert.ASSERTS_ENABLED) { | |
57 Assert.that(type == BasicType.getTObject(), "type check"); | |
58 } | |
59 return handleValue; | |
60 } | |
61 | |
62 public long getInteger() { | |
63 if (Assert.ASSERTS_ENABLED) { | |
64 Assert.that(type == BasicType.getTInt(), "type check"); | |
65 } | |
66 return integerValue; | |
67 } | |
68 | |
69 public boolean equals(Object arg) { | |
70 if (arg == null) { | |
71 return false; | |
72 } | |
73 | |
74 if (!arg.getClass().equals(getClass())) { | |
75 return false; | |
76 } | |
77 | |
78 StackValue sv = (StackValue) arg; | |
79 if (type != sv.type) { | |
80 return false; | |
81 } | |
82 if (type == BasicType.getTObject()) { | |
83 return handleValue.equals(sv.handleValue); | |
84 } else if (type == BasicType.getTInt()) { | |
85 return (integerValue == sv.integerValue); | |
86 } else { | |
87 // Conflict type (not yet used) | |
88 return true; | |
89 } | |
90 } | |
91 | |
92 public int hashCode() { | |
93 if (type == BasicType.getTObject()) { | |
94 return handleValue.hashCode(); | |
95 } else { | |
96 // Returns 0 for conflict type | |
97 return (int) integerValue; | |
98 } | |
99 } | |
100 | |
101 public void print() { | |
102 printOn(System.out); | |
103 } | |
104 | |
105 public void printOn(PrintStream tty) { | |
106 if (type == BasicType.getTInt()) { | |
107 tty.print(integerValue + " (long) " + (int) integerValue + " (int)"); | |
108 } else if (type == BasicType.getTObject()) { | |
109 tty.print("<" + handleValue + ">"); | |
110 } else if (type == BasicType.getTConflict()) { | |
111 tty.print("conflict"); | |
112 } else { | |
113 throw new RuntimeException("should not reach here"); | |
114 } | |
115 } | |
116 } |