author | trims |
Thu, 27 May 2010 19:08:38 -0700 | |
changeset 5547 | f4b087cbb361 |
parent 4571 | 80b553bddc26 |
child 7397 | 5b173b4ca846 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
4571
diff
changeset
|
2 |
* Copyright (c) 2000, 2002, 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:
4571
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
4571
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:
4571
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
25 |
#include "incls/_precompiled.incl" |
|
26 |
#include "incls/_ciType.cpp.incl" |
|
27 |
||
28 |
ciType* ciType::_basic_types[T_CONFLICT+1]; |
|
29 |
||
30 |
// ciType |
|
31 |
// |
|
32 |
// This class represents either a class (T_OBJECT), array (T_ARRAY), |
|
33 |
// or one of the primitive types such as T_INT. |
|
34 |
||
35 |
// ------------------------------------------------------------------ |
|
36 |
// ciType::ciType |
|
37 |
// |
|
38 |
ciType::ciType(BasicType basic_type) : ciObject() { |
|
39 |
assert(basic_type >= T_BOOLEAN && basic_type <= T_CONFLICT, "range check"); |
|
40 |
assert(basic_type != T_OBJECT && basic_type != T_ARRAY, "not a reference type"); |
|
41 |
_basic_type = basic_type; |
|
42 |
} |
|
43 |
||
44 |
ciType::ciType(KlassHandle k) : ciObject(k) { |
|
45 |
_basic_type = Klass::cast(k())->oop_is_array() ? T_ARRAY : T_OBJECT; |
|
46 |
} |
|
47 |
||
48 |
ciType::ciType(ciKlass* klass) : ciObject(klass) { |
|
49 |
_basic_type = klass->is_array_klass_klass() ? T_ARRAY : T_OBJECT; |
|
50 |
} |
|
51 |
||
52 |
||
53 |
// ------------------------------------------------------------------ |
|
54 |
// ciType::is_subtype_of |
|
55 |
// |
|
56 |
bool ciType::is_subtype_of(ciType* type) { |
|
57 |
if (this == type) return true; |
|
58 |
if (is_klass() && type->is_klass()) |
|
59 |
return this->as_klass()->is_subtype_of(type->as_klass()); |
|
60 |
return false; |
|
61 |
} |
|
62 |
||
63 |
// ------------------------------------------------------------------ |
|
64 |
// ciType::print_impl |
|
65 |
// |
|
66 |
// Implementation of the print method. |
|
67 |
void ciType::print_impl(outputStream* st) { |
|
68 |
st->print(" type="); |
|
69 |
print_name_on(st); |
|
70 |
} |
|
71 |
||
72 |
// ------------------------------------------------------------------ |
|
73 |
// ciType::print_name |
|
74 |
// |
|
75 |
// Print the name of this type |
|
76 |
void ciType::print_name_on(outputStream* st) { |
|
77 |
st->print(type2name(basic_type())); |
|
78 |
} |
|
79 |
||
80 |
||
81 |
||
82 |
// ------------------------------------------------------------------ |
|
83 |
// ciType::java_mirror |
|
84 |
// |
|
85 |
ciInstance* ciType::java_mirror() { |
|
86 |
VM_ENTRY_MARK; |
|
87 |
return CURRENT_THREAD_ENV->get_object(Universe::java_mirror(basic_type()))->as_instance(); |
|
88 |
} |
|
89 |
||
90 |
// ------------------------------------------------------------------ |
|
91 |
// ciType::box_klass |
|
92 |
// |
|
93 |
ciKlass* ciType::box_klass() { |
|
94 |
if (!is_primitive_type()) return this->as_klass(); // reference types are "self boxing" |
|
95 |
||
96 |
// Void is "boxed" with a null. |
|
97 |
if (basic_type() == T_VOID) return NULL; |
|
98 |
||
99 |
VM_ENTRY_MARK; |
|
100 |
return CURRENT_THREAD_ENV->get_object(SystemDictionary::box_klass(basic_type()))->as_instance_klass(); |
|
101 |
} |
|
102 |
||
103 |
||
104 |
// ------------------------------------------------------------------ |
|
105 |
// ciType::make |
|
106 |
// |
|
107 |
// Produce the ciType for a given primitive BasicType. |
|
108 |
// As a bonus, produce the right reference type for T_OBJECT. |
|
109 |
// Does not work on T_ARRAY. |
|
110 |
ciType* ciType::make(BasicType t) { |
|
111 |
// short, etc. |
|
112 |
// Note: Bare T_ADDRESS means a raw pointer type, not a return_address. |
|
113 |
assert((uint)t < T_CONFLICT+1, "range check"); |
|
4571 | 114 |
if (t == T_OBJECT) return ciEnv::_Object_klass; // java/lang/Object |
1 | 115 |
assert(_basic_types[t] != NULL, "domain check"); |
116 |
return _basic_types[t]; |
|
117 |
} |
|
118 |
||
119 |
// ciReturnAddress |
|
120 |
// |
|
121 |
// This class represents the type of a specific return address in the |
|
122 |
// bytecodes. |
|
123 |
||
124 |
// ------------------------------------------------------------------ |
|
125 |
// ciReturnAddress::ciReturnAddress |
|
126 |
// |
|
127 |
ciReturnAddress::ciReturnAddress(int bci) : ciType(T_ADDRESS) { |
|
128 |
assert(0 <= bci, "bci cannot be negative"); |
|
129 |
_bci = bci; |
|
130 |
} |
|
131 |
||
132 |
// ------------------------------------------------------------------ |
|
133 |
// ciReturnAddress::print_impl |
|
134 |
// |
|
135 |
// Implementation of the print method. |
|
136 |
void ciReturnAddress::print_impl(outputStream* st) { |
|
137 |
st->print(" bci=%d", _bci); |
|
138 |
} |
|
139 |
||
140 |
// ------------------------------------------------------------------ |
|
141 |
// ciReturnAddress::make |
|
142 |
ciReturnAddress* ciReturnAddress::make(int bci) { |
|
143 |
GUARDED_VM_ENTRY(return CURRENT_ENV->get_return_address(bci);) |
|
144 |
} |