author | gziemski |
Mon, 23 Apr 2018 10:59:39 -0500 | |
changeset 49857 | 31e07291ae29 |
parent 49449 | ef5d5d343e2a |
child 50735 | 2f2af62dfac7 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
33593
diff
changeset
|
2 |
* Copyright (c) 2005, 2017, 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 |
#ifndef SHARE_VM_PRIMS_JVMTICLASSFILERECONSTITUTER_HPP |
26 |
#define SHARE_VM_PRIMS_JVMTICLASSFILERECONSTITUTER_HPP |
|
27 |
||
28 |
#include "jvmtifiles/jvmtiEnv.hpp" |
|
29 |
||
1 | 30 |
|
31 |
class JvmtiConstantPoolReconstituter : public StackObj { |
|
32 |
private: |
|
33 |
int _cpool_size; |
|
34 |
SymbolHashMap* _symmap; |
|
35 |
SymbolHashMap* _classmap; |
|
36 |
constantPoolHandle _cpool; |
|
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
33593
diff
changeset
|
37 |
InstanceKlass* _ik; |
1 | 38 |
jvmtiError _err; |
39 |
||
40 |
protected: |
|
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
33593
diff
changeset
|
41 |
InstanceKlass* ik() { return _ik; }; |
1 | 42 |
constantPoolHandle cpool() { return _cpool; }; |
43 |
||
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
44 |
u2 symbol_to_cpool_index(Symbol* sym) { |
1 | 45 |
return _symmap->symbol_to_value(sym); |
46 |
} |
|
47 |
||
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
48 |
u2 class_symbol_to_cpool_index(Symbol* sym) { |
1 | 49 |
return _classmap->symbol_to_value(sym); |
50 |
} |
|
51 |
||
52 |
public: |
|
53 |
// Calls to this constructor must be proceeded by a ResourceMark |
|
54 |
// and a HandleMark |
|
49449
ef5d5d343e2a
8199263: Split interfaceSupport.hpp to not require including .inline.hpp files
coleenp
parents:
47216
diff
changeset
|
55 |
JvmtiConstantPoolReconstituter(InstanceKlass* ik); |
1 | 56 |
|
57 |
~JvmtiConstantPoolReconstituter() { |
|
58 |
if (_symmap != NULL) { |
|
28625 | 59 |
delete _symmap; |
1 | 60 |
_symmap = NULL; |
61 |
} |
|
62 |
if (_classmap != NULL) { |
|
28625 | 63 |
delete _classmap; |
1 | 64 |
_classmap = NULL; |
65 |
} |
|
66 |
} |
|
67 |
||
68 |
||
69 |
void set_error(jvmtiError err) { _err = err; } |
|
70 |
jvmtiError get_error() { return _err; } |
|
71 |
||
72 |
int cpool_size() { return _cpool_size; } |
|
73 |
||
74 |
void copy_cpool_bytes(unsigned char *cpool_bytes) { |
|
75 |
if (cpool_bytes == NULL) { |
|
76 |
assert(cpool_bytes != NULL, "cpool_bytes pointer must not be NULL"); |
|
77 |
return; |
|
78 |
} |
|
79 |
cpool()->copy_cpool_bytes(cpool_size(), _symmap, cpool_bytes); |
|
80 |
} |
|
81 |
}; |
|
82 |
||
83 |
||
84 |
class JvmtiClassFileReconstituter : public JvmtiConstantPoolReconstituter { |
|
85 |
private: |
|
86 |
size_t _buffer_size; |
|
87 |
u1* _buffer; |
|
88 |
u1* _buffer_ptr; |
|
89 |
Thread* _thread; |
|
90 |
||
91 |
enum { |
|
92 |
// initial size should be power of two |
|
93 |
initial_buffer_size = 1024 |
|
94 |
}; |
|
95 |
||
96 |
inline Thread* thread() { return _thread; } |
|
97 |
||
98 |
void write_class_file_format(); |
|
99 |
void write_field_infos(); |
|
100 |
void write_method_infos(); |
|
33593
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
28625
diff
changeset
|
101 |
void write_method_info(const methodHandle& method); |
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
28625
diff
changeset
|
102 |
void write_code_attribute(const methodHandle& method); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
103 |
void write_exceptions_attribute(ConstMethod* const_method); |
1 | 104 |
void write_synthetic_attribute(); |
105 |
void write_class_attributes(); |
|
106 |
void write_source_file_attribute(); |
|
107 |
void write_source_debug_extension_attribute(); |
|
33593
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
28625
diff
changeset
|
108 |
u2 line_number_table_entries(const methodHandle& method); |
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
28625
diff
changeset
|
109 |
void write_line_number_table_attribute(const methodHandle& method, u2 num_entries); |
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
28625
diff
changeset
|
110 |
void write_local_variable_table_attribute(const methodHandle& method, u2 num_entries); |
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
28625
diff
changeset
|
111 |
void write_local_variable_type_table_attribute(const methodHandle& method, u2 num_entries); |
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
28625
diff
changeset
|
112 |
void write_stackmap_table_attribute(const methodHandle& method, int stackmap_table_len); |
1 | 113 |
u2 inner_classes_attribute_length(); |
114 |
void write_inner_classes_attribute(int length); |
|
115 |
void write_signature_attribute(u2 generic_signaure_index); |
|
116 |
void write_attribute_name_index(const char* name); |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
117 |
void write_annotations_attribute(const char* attr_name, AnnotationArray* annos); |
17309
83ac929d332a
8014044: Spelling error in JDK-8009615: boostrapmethod
sla
parents:
17307
diff
changeset
|
118 |
void write_bootstrapmethod_attribute(); |
1 | 119 |
|
120 |
address writeable_address(size_t size); |
|
121 |
void write_u1(u1 x); |
|
122 |
void write_u2(u2 x); |
|
123 |
void write_u4(u4 x); |
|
124 |
void write_u8(u8 x); |
|
125 |
||
126 |
public: |
|
127 |
// Calls to this constructor must be proceeded by a ResourceMark |
|
128 |
// and a HandleMark |
|
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
33593
diff
changeset
|
129 |
JvmtiClassFileReconstituter(InstanceKlass* ik) : |
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
33593
diff
changeset
|
130 |
JvmtiConstantPoolReconstituter(ik) { |
1 | 131 |
_buffer_size = initial_buffer_size; |
132 |
_buffer = _buffer_ptr = NEW_RESOURCE_ARRAY(u1, _buffer_size); |
|
133 |
_thread = Thread::current(); |
|
134 |
write_class_file_format(); |
|
135 |
}; |
|
136 |
||
137 |
size_t class_file_size() { return _buffer_ptr - _buffer; } |
|
138 |
||
139 |
u1* class_file_bytes() { return _buffer; } |
|
140 |
||
33593
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
28625
diff
changeset
|
141 |
static void copy_bytecodes(const methodHandle& method, unsigned char* bytecodes); |
1 | 142 |
}; |
7397 | 143 |
|
144 |
#endif // SHARE_VM_PRIMS_JVMTICLASSFILERECONSTITUTER_HPP |