author | stefank |
Thu, 09 May 2019 14:28:30 +0200 | |
changeset 54786 | ebf733a324d4 |
parent 51329 | 9c68699bebe5 |
child 59056 | 15936b142f86 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
49480
d7df2dd501ce
8199809: Don't include frame.inline.hpp and other.inline.hpp from .hpp files
coleenp
parents:
49449
diff
changeset
|
2 |
* Copyright (c) 2005, 2018, 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:
3261
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
3261
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:
3261
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#include "precompiled.hpp" |
26 |
#include "classfile/symbolTable.hpp" |
|
27 |
#include "interpreter/bytecodeStream.hpp" |
|
54786 | 28 |
#include "memory/universe.hpp" |
10546 | 29 |
#include "oops/fieldStreams.hpp" |
7397 | 30 |
#include "prims/jvmtiClassFileReconstituter.hpp" |
49480
d7df2dd501ce
8199809: Don't include frame.inline.hpp and other.inline.hpp from .hpp files
coleenp
parents:
49449
diff
changeset
|
31 |
#include "runtime/handles.inline.hpp" |
7397 | 32 |
#include "runtime/signature.hpp" |
25715
d5a8dbdc5150
8049325: Introduce and clean up umbrella headers for the files in the cpu subdirectories.
goetz
parents:
24322
diff
changeset
|
33 |
#include "utilities/bytes.hpp" |
d5a8dbdc5150
8049325: Introduce and clean up umbrella headers for the files in the cpu subdirectories.
goetz
parents:
24322
diff
changeset
|
34 |
|
13863
3a6dfc8fdfd1
7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents:
13728
diff
changeset
|
35 |
// FIXME: add Deprecated attribute |
1 | 36 |
// FIXME: fix Synthetic attribute |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13286
diff
changeset
|
37 |
// FIXME: per Serguei, add error return handling for ConstantPool::copy_cpool_bytes() |
1 | 38 |
|
49449
ef5d5d343e2a
8199263: Split interfaceSupport.hpp to not require including .inline.hpp files
coleenp
parents:
47216
diff
changeset
|
39 |
JvmtiConstantPoolReconstituter::JvmtiConstantPoolReconstituter(InstanceKlass* ik) { |
ef5d5d343e2a
8199263: Split interfaceSupport.hpp to not require including .inline.hpp files
coleenp
parents:
47216
diff
changeset
|
40 |
set_error(JVMTI_ERROR_NONE); |
ef5d5d343e2a
8199263: Split interfaceSupport.hpp to not require including .inline.hpp files
coleenp
parents:
47216
diff
changeset
|
41 |
_ik = ik; |
ef5d5d343e2a
8199263: Split interfaceSupport.hpp to not require including .inline.hpp files
coleenp
parents:
47216
diff
changeset
|
42 |
_cpool = constantPoolHandle(Thread::current(), ik->constants()); |
ef5d5d343e2a
8199263: Split interfaceSupport.hpp to not require including .inline.hpp files
coleenp
parents:
47216
diff
changeset
|
43 |
_symmap = new SymbolHashMap(); |
ef5d5d343e2a
8199263: Split interfaceSupport.hpp to not require including .inline.hpp files
coleenp
parents:
47216
diff
changeset
|
44 |
_classmap = new SymbolHashMap(); |
ef5d5d343e2a
8199263: Split interfaceSupport.hpp to not require including .inline.hpp files
coleenp
parents:
47216
diff
changeset
|
45 |
_cpool_size = _cpool->hash_entries_to(_symmap, _classmap); |
ef5d5d343e2a
8199263: Split interfaceSupport.hpp to not require including .inline.hpp files
coleenp
parents:
47216
diff
changeset
|
46 |
if (_cpool_size == 0) { |
ef5d5d343e2a
8199263: Split interfaceSupport.hpp to not require including .inline.hpp files
coleenp
parents:
47216
diff
changeset
|
47 |
set_error(JVMTI_ERROR_OUT_OF_MEMORY); |
ef5d5d343e2a
8199263: Split interfaceSupport.hpp to not require including .inline.hpp files
coleenp
parents:
47216
diff
changeset
|
48 |
} else if (_cpool_size < 0) { |
ef5d5d343e2a
8199263: Split interfaceSupport.hpp to not require including .inline.hpp files
coleenp
parents:
47216
diff
changeset
|
49 |
set_error(JVMTI_ERROR_INTERNAL); |
ef5d5d343e2a
8199263: Split interfaceSupport.hpp to not require including .inline.hpp files
coleenp
parents:
47216
diff
changeset
|
50 |
} |
ef5d5d343e2a
8199263: Split interfaceSupport.hpp to not require including .inline.hpp files
coleenp
parents:
47216
diff
changeset
|
51 |
} |
1 | 52 |
|
53 |
// Write the field information portion of ClassFile structure |
|
54 |
// JVMSpec| u2 fields_count; |
|
55 |
// JVMSpec| field_info fields[fields_count]; |
|
56 |
void JvmtiClassFileReconstituter::write_field_infos() { |
|
57 |
HandleMark hm(thread()); |
|
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
38031
diff
changeset
|
58 |
Array<AnnotationArray*>* fields_anno = ik()->fields_annotations(); |
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
38031
diff
changeset
|
59 |
Array<AnnotationArray*>* fields_type_anno = ik()->fields_type_annotations(); |
1 | 60 |
|
10546 | 61 |
// Compute the real number of Java fields |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
38031
diff
changeset
|
62 |
int java_fields = ik()->java_fields_count(); |
10546 | 63 |
|
10552 | 64 |
write_u2(java_fields); |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
38031
diff
changeset
|
65 |
for (JavaFieldStream fs(ik()); !fs.done(); fs.next()) { |
10546 | 66 |
AccessFlags access_flags = fs.access_flags(); |
67 |
int name_index = fs.name_index(); |
|
68 |
int signature_index = fs.signature_index(); |
|
69 |
int initial_value_index = fs.initval_index(); |
|
1 | 70 |
guarantee(name_index != 0 && signature_index != 0, "bad constant pool index for field"); |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
38031
diff
changeset
|
71 |
// int offset = ik()->field_offset( index ); |
10546 | 72 |
int generic_signature_index = fs.generic_signature_index(); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13286
diff
changeset
|
73 |
AnnotationArray* anno = fields_anno == NULL ? NULL : fields_anno->at(fs.index()); |
27401
a4697c9502cb
8057043: Type annotations not retained during class redefine / retransform
aeriksso
parents:
25715
diff
changeset
|
74 |
AnnotationArray* type_anno = fields_type_anno == NULL ? NULL : fields_type_anno->at(fs.index()); |
1 | 75 |
|
76 |
// JVMSpec| field_info { |
|
77 |
// JVMSpec| u2 access_flags; |
|
78 |
// JVMSpec| u2 name_index; |
|
79 |
// JVMSpec| u2 descriptor_index; |
|
80 |
// JVMSpec| u2 attributes_count; |
|
81 |
// JVMSpec| attribute_info attributes[attributes_count]; |
|
82 |
// JVMSpec| } |
|
83 |
||
10546 | 84 |
write_u2(access_flags.as_int() & JVM_RECOGNIZED_FIELD_MODIFIERS); |
1 | 85 |
write_u2(name_index); |
86 |
write_u2(signature_index); |
|
87 |
int attr_count = 0; |
|
88 |
if (initial_value_index != 0) { |
|
89 |
++attr_count; |
|
90 |
} |
|
91 |
if (access_flags.is_synthetic()) { |
|
92 |
// ++attr_count; |
|
93 |
} |
|
94 |
if (generic_signature_index != 0) { |
|
95 |
++attr_count; |
|
96 |
} |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13286
diff
changeset
|
97 |
if (anno != NULL) { |
1 | 98 |
++attr_count; // has RuntimeVisibleAnnotations attribute |
99 |
} |
|
27401
a4697c9502cb
8057043: Type annotations not retained during class redefine / retransform
aeriksso
parents:
25715
diff
changeset
|
100 |
if (type_anno != NULL) { |
a4697c9502cb
8057043: Type annotations not retained during class redefine / retransform
aeriksso
parents:
25715
diff
changeset
|
101 |
++attr_count; // has RuntimeVisibleTypeAnnotations attribute |
a4697c9502cb
8057043: Type annotations not retained during class redefine / retransform
aeriksso
parents:
25715
diff
changeset
|
102 |
} |
1 | 103 |
|
104 |
write_u2(attr_count); |
|
105 |
||
106 |
if (initial_value_index != 0) { |
|
107 |
write_attribute_name_index("ConstantValue"); |
|
108 |
write_u4(2); //length always 2 |
|
109 |
write_u2(initial_value_index); |
|
110 |
} |
|
111 |
if (access_flags.is_synthetic()) { |
|
112 |
// write_synthetic_attribute(); |
|
113 |
} |
|
114 |
if (generic_signature_index != 0) { |
|
115 |
write_signature_attribute(generic_signature_index); |
|
116 |
} |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13286
diff
changeset
|
117 |
if (anno != NULL) { |
1 | 118 |
write_annotations_attribute("RuntimeVisibleAnnotations", anno); |
119 |
} |
|
27401
a4697c9502cb
8057043: Type annotations not retained during class redefine / retransform
aeriksso
parents:
25715
diff
changeset
|
120 |
if (type_anno != NULL) { |
a4697c9502cb
8057043: Type annotations not retained during class redefine / retransform
aeriksso
parents:
25715
diff
changeset
|
121 |
write_annotations_attribute("RuntimeVisibleTypeAnnotations", type_anno); |
a4697c9502cb
8057043: Type annotations not retained during class redefine / retransform
aeriksso
parents:
25715
diff
changeset
|
122 |
} |
1 | 123 |
} |
124 |
} |
|
125 |
||
126 |
// Write Code attribute |
|
127 |
// JVMSpec| Code_attribute { |
|
128 |
// JVMSpec| u2 attribute_name_index; |
|
129 |
// JVMSpec| u4 attribute_length; |
|
130 |
// JVMSpec| u2 max_stack; |
|
131 |
// JVMSpec| u2 max_locals; |
|
132 |
// JVMSpec| u4 code_length; |
|
133 |
// JVMSpec| u1 code[code_length]; |
|
134 |
// JVMSpec| u2 exception_table_length; |
|
135 |
// JVMSpec| { u2 start_pc; |
|
136 |
// JVMSpec| u2 end_pc; |
|
137 |
// JVMSpec| u2 handler_pc; |
|
138 |
// JVMSpec| u2 catch_type; |
|
139 |
// JVMSpec| } exception_table[exception_table_length]; |
|
140 |
// JVMSpec| u2 attributes_count; |
|
141 |
// JVMSpec| attribute_info attributes[attributes_count]; |
|
142 |
// JVMSpec| } |
|
33593
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
27401
diff
changeset
|
143 |
void JvmtiClassFileReconstituter::write_code_attribute(const methodHandle& method) { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13286
diff
changeset
|
144 |
ConstMethod* const_method = method->constMethod(); |
1 | 145 |
u2 line_num_cnt = 0; |
146 |
int stackmap_len = 0; |
|
11257
b98dfa12a8f7
7064927: retransformClasses() does not pass in LocalVariableTable of a method
coleenp
parents:
10552
diff
changeset
|
147 |
int local_variable_table_length = 0; |
13863
3a6dfc8fdfd1
7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents:
13728
diff
changeset
|
148 |
int local_variable_type_table_length = 0; |
1 | 149 |
|
11257
b98dfa12a8f7
7064927: retransformClasses() does not pass in LocalVariableTable of a method
coleenp
parents:
10552
diff
changeset
|
150 |
// compute number and length of attributes |
1 | 151 |
int attr_count = 0; |
152 |
int attr_size = 0; |
|
153 |
if (const_method->has_linenumber_table()) { |
|
154 |
line_num_cnt = line_number_table_entries(method); |
|
155 |
if (line_num_cnt != 0) { |
|
156 |
++attr_count; |
|
157 |
// Compute the complete size of the line number table attribute: |
|
158 |
// LineNumberTable_attribute { |
|
159 |
// u2 attribute_name_index; |
|
160 |
// u4 attribute_length; |
|
161 |
// u2 line_number_table_length; |
|
162 |
// { u2 start_pc; |
|
163 |
// u2 line_number; |
|
164 |
// } line_number_table[line_number_table_length]; |
|
165 |
// } |
|
166 |
attr_size += 2 + 4 + 2 + line_num_cnt * (2 + 2); |
|
167 |
} |
|
168 |
} |
|
169 |
if (method->has_stackmap_table()) { |
|
170 |
stackmap_len = method->stackmap_data()->length(); |
|
171 |
if (stackmap_len != 0) { |
|
172 |
++attr_count; |
|
173 |
// Compute the size of the stack map table attribute (VM stores raw): |
|
174 |
// StackMapTable_attribute { |
|
175 |
// u2 attribute_name_index; |
|
176 |
// u4 attribute_length; |
|
177 |
// u2 number_of_entries; |
|
178 |
// stack_map_frame_entries[number_of_entries]; |
|
179 |
// } |
|
180 |
attr_size += 2 + 4 + stackmap_len; |
|
181 |
} |
|
182 |
} |
|
11257
b98dfa12a8f7
7064927: retransformClasses() does not pass in LocalVariableTable of a method
coleenp
parents:
10552
diff
changeset
|
183 |
if (method->has_localvariable_table()) { |
b98dfa12a8f7
7064927: retransformClasses() does not pass in LocalVariableTable of a method
coleenp
parents:
10552
diff
changeset
|
184 |
local_variable_table_length = method->localvariable_table_length(); |
b98dfa12a8f7
7064927: retransformClasses() does not pass in LocalVariableTable of a method
coleenp
parents:
10552
diff
changeset
|
185 |
if (local_variable_table_length != 0) { |
13863
3a6dfc8fdfd1
7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents:
13728
diff
changeset
|
186 |
++attr_count; |
11257
b98dfa12a8f7
7064927: retransformClasses() does not pass in LocalVariableTable of a method
coleenp
parents:
10552
diff
changeset
|
187 |
// Compute the size of the local variable table attribute (VM stores raw): |
b98dfa12a8f7
7064927: retransformClasses() does not pass in LocalVariableTable of a method
coleenp
parents:
10552
diff
changeset
|
188 |
// LocalVariableTable_attribute { |
b98dfa12a8f7
7064927: retransformClasses() does not pass in LocalVariableTable of a method
coleenp
parents:
10552
diff
changeset
|
189 |
// u2 attribute_name_index; |
b98dfa12a8f7
7064927: retransformClasses() does not pass in LocalVariableTable of a method
coleenp
parents:
10552
diff
changeset
|
190 |
// u4 attribute_length; |
b98dfa12a8f7
7064927: retransformClasses() does not pass in LocalVariableTable of a method
coleenp
parents:
10552
diff
changeset
|
191 |
// u2 local_variable_table_length; |
b98dfa12a8f7
7064927: retransformClasses() does not pass in LocalVariableTable of a method
coleenp
parents:
10552
diff
changeset
|
192 |
// { |
b98dfa12a8f7
7064927: retransformClasses() does not pass in LocalVariableTable of a method
coleenp
parents:
10552
diff
changeset
|
193 |
// u2 start_pc; |
b98dfa12a8f7
7064927: retransformClasses() does not pass in LocalVariableTable of a method
coleenp
parents:
10552
diff
changeset
|
194 |
// u2 length; |
b98dfa12a8f7
7064927: retransformClasses() does not pass in LocalVariableTable of a method
coleenp
parents:
10552
diff
changeset
|
195 |
// u2 name_index; |
b98dfa12a8f7
7064927: retransformClasses() does not pass in LocalVariableTable of a method
coleenp
parents:
10552
diff
changeset
|
196 |
// u2 descriptor_index; |
b98dfa12a8f7
7064927: retransformClasses() does not pass in LocalVariableTable of a method
coleenp
parents:
10552
diff
changeset
|
197 |
// u2 index; |
b98dfa12a8f7
7064927: retransformClasses() does not pass in LocalVariableTable of a method
coleenp
parents:
10552
diff
changeset
|
198 |
// } |
b98dfa12a8f7
7064927: retransformClasses() does not pass in LocalVariableTable of a method
coleenp
parents:
10552
diff
changeset
|
199 |
attr_size += 2 + 4 + 2 + local_variable_table_length * (2 + 2 + 2 + 2 + 2); |
13863
3a6dfc8fdfd1
7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents:
13728
diff
changeset
|
200 |
|
3a6dfc8fdfd1
7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents:
13728
diff
changeset
|
201 |
// Local variables with generic signatures must have LVTT entries |
3a6dfc8fdfd1
7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents:
13728
diff
changeset
|
202 |
LocalVariableTableElement *elem = method->localvariable_table_start(); |
3a6dfc8fdfd1
7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents:
13728
diff
changeset
|
203 |
for (int idx = 0; idx < local_variable_table_length; idx++) { |
3a6dfc8fdfd1
7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents:
13728
diff
changeset
|
204 |
if (elem[idx].signature_cp_index != 0) { |
3a6dfc8fdfd1
7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents:
13728
diff
changeset
|
205 |
local_variable_type_table_length++; |
3a6dfc8fdfd1
7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents:
13728
diff
changeset
|
206 |
} |
3a6dfc8fdfd1
7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents:
13728
diff
changeset
|
207 |
} |
3a6dfc8fdfd1
7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents:
13728
diff
changeset
|
208 |
|
3a6dfc8fdfd1
7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents:
13728
diff
changeset
|
209 |
if (local_variable_type_table_length != 0) { |
3a6dfc8fdfd1
7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents:
13728
diff
changeset
|
210 |
++attr_count; |
3a6dfc8fdfd1
7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents:
13728
diff
changeset
|
211 |
// Compute the size of the local variable type table attribute (VM stores raw): |
3a6dfc8fdfd1
7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents:
13728
diff
changeset
|
212 |
// LocalVariableTypeTable_attribute { |
3a6dfc8fdfd1
7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents:
13728
diff
changeset
|
213 |
// u2 attribute_name_index; |
3a6dfc8fdfd1
7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents:
13728
diff
changeset
|
214 |
// u4 attribute_length; |
3a6dfc8fdfd1
7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents:
13728
diff
changeset
|
215 |
// u2 local_variable_type_table_length; |
3a6dfc8fdfd1
7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents:
13728
diff
changeset
|
216 |
// { |
3a6dfc8fdfd1
7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents:
13728
diff
changeset
|
217 |
// u2 start_pc; |
3a6dfc8fdfd1
7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents:
13728
diff
changeset
|
218 |
// u2 length; |
3a6dfc8fdfd1
7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents:
13728
diff
changeset
|
219 |
// u2 name_index; |
3a6dfc8fdfd1
7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents:
13728
diff
changeset
|
220 |
// u2 signature_index; |
3a6dfc8fdfd1
7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents:
13728
diff
changeset
|
221 |
// u2 index; |
3a6dfc8fdfd1
7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents:
13728
diff
changeset
|
222 |
// } |
3a6dfc8fdfd1
7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents:
13728
diff
changeset
|
223 |
attr_size += 2 + 4 + 2 + local_variable_type_table_length * (2 + 2 + 2 + 2 + 2); |
3a6dfc8fdfd1
7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents:
13728
diff
changeset
|
224 |
} |
11257
b98dfa12a8f7
7064927: retransformClasses() does not pass in LocalVariableTable of a method
coleenp
parents:
10552
diff
changeset
|
225 |
} |
b98dfa12a8f7
7064927: retransformClasses() does not pass in LocalVariableTable of a method
coleenp
parents:
10552
diff
changeset
|
226 |
} |
1 | 227 |
|
13282
9872915dd78d
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
12231
diff
changeset
|
228 |
ExceptionTable exception_table(method()); |
9872915dd78d
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
12231
diff
changeset
|
229 |
int exception_table_length = exception_table.length(); |
1 | 230 |
int code_size = const_method->code_size(); |
231 |
int size = |
|
232 |
2+2+4 + // max_stack, max_locals, code_length |
|
233 |
code_size + // code |
|
234 |
2 + // exception_table_length |
|
13282
9872915dd78d
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
12231
diff
changeset
|
235 |
(2+2+2+2) * exception_table_length + // exception_table |
1 | 236 |
2 + // attributes_count |
237 |
attr_size; // attributes |
|
238 |
||
239 |
write_attribute_name_index("Code"); |
|
240 |
write_u4(size); |
|
14480
06c1743f1285
7194607: VerifyLocalVariableTableOnRetransformTest.sh fails after JSR-292 merge
sspitsyn
parents:
13863
diff
changeset
|
241 |
write_u2(method->verifier_max_stack()); |
1 | 242 |
write_u2(method->max_locals()); |
243 |
write_u4(code_size); |
|
244 |
copy_bytecodes(method, (unsigned char*)writeable_address(code_size)); |
|
13282
9872915dd78d
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
12231
diff
changeset
|
245 |
write_u2(exception_table_length); |
9872915dd78d
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
12231
diff
changeset
|
246 |
for (int index = 0; index < exception_table_length; index++) { |
9872915dd78d
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
12231
diff
changeset
|
247 |
write_u2(exception_table.start_pc(index)); |
9872915dd78d
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
12231
diff
changeset
|
248 |
write_u2(exception_table.end_pc(index)); |
9872915dd78d
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
12231
diff
changeset
|
249 |
write_u2(exception_table.handler_pc(index)); |
9872915dd78d
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
12231
diff
changeset
|
250 |
write_u2(exception_table.catch_type_index(index)); |
1 | 251 |
} |
252 |
write_u2(attr_count); |
|
253 |
if (line_num_cnt != 0) { |
|
254 |
write_line_number_table_attribute(method, line_num_cnt); |
|
255 |
} |
|
256 |
if (stackmap_len != 0) { |
|
257 |
write_stackmap_table_attribute(method, stackmap_len); |
|
258 |
} |
|
11257
b98dfa12a8f7
7064927: retransformClasses() does not pass in LocalVariableTable of a method
coleenp
parents:
10552
diff
changeset
|
259 |
if (local_variable_table_length != 0) { |
b98dfa12a8f7
7064927: retransformClasses() does not pass in LocalVariableTable of a method
coleenp
parents:
10552
diff
changeset
|
260 |
write_local_variable_table_attribute(method, local_variable_table_length); |
b98dfa12a8f7
7064927: retransformClasses() does not pass in LocalVariableTable of a method
coleenp
parents:
10552
diff
changeset
|
261 |
} |
13863
3a6dfc8fdfd1
7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents:
13728
diff
changeset
|
262 |
if (local_variable_type_table_length != 0) { |
3a6dfc8fdfd1
7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents:
13728
diff
changeset
|
263 |
write_local_variable_type_table_attribute(method, local_variable_type_table_length); |
3a6dfc8fdfd1
7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents:
13728
diff
changeset
|
264 |
} |
1 | 265 |
} |
266 |
||
267 |
// Write Exceptions attribute |
|
268 |
// JVMSpec| Exceptions_attribute { |
|
269 |
// JVMSpec| u2 attribute_name_index; |
|
270 |
// JVMSpec| u4 attribute_length; |
|
271 |
// JVMSpec| u2 number_of_exceptions; |
|
272 |
// JVMSpec| u2 exception_index_table[number_of_exceptions]; |
|
273 |
// JVMSpec| } |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13286
diff
changeset
|
274 |
void JvmtiClassFileReconstituter::write_exceptions_attribute(ConstMethod* const_method) { |
1 | 275 |
CheckedExceptionElement* checked_exceptions = const_method->checked_exceptions_start(); |
276 |
int checked_exceptions_length = const_method->checked_exceptions_length(); |
|
277 |
int size = |
|
278 |
2 + // number_of_exceptions |
|
279 |
2 * checked_exceptions_length; // exception_index_table |
|
280 |
||
281 |
write_attribute_name_index("Exceptions"); |
|
282 |
write_u4(size); |
|
283 |
write_u2(checked_exceptions_length); |
|
284 |
for (int index = 0; index < checked_exceptions_length; index++) { |
|
285 |
write_u2(checked_exceptions[index].class_cp_index); |
|
286 |
} |
|
287 |
} |
|
288 |
||
289 |
// Write SourceFile attribute |
|
290 |
// JVMSpec| SourceFile_attribute { |
|
291 |
// JVMSpec| u2 attribute_name_index; |
|
292 |
// JVMSpec| u4 attribute_length; |
|
293 |
// JVMSpec| u2 sourcefile_index; |
|
294 |
// JVMSpec| } |
|
295 |
void JvmtiClassFileReconstituter::write_source_file_attribute() { |
|
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
38031
diff
changeset
|
296 |
assert(ik()->source_file_name() != NULL, "caller must check"); |
1 | 297 |
|
298 |
write_attribute_name_index("SourceFile"); |
|
299 |
write_u4(2); // always length 2 |
|
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
38031
diff
changeset
|
300 |
write_u2(symbol_to_cpool_index(ik()->source_file_name())); |
1 | 301 |
} |
302 |
||
303 |
// Write SourceDebugExtension attribute |
|
304 |
// JSR45| SourceDebugExtension_attribute { |
|
305 |
// JSR45| u2 attribute_name_index; |
|
306 |
// JSR45| u4 attribute_length; |
|
13201
69f157caabcc
6294277: java -Xdebug crashes on SourceDebugExtension attribute larger than 64K
fparain
parents:
12231
diff
changeset
|
307 |
// JSR45| u1 debug_extension[attribute_length]; |
1 | 308 |
// JSR45| } |
309 |
void JvmtiClassFileReconstituter::write_source_debug_extension_attribute() { |
|
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
38031
diff
changeset
|
310 |
assert(ik()->source_debug_extension() != NULL, "caller must check"); |
1 | 311 |
|
312 |
write_attribute_name_index("SourceDebugExtension"); |
|
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
38031
diff
changeset
|
313 |
int len = (int)strlen(ik()->source_debug_extension()); |
13201
69f157caabcc
6294277: java -Xdebug crashes on SourceDebugExtension attribute larger than 64K
fparain
parents:
12231
diff
changeset
|
314 |
write_u4(len); |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
38031
diff
changeset
|
315 |
u1* ext = (u1*)ik()->source_debug_extension(); |
13201
69f157caabcc
6294277: java -Xdebug crashes on SourceDebugExtension attribute larger than 64K
fparain
parents:
12231
diff
changeset
|
316 |
for (int i=0; i<len; i++) { |
69f157caabcc
6294277: java -Xdebug crashes on SourceDebugExtension attribute larger than 64K
fparain
parents:
12231
diff
changeset
|
317 |
write_u1(ext[i]); |
69f157caabcc
6294277: java -Xdebug crashes on SourceDebugExtension attribute larger than 64K
fparain
parents:
12231
diff
changeset
|
318 |
} |
1 | 319 |
} |
320 |
||
321 |
// Write (generic) Signature attribute |
|
322 |
// JVMSpec| Signature_attribute { |
|
323 |
// JVMSpec| u2 attribute_name_index; |
|
324 |
// JVMSpec| u4 attribute_length; |
|
325 |
// JVMSpec| u2 signature_index; |
|
326 |
// JVMSpec| } |
|
327 |
void JvmtiClassFileReconstituter::write_signature_attribute(u2 generic_signature_index) { |
|
328 |
write_attribute_name_index("Signature"); |
|
329 |
write_u4(2); // always length 2 |
|
330 |
write_u2(generic_signature_index); |
|
331 |
} |
|
332 |
||
333 |
// Compute the number of entries in the InnerClasses attribute |
|
334 |
u2 JvmtiClassFileReconstituter::inner_classes_attribute_length() { |
|
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
38031
diff
changeset
|
335 |
InnerClassesIterator iter(ik()); |
12231
6a9cfc59a18a
7109878: The instanceKlass EnclosingMethhod attribute fields can be folded into the _inner_class field.
jiangli
parents:
12102
diff
changeset
|
336 |
return iter.length(); |
1 | 337 |
} |
338 |
||
339 |
// Write an annotation attribute. The VM stores them in raw form, so all we need |
|
340 |
// to do is add the attrubute name and fill in the length. |
|
341 |
// JSR202| *Annotations_attribute { |
|
342 |
// JSR202| u2 attribute_name_index; |
|
343 |
// JSR202| u4 attribute_length; |
|
344 |
// JSR202| ... |
|
345 |
// JSR202| } |
|
346 |
void JvmtiClassFileReconstituter::write_annotations_attribute(const char* attr_name, |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13286
diff
changeset
|
347 |
AnnotationArray* annos) { |
1 | 348 |
u4 length = annos->length(); |
349 |
write_attribute_name_index(attr_name); |
|
350 |
write_u4(length); |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13286
diff
changeset
|
351 |
memcpy(writeable_address(length), annos->adr_at(0), length); |
1 | 352 |
} |
353 |
||
17307
74bb7db916df
8009615: JvmtiClassFileReconstituter does not create BootstrapMethod attributes
sla
parents:
17294
diff
changeset
|
354 |
// BootstrapMethods_attribute { |
74bb7db916df
8009615: JvmtiClassFileReconstituter does not create BootstrapMethod attributes
sla
parents:
17294
diff
changeset
|
355 |
// u2 attribute_name_index; |
74bb7db916df
8009615: JvmtiClassFileReconstituter does not create BootstrapMethod attributes
sla
parents:
17294
diff
changeset
|
356 |
// u4 attribute_length; |
74bb7db916df
8009615: JvmtiClassFileReconstituter does not create BootstrapMethod attributes
sla
parents:
17294
diff
changeset
|
357 |
// u2 num_bootstrap_methods; |
74bb7db916df
8009615: JvmtiClassFileReconstituter does not create BootstrapMethod attributes
sla
parents:
17294
diff
changeset
|
358 |
// { u2 bootstrap_method_ref; |
74bb7db916df
8009615: JvmtiClassFileReconstituter does not create BootstrapMethod attributes
sla
parents:
17294
diff
changeset
|
359 |
// u2 num_bootstrap_arguments; |
74bb7db916df
8009615: JvmtiClassFileReconstituter does not create BootstrapMethod attributes
sla
parents:
17294
diff
changeset
|
360 |
// u2 bootstrap_arguments[num_bootstrap_arguments]; |
74bb7db916df
8009615: JvmtiClassFileReconstituter does not create BootstrapMethod attributes
sla
parents:
17294
diff
changeset
|
361 |
// } bootstrap_methods[num_bootstrap_methods]; |
74bb7db916df
8009615: JvmtiClassFileReconstituter does not create BootstrapMethod attributes
sla
parents:
17294
diff
changeset
|
362 |
// } |
17309
83ac929d332a
8014044: Spelling error in JDK-8009615: boostrapmethod
sla
parents:
17307
diff
changeset
|
363 |
void JvmtiClassFileReconstituter::write_bootstrapmethod_attribute() { |
17307
74bb7db916df
8009615: JvmtiClassFileReconstituter does not create BootstrapMethod attributes
sla
parents:
17294
diff
changeset
|
364 |
Array<u2>* operands = cpool()->operands(); |
74bb7db916df
8009615: JvmtiClassFileReconstituter does not create BootstrapMethod attributes
sla
parents:
17294
diff
changeset
|
365 |
write_attribute_name_index("BootstrapMethods"); |
74bb7db916df
8009615: JvmtiClassFileReconstituter does not create BootstrapMethod attributes
sla
parents:
17294
diff
changeset
|
366 |
int num_bootstrap_methods = ConstantPool::operand_array_length(operands); |
74bb7db916df
8009615: JvmtiClassFileReconstituter does not create BootstrapMethod attributes
sla
parents:
17294
diff
changeset
|
367 |
|
74bb7db916df
8009615: JvmtiClassFileReconstituter does not create BootstrapMethod attributes
sla
parents:
17294
diff
changeset
|
368 |
// calculate length of attribute |
17309
83ac929d332a
8014044: Spelling error in JDK-8009615: boostrapmethod
sla
parents:
17307
diff
changeset
|
369 |
int length = sizeof(u2); // num_bootstrap_methods |
17307
74bb7db916df
8009615: JvmtiClassFileReconstituter does not create BootstrapMethod attributes
sla
parents:
17294
diff
changeset
|
370 |
for (int n = 0; n < num_bootstrap_methods; n++) { |
74bb7db916df
8009615: JvmtiClassFileReconstituter does not create BootstrapMethod attributes
sla
parents:
17294
diff
changeset
|
371 |
u2 num_bootstrap_arguments = cpool()->operand_argument_count_at(n); |
74bb7db916df
8009615: JvmtiClassFileReconstituter does not create BootstrapMethod attributes
sla
parents:
17294
diff
changeset
|
372 |
length += sizeof(u2); // bootstrap_method_ref |
74bb7db916df
8009615: JvmtiClassFileReconstituter does not create BootstrapMethod attributes
sla
parents:
17294
diff
changeset
|
373 |
length += sizeof(u2); // num_bootstrap_arguments |
74bb7db916df
8009615: JvmtiClassFileReconstituter does not create BootstrapMethod attributes
sla
parents:
17294
diff
changeset
|
374 |
length += sizeof(u2) * num_bootstrap_arguments; // bootstrap_arguments[num_bootstrap_arguments] |
74bb7db916df
8009615: JvmtiClassFileReconstituter does not create BootstrapMethod attributes
sla
parents:
17294
diff
changeset
|
375 |
} |
74bb7db916df
8009615: JvmtiClassFileReconstituter does not create BootstrapMethod attributes
sla
parents:
17294
diff
changeset
|
376 |
write_u4(length); |
74bb7db916df
8009615: JvmtiClassFileReconstituter does not create BootstrapMethod attributes
sla
parents:
17294
diff
changeset
|
377 |
|
74bb7db916df
8009615: JvmtiClassFileReconstituter does not create BootstrapMethod attributes
sla
parents:
17294
diff
changeset
|
378 |
// write attribute |
74bb7db916df
8009615: JvmtiClassFileReconstituter does not create BootstrapMethod attributes
sla
parents:
17294
diff
changeset
|
379 |
write_u2(num_bootstrap_methods); |
74bb7db916df
8009615: JvmtiClassFileReconstituter does not create BootstrapMethod attributes
sla
parents:
17294
diff
changeset
|
380 |
for (int n = 0; n < num_bootstrap_methods; n++) { |
74bb7db916df
8009615: JvmtiClassFileReconstituter does not create BootstrapMethod attributes
sla
parents:
17294
diff
changeset
|
381 |
u2 bootstrap_method_ref = cpool()->operand_bootstrap_method_ref_index_at(n); |
74bb7db916df
8009615: JvmtiClassFileReconstituter does not create BootstrapMethod attributes
sla
parents:
17294
diff
changeset
|
382 |
u2 num_bootstrap_arguments = cpool()->operand_argument_count_at(n); |
74bb7db916df
8009615: JvmtiClassFileReconstituter does not create BootstrapMethod attributes
sla
parents:
17294
diff
changeset
|
383 |
write_u2(bootstrap_method_ref); |
74bb7db916df
8009615: JvmtiClassFileReconstituter does not create BootstrapMethod attributes
sla
parents:
17294
diff
changeset
|
384 |
write_u2(num_bootstrap_arguments); |
74bb7db916df
8009615: JvmtiClassFileReconstituter does not create BootstrapMethod attributes
sla
parents:
17294
diff
changeset
|
385 |
for (int arg = 0; arg < num_bootstrap_arguments; arg++) { |
74bb7db916df
8009615: JvmtiClassFileReconstituter does not create BootstrapMethod attributes
sla
parents:
17294
diff
changeset
|
386 |
u2 bootstrap_argument = cpool()->operand_argument_index_at(n, arg); |
74bb7db916df
8009615: JvmtiClassFileReconstituter does not create BootstrapMethod attributes
sla
parents:
17294
diff
changeset
|
387 |
write_u2(bootstrap_argument); |
74bb7db916df
8009615: JvmtiClassFileReconstituter does not create BootstrapMethod attributes
sla
parents:
17294
diff
changeset
|
388 |
} |
74bb7db916df
8009615: JvmtiClassFileReconstituter does not create BootstrapMethod attributes
sla
parents:
17294
diff
changeset
|
389 |
} |
74bb7db916df
8009615: JvmtiClassFileReconstituter does not create BootstrapMethod attributes
sla
parents:
17294
diff
changeset
|
390 |
} |
74bb7db916df
8009615: JvmtiClassFileReconstituter does not create BootstrapMethod attributes
sla
parents:
17294
diff
changeset
|
391 |
|
50735
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
49480
diff
changeset
|
392 |
// NestHost_attribute { |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
49480
diff
changeset
|
393 |
// u2 attribute_name_index; |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
49480
diff
changeset
|
394 |
// u4 attribute_length; |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
49480
diff
changeset
|
395 |
// u2 host_class_index; |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
49480
diff
changeset
|
396 |
// } |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
49480
diff
changeset
|
397 |
void JvmtiClassFileReconstituter::write_nest_host_attribute() { |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
49480
diff
changeset
|
398 |
int length = sizeof(u2); |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
49480
diff
changeset
|
399 |
int host_class_index = ik()->nest_host_index(); |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
49480
diff
changeset
|
400 |
|
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
49480
diff
changeset
|
401 |
write_attribute_name_index("NestHost"); |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
49480
diff
changeset
|
402 |
write_u4(length); |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
49480
diff
changeset
|
403 |
write_u2(host_class_index); |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
49480
diff
changeset
|
404 |
} |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
49480
diff
changeset
|
405 |
|
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
49480
diff
changeset
|
406 |
// NestMembers_attribute { |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
49480
diff
changeset
|
407 |
// u2 attribute_name_index; |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
49480
diff
changeset
|
408 |
// u4 attribute_length; |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
49480
diff
changeset
|
409 |
// u2 number_of_classes; |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
49480
diff
changeset
|
410 |
// u2 classes[number_of_classes]; |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
49480
diff
changeset
|
411 |
// } |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
49480
diff
changeset
|
412 |
void JvmtiClassFileReconstituter::write_nest_members_attribute() { |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
49480
diff
changeset
|
413 |
Array<u2>* nest_members = ik()->nest_members(); |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
49480
diff
changeset
|
414 |
int number_of_classes = nest_members->length(); |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
49480
diff
changeset
|
415 |
int length = sizeof(u2) * (1 + number_of_classes); |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
49480
diff
changeset
|
416 |
|
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
49480
diff
changeset
|
417 |
write_attribute_name_index("NestMembers"); |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
49480
diff
changeset
|
418 |
write_u4(length); |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
49480
diff
changeset
|
419 |
write_u2(number_of_classes); |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
49480
diff
changeset
|
420 |
for (int i = 0; i < number_of_classes; i++) { |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
49480
diff
changeset
|
421 |
u2 class_cp_index = nest_members->at(i); |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
49480
diff
changeset
|
422 |
write_u2(class_cp_index); |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
49480
diff
changeset
|
423 |
} |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
49480
diff
changeset
|
424 |
} |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
49480
diff
changeset
|
425 |
|
1 | 426 |
|
427 |
// Write InnerClasses attribute |
|
428 |
// JVMSpec| InnerClasses_attribute { |
|
429 |
// JVMSpec| u2 attribute_name_index; |
|
430 |
// JVMSpec| u4 attribute_length; |
|
431 |
// JVMSpec| u2 number_of_classes; |
|
432 |
// JVMSpec| { u2 inner_class_info_index; |
|
433 |
// JVMSpec| u2 outer_class_info_index; |
|
434 |
// JVMSpec| u2 inner_name_index; |
|
435 |
// JVMSpec| u2 inner_class_access_flags; |
|
436 |
// JVMSpec| } classes[number_of_classes]; |
|
437 |
// JVMSpec| } |
|
438 |
void JvmtiClassFileReconstituter::write_inner_classes_attribute(int length) { |
|
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
38031
diff
changeset
|
439 |
InnerClassesIterator iter(ik()); |
12231
6a9cfc59a18a
7109878: The instanceKlass EnclosingMethhod attribute fields can be folded into the _inner_class field.
jiangli
parents:
12102
diff
changeset
|
440 |
guarantee(iter.length() != 0 && iter.length() == length, |
1 | 441 |
"caller must check"); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13286
diff
changeset
|
442 |
u2 entry_count = length / InstanceKlass::inner_class_next_offset; |
1 | 443 |
u4 size = 2 + entry_count * (2+2+2+2); |
444 |
||
445 |
write_attribute_name_index("InnerClasses"); |
|
446 |
write_u4(size); |
|
447 |
write_u2(entry_count); |
|
12231
6a9cfc59a18a
7109878: The instanceKlass EnclosingMethhod attribute fields can be folded into the _inner_class field.
jiangli
parents:
12102
diff
changeset
|
448 |
for (; !iter.done(); iter.next()) { |
6a9cfc59a18a
7109878: The instanceKlass EnclosingMethhod attribute fields can be folded into the _inner_class field.
jiangli
parents:
12102
diff
changeset
|
449 |
write_u2(iter.inner_class_info_index()); |
6a9cfc59a18a
7109878: The instanceKlass EnclosingMethhod attribute fields can be folded into the _inner_class field.
jiangli
parents:
12102
diff
changeset
|
450 |
write_u2(iter.outer_class_info_index()); |
6a9cfc59a18a
7109878: The instanceKlass EnclosingMethhod attribute fields can be folded into the _inner_class field.
jiangli
parents:
12102
diff
changeset
|
451 |
write_u2(iter.inner_name_index()); |
6a9cfc59a18a
7109878: The instanceKlass EnclosingMethhod attribute fields can be folded into the _inner_class field.
jiangli
parents:
12102
diff
changeset
|
452 |
write_u2(iter.inner_access_flags()); |
1 | 453 |
} |
454 |
} |
|
455 |
||
456 |
// Write Synthetic attribute |
|
457 |
// JVMSpec| Synthetic_attribute { |
|
458 |
// JVMSpec| u2 attribute_name_index; |
|
459 |
// JVMSpec| u4 attribute_length; |
|
460 |
// JVMSpec| } |
|
461 |
void JvmtiClassFileReconstituter::write_synthetic_attribute() { |
|
462 |
write_attribute_name_index("Synthetic"); |
|
463 |
write_u4(0); //length always zero |
|
464 |
} |
|
465 |
||
466 |
// Compute size of LineNumberTable |
|
33593
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
27401
diff
changeset
|
467 |
u2 JvmtiClassFileReconstituter::line_number_table_entries(const methodHandle& method) { |
1 | 468 |
// The line number table is compressed so we don't know how big it is until decompressed. |
469 |
// Decompression is really fast so we just do it twice. |
|
470 |
u2 num_entries = 0; |
|
471 |
CompressedLineNumberReadStream stream(method->compressed_linenumber_table()); |
|
472 |
while (stream.read_pair()) { |
|
473 |
num_entries++; |
|
474 |
} |
|
475 |
return num_entries; |
|
476 |
} |
|
477 |
||
478 |
// Write LineNumberTable attribute |
|
479 |
// JVMSpec| LineNumberTable_attribute { |
|
480 |
// JVMSpec| u2 attribute_name_index; |
|
481 |
// JVMSpec| u4 attribute_length; |
|
482 |
// JVMSpec| u2 line_number_table_length; |
|
483 |
// JVMSpec| { u2 start_pc; |
|
484 |
// JVMSpec| u2 line_number; |
|
485 |
// JVMSpec| } line_number_table[line_number_table_length]; |
|
486 |
// JVMSpec| } |
|
33593
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
27401
diff
changeset
|
487 |
void JvmtiClassFileReconstituter::write_line_number_table_attribute(const methodHandle& method, |
1 | 488 |
u2 num_entries) { |
489 |
||
490 |
write_attribute_name_index("LineNumberTable"); |
|
491 |
write_u4(2 + num_entries * (2 + 2)); |
|
492 |
write_u2(num_entries); |
|
493 |
||
494 |
CompressedLineNumberReadStream stream(method->compressed_linenumber_table()); |
|
495 |
while (stream.read_pair()) { |
|
496 |
write_u2(stream.bci()); |
|
497 |
write_u2(stream.line()); |
|
498 |
} |
|
499 |
} |
|
500 |
||
13863
3a6dfc8fdfd1
7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents:
13728
diff
changeset
|
501 |
// Write LocalVariableTable attribute |
11257
b98dfa12a8f7
7064927: retransformClasses() does not pass in LocalVariableTable of a method
coleenp
parents:
10552
diff
changeset
|
502 |
// JVMSpec| LocalVariableTable_attribute { |
b98dfa12a8f7
7064927: retransformClasses() does not pass in LocalVariableTable of a method
coleenp
parents:
10552
diff
changeset
|
503 |
// JVMSpec| u2 attribute_name_index; |
b98dfa12a8f7
7064927: retransformClasses() does not pass in LocalVariableTable of a method
coleenp
parents:
10552
diff
changeset
|
504 |
// JVMSpec| u4 attribute_length; |
b98dfa12a8f7
7064927: retransformClasses() does not pass in LocalVariableTable of a method
coleenp
parents:
10552
diff
changeset
|
505 |
// JVMSpec| u2 local_variable_table_length; |
b98dfa12a8f7
7064927: retransformClasses() does not pass in LocalVariableTable of a method
coleenp
parents:
10552
diff
changeset
|
506 |
// JVMSpec| { u2 start_pc; |
b98dfa12a8f7
7064927: retransformClasses() does not pass in LocalVariableTable of a method
coleenp
parents:
10552
diff
changeset
|
507 |
// JVMSpec| u2 length; |
b98dfa12a8f7
7064927: retransformClasses() does not pass in LocalVariableTable of a method
coleenp
parents:
10552
diff
changeset
|
508 |
// JVMSpec| u2 name_index; |
b98dfa12a8f7
7064927: retransformClasses() does not pass in LocalVariableTable of a method
coleenp
parents:
10552
diff
changeset
|
509 |
// JVMSpec| u2 descriptor_index; |
b98dfa12a8f7
7064927: retransformClasses() does not pass in LocalVariableTable of a method
coleenp
parents:
10552
diff
changeset
|
510 |
// JVMSpec| u2 index; |
b98dfa12a8f7
7064927: retransformClasses() does not pass in LocalVariableTable of a method
coleenp
parents:
10552
diff
changeset
|
511 |
// JVMSpec| } local_variable_table[local_variable_table_length]; |
b98dfa12a8f7
7064927: retransformClasses() does not pass in LocalVariableTable of a method
coleenp
parents:
10552
diff
changeset
|
512 |
// JVMSpec| } |
33593
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
27401
diff
changeset
|
513 |
void JvmtiClassFileReconstituter::write_local_variable_table_attribute(const methodHandle& method, u2 num_entries) { |
11257
b98dfa12a8f7
7064927: retransformClasses() does not pass in LocalVariableTable of a method
coleenp
parents:
10552
diff
changeset
|
514 |
write_attribute_name_index("LocalVariableTable"); |
b98dfa12a8f7
7064927: retransformClasses() does not pass in LocalVariableTable of a method
coleenp
parents:
10552
diff
changeset
|
515 |
write_u4(2 + num_entries * (2 + 2 + 2 + 2 + 2)); |
b98dfa12a8f7
7064927: retransformClasses() does not pass in LocalVariableTable of a method
coleenp
parents:
10552
diff
changeset
|
516 |
write_u2(num_entries); |
b98dfa12a8f7
7064927: retransformClasses() does not pass in LocalVariableTable of a method
coleenp
parents:
10552
diff
changeset
|
517 |
|
b98dfa12a8f7
7064927: retransformClasses() does not pass in LocalVariableTable of a method
coleenp
parents:
10552
diff
changeset
|
518 |
assert(method->localvariable_table_length() == num_entries, "just checking"); |
b98dfa12a8f7
7064927: retransformClasses() does not pass in LocalVariableTable of a method
coleenp
parents:
10552
diff
changeset
|
519 |
|
b98dfa12a8f7
7064927: retransformClasses() does not pass in LocalVariableTable of a method
coleenp
parents:
10552
diff
changeset
|
520 |
LocalVariableTableElement *elem = method->localvariable_table_start(); |
b98dfa12a8f7
7064927: retransformClasses() does not pass in LocalVariableTable of a method
coleenp
parents:
10552
diff
changeset
|
521 |
for (int j=0; j<method->localvariable_table_length(); j++) { |
b98dfa12a8f7
7064927: retransformClasses() does not pass in LocalVariableTable of a method
coleenp
parents:
10552
diff
changeset
|
522 |
write_u2(elem->start_bci); |
b98dfa12a8f7
7064927: retransformClasses() does not pass in LocalVariableTable of a method
coleenp
parents:
10552
diff
changeset
|
523 |
write_u2(elem->length); |
b98dfa12a8f7
7064927: retransformClasses() does not pass in LocalVariableTable of a method
coleenp
parents:
10552
diff
changeset
|
524 |
write_u2(elem->name_cp_index); |
b98dfa12a8f7
7064927: retransformClasses() does not pass in LocalVariableTable of a method
coleenp
parents:
10552
diff
changeset
|
525 |
write_u2(elem->descriptor_cp_index); |
b98dfa12a8f7
7064927: retransformClasses() does not pass in LocalVariableTable of a method
coleenp
parents:
10552
diff
changeset
|
526 |
write_u2(elem->slot); |
b98dfa12a8f7
7064927: retransformClasses() does not pass in LocalVariableTable of a method
coleenp
parents:
10552
diff
changeset
|
527 |
elem++; |
b98dfa12a8f7
7064927: retransformClasses() does not pass in LocalVariableTable of a method
coleenp
parents:
10552
diff
changeset
|
528 |
} |
b98dfa12a8f7
7064927: retransformClasses() does not pass in LocalVariableTable of a method
coleenp
parents:
10552
diff
changeset
|
529 |
} |
b98dfa12a8f7
7064927: retransformClasses() does not pass in LocalVariableTable of a method
coleenp
parents:
10552
diff
changeset
|
530 |
|
13863
3a6dfc8fdfd1
7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents:
13728
diff
changeset
|
531 |
// Write LocalVariableTypeTable attribute |
3a6dfc8fdfd1
7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents:
13728
diff
changeset
|
532 |
// JVMSpec| LocalVariableTypeTable_attribute { |
3a6dfc8fdfd1
7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents:
13728
diff
changeset
|
533 |
// JVMSpec| u2 attribute_name_index; |
3a6dfc8fdfd1
7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents:
13728
diff
changeset
|
534 |
// JVMSpec| u4 attribute_length; |
3a6dfc8fdfd1
7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents:
13728
diff
changeset
|
535 |
// JVMSpec| u2 local_variable_type_table_length; |
3a6dfc8fdfd1
7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents:
13728
diff
changeset
|
536 |
// JVMSpec| { u2 start_pc; |
3a6dfc8fdfd1
7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents:
13728
diff
changeset
|
537 |
// JVMSpec| u2 length; |
3a6dfc8fdfd1
7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents:
13728
diff
changeset
|
538 |
// JVMSpec| u2 name_index; |
3a6dfc8fdfd1
7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents:
13728
diff
changeset
|
539 |
// JVMSpec| u2 signature_index; |
3a6dfc8fdfd1
7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents:
13728
diff
changeset
|
540 |
// JVMSpec| u2 index; |
3a6dfc8fdfd1
7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents:
13728
diff
changeset
|
541 |
// JVMSpec| } local_variable_type_table[local_variable_type_table_length]; |
3a6dfc8fdfd1
7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents:
13728
diff
changeset
|
542 |
// JVMSpec| } |
33593
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
27401
diff
changeset
|
543 |
void JvmtiClassFileReconstituter::write_local_variable_type_table_attribute(const methodHandle& method, u2 num_entries) { |
13863
3a6dfc8fdfd1
7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents:
13728
diff
changeset
|
544 |
write_attribute_name_index("LocalVariableTypeTable"); |
3a6dfc8fdfd1
7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents:
13728
diff
changeset
|
545 |
write_u4(2 + num_entries * (2 + 2 + 2 + 2 + 2)); |
3a6dfc8fdfd1
7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents:
13728
diff
changeset
|
546 |
write_u2(num_entries); |
3a6dfc8fdfd1
7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents:
13728
diff
changeset
|
547 |
|
3a6dfc8fdfd1
7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents:
13728
diff
changeset
|
548 |
LocalVariableTableElement *elem = method->localvariable_table_start(); |
3a6dfc8fdfd1
7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents:
13728
diff
changeset
|
549 |
for (int j=0; j<method->localvariable_table_length(); j++) { |
3a6dfc8fdfd1
7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents:
13728
diff
changeset
|
550 |
if (elem->signature_cp_index > 0) { |
3a6dfc8fdfd1
7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents:
13728
diff
changeset
|
551 |
// Local variable has a generic signature - write LVTT attribute entry |
3a6dfc8fdfd1
7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents:
13728
diff
changeset
|
552 |
write_u2(elem->start_bci); |
3a6dfc8fdfd1
7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents:
13728
diff
changeset
|
553 |
write_u2(elem->length); |
3a6dfc8fdfd1
7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents:
13728
diff
changeset
|
554 |
write_u2(elem->name_cp_index); |
3a6dfc8fdfd1
7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents:
13728
diff
changeset
|
555 |
write_u2(elem->signature_cp_index); |
3a6dfc8fdfd1
7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents:
13728
diff
changeset
|
556 |
write_u2(elem->slot); |
3a6dfc8fdfd1
7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents:
13728
diff
changeset
|
557 |
num_entries--; |
3a6dfc8fdfd1
7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents:
13728
diff
changeset
|
558 |
} |
3a6dfc8fdfd1
7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents:
13728
diff
changeset
|
559 |
elem++; |
3a6dfc8fdfd1
7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents:
13728
diff
changeset
|
560 |
} |
3a6dfc8fdfd1
7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents:
13728
diff
changeset
|
561 |
assert(num_entries == 0, "just checking"); |
3a6dfc8fdfd1
7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents:
13728
diff
changeset
|
562 |
} |
3a6dfc8fdfd1
7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents:
13728
diff
changeset
|
563 |
|
1 | 564 |
// Write stack map table attribute |
565 |
// JSR-202| StackMapTable_attribute { |
|
566 |
// JSR-202| u2 attribute_name_index; |
|
567 |
// JSR-202| u4 attribute_length; |
|
568 |
// JSR-202| u2 number_of_entries; |
|
569 |
// JSR-202| stack_map_frame_entries[number_of_entries]; |
|
570 |
// JSR-202| } |
|
33593
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
27401
diff
changeset
|
571 |
void JvmtiClassFileReconstituter::write_stackmap_table_attribute(const methodHandle& method, |
1 | 572 |
int stackmap_len) { |
573 |
||
574 |
write_attribute_name_index("StackMapTable"); |
|
575 |
write_u4(stackmap_len); |
|
576 |
memcpy( |
|
577 |
writeable_address(stackmap_len), |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13286
diff
changeset
|
578 |
(void*)(method->stackmap_data()->adr_at(0)), |
1 | 579 |
stackmap_len); |
580 |
} |
|
581 |
||
582 |
// Write one method_info structure |
|
583 |
// JVMSpec| method_info { |
|
584 |
// JVMSpec| u2 access_flags; |
|
585 |
// JVMSpec| u2 name_index; |
|
586 |
// JVMSpec| u2 descriptor_index; |
|
587 |
// JVMSpec| u2 attributes_count; |
|
588 |
// JVMSpec| attribute_info attributes[attributes_count]; |
|
589 |
// JVMSpec| } |
|
33593
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
27401
diff
changeset
|
590 |
void JvmtiClassFileReconstituter::write_method_info(const methodHandle& method) { |
1 | 591 |
AccessFlags access_flags = method->access_flags(); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13286
diff
changeset
|
592 |
ConstMethod* const_method = method->constMethod(); |
1 | 593 |
u2 generic_signature_index = const_method->generic_signature_index(); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13286
diff
changeset
|
594 |
AnnotationArray* anno = method->annotations(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13286
diff
changeset
|
595 |
AnnotationArray* param_anno = method->parameter_annotations(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13286
diff
changeset
|
596 |
AnnotationArray* default_anno = method->annotation_default(); |
27401
a4697c9502cb
8057043: Type annotations not retained during class redefine / retransform
aeriksso
parents:
25715
diff
changeset
|
597 |
AnnotationArray* type_anno = method->type_annotations(); |
1 | 598 |
|
17294
a1a03f4c1cab
8008453: JvmtiClassFileReconstituter does not recognize default methods
sla
parents:
14481
diff
changeset
|
599 |
// skip generated default interface methods |
a1a03f4c1cab
8008453: JvmtiClassFileReconstituter does not recognize default methods
sla
parents:
14481
diff
changeset
|
600 |
if (method->is_overpass()) { |
a1a03f4c1cab
8008453: JvmtiClassFileReconstituter does not recognize default methods
sla
parents:
14481
diff
changeset
|
601 |
return; |
a1a03f4c1cab
8008453: JvmtiClassFileReconstituter does not recognize default methods
sla
parents:
14481
diff
changeset
|
602 |
} |
a1a03f4c1cab
8008453: JvmtiClassFileReconstituter does not recognize default methods
sla
parents:
14481
diff
changeset
|
603 |
|
1 | 604 |
write_u2(access_flags.get_flags() & JVM_RECOGNIZED_METHOD_MODIFIERS); |
605 |
write_u2(const_method->name_index()); |
|
606 |
write_u2(const_method->signature_index()); |
|
607 |
||
608 |
// write attributes in the same order javac does, so we can test with byte for |
|
609 |
// byte comparison |
|
610 |
int attr_count = 0; |
|
611 |
if (const_method->code_size() != 0) { |
|
612 |
++attr_count; // has Code attribute |
|
613 |
} |
|
614 |
if (const_method->has_checked_exceptions()) { |
|
615 |
++attr_count; // has Exceptions attribute |
|
616 |
} |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13286
diff
changeset
|
617 |
if (default_anno != NULL) { |
1 | 618 |
++attr_count; // has AnnotationDefault attribute |
619 |
} |
|
620 |
// Deprecated attribute would go here |
|
621 |
if (access_flags.is_synthetic()) { // FIXME |
|
622 |
// ++attr_count; |
|
623 |
} |
|
624 |
if (generic_signature_index != 0) { |
|
625 |
++attr_count; |
|
626 |
} |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13286
diff
changeset
|
627 |
if (anno != NULL) { |
1 | 628 |
++attr_count; // has RuntimeVisibleAnnotations attribute |
629 |
} |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13286
diff
changeset
|
630 |
if (param_anno != NULL) { |
1 | 631 |
++attr_count; // has RuntimeVisibleParameterAnnotations attribute |
632 |
} |
|
27401
a4697c9502cb
8057043: Type annotations not retained during class redefine / retransform
aeriksso
parents:
25715
diff
changeset
|
633 |
if (type_anno != NULL) { |
a4697c9502cb
8057043: Type annotations not retained during class redefine / retransform
aeriksso
parents:
25715
diff
changeset
|
634 |
++attr_count; // has RuntimeVisibleTypeAnnotations attribute |
a4697c9502cb
8057043: Type annotations not retained during class redefine / retransform
aeriksso
parents:
25715
diff
changeset
|
635 |
} |
1 | 636 |
|
637 |
write_u2(attr_count); |
|
638 |
if (const_method->code_size() > 0) { |
|
639 |
write_code_attribute(method); |
|
640 |
} |
|
641 |
if (const_method->has_checked_exceptions()) { |
|
642 |
write_exceptions_attribute(const_method); |
|
643 |
} |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13286
diff
changeset
|
644 |
if (default_anno != NULL) { |
1 | 645 |
write_annotations_attribute("AnnotationDefault", default_anno); |
646 |
} |
|
647 |
// Deprecated attribute would go here |
|
648 |
if (access_flags.is_synthetic()) { |
|
649 |
// write_synthetic_attribute(); |
|
650 |
} |
|
651 |
if (generic_signature_index != 0) { |
|
652 |
write_signature_attribute(generic_signature_index); |
|
653 |
} |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13286
diff
changeset
|
654 |
if (anno != NULL) { |
1 | 655 |
write_annotations_attribute("RuntimeVisibleAnnotations", anno); |
656 |
} |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13286
diff
changeset
|
657 |
if (param_anno != NULL) { |
1 | 658 |
write_annotations_attribute("RuntimeVisibleParameterAnnotations", param_anno); |
659 |
} |
|
27401
a4697c9502cb
8057043: Type annotations not retained during class redefine / retransform
aeriksso
parents:
25715
diff
changeset
|
660 |
if (type_anno != NULL) { |
a4697c9502cb
8057043: Type annotations not retained during class redefine / retransform
aeriksso
parents:
25715
diff
changeset
|
661 |
write_annotations_attribute("RuntimeVisibleTypeAnnotations", type_anno); |
a4697c9502cb
8057043: Type annotations not retained during class redefine / retransform
aeriksso
parents:
25715
diff
changeset
|
662 |
} |
1 | 663 |
} |
664 |
||
665 |
// Write the class attributes portion of ClassFile structure |
|
666 |
// JVMSpec| u2 attributes_count; |
|
667 |
// JVMSpec| attribute_info attributes[attributes_count]; |
|
668 |
void JvmtiClassFileReconstituter::write_class_attributes() { |
|
669 |
u2 inner_classes_length = inner_classes_attribute_length(); |
|
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
38031
diff
changeset
|
670 |
Symbol* generic_signature = ik()->generic_signature(); |
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
38031
diff
changeset
|
671 |
AnnotationArray* anno = ik()->class_annotations(); |
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
38031
diff
changeset
|
672 |
AnnotationArray* type_anno = ik()->class_type_annotations(); |
1 | 673 |
|
674 |
int attr_count = 0; |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
675 |
if (generic_signature != NULL) { |
1 | 676 |
++attr_count; |
677 |
} |
|
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
38031
diff
changeset
|
678 |
if (ik()->source_file_name() != NULL) { |
1 | 679 |
++attr_count; |
680 |
} |
|
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
38031
diff
changeset
|
681 |
if (ik()->source_debug_extension() != NULL) { |
1 | 682 |
++attr_count; |
683 |
} |
|
684 |
if (inner_classes_length > 0) { |
|
685 |
++attr_count; |
|
686 |
} |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13286
diff
changeset
|
687 |
if (anno != NULL) { |
1 | 688 |
++attr_count; // has RuntimeVisibleAnnotations attribute |
689 |
} |
|
27401
a4697c9502cb
8057043: Type annotations not retained during class redefine / retransform
aeriksso
parents:
25715
diff
changeset
|
690 |
if (type_anno != NULL) { |
a4697c9502cb
8057043: Type annotations not retained during class redefine / retransform
aeriksso
parents:
25715
diff
changeset
|
691 |
++attr_count; // has RuntimeVisibleTypeAnnotations attribute |
a4697c9502cb
8057043: Type annotations not retained during class redefine / retransform
aeriksso
parents:
25715
diff
changeset
|
692 |
} |
17307
74bb7db916df
8009615: JvmtiClassFileReconstituter does not create BootstrapMethod attributes
sla
parents:
17294
diff
changeset
|
693 |
if (cpool()->operands() != NULL) { |
74bb7db916df
8009615: JvmtiClassFileReconstituter does not create BootstrapMethod attributes
sla
parents:
17294
diff
changeset
|
694 |
++attr_count; |
74bb7db916df
8009615: JvmtiClassFileReconstituter does not create BootstrapMethod attributes
sla
parents:
17294
diff
changeset
|
695 |
} |
50735
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
49480
diff
changeset
|
696 |
if (ik()->nest_host_index() != 0) { |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
49480
diff
changeset
|
697 |
++attr_count; |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
49480
diff
changeset
|
698 |
} |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
49480
diff
changeset
|
699 |
if (ik()->nest_members() != Universe::the_empty_short_array()) { |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
49480
diff
changeset
|
700 |
++attr_count; |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
49480
diff
changeset
|
701 |
} |
1 | 702 |
|
703 |
write_u2(attr_count); |
|
704 |
||
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
705 |
if (generic_signature != NULL) { |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
706 |
write_signature_attribute(symbol_to_cpool_index(generic_signature)); |
1 | 707 |
} |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
38031
diff
changeset
|
708 |
if (ik()->source_file_name() != NULL) { |
1 | 709 |
write_source_file_attribute(); |
710 |
} |
|
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
38031
diff
changeset
|
711 |
if (ik()->source_debug_extension() != NULL) { |
1 | 712 |
write_source_debug_extension_attribute(); |
713 |
} |
|
714 |
if (inner_classes_length > 0) { |
|
715 |
write_inner_classes_attribute(inner_classes_length); |
|
716 |
} |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13286
diff
changeset
|
717 |
if (anno != NULL) { |
1 | 718 |
write_annotations_attribute("RuntimeVisibleAnnotations", anno); |
719 |
} |
|
27401
a4697c9502cb
8057043: Type annotations not retained during class redefine / retransform
aeriksso
parents:
25715
diff
changeset
|
720 |
if (type_anno != NULL) { |
a4697c9502cb
8057043: Type annotations not retained during class redefine / retransform
aeriksso
parents:
25715
diff
changeset
|
721 |
write_annotations_attribute("RuntimeVisibleTypeAnnotations", type_anno); |
a4697c9502cb
8057043: Type annotations not retained during class redefine / retransform
aeriksso
parents:
25715
diff
changeset
|
722 |
} |
17307
74bb7db916df
8009615: JvmtiClassFileReconstituter does not create BootstrapMethod attributes
sla
parents:
17294
diff
changeset
|
723 |
if (cpool()->operands() != NULL) { |
17309
83ac929d332a
8014044: Spelling error in JDK-8009615: boostrapmethod
sla
parents:
17307
diff
changeset
|
724 |
write_bootstrapmethod_attribute(); |
17307
74bb7db916df
8009615: JvmtiClassFileReconstituter does not create BootstrapMethod attributes
sla
parents:
17294
diff
changeset
|
725 |
} |
50735
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
49480
diff
changeset
|
726 |
if (ik()->nest_host_index() != 0) { |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
49480
diff
changeset
|
727 |
write_nest_host_attribute(); |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
49480
diff
changeset
|
728 |
} |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
49480
diff
changeset
|
729 |
if (ik()->nest_members() != Universe::the_empty_short_array()) { |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
49480
diff
changeset
|
730 |
write_nest_members_attribute(); |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
49480
diff
changeset
|
731 |
} |
1 | 732 |
} |
733 |
||
734 |
// Write the method information portion of ClassFile structure |
|
735 |
// JVMSpec| u2 methods_count; |
|
736 |
// JVMSpec| method_info methods[methods_count]; |
|
737 |
void JvmtiClassFileReconstituter::write_method_infos() { |
|
738 |
HandleMark hm(thread()); |
|
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
38031
diff
changeset
|
739 |
Array<Method*>* methods = ik()->methods(); |
1 | 740 |
int num_methods = methods->length(); |
17294
a1a03f4c1cab
8008453: JvmtiClassFileReconstituter does not recognize default methods
sla
parents:
14481
diff
changeset
|
741 |
int num_overpass = 0; |
1 | 742 |
|
17294
a1a03f4c1cab
8008453: JvmtiClassFileReconstituter does not recognize default methods
sla
parents:
14481
diff
changeset
|
743 |
// count the generated default interface methods |
a1a03f4c1cab
8008453: JvmtiClassFileReconstituter does not recognize default methods
sla
parents:
14481
diff
changeset
|
744 |
// these will not be re-created by write_method_info |
a1a03f4c1cab
8008453: JvmtiClassFileReconstituter does not recognize default methods
sla
parents:
14481
diff
changeset
|
745 |
// and should not be included in the total count |
a1a03f4c1cab
8008453: JvmtiClassFileReconstituter does not recognize default methods
sla
parents:
14481
diff
changeset
|
746 |
for (int index = 0; index < num_methods; index++) { |
a1a03f4c1cab
8008453: JvmtiClassFileReconstituter does not recognize default methods
sla
parents:
14481
diff
changeset
|
747 |
Method* method = methods->at(index); |
a1a03f4c1cab
8008453: JvmtiClassFileReconstituter does not recognize default methods
sla
parents:
14481
diff
changeset
|
748 |
if (method->is_overpass()) { |
a1a03f4c1cab
8008453: JvmtiClassFileReconstituter does not recognize default methods
sla
parents:
14481
diff
changeset
|
749 |
num_overpass++; |
a1a03f4c1cab
8008453: JvmtiClassFileReconstituter does not recognize default methods
sla
parents:
14481
diff
changeset
|
750 |
} |
a1a03f4c1cab
8008453: JvmtiClassFileReconstituter does not recognize default methods
sla
parents:
14481
diff
changeset
|
751 |
} |
a1a03f4c1cab
8008453: JvmtiClassFileReconstituter does not recognize default methods
sla
parents:
14481
diff
changeset
|
752 |
|
a1a03f4c1cab
8008453: JvmtiClassFileReconstituter does not recognize default methods
sla
parents:
14481
diff
changeset
|
753 |
write_u2(num_methods - num_overpass); |
1 | 754 |
if (JvmtiExport::can_maintain_original_method_order()) { |
755 |
int index; |
|
756 |
int original_index; |
|
38031
e0b822facc03
8149374: Replace C1-specific collection classes with universal collection classes
fzhinkin
parents:
33593
diff
changeset
|
757 |
intArray method_order(num_methods, num_methods, 0); |
1 | 758 |
|
759 |
// invert the method order mapping |
|
760 |
for (index = 0; index < num_methods; index++) { |
|
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
38031
diff
changeset
|
761 |
original_index = ik()->method_ordering()->at(index); |
1 | 762 |
assert(original_index >= 0 && original_index < num_methods, |
763 |
"invalid original method index"); |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13286
diff
changeset
|
764 |
method_order.at_put(original_index, index); |
1 | 765 |
} |
766 |
||
767 |
// write in original order |
|
768 |
for (original_index = 0; original_index < num_methods; original_index++) { |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13286
diff
changeset
|
769 |
index = method_order.at(original_index); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13286
diff
changeset
|
770 |
methodHandle method(thread(), methods->at(index)); |
1 | 771 |
write_method_info(method); |
772 |
} |
|
773 |
} else { |
|
774 |
// method order not preserved just dump the method infos |
|
775 |
for (int index = 0; index < num_methods; index++) { |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13286
diff
changeset
|
776 |
methodHandle method(thread(), methods->at(index)); |
1 | 777 |
write_method_info(method); |
778 |
} |
|
779 |
} |
|
780 |
} |
|
781 |
||
782 |
void JvmtiClassFileReconstituter::write_class_file_format() { |
|
783 |
ReallocMark(); |
|
784 |
||
785 |
// JVMSpec| ClassFile { |
|
786 |
// JVMSpec| u4 magic; |
|
787 |
write_u4(0xCAFEBABE); |
|
788 |
||
789 |
// JVMSpec| u2 minor_version; |
|
790 |
// JVMSpec| u2 major_version; |
|
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
38031
diff
changeset
|
791 |
write_u2(ik()->minor_version()); |
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
38031
diff
changeset
|
792 |
u2 major = ik()->major_version(); |
1 | 793 |
write_u2(major); |
794 |
||
795 |
// JVMSpec| u2 constant_pool_count; |
|
796 |
// JVMSpec| cp_info constant_pool[constant_pool_count-1]; |
|
797 |
write_u2(cpool()->length()); |
|
798 |
copy_cpool_bytes(writeable_address(cpool_size())); |
|
799 |
||
800 |
// JVMSpec| u2 access_flags; |
|
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
38031
diff
changeset
|
801 |
write_u2(ik()->access_flags().get_flags() & JVM_RECOGNIZED_CLASS_MODIFIERS); |
1 | 802 |
|
803 |
// JVMSpec| u2 this_class; |
|
804 |
// JVMSpec| u2 super_class; |
|
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
38031
diff
changeset
|
805 |
write_u2(class_symbol_to_cpool_index(ik()->name())); |
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
38031
diff
changeset
|
806 |
Klass* super_class = ik()->super(); |
1 | 807 |
write_u2(super_class == NULL? 0 : // zero for java.lang.Object |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13286
diff
changeset
|
808 |
class_symbol_to_cpool_index(super_class->name())); |
1 | 809 |
|
810 |
// JVMSpec| u2 interfaces_count; |
|
811 |
// JVMSpec| u2 interfaces[interfaces_count]; |
|
51329
9c68699bebe5
8208999: Some use of Klass* should be replaced by InstanceKlass*
iklam
parents:
50735
diff
changeset
|
812 |
Array<InstanceKlass*>* interfaces = ik()->local_interfaces(); |
1 | 813 |
int num_interfaces = interfaces->length(); |
814 |
write_u2(num_interfaces); |
|
815 |
for (int index = 0; index < num_interfaces; index++) { |
|
816 |
HandleMark hm(thread()); |
|
51329
9c68699bebe5
8208999: Some use of Klass* should be replaced by InstanceKlass*
iklam
parents:
50735
diff
changeset
|
817 |
InstanceKlass* iik = interfaces->at(index); |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
38031
diff
changeset
|
818 |
write_u2(class_symbol_to_cpool_index(iik->name())); |
1 | 819 |
} |
820 |
||
821 |
// JVMSpec| u2 fields_count; |
|
822 |
// JVMSpec| field_info fields[fields_count]; |
|
823 |
write_field_infos(); |
|
824 |
||
825 |
// JVMSpec| u2 methods_count; |
|
826 |
// JVMSpec| method_info methods[methods_count]; |
|
827 |
write_method_infos(); |
|
828 |
||
829 |
// JVMSpec| u2 attributes_count; |
|
830 |
// JVMSpec| attribute_info attributes[attributes_count]; |
|
831 |
// JVMSpec| } /* end ClassFile 8? |
|
832 |
write_class_attributes(); |
|
833 |
} |
|
834 |
||
835 |
address JvmtiClassFileReconstituter::writeable_address(size_t size) { |
|
836 |
size_t used_size = _buffer_ptr - _buffer; |
|
837 |
if (size + used_size >= _buffer_size) { |
|
838 |
// compute the new buffer size: must be at least twice as big as before |
|
839 |
// plus whatever new is being used; then convert to nice clean block boundary |
|
840 |
size_t new_buffer_size = (size + _buffer_size*2 + 1) / initial_buffer_size |
|
841 |
* initial_buffer_size; |
|
842 |
||
843 |
// VM goes belly-up if the memory isn't available, so cannot do OOM processing |
|
844 |
_buffer = REALLOC_RESOURCE_ARRAY(u1, _buffer, _buffer_size, new_buffer_size); |
|
845 |
_buffer_size = new_buffer_size; |
|
846 |
_buffer_ptr = _buffer + used_size; |
|
847 |
} |
|
848 |
u1* ret_ptr = _buffer_ptr; |
|
849 |
_buffer_ptr += size; |
|
850 |
return ret_ptr; |
|
851 |
} |
|
852 |
||
853 |
void JvmtiClassFileReconstituter::write_attribute_name_index(const char* name) { |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
854 |
TempNewSymbol sym = SymbolTable::probe(name, (int)strlen(name)); |
1 | 855 |
assert(sym != NULL, "attribute name symbol not found"); |
856 |
u2 attr_name_index = symbol_to_cpool_index(sym); |
|
857 |
assert(attr_name_index != 0, "attribute name symbol not in constant pool"); |
|
858 |
write_u2(attr_name_index); |
|
859 |
} |
|
860 |
||
861 |
void JvmtiClassFileReconstituter::write_u1(u1 x) { |
|
862 |
*writeable_address(1) = x; |
|
863 |
} |
|
864 |
||
865 |
void JvmtiClassFileReconstituter::write_u2(u2 x) { |
|
866 |
Bytes::put_Java_u2(writeable_address(2), x); |
|
867 |
} |
|
868 |
||
869 |
void JvmtiClassFileReconstituter::write_u4(u4 x) { |
|
870 |
Bytes::put_Java_u4(writeable_address(4), x); |
|
871 |
} |
|
872 |
||
873 |
void JvmtiClassFileReconstituter::write_u8(u8 x) { |
|
874 |
Bytes::put_Java_u8(writeable_address(8), x); |
|
875 |
} |
|
876 |
||
33593
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
27401
diff
changeset
|
877 |
void JvmtiClassFileReconstituter::copy_bytecodes(const methodHandle& mh, |
1 | 878 |
unsigned char* bytecodes) { |
879 |
// use a BytecodeStream to iterate over the bytecodes. JVM/fast bytecodes |
|
880 |
// and the breakpoint bytecode are converted to their original bytecodes. |
|
881 |
||
882 |
BytecodeStream bs(mh); |
|
883 |
||
884 |
unsigned char* p = bytecodes; |
|
885 |
Bytecodes::Code code; |
|
14391
df0a1573d5bd
8000725: NPG: method_holder() and pool_holder() and pool_holder field should be InstanceKlass
coleenp
parents:
13863
diff
changeset
|
886 |
bool is_rewritten = mh->method_holder()->is_rewritten(); |
1 | 887 |
|
888 |
while ((code = bs.next()) >= 0) { |
|
889 |
assert(Bytecodes::is_java_code(code), "sanity check"); |
|
890 |
assert(code != Bytecodes::_breakpoint, "sanity check"); |
|
891 |
||
892 |
// length of bytecode (mnemonic + operands) |
|
893 |
address bcp = bs.bcp(); |
|
5688 | 894 |
int len = bs.instruction_size(); |
1 | 895 |
assert(len > 0, "length must be > 0"); |
896 |
||
897 |
// copy the bytecodes |
|
898 |
*p = (unsigned char) (bs.is_wide()? Bytecodes::_wide : code); |
|
899 |
if (len > 1) { |
|
900 |
memcpy(p+1, bcp+1, len-1); |
|
901 |
} |
|
902 |
||
903 |
// During linking the get/put and invoke instructions are rewritten |
|
904 |
// with an index into the constant pool cache. The original constant |
|
905 |
// pool index must be returned to caller. Rewrite the index. |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13286
diff
changeset
|
906 |
if (is_rewritten && len > 1) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13286
diff
changeset
|
907 |
bool is_wide = false; |
1 | 908 |
switch (code) { |
909 |
case Bytecodes::_getstatic : // fall through |
|
910 |
case Bytecodes::_putstatic : // fall through |
|
911 |
case Bytecodes::_getfield : // fall through |
|
912 |
case Bytecodes::_putfield : // fall through |
|
913 |
case Bytecodes::_invokevirtual : // fall through |
|
914 |
case Bytecodes::_invokespecial : // fall through |
|
915 |
case Bytecodes::_invokestatic : // fall through |
|
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
1
diff
changeset
|
916 |
case Bytecodes::_invokedynamic : // fall through |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13286
diff
changeset
|
917 |
case Bytecodes::_invokeinterface : { |
12102
7a1c6c80bc23
7118280: The gbyc00102 JCK7 test causes an assert in JVM 7.0 fastdebug mode
dsamersoff
parents:
11257
diff
changeset
|
918 |
assert(len == 3 || |
7a1c6c80bc23
7118280: The gbyc00102 JCK7 test causes an assert in JVM 7.0 fastdebug mode
dsamersoff
parents:
11257
diff
changeset
|
919 |
(code == Bytecodes::_invokeinterface && len == 5) || |
7a1c6c80bc23
7118280: The gbyc00102 JCK7 test causes an assert in JVM 7.0 fastdebug mode
dsamersoff
parents:
11257
diff
changeset
|
920 |
(code == Bytecodes::_invokedynamic && len == 5), |
1 | 921 |
"sanity check"); |
12102
7a1c6c80bc23
7118280: The gbyc00102 JCK7 test causes an assert in JVM 7.0 fastdebug mode
dsamersoff
parents:
11257
diff
changeset
|
922 |
|
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
1
diff
changeset
|
923 |
int cpci = Bytes::get_native_u2(bcp+1); |
24322 | 924 |
bool is_invokedynamic = (code == Bytecodes::_invokedynamic); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13286
diff
changeset
|
925 |
ConstantPoolCacheEntry* entry; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13286
diff
changeset
|
926 |
if (is_invokedynamic) { |
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
1
diff
changeset
|
927 |
cpci = Bytes::get_native_u4(bcp+1); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13286
diff
changeset
|
928 |
entry = mh->constants()->invokedynamic_cp_cache_entry_at(cpci); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13286
diff
changeset
|
929 |
} else { |
1 | 930 |
// cache cannot be pre-fetched since some classes won't have it yet |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13286
diff
changeset
|
931 |
entry = mh->constants()->cache()->entry_at(cpci); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13286
diff
changeset
|
932 |
} |
1 | 933 |
int i = entry->constant_pool_index(); |
934 |
assert(i < mh->constants()->length(), "sanity check"); |
|
935 |
Bytes::put_Java_u2((address)(p+1), (u2)i); // java byte ordering |
|
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
1
diff
changeset
|
936 |
if (is_invokedynamic) *(p+3) = *(p+4) = 0; |
1 | 937 |
break; |
938 |
} |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13286
diff
changeset
|
939 |
case Bytecodes::_ldc_w: |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13286
diff
changeset
|
940 |
is_wide = true; // fall through |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13286
diff
changeset
|
941 |
case Bytecodes::_ldc: { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13286
diff
changeset
|
942 |
if (bs.raw_code() == Bytecodes::_fast_aldc || bs.raw_code() == Bytecodes::_fast_aldc_w) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13286
diff
changeset
|
943 |
int cpci = is_wide ? Bytes::get_native_u2(bcp+1) : (u1)(*(bcp+1)); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13286
diff
changeset
|
944 |
int i = mh->constants()->object_to_cp_index(cpci); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13286
diff
changeset
|
945 |
assert(i < mh->constants()->length(), "sanity check"); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13286
diff
changeset
|
946 |
if (is_wide) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13286
diff
changeset
|
947 |
Bytes::put_Java_u2((address)(p+1), (u2)i); // java byte ordering |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13286
diff
changeset
|
948 |
} else { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13286
diff
changeset
|
949 |
*(p+1) = (u1)i; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13286
diff
changeset
|
950 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13286
diff
changeset
|
951 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13286
diff
changeset
|
952 |
break; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13286
diff
changeset
|
953 |
} |
46630
75aa3e39d02c
8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents:
46329
diff
changeset
|
954 |
default: |
75aa3e39d02c
8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents:
46329
diff
changeset
|
955 |
break; |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13286
diff
changeset
|
956 |
} |
1 | 957 |
} |
958 |
||
959 |
p += len; |
|
960 |
} |
|
961 |
} |