annotate src/share/vm/oops/constMethodOop.cpp @ 6213:8150fa46d2ed

7178145: Change constMethodOop::_exception_table to optionally inlined u2 table. Summary: Change constMethodOop::_exception_table to optionally inlined u2 table. Reviewed-by: bdelsart, coleenp, kamg
author jiangli
date Tue, 26 Jun 2012 19:08:44 -0400
parents 2fe087c3e814
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: 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"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
26 #include "oops/constMethodOop.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
27 #include "oops/methodOop.hpp"
0
a61af66fc99e Initial load
duke
parents:
diff changeset
28
a61af66fc99e Initial load
duke
parents:
diff changeset
29 // Static initialization
a61af66fc99e Initial load
duke
parents:
diff changeset
30 const u2 constMethodOopDesc::MAX_IDNUM = 0xFFFE;
a61af66fc99e Initial load
duke
parents:
diff changeset
31 const u2 constMethodOopDesc::UNSET_IDNUM = 0xFFFF;
a61af66fc99e Initial load
duke
parents:
diff changeset
32
a61af66fc99e Initial load
duke
parents:
diff changeset
33 // How big must this constMethodObject be?
a61af66fc99e Initial load
duke
parents:
diff changeset
34
a61af66fc99e Initial load
duke
parents:
diff changeset
35 int constMethodOopDesc::object_size(int code_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
36 int compressed_line_number_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
37 int local_variable_table_length,
6213
8150fa46d2ed 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 6123
diff changeset
38 int exception_table_length,
0
a61af66fc99e Initial load
duke
parents:
diff changeset
39 int checked_exceptions_length) {
a61af66fc99e Initial load
duke
parents:
diff changeset
40 int extra_bytes = code_size;
a61af66fc99e Initial load
duke
parents:
diff changeset
41 if (compressed_line_number_size > 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
42 extra_bytes += compressed_line_number_size;
a61af66fc99e Initial load
duke
parents:
diff changeset
43 }
a61af66fc99e Initial load
duke
parents:
diff changeset
44 if (checked_exceptions_length > 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
45 extra_bytes += sizeof(u2);
a61af66fc99e Initial load
duke
parents:
diff changeset
46 extra_bytes += checked_exceptions_length * sizeof(CheckedExceptionElement);
a61af66fc99e Initial load
duke
parents:
diff changeset
47 }
a61af66fc99e Initial load
duke
parents:
diff changeset
48 if (local_variable_table_length > 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
49 extra_bytes += sizeof(u2);
a61af66fc99e Initial load
duke
parents:
diff changeset
50 extra_bytes +=
a61af66fc99e Initial load
duke
parents:
diff changeset
51 local_variable_table_length * sizeof(LocalVariableTableElement);
a61af66fc99e Initial load
duke
parents:
diff changeset
52 }
6213
8150fa46d2ed 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 6123
diff changeset
53 if (exception_table_length > 0) {
8150fa46d2ed 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 6123
diff changeset
54 extra_bytes += sizeof(u2);
8150fa46d2ed 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 6123
diff changeset
55 extra_bytes += exception_table_length * sizeof(ExceptionTableElement);
8150fa46d2ed 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 6123
diff changeset
56 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
57 int extra_words = align_size_up(extra_bytes, BytesPerWord) / BytesPerWord;
a61af66fc99e Initial load
duke
parents:
diff changeset
58 return align_object_size(header_size() + extra_words);
a61af66fc99e Initial load
duke
parents:
diff changeset
59 }
a61af66fc99e Initial load
duke
parents:
diff changeset
60
6123
2fe087c3e814 7172967: Eliminate constMethod's _method backpointer to methodOop.
jiangli
parents: 1972
diff changeset
61 methodOop constMethodOopDesc::method() const {
2fe087c3e814 7172967: Eliminate constMethod's _method backpointer to methodOop.
jiangli
parents: 1972
diff changeset
62 return instanceKlass::cast(_constants->pool_holder())->method_with_idnum(
2fe087c3e814 7172967: Eliminate constMethod's _method backpointer to methodOop.
jiangli
parents: 1972
diff changeset
63 _method_idnum);
2fe087c3e814 7172967: Eliminate constMethod's _method backpointer to methodOop.
jiangli
parents: 1972
diff changeset
64 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
65
a61af66fc99e Initial load
duke
parents:
diff changeset
66 // linenumber table - note that length is unknown until decompression,
a61af66fc99e Initial load
duke
parents:
diff changeset
67 // see class CompressedLineNumberReadStream.
a61af66fc99e Initial load
duke
parents:
diff changeset
68
a61af66fc99e Initial load
duke
parents:
diff changeset
69 u_char* constMethodOopDesc::compressed_linenumber_table() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
70 // Located immediately following the bytecodes.
a61af66fc99e Initial load
duke
parents:
diff changeset
71 assert(has_linenumber_table(), "called only if table is present");
a61af66fc99e Initial load
duke
parents:
diff changeset
72 return code_end();
a61af66fc99e Initial load
duke
parents:
diff changeset
73 }
a61af66fc99e Initial load
duke
parents:
diff changeset
74
a61af66fc99e Initial load
duke
parents:
diff changeset
75 u2* constMethodOopDesc::checked_exceptions_length_addr() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
76 // Located at the end of the constMethod.
a61af66fc99e Initial load
duke
parents:
diff changeset
77 assert(has_checked_exceptions(), "called only if table is present");
a61af66fc99e Initial load
duke
parents:
diff changeset
78 return last_u2_element();
a61af66fc99e Initial load
duke
parents:
diff changeset
79 }
a61af66fc99e Initial load
duke
parents:
diff changeset
80
6213
8150fa46d2ed 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 6123
diff changeset
81 u2* constMethodOopDesc::exception_table_length_addr() const {
8150fa46d2ed 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 6123
diff changeset
82 assert(has_exception_handler(), "called only if table is present");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
83 if (has_checked_exceptions()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
84 // If checked_exception present, locate immediately before them.
a61af66fc99e Initial load
duke
parents:
diff changeset
85 return (u2*) checked_exceptions_start() - 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
86 } else {
6213
8150fa46d2ed 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 6123
diff changeset
87 // Else, the exception table is at the end of the constMethod.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
88 return last_u2_element();
a61af66fc99e Initial load
duke
parents:
diff changeset
89 }
a61af66fc99e Initial load
duke
parents:
diff changeset
90 }
a61af66fc99e Initial load
duke
parents:
diff changeset
91
6213
8150fa46d2ed 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 6123
diff changeset
92 u2* constMethodOopDesc::localvariable_table_length_addr() const {
8150fa46d2ed 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 6123
diff changeset
93 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
94 if (has_exception_handler()) {
8150fa46d2ed 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 6123
diff changeset
95 // If exception_table present, locate immediately before them.
8150fa46d2ed 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 6123
diff changeset
96 return (u2*) exception_table_start() - 1;
8150fa46d2ed 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 6123
diff changeset
97 } else {
8150fa46d2ed 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 6123
diff changeset
98 if (has_checked_exceptions()) {
8150fa46d2ed 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 6123
diff changeset
99 // If checked_exception present, locate immediately before them.
8150fa46d2ed 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 6123
diff changeset
100 return (u2*) checked_exceptions_start() - 1;
8150fa46d2ed 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 6123
diff changeset
101 } else {
8150fa46d2ed 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 6123
diff changeset
102 // 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
103 return last_u2_element();
8150fa46d2ed 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 6123
diff changeset
104 }
8150fa46d2ed 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 6123
diff changeset
105 }
8150fa46d2ed 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 6123
diff changeset
106 }
8150fa46d2ed 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 6123
diff changeset
107
0
a61af66fc99e Initial load
duke
parents:
diff changeset
108
a61af66fc99e Initial load
duke
parents:
diff changeset
109 // Update the flags to indicate the presence of these optional fields.
a61af66fc99e Initial load
duke
parents:
diff changeset
110 void constMethodOopDesc::set_inlined_tables_length(
a61af66fc99e Initial load
duke
parents:
diff changeset
111 int checked_exceptions_len,
a61af66fc99e Initial load
duke
parents:
diff changeset
112 int compressed_line_number_size,
6213
8150fa46d2ed 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 6123
diff changeset
113 int localvariable_table_len,
8150fa46d2ed 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 6123
diff changeset
114 int exception_table_len) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
115 // Must be done in the order below, otherwise length_addr accessors
a61af66fc99e Initial load
duke
parents:
diff changeset
116 // will not work. Only set bit in header if length is positive.
a61af66fc99e Initial load
duke
parents:
diff changeset
117 assert(_flags == 0, "Error");
a61af66fc99e Initial load
duke
parents:
diff changeset
118 if (compressed_line_number_size > 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
119 _flags |= _has_linenumber_table;
a61af66fc99e Initial load
duke
parents:
diff changeset
120 }
a61af66fc99e Initial load
duke
parents:
diff changeset
121 if (checked_exceptions_len > 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
122 _flags |= _has_checked_exceptions;
a61af66fc99e Initial load
duke
parents:
diff changeset
123 *(checked_exceptions_length_addr()) = checked_exceptions_len;
a61af66fc99e Initial load
duke
parents:
diff changeset
124 }
6213
8150fa46d2ed 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 6123
diff changeset
125 if (exception_table_len > 0) {
8150fa46d2ed 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 6123
diff changeset
126 _flags |= _has_exception_table;
8150fa46d2ed 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 6123
diff changeset
127 *(exception_table_length_addr()) = exception_table_len;
8150fa46d2ed 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 6123
diff changeset
128 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
129 if (localvariable_table_len > 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
130 _flags |= _has_localvariable_table;
a61af66fc99e Initial load
duke
parents:
diff changeset
131 *(localvariable_table_length_addr()) = localvariable_table_len;
a61af66fc99e Initial load
duke
parents:
diff changeset
132 }
a61af66fc99e Initial load
duke
parents:
diff changeset
133 }
a61af66fc99e Initial load
duke
parents:
diff changeset
134
a61af66fc99e Initial load
duke
parents:
diff changeset
135
a61af66fc99e Initial load
duke
parents:
diff changeset
136 int constMethodOopDesc::checked_exceptions_length() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
137 return has_checked_exceptions() ? *(checked_exceptions_length_addr()) : 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
138 }
a61af66fc99e Initial load
duke
parents:
diff changeset
139
a61af66fc99e Initial load
duke
parents:
diff changeset
140
a61af66fc99e Initial load
duke
parents:
diff changeset
141 CheckedExceptionElement* constMethodOopDesc::checked_exceptions_start() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
142 u2* addr = checked_exceptions_length_addr();
a61af66fc99e Initial load
duke
parents:
diff changeset
143 u2 length = *addr;
a61af66fc99e Initial load
duke
parents:
diff changeset
144 assert(length > 0, "should only be called if table is present");
a61af66fc99e Initial load
duke
parents:
diff changeset
145 addr -= length * sizeof(CheckedExceptionElement) / sizeof(u2);
a61af66fc99e Initial load
duke
parents:
diff changeset
146 return (CheckedExceptionElement*) addr;
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 constMethodOopDesc::localvariable_table_length() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
151 return has_localvariable_table() ? *(localvariable_table_length_addr()) : 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
152 }
a61af66fc99e Initial load
duke
parents:
diff changeset
153
a61af66fc99e Initial load
duke
parents:
diff changeset
154
a61af66fc99e Initial load
duke
parents:
diff changeset
155 LocalVariableTableElement* constMethodOopDesc::localvariable_table_start() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
156 u2* addr = localvariable_table_length_addr();
a61af66fc99e Initial load
duke
parents:
diff changeset
157 u2 length = *addr;
a61af66fc99e Initial load
duke
parents:
diff changeset
158 assert(length > 0, "should only be called if table is present");
a61af66fc99e Initial load
duke
parents:
diff changeset
159 addr -= length * sizeof(LocalVariableTableElement) / sizeof(u2);
a61af66fc99e Initial load
duke
parents:
diff changeset
160 return (LocalVariableTableElement*) addr;
a61af66fc99e Initial load
duke
parents:
diff changeset
161 }
6213
8150fa46d2ed 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 6123
diff changeset
162
8150fa46d2ed 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 6123
diff changeset
163 int constMethodOopDesc::exception_table_length() const {
8150fa46d2ed 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 6123
diff changeset
164 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
165 }
8150fa46d2ed 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 6123
diff changeset
166
8150fa46d2ed 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 6123
diff changeset
167 ExceptionTableElement* constMethodOopDesc::exception_table_start() const {
8150fa46d2ed 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 6123
diff changeset
168 u2* addr = exception_table_length_addr();
8150fa46d2ed 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 6123
diff changeset
169 u2 length = *addr;
8150fa46d2ed 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 6123
diff changeset
170 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
171 addr -= length * sizeof(ExceptionTableElement) / sizeof(u2);
8150fa46d2ed 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 6123
diff changeset
172 return (ExceptionTableElement*)addr;
8150fa46d2ed 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 6123
diff changeset
173 }