annotate src/share/vm/ci/ciType.cpp @ 14518:d8041d695d19

Merged with jdk9/dev/hotspot changeset 3812c088b945
author twisti
date Tue, 11 Mar 2014 18:45:59 -0700
parents de6a9e811145
children 4ca6dc0799b6 78bbf4d43a14
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
14223
de6a9e811145 8029233: Update copyright year to match last edit in jdk8 hotspot repository for 2013
mikael
parents: 7604
diff changeset
2 * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
0
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 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1142
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1142
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1142
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
25 #include "precompiled.hpp"
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1972
diff changeset
26 #include "ci/ciEnv.hpp"
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
27 #include "ci/ciType.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
28 #include "ci/ciUtilities.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
29 #include "classfile/systemDictionary.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
30 #include "oops/oop.inline.hpp"
0
a61af66fc99e Initial load
duke
parents:
diff changeset
31
a61af66fc99e Initial load
duke
parents:
diff changeset
32 ciType* ciType::_basic_types[T_CONFLICT+1];
a61af66fc99e Initial load
duke
parents:
diff changeset
33
a61af66fc99e Initial load
duke
parents:
diff changeset
34 // ciType
a61af66fc99e Initial load
duke
parents:
diff changeset
35 //
a61af66fc99e Initial load
duke
parents:
diff changeset
36 // This class represents either a class (T_OBJECT), array (T_ARRAY),
a61af66fc99e Initial load
duke
parents:
diff changeset
37 // or one of the primitive types such as T_INT.
a61af66fc99e Initial load
duke
parents:
diff changeset
38
a61af66fc99e Initial load
duke
parents:
diff changeset
39 // ------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
40 // ciType::ciType
a61af66fc99e Initial load
duke
parents:
diff changeset
41 //
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1972
diff changeset
42 ciType::ciType(BasicType basic_type) : ciMetadata() {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
43 assert(basic_type >= T_BOOLEAN && basic_type <= T_CONFLICT, "range check");
a61af66fc99e Initial load
duke
parents:
diff changeset
44 _basic_type = basic_type;
a61af66fc99e Initial load
duke
parents:
diff changeset
45 }
a61af66fc99e Initial load
duke
parents:
diff changeset
46
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1972
diff changeset
47 ciType::ciType(KlassHandle k) : ciMetadata(k()) {
6983
070d523b96a7 8001471: Klass::cast() does nothing
hseigel
parents: 6725
diff changeset
48 _basic_type = k()->oop_is_array() ? T_ARRAY : T_OBJECT;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
49 }
a61af66fc99e Initial load
duke
parents:
diff changeset
50
a61af66fc99e Initial load
duke
parents:
diff changeset
51
a61af66fc99e Initial load
duke
parents:
diff changeset
52 // ------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
53 // ciType::is_subtype_of
a61af66fc99e Initial load
duke
parents:
diff changeset
54 //
a61af66fc99e Initial load
duke
parents:
diff changeset
55 bool ciType::is_subtype_of(ciType* type) {
a61af66fc99e Initial load
duke
parents:
diff changeset
56 if (this == type) return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
57 if (is_klass() && type->is_klass())
a61af66fc99e Initial load
duke
parents:
diff changeset
58 return this->as_klass()->is_subtype_of(type->as_klass());
a61af66fc99e Initial load
duke
parents:
diff changeset
59 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
60 }
a61af66fc99e Initial load
duke
parents:
diff changeset
61
a61af66fc99e Initial load
duke
parents:
diff changeset
62 // ------------------------------------------------------------------
7604
f1de9dbc914e 8006109: test/java/util/AbstractSequentialList/AddAll.java fails: assert(rtype == ctype) failed: mismatched return types
twisti
parents: 6983
diff changeset
63 // ciType::name
f1de9dbc914e 8006109: test/java/util/AbstractSequentialList/AddAll.java fails: assert(rtype == ctype) failed: mismatched return types
twisti
parents: 6983
diff changeset
64 //
f1de9dbc914e 8006109: test/java/util/AbstractSequentialList/AddAll.java fails: assert(rtype == ctype) failed: mismatched return types
twisti
parents: 6983
diff changeset
65 // Return the name of this type
f1de9dbc914e 8006109: test/java/util/AbstractSequentialList/AddAll.java fails: assert(rtype == ctype) failed: mismatched return types
twisti
parents: 6983
diff changeset
66 const char* ciType::name() {
f1de9dbc914e 8006109: test/java/util/AbstractSequentialList/AddAll.java fails: assert(rtype == ctype) failed: mismatched return types
twisti
parents: 6983
diff changeset
67 if (is_primitive_type()) {
f1de9dbc914e 8006109: test/java/util/AbstractSequentialList/AddAll.java fails: assert(rtype == ctype) failed: mismatched return types
twisti
parents: 6983
diff changeset
68 return type2name(basic_type());
f1de9dbc914e 8006109: test/java/util/AbstractSequentialList/AddAll.java fails: assert(rtype == ctype) failed: mismatched return types
twisti
parents: 6983
diff changeset
69 } else {
f1de9dbc914e 8006109: test/java/util/AbstractSequentialList/AddAll.java fails: assert(rtype == ctype) failed: mismatched return types
twisti
parents: 6983
diff changeset
70 assert(is_klass(), "must be");
f1de9dbc914e 8006109: test/java/util/AbstractSequentialList/AddAll.java fails: assert(rtype == ctype) failed: mismatched return types
twisti
parents: 6983
diff changeset
71 return as_klass()->name()->as_utf8();
f1de9dbc914e 8006109: test/java/util/AbstractSequentialList/AddAll.java fails: assert(rtype == ctype) failed: mismatched return types
twisti
parents: 6983
diff changeset
72 }
f1de9dbc914e 8006109: test/java/util/AbstractSequentialList/AddAll.java fails: assert(rtype == ctype) failed: mismatched return types
twisti
parents: 6983
diff changeset
73 }
f1de9dbc914e 8006109: test/java/util/AbstractSequentialList/AddAll.java fails: assert(rtype == ctype) failed: mismatched return types
twisti
parents: 6983
diff changeset
74
f1de9dbc914e 8006109: test/java/util/AbstractSequentialList/AddAll.java fails: assert(rtype == ctype) failed: mismatched return types
twisti
parents: 6983
diff changeset
75 // ------------------------------------------------------------------
0
a61af66fc99e Initial load
duke
parents:
diff changeset
76 // ciType::print_impl
a61af66fc99e Initial load
duke
parents:
diff changeset
77 //
a61af66fc99e Initial load
duke
parents:
diff changeset
78 // Implementation of the print method.
a61af66fc99e Initial load
duke
parents:
diff changeset
79 void ciType::print_impl(outputStream* st) {
a61af66fc99e Initial load
duke
parents:
diff changeset
80 st->print(" type=");
a61af66fc99e Initial load
duke
parents:
diff changeset
81 print_name_on(st);
a61af66fc99e Initial load
duke
parents:
diff changeset
82 }
a61af66fc99e Initial load
duke
parents:
diff changeset
83
a61af66fc99e Initial load
duke
parents:
diff changeset
84 // ------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
85 // ciType::print_name
a61af66fc99e Initial load
duke
parents:
diff changeset
86 //
a61af66fc99e Initial load
duke
parents:
diff changeset
87 // Print the name of this type
a61af66fc99e Initial load
duke
parents:
diff changeset
88 void ciType::print_name_on(outputStream* st) {
7604
f1de9dbc914e 8006109: test/java/util/AbstractSequentialList/AddAll.java fails: assert(rtype == ctype) failed: mismatched return types
twisti
parents: 6983
diff changeset
89 ResourceMark rm;
f1de9dbc914e 8006109: test/java/util/AbstractSequentialList/AddAll.java fails: assert(rtype == ctype) failed: mismatched return types
twisti
parents: 6983
diff changeset
90 st->print(name());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
91 }
a61af66fc99e Initial load
duke
parents:
diff changeset
92
a61af66fc99e Initial load
duke
parents:
diff changeset
93
a61af66fc99e Initial load
duke
parents:
diff changeset
94
a61af66fc99e Initial load
duke
parents:
diff changeset
95 // ------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
96 // ciType::java_mirror
a61af66fc99e Initial load
duke
parents:
diff changeset
97 //
a61af66fc99e Initial load
duke
parents:
diff changeset
98 ciInstance* ciType::java_mirror() {
a61af66fc99e Initial load
duke
parents:
diff changeset
99 VM_ENTRY_MARK;
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1972
diff changeset
100 return CURRENT_THREAD_ENV->get_instance(Universe::java_mirror(basic_type()));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
101 }
a61af66fc99e Initial load
duke
parents:
diff changeset
102
a61af66fc99e Initial load
duke
parents:
diff changeset
103 // ------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
104 // ciType::box_klass
a61af66fc99e Initial load
duke
parents:
diff changeset
105 //
a61af66fc99e Initial load
duke
parents:
diff changeset
106 ciKlass* ciType::box_klass() {
a61af66fc99e Initial load
duke
parents:
diff changeset
107 if (!is_primitive_type()) return this->as_klass(); // reference types are "self boxing"
a61af66fc99e Initial load
duke
parents:
diff changeset
108
a61af66fc99e Initial load
duke
parents:
diff changeset
109 // Void is "boxed" with a null.
a61af66fc99e Initial load
duke
parents:
diff changeset
110 if (basic_type() == T_VOID) return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
111
a61af66fc99e Initial load
duke
parents:
diff changeset
112 VM_ENTRY_MARK;
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1972
diff changeset
113 return CURRENT_THREAD_ENV->get_instance_klass(SystemDictionary::box_klass(basic_type()));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
114 }
a61af66fc99e Initial load
duke
parents:
diff changeset
115
a61af66fc99e Initial load
duke
parents:
diff changeset
116
a61af66fc99e Initial load
duke
parents:
diff changeset
117 // ------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
118 // ciType::make
a61af66fc99e Initial load
duke
parents:
diff changeset
119 //
a61af66fc99e Initial load
duke
parents:
diff changeset
120 // Produce the ciType for a given primitive BasicType.
a61af66fc99e Initial load
duke
parents:
diff changeset
121 // As a bonus, produce the right reference type for T_OBJECT.
a61af66fc99e Initial load
duke
parents:
diff changeset
122 // Does not work on T_ARRAY.
a61af66fc99e Initial load
duke
parents:
diff changeset
123 ciType* ciType::make(BasicType t) {
a61af66fc99e Initial load
duke
parents:
diff changeset
124 // short, etc.
a61af66fc99e Initial load
duke
parents:
diff changeset
125 // Note: Bare T_ADDRESS means a raw pointer type, not a return_address.
a61af66fc99e Initial load
duke
parents:
diff changeset
126 assert((uint)t < T_CONFLICT+1, "range check");
1142
4ce7240d622c 6914300: ciEnv should export all well known classes
never
parents: 0
diff changeset
127 if (t == T_OBJECT) return ciEnv::_Object_klass; // java/lang/Object
0
a61af66fc99e Initial load
duke
parents:
diff changeset
128 assert(_basic_types[t] != NULL, "domain check");
a61af66fc99e Initial load
duke
parents:
diff changeset
129 return _basic_types[t];
a61af66fc99e Initial load
duke
parents:
diff changeset
130 }
a61af66fc99e Initial load
duke
parents:
diff changeset
131
a61af66fc99e Initial load
duke
parents:
diff changeset
132 // ciReturnAddress
a61af66fc99e Initial load
duke
parents:
diff changeset
133 //
a61af66fc99e Initial load
duke
parents:
diff changeset
134 // This class represents the type of a specific return address in the
a61af66fc99e Initial load
duke
parents:
diff changeset
135 // bytecodes.
a61af66fc99e Initial load
duke
parents:
diff changeset
136
a61af66fc99e Initial load
duke
parents:
diff changeset
137 // ------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
138 // ciReturnAddress::ciReturnAddress
a61af66fc99e Initial load
duke
parents:
diff changeset
139 //
a61af66fc99e Initial load
duke
parents:
diff changeset
140 ciReturnAddress::ciReturnAddress(int bci) : ciType(T_ADDRESS) {
a61af66fc99e Initial load
duke
parents:
diff changeset
141 assert(0 <= bci, "bci cannot be negative");
a61af66fc99e Initial load
duke
parents:
diff changeset
142 _bci = bci;
a61af66fc99e Initial load
duke
parents:
diff changeset
143 }
a61af66fc99e Initial load
duke
parents:
diff changeset
144
a61af66fc99e Initial load
duke
parents:
diff changeset
145 // ------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
146 // ciReturnAddress::print_impl
a61af66fc99e Initial load
duke
parents:
diff changeset
147 //
a61af66fc99e Initial load
duke
parents:
diff changeset
148 // Implementation of the print method.
a61af66fc99e Initial load
duke
parents:
diff changeset
149 void ciReturnAddress::print_impl(outputStream* st) {
a61af66fc99e Initial load
duke
parents:
diff changeset
150 st->print(" bci=%d", _bci);
a61af66fc99e Initial load
duke
parents:
diff changeset
151 }
a61af66fc99e Initial load
duke
parents:
diff changeset
152
a61af66fc99e Initial load
duke
parents:
diff changeset
153 // ------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
154 // ciReturnAddress::make
a61af66fc99e Initial load
duke
parents:
diff changeset
155 ciReturnAddress* ciReturnAddress::make(int bci) {
a61af66fc99e Initial load
duke
parents:
diff changeset
156 GUARDED_VM_ENTRY(return CURRENT_ENV->get_return_address(bci);)
a61af66fc99e Initial load
duke
parents:
diff changeset
157 }