annotate src/share/vm/ci/ciInstance.cpp @ 8733:9def4075da6d

8008079: G1: Add nextObject routine to CMBitMapRO and replace nextWord Summary: Update the task local finger to the start of the next object when marking aborts, in order to avoid the redundant scanning of all 0's when the marking task restarts, if otherwise updating to the next word. In addition, reuse the routine nextObject() in routine iterate(). Reviewed-by: johnc, ysr Contributed-by: tamao <tao.mao@oracle.com>
author tamao
date Tue, 05 Mar 2013 15:36:56 -0800
parents da91efe96a93
children 59982ff9e0ec
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 2467
diff changeset
2 * Copyright (c) 1999, 2012, 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"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
26 #include "ci/ciConstant.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
27 #include "ci/ciField.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
28 #include "ci/ciInstance.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
29 #include "ci/ciInstanceKlass.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
30 #include "ci/ciUtilities.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
31 #include "classfile/systemDictionary.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
32 #include "oops/oop.inline.hpp"
0
a61af66fc99e Initial load
duke
parents:
diff changeset
33
a61af66fc99e Initial load
duke
parents:
diff changeset
34 // ciInstance
a61af66fc99e Initial load
duke
parents:
diff changeset
35 //
a61af66fc99e Initial load
duke
parents:
diff changeset
36 // This class represents an instanceOop in the HotSpot virtual
a61af66fc99e Initial load
duke
parents:
diff changeset
37 // machine.
a61af66fc99e Initial load
duke
parents:
diff changeset
38
a61af66fc99e Initial load
duke
parents:
diff changeset
39 // ------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
40 // ciObject::java_mirror_type
a61af66fc99e Initial load
duke
parents:
diff changeset
41 ciType* ciInstance::java_mirror_type() {
a61af66fc99e Initial load
duke
parents:
diff changeset
42 VM_ENTRY_MARK;
a61af66fc99e Initial load
duke
parents:
diff changeset
43 oop m = get_oop();
a61af66fc99e Initial load
duke
parents:
diff changeset
44 // Return NULL if it is not java.lang.Class.
1142
4ce7240d622c 6914300: ciEnv should export all well known classes
never
parents: 0
diff changeset
45 if (m == NULL || m->klass() != SystemDictionary::Class_klass()) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
46 return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
47 }
a61af66fc99e Initial load
duke
parents:
diff changeset
48 // Return either a primitive type or a klass.
a61af66fc99e Initial load
duke
parents:
diff changeset
49 if (java_lang_Class::is_primitive(m)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
50 return ciType::make(java_lang_Class::primitive_type(m));
a61af66fc99e Initial load
duke
parents:
diff changeset
51 } else {
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 2467
diff changeset
52 Klass* k = java_lang_Class::as_Klass(m);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
53 assert(k != NULL, "");
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 2467
diff changeset
54 return CURRENT_THREAD_ENV->get_klass(k);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
55 }
a61af66fc99e Initial load
duke
parents:
diff changeset
56 }
a61af66fc99e Initial load
duke
parents:
diff changeset
57
a61af66fc99e Initial load
duke
parents:
diff changeset
58 // ------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
59 // ciInstance::field_value
a61af66fc99e Initial load
duke
parents:
diff changeset
60 //
a61af66fc99e Initial load
duke
parents:
diff changeset
61 // Constant value of a field.
a61af66fc99e Initial load
duke
parents:
diff changeset
62 ciConstant ciInstance::field_value(ciField* field) {
a61af66fc99e Initial load
duke
parents:
diff changeset
63 assert(is_loaded() &&
a61af66fc99e Initial load
duke
parents:
diff changeset
64 field->holder()->is_loaded() &&
a61af66fc99e Initial load
duke
parents:
diff changeset
65 klass()->is_subclass_of(field->holder()),
a61af66fc99e Initial load
duke
parents:
diff changeset
66 "invalid access");
a61af66fc99e Initial load
duke
parents:
diff changeset
67 VM_ENTRY_MARK;
a61af66fc99e Initial load
duke
parents:
diff changeset
68 ciConstant result;
2467
3fa3c7e4d4f3 7035161: assert(!o->is_null_object()) failed: null object not yet handled here.
never
parents: 2376
diff changeset
69 Handle obj = get_oop();
3fa3c7e4d4f3 7035161: assert(!o->is_null_object()) failed: null object not yet handled here.
never
parents: 2376
diff changeset
70 assert(!obj.is_null(), "bad oop");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
71 BasicType field_btype = field->type()->basic_type();
a61af66fc99e Initial load
duke
parents:
diff changeset
72 int offset = field->offset();
a61af66fc99e Initial load
duke
parents:
diff changeset
73
a61af66fc99e Initial load
duke
parents:
diff changeset
74 switch(field_btype) {
a61af66fc99e Initial load
duke
parents:
diff changeset
75 case T_BYTE:
a61af66fc99e Initial load
duke
parents:
diff changeset
76 return ciConstant(field_btype, obj->byte_field(offset));
a61af66fc99e Initial load
duke
parents:
diff changeset
77 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
78 case T_CHAR:
a61af66fc99e Initial load
duke
parents:
diff changeset
79 return ciConstant(field_btype, obj->char_field(offset));
a61af66fc99e Initial load
duke
parents:
diff changeset
80 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
81 case T_SHORT:
a61af66fc99e Initial load
duke
parents:
diff changeset
82 return ciConstant(field_btype, obj->short_field(offset));
a61af66fc99e Initial load
duke
parents:
diff changeset
83 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
84 case T_BOOLEAN:
a61af66fc99e Initial load
duke
parents:
diff changeset
85 return ciConstant(field_btype, obj->bool_field(offset));
a61af66fc99e Initial load
duke
parents:
diff changeset
86 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
87 case T_INT:
a61af66fc99e Initial load
duke
parents:
diff changeset
88 return ciConstant(field_btype, obj->int_field(offset));
a61af66fc99e Initial load
duke
parents:
diff changeset
89 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
90 case T_FLOAT:
a61af66fc99e Initial load
duke
parents:
diff changeset
91 return ciConstant(obj->float_field(offset));
a61af66fc99e Initial load
duke
parents:
diff changeset
92 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
93 case T_DOUBLE:
a61af66fc99e Initial load
duke
parents:
diff changeset
94 return ciConstant(obj->double_field(offset));
a61af66fc99e Initial load
duke
parents:
diff changeset
95 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
96 case T_LONG:
a61af66fc99e Initial load
duke
parents:
diff changeset
97 return ciConstant(obj->long_field(offset));
a61af66fc99e Initial load
duke
parents:
diff changeset
98 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
99 case T_OBJECT:
a61af66fc99e Initial load
duke
parents:
diff changeset
100 case T_ARRAY:
a61af66fc99e Initial load
duke
parents:
diff changeset
101 {
a61af66fc99e Initial load
duke
parents:
diff changeset
102 oop o = obj->obj_field(offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
103
a61af66fc99e Initial load
duke
parents:
diff changeset
104 // A field will be "constant" if it is known always to be
a61af66fc99e Initial load
duke
parents:
diff changeset
105 // a non-null reference to an instance of a particular class,
a61af66fc99e Initial load
duke
parents:
diff changeset
106 // or to a particular array. This can happen even if the instance
a61af66fc99e Initial load
duke
parents:
diff changeset
107 // or array is not perm. In such a case, an "unloaded" ciArray
a61af66fc99e Initial load
duke
parents:
diff changeset
108 // or ciInstance is created. The compiler may be able to use
a61af66fc99e Initial load
duke
parents:
diff changeset
109 // information about the object's class (which is exact) or length.
a61af66fc99e Initial load
duke
parents:
diff changeset
110
a61af66fc99e Initial load
duke
parents:
diff changeset
111 if (o == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
112 return ciConstant(field_btype, ciNullObject::make());
a61af66fc99e Initial load
duke
parents:
diff changeset
113 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
114 return ciConstant(field_btype, CURRENT_ENV->get_object(o));
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 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
119 // to shut up the compiler
a61af66fc99e Initial load
duke
parents:
diff changeset
120 return ciConstant();
a61af66fc99e Initial load
duke
parents:
diff changeset
121 }
a61af66fc99e Initial load
duke
parents:
diff changeset
122
a61af66fc99e Initial load
duke
parents:
diff changeset
123 // ------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
124 // ciInstance::field_value_by_offset
a61af66fc99e Initial load
duke
parents:
diff changeset
125 //
a61af66fc99e Initial load
duke
parents:
diff changeset
126 // Constant value of a field at the specified offset.
a61af66fc99e Initial load
duke
parents:
diff changeset
127 ciConstant ciInstance::field_value_by_offset(int field_offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
128 ciInstanceKlass* ik = klass()->as_instance_klass();
a61af66fc99e Initial load
duke
parents:
diff changeset
129 ciField* field = ik->get_field_by_offset(field_offset, false);
a61af66fc99e Initial load
duke
parents:
diff changeset
130 return field_value(field);
a61af66fc99e Initial load
duke
parents:
diff changeset
131 }
a61af66fc99e Initial load
duke
parents:
diff changeset
132
a61af66fc99e Initial load
duke
parents:
diff changeset
133 // ------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
134 // ciInstance::print_impl
a61af66fc99e Initial load
duke
parents:
diff changeset
135 //
a61af66fc99e Initial load
duke
parents:
diff changeset
136 // Implementation of the print method.
a61af66fc99e Initial load
duke
parents:
diff changeset
137 void ciInstance::print_impl(outputStream* st) {
a61af66fc99e Initial load
duke
parents:
diff changeset
138 st->print(" type=");
a61af66fc99e Initial load
duke
parents:
diff changeset
139 klass()->print(st);
a61af66fc99e Initial load
duke
parents:
diff changeset
140 }
2376
c7f3d0b4570f 7017732: move static fields into Class to prepare for perm gen removal
never
parents: 1972
diff changeset
141
c7f3d0b4570f 7017732: move static fields into Class to prepare for perm gen removal
never
parents: 1972
diff changeset
142
c7f3d0b4570f 7017732: move static fields into Class to prepare for perm gen removal
never
parents: 1972
diff changeset
143 ciKlass* ciInstance::java_lang_Class_klass() {
c7f3d0b4570f 7017732: move static fields into Class to prepare for perm gen removal
never
parents: 1972
diff changeset
144 VM_ENTRY_MARK;
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 2467
diff changeset
145 return CURRENT_ENV->get_metadata(java_lang_Class::as_Klass(get_oop()))->as_klass();
2376
c7f3d0b4570f 7017732: move static fields into Class to prepare for perm gen removal
never
parents: 1972
diff changeset
146 }