comparison src/share/vm/c1/c1_ValueType.cpp @ 0:a61af66fc99e jdk7-b24

Initial load
author duke
date Sat, 01 Dec 2007 00:00:00 +0000
parents
children 148e5441d916
comparison
equal deleted inserted replaced
-1:000000000000 0:a61af66fc99e
1 /*
2 * Copyright 1999-2005 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 # include "incls/_precompiled.incl"
26 # include "incls/_c1_ValueType.cpp.incl"
27
28
29 // predefined types
30 VoidType* voidType = NULL;
31 IntType* intType = NULL;
32 LongType* longType = NULL;
33 FloatType* floatType = NULL;
34 DoubleType* doubleType = NULL;
35 ObjectType* objectType = NULL;
36 ArrayType* arrayType = NULL;
37 InstanceType* instanceType = NULL;
38 ClassType* classType = NULL;
39 AddressType* addressType = NULL;
40 IllegalType* illegalType = NULL;
41
42
43 // predefined constants
44 IntConstant* intZero = NULL;
45 IntConstant* intOne = NULL;
46 ObjectConstant* objectNull = NULL;
47
48
49 void ValueType::initialize() {
50 // Note: Must initialize all types for each compilation
51 // as they are allocated within a ResourceMark!
52
53 // types
54 voidType = new VoidType();
55 intType = new IntType();
56 longType = new LongType();
57 floatType = new FloatType();
58 doubleType = new DoubleType();
59 objectType = new ObjectType();
60 arrayType = new ArrayType();
61 instanceType = new InstanceType();
62 classType = new ClassType();
63 addressType = new AddressType();
64 illegalType = new IllegalType();
65
66 // constants
67 intZero = new IntConstant(0);
68 intOne = new IntConstant(1);
69 objectNull = new ObjectConstant(ciNullObject::make());
70 };
71
72
73 ValueType* ValueType::meet(ValueType* y) const {
74 // incomplete & conservative solution for now - fix this!
75 assert(tag() == y->tag(), "types must match");
76 return base();
77 }
78
79
80 ValueType* ValueType::join(ValueType* y) const {
81 Unimplemented();
82 return NULL;
83 }
84
85
86
87 jobject ObjectType::encoding() const {
88 assert(is_constant(), "must be");
89 return constant_value()->encoding();
90 }
91
92 bool ObjectType::is_loaded() const {
93 assert(is_constant(), "must be");
94 return constant_value()->is_loaded();
95 }
96
97 ciObject* ObjectConstant::constant_value() const { return _value; }
98 ciObject* ArrayConstant::constant_value() const { return _value; }
99 ciObject* InstanceConstant::constant_value() const { return _value; }
100 ciObject* ClassConstant::constant_value() const { return _value; }
101
102
103 ValueType* as_ValueType(BasicType type) {
104 switch (type) {
105 case T_VOID : return voidType;
106 case T_BYTE : // fall through
107 case T_CHAR : // fall through
108 case T_SHORT : // fall through
109 case T_BOOLEAN: // fall through
110 case T_INT : return intType;
111 case T_LONG : return longType;
112 case T_FLOAT : return floatType;
113 case T_DOUBLE : return doubleType;
114 case T_ARRAY : return arrayType;
115 case T_OBJECT : return objectType;
116 case T_ADDRESS: return addressType;
117 case T_ILLEGAL: return illegalType;
118 }
119 ShouldNotReachHere();
120 return illegalType;
121 }
122
123
124 ValueType* as_ValueType(ciConstant value) {
125 switch (value.basic_type()) {
126 case T_BYTE : // fall through
127 case T_CHAR : // fall through
128 case T_SHORT : // fall through
129 case T_BOOLEAN: // fall through
130 case T_INT : return new IntConstant (value.as_int ());
131 case T_LONG : return new LongConstant (value.as_long ());
132 case T_FLOAT : return new FloatConstant (value.as_float ());
133 case T_DOUBLE : return new DoubleConstant(value.as_double());
134 case T_ARRAY : // fall through (ciConstant doesn't have an array accessor)
135 case T_OBJECT : return new ObjectConstant(value.as_object());
136 }
137 ShouldNotReachHere();
138 return illegalType;
139 }
140
141
142 BasicType as_BasicType(ValueType* type) {
143 switch (type->tag()) {
144 case voidTag: return T_VOID;
145 case intTag: return T_INT;
146 case longTag: return T_LONG;
147 case floatTag: return T_FLOAT;
148 case doubleTag: return T_DOUBLE;
149 case objectTag: return T_OBJECT;
150 case addressTag: return T_ADDRESS;
151 case illegalTag: return T_ILLEGAL;
152 }
153 ShouldNotReachHere();
154 return T_ILLEGAL;
155 }