author | roland |
Thu, 20 Sep 2012 16:49:17 +0200 | |
changeset 13886 | 8d82c4dfa722 |
parent 13742 | 9180987e305d |
child 31957 | ed3e3cb35041 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2 |
* Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. |
1 | 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 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
3908
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
3908
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
3908
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#include "precompiled.hpp" |
26 |
#include "c1/c1_ValueType.hpp" |
|
27 |
#include "ci/ciArray.hpp" |
|
28 |
#include "ci/ciInstance.hpp" |
|
29 |
#include "ci/ciNullObject.hpp" |
|
1 | 30 |
|
31 |
||
32 |
// predefined types |
|
33 |
VoidType* voidType = NULL; |
|
34 |
IntType* intType = NULL; |
|
35 |
LongType* longType = NULL; |
|
36 |
FloatType* floatType = NULL; |
|
37 |
DoubleType* doubleType = NULL; |
|
38 |
ObjectType* objectType = NULL; |
|
39 |
ArrayType* arrayType = NULL; |
|
40 |
InstanceType* instanceType = NULL; |
|
41 |
ClassType* classType = NULL; |
|
42 |
AddressType* addressType = NULL; |
|
43 |
IllegalType* illegalType = NULL; |
|
44 |
||
45 |
||
46 |
// predefined constants |
|
47 |
IntConstant* intZero = NULL; |
|
48 |
IntConstant* intOne = NULL; |
|
49 |
ObjectConstant* objectNull = NULL; |
|
50 |
||
51 |
||
5707 | 52 |
void ValueType::initialize(Arena* arena) { |
1 | 53 |
// Note: Must initialize all types for each compilation |
54 |
// as they are allocated within a ResourceMark! |
|
55 |
||
56 |
// types |
|
5707 | 57 |
voidType = new (arena) VoidType(); |
58 |
intType = new (arena) IntType(); |
|
59 |
longType = new (arena) LongType(); |
|
60 |
floatType = new (arena) FloatType(); |
|
61 |
doubleType = new (arena) DoubleType(); |
|
62 |
objectType = new (arena) ObjectType(); |
|
63 |
arrayType = new (arena) ArrayType(); |
|
64 |
instanceType = new (arena) InstanceType(); |
|
65 |
classType = new (arena) ClassType(); |
|
66 |
addressType = new (arena) AddressType(); |
|
67 |
illegalType = new (arena) IllegalType(); |
|
1 | 68 |
|
5707 | 69 |
intZero = new (arena) IntConstant(0); |
70 |
intOne = new (arena) IntConstant(1); |
|
71 |
objectNull = new (arena) ObjectConstant(ciNullObject::make()); |
|
1 | 72 |
}; |
73 |
||
74 |
||
75 |
ValueType* ValueType::meet(ValueType* y) const { |
|
76 |
// incomplete & conservative solution for now - fix this! |
|
77 |
assert(tag() == y->tag(), "types must match"); |
|
78 |
return base(); |
|
79 |
} |
|
80 |
||
81 |
||
82 |
ValueType* ValueType::join(ValueType* y) const { |
|
83 |
Unimplemented(); |
|
84 |
return NULL; |
|
85 |
} |
|
86 |
||
87 |
||
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
7397
diff
changeset
|
88 |
ciType* ObjectConstant::exact_type() const { |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
7397
diff
changeset
|
89 |
ciObject* c = constant_value(); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
7397
diff
changeset
|
90 |
return (c != NULL && !c->is_null_object()) ? c->klass() : NULL; |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
7397
diff
changeset
|
91 |
} |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
7397
diff
changeset
|
92 |
ciType* ArrayConstant::exact_type() const { |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
7397
diff
changeset
|
93 |
ciObject* c = constant_value(); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
7397
diff
changeset
|
94 |
return (c != NULL && !c->is_null_object()) ? c->klass() : NULL; |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
7397
diff
changeset
|
95 |
} |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
7397
diff
changeset
|
96 |
ciType* InstanceConstant::exact_type() const { |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
7397
diff
changeset
|
97 |
ciObject* c = constant_value(); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
7397
diff
changeset
|
98 |
return (c != NULL && !c->is_null_object()) ? c->klass() : NULL; |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
7397
diff
changeset
|
99 |
} |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
7397
diff
changeset
|
100 |
ciType* ClassConstant::exact_type() const { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
101 |
return Compilation::current()->env()->Class_klass(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
102 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
103 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
104 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
105 |
jobject ObjectType::encoding() const { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
106 |
assert(is_constant(), "must be"); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
107 |
return constant_value()->constant_encoding(); |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
7397
diff
changeset
|
108 |
} |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
7397
diff
changeset
|
109 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
110 |
bool ObjectType::is_loaded() const { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
111 |
assert(is_constant(), "must be"); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
112 |
return constant_value()->is_loaded(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
113 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
114 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
115 |
bool MetadataType::is_loaded() const { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
116 |
assert(is_constant(), "must be"); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
117 |
return constant_value()->is_loaded(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
118 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
119 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
120 |
ciObject* ObjectConstant::constant_value() const { return _value; } |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
121 |
ciObject* ArrayConstant::constant_value() const { return _value; } |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
122 |
ciObject* InstanceConstant::constant_value() const { return _value; } |
1 | 123 |
|
124 |
ValueType* as_ValueType(BasicType type) { |
|
125 |
switch (type) { |
|
126 |
case T_VOID : return voidType; |
|
127 |
case T_BYTE : // fall through |
|
128 |
case T_CHAR : // fall through |
|
129 |
case T_SHORT : // fall through |
|
130 |
case T_BOOLEAN: // fall through |
|
131 |
case T_INT : return intType; |
|
132 |
case T_LONG : return longType; |
|
133 |
case T_FLOAT : return floatType; |
|
134 |
case T_DOUBLE : return doubleType; |
|
135 |
case T_ARRAY : return arrayType; |
|
136 |
case T_OBJECT : return objectType; |
|
137 |
case T_ADDRESS: return addressType; |
|
138 |
case T_ILLEGAL: return illegalType; |
|
139 |
} |
|
140 |
ShouldNotReachHere(); |
|
141 |
return illegalType; |
|
142 |
} |
|
143 |
||
144 |
||
145 |
ValueType* as_ValueType(ciConstant value) { |
|
146 |
switch (value.basic_type()) { |
|
147 |
case T_BYTE : // fall through |
|
148 |
case T_CHAR : // fall through |
|
149 |
case T_SHORT : // fall through |
|
150 |
case T_BOOLEAN: // fall through |
|
151 |
case T_INT : return new IntConstant (value.as_int ()); |
|
152 |
case T_LONG : return new LongConstant (value.as_long ()); |
|
153 |
case T_FLOAT : return new FloatConstant (value.as_float ()); |
|
154 |
case T_DOUBLE : return new DoubleConstant(value.as_double()); |
|
155 |
case T_ARRAY : // fall through (ciConstant doesn't have an array accessor) |
|
156 |
case T_OBJECT : return new ObjectConstant(value.as_object()); |
|
157 |
} |
|
158 |
ShouldNotReachHere(); |
|
159 |
return illegalType; |
|
160 |
} |
|
161 |
||
162 |
||
163 |
BasicType as_BasicType(ValueType* type) { |
|
164 |
switch (type->tag()) { |
|
165 |
case voidTag: return T_VOID; |
|
166 |
case intTag: return T_INT; |
|
167 |
case longTag: return T_LONG; |
|
168 |
case floatTag: return T_FLOAT; |
|
169 |
case doubleTag: return T_DOUBLE; |
|
170 |
case objectTag: return T_OBJECT; |
|
13742
9180987e305d
7195816: NPG: Crash in c1_ValueType - ShouldNotReachHere
roland
parents:
13728
diff
changeset
|
171 |
case metaDataTag:return T_METADATA; |
1 | 172 |
case addressTag: return T_ADDRESS; |
173 |
case illegalTag: return T_ILLEGAL; |
|
174 |
} |
|
175 |
ShouldNotReachHere(); |
|
176 |
return T_ILLEGAL; |
|
177 |
} |