annotate src/share/vm/c1/c1_ValueType.cpp @ 113:ba764ed4b6f2

6420645: Create a vm that uses compressed oops for up to 32gb heapsizes Summary: Compressed oops in instances, arrays, and headers. Code contributors are coleenp, phh, never, swamyv Reviewed-by: jmasa, kamg, acorn, tbell, kvn, rasbold
author coleenp
date Sun, 13 Apr 2008 17:43:42 -0400
parents a61af66fc99e
children 148e5441d916
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
2 * Copyright 1999-2005 Sun Microsystems, Inc. All Rights Reserved.
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 *
a61af66fc99e Initial load
duke
parents:
diff changeset
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
a61af66fc99e Initial load
duke
parents:
diff changeset
20 * CA 95054 USA or visit www.sun.com if you need additional information or
a61af66fc99e Initial load
duke
parents:
diff changeset
21 * have any questions.
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 # include "incls/_precompiled.incl"
a61af66fc99e Initial load
duke
parents:
diff changeset
26 # include "incls/_c1_ValueType.cpp.incl"
a61af66fc99e Initial load
duke
parents:
diff changeset
27
a61af66fc99e Initial load
duke
parents:
diff changeset
28
a61af66fc99e Initial load
duke
parents:
diff changeset
29 // predefined types
a61af66fc99e Initial load
duke
parents:
diff changeset
30 VoidType* voidType = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
31 IntType* intType = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
32 LongType* longType = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
33 FloatType* floatType = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
34 DoubleType* doubleType = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
35 ObjectType* objectType = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
36 ArrayType* arrayType = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
37 InstanceType* instanceType = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
38 ClassType* classType = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
39 AddressType* addressType = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
40 IllegalType* illegalType = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
41
a61af66fc99e Initial load
duke
parents:
diff changeset
42
a61af66fc99e Initial load
duke
parents:
diff changeset
43 // predefined constants
a61af66fc99e Initial load
duke
parents:
diff changeset
44 IntConstant* intZero = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
45 IntConstant* intOne = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
46 ObjectConstant* objectNull = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
47
a61af66fc99e Initial load
duke
parents:
diff changeset
48
a61af66fc99e Initial load
duke
parents:
diff changeset
49 void ValueType::initialize() {
a61af66fc99e Initial load
duke
parents:
diff changeset
50 // Note: Must initialize all types for each compilation
a61af66fc99e Initial load
duke
parents:
diff changeset
51 // as they are allocated within a ResourceMark!
a61af66fc99e Initial load
duke
parents:
diff changeset
52
a61af66fc99e Initial load
duke
parents:
diff changeset
53 // types
a61af66fc99e Initial load
duke
parents:
diff changeset
54 voidType = new VoidType();
a61af66fc99e Initial load
duke
parents:
diff changeset
55 intType = new IntType();
a61af66fc99e Initial load
duke
parents:
diff changeset
56 longType = new LongType();
a61af66fc99e Initial load
duke
parents:
diff changeset
57 floatType = new FloatType();
a61af66fc99e Initial load
duke
parents:
diff changeset
58 doubleType = new DoubleType();
a61af66fc99e Initial load
duke
parents:
diff changeset
59 objectType = new ObjectType();
a61af66fc99e Initial load
duke
parents:
diff changeset
60 arrayType = new ArrayType();
a61af66fc99e Initial load
duke
parents:
diff changeset
61 instanceType = new InstanceType();
a61af66fc99e Initial load
duke
parents:
diff changeset
62 classType = new ClassType();
a61af66fc99e Initial load
duke
parents:
diff changeset
63 addressType = new AddressType();
a61af66fc99e Initial load
duke
parents:
diff changeset
64 illegalType = new IllegalType();
a61af66fc99e Initial load
duke
parents:
diff changeset
65
a61af66fc99e Initial load
duke
parents:
diff changeset
66 // constants
a61af66fc99e Initial load
duke
parents:
diff changeset
67 intZero = new IntConstant(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
68 intOne = new IntConstant(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
69 objectNull = new ObjectConstant(ciNullObject::make());
a61af66fc99e Initial load
duke
parents:
diff changeset
70 };
a61af66fc99e Initial load
duke
parents:
diff changeset
71
a61af66fc99e Initial load
duke
parents:
diff changeset
72
a61af66fc99e Initial load
duke
parents:
diff changeset
73 ValueType* ValueType::meet(ValueType* y) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
74 // incomplete & conservative solution for now - fix this!
a61af66fc99e Initial load
duke
parents:
diff changeset
75 assert(tag() == y->tag(), "types must match");
a61af66fc99e Initial load
duke
parents:
diff changeset
76 return base();
a61af66fc99e Initial load
duke
parents:
diff changeset
77 }
a61af66fc99e Initial load
duke
parents:
diff changeset
78
a61af66fc99e Initial load
duke
parents:
diff changeset
79
a61af66fc99e Initial load
duke
parents:
diff changeset
80 ValueType* ValueType::join(ValueType* y) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
81 Unimplemented();
a61af66fc99e Initial load
duke
parents:
diff changeset
82 return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
83 }
a61af66fc99e Initial load
duke
parents:
diff changeset
84
a61af66fc99e Initial load
duke
parents:
diff changeset
85
a61af66fc99e Initial load
duke
parents:
diff changeset
86
a61af66fc99e Initial load
duke
parents:
diff changeset
87 jobject ObjectType::encoding() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
88 assert(is_constant(), "must be");
a61af66fc99e Initial load
duke
parents:
diff changeset
89 return constant_value()->encoding();
a61af66fc99e Initial load
duke
parents:
diff changeset
90 }
a61af66fc99e Initial load
duke
parents:
diff changeset
91
a61af66fc99e Initial load
duke
parents:
diff changeset
92 bool ObjectType::is_loaded() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
93 assert(is_constant(), "must be");
a61af66fc99e Initial load
duke
parents:
diff changeset
94 return constant_value()->is_loaded();
a61af66fc99e Initial load
duke
parents:
diff changeset
95 }
a61af66fc99e Initial load
duke
parents:
diff changeset
96
a61af66fc99e Initial load
duke
parents:
diff changeset
97 ciObject* ObjectConstant::constant_value() const { return _value; }
a61af66fc99e Initial load
duke
parents:
diff changeset
98 ciObject* ArrayConstant::constant_value() const { return _value; }
a61af66fc99e Initial load
duke
parents:
diff changeset
99 ciObject* InstanceConstant::constant_value() const { return _value; }
a61af66fc99e Initial load
duke
parents:
diff changeset
100 ciObject* ClassConstant::constant_value() const { return _value; }
a61af66fc99e Initial load
duke
parents:
diff changeset
101
a61af66fc99e Initial load
duke
parents:
diff changeset
102
a61af66fc99e Initial load
duke
parents:
diff changeset
103 ValueType* as_ValueType(BasicType type) {
a61af66fc99e Initial load
duke
parents:
diff changeset
104 switch (type) {
a61af66fc99e Initial load
duke
parents:
diff changeset
105 case T_VOID : return voidType;
a61af66fc99e Initial load
duke
parents:
diff changeset
106 case T_BYTE : // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
107 case T_CHAR : // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
108 case T_SHORT : // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
109 case T_BOOLEAN: // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
110 case T_INT : return intType;
a61af66fc99e Initial load
duke
parents:
diff changeset
111 case T_LONG : return longType;
a61af66fc99e Initial load
duke
parents:
diff changeset
112 case T_FLOAT : return floatType;
a61af66fc99e Initial load
duke
parents:
diff changeset
113 case T_DOUBLE : return doubleType;
a61af66fc99e Initial load
duke
parents:
diff changeset
114 case T_ARRAY : return arrayType;
a61af66fc99e Initial load
duke
parents:
diff changeset
115 case T_OBJECT : return objectType;
a61af66fc99e Initial load
duke
parents:
diff changeset
116 case T_ADDRESS: return addressType;
a61af66fc99e Initial load
duke
parents:
diff changeset
117 case T_ILLEGAL: return illegalType;
a61af66fc99e Initial load
duke
parents:
diff changeset
118 }
a61af66fc99e Initial load
duke
parents:
diff changeset
119 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
120 return illegalType;
a61af66fc99e Initial load
duke
parents:
diff changeset
121 }
a61af66fc99e Initial load
duke
parents:
diff changeset
122
a61af66fc99e Initial load
duke
parents:
diff changeset
123
a61af66fc99e Initial load
duke
parents:
diff changeset
124 ValueType* as_ValueType(ciConstant value) {
a61af66fc99e Initial load
duke
parents:
diff changeset
125 switch (value.basic_type()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
126 case T_BYTE : // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
127 case T_CHAR : // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
128 case T_SHORT : // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
129 case T_BOOLEAN: // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
130 case T_INT : return new IntConstant (value.as_int ());
a61af66fc99e Initial load
duke
parents:
diff changeset
131 case T_LONG : return new LongConstant (value.as_long ());
a61af66fc99e Initial load
duke
parents:
diff changeset
132 case T_FLOAT : return new FloatConstant (value.as_float ());
a61af66fc99e Initial load
duke
parents:
diff changeset
133 case T_DOUBLE : return new DoubleConstant(value.as_double());
a61af66fc99e Initial load
duke
parents:
diff changeset
134 case T_ARRAY : // fall through (ciConstant doesn't have an array accessor)
a61af66fc99e Initial load
duke
parents:
diff changeset
135 case T_OBJECT : return new ObjectConstant(value.as_object());
a61af66fc99e Initial load
duke
parents:
diff changeset
136 }
a61af66fc99e Initial load
duke
parents:
diff changeset
137 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
138 return illegalType;
a61af66fc99e Initial load
duke
parents:
diff changeset
139 }
a61af66fc99e Initial load
duke
parents:
diff changeset
140
a61af66fc99e Initial load
duke
parents:
diff changeset
141
a61af66fc99e Initial load
duke
parents:
diff changeset
142 BasicType as_BasicType(ValueType* type) {
a61af66fc99e Initial load
duke
parents:
diff changeset
143 switch (type->tag()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
144 case voidTag: return T_VOID;
a61af66fc99e Initial load
duke
parents:
diff changeset
145 case intTag: return T_INT;
a61af66fc99e Initial load
duke
parents:
diff changeset
146 case longTag: return T_LONG;
a61af66fc99e Initial load
duke
parents:
diff changeset
147 case floatTag: return T_FLOAT;
a61af66fc99e Initial load
duke
parents:
diff changeset
148 case doubleTag: return T_DOUBLE;
a61af66fc99e Initial load
duke
parents:
diff changeset
149 case objectTag: return T_OBJECT;
a61af66fc99e Initial load
duke
parents:
diff changeset
150 case addressTag: return T_ADDRESS;
a61af66fc99e Initial load
duke
parents:
diff changeset
151 case illegalTag: return T_ILLEGAL;
a61af66fc99e Initial load
duke
parents:
diff changeset
152 }
a61af66fc99e Initial load
duke
parents:
diff changeset
153 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
154 return T_ILLEGAL;
a61af66fc99e Initial load
duke
parents:
diff changeset
155 }