annotate src/share/vm/ci/ciType.cpp @ 666:ebebd376f657

6805522: Server VM fails with assertion (block1->start() != block2->start(),"successors have unique bcis") Reviewed-by: kvn
author never
date Mon, 23 Mar 2009 13:58:58 -0700
parents a61af66fc99e
children 4ce7240d622c
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 2000-2002 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/_ciType.cpp.incl"
a61af66fc99e Initial load
duke
parents:
diff changeset
27
a61af66fc99e Initial load
duke
parents:
diff changeset
28 ciType* ciType::_basic_types[T_CONFLICT+1];
a61af66fc99e Initial load
duke
parents:
diff changeset
29
a61af66fc99e Initial load
duke
parents:
diff changeset
30 // ciType
a61af66fc99e Initial load
duke
parents:
diff changeset
31 //
a61af66fc99e Initial load
duke
parents:
diff changeset
32 // This class represents either a class (T_OBJECT), array (T_ARRAY),
a61af66fc99e Initial load
duke
parents:
diff changeset
33 // or one of the primitive types such as T_INT.
a61af66fc99e Initial load
duke
parents:
diff changeset
34
a61af66fc99e Initial load
duke
parents:
diff changeset
35 // ------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
36 // ciType::ciType
a61af66fc99e Initial load
duke
parents:
diff changeset
37 //
a61af66fc99e Initial load
duke
parents:
diff changeset
38 ciType::ciType(BasicType basic_type) : ciObject() {
a61af66fc99e Initial load
duke
parents:
diff changeset
39 assert(basic_type >= T_BOOLEAN && basic_type <= T_CONFLICT, "range check");
a61af66fc99e Initial load
duke
parents:
diff changeset
40 assert(basic_type != T_OBJECT && basic_type != T_ARRAY, "not a reference type");
a61af66fc99e Initial load
duke
parents:
diff changeset
41 _basic_type = basic_type;
a61af66fc99e Initial load
duke
parents:
diff changeset
42 }
a61af66fc99e Initial load
duke
parents:
diff changeset
43
a61af66fc99e Initial load
duke
parents:
diff changeset
44 ciType::ciType(KlassHandle k) : ciObject(k) {
a61af66fc99e Initial load
duke
parents:
diff changeset
45 _basic_type = Klass::cast(k())->oop_is_array() ? T_ARRAY : T_OBJECT;
a61af66fc99e Initial load
duke
parents:
diff changeset
46 }
a61af66fc99e Initial load
duke
parents:
diff changeset
47
a61af66fc99e Initial load
duke
parents:
diff changeset
48 ciType::ciType(ciKlass* klass) : ciObject(klass) {
a61af66fc99e Initial load
duke
parents:
diff changeset
49 _basic_type = klass->is_array_klass_klass() ? T_ARRAY : T_OBJECT;
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 // ------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
54 // ciType::is_subtype_of
a61af66fc99e Initial load
duke
parents:
diff changeset
55 //
a61af66fc99e Initial load
duke
parents:
diff changeset
56 bool ciType::is_subtype_of(ciType* type) {
a61af66fc99e Initial load
duke
parents:
diff changeset
57 if (this == type) return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
58 if (is_klass() && type->is_klass())
a61af66fc99e Initial load
duke
parents:
diff changeset
59 return this->as_klass()->is_subtype_of(type->as_klass());
a61af66fc99e Initial load
duke
parents:
diff changeset
60 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
61 }
a61af66fc99e Initial load
duke
parents:
diff changeset
62
a61af66fc99e Initial load
duke
parents:
diff changeset
63 // ------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
64 // ciType::print_impl
a61af66fc99e Initial load
duke
parents:
diff changeset
65 //
a61af66fc99e Initial load
duke
parents:
diff changeset
66 // Implementation of the print method.
a61af66fc99e Initial load
duke
parents:
diff changeset
67 void ciType::print_impl(outputStream* st) {
a61af66fc99e Initial load
duke
parents:
diff changeset
68 st->print(" type=");
a61af66fc99e Initial load
duke
parents:
diff changeset
69 print_name_on(st);
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 // ciType::print_name
a61af66fc99e Initial load
duke
parents:
diff changeset
74 //
a61af66fc99e Initial load
duke
parents:
diff changeset
75 // Print the name of this type
a61af66fc99e Initial load
duke
parents:
diff changeset
76 void ciType::print_name_on(outputStream* st) {
a61af66fc99e Initial load
duke
parents:
diff changeset
77 st->print(type2name(basic_type()));
a61af66fc99e Initial load
duke
parents:
diff changeset
78 }
a61af66fc99e Initial load
duke
parents:
diff changeset
79
a61af66fc99e Initial load
duke
parents:
diff changeset
80
a61af66fc99e Initial load
duke
parents:
diff changeset
81
a61af66fc99e Initial load
duke
parents:
diff changeset
82 // ------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
83 // ciType::java_mirror
a61af66fc99e Initial load
duke
parents:
diff changeset
84 //
a61af66fc99e Initial load
duke
parents:
diff changeset
85 ciInstance* ciType::java_mirror() {
a61af66fc99e Initial load
duke
parents:
diff changeset
86 VM_ENTRY_MARK;
a61af66fc99e Initial load
duke
parents:
diff changeset
87 return CURRENT_THREAD_ENV->get_object(Universe::java_mirror(basic_type()))->as_instance();
a61af66fc99e Initial load
duke
parents:
diff changeset
88 }
a61af66fc99e Initial load
duke
parents:
diff changeset
89
a61af66fc99e Initial load
duke
parents:
diff changeset
90 // ------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
91 // ciType::box_klass
a61af66fc99e Initial load
duke
parents:
diff changeset
92 //
a61af66fc99e Initial load
duke
parents:
diff changeset
93 ciKlass* ciType::box_klass() {
a61af66fc99e Initial load
duke
parents:
diff changeset
94 if (!is_primitive_type()) return this->as_klass(); // reference types are "self boxing"
a61af66fc99e Initial load
duke
parents:
diff changeset
95
a61af66fc99e Initial load
duke
parents:
diff changeset
96 // Void is "boxed" with a null.
a61af66fc99e Initial load
duke
parents:
diff changeset
97 if (basic_type() == T_VOID) return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
98
a61af66fc99e Initial load
duke
parents:
diff changeset
99 VM_ENTRY_MARK;
a61af66fc99e Initial load
duke
parents:
diff changeset
100 return CURRENT_THREAD_ENV->get_object(SystemDictionary::box_klass(basic_type()))->as_instance_klass();
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 // ------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
105 // ciType::make
a61af66fc99e Initial load
duke
parents:
diff changeset
106 //
a61af66fc99e Initial load
duke
parents:
diff changeset
107 // Produce the ciType for a given primitive BasicType.
a61af66fc99e Initial load
duke
parents:
diff changeset
108 // As a bonus, produce the right reference type for T_OBJECT.
a61af66fc99e Initial load
duke
parents:
diff changeset
109 // Does not work on T_ARRAY.
a61af66fc99e Initial load
duke
parents:
diff changeset
110 ciType* ciType::make(BasicType t) {
a61af66fc99e Initial load
duke
parents:
diff changeset
111 // short, etc.
a61af66fc99e Initial load
duke
parents:
diff changeset
112 // Note: Bare T_ADDRESS means a raw pointer type, not a return_address.
a61af66fc99e Initial load
duke
parents:
diff changeset
113 assert((uint)t < T_CONFLICT+1, "range check");
a61af66fc99e Initial load
duke
parents:
diff changeset
114 if (t == T_OBJECT) return ciEnv::_Object; // java/lang/Object
a61af66fc99e Initial load
duke
parents:
diff changeset
115 assert(_basic_types[t] != NULL, "domain check");
a61af66fc99e Initial load
duke
parents:
diff changeset
116 return _basic_types[t];
a61af66fc99e Initial load
duke
parents:
diff changeset
117 }
a61af66fc99e Initial load
duke
parents:
diff changeset
118
a61af66fc99e Initial load
duke
parents:
diff changeset
119 // ciReturnAddress
a61af66fc99e Initial load
duke
parents:
diff changeset
120 //
a61af66fc99e Initial load
duke
parents:
diff changeset
121 // This class represents the type of a specific return address in the
a61af66fc99e Initial load
duke
parents:
diff changeset
122 // bytecodes.
a61af66fc99e Initial load
duke
parents:
diff changeset
123
a61af66fc99e Initial load
duke
parents:
diff changeset
124 // ------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
125 // ciReturnAddress::ciReturnAddress
a61af66fc99e Initial load
duke
parents:
diff changeset
126 //
a61af66fc99e Initial load
duke
parents:
diff changeset
127 ciReturnAddress::ciReturnAddress(int bci) : ciType(T_ADDRESS) {
a61af66fc99e Initial load
duke
parents:
diff changeset
128 assert(0 <= bci, "bci cannot be negative");
a61af66fc99e Initial load
duke
parents:
diff changeset
129 _bci = bci;
a61af66fc99e Initial load
duke
parents:
diff changeset
130 }
a61af66fc99e Initial load
duke
parents:
diff changeset
131
a61af66fc99e Initial load
duke
parents:
diff changeset
132 // ------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
133 // ciReturnAddress::print_impl
a61af66fc99e Initial load
duke
parents:
diff changeset
134 //
a61af66fc99e Initial load
duke
parents:
diff changeset
135 // Implementation of the print method.
a61af66fc99e Initial load
duke
parents:
diff changeset
136 void ciReturnAddress::print_impl(outputStream* st) {
a61af66fc99e Initial load
duke
parents:
diff changeset
137 st->print(" bci=%d", _bci);
a61af66fc99e Initial load
duke
parents:
diff changeset
138 }
a61af66fc99e Initial load
duke
parents:
diff changeset
139
a61af66fc99e Initial load
duke
parents:
diff changeset
140 // ------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
141 // ciReturnAddress::make
a61af66fc99e Initial load
duke
parents:
diff changeset
142 ciReturnAddress* ciReturnAddress::make(int bci) {
a61af66fc99e Initial load
duke
parents:
diff changeset
143 GUARDED_VM_ENTRY(return CURRENT_ENV->get_return_address(bci);)
a61af66fc99e Initial load
duke
parents:
diff changeset
144 }