annotate src/share/vm/oops/constMethod.cpp @ 6725:da91efe96a93

6964458: Reimplement class meta-data storage to use native memory Summary: Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland Contributed-by: jmasa <jon.masamitsu@oracle.com>, stefank <stefan.karlsson@oracle.com>, mgerdin <mikael.gerdin@oracle.com>, never <tom.rodriguez@oracle.com>
author coleenp
date Sat, 01 Sep 2012 13:25:18 -0400
parents src/share/vm/oops/constMethodOop.cpp@8150fa46d2ed
children 4735d2c84362
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: 1972
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: 0
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
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: 0
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: 6213
diff changeset
26 #include "interpreter/interpreter.hpp"
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
27 #include "memory/gcLocker.hpp"
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
28 #include "memory/metadataFactory.hpp"
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
29 #include "oops/constMethod.hpp"
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
30 #include "oops/method.hpp"
0
a61af66fc99e Initial load
duke
parents:
diff changeset
31
a61af66fc99e Initial load
duke
parents:
diff changeset
32 // Static initialization
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
33 const u2 ConstMethod::MAX_IDNUM = 0xFFFE;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
34 const u2 ConstMethod::UNSET_IDNUM = 0xFFFF;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
35
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
36 ConstMethod* ConstMethod::allocate(ClassLoaderData* loader_data,
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
37 int byte_code_size,
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
38 int compressed_line_number_size,
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
39 int localvariable_table_length,
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
40 int exception_table_length,
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
41 int checked_exceptions_length,
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
42 TRAPS) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
43 int size = ConstMethod::size(byte_code_size,
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
44 compressed_line_number_size,
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
45 localvariable_table_length,
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
46 exception_table_length,
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
47 checked_exceptions_length);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
48 return new (loader_data, size, true, THREAD) ConstMethod(
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
49 byte_code_size, compressed_line_number_size,
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
50 localvariable_table_length, exception_table_length,
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
51 checked_exceptions_length, size);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
52 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
53
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
54 ConstMethod::ConstMethod(int byte_code_size,
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
55 int compressed_line_number_size,
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
56 int localvariable_table_length,
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
57 int exception_table_length,
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
58 int checked_exceptions_length,
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
59 int size) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
60
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
61 No_Safepoint_Verifier no_safepoint;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
62 set_interpreter_kind(Interpreter::invalid);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
63 init_fingerprint();
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
64 set_constants(NULL);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
65 set_stackmap_data(NULL);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
66 set_code_size(byte_code_size);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
67 set_constMethod_size(size);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
68 set_inlined_tables_length(checked_exceptions_length,
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
69 compressed_line_number_size,
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
70 localvariable_table_length,
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
71 exception_table_length);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
72 assert(this->size() == size, "wrong size for object");
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
73 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
74
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
75
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
76 // Deallocate metadata fields associated with ConstMethod*
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
77 void ConstMethod::deallocate_contents(ClassLoaderData* loader_data) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
78 set_interpreter_kind(Interpreter::invalid);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
79 if (stackmap_data() != NULL) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
80 MetadataFactory::free_array<u1>(loader_data, stackmap_data());
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
81 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
82 set_stackmap_data(NULL);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
83 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
84
a61af66fc99e Initial load
duke
parents:
diff changeset
85 // How big must this constMethodObject be?
a61af66fc99e Initial load
duke
parents:
diff changeset
86
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
87 int ConstMethod::size(int code_size,
0
a61af66fc99e Initial load
duke
parents:
diff changeset
88 int compressed_line_number_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
89 int local_variable_table_length,
6213
8150fa46d2ed 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 6123
diff changeset
90 int exception_table_length,
0
a61af66fc99e Initial load
duke
parents:
diff changeset
91 int checked_exceptions_length) {
a61af66fc99e Initial load
duke
parents:
diff changeset
92 int extra_bytes = code_size;
a61af66fc99e Initial load
duke
parents:
diff changeset
93 if (compressed_line_number_size > 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
94 extra_bytes += compressed_line_number_size;
a61af66fc99e Initial load
duke
parents:
diff changeset
95 }
a61af66fc99e Initial load
duke
parents:
diff changeset
96 if (checked_exceptions_length > 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
97 extra_bytes += sizeof(u2);
a61af66fc99e Initial load
duke
parents:
diff changeset
98 extra_bytes += checked_exceptions_length * sizeof(CheckedExceptionElement);
a61af66fc99e Initial load
duke
parents:
diff changeset
99 }
a61af66fc99e Initial load
duke
parents:
diff changeset
100 if (local_variable_table_length > 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
101 extra_bytes += sizeof(u2);
a61af66fc99e Initial load
duke
parents:
diff changeset
102 extra_bytes +=
a61af66fc99e Initial load
duke
parents:
diff changeset
103 local_variable_table_length * sizeof(LocalVariableTableElement);
a61af66fc99e Initial load
duke
parents:
diff changeset
104 }
6213
8150fa46d2ed 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 6123
diff changeset
105 if (exception_table_length > 0) {
8150fa46d2ed 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 6123
diff changeset
106 extra_bytes += sizeof(u2);
8150fa46d2ed 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 6123
diff changeset
107 extra_bytes += exception_table_length * sizeof(ExceptionTableElement);
8150fa46d2ed 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 6123
diff changeset
108 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
109 int extra_words = align_size_up(extra_bytes, BytesPerWord) / BytesPerWord;
a61af66fc99e Initial load
duke
parents:
diff changeset
110 return align_object_size(header_size() + extra_words);
a61af66fc99e Initial load
duke
parents:
diff changeset
111 }
a61af66fc99e Initial load
duke
parents:
diff changeset
112
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
113 Method* ConstMethod::method() const {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
114 return InstanceKlass::cast(_constants->pool_holder())->method_with_idnum(
6123
2fe087c3e814 7172967: Eliminate constMethod's _method backpointer to methodOop.
jiangli
parents: 1972
diff changeset
115 _method_idnum);
2fe087c3e814 7172967: Eliminate constMethod's _method backpointer to methodOop.
jiangli
parents: 1972
diff changeset
116 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
117
a61af66fc99e Initial load
duke
parents:
diff changeset
118 // linenumber table - note that length is unknown until decompression,
a61af66fc99e Initial load
duke
parents:
diff changeset
119 // see class CompressedLineNumberReadStream.
a61af66fc99e Initial load
duke
parents:
diff changeset
120
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
121 u_char* ConstMethod::compressed_linenumber_table() const {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
122 // Located immediately following the bytecodes.
a61af66fc99e Initial load
duke
parents:
diff changeset
123 assert(has_linenumber_table(), "called only if table is present");
a61af66fc99e Initial load
duke
parents:
diff changeset
124 return code_end();
a61af66fc99e Initial load
duke
parents:
diff changeset
125 }
a61af66fc99e Initial load
duke
parents:
diff changeset
126
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
127 u2* ConstMethod::checked_exceptions_length_addr() const {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
128 // Located at the end of the constMethod.
a61af66fc99e Initial load
duke
parents:
diff changeset
129 assert(has_checked_exceptions(), "called only if table is present");
a61af66fc99e Initial load
duke
parents:
diff changeset
130 return last_u2_element();
a61af66fc99e Initial load
duke
parents:
diff changeset
131 }
a61af66fc99e Initial load
duke
parents:
diff changeset
132
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
133 u2* ConstMethod::exception_table_length_addr() const {
6213
8150fa46d2ed 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 6123
diff changeset
134 assert(has_exception_handler(), "called only if table is present");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
135 if (has_checked_exceptions()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
136 // If checked_exception present, locate immediately before them.
a61af66fc99e Initial load
duke
parents:
diff changeset
137 return (u2*) checked_exceptions_start() - 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
138 } else {
6213
8150fa46d2ed 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 6123
diff changeset
139 // Else, the exception table is at the end of the constMethod.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
140 return last_u2_element();
a61af66fc99e Initial load
duke
parents:
diff changeset
141 }
a61af66fc99e Initial load
duke
parents:
diff changeset
142 }
a61af66fc99e Initial load
duke
parents:
diff changeset
143
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
144 u2* ConstMethod::localvariable_table_length_addr() const {
6213
8150fa46d2ed 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 6123
diff changeset
145 assert(has_localvariable_table(), "called only if table is present");
8150fa46d2ed 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 6123
diff changeset
146 if (has_exception_handler()) {
8150fa46d2ed 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 6123
diff changeset
147 // If exception_table present, locate immediately before them.
8150fa46d2ed 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 6123
diff changeset
148 return (u2*) exception_table_start() - 1;
8150fa46d2ed 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 6123
diff changeset
149 } else {
8150fa46d2ed 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 6123
diff changeset
150 if (has_checked_exceptions()) {
8150fa46d2ed 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 6123
diff changeset
151 // If checked_exception present, locate immediately before them.
8150fa46d2ed 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 6123
diff changeset
152 return (u2*) checked_exceptions_start() - 1;
8150fa46d2ed 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 6123
diff changeset
153 } else {
8150fa46d2ed 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 6123
diff changeset
154 // Else, the linenumber table is at the end of the constMethod.
8150fa46d2ed 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 6123
diff changeset
155 return last_u2_element();
8150fa46d2ed 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 6123
diff changeset
156 }
8150fa46d2ed 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 6123
diff changeset
157 }
8150fa46d2ed 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 6123
diff changeset
158 }
8150fa46d2ed 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 6123
diff changeset
159
0
a61af66fc99e Initial load
duke
parents:
diff changeset
160
a61af66fc99e Initial load
duke
parents:
diff changeset
161 // Update the flags to indicate the presence of these optional fields.
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
162 void ConstMethod::set_inlined_tables_length(
0
a61af66fc99e Initial load
duke
parents:
diff changeset
163 int checked_exceptions_len,
a61af66fc99e Initial load
duke
parents:
diff changeset
164 int compressed_line_number_size,
6213
8150fa46d2ed 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 6123
diff changeset
165 int localvariable_table_len,
8150fa46d2ed 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 6123
diff changeset
166 int exception_table_len) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
167 // Must be done in the order below, otherwise length_addr accessors
a61af66fc99e Initial load
duke
parents:
diff changeset
168 // will not work. Only set bit in header if length is positive.
a61af66fc99e Initial load
duke
parents:
diff changeset
169 assert(_flags == 0, "Error");
a61af66fc99e Initial load
duke
parents:
diff changeset
170 if (compressed_line_number_size > 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
171 _flags |= _has_linenumber_table;
a61af66fc99e Initial load
duke
parents:
diff changeset
172 }
a61af66fc99e Initial load
duke
parents:
diff changeset
173 if (checked_exceptions_len > 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
174 _flags |= _has_checked_exceptions;
a61af66fc99e Initial load
duke
parents:
diff changeset
175 *(checked_exceptions_length_addr()) = checked_exceptions_len;
a61af66fc99e Initial load
duke
parents:
diff changeset
176 }
6213
8150fa46d2ed 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 6123
diff changeset
177 if (exception_table_len > 0) {
8150fa46d2ed 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 6123
diff changeset
178 _flags |= _has_exception_table;
8150fa46d2ed 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 6123
diff changeset
179 *(exception_table_length_addr()) = exception_table_len;
8150fa46d2ed 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 6123
diff changeset
180 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
181 if (localvariable_table_len > 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
182 _flags |= _has_localvariable_table;
a61af66fc99e Initial load
duke
parents:
diff changeset
183 *(localvariable_table_length_addr()) = localvariable_table_len;
a61af66fc99e Initial load
duke
parents:
diff changeset
184 }
a61af66fc99e Initial load
duke
parents:
diff changeset
185 }
a61af66fc99e Initial load
duke
parents:
diff changeset
186
a61af66fc99e Initial load
duke
parents:
diff changeset
187
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
188 int ConstMethod::checked_exceptions_length() const {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
189 return has_checked_exceptions() ? *(checked_exceptions_length_addr()) : 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
190 }
a61af66fc99e Initial load
duke
parents:
diff changeset
191
a61af66fc99e Initial load
duke
parents:
diff changeset
192
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
193 CheckedExceptionElement* ConstMethod::checked_exceptions_start() const {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
194 u2* addr = checked_exceptions_length_addr();
a61af66fc99e Initial load
duke
parents:
diff changeset
195 u2 length = *addr;
a61af66fc99e Initial load
duke
parents:
diff changeset
196 assert(length > 0, "should only be called if table is present");
a61af66fc99e Initial load
duke
parents:
diff changeset
197 addr -= length * sizeof(CheckedExceptionElement) / sizeof(u2);
a61af66fc99e Initial load
duke
parents:
diff changeset
198 return (CheckedExceptionElement*) addr;
a61af66fc99e Initial load
duke
parents:
diff changeset
199 }
a61af66fc99e Initial load
duke
parents:
diff changeset
200
a61af66fc99e Initial load
duke
parents:
diff changeset
201
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
202 int ConstMethod::localvariable_table_length() const {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
203 return has_localvariable_table() ? *(localvariable_table_length_addr()) : 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
204 }
a61af66fc99e Initial load
duke
parents:
diff changeset
205
a61af66fc99e Initial load
duke
parents:
diff changeset
206
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
207 LocalVariableTableElement* ConstMethod::localvariable_table_start() const {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
208 u2* addr = localvariable_table_length_addr();
a61af66fc99e Initial load
duke
parents:
diff changeset
209 u2 length = *addr;
a61af66fc99e Initial load
duke
parents:
diff changeset
210 assert(length > 0, "should only be called if table is present");
a61af66fc99e Initial load
duke
parents:
diff changeset
211 addr -= length * sizeof(LocalVariableTableElement) / sizeof(u2);
a61af66fc99e Initial load
duke
parents:
diff changeset
212 return (LocalVariableTableElement*) addr;
a61af66fc99e Initial load
duke
parents:
diff changeset
213 }
6213
8150fa46d2ed 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 6123
diff changeset
214
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
215 int ConstMethod::exception_table_length() const {
6213
8150fa46d2ed 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 6123
diff changeset
216 return has_exception_handler() ? *(exception_table_length_addr()) : 0;
8150fa46d2ed 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 6123
diff changeset
217 }
8150fa46d2ed 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 6123
diff changeset
218
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
219 ExceptionTableElement* ConstMethod::exception_table_start() const {
6213
8150fa46d2ed 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 6123
diff changeset
220 u2* addr = exception_table_length_addr();
8150fa46d2ed 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 6123
diff changeset
221 u2 length = *addr;
8150fa46d2ed 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 6123
diff changeset
222 assert(length > 0, "should only be called if table is present");
8150fa46d2ed 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 6123
diff changeset
223 addr -= length * sizeof(ExceptionTableElement) / sizeof(u2);
8150fa46d2ed 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 6123
diff changeset
224 return (ExceptionTableElement*)addr;
8150fa46d2ed 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 6123
diff changeset
225 }
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
226
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
227
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
228 // Printing
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
229
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
230 void ConstMethod::print_on(outputStream* st) const {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
231 ResourceMark rm;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
232 assert(is_constMethod(), "must be constMethod");
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
233 st->print_cr(internal_name());
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
234 st->print(" - method: " INTPTR_FORMAT " ", (address)method());
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
235 method()->print_value_on(st); st->cr();
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
236 if (has_stackmap_table()) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
237 st->print(" - stackmap data: ");
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
238 stackmap_data()->print_value_on(st);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
239 st->cr();
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
240 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
241 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
242
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
243 // Short version of printing ConstMethod* - just print the name of the
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
244 // method it belongs to.
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
245 void ConstMethod::print_value_on(outputStream* st) const {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
246 assert(is_constMethod(), "must be constMethod");
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
247 st->print(" const part of method " );
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
248 method()->print_value_on(st);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
249 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
250
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
251
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
252 // Verification
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
253
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
254 void ConstMethod::verify_on(outputStream* st) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
255 guarantee(is_constMethod(), "object must be constMethod");
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
256 guarantee(is_metadata(), err_msg("Should be metadata " PTR_FORMAT, this));
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
257
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
258 // Verification can occur during oop construction before the method or
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
259 // other fields have been initialized.
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
260 guarantee(is_metadata(), err_msg("Should be metadata " PTR_FORMAT, this));
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
261 guarantee(method()->is_method(), "should be method");
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
262
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
263 address m_end = (address)((oop*) this + size());
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
264 address compressed_table_start = code_end();
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
265 guarantee(compressed_table_start <= m_end, "invalid method layout");
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
266 address compressed_table_end = compressed_table_start;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
267 // Verify line number table
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
268 if (has_linenumber_table()) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
269 CompressedLineNumberReadStream stream(compressed_linenumber_table());
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
270 while (stream.read_pair()) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
271 guarantee(stream.bci() >= 0 && stream.bci() <= code_size(), "invalid bci in line number table");
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
272 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
273 compressed_table_end += stream.position();
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
274 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
275 guarantee(compressed_table_end <= m_end, "invalid method layout");
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
276 // Verify checked exceptions, exception table and local variable tables
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
277 if (has_checked_exceptions()) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
278 u2* addr = checked_exceptions_length_addr();
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
279 guarantee(*addr > 0 && (address) addr >= compressed_table_end && (address) addr < m_end, "invalid method layout");
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
280 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
281 if (has_exception_handler()) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
282 u2* addr = exception_table_length_addr();
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
283 guarantee(*addr > 0 && (address) addr >= compressed_table_end && (address) addr < m_end, "invalid method layout");
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
284 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
285 if (has_localvariable_table()) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
286 u2* addr = localvariable_table_length_addr();
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
287 guarantee(*addr > 0 && (address) addr >= compressed_table_end && (address) addr < m_end, "invalid method layout");
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
288 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
289 // Check compressed_table_end relative to uncompressed_table_start
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
290 u2* uncompressed_table_start;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
291 if (has_localvariable_table()) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
292 uncompressed_table_start = (u2*) localvariable_table_start();
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
293 } else if (has_exception_handler()) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
294 uncompressed_table_start = (u2*) exception_table_start();
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
295 } else if (has_checked_exceptions()) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
296 uncompressed_table_start = (u2*) checked_exceptions_start();
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
297 } else {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
298 uncompressed_table_start = (u2*) m_end;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
299 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
300 int gap = (intptr_t) uncompressed_table_start - (intptr_t) compressed_table_end;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
301 int max_gap = align_object_size(1)*BytesPerWord;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
302 guarantee(gap >= 0 && gap < max_gap, "invalid method layout");
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6213
diff changeset
303 }