comparison src/share/vm/oops/constMethod.cpp @ 7183:b2dbd323c668

8003848: Make ConstMethod::generic_signature_index optional and move Method::_max_stack to ConstMethod. Summary: Make ConstMethod::generic_signature_index optional and move Method::_max_stack to ConstMethod. Reviewed-by: bdelsart, sspitsyn, coleenp
author jiangli
date Tue, 27 Nov 2012 17:03:56 -0500
parents 18fb7da42534
children ade95d680b42
comparison
equal deleted inserted replaced
7165:e1d42ba865de 7183:b2dbd323c668
37 int byte_code_size, 37 int byte_code_size,
38 int compressed_line_number_size, 38 int compressed_line_number_size,
39 int localvariable_table_length, 39 int localvariable_table_length,
40 int exception_table_length, 40 int exception_table_length,
41 int checked_exceptions_length, 41 int checked_exceptions_length,
42 u2 generic_signature_index,
42 MethodType method_type, 43 MethodType method_type,
43 TRAPS) { 44 TRAPS) {
44 int size = ConstMethod::size(byte_code_size, 45 int size = ConstMethod::size(byte_code_size,
45 compressed_line_number_size, 46 compressed_line_number_size,
46 localvariable_table_length, 47 localvariable_table_length,
47 exception_table_length, 48 exception_table_length,
48 checked_exceptions_length); 49 checked_exceptions_length,
50 generic_signature_index);
49 return new (loader_data, size, true, THREAD) ConstMethod( 51 return new (loader_data, size, true, THREAD) ConstMethod(
50 byte_code_size, compressed_line_number_size, localvariable_table_length, 52 byte_code_size, compressed_line_number_size, localvariable_table_length,
51 exception_table_length, checked_exceptions_length, method_type, size); 53 exception_table_length, checked_exceptions_length, generic_signature_index,
54 method_type, size);
52 } 55 }
53 56
54 ConstMethod::ConstMethod(int byte_code_size, 57 ConstMethod::ConstMethod(int byte_code_size,
55 int compressed_line_number_size, 58 int compressed_line_number_size,
56 int localvariable_table_length, 59 int localvariable_table_length,
57 int exception_table_length, 60 int exception_table_length,
58 int checked_exceptions_length, 61 int checked_exceptions_length,
62 u2 generic_signature_index,
59 MethodType method_type, 63 MethodType method_type,
60 int size) { 64 int size) {
61 65
62 No_Safepoint_Verifier no_safepoint; 66 No_Safepoint_Verifier no_safepoint;
63 set_interpreter_kind(Interpreter::invalid); 67 set_interpreter_kind(Interpreter::invalid);
64 init_fingerprint(); 68 init_fingerprint();
65 set_constants(NULL); 69 set_constants(NULL);
66 set_stackmap_data(NULL); 70 set_stackmap_data(NULL);
67 set_code_size(byte_code_size); 71 set_code_size(byte_code_size);
68 set_constMethod_size(size); 72 set_constMethod_size(size);
69 set_inlined_tables_length(checked_exceptions_length, 73 set_inlined_tables_length(generic_signature_index,
74 checked_exceptions_length,
70 compressed_line_number_size, 75 compressed_line_number_size,
71 localvariable_table_length, 76 localvariable_table_length,
72 exception_table_length); 77 exception_table_length);
73 set_method_type(method_type); 78 set_method_type(method_type);
74 assert(this->size() == size, "wrong size for object"); 79 assert(this->size() == size, "wrong size for object");
88 93
89 int ConstMethod::size(int code_size, 94 int ConstMethod::size(int code_size,
90 int compressed_line_number_size, 95 int compressed_line_number_size,
91 int local_variable_table_length, 96 int local_variable_table_length,
92 int exception_table_length, 97 int exception_table_length,
93 int checked_exceptions_length) { 98 int checked_exceptions_length,
99 u2 generic_signature_index) {
94 int extra_bytes = code_size; 100 int extra_bytes = code_size;
95 if (compressed_line_number_size > 0) { 101 if (compressed_line_number_size > 0) {
96 extra_bytes += compressed_line_number_size; 102 extra_bytes += compressed_line_number_size;
97 } 103 }
98 if (checked_exceptions_length > 0) { 104 if (checked_exceptions_length > 0) {
106 } 112 }
107 if (exception_table_length > 0) { 113 if (exception_table_length > 0) {
108 extra_bytes += sizeof(u2); 114 extra_bytes += sizeof(u2);
109 extra_bytes += exception_table_length * sizeof(ExceptionTableElement); 115 extra_bytes += exception_table_length * sizeof(ExceptionTableElement);
110 } 116 }
117 if (generic_signature_index != 0) {
118 extra_bytes += sizeof(u2);
119 }
111 int extra_words = align_size_up(extra_bytes, BytesPerWord) / BytesPerWord; 120 int extra_words = align_size_up(extra_bytes, BytesPerWord) / BytesPerWord;
112 return align_object_size(header_size() + extra_words); 121 return align_object_size(header_size() + extra_words);
113 } 122 }
114 123
115 Method* ConstMethod::method() const { 124 Method* ConstMethod::method() const {
123 // Located immediately following the bytecodes. 132 // Located immediately following the bytecodes.
124 assert(has_linenumber_table(), "called only if table is present"); 133 assert(has_linenumber_table(), "called only if table is present");
125 return code_end(); 134 return code_end();
126 } 135 }
127 136
137 u2* ConstMethod::generic_signature_index_addr() const {
138 // Located at the end of the constMethod.
139 assert(has_generic_signature(), "called only if generic signature exists");
140 return last_u2_element();
141 }
142
128 u2* ConstMethod::checked_exceptions_length_addr() const { 143 u2* ConstMethod::checked_exceptions_length_addr() const {
129 // Located at the end of the constMethod. 144 // Located immediately before the generic signature index.
130 assert(has_checked_exceptions(), "called only if table is present"); 145 assert(has_checked_exceptions(), "called only if table is present");
131 return last_u2_element(); 146 return has_generic_signature() ? (last_u2_element() - 1) :
147 last_u2_element();
132 } 148 }
133 149
134 u2* ConstMethod::exception_table_length_addr() const { 150 u2* ConstMethod::exception_table_length_addr() const {
135 assert(has_exception_handler(), "called only if table is present"); 151 assert(has_exception_handler(), "called only if table is present");
136 if (has_checked_exceptions()) { 152 if (has_checked_exceptions()) {
137 // If checked_exception present, locate immediately before them. 153 // If checked_exception present, locate immediately before them.
138 return (u2*) checked_exceptions_start() - 1; 154 return (u2*) checked_exceptions_start() - 1;
139 } else { 155 } else {
140 // Else, the exception table is at the end of the constMethod. 156 // Else, the exception table is at the end of the constMethod or
141 return last_u2_element(); 157 // immediately before the generic signature index.
158 return has_generic_signature() ? (last_u2_element() - 1) :
159 last_u2_element();
142 } 160 }
143 } 161 }
144 162
145 u2* ConstMethod::localvariable_table_length_addr() const { 163 u2* ConstMethod::localvariable_table_length_addr() const {
146 assert(has_localvariable_table(), "called only if table is present"); 164 assert(has_localvariable_table(), "called only if table is present");
150 } else { 168 } else {
151 if (has_checked_exceptions()) { 169 if (has_checked_exceptions()) {
152 // If checked_exception present, locate immediately before them. 170 // If checked_exception present, locate immediately before them.
153 return (u2*) checked_exceptions_start() - 1; 171 return (u2*) checked_exceptions_start() - 1;
154 } else { 172 } else {
155 // Else, the linenumber table is at the end of the constMethod. 173 // Else, the linenumber table is at the end of the constMethod or
156 return last_u2_element(); 174 // immediately before the generic signature index.
175 return has_generic_signature() ? (last_u2_element() - 1) :
176 last_u2_element();
157 } 177 }
158 } 178 }
159 } 179 }
160 180
161
162 // Update the flags to indicate the presence of these optional fields. 181 // Update the flags to indicate the presence of these optional fields.
163 void ConstMethod::set_inlined_tables_length( 182 void ConstMethod::set_inlined_tables_length(u2 generic_signature_index,
164 int checked_exceptions_len, 183 int checked_exceptions_len,
165 int compressed_line_number_size, 184 int compressed_line_number_size,
166 int localvariable_table_len, 185 int localvariable_table_len,
167 int exception_table_len) { 186 int exception_table_len) {
168 // Must be done in the order below, otherwise length_addr accessors 187 // Must be done in the order below, otherwise length_addr accessors
169 // will not work. Only set bit in header if length is positive. 188 // will not work. Only set bit in header if length is positive.
170 assert(_flags == 0, "Error"); 189 assert(_flags == 0, "Error");
171 if (compressed_line_number_size > 0) { 190 if (compressed_line_number_size > 0) {
172 _flags |= _has_linenumber_table; 191 _flags |= _has_linenumber_table;
192 }
193 if (generic_signature_index != 0) {
194 _flags |= _has_generic_signature;
195 *(generic_signature_index_addr()) = generic_signature_index;
173 } 196 }
174 if (checked_exceptions_len > 0) { 197 if (checked_exceptions_len > 0) {
175 _flags |= _has_checked_exceptions; 198 _flags |= _has_checked_exceptions;
176 *(checked_exceptions_length_addr()) = checked_exceptions_len; 199 *(checked_exceptions_length_addr()) = checked_exceptions_len;
177 } 200 }