author | coleenp |
Tue, 18 Oct 2016 08:39:43 -0400 | |
changeset 41727 | f1658e76a682 |
parent 37480 | 291ee208fb72 |
child 45240 | e804b9d60859 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
35898
ddc274f0052f
8145628: hotspot metadata classes shouldn't use HeapWordSize or heap related macros like align_object_size
coleenp
parents:
35492
diff
changeset
|
2 |
* Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved. |
1 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#include "precompiled.hpp" |
30764 | 26 |
#include "gc/shared/gcLocker.hpp" |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
27 |
#include "interpreter/interpreter.hpp" |
15437 | 28 |
#include "memory/heapInspection.hpp" |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
29 |
#include "memory/metadataFactory.hpp" |
37248 | 30 |
#include "memory/resourceArea.hpp" |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
31 |
#include "oops/constMethod.hpp" |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
32 |
#include "oops/method.hpp" |
1 | 33 |
|
34 |
// Static initialization |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
35 |
const u2 ConstMethod::MAX_IDNUM = 0xFFFE; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
36 |
const u2 ConstMethod::UNSET_IDNUM = 0xFFFF; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
37 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
38 |
ConstMethod* ConstMethod::allocate(ClassLoaderData* loader_data, |
14385 | 39 |
int byte_code_size, |
15601 | 40 |
InlineTableSizes* sizes, |
14385 | 41 |
MethodType method_type, |
42 |
TRAPS) { |
|
15601 | 43 |
int size = ConstMethod::size(byte_code_size, sizes); |
17858
c292f8791cca
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
16588
diff
changeset
|
44 |
return new (loader_data, size, true, MetaspaceObj::ConstMethodType, THREAD) ConstMethod( |
15601 | 45 |
byte_code_size, sizes, method_type, size); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
46 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
47 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
48 |
ConstMethod::ConstMethod(int byte_code_size, |
15601 | 49 |
InlineTableSizes* sizes, |
14385 | 50 |
MethodType method_type, |
51 |
int size) { |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
52 |
|
35492
c8c0273e6b91
8146690: Make all classes in GC follow the naming convention.
david
parents:
30764
diff
changeset
|
53 |
NoSafepointVerifier no_safepoint; |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
54 |
init_fingerprint(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
55 |
set_constants(NULL); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
56 |
set_stackmap_data(NULL); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
57 |
set_code_size(byte_code_size); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
58 |
set_constMethod_size(size); |
15931
c4fc378a132b
8009836: nsk/regression/b4222717 fails with empty stack trace
coleenp
parents:
15928
diff
changeset
|
59 |
set_inlined_tables_length(sizes); // sets _flags |
14385 | 60 |
set_method_type(method_type); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
61 |
assert(this->size() == size, "wrong size for object"); |
15928
f9d5c6e4107f
8003553: NPG: metaspace objects should be zeroed in constructors
coleenp
parents:
15601
diff
changeset
|
62 |
set_name_index(0); |
f9d5c6e4107f
8003553: NPG: metaspace objects should be zeroed in constructors
coleenp
parents:
15601
diff
changeset
|
63 |
set_signature_index(0); |
f9d5c6e4107f
8003553: NPG: metaspace objects should be zeroed in constructors
coleenp
parents:
15601
diff
changeset
|
64 |
set_constants(NULL); |
f9d5c6e4107f
8003553: NPG: metaspace objects should be zeroed in constructors
coleenp
parents:
15601
diff
changeset
|
65 |
set_max_stack(0); |
f9d5c6e4107f
8003553: NPG: metaspace objects should be zeroed in constructors
coleenp
parents:
15601
diff
changeset
|
66 |
set_max_locals(0); |
f9d5c6e4107f
8003553: NPG: metaspace objects should be zeroed in constructors
coleenp
parents:
15601
diff
changeset
|
67 |
set_method_idnum(0); |
15931
c4fc378a132b
8009836: nsk/regression/b4222717 fails with empty stack trace
coleenp
parents:
15928
diff
changeset
|
68 |
set_size_of_parameters(0); |
37480 | 69 |
set_result_type(T_VOID); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
70 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
71 |
|
15935
50da9e5eb858
8003419: NPG: Clean up metadata created during class loading if failure
coleenp
parents:
15931
diff
changeset
|
72 |
// Accessor that copies to metadata. |
50da9e5eb858
8003419: NPG: Clean up metadata created during class loading if failure
coleenp
parents:
15931
diff
changeset
|
73 |
void ConstMethod::copy_stackmap_data(ClassLoaderData* loader_data, |
50da9e5eb858
8003419: NPG: Clean up metadata created during class loading if failure
coleenp
parents:
15931
diff
changeset
|
74 |
u1* sd, int length, TRAPS) { |
50da9e5eb858
8003419: NPG: Clean up metadata created during class loading if failure
coleenp
parents:
15931
diff
changeset
|
75 |
_stackmap_data = MetadataFactory::new_array<u1>(loader_data, length, CHECK); |
50da9e5eb858
8003419: NPG: Clean up metadata created during class loading if failure
coleenp
parents:
15931
diff
changeset
|
76 |
memcpy((void*)_stackmap_data->adr_at(0), (void*)sd, length); |
50da9e5eb858
8003419: NPG: Clean up metadata created during class loading if failure
coleenp
parents:
15931
diff
changeset
|
77 |
} |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
78 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
79 |
// Deallocate metadata fields associated with ConstMethod* |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
80 |
void ConstMethod::deallocate_contents(ClassLoaderData* loader_data) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
81 |
if (stackmap_data() != NULL) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
82 |
MetadataFactory::free_array<u1>(loader_data, stackmap_data()); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
83 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
84 |
set_stackmap_data(NULL); |
15601 | 85 |
|
86 |
// deallocate annotation arrays |
|
87 |
if (has_method_annotations()) |
|
88 |
MetadataFactory::free_array<u1>(loader_data, method_annotations()); |
|
89 |
if (has_parameter_annotations()) |
|
90 |
MetadataFactory::free_array<u1>(loader_data, parameter_annotations()); |
|
91 |
if (has_type_annotations()) |
|
92 |
MetadataFactory::free_array<u1>(loader_data, type_annotations()); |
|
93 |
if (has_default_annotations()) |
|
94 |
MetadataFactory::free_array<u1>(loader_data, default_annotations()); |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
95 |
} |
1 | 96 |
|
97 |
// How big must this constMethodObject be? |
|
98 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
99 |
int ConstMethod::size(int code_size, |
15601 | 100 |
InlineTableSizes* sizes) { |
1 | 101 |
int extra_bytes = code_size; |
15601 | 102 |
if (sizes->compressed_linenumber_size() > 0) { |
103 |
extra_bytes += sizes->compressed_linenumber_size(); |
|
1 | 104 |
} |
15601 | 105 |
if (sizes->checked_exceptions_length() > 0) { |
1 | 106 |
extra_bytes += sizeof(u2); |
15601 | 107 |
extra_bytes += sizes->checked_exceptions_length() * sizeof(CheckedExceptionElement); |
1 | 108 |
} |
15601 | 109 |
if (sizes->localvariable_table_length() > 0) { |
1 | 110 |
extra_bytes += sizeof(u2); |
111 |
extra_bytes += |
|
15601 | 112 |
sizes->localvariable_table_length() * sizeof(LocalVariableTableElement); |
1 | 113 |
} |
15601 | 114 |
if (sizes->exception_table_length() > 0) { |
13282
9872915dd78d
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
12937
diff
changeset
|
115 |
extra_bytes += sizeof(u2); |
15601 | 116 |
extra_bytes += sizes->exception_table_length() * sizeof(ExceptionTableElement); |
13282
9872915dd78d
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
12937
diff
changeset
|
117 |
} |
15601 | 118 |
if (sizes->generic_signature_index() != 0) { |
14586
1262473e8fc1
8003848: Make ConstMethod::generic_signature_index optional and move Method::_max_stack to ConstMethod.
jiangli
parents:
14391
diff
changeset
|
119 |
extra_bytes += sizeof(u2); |
1262473e8fc1
8003848: Make ConstMethod::generic_signature_index optional and move Method::_max_stack to ConstMethod.
jiangli
parents:
14391
diff
changeset
|
120 |
} |
27612
7201412afbd0
8058313: Mismatch of method descriptor and MethodParameters.parameters_count should cause MalformedParameterException
emc
parents:
24424
diff
changeset
|
121 |
// This has to be a less-than-or-equal check, because we might be |
7201412afbd0
8058313: Mismatch of method descriptor and MethodParameters.parameters_count should cause MalformedParameterException
emc
parents:
24424
diff
changeset
|
122 |
// storing information from a zero-length MethodParameters |
7201412afbd0
8058313: Mismatch of method descriptor and MethodParameters.parameters_count should cause MalformedParameterException
emc
parents:
24424
diff
changeset
|
123 |
// attribute. We have to store these, because in some cases, they |
7201412afbd0
8058313: Mismatch of method descriptor and MethodParameters.parameters_count should cause MalformedParameterException
emc
parents:
24424
diff
changeset
|
124 |
// cause the reflection API to throw a MalformedParametersException. |
7201412afbd0
8058313: Mismatch of method descriptor and MethodParameters.parameters_count should cause MalformedParameterException
emc
parents:
24424
diff
changeset
|
125 |
if (sizes->method_parameters_length() >= 0) { |
15102
0a86564e5f61
8004728: Add hotspot support for parameter reflection
coleenp
parents:
14586
diff
changeset
|
126 |
extra_bytes += sizeof(u2); |
15601 | 127 |
extra_bytes += sizes->method_parameters_length() * sizeof(MethodParametersElement); |
128 |
} |
|
129 |
||
130 |
// Align sizes up to a word. |
|
131 |
extra_bytes = align_size_up(extra_bytes, BytesPerWord); |
|
132 |
||
133 |
// One pointer per annotation array |
|
134 |
if (sizes->method_annotations_length() > 0) { |
|
135 |
extra_bytes += sizeof(AnnotationArray*); |
|
15102
0a86564e5f61
8004728: Add hotspot support for parameter reflection
coleenp
parents:
14586
diff
changeset
|
136 |
} |
15601 | 137 |
if (sizes->parameter_annotations_length() > 0) { |
138 |
extra_bytes += sizeof(AnnotationArray*); |
|
139 |
} |
|
140 |
if (sizes->type_annotations_length() > 0) { |
|
141 |
extra_bytes += sizeof(AnnotationArray*); |
|
142 |
} |
|
143 |
if (sizes->default_annotations_length() > 0) { |
|
144 |
extra_bytes += sizeof(AnnotationArray*); |
|
145 |
} |
|
146 |
||
1 | 147 |
int extra_words = align_size_up(extra_bytes, BytesPerWord) / BytesPerWord; |
15601 | 148 |
assert(extra_words == extra_bytes/BytesPerWord, "should already be aligned"); |
35898
ddc274f0052f
8145628: hotspot metadata classes shouldn't use HeapWordSize or heap related macros like align_object_size
coleenp
parents:
35492
diff
changeset
|
149 |
return align_metadata_size(header_size() + extra_words); |
1 | 150 |
} |
151 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
152 |
Method* ConstMethod::method() const { |
14391
df0a1573d5bd
8000725: NPG: method_holder() and pool_holder() and pool_holder field should be InstanceKlass
coleenp
parents:
14385
diff
changeset
|
153 |
return _constants->pool_holder()->method_with_idnum(_method_idnum); |
12937
0032fb2caff6
7172967: Eliminate constMethod's _method backpointer to methodOop.
jiangli
parents:
7397
diff
changeset
|
154 |
} |
1 | 155 |
|
156 |
// linenumber table - note that length is unknown until decompression, |
|
157 |
// see class CompressedLineNumberReadStream. |
|
158 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
159 |
u_char* ConstMethod::compressed_linenumber_table() const { |
1 | 160 |
// Located immediately following the bytecodes. |
161 |
assert(has_linenumber_table(), "called only if table is present"); |
|
162 |
return code_end(); |
|
163 |
} |
|
164 |
||
15601 | 165 |
// Last short in ConstMethod* before annotations |
166 |
u2* ConstMethod::last_u2_element() const { |
|
167 |
int offset = 0; |
|
168 |
if (has_method_annotations()) offset++; |
|
169 |
if (has_parameter_annotations()) offset++; |
|
170 |
if (has_type_annotations()) offset++; |
|
171 |
if (has_default_annotations()) offset++; |
|
172 |
return (u2*)((AnnotationArray**)constMethod_end() - offset) - 1; |
|
173 |
} |
|
174 |
||
14586
1262473e8fc1
8003848: Make ConstMethod::generic_signature_index optional and move Method::_max_stack to ConstMethod.
jiangli
parents:
14391
diff
changeset
|
175 |
u2* ConstMethod::generic_signature_index_addr() const { |
1 | 176 |
// Located at the end of the constMethod. |
14586
1262473e8fc1
8003848: Make ConstMethod::generic_signature_index optional and move Method::_max_stack to ConstMethod.
jiangli
parents:
14391
diff
changeset
|
177 |
assert(has_generic_signature(), "called only if generic signature exists"); |
1262473e8fc1
8003848: Make ConstMethod::generic_signature_index optional and move Method::_max_stack to ConstMethod.
jiangli
parents:
14391
diff
changeset
|
178 |
return last_u2_element(); |
1262473e8fc1
8003848: Make ConstMethod::generic_signature_index optional and move Method::_max_stack to ConstMethod.
jiangli
parents:
14391
diff
changeset
|
179 |
} |
1262473e8fc1
8003848: Make ConstMethod::generic_signature_index optional and move Method::_max_stack to ConstMethod.
jiangli
parents:
14391
diff
changeset
|
180 |
|
15601 | 181 |
u2* ConstMethod::method_parameters_length_addr() const { |
182 |
assert(has_method_parameters(), "called only if table is present"); |
|
183 |
return has_generic_signature() ? (last_u2_element() - 1) : |
|
184 |
last_u2_element(); |
|
185 |
} |
|
186 |
||
14586
1262473e8fc1
8003848: Make ConstMethod::generic_signature_index optional and move Method::_max_stack to ConstMethod.
jiangli
parents:
14391
diff
changeset
|
187 |
u2* ConstMethod::checked_exceptions_length_addr() const { |
1262473e8fc1
8003848: Make ConstMethod::generic_signature_index optional and move Method::_max_stack to ConstMethod.
jiangli
parents:
14391
diff
changeset
|
188 |
// Located immediately before the generic signature index. |
1 | 189 |
assert(has_checked_exceptions(), "called only if table is present"); |
15102
0a86564e5f61
8004728: Add hotspot support for parameter reflection
coleenp
parents:
14586
diff
changeset
|
190 |
if(has_method_parameters()) { |
0a86564e5f61
8004728: Add hotspot support for parameter reflection
coleenp
parents:
14586
diff
changeset
|
191 |
// If method parameters present, locate immediately before them. |
0a86564e5f61
8004728: Add hotspot support for parameter reflection
coleenp
parents:
14586
diff
changeset
|
192 |
return (u2*)method_parameters_start() - 1; |
0a86564e5f61
8004728: Add hotspot support for parameter reflection
coleenp
parents:
14586
diff
changeset
|
193 |
} else { |
0a86564e5f61
8004728: Add hotspot support for parameter reflection
coleenp
parents:
14586
diff
changeset
|
194 |
// Else, the exception table is at the end of the constMethod. |
0a86564e5f61
8004728: Add hotspot support for parameter reflection
coleenp
parents:
14586
diff
changeset
|
195 |
return has_generic_signature() ? (last_u2_element() - 1) : |
0a86564e5f61
8004728: Add hotspot support for parameter reflection
coleenp
parents:
14586
diff
changeset
|
196 |
last_u2_element(); |
0a86564e5f61
8004728: Add hotspot support for parameter reflection
coleenp
parents:
14586
diff
changeset
|
197 |
} |
0a86564e5f61
8004728: Add hotspot support for parameter reflection
coleenp
parents:
14586
diff
changeset
|
198 |
} |
0a86564e5f61
8004728: Add hotspot support for parameter reflection
coleenp
parents:
14586
diff
changeset
|
199 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
200 |
u2* ConstMethod::exception_table_length_addr() const { |
13282
9872915dd78d
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
12937
diff
changeset
|
201 |
assert(has_exception_handler(), "called only if table is present"); |
1 | 202 |
if (has_checked_exceptions()) { |
203 |
// If checked_exception present, locate immediately before them. |
|
204 |
return (u2*) checked_exceptions_start() - 1; |
|
205 |
} else { |
|
15102
0a86564e5f61
8004728: Add hotspot support for parameter reflection
coleenp
parents:
14586
diff
changeset
|
206 |
if(has_method_parameters()) { |
0a86564e5f61
8004728: Add hotspot support for parameter reflection
coleenp
parents:
14586
diff
changeset
|
207 |
// If method parameters present, locate immediately before them. |
0a86564e5f61
8004728: Add hotspot support for parameter reflection
coleenp
parents:
14586
diff
changeset
|
208 |
return (u2*)method_parameters_start() - 1; |
0a86564e5f61
8004728: Add hotspot support for parameter reflection
coleenp
parents:
14586
diff
changeset
|
209 |
} else { |
0a86564e5f61
8004728: Add hotspot support for parameter reflection
coleenp
parents:
14586
diff
changeset
|
210 |
// Else, the exception table is at the end of the constMethod. |
15601 | 211 |
return has_generic_signature() ? (last_u2_element() - 1) : |
212 |
last_u2_element(); |
|
213 |
} |
|
15102
0a86564e5f61
8004728: Add hotspot support for parameter reflection
coleenp
parents:
14586
diff
changeset
|
214 |
} |
1 | 215 |
} |
216 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
217 |
u2* ConstMethod::localvariable_table_length_addr() const { |
13282
9872915dd78d
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
12937
diff
changeset
|
218 |
assert(has_localvariable_table(), "called only if table is present"); |
9872915dd78d
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
12937
diff
changeset
|
219 |
if (has_exception_handler()) { |
9872915dd78d
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
12937
diff
changeset
|
220 |
// If exception_table present, locate immediately before them. |
9872915dd78d
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
12937
diff
changeset
|
221 |
return (u2*) exception_table_start() - 1; |
9872915dd78d
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
12937
diff
changeset
|
222 |
} else { |
9872915dd78d
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
12937
diff
changeset
|
223 |
if (has_checked_exceptions()) { |
9872915dd78d
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
12937
diff
changeset
|
224 |
// If checked_exception present, locate immediately before them. |
9872915dd78d
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
12937
diff
changeset
|
225 |
return (u2*) checked_exceptions_start() - 1; |
9872915dd78d
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
12937
diff
changeset
|
226 |
} else { |
15102
0a86564e5f61
8004728: Add hotspot support for parameter reflection
coleenp
parents:
14586
diff
changeset
|
227 |
if(has_method_parameters()) { |
0a86564e5f61
8004728: Add hotspot support for parameter reflection
coleenp
parents:
14586
diff
changeset
|
228 |
// If method parameters present, locate immediately before them. |
0a86564e5f61
8004728: Add hotspot support for parameter reflection
coleenp
parents:
14586
diff
changeset
|
229 |
return (u2*)method_parameters_start() - 1; |
0a86564e5f61
8004728: Add hotspot support for parameter reflection
coleenp
parents:
14586
diff
changeset
|
230 |
} else { |
0a86564e5f61
8004728: Add hotspot support for parameter reflection
coleenp
parents:
14586
diff
changeset
|
231 |
// Else, the exception table is at the end of the constMethod. |
14586
1262473e8fc1
8003848: Make ConstMethod::generic_signature_index optional and move Method::_max_stack to ConstMethod.
jiangli
parents:
14391
diff
changeset
|
232 |
return has_generic_signature() ? (last_u2_element() - 1) : |
1262473e8fc1
8003848: Make ConstMethod::generic_signature_index optional and move Method::_max_stack to ConstMethod.
jiangli
parents:
14391
diff
changeset
|
233 |
last_u2_element(); |
15601 | 234 |
} |
13282
9872915dd78d
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
12937
diff
changeset
|
235 |
} |
9872915dd78d
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
12937
diff
changeset
|
236 |
} |
9872915dd78d
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
12937
diff
changeset
|
237 |
} |
9872915dd78d
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
12937
diff
changeset
|
238 |
|
1 | 239 |
// Update the flags to indicate the presence of these optional fields. |
15601 | 240 |
void ConstMethod::set_inlined_tables_length(InlineTableSizes* sizes) { |
241 |
_flags = 0; |
|
242 |
if (sizes->compressed_linenumber_size() > 0) |
|
1 | 243 |
_flags |= _has_linenumber_table; |
15601 | 244 |
if (sizes->generic_signature_index() != 0) |
14586
1262473e8fc1
8003848: Make ConstMethod::generic_signature_index optional and move Method::_max_stack to ConstMethod.
jiangli
parents:
14391
diff
changeset
|
245 |
_flags |= _has_generic_signature; |
27612
7201412afbd0
8058313: Mismatch of method descriptor and MethodParameters.parameters_count should cause MalformedParameterException
emc
parents:
24424
diff
changeset
|
246 |
if (sizes->method_parameters_length() >= 0) |
15102
0a86564e5f61
8004728: Add hotspot support for parameter reflection
coleenp
parents:
14586
diff
changeset
|
247 |
_flags |= _has_method_parameters; |
15601 | 248 |
if (sizes->checked_exceptions_length() > 0) |
15102
0a86564e5f61
8004728: Add hotspot support for parameter reflection
coleenp
parents:
14586
diff
changeset
|
249 |
_flags |= _has_checked_exceptions; |
15601 | 250 |
if (sizes->exception_table_length() > 0) |
15102
0a86564e5f61
8004728: Add hotspot support for parameter reflection
coleenp
parents:
14586
diff
changeset
|
251 |
_flags |= _has_exception_table; |
15601 | 252 |
if (sizes->localvariable_table_length() > 0) |
15102
0a86564e5f61
8004728: Add hotspot support for parameter reflection
coleenp
parents:
14586
diff
changeset
|
253 |
_flags |= _has_localvariable_table; |
0a86564e5f61
8004728: Add hotspot support for parameter reflection
coleenp
parents:
14586
diff
changeset
|
254 |
|
15601 | 255 |
// annotations, they are all pointer sized embedded objects so don't have |
256 |
// a length embedded also. |
|
257 |
if (sizes->method_annotations_length() > 0) |
|
258 |
_flags |= _has_method_annotations; |
|
259 |
if (sizes->parameter_annotations_length() > 0) |
|
260 |
_flags |= _has_parameter_annotations; |
|
261 |
if (sizes->type_annotations_length() > 0) |
|
262 |
_flags |= _has_type_annotations; |
|
263 |
if (sizes->default_annotations_length() > 0) |
|
264 |
_flags |= _has_default_annotations; |
|
265 |
||
15102
0a86564e5f61
8004728: Add hotspot support for parameter reflection
coleenp
parents:
14586
diff
changeset
|
266 |
// This code is extremely brittle and should possibly be revised. |
0a86564e5f61
8004728: Add hotspot support for parameter reflection
coleenp
parents:
14586
diff
changeset
|
267 |
// The *_length_addr functions walk backwards through the |
0a86564e5f61
8004728: Add hotspot support for parameter reflection
coleenp
parents:
14586
diff
changeset
|
268 |
// constMethod data, using each of the length indexes ahead of them, |
0a86564e5f61
8004728: Add hotspot support for parameter reflection
coleenp
parents:
14586
diff
changeset
|
269 |
// as well as the flags variable. Therefore, the indexes must be |
0a86564e5f61
8004728: Add hotspot support for parameter reflection
coleenp
parents:
14586
diff
changeset
|
270 |
// initialized in reverse order, or else they will compute the wrong |
0a86564e5f61
8004728: Add hotspot support for parameter reflection
coleenp
parents:
14586
diff
changeset
|
271 |
// offsets. Moving the initialization of _flags into a separate |
0a86564e5f61
8004728: Add hotspot support for parameter reflection
coleenp
parents:
14586
diff
changeset
|
272 |
// block solves *half* of the problem, but the following part will |
0a86564e5f61
8004728: Add hotspot support for parameter reflection
coleenp
parents:
14586
diff
changeset
|
273 |
// still break if the order is not exactly right. |
0a86564e5f61
8004728: Add hotspot support for parameter reflection
coleenp
parents:
14586
diff
changeset
|
274 |
// |
0a86564e5f61
8004728: Add hotspot support for parameter reflection
coleenp
parents:
14586
diff
changeset
|
275 |
// Also, the servicability agent needs to be informed anytime |
0a86564e5f61
8004728: Add hotspot support for parameter reflection
coleenp
parents:
14586
diff
changeset
|
276 |
// anything is added here. It might be advisable to have some sort |
0a86564e5f61
8004728: Add hotspot support for parameter reflection
coleenp
parents:
14586
diff
changeset
|
277 |
// of indication of this inline. |
15601 | 278 |
if (sizes->generic_signature_index() != 0) |
279 |
*(generic_signature_index_addr()) = sizes->generic_signature_index(); |
|
15102
0a86564e5f61
8004728: Add hotspot support for parameter reflection
coleenp
parents:
14586
diff
changeset
|
280 |
// New data should probably go here. |
27612
7201412afbd0
8058313: Mismatch of method descriptor and MethodParameters.parameters_count should cause MalformedParameterException
emc
parents:
24424
diff
changeset
|
281 |
if (sizes->method_parameters_length() >= 0) |
15601 | 282 |
*(method_parameters_length_addr()) = sizes->method_parameters_length(); |
283 |
if (sizes->checked_exceptions_length() > 0) |
|
284 |
*(checked_exceptions_length_addr()) = sizes->checked_exceptions_length(); |
|
285 |
if (sizes->exception_table_length() > 0) |
|
286 |
*(exception_table_length_addr()) = sizes->exception_table_length(); |
|
287 |
if (sizes->localvariable_table_length() > 0) |
|
288 |
*(localvariable_table_length_addr()) = sizes->localvariable_table_length(); |
|
15102
0a86564e5f61
8004728: Add hotspot support for parameter reflection
coleenp
parents:
14586
diff
changeset
|
289 |
} |
0a86564e5f61
8004728: Add hotspot support for parameter reflection
coleenp
parents:
14586
diff
changeset
|
290 |
|
0a86564e5f61
8004728: Add hotspot support for parameter reflection
coleenp
parents:
14586
diff
changeset
|
291 |
int ConstMethod::method_parameters_length() const { |
27612
7201412afbd0
8058313: Mismatch of method descriptor and MethodParameters.parameters_count should cause MalformedParameterException
emc
parents:
24424
diff
changeset
|
292 |
return has_method_parameters() ? *(method_parameters_length_addr()) : -1; |
15102
0a86564e5f61
8004728: Add hotspot support for parameter reflection
coleenp
parents:
14586
diff
changeset
|
293 |
} |
0a86564e5f61
8004728: Add hotspot support for parameter reflection
coleenp
parents:
14586
diff
changeset
|
294 |
|
0a86564e5f61
8004728: Add hotspot support for parameter reflection
coleenp
parents:
14586
diff
changeset
|
295 |
MethodParametersElement* ConstMethod::method_parameters_start() const { |
0a86564e5f61
8004728: Add hotspot support for parameter reflection
coleenp
parents:
14586
diff
changeset
|
296 |
u2* addr = method_parameters_length_addr(); |
0a86564e5f61
8004728: Add hotspot support for parameter reflection
coleenp
parents:
14586
diff
changeset
|
297 |
u2 length = *addr; |
0a86564e5f61
8004728: Add hotspot support for parameter reflection
coleenp
parents:
14586
diff
changeset
|
298 |
addr -= length * sizeof(MethodParametersElement) / sizeof(u2); |
0a86564e5f61
8004728: Add hotspot support for parameter reflection
coleenp
parents:
14586
diff
changeset
|
299 |
return (MethodParametersElement*) addr; |
1 | 300 |
} |
301 |
||
302 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
303 |
int ConstMethod::checked_exceptions_length() const { |
1 | 304 |
return has_checked_exceptions() ? *(checked_exceptions_length_addr()) : 0; |
305 |
} |
|
306 |
||
307 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
308 |
CheckedExceptionElement* ConstMethod::checked_exceptions_start() const { |
1 | 309 |
u2* addr = checked_exceptions_length_addr(); |
310 |
u2 length = *addr; |
|
311 |
assert(length > 0, "should only be called if table is present"); |
|
312 |
addr -= length * sizeof(CheckedExceptionElement) / sizeof(u2); |
|
313 |
return (CheckedExceptionElement*) addr; |
|
314 |
} |
|
315 |
||
316 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
317 |
int ConstMethod::localvariable_table_length() const { |
1 | 318 |
return has_localvariable_table() ? *(localvariable_table_length_addr()) : 0; |
319 |
} |
|
320 |
||
321 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
322 |
LocalVariableTableElement* ConstMethod::localvariable_table_start() const { |
1 | 323 |
u2* addr = localvariable_table_length_addr(); |
324 |
u2 length = *addr; |
|
325 |
assert(length > 0, "should only be called if table is present"); |
|
326 |
addr -= length * sizeof(LocalVariableTableElement) / sizeof(u2); |
|
327 |
return (LocalVariableTableElement*) addr; |
|
328 |
} |
|
13282
9872915dd78d
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
12937
diff
changeset
|
329 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
330 |
int ConstMethod::exception_table_length() const { |
13282
9872915dd78d
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
12937
diff
changeset
|
331 |
return has_exception_handler() ? *(exception_table_length_addr()) : 0; |
9872915dd78d
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
12937
diff
changeset
|
332 |
} |
9872915dd78d
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
12937
diff
changeset
|
333 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
334 |
ExceptionTableElement* ConstMethod::exception_table_start() const { |
13282
9872915dd78d
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
12937
diff
changeset
|
335 |
u2* addr = exception_table_length_addr(); |
9872915dd78d
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
12937
diff
changeset
|
336 |
u2 length = *addr; |
9872915dd78d
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
12937
diff
changeset
|
337 |
assert(length > 0, "should only be called if table is present"); |
9872915dd78d
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
12937
diff
changeset
|
338 |
addr -= length * sizeof(ExceptionTableElement) / sizeof(u2); |
9872915dd78d
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
12937
diff
changeset
|
339 |
return (ExceptionTableElement*)addr; |
9872915dd78d
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
12937
diff
changeset
|
340 |
} |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
341 |
|
15601 | 342 |
AnnotationArray** ConstMethod::method_annotations_addr() const { |
343 |
assert(has_method_annotations(), "should only be called if method annotations are present"); |
|
344 |
return (AnnotationArray**)constMethod_end() - 1; |
|
345 |
} |
|
346 |
||
347 |
AnnotationArray** ConstMethod::parameter_annotations_addr() const { |
|
348 |
assert(has_parameter_annotations(), "should only be called if method parameter annotations are present"); |
|
349 |
int offset = 1; |
|
350 |
if (has_method_annotations()) offset++; |
|
351 |
return (AnnotationArray**)constMethod_end() - offset; |
|
352 |
} |
|
353 |
||
354 |
AnnotationArray** ConstMethod::type_annotations_addr() const { |
|
355 |
assert(has_type_annotations(), "should only be called if method type annotations are present"); |
|
356 |
int offset = 1; |
|
357 |
if (has_method_annotations()) offset++; |
|
358 |
if (has_parameter_annotations()) offset++; |
|
359 |
return (AnnotationArray**)constMethod_end() - offset; |
|
360 |
} |
|
361 |
||
362 |
AnnotationArray** ConstMethod::default_annotations_addr() const { |
|
363 |
assert(has_default_annotations(), "should only be called if method default annotations are present"); |
|
364 |
int offset = 1; |
|
365 |
if (has_method_annotations()) offset++; |
|
366 |
if (has_parameter_annotations()) offset++; |
|
367 |
if (has_type_annotations()) offset++; |
|
368 |
return (AnnotationArray**)constMethod_end() - offset; |
|
369 |
} |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
370 |
|
41727
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
37480
diff
changeset
|
371 |
Array<u1>* copy_annotations(ClassLoaderData* loader_data, AnnotationArray* from, TRAPS) { |
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
37480
diff
changeset
|
372 |
int length = from->length(); |
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
37480
diff
changeset
|
373 |
Array<u1>* a = MetadataFactory::new_array<u1>(loader_data, length, 0, CHECK_NULL); |
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
37480
diff
changeset
|
374 |
memcpy((void*)a->adr_at(0), (void*)from->adr_at(0), length); |
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
37480
diff
changeset
|
375 |
return a; |
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
37480
diff
changeset
|
376 |
} |
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
37480
diff
changeset
|
377 |
|
16588
7e90e795813e
8009531: Crash when redefining class with annotated method
coleenp
parents:
15935
diff
changeset
|
378 |
// copy annotations from 'cm' to 'this' |
41727
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
37480
diff
changeset
|
379 |
// Must make copy because these are deallocated with their constMethod, if redefined. |
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
37480
diff
changeset
|
380 |
void ConstMethod::copy_annotations_from(ClassLoaderData* loader_data, ConstMethod* cm, TRAPS) { |
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
37480
diff
changeset
|
381 |
Array<u1>* a; |
16588
7e90e795813e
8009531: Crash when redefining class with annotated method
coleenp
parents:
15935
diff
changeset
|
382 |
if (cm->has_method_annotations()) { |
7e90e795813e
8009531: Crash when redefining class with annotated method
coleenp
parents:
15935
diff
changeset
|
383 |
assert(has_method_annotations(), "should be allocated already"); |
41727
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
37480
diff
changeset
|
384 |
a = copy_annotations(loader_data, cm->method_annotations(), CHECK); |
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
37480
diff
changeset
|
385 |
set_method_annotations(a); |
16588
7e90e795813e
8009531: Crash when redefining class with annotated method
coleenp
parents:
15935
diff
changeset
|
386 |
} |
7e90e795813e
8009531: Crash when redefining class with annotated method
coleenp
parents:
15935
diff
changeset
|
387 |
if (cm->has_parameter_annotations()) { |
7e90e795813e
8009531: Crash when redefining class with annotated method
coleenp
parents:
15935
diff
changeset
|
388 |
assert(has_parameter_annotations(), "should be allocated already"); |
41727
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
37480
diff
changeset
|
389 |
a = copy_annotations(loader_data, cm->parameter_annotations(), CHECK); |
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
37480
diff
changeset
|
390 |
set_parameter_annotations(a); |
16588
7e90e795813e
8009531: Crash when redefining class with annotated method
coleenp
parents:
15935
diff
changeset
|
391 |
} |
7e90e795813e
8009531: Crash when redefining class with annotated method
coleenp
parents:
15935
diff
changeset
|
392 |
if (cm->has_type_annotations()) { |
7e90e795813e
8009531: Crash when redefining class with annotated method
coleenp
parents:
15935
diff
changeset
|
393 |
assert(has_type_annotations(), "should be allocated already"); |
41727
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
37480
diff
changeset
|
394 |
a = copy_annotations(loader_data, cm->type_annotations(), CHECK); |
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
37480
diff
changeset
|
395 |
set_type_annotations(a); |
16588
7e90e795813e
8009531: Crash when redefining class with annotated method
coleenp
parents:
15935
diff
changeset
|
396 |
} |
7e90e795813e
8009531: Crash when redefining class with annotated method
coleenp
parents:
15935
diff
changeset
|
397 |
if (cm->has_default_annotations()) { |
7e90e795813e
8009531: Crash when redefining class with annotated method
coleenp
parents:
15935
diff
changeset
|
398 |
assert(has_default_annotations(), "should be allocated already"); |
41727
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
37480
diff
changeset
|
399 |
a = copy_annotations(loader_data, cm->default_annotations(), CHECK); |
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
37480
diff
changeset
|
400 |
set_default_annotations(a); |
16588
7e90e795813e
8009531: Crash when redefining class with annotated method
coleenp
parents:
15935
diff
changeset
|
401 |
} |
7e90e795813e
8009531: Crash when redefining class with annotated method
coleenp
parents:
15935
diff
changeset
|
402 |
} |
7e90e795813e
8009531: Crash when redefining class with annotated method
coleenp
parents:
15935
diff
changeset
|
403 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
404 |
// Printing |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
405 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
406 |
void ConstMethod::print_on(outputStream* st) const { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
407 |
ResourceMark rm; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
408 |
assert(is_constMethod(), "must be constMethod"); |
24424
2658d7834c6e
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
18439
diff
changeset
|
409 |
st->print_cr("%s", internal_name()); |
2658d7834c6e
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
18439
diff
changeset
|
410 |
st->print(" - method: " INTPTR_FORMAT " ", p2i((address)method())); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
411 |
method()->print_value_on(st); st->cr(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
412 |
if (has_stackmap_table()) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
413 |
st->print(" - stackmap data: "); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
414 |
stackmap_data()->print_value_on(st); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
415 |
st->cr(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
416 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
417 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
418 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
419 |
// Short version of printing ConstMethod* - just print the name of the |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
420 |
// method it belongs to. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
421 |
void ConstMethod::print_value_on(outputStream* st) const { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
422 |
assert(is_constMethod(), "must be constMethod"); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
423 |
st->print(" const part of method " ); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
424 |
method()->print_value_on(st); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
425 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
426 |
|
15437 | 427 |
#if INCLUDE_SERVICES |
428 |
// Size Statistics |
|
429 |
void ConstMethod::collect_statistics(KlassSizeStats *sz) const { |
|
430 |
int n1, n2, n3; |
|
431 |
sz->_const_method_bytes += (n1 = sz->count(this)); |
|
432 |
sz->_bytecode_bytes += (n2 = code_size()); |
|
433 |
sz->_stackmap_bytes += (n3 = sz->count_array(stackmap_data())); |
|
434 |
||
15601 | 435 |
// Count method annotations |
436 |
int a1 = 0, a2 = 0, a3 = 0, a4 = 0; |
|
437 |
if (has_method_annotations()) { |
|
438 |
sz->_methods_annotations_bytes += (a1 = sz->count_array(method_annotations())); |
|
439 |
} |
|
440 |
if (has_parameter_annotations()) { |
|
441 |
sz->_methods_parameter_annotations_bytes += (a2 = sz->count_array(parameter_annotations())); |
|
442 |
} |
|
443 |
if (has_type_annotations()) { |
|
444 |
sz->_methods_type_annotations_bytes += (a3 = sz->count_array(type_annotations())); |
|
445 |
} |
|
446 |
if (has_default_annotations()) { |
|
447 |
sz->_methods_default_annotations_bytes += (a4 = sz->count_array(default_annotations())); |
|
448 |
} |
|
449 |
||
450 |
int size_annotations = a1 + a2 + a3 + a4; |
|
451 |
||
452 |
sz->_method_all_bytes += n1 + n3 + size_annotations; // note: n2 is part of n3 |
|
453 |
sz->_ro_bytes += n1 + n3 + size_annotations; |
|
15437 | 454 |
} |
455 |
#endif // INCLUDE_SERVICES |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
456 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
457 |
// Verification |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
458 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
459 |
void ConstMethod::verify_on(outputStream* st) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
460 |
guarantee(is_constMethod(), "object must be constMethod"); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
461 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
462 |
// Verification can occur during oop construction before the method or |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
463 |
// other fields have been initialized. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
464 |
guarantee(method()->is_method(), "should be method"); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
465 |
|
15601 | 466 |
address m_end = (address)((intptr_t) this + size()); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
467 |
address compressed_table_start = code_end(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
468 |
guarantee(compressed_table_start <= m_end, "invalid method layout"); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
469 |
address compressed_table_end = compressed_table_start; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
470 |
// Verify line number table |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
471 |
if (has_linenumber_table()) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
472 |
CompressedLineNumberReadStream stream(compressed_linenumber_table()); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
473 |
while (stream.read_pair()) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
474 |
guarantee(stream.bci() >= 0 && stream.bci() <= code_size(), "invalid bci in line number table"); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
475 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
476 |
compressed_table_end += stream.position(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
477 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
478 |
guarantee(compressed_table_end <= m_end, "invalid method layout"); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
479 |
// Verify checked exceptions, exception table and local variable tables |
15102
0a86564e5f61
8004728: Add hotspot support for parameter reflection
coleenp
parents:
14586
diff
changeset
|
480 |
if (has_method_parameters()) { |
0a86564e5f61
8004728: Add hotspot support for parameter reflection
coleenp
parents:
14586
diff
changeset
|
481 |
u2* addr = method_parameters_length_addr(); |
0a86564e5f61
8004728: Add hotspot support for parameter reflection
coleenp
parents:
14586
diff
changeset
|
482 |
guarantee(*addr > 0 && (address) addr >= compressed_table_end && (address) addr < m_end, "invalid method layout"); |
0a86564e5f61
8004728: Add hotspot support for parameter reflection
coleenp
parents:
14586
diff
changeset
|
483 |
} |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
484 |
if (has_checked_exceptions()) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
485 |
u2* addr = checked_exceptions_length_addr(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
486 |
guarantee(*addr > 0 && (address) addr >= compressed_table_end && (address) addr < m_end, "invalid method layout"); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
487 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
488 |
if (has_exception_handler()) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
489 |
u2* addr = exception_table_length_addr(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
490 |
guarantee(*addr > 0 && (address) addr >= compressed_table_end && (address) addr < m_end, "invalid method layout"); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
491 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
492 |
if (has_localvariable_table()) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
493 |
u2* addr = localvariable_table_length_addr(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
494 |
guarantee(*addr > 0 && (address) addr >= compressed_table_end && (address) addr < m_end, "invalid method layout"); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
495 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
496 |
// Check compressed_table_end relative to uncompressed_table_start |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
497 |
u2* uncompressed_table_start; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
498 |
if (has_localvariable_table()) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
499 |
uncompressed_table_start = (u2*) localvariable_table_start(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
500 |
} else if (has_exception_handler()) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
501 |
uncompressed_table_start = (u2*) exception_table_start(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
502 |
} else if (has_checked_exceptions()) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
503 |
uncompressed_table_start = (u2*) checked_exceptions_start(); |
15102
0a86564e5f61
8004728: Add hotspot support for parameter reflection
coleenp
parents:
14586
diff
changeset
|
504 |
} else if (has_method_parameters()) { |
0a86564e5f61
8004728: Add hotspot support for parameter reflection
coleenp
parents:
14586
diff
changeset
|
505 |
uncompressed_table_start = (u2*) method_parameters_start(); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
506 |
} else { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
507 |
uncompressed_table_start = (u2*) m_end; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
508 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
509 |
int gap = (intptr_t) uncompressed_table_start - (intptr_t) compressed_table_end; |
35898
ddc274f0052f
8145628: hotspot metadata classes shouldn't use HeapWordSize or heap related macros like align_object_size
coleenp
parents:
35492
diff
changeset
|
510 |
int max_gap = align_metadata_size(1)*BytesPerWord; |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
511 |
guarantee(gap >= 0 && gap < max_gap, "invalid method layout"); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13282
diff
changeset
|
512 |
} |