annotate src/share/vm/prims/jvmtiClassFileReconstituter.hpp @ 10241:d17700c82d7d

8006088: Incompatible heap size flags accepted by VM Summary: Make processing of minimum, initial and maximum heap size more intiutive by removing previous limitations on allowed values, and make error reporting consistent. Further, fix errors in ergonomic heap sizing. Reviewed-by: johnc, jwilhelm, tamao
author tschatzl
date Mon, 06 May 2013 17:19:42 +0200
parents 1cb8583c3da8
children 187154b7a226
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6197
diff changeset
2 * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
25 #ifndef SHARE_VM_PRIMS_JVMTICLASSFILERECONSTITUTER_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
26 #define SHARE_VM_PRIMS_JVMTICLASSFILERECONSTITUTER_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
27
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
28 #include "jvmtifiles/jvmtiEnv.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
29
0
a61af66fc99e Initial load
duke
parents:
diff changeset
30
a61af66fc99e Initial load
duke
parents:
diff changeset
31 class JvmtiConstantPoolReconstituter : public StackObj {
a61af66fc99e Initial load
duke
parents:
diff changeset
32 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
33 int _cpool_size;
a61af66fc99e Initial load
duke
parents:
diff changeset
34 SymbolHashMap* _symmap;
a61af66fc99e Initial load
duke
parents:
diff changeset
35 SymbolHashMap* _classmap;
a61af66fc99e Initial load
duke
parents:
diff changeset
36 constantPoolHandle _cpool;
a61af66fc99e Initial load
duke
parents:
diff changeset
37 instanceKlassHandle _ikh;
a61af66fc99e Initial load
duke
parents:
diff changeset
38 jvmtiError _err;
a61af66fc99e Initial load
duke
parents:
diff changeset
39
a61af66fc99e Initial load
duke
parents:
diff changeset
40 protected:
a61af66fc99e Initial load
duke
parents:
diff changeset
41 instanceKlassHandle ikh() { return _ikh; };
a61af66fc99e Initial load
duke
parents:
diff changeset
42 constantPoolHandle cpool() { return _cpool; };
a61af66fc99e Initial load
duke
parents:
diff changeset
43
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
44 u2 symbol_to_cpool_index(Symbol* sym) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
45 return _symmap->symbol_to_value(sym);
a61af66fc99e Initial load
duke
parents:
diff changeset
46 }
a61af66fc99e Initial load
duke
parents:
diff changeset
47
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
48 u2 class_symbol_to_cpool_index(Symbol* sym) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
49 return _classmap->symbol_to_value(sym);
a61af66fc99e Initial load
duke
parents:
diff changeset
50 }
a61af66fc99e Initial load
duke
parents:
diff changeset
51
a61af66fc99e Initial load
duke
parents:
diff changeset
52 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
53 // Calls to this constructor must be proceeded by a ResourceMark
a61af66fc99e Initial load
duke
parents:
diff changeset
54 // and a HandleMark
a61af66fc99e Initial load
duke
parents:
diff changeset
55 JvmtiConstantPoolReconstituter(instanceKlassHandle ikh){
a61af66fc99e Initial load
duke
parents:
diff changeset
56 set_error(JVMTI_ERROR_NONE);
a61af66fc99e Initial load
duke
parents:
diff changeset
57 _ikh = ikh;
a61af66fc99e Initial load
duke
parents:
diff changeset
58 _cpool = constantPoolHandle(Thread::current(), ikh->constants());
a61af66fc99e Initial load
duke
parents:
diff changeset
59 _symmap = new SymbolHashMap();
a61af66fc99e Initial load
duke
parents:
diff changeset
60 _classmap = new SymbolHashMap();
a61af66fc99e Initial load
duke
parents:
diff changeset
61 _cpool_size = _cpool->hash_entries_to(_symmap, _classmap);
a61af66fc99e Initial load
duke
parents:
diff changeset
62 if (_cpool_size == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
63 set_error(JVMTI_ERROR_OUT_OF_MEMORY);
a61af66fc99e Initial load
duke
parents:
diff changeset
64 } else if (_cpool_size < 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
65 set_error(JVMTI_ERROR_INTERNAL);
a61af66fc99e Initial load
duke
parents:
diff changeset
66 }
a61af66fc99e Initial load
duke
parents:
diff changeset
67 }
a61af66fc99e Initial load
duke
parents:
diff changeset
68
a61af66fc99e Initial load
duke
parents:
diff changeset
69 ~JvmtiConstantPoolReconstituter() {
a61af66fc99e Initial load
duke
parents:
diff changeset
70 if (_symmap != NULL) {
6197
d2a62e0f25eb 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 4718
diff changeset
71 os::free(_symmap, mtClass);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
72 _symmap = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
73 }
a61af66fc99e Initial load
duke
parents:
diff changeset
74 if (_classmap != NULL) {
6197
d2a62e0f25eb 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 4718
diff changeset
75 os::free(_classmap, mtClass);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
76 _classmap = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
77 }
a61af66fc99e Initial load
duke
parents:
diff changeset
78 }
a61af66fc99e Initial load
duke
parents:
diff changeset
79
a61af66fc99e Initial load
duke
parents:
diff changeset
80
a61af66fc99e Initial load
duke
parents:
diff changeset
81 void set_error(jvmtiError err) { _err = err; }
a61af66fc99e Initial load
duke
parents:
diff changeset
82 jvmtiError get_error() { return _err; }
a61af66fc99e Initial load
duke
parents:
diff changeset
83
a61af66fc99e Initial load
duke
parents:
diff changeset
84 int cpool_size() { return _cpool_size; }
a61af66fc99e Initial load
duke
parents:
diff changeset
85
a61af66fc99e Initial load
duke
parents:
diff changeset
86 void copy_cpool_bytes(unsigned char *cpool_bytes) {
a61af66fc99e Initial load
duke
parents:
diff changeset
87 if (cpool_bytes == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
88 assert(cpool_bytes != NULL, "cpool_bytes pointer must not be NULL");
a61af66fc99e Initial load
duke
parents:
diff changeset
89 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
90 }
a61af66fc99e Initial load
duke
parents:
diff changeset
91 cpool()->copy_cpool_bytes(cpool_size(), _symmap, cpool_bytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
92 }
a61af66fc99e Initial load
duke
parents:
diff changeset
93 };
a61af66fc99e Initial load
duke
parents:
diff changeset
94
a61af66fc99e Initial load
duke
parents:
diff changeset
95
a61af66fc99e Initial load
duke
parents:
diff changeset
96 class JvmtiClassFileReconstituter : public JvmtiConstantPoolReconstituter {
a61af66fc99e Initial load
duke
parents:
diff changeset
97 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
98 size_t _buffer_size;
a61af66fc99e Initial load
duke
parents:
diff changeset
99 u1* _buffer;
a61af66fc99e Initial load
duke
parents:
diff changeset
100 u1* _buffer_ptr;
a61af66fc99e Initial load
duke
parents:
diff changeset
101 Thread* _thread;
a61af66fc99e Initial load
duke
parents:
diff changeset
102
a61af66fc99e Initial load
duke
parents:
diff changeset
103 enum {
a61af66fc99e Initial load
duke
parents:
diff changeset
104 // initial size should be power of two
a61af66fc99e Initial load
duke
parents:
diff changeset
105 initial_buffer_size = 1024
a61af66fc99e Initial load
duke
parents:
diff changeset
106 };
a61af66fc99e Initial load
duke
parents:
diff changeset
107
a61af66fc99e Initial load
duke
parents:
diff changeset
108 inline Thread* thread() { return _thread; }
a61af66fc99e Initial load
duke
parents:
diff changeset
109
a61af66fc99e Initial load
duke
parents:
diff changeset
110 void write_class_file_format();
a61af66fc99e Initial load
duke
parents:
diff changeset
111 void write_field_infos();
a61af66fc99e Initial load
duke
parents:
diff changeset
112 void write_method_infos();
a61af66fc99e Initial load
duke
parents:
diff changeset
113 void write_method_info(methodHandle method);
a61af66fc99e Initial load
duke
parents:
diff changeset
114 void write_code_attribute(methodHandle method);
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6197
diff changeset
115 void write_exceptions_attribute(ConstMethod* const_method);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
116 void write_synthetic_attribute();
a61af66fc99e Initial load
duke
parents:
diff changeset
117 void write_class_attributes();
a61af66fc99e Initial load
duke
parents:
diff changeset
118 void write_source_file_attribute();
a61af66fc99e Initial load
duke
parents:
diff changeset
119 void write_source_debug_extension_attribute();
a61af66fc99e Initial load
duke
parents:
diff changeset
120 u2 line_number_table_entries(methodHandle method);
a61af66fc99e Initial load
duke
parents:
diff changeset
121 void write_line_number_table_attribute(methodHandle method, u2 num_entries);
4718
c01e115b095e 7064927: retransformClasses() does not pass in LocalVariableTable of a method
coleenp
parents: 2426
diff changeset
122 void write_local_variable_table_attribute(methodHandle method, u2 num_entries);
6772
1cb8583c3da8 7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents: 6725
diff changeset
123 void write_local_variable_type_table_attribute(methodHandle method, u2 num_entries);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
124 void write_stackmap_table_attribute(methodHandle method, int stackmap_table_len);
a61af66fc99e Initial load
duke
parents:
diff changeset
125 u2 inner_classes_attribute_length();
a61af66fc99e Initial load
duke
parents:
diff changeset
126 void write_inner_classes_attribute(int length);
a61af66fc99e Initial load
duke
parents:
diff changeset
127 void write_signature_attribute(u2 generic_signaure_index);
a61af66fc99e Initial load
duke
parents:
diff changeset
128 void write_attribute_name_index(const char* name);
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6197
diff changeset
129 void write_annotations_attribute(const char* attr_name, AnnotationArray* annos);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
130
a61af66fc99e Initial load
duke
parents:
diff changeset
131 address writeable_address(size_t size);
a61af66fc99e Initial load
duke
parents:
diff changeset
132 void write_u1(u1 x);
a61af66fc99e Initial load
duke
parents:
diff changeset
133 void write_u2(u2 x);
a61af66fc99e Initial load
duke
parents:
diff changeset
134 void write_u4(u4 x);
a61af66fc99e Initial load
duke
parents:
diff changeset
135 void write_u8(u8 x);
a61af66fc99e Initial load
duke
parents:
diff changeset
136
a61af66fc99e Initial load
duke
parents:
diff changeset
137 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
138 // Calls to this constructor must be proceeded by a ResourceMark
a61af66fc99e Initial load
duke
parents:
diff changeset
139 // and a HandleMark
a61af66fc99e Initial load
duke
parents:
diff changeset
140 JvmtiClassFileReconstituter(instanceKlassHandle ikh) :
a61af66fc99e Initial load
duke
parents:
diff changeset
141 JvmtiConstantPoolReconstituter(ikh) {
a61af66fc99e Initial load
duke
parents:
diff changeset
142 _buffer_size = initial_buffer_size;
a61af66fc99e Initial load
duke
parents:
diff changeset
143 _buffer = _buffer_ptr = NEW_RESOURCE_ARRAY(u1, _buffer_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
144 _thread = Thread::current();
a61af66fc99e Initial load
duke
parents:
diff changeset
145 write_class_file_format();
a61af66fc99e Initial load
duke
parents:
diff changeset
146 };
a61af66fc99e Initial load
duke
parents:
diff changeset
147
a61af66fc99e Initial load
duke
parents:
diff changeset
148 size_t class_file_size() { return _buffer_ptr - _buffer; }
a61af66fc99e Initial load
duke
parents:
diff changeset
149
a61af66fc99e Initial load
duke
parents:
diff changeset
150 u1* class_file_bytes() { return _buffer; }
a61af66fc99e Initial load
duke
parents:
diff changeset
151
a61af66fc99e Initial load
duke
parents:
diff changeset
152 static void copy_bytecodes(methodHandle method, unsigned char* bytecodes);
a61af66fc99e Initial load
duke
parents:
diff changeset
153 };
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
154
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
155 #endif // SHARE_VM_PRIMS_JVMTICLASSFILERECONSTITUTER_HPP