annotate src/share/vm/oops/constMethodKlass.cpp @ 6266:1d7922586cf6

7023639: JSR 292 method handle invocation needs a fast path for compiled code 6984705: JSR 292 method handle creation should not go through JNI Summary: remove assembly code for JDK 7 chained method handles Reviewed-by: jrose, twisti, kvn, mhaupt Contributed-by: John Rose <john.r.rose@oracle.com>, Christian Thalinger <christian.thalinger@oracle.com>, Michael Haupt <michael.haupt@oracle.com>
author twisti
date Tue, 24 Jul 2012 10:51:00 -0700
parents 8150fa46d2ed
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
6123
2fe087c3e814 7172967: Eliminate constMethod's _method backpointer to methodOop.
jiangli
parents: 3899
diff changeset
2 * Copyright (c) 2003, 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: 1155
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1155
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: 1155
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: 1713
diff changeset
25 #include "precompiled.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1713
diff changeset
26 #include "gc_implementation/shared/markSweep.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1713
diff changeset
27 #include "interpreter/interpreter.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1713
diff changeset
28 #include "memory/gcLocker.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1713
diff changeset
29 #include "memory/resourceArea.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1713
diff changeset
30 #include "oops/constMethodKlass.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1713
diff changeset
31 #include "oops/constMethodOop.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1713
diff changeset
32 #include "oops/oop.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1713
diff changeset
33 #include "oops/oop.inline2.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1713
diff changeset
34 #include "runtime/handles.inline.hpp"
0
a61af66fc99e Initial load
duke
parents:
diff changeset
35
a61af66fc99e Initial load
duke
parents:
diff changeset
36
a61af66fc99e Initial load
duke
parents:
diff changeset
37 klassOop constMethodKlass::create_klass(TRAPS) {
a61af66fc99e Initial load
duke
parents:
diff changeset
38 constMethodKlass o;
a61af66fc99e Initial load
duke
parents:
diff changeset
39 KlassHandle h_this_klass(THREAD, Universe::klassKlassObj());
a61af66fc99e Initial load
duke
parents:
diff changeset
40 KlassHandle k = base_create_klass(h_this_klass, header_size(),
a61af66fc99e Initial load
duke
parents:
diff changeset
41 o.vtbl_value(), CHECK_NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
42 // Make sure size calculation is right
a61af66fc99e Initial load
duke
parents:
diff changeset
43 assert(k()->size() == align_object_size(header_size()),
a61af66fc99e Initial load
duke
parents:
diff changeset
44 "wrong size for object");
a61af66fc99e Initial load
duke
parents:
diff changeset
45 //java_lang_Class::create_mirror(k, CHECK_NULL); // Allocate mirror
a61af66fc99e Initial load
duke
parents:
diff changeset
46 return k();
a61af66fc99e Initial load
duke
parents:
diff changeset
47 }
a61af66fc99e Initial load
duke
parents:
diff changeset
48
a61af66fc99e Initial load
duke
parents:
diff changeset
49
a61af66fc99e Initial load
duke
parents:
diff changeset
50 int constMethodKlass::oop_size(oop obj) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
51 assert(obj->is_constMethod(), "must be constMethod oop");
a61af66fc99e Initial load
duke
parents:
diff changeset
52 return constMethodOop(obj)->object_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
53 }
a61af66fc99e Initial load
duke
parents:
diff changeset
54
a61af66fc99e Initial load
duke
parents:
diff changeset
55 bool constMethodKlass::oop_is_parsable(oop obj) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
56 assert(obj->is_constMethod(), "must be constMethod oop");
a61af66fc99e Initial load
duke
parents:
diff changeset
57 return constMethodOop(obj)->object_is_parsable();
a61af66fc99e Initial load
duke
parents:
diff changeset
58 }
a61af66fc99e Initial load
duke
parents:
diff changeset
59
518
0af8b0718fc9 6692899: CMS: many vm.parallel_class_loading tests fail with assert "missing Printezis mark"
jmasa
parents: 0
diff changeset
60 bool constMethodKlass::oop_is_conc_safe(oop obj) const {
0af8b0718fc9 6692899: CMS: many vm.parallel_class_loading tests fail with assert "missing Printezis mark"
jmasa
parents: 0
diff changeset
61 assert(obj->is_constMethod(), "must be constMethod oop");
0af8b0718fc9 6692899: CMS: many vm.parallel_class_loading tests fail with assert "missing Printezis mark"
jmasa
parents: 0
diff changeset
62 return constMethodOop(obj)->is_conc_safe();
0af8b0718fc9 6692899: CMS: many vm.parallel_class_loading tests fail with assert "missing Printezis mark"
jmasa
parents: 0
diff changeset
63 }
0af8b0718fc9 6692899: CMS: many vm.parallel_class_loading tests fail with assert "missing Printezis mark"
jmasa
parents: 0
diff changeset
64
0
a61af66fc99e Initial load
duke
parents:
diff changeset
65 constMethodOop constMethodKlass::allocate(int byte_code_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
66 int compressed_line_number_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
67 int localvariable_table_length,
6213
8150fa46d2ed 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 6123
diff changeset
68 int exception_table_length,
0
a61af66fc99e Initial load
duke
parents:
diff changeset
69 int checked_exceptions_length,
518
0af8b0718fc9 6692899: CMS: many vm.parallel_class_loading tests fail with assert "missing Printezis mark"
jmasa
parents: 0
diff changeset
70 bool is_conc_safe,
0
a61af66fc99e Initial load
duke
parents:
diff changeset
71 TRAPS) {
a61af66fc99e Initial load
duke
parents:
diff changeset
72
a61af66fc99e Initial load
duke
parents:
diff changeset
73 int size = constMethodOopDesc::object_size(byte_code_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
74 compressed_line_number_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
75 localvariable_table_length,
6213
8150fa46d2ed 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 6123
diff changeset
76 exception_table_length,
0
a61af66fc99e Initial load
duke
parents:
diff changeset
77 checked_exceptions_length);
a61af66fc99e Initial load
duke
parents:
diff changeset
78 KlassHandle h_k(THREAD, as_klassOop());
a61af66fc99e Initial load
duke
parents:
diff changeset
79 constMethodOop cm = (constMethodOop)
a61af66fc99e Initial load
duke
parents:
diff changeset
80 CollectedHeap::permanent_obj_allocate(h_k, size, CHECK_NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
81 assert(!cm->is_parsable(), "Not yet safely parsable");
a61af66fc99e Initial load
duke
parents:
diff changeset
82 No_Safepoint_Verifier no_safepoint;
a61af66fc99e Initial load
duke
parents:
diff changeset
83 cm->set_interpreter_kind(Interpreter::invalid);
a61af66fc99e Initial load
duke
parents:
diff changeset
84 cm->init_fingerprint();
6123
2fe087c3e814 7172967: Eliminate constMethod's _method backpointer to methodOop.
jiangli
parents: 3899
diff changeset
85 cm->set_constants(NULL);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
86 cm->set_stackmap_data(NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
87 cm->set_code_size(byte_code_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
88 cm->set_constMethod_size(size);
a61af66fc99e Initial load
duke
parents:
diff changeset
89 cm->set_inlined_tables_length(checked_exceptions_length,
a61af66fc99e Initial load
duke
parents:
diff changeset
90 compressed_line_number_size,
6213
8150fa46d2ed 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 6123
diff changeset
91 localvariable_table_length,
8150fa46d2ed 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 6123
diff changeset
92 exception_table_length);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
93 assert(cm->size() == size, "wrong size for object");
518
0af8b0718fc9 6692899: CMS: many vm.parallel_class_loading tests fail with assert "missing Printezis mark"
jmasa
parents: 0
diff changeset
94 cm->set_is_conc_safe(is_conc_safe);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
95 cm->set_partially_loaded();
a61af66fc99e Initial load
duke
parents:
diff changeset
96 assert(cm->is_parsable(), "Is safely parsable by gc");
a61af66fc99e Initial load
duke
parents:
diff changeset
97 return cm;
a61af66fc99e Initial load
duke
parents:
diff changeset
98 }
a61af66fc99e Initial load
duke
parents:
diff changeset
99
a61af66fc99e Initial load
duke
parents:
diff changeset
100 void constMethodKlass::oop_follow_contents(oop obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
101 assert (obj->is_constMethod(), "object must be constMethod");
a61af66fc99e Initial load
duke
parents:
diff changeset
102 constMethodOop cm = constMethodOop(obj);
6123
2fe087c3e814 7172967: Eliminate constMethod's _method backpointer to methodOop.
jiangli
parents: 3899
diff changeset
103 MarkSweep::mark_and_push(cm->adr_constants());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
104 MarkSweep::mark_and_push(cm->adr_stackmap_data());
a61af66fc99e Initial load
duke
parents:
diff changeset
105 // Performance tweak: We skip iterating over the klass pointer since we
a61af66fc99e Initial load
duke
parents:
diff changeset
106 // know that Universe::constMethodKlassObj never moves.
a61af66fc99e Initial load
duke
parents:
diff changeset
107 }
a61af66fc99e Initial load
duke
parents:
diff changeset
108
a61af66fc99e Initial load
duke
parents:
diff changeset
109 #ifndef SERIALGC
a61af66fc99e Initial load
duke
parents:
diff changeset
110 void constMethodKlass::oop_follow_contents(ParCompactionManager* cm,
a61af66fc99e Initial load
duke
parents:
diff changeset
111 oop obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
112 assert (obj->is_constMethod(), "object must be constMethod");
a61af66fc99e Initial load
duke
parents:
diff changeset
113 constMethodOop cm_oop = constMethodOop(obj);
6123
2fe087c3e814 7172967: Eliminate constMethod's _method backpointer to methodOop.
jiangli
parents: 3899
diff changeset
114 PSParallelCompact::mark_and_push(cm, cm_oop->adr_constants());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
115 PSParallelCompact::mark_and_push(cm, cm_oop->adr_stackmap_data());
a61af66fc99e Initial load
duke
parents:
diff changeset
116 // Performance tweak: We skip iterating over the klass pointer since we
a61af66fc99e Initial load
duke
parents:
diff changeset
117 // know that Universe::constMethodKlassObj never moves.
a61af66fc99e Initial load
duke
parents:
diff changeset
118 }
a61af66fc99e Initial load
duke
parents:
diff changeset
119 #endif // SERIALGC
a61af66fc99e Initial load
duke
parents:
diff changeset
120
a61af66fc99e Initial load
duke
parents:
diff changeset
121 int constMethodKlass::oop_oop_iterate(oop obj, OopClosure* blk) {
a61af66fc99e Initial load
duke
parents:
diff changeset
122 assert (obj->is_constMethod(), "object must be constMethod");
a61af66fc99e Initial load
duke
parents:
diff changeset
123 constMethodOop cm = constMethodOop(obj);
6123
2fe087c3e814 7172967: Eliminate constMethod's _method backpointer to methodOop.
jiangli
parents: 3899
diff changeset
124 blk->do_oop(cm->adr_constants());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
125 blk->do_oop(cm->adr_stackmap_data());
a61af66fc99e Initial load
duke
parents:
diff changeset
126 // Get size before changing pointers.
a61af66fc99e Initial load
duke
parents:
diff changeset
127 // Don't call size() or oop_size() since that is a virtual call.
a61af66fc99e Initial load
duke
parents:
diff changeset
128 int size = cm->object_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
129 return size;
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 int constMethodKlass::oop_oop_iterate_m(oop obj, OopClosure* blk, MemRegion mr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
134 assert (obj->is_constMethod(), "object must be constMethod");
a61af66fc99e Initial load
duke
parents:
diff changeset
135 constMethodOop cm = constMethodOop(obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
136 oop* adr;
6123
2fe087c3e814 7172967: Eliminate constMethod's _method backpointer to methodOop.
jiangli
parents: 3899
diff changeset
137 adr = cm->adr_constants();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
138 if (mr.contains(adr)) blk->do_oop(adr);
a61af66fc99e Initial load
duke
parents:
diff changeset
139 adr = cm->adr_stackmap_data();
a61af66fc99e Initial load
duke
parents:
diff changeset
140 if (mr.contains(adr)) blk->do_oop(adr);
a61af66fc99e Initial load
duke
parents:
diff changeset
141 // Get size before changing pointers.
a61af66fc99e Initial load
duke
parents:
diff changeset
142 // Don't call size() or oop_size() since that is a virtual call.
a61af66fc99e Initial load
duke
parents:
diff changeset
143 int size = cm->object_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
144 // Performance tweak: We skip iterating over the klass pointer since we
a61af66fc99e Initial load
duke
parents:
diff changeset
145 // know that Universe::constMethodKlassObj never moves.
a61af66fc99e Initial load
duke
parents:
diff changeset
146 return size;
a61af66fc99e Initial load
duke
parents:
diff changeset
147 }
a61af66fc99e Initial load
duke
parents:
diff changeset
148
a61af66fc99e Initial load
duke
parents:
diff changeset
149
a61af66fc99e Initial load
duke
parents:
diff changeset
150 int constMethodKlass::oop_adjust_pointers(oop obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
151 assert(obj->is_constMethod(), "should be constMethod");
a61af66fc99e Initial load
duke
parents:
diff changeset
152 constMethodOop cm = constMethodOop(obj);
6123
2fe087c3e814 7172967: Eliminate constMethod's _method backpointer to methodOop.
jiangli
parents: 3899
diff changeset
153 MarkSweep::adjust_pointer(cm->adr_constants());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
154 MarkSweep::adjust_pointer(cm->adr_stackmap_data());
a61af66fc99e Initial load
duke
parents:
diff changeset
155 // Get size before changing pointers.
a61af66fc99e Initial load
duke
parents:
diff changeset
156 // Don't call size() or oop_size() since that is a virtual call.
a61af66fc99e Initial load
duke
parents:
diff changeset
157 int size = cm->object_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
158 // Performance tweak: We skip iterating over the klass pointer since we
a61af66fc99e Initial load
duke
parents:
diff changeset
159 // know that Universe::constMethodKlassObj never moves.
a61af66fc99e Initial load
duke
parents:
diff changeset
160 return size;
a61af66fc99e Initial load
duke
parents:
diff changeset
161 }
a61af66fc99e Initial load
duke
parents:
diff changeset
162
a61af66fc99e Initial load
duke
parents:
diff changeset
163 #ifndef SERIALGC
a61af66fc99e Initial load
duke
parents:
diff changeset
164 void constMethodKlass::oop_push_contents(PSPromotionManager* pm, oop obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
165 assert(obj->is_constMethod(), "should be constMethod");
a61af66fc99e Initial load
duke
parents:
diff changeset
166 }
a61af66fc99e Initial load
duke
parents:
diff changeset
167
a61af66fc99e Initial load
duke
parents:
diff changeset
168 int constMethodKlass::oop_update_pointers(ParCompactionManager* cm, oop obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
169 assert(obj->is_constMethod(), "should be constMethod");
a61af66fc99e Initial load
duke
parents:
diff changeset
170 constMethodOop cm_oop = constMethodOop(obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
171 oop* const beg_oop = cm_oop->oop_block_beg();
a61af66fc99e Initial load
duke
parents:
diff changeset
172 oop* const end_oop = cm_oop->oop_block_end();
a61af66fc99e Initial load
duke
parents:
diff changeset
173 for (oop* cur_oop = beg_oop; cur_oop < end_oop; ++cur_oop) {
a61af66fc99e Initial load
duke
parents:
diff changeset
174 PSParallelCompact::adjust_pointer(cur_oop);
a61af66fc99e Initial load
duke
parents:
diff changeset
175 }
a61af66fc99e Initial load
duke
parents:
diff changeset
176 return cm_oop->object_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
177 }
a61af66fc99e Initial load
duke
parents:
diff changeset
178 #endif // SERIALGC
a61af66fc99e Initial load
duke
parents:
diff changeset
179
a61af66fc99e Initial load
duke
parents:
diff changeset
180 // Printing
a61af66fc99e Initial load
duke
parents:
diff changeset
181
a61af66fc99e Initial load
duke
parents:
diff changeset
182 void constMethodKlass::oop_print_on(oop obj, outputStream* st) {
a61af66fc99e Initial load
duke
parents:
diff changeset
183 ResourceMark rm;
a61af66fc99e Initial load
duke
parents:
diff changeset
184 assert(obj->is_constMethod(), "must be constMethod");
a61af66fc99e Initial load
duke
parents:
diff changeset
185 Klass::oop_print_on(obj, st);
a61af66fc99e Initial load
duke
parents:
diff changeset
186 constMethodOop m = constMethodOop(obj);
6123
2fe087c3e814 7172967: Eliminate constMethod's _method backpointer to methodOop.
jiangli
parents: 3899
diff changeset
187 st->print(" - constants: " INTPTR_FORMAT " ", (address)m->constants());
2fe087c3e814 7172967: Eliminate constMethod's _method backpointer to methodOop.
jiangli
parents: 3899
diff changeset
188 m->constants()->print_value_on(st); st->cr();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
189 if (m->has_stackmap_table()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
190 st->print(" - stackmap data: ");
a61af66fc99e Initial load
duke
parents:
diff changeset
191 m->stackmap_data()->print_value_on(st);
a61af66fc99e Initial load
duke
parents:
diff changeset
192 st->cr();
a61af66fc99e Initial load
duke
parents:
diff changeset
193 }
a61af66fc99e Initial load
duke
parents:
diff changeset
194 }
a61af66fc99e Initial load
duke
parents:
diff changeset
195
a61af66fc99e Initial load
duke
parents:
diff changeset
196 // Short version of printing constMethodOop - just print the name of the
a61af66fc99e Initial load
duke
parents:
diff changeset
197 // method it belongs to.
a61af66fc99e Initial load
duke
parents:
diff changeset
198 void constMethodKlass::oop_print_value_on(oop obj, outputStream* st) {
a61af66fc99e Initial load
duke
parents:
diff changeset
199 assert(obj->is_constMethod(), "must be constMethod");
a61af66fc99e Initial load
duke
parents:
diff changeset
200 constMethodOop m = constMethodOop(obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
201 st->print(" const part of method " );
a61af66fc99e Initial load
duke
parents:
diff changeset
202 m->method()->print_value_on(st);
a61af66fc99e Initial load
duke
parents:
diff changeset
203 }
a61af66fc99e Initial load
duke
parents:
diff changeset
204
a61af66fc99e Initial load
duke
parents:
diff changeset
205 const char* constMethodKlass::internal_name() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
206 return "{constMethod}";
a61af66fc99e Initial load
duke
parents:
diff changeset
207 }
a61af66fc99e Initial load
duke
parents:
diff changeset
208
a61af66fc99e Initial load
duke
parents:
diff changeset
209
a61af66fc99e Initial load
duke
parents:
diff changeset
210 // Verification
a61af66fc99e Initial load
duke
parents:
diff changeset
211
a61af66fc99e Initial load
duke
parents:
diff changeset
212 void constMethodKlass::oop_verify_on(oop obj, outputStream* st) {
a61af66fc99e Initial load
duke
parents:
diff changeset
213 Klass::oop_verify_on(obj, st);
a61af66fc99e Initial load
duke
parents:
diff changeset
214 guarantee(obj->is_constMethod(), "object must be constMethod");
a61af66fc99e Initial load
duke
parents:
diff changeset
215 constMethodOop m = constMethodOop(obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
216 guarantee(m->is_perm(), "should be in permspace");
a61af66fc99e Initial load
duke
parents:
diff changeset
217
a61af66fc99e Initial load
duke
parents:
diff changeset
218 // Verification can occur during oop construction before the method or
a61af66fc99e Initial load
duke
parents:
diff changeset
219 // other fields have been initialized.
a61af66fc99e Initial load
duke
parents:
diff changeset
220 if (!obj->partially_loaded()) {
6123
2fe087c3e814 7172967: Eliminate constMethod's _method backpointer to methodOop.
jiangli
parents: 3899
diff changeset
221 guarantee(m->constants()->is_perm(), "should be in permspace");
2fe087c3e814 7172967: Eliminate constMethod's _method backpointer to methodOop.
jiangli
parents: 3899
diff changeset
222 guarantee(m->constants()->is_constantPool(), "should be constant pool");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
223 typeArrayOop stackmap_data = m->stackmap_data();
a61af66fc99e Initial load
duke
parents:
diff changeset
224 guarantee(stackmap_data == NULL ||
a61af66fc99e Initial load
duke
parents:
diff changeset
225 stackmap_data->is_perm(), "should be in permspace");
a61af66fc99e Initial load
duke
parents:
diff changeset
226
a61af66fc99e Initial load
duke
parents:
diff changeset
227 address m_end = (address)((oop*) m + m->size());
a61af66fc99e Initial load
duke
parents:
diff changeset
228 address compressed_table_start = m->code_end();
a61af66fc99e Initial load
duke
parents:
diff changeset
229 guarantee(compressed_table_start <= m_end, "invalid method layout");
a61af66fc99e Initial load
duke
parents:
diff changeset
230 address compressed_table_end = compressed_table_start;
a61af66fc99e Initial load
duke
parents:
diff changeset
231 // Verify line number table
a61af66fc99e Initial load
duke
parents:
diff changeset
232 if (m->has_linenumber_table()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
233 CompressedLineNumberReadStream stream(m->compressed_linenumber_table());
a61af66fc99e Initial load
duke
parents:
diff changeset
234 while (stream.read_pair()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
235 guarantee(stream.bci() >= 0 && stream.bci() <= m->code_size(), "invalid bci in line number table");
a61af66fc99e Initial load
duke
parents:
diff changeset
236 }
a61af66fc99e Initial load
duke
parents:
diff changeset
237 compressed_table_end += stream.position();
a61af66fc99e Initial load
duke
parents:
diff changeset
238 }
a61af66fc99e Initial load
duke
parents:
diff changeset
239 guarantee(compressed_table_end <= m_end, "invalid method layout");
6213
8150fa46d2ed 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 6123
diff changeset
240 // Verify checked exceptions, exception table and local variable tables
0
a61af66fc99e Initial load
duke
parents:
diff changeset
241 if (m->has_checked_exceptions()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
242 u2* addr = m->checked_exceptions_length_addr();
a61af66fc99e Initial load
duke
parents:
diff changeset
243 guarantee(*addr > 0 && (address) addr >= compressed_table_end && (address) addr < m_end, "invalid method layout");
a61af66fc99e Initial load
duke
parents:
diff changeset
244 }
6213
8150fa46d2ed 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 6123
diff changeset
245 if (m->has_exception_handler()) {
8150fa46d2ed 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 6123
diff changeset
246 u2* addr = m->exception_table_length_addr();
8150fa46d2ed 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 6123
diff changeset
247 guarantee(*addr > 0 && (address) addr >= compressed_table_end && (address) addr < m_end, "invalid method layout");
8150fa46d2ed 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 6123
diff changeset
248 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
249 if (m->has_localvariable_table()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
250 u2* addr = m->localvariable_table_length_addr();
a61af66fc99e Initial load
duke
parents:
diff changeset
251 guarantee(*addr > 0 && (address) addr >= compressed_table_end && (address) addr < m_end, "invalid method layout");
a61af66fc99e Initial load
duke
parents:
diff changeset
252 }
a61af66fc99e Initial load
duke
parents:
diff changeset
253 // Check compressed_table_end relative to uncompressed_table_start
a61af66fc99e Initial load
duke
parents:
diff changeset
254 u2* uncompressed_table_start;
a61af66fc99e Initial load
duke
parents:
diff changeset
255 if (m->has_localvariable_table()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
256 uncompressed_table_start = (u2*) m->localvariable_table_start();
6213
8150fa46d2ed 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 6123
diff changeset
257 } else if (m->has_exception_handler()) {
8150fa46d2ed 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 6123
diff changeset
258 uncompressed_table_start = (u2*) m->exception_table_start();
8150fa46d2ed 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 6123
diff changeset
259 } else if (m->has_checked_exceptions()) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
260 uncompressed_table_start = (u2*) m->checked_exceptions_start();
6213
8150fa46d2ed 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 6123
diff changeset
261 } else {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
262 uncompressed_table_start = (u2*) m_end;
a61af66fc99e Initial load
duke
parents:
diff changeset
263 }
a61af66fc99e Initial load
duke
parents:
diff changeset
264 int gap = (intptr_t) uncompressed_table_start - (intptr_t) compressed_table_end;
a61af66fc99e Initial load
duke
parents:
diff changeset
265 int max_gap = align_object_size(1)*BytesPerWord;
a61af66fc99e Initial load
duke
parents:
diff changeset
266 guarantee(gap >= 0 && gap < max_gap, "invalid method layout");
a61af66fc99e Initial load
duke
parents:
diff changeset
267 }
a61af66fc99e Initial load
duke
parents:
diff changeset
268 }
a61af66fc99e Initial load
duke
parents:
diff changeset
269
a61af66fc99e Initial load
duke
parents:
diff changeset
270 bool constMethodKlass::oop_partially_loaded(oop obj) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
271 assert(obj->is_constMethod(), "object must be klass");
a61af66fc99e Initial load
duke
parents:
diff changeset
272 constMethodOop m = constMethodOop(obj);
6213
8150fa46d2ed 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 6123
diff changeset
273 // check whether stackmap_data points to self (flag for partially loaded)
8150fa46d2ed 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 6123
diff changeset
274 return m->stackmap_data() == (typeArrayOop)obj;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
275 }
a61af66fc99e Initial load
duke
parents:
diff changeset
276
a61af66fc99e Initial load
duke
parents:
diff changeset
277
a61af66fc99e Initial load
duke
parents:
diff changeset
278 // The exception_table is the last field set when loading an object.
a61af66fc99e Initial load
duke
parents:
diff changeset
279 void constMethodKlass::oop_set_partially_loaded(oop obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
280 assert(obj->is_constMethod(), "object must be klass");
a61af66fc99e Initial load
duke
parents:
diff changeset
281 constMethodOop m = constMethodOop(obj);
6213
8150fa46d2ed 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 6123
diff changeset
282 // Temporarily set stackmap_data to point to self
8150fa46d2ed 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 6123
diff changeset
283 m->set_stackmap_data((typeArrayOop)obj);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
284 }