annotate src/share/vm/ci/ciInstance.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 1999-2005 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/_ciInstance.cpp.incl"
a61af66fc99e Initial load
duke
parents:
diff changeset
27
a61af66fc99e Initial load
duke
parents:
diff changeset
28 // ciInstance
a61af66fc99e Initial load
duke
parents:
diff changeset
29 //
a61af66fc99e Initial load
duke
parents:
diff changeset
30 // This class represents an instanceOop in the HotSpot virtual
a61af66fc99e Initial load
duke
parents:
diff changeset
31 // machine.
a61af66fc99e Initial load
duke
parents:
diff changeset
32
a61af66fc99e Initial load
duke
parents:
diff changeset
33 // ------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
34 // ciObject::java_mirror_type
a61af66fc99e Initial load
duke
parents:
diff changeset
35 ciType* ciInstance::java_mirror_type() {
a61af66fc99e Initial load
duke
parents:
diff changeset
36 VM_ENTRY_MARK;
a61af66fc99e Initial load
duke
parents:
diff changeset
37 oop m = get_oop();
a61af66fc99e Initial load
duke
parents:
diff changeset
38 // Return NULL if it is not java.lang.Class.
a61af66fc99e Initial load
duke
parents:
diff changeset
39 if (m == NULL || m->klass() != SystemDictionary::class_klass()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
40 return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
41 }
a61af66fc99e Initial load
duke
parents:
diff changeset
42 // Return either a primitive type or a klass.
a61af66fc99e Initial load
duke
parents:
diff changeset
43 if (java_lang_Class::is_primitive(m)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
44 return ciType::make(java_lang_Class::primitive_type(m));
a61af66fc99e Initial load
duke
parents:
diff changeset
45 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
46 klassOop k = java_lang_Class::as_klassOop(m);
a61af66fc99e Initial load
duke
parents:
diff changeset
47 assert(k != NULL, "");
a61af66fc99e Initial load
duke
parents:
diff changeset
48 return CURRENT_THREAD_ENV->get_object(k)->as_klass();
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 // ciInstance::field_value
a61af66fc99e Initial load
duke
parents:
diff changeset
54 //
a61af66fc99e Initial load
duke
parents:
diff changeset
55 // Constant value of a field.
a61af66fc99e Initial load
duke
parents:
diff changeset
56 ciConstant ciInstance::field_value(ciField* field) {
a61af66fc99e Initial load
duke
parents:
diff changeset
57 assert(is_loaded() &&
a61af66fc99e Initial load
duke
parents:
diff changeset
58 field->holder()->is_loaded() &&
a61af66fc99e Initial load
duke
parents:
diff changeset
59 klass()->is_subclass_of(field->holder()),
a61af66fc99e Initial load
duke
parents:
diff changeset
60 "invalid access");
a61af66fc99e Initial load
duke
parents:
diff changeset
61 VM_ENTRY_MARK;
a61af66fc99e Initial load
duke
parents:
diff changeset
62 ciConstant result;
a61af66fc99e Initial load
duke
parents:
diff changeset
63 oop obj = get_oop();
a61af66fc99e Initial load
duke
parents:
diff changeset
64 assert(obj != NULL, "bad oop");
a61af66fc99e Initial load
duke
parents:
diff changeset
65 BasicType field_btype = field->type()->basic_type();
a61af66fc99e Initial load
duke
parents:
diff changeset
66 int offset = field->offset();
a61af66fc99e Initial load
duke
parents:
diff changeset
67
a61af66fc99e Initial load
duke
parents:
diff changeset
68 switch(field_btype) {
a61af66fc99e Initial load
duke
parents:
diff changeset
69 case T_BYTE:
a61af66fc99e Initial load
duke
parents:
diff changeset
70 return ciConstant(field_btype, obj->byte_field(offset));
a61af66fc99e Initial load
duke
parents:
diff changeset
71 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
72 case T_CHAR:
a61af66fc99e Initial load
duke
parents:
diff changeset
73 return ciConstant(field_btype, obj->char_field(offset));
a61af66fc99e Initial load
duke
parents:
diff changeset
74 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
75 case T_SHORT:
a61af66fc99e Initial load
duke
parents:
diff changeset
76 return ciConstant(field_btype, obj->short_field(offset));
a61af66fc99e Initial load
duke
parents:
diff changeset
77 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
78 case T_BOOLEAN:
a61af66fc99e Initial load
duke
parents:
diff changeset
79 return ciConstant(field_btype, obj->bool_field(offset));
a61af66fc99e Initial load
duke
parents:
diff changeset
80 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
81 case T_INT:
a61af66fc99e Initial load
duke
parents:
diff changeset
82 return ciConstant(field_btype, obj->int_field(offset));
a61af66fc99e Initial load
duke
parents:
diff changeset
83 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
84 case T_FLOAT:
a61af66fc99e Initial load
duke
parents:
diff changeset
85 return ciConstant(obj->float_field(offset));
a61af66fc99e Initial load
duke
parents:
diff changeset
86 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
87 case T_DOUBLE:
a61af66fc99e Initial load
duke
parents:
diff changeset
88 return ciConstant(obj->double_field(offset));
a61af66fc99e Initial load
duke
parents:
diff changeset
89 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
90 case T_LONG:
a61af66fc99e Initial load
duke
parents:
diff changeset
91 return ciConstant(obj->long_field(offset));
a61af66fc99e Initial load
duke
parents:
diff changeset
92 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
93 case T_OBJECT:
a61af66fc99e Initial load
duke
parents:
diff changeset
94 case T_ARRAY:
a61af66fc99e Initial load
duke
parents:
diff changeset
95 {
a61af66fc99e Initial load
duke
parents:
diff changeset
96 oop o = obj->obj_field(offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
97
a61af66fc99e Initial load
duke
parents:
diff changeset
98 // A field will be "constant" if it is known always to be
a61af66fc99e Initial load
duke
parents:
diff changeset
99 // a non-null reference to an instance of a particular class,
a61af66fc99e Initial load
duke
parents:
diff changeset
100 // or to a particular array. This can happen even if the instance
a61af66fc99e Initial load
duke
parents:
diff changeset
101 // or array is not perm. In such a case, an "unloaded" ciArray
a61af66fc99e Initial load
duke
parents:
diff changeset
102 // or ciInstance is created. The compiler may be able to use
a61af66fc99e Initial load
duke
parents:
diff changeset
103 // information about the object's class (which is exact) or length.
a61af66fc99e Initial load
duke
parents:
diff changeset
104
a61af66fc99e Initial load
duke
parents:
diff changeset
105 if (o == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
106 return ciConstant(field_btype, ciNullObject::make());
a61af66fc99e Initial load
duke
parents:
diff changeset
107 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
108 return ciConstant(field_btype, CURRENT_ENV->get_object(o));
a61af66fc99e Initial load
duke
parents:
diff changeset
109 }
a61af66fc99e Initial load
duke
parents:
diff changeset
110 }
a61af66fc99e Initial load
duke
parents:
diff changeset
111 }
a61af66fc99e Initial load
duke
parents:
diff changeset
112 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
113 // to shut up the compiler
a61af66fc99e Initial load
duke
parents:
diff changeset
114 return ciConstant();
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 // ciInstance::field_value_by_offset
a61af66fc99e Initial load
duke
parents:
diff changeset
119 //
a61af66fc99e Initial load
duke
parents:
diff changeset
120 // Constant value of a field at the specified offset.
a61af66fc99e Initial load
duke
parents:
diff changeset
121 ciConstant ciInstance::field_value_by_offset(int field_offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
122 ciInstanceKlass* ik = klass()->as_instance_klass();
a61af66fc99e Initial load
duke
parents:
diff changeset
123 ciField* field = ik->get_field_by_offset(field_offset, false);
a61af66fc99e Initial load
duke
parents:
diff changeset
124 return field_value(field);
a61af66fc99e Initial load
duke
parents:
diff changeset
125 }
a61af66fc99e Initial load
duke
parents:
diff changeset
126
a61af66fc99e Initial load
duke
parents:
diff changeset
127 // ------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
128 // ciInstance::print_impl
a61af66fc99e Initial load
duke
parents:
diff changeset
129 //
a61af66fc99e Initial load
duke
parents:
diff changeset
130 // Implementation of the print method.
a61af66fc99e Initial load
duke
parents:
diff changeset
131 void ciInstance::print_impl(outputStream* st) {
a61af66fc99e Initial load
duke
parents:
diff changeset
132 st->print(" type=");
a61af66fc99e Initial load
duke
parents:
diff changeset
133 klass()->print(st);
a61af66fc99e Initial load
duke
parents:
diff changeset
134 }