Mercurial > hg > truffle
annotate src/share/vm/classfile/verifier.hpp @ 11722:ff05c78a7f64
use time passed to decide what methods to compile or inline
author | Christian Wirth <christian.wirth@oracle.com> |
---|---|
date | Thu, 19 Sep 2013 10:36:56 +0200 |
parents | ef57c43512d6 |
children | 22eaa15b7960 |
rev | line source |
---|---|
0 | 1 /* |
10265
92ef81e2f571
8003557: NPG: Klass* const k should be const Klass* k.
minqi
parents:
6725
diff
changeset
|
2 * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. |
0 | 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 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
973
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
973
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:
973
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
1972 | 25 #ifndef SHARE_VM_CLASSFILE_VERIFIER_HPP |
26 #define SHARE_VM_CLASSFILE_VERIFIER_HPP | |
27 | |
28 #include "classfile/verificationType.hpp" | |
29 #include "memory/gcLocker.hpp" | |
30 #include "oops/klass.hpp" | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6605
diff
changeset
|
31 #include "oops/method.hpp" |
1972 | 32 #include "runtime/handles.hpp" |
33 #include "utilities/exceptions.hpp" | |
34 | |
0 | 35 // The verifier class |
36 class Verifier : AllStatic { | |
37 public: | |
1602 | 38 enum { |
10381
4552a7633a07
8015385: Remove RelaxAccessControlCheck for JDK 8 bytecodes
hseigel
parents:
10265
diff
changeset
|
39 STRICTER_ACCESS_CTRL_CHECK_VERSION = 49, |
1602 | 40 STACKMAP_ATTRIBUTE_MAJOR_VERSION = 50, |
10381
4552a7633a07
8015385: Remove RelaxAccessControlCheck for JDK 8 bytecodes
hseigel
parents:
10265
diff
changeset
|
41 INVOKEDYNAMIC_MAJOR_VERSION = 51, |
4552a7633a07
8015385: Remove RelaxAccessControlCheck for JDK 8 bytecodes
hseigel
parents:
10265
diff
changeset
|
42 NO_RELAX_ACCESS_CTRL_CHECK_VERSION = 52 |
1602 | 43 }; |
0 | 44 typedef enum { ThrowException, NoException } Mode; |
45 | |
46 /** | |
47 * Verify the bytecodes for a class. If 'throw_exception' is true | |
48 * then the appropriate VerifyError or ClassFormatError will be thrown. | |
49 * Otherwise, no exception is thrown and the return indicates the | |
50 * error. | |
51 */ | |
973
ad6585fd4087
6830542: Performance: JVM_DefineClass already verified.
acorn
parents:
0
diff
changeset
|
52 static bool verify(instanceKlassHandle klass, Mode mode, bool should_verify_class, TRAPS); |
0 | 53 |
973
ad6585fd4087
6830542: Performance: JVM_DefineClass already verified.
acorn
parents:
0
diff
changeset
|
54 // Return false if the class is loaded by the bootstrap loader, |
ad6585fd4087
6830542: Performance: JVM_DefineClass already verified.
acorn
parents:
0
diff
changeset
|
55 // or if defineClass was called requesting skipping verification |
ad6585fd4087
6830542: Performance: JVM_DefineClass already verified.
acorn
parents:
0
diff
changeset
|
56 // -Xverify:all/none override this value |
ad6585fd4087
6830542: Performance: JVM_DefineClass already verified.
acorn
parents:
0
diff
changeset
|
57 static bool should_verify_for(oop class_loader, bool should_verify_class); |
0 | 58 |
59 // Relax certain verifier checks to enable some broken 1.1 apps to run on 1.2. | |
60 static bool relax_verify_for(oop class_loader); | |
61 | |
62 private: | |
973
ad6585fd4087
6830542: Performance: JVM_DefineClass already verified.
acorn
parents:
0
diff
changeset
|
63 static bool is_eligible_for_verification(instanceKlassHandle klass, bool should_verify_class); |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
64 static Symbol* inference_verify( |
0 | 65 instanceKlassHandle klass, char* msg, size_t msg_len, TRAPS); |
66 }; | |
67 | |
68 class RawBytecodeStream; | |
69 class StackMapFrame; | |
70 class StackMapTable; | |
71 | |
72 // Summary of verifier's memory usage: | |
73 // StackMapTable is stack allocated. | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
74 // StackMapFrame are resource allocated. There is only one ResourceMark |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
75 // for each class verification, which is created at the top level. |
0 | 76 // There is one mutable StackMapFrame (current_frame) which is updated |
77 // by abstract bytecode interpretation. frame_in_exception_handler() returns | |
78 // a frame that has a mutable one-item stack (ready for pushing the | |
79 // catch type exception object). All the other StackMapFrame's | |
80 // are immutable (including their locals and stack arrays) after | |
81 // their constructions. | |
82 // locals/stack arrays in StackMapFrame are resource allocated. | |
83 // locals/stack arrays can be shared between StackMapFrame's, except | |
84 // the mutable StackMapFrame (current_frame). | |
85 | |
86 // These macros are used similarly to CHECK macros but also check | |
87 // the status of the verifier and return if that has an error. | |
88 #define CHECK_VERIFY(verifier) \ | |
10973
ef57c43512d6
8014431: cleanup warnings indicated by the -Wunused-value compiler option on linux
ccheung
parents:
10381
diff
changeset
|
89 CHECK); if ((verifier)->has_error()) return; ((void)0 |
0 | 90 #define CHECK_VERIFY_(verifier, result) \ |
10973
ef57c43512d6
8014431: cleanup warnings indicated by the -Wunused-value compiler option on linux
ccheung
parents:
10381
diff
changeset
|
91 CHECK_(result)); if ((verifier)->has_error()) return (result); ((void)0 |
0 | 92 |
6605 | 93 class TypeOrigin VALUE_OBJ_CLASS_SPEC { |
94 private: | |
95 typedef enum { | |
96 CF_LOCALS, // Comes from the current frame locals | |
97 CF_STACK, // Comes from the current frame expression stack | |
98 SM_LOCALS, // Comes from stackmap locals | |
99 SM_STACK, // Comes from stackmap expression stack | |
100 CONST_POOL, // Comes from the constant pool | |
101 SIG, // Comes from method signature | |
102 IMPLICIT, // Comes implicitly from code or context | |
103 BAD_INDEX, // No type, but the index is bad | |
104 FRAME_ONLY, // No type, context just contains the frame | |
105 NONE | |
106 } Origin; | |
107 | |
108 Origin _origin; | |
109 u2 _index; // local, stack, or constant pool index | |
110 StackMapFrame* _frame; // source frame if CF or SM | |
111 VerificationType _type; // The actual type | |
112 | |
113 TypeOrigin( | |
114 Origin origin, u2 index, StackMapFrame* frame, VerificationType type) | |
115 : _origin(origin), _index(index), _frame(frame), _type(type) {} | |
116 | |
117 public: | |
118 TypeOrigin() : _origin(NONE), _index(0), _frame(NULL) {} | |
119 | |
120 static TypeOrigin null(); | |
121 static TypeOrigin local(u2 index, StackMapFrame* frame); | |
122 static TypeOrigin stack(u2 index, StackMapFrame* frame); | |
123 static TypeOrigin sm_local(u2 index, StackMapFrame* frame); | |
124 static TypeOrigin sm_stack(u2 index, StackMapFrame* frame); | |
125 static TypeOrigin cp(u2 index, VerificationType vt); | |
126 static TypeOrigin signature(VerificationType vt); | |
127 static TypeOrigin bad_index(u2 index); | |
128 static TypeOrigin implicit(VerificationType t); | |
129 static TypeOrigin frame(StackMapFrame* frame); | |
130 | |
131 void reset_frame(); | |
132 void details(outputStream* ss) const; | |
133 void print_frame(outputStream* ss) const; | |
134 const StackMapFrame* frame() const { return _frame; } | |
135 bool is_valid() const { return _origin != NONE; } | |
136 u2 index() const { return _index; } | |
137 | |
138 #ifdef ASSERT | |
139 void print_on(outputStream* str) const; | |
140 #endif | |
141 }; | |
142 | |
143 class ErrorContext VALUE_OBJ_CLASS_SPEC { | |
144 private: | |
145 typedef enum { | |
146 INVALID_BYTECODE, // There was a problem with the bytecode | |
147 WRONG_TYPE, // Type value was not as expected | |
148 FLAGS_MISMATCH, // Frame flags are not assignable | |
149 BAD_CP_INDEX, // Invalid constant pool index | |
150 BAD_LOCAL_INDEX, // Invalid local index | |
151 LOCALS_SIZE_MISMATCH, // Frames have differing local counts | |
152 STACK_SIZE_MISMATCH, // Frames have different stack sizes | |
153 STACK_OVERFLOW, // Attempt to push onto a full expression stack | |
154 STACK_UNDERFLOW, // Attempt to pop and empty expression stack | |
155 MISSING_STACKMAP, // No stackmap for this location and there should be | |
156 BAD_STACKMAP, // Format error in stackmap | |
157 NO_FAULT, // No error | |
158 UNKNOWN | |
159 } FaultType; | |
160 | |
161 int _bci; | |
162 FaultType _fault; | |
163 TypeOrigin _type; | |
164 TypeOrigin _expected; | |
165 | |
166 ErrorContext(int bci, FaultType fault) : | |
167 _bci(bci), _fault(fault) {} | |
168 ErrorContext(int bci, FaultType fault, TypeOrigin type) : | |
169 _bci(bci), _fault(fault), _type(type) {} | |
170 ErrorContext(int bci, FaultType fault, TypeOrigin type, TypeOrigin exp) : | |
171 _bci(bci), _fault(fault), _type(type), _expected(exp) {} | |
172 | |
173 public: | |
174 ErrorContext() : _bci(-1), _fault(NO_FAULT) {} | |
175 | |
176 static ErrorContext bad_code(u2 bci) { | |
177 return ErrorContext(bci, INVALID_BYTECODE); | |
178 } | |
179 static ErrorContext bad_type(u2 bci, TypeOrigin type) { | |
180 return ErrorContext(bci, WRONG_TYPE, type); | |
181 } | |
182 static ErrorContext bad_type(u2 bci, TypeOrigin type, TypeOrigin exp) { | |
183 return ErrorContext(bci, WRONG_TYPE, type, exp); | |
184 } | |
185 static ErrorContext bad_flags(u2 bci, StackMapFrame* frame) { | |
186 return ErrorContext(bci, FLAGS_MISMATCH, TypeOrigin::frame(frame)); | |
187 } | |
188 static ErrorContext bad_flags(u2 bci, StackMapFrame* cur, StackMapFrame* sm) { | |
189 return ErrorContext(bci, FLAGS_MISMATCH, | |
190 TypeOrigin::frame(cur), TypeOrigin::frame(sm)); | |
191 } | |
192 static ErrorContext bad_cp_index(u2 bci, u2 index) { | |
193 return ErrorContext(bci, BAD_CP_INDEX, TypeOrigin::bad_index(index)); | |
194 } | |
195 static ErrorContext bad_local_index(u2 bci, u2 index) { | |
196 return ErrorContext(bci, BAD_LOCAL_INDEX, TypeOrigin::bad_index(index)); | |
197 } | |
198 static ErrorContext locals_size_mismatch( | |
199 u2 bci, StackMapFrame* frame0, StackMapFrame* frame1) { | |
200 return ErrorContext(bci, LOCALS_SIZE_MISMATCH, | |
201 TypeOrigin::frame(frame0), TypeOrigin::frame(frame1)); | |
202 } | |
203 static ErrorContext stack_size_mismatch( | |
204 u2 bci, StackMapFrame* frame0, StackMapFrame* frame1) { | |
205 return ErrorContext(bci, STACK_SIZE_MISMATCH, | |
206 TypeOrigin::frame(frame0), TypeOrigin::frame(frame1)); | |
207 } | |
208 static ErrorContext stack_overflow(u2 bci, StackMapFrame* frame) { | |
209 return ErrorContext(bci, STACK_OVERFLOW, TypeOrigin::frame(frame)); | |
210 } | |
211 static ErrorContext stack_underflow(u2 bci, StackMapFrame* frame) { | |
212 return ErrorContext(bci, STACK_UNDERFLOW, TypeOrigin::frame(frame)); | |
213 } | |
214 static ErrorContext missing_stackmap(u2 bci) { | |
215 return ErrorContext(bci, MISSING_STACKMAP); | |
216 } | |
217 static ErrorContext bad_stackmap(int index, StackMapFrame* frame) { | |
218 return ErrorContext(0, BAD_STACKMAP, TypeOrigin::frame(frame)); | |
219 } | |
220 | |
221 bool is_valid() const { return _fault != NO_FAULT; } | |
222 int bci() const { return _bci; } | |
223 | |
224 void reset_frames() { | |
225 _type.reset_frame(); | |
226 _expected.reset_frame(); | |
227 } | |
228 | |
10265
92ef81e2f571
8003557: NPG: Klass* const k should be const Klass* k.
minqi
parents:
6725
diff
changeset
|
229 void details(outputStream* ss, const Method* method) const; |
6605 | 230 |
231 #ifdef ASSERT | |
232 void print_on(outputStream* str) const { | |
233 str->print("error_context(%d, %d,", _bci, _fault); | |
234 _type.print_on(str); | |
235 str->print(","); | |
236 _expected.print_on(str); | |
237 str->print(")"); | |
238 } | |
239 #endif | |
240 | |
241 private: | |
10265
92ef81e2f571
8003557: NPG: Klass* const k should be const Klass* k.
minqi
parents:
6725
diff
changeset
|
242 void location_details(outputStream* ss, const Method* method) const; |
6605 | 243 void reason_details(outputStream* ss) const; |
244 void frame_details(outputStream* ss) const; | |
10265
92ef81e2f571
8003557: NPG: Klass* const k should be const Klass* k.
minqi
parents:
6725
diff
changeset
|
245 void bytecode_details(outputStream* ss, const Method* method) const; |
92ef81e2f571
8003557: NPG: Klass* const k should be const Klass* k.
minqi
parents:
6725
diff
changeset
|
246 void handler_details(outputStream* ss, const Method* method) const; |
92ef81e2f571
8003557: NPG: Klass* const k should be const Klass* k.
minqi
parents:
6725
diff
changeset
|
247 void stackmap_details(outputStream* ss, const Method* method) const; |
6605 | 248 }; |
249 | |
0 | 250 // A new instance of this class is created for each class being verified |
251 class ClassVerifier : public StackObj { | |
252 private: | |
253 Thread* _thread; | |
6605 | 254 GrowableArray<Symbol*>* _symbols; // keep a list of symbols created |
255 | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
256 Symbol* _exception_type; |
0 | 257 char* _message; |
6605 | 258 |
259 ErrorContext _error_context; // contains information about an error | |
0 | 260 |
261 void verify_method(methodHandle method, TRAPS); | |
262 char* generate_code_data(methodHandle m, u4 code_length, TRAPS); | |
6605 | 263 void verify_exception_handler_table(u4 code_length, char* code_data, |
264 int& min, int& max, TRAPS); | |
0 | 265 void verify_local_variable_table(u4 code_length, char* code_data, TRAPS); |
266 | |
267 VerificationType cp_ref_index_to_type( | |
268 int index, constantPoolHandle cp, TRAPS) { | |
269 return cp_index_to_type(cp->klass_ref_index_at(index), cp, THREAD); | |
270 } | |
271 | |
272 bool is_protected_access( | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6605
diff
changeset
|
273 instanceKlassHandle this_class, Klass* target_class, |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
274 Symbol* field_name, Symbol* field_sig, bool is_method); |
0 | 275 |
6605 | 276 void verify_cp_index(u2 bci, constantPoolHandle cp, int index, TRAPS); |
277 void verify_cp_type(u2 bci, int index, constantPoolHandle cp, | |
278 unsigned int types, TRAPS); | |
279 void verify_cp_class_type(u2 bci, int index, constantPoolHandle cp, TRAPS); | |
0 | 280 |
281 u2 verify_stackmap_table( | |
282 u2 stackmap_index, u2 bci, StackMapFrame* current_frame, | |
283 StackMapTable* stackmap_table, bool no_control_flow, TRAPS); | |
284 | |
285 void verify_exception_handler_targets( | |
286 u2 bci, bool this_uninit, StackMapFrame* current_frame, | |
287 StackMapTable* stackmap_table, TRAPS); | |
288 | |
289 void verify_ldc( | |
290 int opcode, u2 index, StackMapFrame *current_frame, | |
291 constantPoolHandle cp, u2 bci, TRAPS); | |
292 | |
293 void verify_switch( | |
294 RawBytecodeStream* bcs, u4 code_length, char* code_data, | |
295 StackMapFrame* current_frame, StackMapTable* stackmap_table, TRAPS); | |
296 | |
297 void verify_field_instructions( | |
298 RawBytecodeStream* bcs, StackMapFrame* current_frame, | |
299 constantPoolHandle cp, TRAPS); | |
300 | |
301 void verify_invoke_init( | |
6605 | 302 RawBytecodeStream* bcs, u2 ref_index, VerificationType ref_class_type, |
0 | 303 StackMapFrame* current_frame, u4 code_length, bool* this_uninit, |
304 constantPoolHandle cp, TRAPS); | |
305 | |
306 void verify_invoke_instructions( | |
307 RawBytecodeStream* bcs, u4 code_length, StackMapFrame* current_frame, | |
308 bool* this_uninit, VerificationType return_type, | |
309 constantPoolHandle cp, TRAPS); | |
310 | |
311 VerificationType get_newarray_type(u2 index, u2 bci, TRAPS); | |
6605 | 312 void verify_anewarray(u2 bci, u2 index, constantPoolHandle cp, |
313 StackMapFrame* current_frame, TRAPS); | |
0 | 314 void verify_return_value( |
6605 | 315 VerificationType return_type, VerificationType type, u2 offset, |
316 StackMapFrame* current_frame, TRAPS); | |
0 | 317 |
318 void verify_iload (u2 index, StackMapFrame* current_frame, TRAPS); | |
319 void verify_lload (u2 index, StackMapFrame* current_frame, TRAPS); | |
320 void verify_fload (u2 index, StackMapFrame* current_frame, TRAPS); | |
321 void verify_dload (u2 index, StackMapFrame* current_frame, TRAPS); | |
322 void verify_aload (u2 index, StackMapFrame* current_frame, TRAPS); | |
323 void verify_istore(u2 index, StackMapFrame* current_frame, TRAPS); | |
324 void verify_lstore(u2 index, StackMapFrame* current_frame, TRAPS); | |
325 void verify_fstore(u2 index, StackMapFrame* current_frame, TRAPS); | |
326 void verify_dstore(u2 index, StackMapFrame* current_frame, TRAPS); | |
327 void verify_astore(u2 index, StackMapFrame* current_frame, TRAPS); | |
328 void verify_iinc (u2 index, StackMapFrame* current_frame, TRAPS); | |
329 | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
330 bool name_in_supers(Symbol* ref_name, instanceKlassHandle current); |
0 | 331 |
1955
1070423b51f3
6865028: Illegal instructions passing verification prior to 'invokespecial Object.<init>'
kamg
parents:
1602
diff
changeset
|
332 VerificationType object_type() const; |
1070423b51f3
6865028: Illegal instructions passing verification prior to 'invokespecial Object.<init>'
kamg
parents:
1602
diff
changeset
|
333 |
0 | 334 instanceKlassHandle _klass; // the class being verified |
335 methodHandle _method; // current method being verified | |
336 VerificationType _this_type; // the verification type of the current class | |
337 | |
1570 | 338 // Some recursive calls from the verifier to the name resolver |
339 // can cause the current class to be re-verified and rewritten. | |
340 // If this happens, the original verification should not continue, | |
341 // because constant pool indexes will have changed. | |
342 // The rewriter is preceded by the verifier. If the verifier throws | |
343 // an error, rewriting is prevented. Also, rewriting always precedes | |
344 // bytecode execution or compilation. Thus, is_rewritten implies | |
345 // that a class has been verified and prepared for execution. | |
346 bool was_recursively_verified() { return _klass->is_rewritten(); } | |
347 | |
0 | 348 public: |
349 enum { | |
350 BYTECODE_OFFSET = 1, | |
351 NEW_OFFSET = 2 | |
352 }; | |
353 | |
354 // constructor | |
6605 | 355 ClassVerifier(instanceKlassHandle klass, TRAPS); |
0 | 356 |
357 // destructor | |
358 ~ClassVerifier(); | |
359 | |
360 Thread* thread() { return _thread; } | |
361 methodHandle method() { return _method; } | |
362 instanceKlassHandle current_class() const { return _klass; } | |
363 VerificationType current_type() const { return _this_type; } | |
364 | |
365 // Verifies the class. If a verify or class file format error occurs, | |
366 // the '_exception_name' symbols will set to the exception name and | |
367 // the message_buffer will be filled in with the exception message. | |
368 void verify_class(TRAPS); | |
369 | |
370 // Return status modes | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
371 Symbol* result() const { return _exception_type; } |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
372 bool has_error() const { return result() != NULL; } |
6605 | 373 char* exception_message() { |
374 stringStream ss; | |
375 ss.print(_message); | |
376 _error_context.details(&ss, _method()); | |
377 return ss.as_string(); | |
378 } | |
0 | 379 |
380 // Called when verify or class format errors are encountered. | |
381 // May throw an exception based upon the mode. | |
6605 | 382 void verify_error(ErrorContext ctx, const char* fmt, ...); |
0 | 383 void class_format_error(const char* fmt, ...); |
384 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6605
diff
changeset
|
385 Klass* load_class(Symbol* name, TRAPS); |
0 | 386 |
387 int change_sig_to_verificationType( | |
388 SignatureStream* sig_type, VerificationType* inference_type, TRAPS); | |
389 | |
390 VerificationType cp_index_to_type(int index, constantPoolHandle cp, TRAPS) { | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
391 return VerificationType::reference_type(cp->klass_name_at(index)); |
0 | 392 } |
393 | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
394 // Keep a list of temporary symbols created during verification because |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
395 // their reference counts need to be decrememented when the verifier object |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
396 // goes out of scope. Since these symbols escape the scope in which they're |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
397 // created, we can't use a TempNewSymbol. |
6605 | 398 Symbol* create_temporary_symbol( |
399 const Symbol* s, int begin, int end, TRAPS); | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
400 Symbol* create_temporary_symbol(const char *s, int length, TRAPS); |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
401 |
6605 | 402 TypeOrigin ref_ctx(const char* str, TRAPS); |
0 | 403 }; |
404 | |
405 inline int ClassVerifier::change_sig_to_verificationType( | |
406 SignatureStream* sig_type, VerificationType* inference_type, TRAPS) { | |
407 BasicType bt = sig_type->type(); | |
408 switch (bt) { | |
409 case T_OBJECT: | |
410 case T_ARRAY: | |
411 { | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
412 Symbol* name = sig_type->as_symbol(CHECK_0); |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
413 // Create another symbol to save as signature stream unreferences |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
414 // this symbol. |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
415 Symbol* name_copy = |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
416 create_temporary_symbol(name, 0, name->utf8_length(), CHECK_0); |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
417 assert(name_copy == name, "symbols don't match"); |
0 | 418 *inference_type = |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
419 VerificationType::reference_type(name_copy); |
0 | 420 return 1; |
421 } | |
422 case T_LONG: | |
423 *inference_type = VerificationType::long_type(); | |
424 *++inference_type = VerificationType::long2_type(); | |
425 return 2; | |
426 case T_DOUBLE: | |
427 *inference_type = VerificationType::double_type(); | |
428 *++inference_type = VerificationType::double2_type(); | |
429 return 2; | |
430 case T_INT: | |
431 case T_BOOLEAN: | |
432 case T_BYTE: | |
433 case T_CHAR: | |
434 case T_SHORT: | |
435 *inference_type = VerificationType::integer_type(); | |
436 return 1; | |
437 case T_FLOAT: | |
438 *inference_type = VerificationType::float_type(); | |
439 return 1; | |
440 default: | |
441 ShouldNotReachHere(); | |
442 return 1; | |
443 } | |
444 } | |
1972 | 445 |
446 #endif // SHARE_VM_CLASSFILE_VERIFIER_HPP |