author | hseigel |
Wed, 07 May 2014 19:34:48 +0400 | |
changeset 25508 | 3b6775dd6f41 |
parent 25505 | 9bd829aeb960 |
child 25509 | 2677915ac7ef |
permissions | -rw-r--r-- |
1 | 1 |
/* |
23999
22eb7be3d99d
8033150: invokestatic: IncompatibleClassChangeError trying to invoke static method from a parent in presence of conflicting defaults.
lfoltan
parents:
21768
diff
changeset
|
2 |
* Copyright (c) 1998, 2014, 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:
4571
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
4571
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:
4571
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#include "precompiled.hpp" |
26 |
#include "classfile/classFileStream.hpp" |
|
27 |
#include "classfile/javaClasses.hpp" |
|
28 |
#include "classfile/stackMapTable.hpp" |
|
13476 | 29 |
#include "classfile/stackMapFrame.hpp" |
30 |
#include "classfile/stackMapTableFormat.hpp" |
|
7397 | 31 |
#include "classfile/systemDictionary.hpp" |
32 |
#include "classfile/verifier.hpp" |
|
33 |
#include "classfile/vmSymbols.hpp" |
|
13476 | 34 |
#include "interpreter/bytecodes.hpp" |
7397 | 35 |
#include "interpreter/bytecodeStream.hpp" |
36 |
#include "memory/oopFactory.hpp" |
|
37 |
#include "memory/resourceArea.hpp" |
|
38 |
#include "oops/instanceKlass.hpp" |
|
39 |
#include "oops/oop.inline.hpp" |
|
40 |
#include "oops/typeArrayOop.hpp" |
|
41 |
#include "prims/jvm.h" |
|
42 |
#include "runtime/fieldDescriptor.hpp" |
|
43 |
#include "runtime/handles.inline.hpp" |
|
44 |
#include "runtime/interfaceSupport.hpp" |
|
45 |
#include "runtime/javaCalls.hpp" |
|
24351
61b33cc6d3cf
8042195: Introduce umbrella header orderAccess.inline.hpp.
goetz
parents:
24322
diff
changeset
|
46 |
#include "runtime/orderAccess.inline.hpp" |
7397 | 47 |
#include "runtime/os.hpp" |
48 |
#ifdef TARGET_ARCH_x86 |
|
49 |
# include "bytes_x86.hpp" |
|
50 |
#endif |
|
51 |
#ifdef TARGET_ARCH_sparc |
|
52 |
# include "bytes_sparc.hpp" |
|
53 |
#endif |
|
54 |
#ifdef TARGET_ARCH_zero |
|
55 |
# include "bytes_zero.hpp" |
|
56 |
#endif |
|
8107
78e5bd944384
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
8076
diff
changeset
|
57 |
#ifdef TARGET_ARCH_arm |
78e5bd944384
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
8076
diff
changeset
|
58 |
# include "bytes_arm.hpp" |
78e5bd944384
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
8076
diff
changeset
|
59 |
#endif |
78e5bd944384
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
8076
diff
changeset
|
60 |
#ifdef TARGET_ARCH_ppc |
78e5bd944384
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
8076
diff
changeset
|
61 |
# include "bytes_ppc.hpp" |
78e5bd944384
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
8076
diff
changeset
|
62 |
#endif |
1 | 63 |
|
16442
a929bb40c0e8
8010667: Non-zero padding is not allowed in splitverifier for tableswitch/lookupswitch instructions.
hseigel
parents:
15736
diff
changeset
|
64 |
#define NOFAILOVER_MAJOR_VERSION 51 |
a929bb40c0e8
8010667: Non-zero padding is not allowed in splitverifier for tableswitch/lookupswitch instructions.
hseigel
parents:
15736
diff
changeset
|
65 |
#define NONZERO_PADDING_BYTES_IN_SWITCH_MAJOR_VERSION 51 |
16676
ea5bba2e47e9
8011671: JCK tests on static interface methods fail under b84: Illegal type at constant pool entry 5
bharadwaj
parents:
16445
diff
changeset
|
66 |
#define STATIC_METHOD_IN_INTERFACE_MAJOR_VERSION 52 |
5683
116fea597b5d
6911922: JVM must throw VerifyError for jsr or jsr_w opcodes in class file v.51+
kamg
parents:
4571
diff
changeset
|
67 |
|
1 | 68 |
// Access to external entry for VerifyClassCodes - old byte code verifier |
69 |
||
70 |
extern "C" { |
|
71 |
typedef jboolean (*verify_byte_codes_fn_t)(JNIEnv *, jclass, char *, jint); |
|
72 |
typedef jboolean (*verify_byte_codes_fn_new_t)(JNIEnv *, jclass, char *, jint, jint); |
|
73 |
} |
|
74 |
||
75 |
static void* volatile _verify_byte_codes_fn = NULL; |
|
76 |
||
77 |
static volatile jint _is_new_verify_byte_codes_fn = (jint) true; |
|
78 |
||
79 |
static void* verify_byte_codes_fn() { |
|
80 |
if (_verify_byte_codes_fn == NULL) { |
|
81 |
void *lib_handle = os::native_java_library(); |
|
7405
e6fc8d3926f8
6348631: remove the use of the HPI library from Hotspot
ikrylov
parents:
7397
diff
changeset
|
82 |
void *func = os::dll_lookup(lib_handle, "VerifyClassCodesForMajorVersion"); |
1 | 83 |
OrderAccess::release_store_ptr(&_verify_byte_codes_fn, func); |
84 |
if (func == NULL) { |
|
85 |
OrderAccess::release_store(&_is_new_verify_byte_codes_fn, false); |
|
7405
e6fc8d3926f8
6348631: remove the use of the HPI library from Hotspot
ikrylov
parents:
7397
diff
changeset
|
86 |
func = os::dll_lookup(lib_handle, "VerifyClassCodes"); |
1 | 87 |
OrderAccess::release_store_ptr(&_verify_byte_codes_fn, func); |
88 |
} |
|
89 |
} |
|
90 |
return (void*)_verify_byte_codes_fn; |
|
91 |
} |
|
92 |
||
93 |
||
94 |
// Methods in Verifier |
|
95 |
||
3820
0a8fbbe180db
6830542: Performance: JVM_DefineClass already verified.
acorn
parents:
3261
diff
changeset
|
96 |
bool Verifier::should_verify_for(oop class_loader, bool should_verify_class) { |
0a8fbbe180db
6830542: Performance: JVM_DefineClass already verified.
acorn
parents:
3261
diff
changeset
|
97 |
return (class_loader == NULL || !should_verify_class) ? |
1 | 98 |
BytecodeVerificationLocal : BytecodeVerificationRemote; |
99 |
} |
|
100 |
||
101 |
bool Verifier::relax_verify_for(oop loader) { |
|
102 |
bool trusted = java_lang_ClassLoader::is_trusted_loader(loader); |
|
103 |
bool need_verify = |
|
104 |
// verifyAll |
|
105 |
(BytecodeVerificationLocal && BytecodeVerificationRemote) || |
|
106 |
// verifyRemote |
|
107 |
(!BytecodeVerificationLocal && BytecodeVerificationRemote && !trusted); |
|
108 |
return !need_verify; |
|
109 |
} |
|
110 |
||
3820
0a8fbbe180db
6830542: Performance: JVM_DefineClass already verified.
acorn
parents:
3261
diff
changeset
|
111 |
bool Verifier::verify(instanceKlassHandle klass, Verifier::Mode mode, bool should_verify_class, TRAPS) { |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7405
diff
changeset
|
112 |
HandleMark hm; |
1 | 113 |
ResourceMark rm(THREAD); |
114 |
||
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7405
diff
changeset
|
115 |
Symbol* exception_name = NULL; |
1 | 116 |
const size_t message_buffer_len = klass->name()->utf8_length() + 1024; |
117 |
char* message_buffer = NEW_RESOURCE_ARRAY(char, message_buffer_len); |
|
13476 | 118 |
char* exception_message = message_buffer; |
1 | 119 |
|
120 |
const char* klassName = klass->external_name(); |
|
13476 | 121 |
bool can_failover = FailOverToOldVerifier && |
122 |
klass->major_version() < NOFAILOVER_MAJOR_VERSION; |
|
1 | 123 |
|
124 |
// If the class should be verified, first see if we can use the split |
|
125 |
// verifier. If not, or if verification fails and FailOverToOldVerifier |
|
126 |
// is set, then call the inference verifier. |
|
3820
0a8fbbe180db
6830542: Performance: JVM_DefineClass already verified.
acorn
parents:
3261
diff
changeset
|
127 |
if (is_eligible_for_verification(klass, should_verify_class)) { |
1 | 128 |
if (TraceClassInitialization) { |
129 |
tty->print_cr("Start class verification for: %s", klassName); |
|
130 |
} |
|
16445
cb44d5b3ad89
8009595: The UseSplitVerifier option needs to be deprecated.
hseigel
parents:
16443
diff
changeset
|
131 |
if (klass->major_version() >= STACKMAP_ATTRIBUTE_MAJOR_VERSION) { |
13476 | 132 |
ClassVerifier split_verifier(klass, THREAD); |
133 |
split_verifier.verify_class(THREAD); |
|
134 |
exception_name = split_verifier.result(); |
|
135 |
if (can_failover && !HAS_PENDING_EXCEPTION && |
|
1 | 136 |
(exception_name == vmSymbols::java_lang_VerifyError() || |
137 |
exception_name == vmSymbols::java_lang_ClassFormatError())) { |
|
13476 | 138 |
if (TraceClassInitialization || VerboseVerification) { |
1 | 139 |
tty->print_cr( |
140 |
"Fail over class verification to old verifier for: %s", klassName); |
|
141 |
} |
|
142 |
exception_name = inference_verify( |
|
143 |
klass, message_buffer, message_buffer_len, THREAD); |
|
144 |
} |
|
13476 | 145 |
if (exception_name != NULL) { |
146 |
exception_message = split_verifier.exception_message(); |
|
147 |
} |
|
1 | 148 |
} else { |
149 |
exception_name = inference_verify( |
|
150 |
klass, message_buffer, message_buffer_len, THREAD); |
|
151 |
} |
|
152 |
||
13476 | 153 |
if (TraceClassInitialization || VerboseVerification) { |
1 | 154 |
if (HAS_PENDING_EXCEPTION) { |
155 |
tty->print("Verification for %s has", klassName); |
|
156 |
tty->print_cr(" exception pending %s ", |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13479
diff
changeset
|
157 |
InstanceKlass::cast(PENDING_EXCEPTION->klass())->external_name()); |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7405
diff
changeset
|
158 |
} else if (exception_name != NULL) { |
1 | 159 |
tty->print_cr("Verification for %s failed", klassName); |
160 |
} |
|
161 |
tty->print_cr("End class verification for: %s", klassName); |
|
162 |
} |
|
163 |
} |
|
164 |
||
165 |
if (HAS_PENDING_EXCEPTION) { |
|
166 |
return false; // use the existing exception |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7405
diff
changeset
|
167 |
} else if (exception_name == NULL) { |
1 | 168 |
return true; // verifcation succeeded |
169 |
} else { // VerifyError or ClassFormatError to be created and thrown |
|
170 |
ResourceMark rm(THREAD); |
|
171 |
instanceKlassHandle kls = |
|
172 |
SystemDictionary::resolve_or_fail(exception_name, true, CHECK_false); |
|
173 |
while (!kls.is_null()) { |
|
174 |
if (kls == klass) { |
|
175 |
// If the class being verified is the exception we're creating |
|
176 |
// or one of it's superclasses, we're in trouble and are going |
|
177 |
// to infinitely recurse when we try to initialize the exception. |
|
178 |
// So bail out here by throwing the preallocated VM error. |
|
179 |
THROW_OOP_(Universe::virtual_machine_error_instance(), false); |
|
180 |
} |
|
181 |
kls = kls->super(); |
|
182 |
} |
|
183 |
message_buffer[message_buffer_len - 1] = '\0'; // just to be sure |
|
13476 | 184 |
THROW_MSG_(exception_name, exception_message, false); |
1 | 185 |
} |
186 |
} |
|
187 |
||
3820
0a8fbbe180db
6830542: Performance: JVM_DefineClass already verified.
acorn
parents:
3261
diff
changeset
|
188 |
bool Verifier::is_eligible_for_verification(instanceKlassHandle klass, bool should_verify_class) { |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7405
diff
changeset
|
189 |
Symbol* name = klass->name(); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13479
diff
changeset
|
190 |
Klass* refl_magic_klass = SystemDictionary::reflect_MagicAccessorImpl_klass(); |
19704
475be20c57de
8023872: Verification error in generated lambda classes
acorn
parents:
19692
diff
changeset
|
191 |
|
475be20c57de
8023872: Verification error in generated lambda classes
acorn
parents:
19692
diff
changeset
|
192 |
bool is_reflect = refl_magic_klass != NULL && klass->is_subtype_of(refl_magic_klass); |
1 | 193 |
|
3820
0a8fbbe180db
6830542: Performance: JVM_DefineClass already verified.
acorn
parents:
3261
diff
changeset
|
194 |
return (should_verify_for(klass->class_loader(), should_verify_class) && |
1 | 195 |
// return if the class is a bootstrapping class |
3820
0a8fbbe180db
6830542: Performance: JVM_DefineClass already verified.
acorn
parents:
3261
diff
changeset
|
196 |
// or defineClass specified not to verify by default (flags override passed arg) |
1 | 197 |
// We need to skip the following four for bootstraping |
198 |
name != vmSymbols::java_lang_Object() && |
|
199 |
name != vmSymbols::java_lang_Class() && |
|
200 |
name != vmSymbols::java_lang_String() && |
|
201 |
name != vmSymbols::java_lang_Throwable() && |
|
202 |
||
203 |
// Can not verify the bytecodes for shared classes because they have |
|
204 |
// already been rewritten to contain constant pool cache indices, |
|
205 |
// which the verifier can't understand. |
|
206 |
// Shared classes shouldn't have stackmaps either. |
|
207 |
!klass()->is_shared() && |
|
208 |
||
209 |
// As of the fix for 4486457 we disable verification for all of the |
|
210 |
// dynamically-generated bytecodes associated with the 1.4 |
|
211 |
// reflection implementation, not just those associated with |
|
212 |
// sun/reflect/SerializationConstructorAccessor. |
|
213 |
// NOTE: this is called too early in the bootstrapping process to be |
|
24456
8c7933fa5a1f
8025580: Temporary flags: UseNewReflection and ReflectionWrapResolutionErrors
coleenp
parents:
24424
diff
changeset
|
214 |
// guarded by Universe::is_gte_jdk14x_version(). |
19704
475be20c57de
8023872: Verification error in generated lambda classes
acorn
parents:
19692
diff
changeset
|
215 |
// Also for lambda generated code, gte jdk8 |
24456
8c7933fa5a1f
8025580: Temporary flags: UseNewReflection and ReflectionWrapResolutionErrors
coleenp
parents:
24424
diff
changeset
|
216 |
(!is_reflect)); |
1 | 217 |
} |
218 |
||
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7405
diff
changeset
|
219 |
Symbol* Verifier::inference_verify( |
1 | 220 |
instanceKlassHandle klass, char* message, size_t message_len, TRAPS) { |
221 |
JavaThread* thread = (JavaThread*)THREAD; |
|
222 |
JNIEnv *env = thread->jni_environment(); |
|
223 |
||
224 |
void* verify_func = verify_byte_codes_fn(); |
|
225 |
||
226 |
if (verify_func == NULL) { |
|
227 |
jio_snprintf(message, message_len, "Could not link verifier"); |
|
228 |
return vmSymbols::java_lang_VerifyError(); |
|
229 |
} |
|
230 |
||
231 |
ResourceMark rm(THREAD); |
|
13476 | 232 |
if (VerboseVerification) { |
1 | 233 |
tty->print_cr("Verifying class %s with old format", klass->external_name()); |
234 |
} |
|
235 |
||
236 |
jclass cls = (jclass) JNIHandles::make_local(env, klass->java_mirror()); |
|
237 |
jint result; |
|
238 |
||
239 |
{ |
|
240 |
HandleMark hm(thread); |
|
241 |
ThreadToNativeFromVM ttn(thread); |
|
242 |
// ThreadToNativeFromVM takes care of changing thread_state, so safepoint |
|
243 |
// code knows that we have left the VM |
|
244 |
||
245 |
if (_is_new_verify_byte_codes_fn) { |
|
246 |
verify_byte_codes_fn_new_t func = |
|
247 |
CAST_TO_FN_PTR(verify_byte_codes_fn_new_t, verify_func); |
|
248 |
result = (*func)(env, cls, message, (int)message_len, |
|
249 |
klass->major_version()); |
|
250 |
} else { |
|
251 |
verify_byte_codes_fn_t func = |
|
252 |
CAST_TO_FN_PTR(verify_byte_codes_fn_t, verify_func); |
|
253 |
result = (*func)(env, cls, message, (int)message_len); |
|
254 |
} |
|
255 |
} |
|
256 |
||
257 |
JNIHandles::destroy_local(cls); |
|
258 |
||
259 |
// These numbers are chosen so that VerifyClassCodes interface doesn't need |
|
260 |
// to be changed (still return jboolean (unsigned char)), and result is |
|
261 |
// 1 when verification is passed. |
|
262 |
if (result == 0) { |
|
263 |
return vmSymbols::java_lang_VerifyError(); |
|
264 |
} else if (result == 1) { |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7405
diff
changeset
|
265 |
return NULL; // verified. |
1 | 266 |
} else if (result == 2) { |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7405
diff
changeset
|
267 |
THROW_MSG_(vmSymbols::java_lang_OutOfMemoryError(), message, NULL); |
1 | 268 |
} else if (result == 3) { |
269 |
return vmSymbols::java_lang_ClassFormatError(); |
|
270 |
} else { |
|
271 |
ShouldNotReachHere(); |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7405
diff
changeset
|
272 |
return NULL; |
1 | 273 |
} |
274 |
} |
|
275 |
||
13476 | 276 |
TypeOrigin TypeOrigin::null() { |
277 |
return TypeOrigin(); |
|
278 |
} |
|
279 |
TypeOrigin TypeOrigin::local(u2 index, StackMapFrame* frame) { |
|
280 |
assert(frame != NULL, "Must have a frame"); |
|
281 |
return TypeOrigin(CF_LOCALS, index, StackMapFrame::copy(frame), |
|
282 |
frame->local_at(index)); |
|
283 |
} |
|
284 |
TypeOrigin TypeOrigin::stack(u2 index, StackMapFrame* frame) { |
|
285 |
assert(frame != NULL, "Must have a frame"); |
|
286 |
return TypeOrigin(CF_STACK, index, StackMapFrame::copy(frame), |
|
287 |
frame->stack_at(index)); |
|
288 |
} |
|
289 |
TypeOrigin TypeOrigin::sm_local(u2 index, StackMapFrame* frame) { |
|
290 |
assert(frame != NULL, "Must have a frame"); |
|
291 |
return TypeOrigin(SM_LOCALS, index, StackMapFrame::copy(frame), |
|
292 |
frame->local_at(index)); |
|
293 |
} |
|
294 |
TypeOrigin TypeOrigin::sm_stack(u2 index, StackMapFrame* frame) { |
|
295 |
assert(frame != NULL, "Must have a frame"); |
|
296 |
return TypeOrigin(SM_STACK, index, StackMapFrame::copy(frame), |
|
297 |
frame->stack_at(index)); |
|
298 |
} |
|
299 |
TypeOrigin TypeOrigin::bad_index(u2 index) { |
|
300 |
return TypeOrigin(BAD_INDEX, index, NULL, VerificationType::bogus_type()); |
|
301 |
} |
|
302 |
TypeOrigin TypeOrigin::cp(u2 index, VerificationType vt) { |
|
303 |
return TypeOrigin(CONST_POOL, index, NULL, vt); |
|
304 |
} |
|
305 |
TypeOrigin TypeOrigin::signature(VerificationType vt) { |
|
306 |
return TypeOrigin(SIG, 0, NULL, vt); |
|
307 |
} |
|
308 |
TypeOrigin TypeOrigin::implicit(VerificationType t) { |
|
309 |
return TypeOrigin(IMPLICIT, 0, NULL, t); |
|
310 |
} |
|
311 |
TypeOrigin TypeOrigin::frame(StackMapFrame* frame) { |
|
312 |
return TypeOrigin(FRAME_ONLY, 0, StackMapFrame::copy(frame), |
|
313 |
VerificationType::bogus_type()); |
|
314 |
} |
|
315 |
||
316 |
void TypeOrigin::reset_frame() { |
|
317 |
if (_frame != NULL) { |
|
318 |
_frame->restore(); |
|
319 |
} |
|
320 |
} |
|
321 |
||
322 |
void TypeOrigin::details(outputStream* ss) const { |
|
323 |
_type.print_on(ss); |
|
324 |
switch (_origin) { |
|
325 |
case CF_LOCALS: |
|
326 |
ss->print(" (current frame, locals[%d])", _index); |
|
327 |
break; |
|
328 |
case CF_STACK: |
|
329 |
ss->print(" (current frame, stack[%d])", _index); |
|
330 |
break; |
|
331 |
case SM_LOCALS: |
|
332 |
ss->print(" (stack map, locals[%d])", _index); |
|
333 |
break; |
|
334 |
case SM_STACK: |
|
335 |
ss->print(" (stack map, stack[%d])", _index); |
|
336 |
break; |
|
337 |
case CONST_POOL: |
|
338 |
ss->print(" (constant pool %d)", _index); |
|
339 |
break; |
|
340 |
case SIG: |
|
341 |
ss->print(" (from method signature)"); |
|
342 |
break; |
|
343 |
case IMPLICIT: |
|
344 |
case FRAME_ONLY: |
|
345 |
case NONE: |
|
346 |
default: |
|
347 |
; |
|
348 |
} |
|
349 |
} |
|
350 |
||
351 |
#ifdef ASSERT |
|
352 |
void TypeOrigin::print_on(outputStream* str) const { |
|
353 |
str->print("{%d,%d,%p:", _origin, _index, _frame); |
|
354 |
if (_frame != NULL) { |
|
355 |
_frame->print_on(str); |
|
356 |
} else { |
|
357 |
str->print("null"); |
|
358 |
} |
|
359 |
str->print(","); |
|
360 |
_type.print_on(str); |
|
361 |
str->print("}"); |
|
362 |
} |
|
363 |
#endif |
|
364 |
||
17370
59a0620561fa
8003557: NPG: Klass* const k should be const Klass* k.
minqi
parents:
16676
diff
changeset
|
365 |
void ErrorContext::details(outputStream* ss, const Method* method) const { |
13476 | 366 |
if (is_valid()) { |
24424
2658d7834c6e
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
24351
diff
changeset
|
367 |
ss->cr(); |
13476 | 368 |
ss->print_cr("Exception Details:"); |
369 |
location_details(ss, method); |
|
370 |
reason_details(ss); |
|
371 |
frame_details(ss); |
|
372 |
bytecode_details(ss, method); |
|
373 |
handler_details(ss, method); |
|
374 |
stackmap_details(ss, method); |
|
375 |
} |
|
376 |
} |
|
377 |
||
378 |
void ErrorContext::reason_details(outputStream* ss) const { |
|
379 |
streamIndentor si(ss); |
|
380 |
ss->indent().print_cr("Reason:"); |
|
381 |
streamIndentor si2(ss); |
|
24424
2658d7834c6e
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
24351
diff
changeset
|
382 |
ss->indent().print("%s", ""); |
13476 | 383 |
switch (_fault) { |
384 |
case INVALID_BYTECODE: |
|
385 |
ss->print("Error exists in the bytecode"); |
|
386 |
break; |
|
387 |
case WRONG_TYPE: |
|
388 |
if (_expected.is_valid()) { |
|
389 |
ss->print("Type "); |
|
390 |
_type.details(ss); |
|
391 |
ss->print(" is not assignable to "); |
|
392 |
_expected.details(ss); |
|
393 |
} else { |
|
394 |
ss->print("Invalid type: "); |
|
395 |
_type.details(ss); |
|
396 |
} |
|
397 |
break; |
|
398 |
case FLAGS_MISMATCH: |
|
399 |
if (_expected.is_valid()) { |
|
400 |
ss->print("Current frame's flags are not assignable " |
|
401 |
"to stack map frame's."); |
|
402 |
} else { |
|
403 |
ss->print("Current frame's flags are invalid in this context."); |
|
404 |
} |
|
405 |
break; |
|
406 |
case BAD_CP_INDEX: |
|
407 |
ss->print("Constant pool index %d is invalid", _type.index()); |
|
408 |
break; |
|
409 |
case BAD_LOCAL_INDEX: |
|
410 |
ss->print("Local index %d is invalid", _type.index()); |
|
411 |
break; |
|
412 |
case LOCALS_SIZE_MISMATCH: |
|
413 |
ss->print("Current frame's local size doesn't match stackmap."); |
|
414 |
break; |
|
415 |
case STACK_SIZE_MISMATCH: |
|
416 |
ss->print("Current frame's stack size doesn't match stackmap."); |
|
417 |
break; |
|
418 |
case STACK_OVERFLOW: |
|
419 |
ss->print("Exceeded max stack size."); |
|
420 |
break; |
|
421 |
case STACK_UNDERFLOW: |
|
422 |
ss->print("Attempt to pop empty stack."); |
|
423 |
break; |
|
424 |
case MISSING_STACKMAP: |
|
425 |
ss->print("Expected stackmap frame at this location."); |
|
426 |
break; |
|
427 |
case BAD_STACKMAP: |
|
428 |
ss->print("Invalid stackmap specification."); |
|
429 |
break; |
|
430 |
case UNKNOWN: |
|
431 |
default: |
|
432 |
ShouldNotReachHere(); |
|
433 |
ss->print_cr("Unknown"); |
|
434 |
} |
|
24424
2658d7834c6e
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
24351
diff
changeset
|
435 |
ss->cr(); |
13476 | 436 |
} |
437 |
||
17370
59a0620561fa
8003557: NPG: Klass* const k should be const Klass* k.
minqi
parents:
16676
diff
changeset
|
438 |
void ErrorContext::location_details(outputStream* ss, const Method* method) const { |
13476 | 439 |
if (_bci != -1 && method != NULL) { |
440 |
streamIndentor si(ss); |
|
441 |
const char* bytecode_name = "<invalid>"; |
|
442 |
if (method->validate_bci_from_bcx(_bci) != -1) { |
|
443 |
Bytecodes::Code code = Bytecodes::code_or_bp_at(method->bcp_from(_bci)); |
|
444 |
if (Bytecodes::is_defined(code)) { |
|
445 |
bytecode_name = Bytecodes::name(code); |
|
446 |
} else { |
|
447 |
bytecode_name = "<illegal>"; |
|
448 |
} |
|
449 |
} |
|
14391
df0a1573d5bd
8000725: NPG: method_holder() and pool_holder() and pool_holder field should be InstanceKlass
coleenp
parents:
14385
diff
changeset
|
450 |
InstanceKlass* ik = method->method_holder(); |
13476 | 451 |
ss->indent().print_cr("Location:"); |
452 |
streamIndentor si2(ss); |
|
453 |
ss->indent().print_cr("%s.%s%s @%d: %s", |
|
454 |
ik->name()->as_C_string(), method->name()->as_C_string(), |
|
455 |
method->signature()->as_C_string(), _bci, bytecode_name); |
|
456 |
} |
|
457 |
} |
|
458 |
||
459 |
void ErrorContext::frame_details(outputStream* ss) const { |
|
460 |
streamIndentor si(ss); |
|
461 |
if (_type.is_valid() && _type.frame() != NULL) { |
|
462 |
ss->indent().print_cr("Current Frame:"); |
|
463 |
streamIndentor si2(ss); |
|
464 |
_type.frame()->print_on(ss); |
|
465 |
} |
|
466 |
if (_expected.is_valid() && _expected.frame() != NULL) { |
|
467 |
ss->indent().print_cr("Stackmap Frame:"); |
|
468 |
streamIndentor si2(ss); |
|
469 |
_expected.frame()->print_on(ss); |
|
470 |
} |
|
471 |
} |
|
472 |
||
17370
59a0620561fa
8003557: NPG: Klass* const k should be const Klass* k.
minqi
parents:
16676
diff
changeset
|
473 |
void ErrorContext::bytecode_details(outputStream* ss, const Method* method) const { |
13476 | 474 |
if (method != NULL) { |
475 |
streamIndentor si(ss); |
|
476 |
ss->indent().print_cr("Bytecode:"); |
|
477 |
streamIndentor si2(ss); |
|
478 |
ss->print_data(method->code_base(), method->code_size(), false); |
|
479 |
} |
|
480 |
} |
|
481 |
||
17370
59a0620561fa
8003557: NPG: Klass* const k should be const Klass* k.
minqi
parents:
16676
diff
changeset
|
482 |
void ErrorContext::handler_details(outputStream* ss, const Method* method) const { |
13476 | 483 |
if (method != NULL) { |
484 |
streamIndentor si(ss); |
|
485 |
ExceptionTable table(method); |
|
486 |
if (table.length() > 0) { |
|
487 |
ss->indent().print_cr("Exception Handler Table:"); |
|
488 |
streamIndentor si2(ss); |
|
489 |
for (int i = 0; i < table.length(); ++i) { |
|
490 |
ss->indent().print_cr("bci [%d, %d] => handler: %d", table.start_pc(i), |
|
491 |
table.end_pc(i), table.handler_pc(i)); |
|
492 |
} |
|
493 |
} |
|
494 |
} |
|
495 |
} |
|
496 |
||
17370
59a0620561fa
8003557: NPG: Klass* const k should be const Klass* k.
minqi
parents:
16676
diff
changeset
|
497 |
void ErrorContext::stackmap_details(outputStream* ss, const Method* method) const { |
13476 | 498 |
if (method != NULL && method->has_stackmap_table()) { |
499 |
streamIndentor si(ss); |
|
500 |
ss->indent().print_cr("Stackmap Table:"); |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13479
diff
changeset
|
501 |
Array<u1>* data = method->stackmap_data(); |
13476 | 502 |
stack_map_table* sm_table = |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13479
diff
changeset
|
503 |
stack_map_table::at((address)data->adr_at(0)); |
13476 | 504 |
stack_map_frame* sm_frame = sm_table->entries(); |
505 |
streamIndentor si2(ss); |
|
506 |
int current_offset = -1; |
|
507 |
for (u2 i = 0; i < sm_table->number_of_entries(); ++i) { |
|
508 |
ss->indent(); |
|
509 |
sm_frame->print_on(ss, current_offset); |
|
24424
2658d7834c6e
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
24351
diff
changeset
|
510 |
ss->cr(); |
13476 | 511 |
current_offset += sm_frame->offset_delta(); |
512 |
sm_frame = sm_frame->next(); |
|
513 |
} |
|
514 |
} |
|
515 |
} |
|
516 |
||
1 | 517 |
// Methods in ClassVerifier |
518 |
||
519 |
ClassVerifier::ClassVerifier( |
|
13476 | 520 |
instanceKlassHandle klass, TRAPS) |
521 |
: _thread(THREAD), _exception_type(NULL), _message(NULL), _klass(klass) { |
|
1 | 522 |
_this_type = VerificationType::reference_type(klass->name()); |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7405
diff
changeset
|
523 |
// Create list to hold symbols in reference area. |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7405
diff
changeset
|
524 |
_symbols = new GrowableArray<Symbol*>(100, 0, NULL); |
1 | 525 |
} |
526 |
||
527 |
ClassVerifier::~ClassVerifier() { |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7405
diff
changeset
|
528 |
// Decrement the reference count for any symbols created. |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7405
diff
changeset
|
529 |
for (int i = 0; i < _symbols->length(); i++) { |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7405
diff
changeset
|
530 |
Symbol* s = _symbols->at(i); |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7405
diff
changeset
|
531 |
s->decrement_refcount(); |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7405
diff
changeset
|
532 |
} |
1 | 533 |
} |
534 |
||
7380
041cf7f1cce6
6865028: Illegal instructions passing verification prior to 'invokespecial Object.<init>'
kamg
parents:
6173
diff
changeset
|
535 |
VerificationType ClassVerifier::object_type() const { |
041cf7f1cce6
6865028: Illegal instructions passing verification prior to 'invokespecial Object.<init>'
kamg
parents:
6173
diff
changeset
|
536 |
return VerificationType::reference_type(vmSymbols::java_lang_Object()); |
041cf7f1cce6
6865028: Illegal instructions passing verification prior to 'invokespecial Object.<init>'
kamg
parents:
6173
diff
changeset
|
537 |
} |
041cf7f1cce6
6865028: Illegal instructions passing verification prior to 'invokespecial Object.<init>'
kamg
parents:
6173
diff
changeset
|
538 |
|
13476 | 539 |
TypeOrigin ClassVerifier::ref_ctx(const char* sig, TRAPS) { |
540 |
VerificationType vt = VerificationType::reference_type( |
|
541 |
create_temporary_symbol(sig, (int)strlen(sig), THREAD)); |
|
542 |
return TypeOrigin::implicit(vt); |
|
543 |
} |
|
544 |
||
1 | 545 |
void ClassVerifier::verify_class(TRAPS) { |
13476 | 546 |
if (VerboseVerification) { |
1 | 547 |
tty->print_cr("Verifying class %s with new format", |
548 |
_klass->external_name()); |
|
549 |
} |
|
550 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13479
diff
changeset
|
551 |
Array<Method*>* methods = _klass->methods(); |
1 | 552 |
int num_methods = methods->length(); |
553 |
||
554 |
for (int index = 0; index < num_methods; index++) { |
|
5693 | 555 |
// Check for recursive re-verification before each method. |
556 |
if (was_recursively_verified()) return; |
|
557 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13479
diff
changeset
|
558 |
Method* m = methods->at(index); |
14385 | 559 |
if (m->is_native() || m->is_abstract() || m->is_overpass()) { |
1 | 560 |
// If m is native or abstract, skip it. It is checked in class file |
14385 | 561 |
// parser that methods do not override a final method. Overpass methods |
562 |
// are trusted since the VM generates them. |
|
1 | 563 |
continue; |
564 |
} |
|
565 |
verify_method(methodHandle(THREAD, m), CHECK_VERIFY(this)); |
|
566 |
} |
|
5693 | 567 |
|
13476 | 568 |
if (VerboseVerification || TraceClassInitialization) { |
5693 | 569 |
if (was_recursively_verified()) |
570 |
tty->print_cr("Recursive verification detected for: %s", |
|
571 |
_klass->external_name()); |
|
572 |
} |
|
1 | 573 |
} |
574 |
||
575 |
void ClassVerifier::verify_method(methodHandle m, TRAPS) { |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13479
diff
changeset
|
576 |
HandleMark hm(THREAD); |
1 | 577 |
_method = m; // initialize _method |
13476 | 578 |
if (VerboseVerification) { |
1 | 579 |
tty->print_cr("Verifying method %s", m->name_and_sig_as_C_string()); |
580 |
} |
|
581 |
||
24424
2658d7834c6e
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
24351
diff
changeset
|
582 |
// For clang, the only good constant format string is a literal constant format string. |
2658d7834c6e
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
24351
diff
changeset
|
583 |
#define bad_type_msg "Bad type on operand stack in %s" |
1 | 584 |
|
13396
1b2b5f740ee0
7188911: nightly failures after JSR 292 lazy method handle update (round 2)
twisti
parents:
13283
diff
changeset
|
585 |
int32_t max_stack = m->verifier_max_stack(); |
1 | 586 |
int32_t max_locals = m->max_locals(); |
587 |
constantPoolHandle cp(THREAD, m->constants()); |
|
588 |
||
589 |
if (!SignatureVerifier::is_valid_method_signature(m->signature())) { |
|
590 |
class_format_error("Invalid method signature"); |
|
591 |
return; |
|
592 |
} |
|
593 |
||
594 |
// Initial stack map frame: offset is 0, stack is initially empty. |
|
595 |
StackMapFrame current_frame(max_locals, max_stack, this); |
|
596 |
// Set initial locals |
|
597 |
VerificationType return_type = current_frame.set_locals_from_arg( |
|
598 |
m, current_type(), CHECK_VERIFY(this)); |
|
599 |
||
600 |
int32_t stackmap_index = 0; // index to the stackmap array |
|
601 |
||
602 |
u4 code_length = m->code_size(); |
|
603 |
||
604 |
// Scan the bytecode and map each instruction's start offset to a number. |
|
605 |
char* code_data = generate_code_data(m, code_length, CHECK_VERIFY(this)); |
|
606 |
||
607 |
int ex_min = code_length; |
|
608 |
int ex_max = -1; |
|
609 |
// Look through each item on the exception table. Each of the fields must refer |
|
610 |
// to a legal instruction. |
|
611 |
verify_exception_handler_table( |
|
612 |
code_length, code_data, ex_min, ex_max, CHECK_VERIFY(this)); |
|
613 |
||
614 |
// Look through each entry on the local variable table and make sure |
|
615 |
// its range of code array offsets is valid. (4169817) |
|
616 |
if (m->has_localvariable_table()) { |
|
617 |
verify_local_variable_table(code_length, code_data, CHECK_VERIFY(this)); |
|
618 |
} |
|
619 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13479
diff
changeset
|
620 |
Array<u1>* stackmap_data = m->stackmap_data(); |
1 | 621 |
StackMapStream stream(stackmap_data); |
622 |
StackMapReader reader(this, &stream, code_data, code_length, THREAD); |
|
623 |
StackMapTable stackmap_table(&reader, ¤t_frame, max_locals, max_stack, |
|
624 |
code_data, code_length, CHECK_VERIFY(this)); |
|
625 |
||
13476 | 626 |
if (VerboseVerification) { |
627 |
stackmap_table.print_on(tty); |
|
1 | 628 |
} |
629 |
||
630 |
RawBytecodeStream bcs(m); |
|
631 |
||
632 |
// Scan the byte code linearly from the start to the end |
|
633 |
bool no_control_flow = false; // Set to true when there is no direct control |
|
634 |
// flow from current instruction to the next |
|
635 |
// instruction in sequence |
|
25505 | 636 |
|
637 |
set_furthest_jump(0); |
|
638 |
||
1 | 639 |
Bytecodes::Code opcode; |
640 |
while (!bcs.is_last_bytecode()) { |
|
5693 | 641 |
// Check for recursive re-verification before each bytecode. |
642 |
if (was_recursively_verified()) return; |
|
643 |
||
1 | 644 |
opcode = bcs.raw_next(); |
645 |
u2 bci = bcs.bci(); |
|
646 |
||
647 |
// Set current frame's offset to bci |
|
648 |
current_frame.set_offset(bci); |
|
13476 | 649 |
current_frame.set_mark(); |
1 | 650 |
|
651 |
// Make sure every offset in stackmap table point to the beginning to |
|
652 |
// an instruction. Match current_frame to stackmap_table entry with |
|
653 |
// the same offset if exists. |
|
654 |
stackmap_index = verify_stackmap_table( |
|
655 |
stackmap_index, bci, ¤t_frame, &stackmap_table, |
|
656 |
no_control_flow, CHECK_VERIFY(this)); |
|
657 |
||
13476 | 658 |
|
1 | 659 |
bool this_uninit = false; // Set to true when invokespecial <init> initialized 'this' |
660 |
||
661 |
// Merge with the next instruction |
|
662 |
{ |
|
663 |
u2 index; |
|
664 |
int target; |
|
665 |
VerificationType type, type2; |
|
666 |
VerificationType atype; |
|
667 |
||
668 |
#ifndef PRODUCT |
|
13476 | 669 |
if (VerboseVerification) { |
670 |
current_frame.print_on(tty); |
|
1 | 671 |
tty->print_cr("offset = %d, opcode = %s", bci, Bytecodes::name(opcode)); |
672 |
} |
|
673 |
#endif |
|
674 |
||
675 |
// Make sure wide instruction is in correct format |
|
676 |
if (bcs.is_wide()) { |
|
677 |
if (opcode != Bytecodes::_iinc && opcode != Bytecodes::_iload && |
|
678 |
opcode != Bytecodes::_aload && opcode != Bytecodes::_lload && |
|
679 |
opcode != Bytecodes::_istore && opcode != Bytecodes::_astore && |
|
680 |
opcode != Bytecodes::_lstore && opcode != Bytecodes::_fload && |
|
681 |
opcode != Bytecodes::_dload && opcode != Bytecodes::_fstore && |
|
682 |
opcode != Bytecodes::_dstore) { |
|
13476 | 683 |
/* Unreachable? RawBytecodeStream's raw_next() returns 'illegal' |
684 |
* if we encounter a wide instruction that modifies an invalid |
|
685 |
* opcode (not one of the ones listed above) */ |
|
686 |
verify_error(ErrorContext::bad_code(bci), "Bad wide instruction"); |
|
1 | 687 |
return; |
688 |
} |
|
689 |
} |
|
690 |
||
691 |
switch (opcode) { |
|
692 |
case Bytecodes::_nop : |
|
693 |
no_control_flow = false; break; |
|
694 |
case Bytecodes::_aconst_null : |
|
695 |
current_frame.push_stack( |
|
696 |
VerificationType::null_type(), CHECK_VERIFY(this)); |
|
697 |
no_control_flow = false; break; |
|
698 |
case Bytecodes::_iconst_m1 : |
|
699 |
case Bytecodes::_iconst_0 : |
|
700 |
case Bytecodes::_iconst_1 : |
|
701 |
case Bytecodes::_iconst_2 : |
|
702 |
case Bytecodes::_iconst_3 : |
|
703 |
case Bytecodes::_iconst_4 : |
|
704 |
case Bytecodes::_iconst_5 : |
|
705 |
current_frame.push_stack( |
|
706 |
VerificationType::integer_type(), CHECK_VERIFY(this)); |
|
707 |
no_control_flow = false; break; |
|
708 |
case Bytecodes::_lconst_0 : |
|
709 |
case Bytecodes::_lconst_1 : |
|
710 |
current_frame.push_stack_2( |
|
711 |
VerificationType::long_type(), |
|
712 |
VerificationType::long2_type(), CHECK_VERIFY(this)); |
|
713 |
no_control_flow = false; break; |
|
714 |
case Bytecodes::_fconst_0 : |
|
715 |
case Bytecodes::_fconst_1 : |
|
716 |
case Bytecodes::_fconst_2 : |
|
717 |
current_frame.push_stack( |
|
718 |
VerificationType::float_type(), CHECK_VERIFY(this)); |
|
719 |
no_control_flow = false; break; |
|
720 |
case Bytecodes::_dconst_0 : |
|
721 |
case Bytecodes::_dconst_1 : |
|
722 |
current_frame.push_stack_2( |
|
723 |
VerificationType::double_type(), |
|
724 |
VerificationType::double2_type(), CHECK_VERIFY(this)); |
|
725 |
no_control_flow = false; break; |
|
726 |
case Bytecodes::_sipush : |
|
727 |
case Bytecodes::_bipush : |
|
728 |
current_frame.push_stack( |
|
729 |
VerificationType::integer_type(), CHECK_VERIFY(this)); |
|
730 |
no_control_flow = false; break; |
|
731 |
case Bytecodes::_ldc : |
|
732 |
verify_ldc( |
|
5688 | 733 |
opcode, bcs.get_index_u1(), ¤t_frame, |
1 | 734 |
cp, bci, CHECK_VERIFY(this)); |
735 |
no_control_flow = false; break; |
|
736 |
case Bytecodes::_ldc_w : |
|
737 |
case Bytecodes::_ldc2_w : |
|
738 |
verify_ldc( |
|
5688 | 739 |
opcode, bcs.get_index_u2(), ¤t_frame, |
1 | 740 |
cp, bci, CHECK_VERIFY(this)); |
741 |
no_control_flow = false; break; |
|
742 |
case Bytecodes::_iload : |
|
743 |
verify_iload(bcs.get_index(), ¤t_frame, CHECK_VERIFY(this)); |
|
744 |
no_control_flow = false; break; |
|
745 |
case Bytecodes::_iload_0 : |
|
746 |
case Bytecodes::_iload_1 : |
|
747 |
case Bytecodes::_iload_2 : |
|
748 |
case Bytecodes::_iload_3 : |
|
749 |
index = opcode - Bytecodes::_iload_0; |
|
750 |
verify_iload(index, ¤t_frame, CHECK_VERIFY(this)); |
|
751 |
no_control_flow = false; break; |
|
752 |
case Bytecodes::_lload : |
|
753 |
verify_lload(bcs.get_index(), ¤t_frame, CHECK_VERIFY(this)); |
|
754 |
no_control_flow = false; break; |
|
755 |
case Bytecodes::_lload_0 : |
|
756 |
case Bytecodes::_lload_1 : |
|
757 |
case Bytecodes::_lload_2 : |
|
758 |
case Bytecodes::_lload_3 : |
|
759 |
index = opcode - Bytecodes::_lload_0; |
|
760 |
verify_lload(index, ¤t_frame, CHECK_VERIFY(this)); |
|
761 |
no_control_flow = false; break; |
|
762 |
case Bytecodes::_fload : |
|
763 |
verify_fload(bcs.get_index(), ¤t_frame, CHECK_VERIFY(this)); |
|
764 |
no_control_flow = false; break; |
|
765 |
case Bytecodes::_fload_0 : |
|
766 |
case Bytecodes::_fload_1 : |
|
767 |
case Bytecodes::_fload_2 : |
|
768 |
case Bytecodes::_fload_3 : |
|
769 |
index = opcode - Bytecodes::_fload_0; |
|
770 |
verify_fload(index, ¤t_frame, CHECK_VERIFY(this)); |
|
771 |
no_control_flow = false; break; |
|
772 |
case Bytecodes::_dload : |
|
773 |
verify_dload(bcs.get_index(), ¤t_frame, CHECK_VERIFY(this)); |
|
774 |
no_control_flow = false; break; |
|
775 |
case Bytecodes::_dload_0 : |
|
776 |
case Bytecodes::_dload_1 : |
|
777 |
case Bytecodes::_dload_2 : |
|
778 |
case Bytecodes::_dload_3 : |
|
779 |
index = opcode - Bytecodes::_dload_0; |
|
780 |
verify_dload(index, ¤t_frame, CHECK_VERIFY(this)); |
|
781 |
no_control_flow = false; break; |
|
782 |
case Bytecodes::_aload : |
|
783 |
verify_aload(bcs.get_index(), ¤t_frame, CHECK_VERIFY(this)); |
|
784 |
no_control_flow = false; break; |
|
785 |
case Bytecodes::_aload_0 : |
|
786 |
case Bytecodes::_aload_1 : |
|
787 |
case Bytecodes::_aload_2 : |
|
788 |
case Bytecodes::_aload_3 : |
|
789 |
index = opcode - Bytecodes::_aload_0; |
|
790 |
verify_aload(index, ¤t_frame, CHECK_VERIFY(this)); |
|
791 |
no_control_flow = false; break; |
|
792 |
case Bytecodes::_iaload : |
|
793 |
type = current_frame.pop_stack( |
|
794 |
VerificationType::integer_type(), CHECK_VERIFY(this)); |
|
795 |
atype = current_frame.pop_stack( |
|
796 |
VerificationType::reference_check(), CHECK_VERIFY(this)); |
|
797 |
if (!atype.is_int_array()) { |
|
13476 | 798 |
verify_error(ErrorContext::bad_type(bci, |
799 |
current_frame.stack_top_ctx(), ref_ctx("[I", THREAD)), |
|
800 |
bad_type_msg, "iaload"); |
|
1 | 801 |
return; |
802 |
} |
|
803 |
current_frame.push_stack( |
|
804 |
VerificationType::integer_type(), CHECK_VERIFY(this)); |
|
805 |
no_control_flow = false; break; |
|
806 |
case Bytecodes::_baload : |
|
807 |
type = current_frame.pop_stack( |
|
808 |
VerificationType::integer_type(), CHECK_VERIFY(this)); |
|
809 |
atype = current_frame.pop_stack( |
|
810 |
VerificationType::reference_check(), CHECK_VERIFY(this)); |
|
811 |
if (!atype.is_bool_array() && !atype.is_byte_array()) { |
|
13476 | 812 |
verify_error( |
813 |
ErrorContext::bad_type(bci, current_frame.stack_top_ctx()), |
|
814 |
bad_type_msg, "baload"); |
|
1 | 815 |
return; |
816 |
} |
|
817 |
current_frame.push_stack( |
|
818 |
VerificationType::integer_type(), CHECK_VERIFY(this)); |
|
819 |
no_control_flow = false; break; |
|
820 |
case Bytecodes::_caload : |
|
821 |
type = current_frame.pop_stack( |
|
822 |
VerificationType::integer_type(), CHECK_VERIFY(this)); |
|
823 |
atype = current_frame.pop_stack( |
|
824 |
VerificationType::reference_check(), CHECK_VERIFY(this)); |
|
825 |
if (!atype.is_char_array()) { |
|
13476 | 826 |
verify_error(ErrorContext::bad_type(bci, |
827 |
current_frame.stack_top_ctx(), ref_ctx("[C", THREAD)), |
|
828 |
bad_type_msg, "caload"); |
|
1 | 829 |
return; |
830 |
} |
|
831 |
current_frame.push_stack( |
|
832 |
VerificationType::integer_type(), CHECK_VERIFY(this)); |
|
833 |
no_control_flow = false; break; |
|
834 |
case Bytecodes::_saload : |
|
835 |
type = current_frame.pop_stack( |
|
836 |
VerificationType::integer_type(), CHECK_VERIFY(this)); |
|
837 |
atype = current_frame.pop_stack( |
|
838 |
VerificationType::reference_check(), CHECK_VERIFY(this)); |
|
839 |
if (!atype.is_short_array()) { |
|
13476 | 840 |
verify_error(ErrorContext::bad_type(bci, |
841 |
current_frame.stack_top_ctx(), ref_ctx("[S", THREAD)), |
|
842 |
bad_type_msg, "saload"); |
|
1 | 843 |
return; |
844 |
} |
|
845 |
current_frame.push_stack( |
|
846 |
VerificationType::integer_type(), CHECK_VERIFY(this)); |
|
847 |
no_control_flow = false; break; |
|
848 |
case Bytecodes::_laload : |
|
849 |
type = current_frame.pop_stack( |
|
850 |
VerificationType::integer_type(), CHECK_VERIFY(this)); |
|
851 |
atype = current_frame.pop_stack( |
|
852 |
VerificationType::reference_check(), CHECK_VERIFY(this)); |
|
853 |
if (!atype.is_long_array()) { |
|
13476 | 854 |
verify_error(ErrorContext::bad_type(bci, |
855 |
current_frame.stack_top_ctx(), ref_ctx("[J", THREAD)), |
|
856 |
bad_type_msg, "laload"); |
|
1 | 857 |
return; |
858 |
} |
|
859 |
current_frame.push_stack_2( |
|
860 |
VerificationType::long_type(), |
|
861 |
VerificationType::long2_type(), CHECK_VERIFY(this)); |
|
862 |
no_control_flow = false; break; |
|
863 |
case Bytecodes::_faload : |
|
864 |
type = current_frame.pop_stack( |
|
865 |
VerificationType::integer_type(), CHECK_VERIFY(this)); |
|
866 |
atype = current_frame.pop_stack( |
|
867 |
VerificationType::reference_check(), CHECK_VERIFY(this)); |
|
868 |
if (!atype.is_float_array()) { |
|
13476 | 869 |
verify_error(ErrorContext::bad_type(bci, |
870 |
current_frame.stack_top_ctx(), ref_ctx("[F", THREAD)), |
|
871 |
bad_type_msg, "faload"); |
|
1 | 872 |
return; |
873 |
} |
|
874 |
current_frame.push_stack( |
|
875 |
VerificationType::float_type(), CHECK_VERIFY(this)); |
|
876 |
no_control_flow = false; break; |
|
877 |
case Bytecodes::_daload : |
|
878 |
type = current_frame.pop_stack( |
|
879 |
VerificationType::integer_type(), CHECK_VERIFY(this)); |
|
880 |
atype = current_frame.pop_stack( |
|
881 |
VerificationType::reference_check(), CHECK_VERIFY(this)); |
|
882 |
if (!atype.is_double_array()) { |
|
13476 | 883 |
verify_error(ErrorContext::bad_type(bci, |
884 |
current_frame.stack_top_ctx(), ref_ctx("[D", THREAD)), |
|
885 |
bad_type_msg, "daload"); |
|
1 | 886 |
return; |
887 |
} |
|
888 |
current_frame.push_stack_2( |
|
889 |
VerificationType::double_type(), |
|
890 |
VerificationType::double2_type(), CHECK_VERIFY(this)); |
|
891 |
no_control_flow = false; break; |
|
892 |
case Bytecodes::_aaload : { |
|
893 |
type = current_frame.pop_stack( |
|
894 |
VerificationType::integer_type(), CHECK_VERIFY(this)); |
|
895 |
atype = current_frame.pop_stack( |
|
896 |
VerificationType::reference_check(), CHECK_VERIFY(this)); |
|
897 |
if (!atype.is_reference_array()) { |
|
13476 | 898 |
verify_error(ErrorContext::bad_type(bci, |
899 |
current_frame.stack_top_ctx(), |
|
900 |
TypeOrigin::implicit(VerificationType::reference_check())), |
|
901 |
bad_type_msg, "aaload"); |
|
1 | 902 |
return; |
903 |
} |
|
904 |
if (atype.is_null()) { |
|
905 |
current_frame.push_stack( |
|
906 |
VerificationType::null_type(), CHECK_VERIFY(this)); |
|
907 |
} else { |
|
908 |
VerificationType component = |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7405
diff
changeset
|
909 |
atype.get_component(this, CHECK_VERIFY(this)); |
1 | 910 |
current_frame.push_stack(component, CHECK_VERIFY(this)); |
911 |
} |
|
912 |
no_control_flow = false; break; |
|
913 |
} |
|
914 |
case Bytecodes::_istore : |
|
915 |
verify_istore(bcs.get_index(), ¤t_frame, CHECK_VERIFY(this)); |
|
916 |
no_control_flow = false; break; |
|
917 |
case Bytecodes::_istore_0 : |
|
918 |
case Bytecodes::_istore_1 : |
|
919 |
case Bytecodes::_istore_2 : |
|
920 |
case Bytecodes::_istore_3 : |
|
921 |
index = opcode - Bytecodes::_istore_0; |
|
922 |
verify_istore(index, ¤t_frame, CHECK_VERIFY(this)); |
|
923 |
no_control_flow = false; break; |
|
924 |
case Bytecodes::_lstore : |
|
925 |
verify_lstore(bcs.get_index(), ¤t_frame, CHECK_VERIFY(this)); |
|
926 |
no_control_flow = false; break; |
|
927 |
case Bytecodes::_lstore_0 : |
|
928 |
case Bytecodes::_lstore_1 : |
|
929 |
case Bytecodes::_lstore_2 : |
|
930 |
case Bytecodes::_lstore_3 : |
|
931 |
index = opcode - Bytecodes::_lstore_0; |
|
932 |
verify_lstore(index, ¤t_frame, CHECK_VERIFY(this)); |
|
933 |
no_control_flow = false; break; |
|
934 |
case Bytecodes::_fstore : |
|
935 |
verify_fstore(bcs.get_index(), ¤t_frame, CHECK_VERIFY(this)); |
|
936 |
no_control_flow = false; break; |
|
937 |
case Bytecodes::_fstore_0 : |
|
938 |
case Bytecodes::_fstore_1 : |
|
939 |
case Bytecodes::_fstore_2 : |
|
940 |
case Bytecodes::_fstore_3 : |
|
941 |
index = opcode - Bytecodes::_fstore_0; |
|
942 |
verify_fstore(index, ¤t_frame, CHECK_VERIFY(this)); |
|
943 |
no_control_flow = false; break; |
|
944 |
case Bytecodes::_dstore : |
|
945 |
verify_dstore(bcs.get_index(), ¤t_frame, CHECK_VERIFY(this)); |
|
946 |
no_control_flow = false; break; |
|
947 |
case Bytecodes::_dstore_0 : |
|
948 |
case Bytecodes::_dstore_1 : |
|
949 |
case Bytecodes::_dstore_2 : |
|
950 |
case Bytecodes::_dstore_3 : |
|
951 |
index = opcode - Bytecodes::_dstore_0; |
|
952 |
verify_dstore(index, ¤t_frame, CHECK_VERIFY(this)); |
|
953 |
no_control_flow = false; break; |
|
954 |
case Bytecodes::_astore : |
|
955 |
verify_astore(bcs.get_index(), ¤t_frame, CHECK_VERIFY(this)); |
|
956 |
no_control_flow = false; break; |
|
957 |
case Bytecodes::_astore_0 : |
|
958 |
case Bytecodes::_astore_1 : |
|
959 |
case Bytecodes::_astore_2 : |
|
960 |
case Bytecodes::_astore_3 : |
|
961 |
index = opcode - Bytecodes::_astore_0; |
|
962 |
verify_astore(index, ¤t_frame, CHECK_VERIFY(this)); |
|
963 |
no_control_flow = false; break; |
|
964 |
case Bytecodes::_iastore : |
|
965 |
type = current_frame.pop_stack( |
|
966 |
VerificationType::integer_type(), CHECK_VERIFY(this)); |
|
967 |
type2 = current_frame.pop_stack( |
|
968 |
VerificationType::integer_type(), CHECK_VERIFY(this)); |
|
969 |
atype = current_frame.pop_stack( |
|
970 |
VerificationType::reference_check(), CHECK_VERIFY(this)); |
|
971 |
if (!atype.is_int_array()) { |
|
13476 | 972 |
verify_error(ErrorContext::bad_type(bci, |
973 |
current_frame.stack_top_ctx(), ref_ctx("[I", THREAD)), |
|
974 |
bad_type_msg, "iastore"); |
|
1 | 975 |
return; |
976 |
} |
|
977 |
no_control_flow = false; break; |
|
978 |
case Bytecodes::_bastore : |
|
979 |
type = current_frame.pop_stack( |
|
980 |
VerificationType::integer_type(), CHECK_VERIFY(this)); |
|
981 |
type2 = current_frame.pop_stack( |
|
982 |
VerificationType::integer_type(), CHECK_VERIFY(this)); |
|
983 |
atype = current_frame.pop_stack( |
|
984 |
VerificationType::reference_check(), CHECK_VERIFY(this)); |
|
985 |
if (!atype.is_bool_array() && !atype.is_byte_array()) { |
|
13476 | 986 |
verify_error( |
987 |
ErrorContext::bad_type(bci, current_frame.stack_top_ctx()), |
|
988 |
bad_type_msg, "bastore"); |
|
1 | 989 |
return; |
990 |
} |
|
991 |
no_control_flow = false; break; |
|
992 |
case Bytecodes::_castore : |
|
993 |
current_frame.pop_stack( |
|
994 |
VerificationType::integer_type(), CHECK_VERIFY(this)); |
|
995 |
current_frame.pop_stack( |
|
996 |
VerificationType::integer_type(), CHECK_VERIFY(this)); |
|
997 |
atype = current_frame.pop_stack( |
|
998 |
VerificationType::reference_check(), CHECK_VERIFY(this)); |
|
999 |
if (!atype.is_char_array()) { |
|
13476 | 1000 |
verify_error(ErrorContext::bad_type(bci, |
1001 |
current_frame.stack_top_ctx(), ref_ctx("[C", THREAD)), |
|
1002 |
bad_type_msg, "castore"); |
|
1 | 1003 |
return; |
1004 |
} |
|
1005 |
no_control_flow = false; break; |
|
1006 |
case Bytecodes::_sastore : |
|
1007 |
current_frame.pop_stack( |
|
1008 |
VerificationType::integer_type(), CHECK_VERIFY(this)); |
|
1009 |
current_frame.pop_stack( |
|
1010 |
VerificationType::integer_type(), CHECK_VERIFY(this)); |
|
1011 |
atype = current_frame.pop_stack( |
|
1012 |
VerificationType::reference_check(), CHECK_VERIFY(this)); |
|
1013 |
if (!atype.is_short_array()) { |
|
13476 | 1014 |
verify_error(ErrorContext::bad_type(bci, |
1015 |
current_frame.stack_top_ctx(), ref_ctx("[S", THREAD)), |
|
1016 |
bad_type_msg, "sastore"); |
|
1 | 1017 |
return; |
1018 |
} |
|
1019 |
no_control_flow = false; break; |
|
1020 |
case Bytecodes::_lastore : |
|
1021 |
current_frame.pop_stack_2( |
|
1022 |
VerificationType::long2_type(), |
|
1023 |
VerificationType::long_type(), CHECK_VERIFY(this)); |
|
1024 |
current_frame.pop_stack( |
|
1025 |
VerificationType::integer_type(), CHECK_VERIFY(this)); |
|
1026 |
atype = current_frame.pop_stack( |
|
1027 |
VerificationType::reference_check(), CHECK_VERIFY(this)); |
|
1028 |
if (!atype.is_long_array()) { |
|
13476 | 1029 |
verify_error(ErrorContext::bad_type(bci, |
1030 |
current_frame.stack_top_ctx(), ref_ctx("[J", THREAD)), |
|
1031 |
bad_type_msg, "lastore"); |
|
1 | 1032 |
return; |
1033 |
} |
|
1034 |
no_control_flow = false; break; |
|
1035 |
case Bytecodes::_fastore : |
|
1036 |
current_frame.pop_stack( |
|
1037 |
VerificationType::float_type(), CHECK_VERIFY(this)); |
|
1038 |
current_frame.pop_stack |
|
1039 |
(VerificationType::integer_type(), CHECK_VERIFY(this)); |
|
1040 |
atype = current_frame.pop_stack( |
|
1041 |
VerificationType::reference_check(), CHECK_VERIFY(this)); |
|
1042 |
if (!atype.is_float_array()) { |
|
13476 | 1043 |
verify_error(ErrorContext::bad_type(bci, |
1044 |
current_frame.stack_top_ctx(), ref_ctx("[F", THREAD)), |
|
1045 |
bad_type_msg, "fastore"); |
|
1 | 1046 |
return; |
1047 |
} |
|
1048 |
no_control_flow = false; break; |
|
1049 |
case Bytecodes::_dastore : |
|
1050 |
current_frame.pop_stack_2( |
|
1051 |
VerificationType::double2_type(), |
|
1052 |
VerificationType::double_type(), CHECK_VERIFY(this)); |
|
1053 |
current_frame.pop_stack( |
|
1054 |
VerificationType::integer_type(), CHECK_VERIFY(this)); |
|
1055 |
atype = current_frame.pop_stack( |
|
1056 |
VerificationType::reference_check(), CHECK_VERIFY(this)); |
|
1057 |
if (!atype.is_double_array()) { |
|
13476 | 1058 |
verify_error(ErrorContext::bad_type(bci, |
1059 |
current_frame.stack_top_ctx(), ref_ctx("[D", THREAD)), |
|
1060 |
bad_type_msg, "dastore"); |
|
1 | 1061 |
return; |
1062 |
} |
|
1063 |
no_control_flow = false; break; |
|
1064 |
case Bytecodes::_aastore : |
|
7380
041cf7f1cce6
6865028: Illegal instructions passing verification prior to 'invokespecial Object.<init>'
kamg
parents:
6173
diff
changeset
|
1065 |
type = current_frame.pop_stack(object_type(), CHECK_VERIFY(this)); |
1 | 1066 |
type2 = current_frame.pop_stack( |
1067 |
VerificationType::integer_type(), CHECK_VERIFY(this)); |
|
1068 |
atype = current_frame.pop_stack( |
|
1069 |
VerificationType::reference_check(), CHECK_VERIFY(this)); |
|
1070 |
// more type-checking is done at runtime |
|
1071 |
if (!atype.is_reference_array()) { |
|
13476 | 1072 |
verify_error(ErrorContext::bad_type(bci, |
1073 |
current_frame.stack_top_ctx(), |
|
1074 |
TypeOrigin::implicit(VerificationType::reference_check())), |
|
1075 |
bad_type_msg, "aastore"); |
|
1 | 1076 |
return; |
1077 |
} |
|
1078 |
// 4938384: relaxed constraint in JVMS 3nd edition. |
|
1079 |
no_control_flow = false; break; |
|
1080 |
case Bytecodes::_pop : |
|
1081 |
current_frame.pop_stack( |
|
1082 |
VerificationType::category1_check(), CHECK_VERIFY(this)); |
|
1083 |
no_control_flow = false; break; |
|
1084 |
case Bytecodes::_pop2 : |
|
1085 |
type = current_frame.pop_stack(CHECK_VERIFY(this)); |
|
1086 |
if (type.is_category1()) { |
|
1087 |
current_frame.pop_stack( |
|
1088 |
VerificationType::category1_check(), CHECK_VERIFY(this)); |
|
1089 |
} else if (type.is_category2_2nd()) { |
|
1090 |
current_frame.pop_stack( |
|
1091 |
VerificationType::category2_check(), CHECK_VERIFY(this)); |
|
1092 |
} else { |
|
13476 | 1093 |
/* Unreachable? Would need a category2_1st on TOS |
1094 |
* which does not appear possible. */ |
|
1095 |
verify_error( |
|
1096 |
ErrorContext::bad_type(bci, current_frame.stack_top_ctx()), |
|
1097 |
bad_type_msg, "pop2"); |
|
1 | 1098 |
return; |
1099 |
} |
|
1100 |
no_control_flow = false; break; |
|
1101 |
case Bytecodes::_dup : |
|
1102 |
type = current_frame.pop_stack( |
|
1103 |
VerificationType::category1_check(), CHECK_VERIFY(this)); |
|
1104 |
current_frame.push_stack(type, CHECK_VERIFY(this)); |
|
1105 |
current_frame.push_stack(type, CHECK_VERIFY(this)); |
|
1106 |
no_control_flow = false; break; |
|
1107 |
case Bytecodes::_dup_x1 : |
|
1108 |
type = current_frame.pop_stack( |
|
1109 |
VerificationType::category1_check(), CHECK_VERIFY(this)); |
|
1110 |
type2 = current_frame.pop_stack( |
|
1111 |
VerificationType::category1_check(), CHECK_VERIFY(this)); |
|
1112 |
current_frame.push_stack(type, CHECK_VERIFY(this)); |
|
1113 |
current_frame.push_stack(type2, CHECK_VERIFY(this)); |
|
1114 |
current_frame.push_stack(type, CHECK_VERIFY(this)); |
|
1115 |
no_control_flow = false; break; |
|
1116 |
case Bytecodes::_dup_x2 : |
|
1117 |
{ |
|
1118 |
VerificationType type3; |
|
1119 |
type = current_frame.pop_stack( |
|
1120 |
VerificationType::category1_check(), CHECK_VERIFY(this)); |
|
1121 |
type2 = current_frame.pop_stack(CHECK_VERIFY(this)); |
|
1122 |
if (type2.is_category1()) { |
|
1123 |
type3 = current_frame.pop_stack( |
|
1124 |
VerificationType::category1_check(), CHECK_VERIFY(this)); |
|
1125 |
} else if (type2.is_category2_2nd()) { |
|
1126 |
type3 = current_frame.pop_stack( |
|
1127 |
VerificationType::category2_check(), CHECK_VERIFY(this)); |
|
1128 |
} else { |
|
13476 | 1129 |
/* Unreachable? Would need a category2_1st at stack depth 2 with |
1130 |
* a category1 on TOS which does not appear possible. */ |
|
1131 |
verify_error(ErrorContext::bad_type( |
|
1132 |
bci, current_frame.stack_top_ctx()), bad_type_msg, "dup_x2"); |
|
1 | 1133 |
return; |
1134 |
} |
|
1135 |
current_frame.push_stack(type, CHECK_VERIFY(this)); |
|
1136 |
current_frame.push_stack(type3, CHECK_VERIFY(this)); |
|
1137 |
current_frame.push_stack(type2, CHECK_VERIFY(this)); |
|
1138 |
current_frame.push_stack(type, CHECK_VERIFY(this)); |
|
1139 |
no_control_flow = false; break; |
|
1140 |
} |
|
1141 |
case Bytecodes::_dup2 : |
|
1142 |
type = current_frame.pop_stack(CHECK_VERIFY(this)); |
|
1143 |
if (type.is_category1()) { |
|
1144 |
type2 = current_frame.pop_stack( |
|
1145 |
VerificationType::category1_check(), CHECK_VERIFY(this)); |
|
1146 |
} else if (type.is_category2_2nd()) { |
|
1147 |
type2 = current_frame.pop_stack( |
|
1148 |
VerificationType::category2_check(), CHECK_VERIFY(this)); |
|
1149 |
} else { |
|
13476 | 1150 |
/* Unreachable? Would need a category2_1st on TOS which does not |
1151 |
* appear possible. */ |
|
1152 |
verify_error( |
|
1153 |
ErrorContext::bad_type(bci, current_frame.stack_top_ctx()), |
|
1154 |
bad_type_msg, "dup2"); |
|
1 | 1155 |
return; |
1156 |
} |
|
1157 |
current_frame.push_stack(type2, CHECK_VERIFY(this)); |
|
1158 |
current_frame.push_stack(type, CHECK_VERIFY(this)); |
|
1159 |
current_frame.push_stack(type2, CHECK_VERIFY(this)); |
|
1160 |
current_frame.push_stack(type, CHECK_VERIFY(this)); |
|
1161 |
no_control_flow = false; break; |
|
1162 |
case Bytecodes::_dup2_x1 : |
|
1163 |
{ |
|
1164 |
VerificationType type3; |
|
1165 |
type = current_frame.pop_stack(CHECK_VERIFY(this)); |
|
1166 |
if (type.is_category1()) { |
|
1167 |
type2 = current_frame.pop_stack( |
|
1168 |
VerificationType::category1_check(), CHECK_VERIFY(this)); |
|
13476 | 1169 |
} else if (type.is_category2_2nd()) { |
1170 |
type2 = current_frame.pop_stack( |
|
1171 |
VerificationType::category2_check(), CHECK_VERIFY(this)); |
|
1 | 1172 |
} else { |
13476 | 1173 |
/* Unreachable? Would need a category2_1st on TOS which does |
1174 |
* not appear possible. */ |
|
1175 |
verify_error( |
|
1176 |
ErrorContext::bad_type(bci, current_frame.stack_top_ctx()), |
|
1177 |
bad_type_msg, "dup2_x1"); |
|
1 | 1178 |
return; |
1179 |
} |
|
1180 |
type3 = current_frame.pop_stack( |
|
1181 |
VerificationType::category1_check(), CHECK_VERIFY(this)); |
|
1182 |
current_frame.push_stack(type2, CHECK_VERIFY(this)); |
|
1183 |
current_frame.push_stack(type, CHECK_VERIFY(this)); |
|
1184 |
current_frame.push_stack(type3, CHECK_VERIFY(this)); |
|
1185 |
current_frame.push_stack(type2, CHECK_VERIFY(this)); |
|
1186 |
current_frame.push_stack(type, CHECK_VERIFY(this)); |
|
1187 |
no_control_flow = false; break; |
|
1188 |
} |
|
1189 |
case Bytecodes::_dup2_x2 : |
|
1190 |
{ |
|
1191 |
VerificationType type3, type4; |
|
1192 |
type = current_frame.pop_stack(CHECK_VERIFY(this)); |
|
1193 |
if (type.is_category1()) { |
|
1194 |
type2 = current_frame.pop_stack( |
|
1195 |
VerificationType::category1_check(), CHECK_VERIFY(this)); |
|
1196 |
} else if (type.is_category2_2nd()) { |
|
1197 |
type2 = current_frame.pop_stack( |
|
1198 |
VerificationType::category2_check(), CHECK_VERIFY(this)); |
|
1199 |
} else { |
|
13476 | 1200 |
/* Unreachable? Would need a category2_1st on TOS which does |
1201 |
* not appear possible. */ |
|
1202 |
verify_error( |
|
1203 |
ErrorContext::bad_type(bci, current_frame.stack_top_ctx()), |
|
1204 |
bad_type_msg, "dup2_x2"); |
|
1 | 1205 |
return; |
1206 |
} |
|
1207 |
type3 = current_frame.pop_stack(CHECK_VERIFY(this)); |
|
1208 |
if (type3.is_category1()) { |
|
1209 |
type4 = current_frame.pop_stack( |
|
1210 |
VerificationType::category1_check(), CHECK_VERIFY(this)); |
|
1211 |
} else if (type3.is_category2_2nd()) { |
|
1212 |
type4 = current_frame.pop_stack( |
|
1213 |
VerificationType::category2_check(), CHECK_VERIFY(this)); |
|
1214 |
} else { |
|
13476 | 1215 |
/* Unreachable? Would need a category2_1st on TOS after popping |
1216 |
* a long/double or two category 1's, which does not |
|
1217 |
* appear possible. */ |
|
1218 |
verify_error( |
|
1219 |
ErrorContext::bad_type(bci, current_frame.stack_top_ctx()), |
|
1220 |
bad_type_msg, "dup2_x2"); |
|
1 | 1221 |
return; |
1222 |
} |
|
1223 |
current_frame.push_stack(type2, CHECK_VERIFY(this)); |
|
1224 |
current_frame.push_stack(type, CHECK_VERIFY(this)); |
|
1225 |
current_frame.push_stack(type4, CHECK_VERIFY(this)); |
|
1226 |
current_frame.push_stack(type3, CHECK_VERIFY(this)); |
|
1227 |
current_frame.push_stack(type2, CHECK_VERIFY(this)); |
|
1228 |
current_frame.push_stack(type, CHECK_VERIFY(this)); |
|
1229 |
no_control_flow = false; break; |
|
1230 |
} |
|
1231 |
case Bytecodes::_swap : |
|
1232 |
type = current_frame.pop_stack( |
|
1233 |
VerificationType::category1_check(), CHECK_VERIFY(this)); |
|
1234 |
type2 = current_frame.pop_stack( |
|
1235 |
VerificationType::category1_check(), CHECK_VERIFY(this)); |
|
1236 |
current_frame.push_stack(type, CHECK_VERIFY(this)); |
|
1237 |
current_frame.push_stack(type2, CHECK_VERIFY(this)); |
|
1238 |
no_control_flow = false; break; |
|
1239 |
case Bytecodes::_iadd : |
|
1240 |
case Bytecodes::_isub : |
|
1241 |
case Bytecodes::_imul : |
|
1242 |
case Bytecodes::_idiv : |
|
1243 |
case Bytecodes::_irem : |
|
1244 |
case Bytecodes::_ishl : |
|
1245 |
case Bytecodes::_ishr : |
|
1246 |
case Bytecodes::_iushr : |
|
1247 |
case Bytecodes::_ior : |
|
1248 |
case Bytecodes::_ixor : |
|
1249 |
case Bytecodes::_iand : |
|
1250 |
current_frame.pop_stack( |
|
1251 |
VerificationType::integer_type(), CHECK_VERIFY(this)); |
|
1252 |
// fall through |
|
1253 |
case Bytecodes::_ineg : |
|
1254 |
current_frame.pop_stack( |
|
1255 |
VerificationType::integer_type(), CHECK_VERIFY(this)); |
|
1256 |
current_frame.push_stack( |
|
1257 |
VerificationType::integer_type(), CHECK_VERIFY(this)); |
|
1258 |
no_control_flow = false; break; |
|
1259 |
case Bytecodes::_ladd : |
|
1260 |
case Bytecodes::_lsub : |
|
1261 |
case Bytecodes::_lmul : |
|
1262 |
case Bytecodes::_ldiv : |
|
1263 |
case Bytecodes::_lrem : |
|
1264 |
case Bytecodes::_land : |
|
1265 |
case Bytecodes::_lor : |
|
1266 |
case Bytecodes::_lxor : |
|
1267 |
current_frame.pop_stack_2( |
|
1268 |
VerificationType::long2_type(), |
|
1269 |
VerificationType::long_type(), CHECK_VERIFY(this)); |
|
1270 |
// fall through |
|
1271 |
case Bytecodes::_lneg : |
|
1272 |
current_frame.pop_stack_2( |
|
1273 |
VerificationType::long2_type(), |
|
1274 |
VerificationType::long_type(), CHECK_VERIFY(this)); |
|
1275 |
current_frame.push_stack_2( |
|
1276 |
VerificationType::long_type(), |
|
1277 |
VerificationType::long2_type(), CHECK_VERIFY(this)); |
|
1278 |
no_control_flow = false; break; |
|
1279 |
case Bytecodes::_lshl : |
|
1280 |
case Bytecodes::_lshr : |
|
1281 |
case Bytecodes::_lushr : |
|
1282 |
current_frame.pop_stack( |
|
1283 |
VerificationType::integer_type(), CHECK_VERIFY(this)); |
|
1284 |
current_frame.pop_stack_2( |
|
1285 |
VerificationType::long2_type(), |
|
1286 |
VerificationType::long_type(), CHECK_VERIFY(this)); |
|
1287 |
current_frame.push_stack_2( |
|
1288 |
VerificationType::long_type(), |
|
1289 |
VerificationType::long2_type(), CHECK_VERIFY(this)); |
|
1290 |
no_control_flow = false; break; |
|
1291 |
case Bytecodes::_fadd : |
|
1292 |
case Bytecodes::_fsub : |
|
1293 |
case Bytecodes::_fmul : |
|
1294 |
case Bytecodes::_fdiv : |
|
1295 |
case Bytecodes::_frem : |
|
1296 |
current_frame.pop_stack( |
|
1297 |
VerificationType::float_type(), CHECK_VERIFY(this)); |
|
1298 |
// fall through |
|
1299 |
case Bytecodes::_fneg : |
|
1300 |
current_frame.pop_stack( |
|
1301 |
VerificationType::float_type(), CHECK_VERIFY(this)); |
|
1302 |
current_frame.push_stack( |
|
1303 |
VerificationType::float_type(), CHECK_VERIFY(this)); |
|
1304 |
no_control_flow = false; break; |
|
1305 |
case Bytecodes::_dadd : |
|
1306 |
case Bytecodes::_dsub : |
|
1307 |
case Bytecodes::_dmul : |
|
1308 |
case Bytecodes::_ddiv : |
|
1309 |
case Bytecodes::_drem : |
|
1310 |
current_frame.pop_stack_2( |
|
1311 |
VerificationType::double2_type(), |
|
1312 |
VerificationType::double_type(), CHECK_VERIFY(this)); |
|
1313 |
// fall through |
|
1314 |
case Bytecodes::_dneg : |
|
1315 |
current_frame.pop_stack_2( |
|
1316 |
VerificationType::double2_type(), |
|
1317 |
VerificationType::double_type(), CHECK_VERIFY(this)); |
|
1318 |
current_frame.push_stack_2( |
|
1319 |
VerificationType::double_type(), |
|
1320 |
VerificationType::double2_type(), CHECK_VERIFY(this)); |
|
1321 |
no_control_flow = false; break; |
|
1322 |
case Bytecodes::_iinc : |
|
1323 |
verify_iinc(bcs.get_index(), ¤t_frame, CHECK_VERIFY(this)); |
|
1324 |
no_control_flow = false; break; |
|
1325 |
case Bytecodes::_i2l : |
|
1326 |
type = current_frame.pop_stack( |
|
1327 |
VerificationType::integer_type(), CHECK_VERIFY(this)); |
|
1328 |
current_frame.push_stack_2( |
|
1329 |
VerificationType::long_type(), |
|
1330 |
VerificationType::long2_type(), CHECK_VERIFY(this)); |
|
1331 |
no_control_flow = false; break; |
|
1332 |
case Bytecodes::_l2i : |
|
1333 |
current_frame.pop_stack_2( |
|
1334 |
VerificationType::long2_type(), |
|
1335 |
VerificationType::long_type(), CHECK_VERIFY(this)); |
|
1336 |
current_frame.push_stack( |
|
1337 |
VerificationType::integer_type(), CHECK_VERIFY(this)); |
|
1338 |
no_control_flow = false; break; |
|
1339 |
case Bytecodes::_i2f : |
|
1340 |
current_frame.pop_stack( |
|
1341 |
VerificationType::integer_type(), CHECK_VERIFY(this)); |
|
1342 |
current_frame.push_stack( |
|
1343 |
VerificationType::float_type(), CHECK_VERIFY(this)); |
|
1344 |
no_control_flow = false; break; |
|
1345 |
case Bytecodes::_i2d : |
|
1346 |
current_frame.pop_stack( |
|
1347 |
VerificationType::integer_type(), CHECK_VERIFY(this)); |
|
1348 |
current_frame.push_stack_2( |
|
1349 |
VerificationType::double_type(), |
|
1350 |
VerificationType::double2_type(), CHECK_VERIFY(this)); |
|
1351 |
no_control_flow = false; break; |
|
1352 |
case Bytecodes::_l2f : |
|
1353 |
current_frame.pop_stack_2( |
|
1354 |
VerificationType::long2_type(), |
|
1355 |
VerificationType::long_type(), CHECK_VERIFY(this)); |
|
1356 |
current_frame.push_stack( |
|
1357 |
VerificationType::float_type(), CHECK_VERIFY(this)); |
|
1358 |
no_control_flow = false; break; |
|
1359 |
case Bytecodes::_l2d : |
|
1360 |
current_frame.pop_stack_2( |
|
1361 |
VerificationType::long2_type(), |
|
1362 |
VerificationType::long_type(), CHECK_VERIFY(this)); |
|
1363 |
current_frame.push_stack_2( |
|
1364 |
VerificationType::double_type(), |
|
1365 |
VerificationType::double2_type(), CHECK_VERIFY(this)); |
|
1366 |
no_control_flow = false; break; |
|
1367 |
case Bytecodes::_f2i : |
|
1368 |
current_frame.pop_stack( |
|
1369 |
VerificationType::float_type(), CHECK_VERIFY(this)); |
|
1370 |
current_frame.push_stack( |
|
1371 |
VerificationType::integer_type(), CHECK_VERIFY(this)); |
|
1372 |
no_control_flow = false; break; |
|
1373 |
case Bytecodes::_f2l : |
|
1374 |
current_frame.pop_stack( |
|
1375 |
VerificationType::float_type(), CHECK_VERIFY(this)); |
|
1376 |
current_frame.push_stack_2( |
|
1377 |
VerificationType::long_type(), |
|
1378 |
VerificationType::long2_type(), CHECK_VERIFY(this)); |
|
1379 |
no_control_flow = false; break; |
|
1380 |
case Bytecodes::_f2d : |
|
1381 |
current_frame.pop_stack( |
|
1382 |
VerificationType::float_type(), CHECK_VERIFY(this)); |
|
1383 |
current_frame.push_stack_2( |
|
1384 |
VerificationType::double_type(), |
|
1385 |
VerificationType::double2_type(), CHECK_VERIFY(this)); |
|
1386 |
no_control_flow = false; break; |
|
1387 |
case Bytecodes::_d2i : |
|
1388 |
current_frame.pop_stack_2( |
|
1389 |
VerificationType::double2_type(), |
|
1390 |
VerificationType::double_type(), CHECK_VERIFY(this)); |
|
1391 |
current_frame.push_stack( |
|
1392 |
VerificationType::integer_type(), CHECK_VERIFY(this)); |
|
1393 |
no_control_flow = false; break; |
|
1394 |
case Bytecodes::_d2l : |
|
1395 |
current_frame.pop_stack_2( |
|
1396 |
VerificationType::double2_type(), |
|
1397 |
VerificationType::double_type(), CHECK_VERIFY(this)); |
|
1398 |
current_frame.push_stack_2( |
|
1399 |
VerificationType::long_type(), |
|
1400 |
VerificationType::long2_type(), CHECK_VERIFY(this)); |
|
1401 |
no_control_flow = false; break; |
|
1402 |
case Bytecodes::_d2f : |
|
1403 |
current_frame.pop_stack_2( |
|
1404 |
VerificationType::double2_type(), |
|
1405 |
VerificationType::double_type(), CHECK_VERIFY(this)); |
|
1406 |
current_frame.push_stack( |
|
1407 |
VerificationType::float_type(), CHECK_VERIFY(this)); |
|
1408 |
no_control_flow = false; break; |
|
1409 |
case Bytecodes::_i2b : |
|
1410 |
case Bytecodes::_i2c : |
|
1411 |
case Bytecodes::_i2s : |
|
1412 |
current_frame.pop_stack( |
|
1413 |
VerificationType::integer_type(), CHECK_VERIFY(this)); |
|
1414 |
current_frame.push_stack( |
|
1415 |
VerificationType::integer_type(), CHECK_VERIFY(this)); |
|
1416 |
no_control_flow = false; break; |
|
1417 |
case Bytecodes::_lcmp : |
|
1418 |
current_frame.pop_stack_2( |
|
1419 |
VerificationType::long2_type(), |
|
1420 |
VerificationType::long_type(), CHECK_VERIFY(this)); |
|
1421 |
current_frame.pop_stack_2( |
|
1422 |
VerificationType::long2_type(), |
|
1423 |
VerificationType::long_type(), CHECK_VERIFY(this)); |
|
1424 |
current_frame.push_stack( |
|
1425 |
VerificationType::integer_type(), CHECK_VERIFY(this)); |
|
1426 |
no_control_flow = false; break; |
|
1427 |
case Bytecodes::_fcmpl : |
|
1428 |
case Bytecodes::_fcmpg : |
|
1429 |
current_frame.pop_stack( |
|
1430 |
VerificationType::float_type(), CHECK_VERIFY(this)); |
|
1431 |
current_frame.pop_stack( |
|
1432 |
VerificationType::float_type(), CHECK_VERIFY(this)); |
|
1433 |
current_frame.push_stack( |
|
1434 |
VerificationType::integer_type(), CHECK_VERIFY(this)); |
|
1435 |
no_control_flow = false; break; |
|
1436 |
case Bytecodes::_dcmpl : |
|
1437 |
case Bytecodes::_dcmpg : |
|
1438 |
current_frame.pop_stack_2( |
|
1439 |
VerificationType::double2_type(), |
|
1440 |
VerificationType::double_type(), CHECK_VERIFY(this)); |
|
1441 |
current_frame.pop_stack_2( |
|
1442 |
VerificationType::double2_type(), |
|
1443 |
VerificationType::double_type(), CHECK_VERIFY(this)); |
|
1444 |
current_frame.push_stack( |
|
1445 |
VerificationType::integer_type(), CHECK_VERIFY(this)); |
|
1446 |
no_control_flow = false; break; |
|
1447 |
case Bytecodes::_if_icmpeq: |
|
1448 |
case Bytecodes::_if_icmpne: |
|
1449 |
case Bytecodes::_if_icmplt: |
|
1450 |
case Bytecodes::_if_icmpge: |
|
1451 |
case Bytecodes::_if_icmpgt: |
|
1452 |
case Bytecodes::_if_icmple: |
|
1453 |
current_frame.pop_stack( |
|
1454 |
VerificationType::integer_type(), CHECK_VERIFY(this)); |
|
1455 |
// fall through |
|
1456 |
case Bytecodes::_ifeq: |
|
1457 |
case Bytecodes::_ifne: |
|
1458 |
case Bytecodes::_iflt: |
|
1459 |
case Bytecodes::_ifge: |
|
1460 |
case Bytecodes::_ifgt: |
|
1461 |
case Bytecodes::_ifle: |
|
1462 |
current_frame.pop_stack( |
|
1463 |
VerificationType::integer_type(), CHECK_VERIFY(this)); |
|
1464 |
target = bcs.dest(); |
|
1465 |
stackmap_table.check_jump_target( |
|
1466 |
¤t_frame, target, CHECK_VERIFY(this)); |
|
1467 |
no_control_flow = false; break; |
|
1468 |
case Bytecodes::_if_acmpeq : |
|
1469 |
case Bytecodes::_if_acmpne : |
|
1470 |
current_frame.pop_stack( |
|
1471 |
VerificationType::reference_check(), CHECK_VERIFY(this)); |
|
1472 |
// fall through |
|
1473 |
case Bytecodes::_ifnull : |
|
1474 |
case Bytecodes::_ifnonnull : |
|
1475 |
current_frame.pop_stack( |
|
1476 |
VerificationType::reference_check(), CHECK_VERIFY(this)); |
|
1477 |
target = bcs.dest(); |
|
1478 |
stackmap_table.check_jump_target |
|
1479 |
(¤t_frame, target, CHECK_VERIFY(this)); |
|
1480 |
no_control_flow = false; break; |
|
1481 |
case Bytecodes::_goto : |
|
1482 |
target = bcs.dest(); |
|
1483 |
stackmap_table.check_jump_target( |
|
1484 |
¤t_frame, target, CHECK_VERIFY(this)); |
|
1485 |
no_control_flow = true; break; |
|
1486 |
case Bytecodes::_goto_w : |
|
1487 |
target = bcs.dest_w(); |
|
1488 |
stackmap_table.check_jump_target( |
|
1489 |
¤t_frame, target, CHECK_VERIFY(this)); |
|
1490 |
no_control_flow = true; break; |
|
1491 |
case Bytecodes::_tableswitch : |
|
1492 |
case Bytecodes::_lookupswitch : |
|
1493 |
verify_switch( |
|
1494 |
&bcs, code_length, code_data, ¤t_frame, |
|
1495 |
&stackmap_table, CHECK_VERIFY(this)); |
|
1496 |
no_control_flow = true; break; |
|
1497 |
case Bytecodes::_ireturn : |
|
1498 |
type = current_frame.pop_stack( |
|
1499 |
VerificationType::integer_type(), CHECK_VERIFY(this)); |
|
13476 | 1500 |
verify_return_value(return_type, type, bci, |
1501 |
¤t_frame, CHECK_VERIFY(this)); |
|
1 | 1502 |
no_control_flow = true; break; |
1503 |
case Bytecodes::_lreturn : |
|
1504 |
type2 = current_frame.pop_stack( |
|
1505 |
VerificationType::long2_type(), CHECK_VERIFY(this)); |
|
1506 |
type = current_frame.pop_stack( |
|
1507 |
VerificationType::long_type(), CHECK_VERIFY(this)); |
|
13476 | 1508 |
verify_return_value(return_type, type, bci, |
1509 |
¤t_frame, CHECK_VERIFY(this)); |
|
1 | 1510 |
no_control_flow = true; break; |
1511 |
case Bytecodes::_freturn : |
|
1512 |
type = current_frame.pop_stack( |
|
1513 |
VerificationType::float_type(), CHECK_VERIFY(this)); |
|
13476 | 1514 |
verify_return_value(return_type, type, bci, |
1515 |
¤t_frame, CHECK_VERIFY(this)); |
|
1 | 1516 |
no_control_flow = true; break; |
1517 |
case Bytecodes::_dreturn : |
|
1518 |
type2 = current_frame.pop_stack( |
|
1519 |
VerificationType::double2_type(), CHECK_VERIFY(this)); |
|
1520 |
type = current_frame.pop_stack( |
|
1521 |
VerificationType::double_type(), CHECK_VERIFY(this)); |
|
13476 | 1522 |
verify_return_value(return_type, type, bci, |
1523 |
¤t_frame, CHECK_VERIFY(this)); |
|
1 | 1524 |
no_control_flow = true; break; |
1525 |
case Bytecodes::_areturn : |
|
1526 |
type = current_frame.pop_stack( |
|
1527 |
VerificationType::reference_check(), CHECK_VERIFY(this)); |
|
13476 | 1528 |
verify_return_value(return_type, type, bci, |
1529 |
¤t_frame, CHECK_VERIFY(this)); |
|
1 | 1530 |
no_control_flow = true; break; |
1531 |
case Bytecodes::_return : |
|
1532 |
if (return_type != VerificationType::bogus_type()) { |
|
13476 | 1533 |
verify_error(ErrorContext::bad_code(bci), |
1534 |
"Method expects a return value"); |
|
1 | 1535 |
return; |
1536 |
} |
|
1537 |
// Make sure "this" has been initialized if current method is an |
|
1538 |
// <init> |
|
1539 |
if (_method->name() == vmSymbols::object_initializer_name() && |
|
1540 |
current_frame.flag_this_uninit()) { |
|
13476 | 1541 |
verify_error(ErrorContext::bad_code(bci), |
1542 |
"Constructor must call super() or this() " |
|
1543 |
"before return"); |
|
1 | 1544 |
return; |
1545 |
} |
|
1546 |
no_control_flow = true; break; |
|
1547 |
case Bytecodes::_getstatic : |
|
1548 |
case Bytecodes::_putstatic : |
|
1549 |
case Bytecodes::_getfield : |
|
1550 |
case Bytecodes::_putfield : |
|
1551 |
verify_field_instructions( |
|
1552 |
&bcs, ¤t_frame, cp, CHECK_VERIFY(this)); |
|
1553 |
no_control_flow = false; break; |
|
1554 |
case Bytecodes::_invokevirtual : |
|
1555 |
case Bytecodes::_invokespecial : |
|
1556 |
case Bytecodes::_invokestatic : |
|
1557 |
verify_invoke_instructions( |
|
1558 |
&bcs, code_length, ¤t_frame, |
|
1559 |
&this_uninit, return_type, cp, CHECK_VERIFY(this)); |
|
1560 |
no_control_flow = false; break; |
|
1561 |
case Bytecodes::_invokeinterface : |
|
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
1550
diff
changeset
|
1562 |
case Bytecodes::_invokedynamic : |
1 | 1563 |
verify_invoke_instructions( |
1564 |
&bcs, code_length, ¤t_frame, |
|
1565 |
&this_uninit, return_type, cp, CHECK_VERIFY(this)); |
|
1566 |
no_control_flow = false; break; |
|
1567 |
case Bytecodes::_new : |
|
1568 |
{ |
|
5688 | 1569 |
index = bcs.get_index_u2(); |
13476 | 1570 |
verify_cp_class_type(bci, index, cp, CHECK_VERIFY(this)); |
1 | 1571 |
VerificationType new_class_type = |
1572 |
cp_index_to_type(index, cp, CHECK_VERIFY(this)); |
|
1573 |
if (!new_class_type.is_object()) { |
|
13476 | 1574 |
verify_error(ErrorContext::bad_type(bci, |
1575 |
TypeOrigin::cp(index, new_class_type)), |
|
1576 |
"Illegal new instruction"); |
|
1 | 1577 |
return; |
1578 |
} |
|
1579 |
type = VerificationType::uninitialized_type(bci); |
|
1580 |
current_frame.push_stack(type, CHECK_VERIFY(this)); |
|
1581 |
no_control_flow = false; break; |
|
1582 |
} |
|
1583 |
case Bytecodes::_newarray : |
|
1584 |
type = get_newarray_type(bcs.get_index(), bci, CHECK_VERIFY(this)); |
|
1585 |
current_frame.pop_stack( |
|
1586 |
VerificationType::integer_type(), CHECK_VERIFY(this)); |
|
1587 |
current_frame.push_stack(type, CHECK_VERIFY(this)); |
|
1588 |
no_control_flow = false; break; |
|
1589 |
case Bytecodes::_anewarray : |
|
1590 |
verify_anewarray( |
|
13476 | 1591 |
bci, bcs.get_index_u2(), cp, ¤t_frame, CHECK_VERIFY(this)); |
1 | 1592 |
no_control_flow = false; break; |
1593 |
case Bytecodes::_arraylength : |
|
1594 |
type = current_frame.pop_stack( |
|
1595 |
VerificationType::reference_check(), CHECK_VERIFY(this)); |
|
381
e7275780f686
6692246: Regression : JDK 6u4 b01 fails two JCK tests when fallback is switched off
kamg
parents:
1
diff
changeset
|
1596 |
if (!(type.is_null() || type.is_array())) { |
13476 | 1597 |
verify_error(ErrorContext::bad_type( |
1598 |
bci, current_frame.stack_top_ctx()), |
|
1599 |
bad_type_msg, "arraylength"); |
|
1 | 1600 |
} |
1601 |
current_frame.push_stack( |
|
1602 |
VerificationType::integer_type(), CHECK_VERIFY(this)); |
|
1603 |
no_control_flow = false; break; |
|
1604 |
case Bytecodes::_checkcast : |
|
1605 |
{ |
|
5688 | 1606 |
index = bcs.get_index_u2(); |
13476 | 1607 |
verify_cp_class_type(bci, index, cp, CHECK_VERIFY(this)); |
7380
041cf7f1cce6
6865028: Illegal instructions passing verification prior to 'invokespecial Object.<init>'
kamg
parents:
6173
diff
changeset
|
1608 |
current_frame.pop_stack(object_type(), CHECK_VERIFY(this)); |
1 | 1609 |
VerificationType klass_type = cp_index_to_type( |
1610 |
index, cp, CHECK_VERIFY(this)); |
|
1611 |
current_frame.push_stack(klass_type, CHECK_VERIFY(this)); |
|
1612 |
no_control_flow = false; break; |
|
1613 |
} |
|
1614 |
case Bytecodes::_instanceof : { |
|
5688 | 1615 |
index = bcs.get_index_u2(); |
13476 | 1616 |
verify_cp_class_type(bci, index, cp, CHECK_VERIFY(this)); |
7380
041cf7f1cce6
6865028: Illegal instructions passing verification prior to 'invokespecial Object.<init>'
kamg
parents:
6173
diff
changeset
|
1617 |
current_frame.pop_stack(object_type(), CHECK_VERIFY(this)); |
1 | 1618 |
current_frame.push_stack( |
1619 |
VerificationType::integer_type(), CHECK_VERIFY(this)); |
|
1620 |
no_control_flow = false; break; |
|
1621 |
} |
|
1622 |
case Bytecodes::_monitorenter : |
|
1623 |
case Bytecodes::_monitorexit : |
|
1624 |
current_frame.pop_stack( |
|
1625 |
VerificationType::reference_check(), CHECK_VERIFY(this)); |
|
1626 |
no_control_flow = false; break; |
|
1627 |
case Bytecodes::_multianewarray : |
|
1628 |
{ |
|
5688 | 1629 |
index = bcs.get_index_u2(); |
1 | 1630 |
u2 dim = *(bcs.bcp()+3); |
13476 | 1631 |
verify_cp_class_type(bci, index, cp, CHECK_VERIFY(this)); |
1 | 1632 |
VerificationType new_array_type = |
1633 |
cp_index_to_type(index, cp, CHECK_VERIFY(this)); |
|
1634 |
if (!new_array_type.is_array()) { |
|
13476 | 1635 |
verify_error(ErrorContext::bad_type(bci, |
1636 |
TypeOrigin::cp(index, new_array_type)), |
|
1637 |
"Illegal constant pool index in multianewarray instruction"); |
|
1 | 1638 |
return; |
1639 |
} |
|
1640 |
if (dim < 1 || new_array_type.dimensions() < dim) { |
|
13476 | 1641 |
verify_error(ErrorContext::bad_code(bci), |
1642 |
"Illegal dimension in multianewarray instruction: %d", dim); |
|
1 | 1643 |
return; |
1644 |
} |
|
1645 |
for (int i = 0; i < dim; i++) { |
|
1646 |
current_frame.pop_stack( |
|
1647 |
VerificationType::integer_type(), CHECK_VERIFY(this)); |
|
1648 |
} |
|
1649 |
current_frame.push_stack(new_array_type, CHECK_VERIFY(this)); |
|
1650 |
no_control_flow = false; break; |
|
1651 |
} |
|
1652 |
case Bytecodes::_athrow : |
|
1653 |
type = VerificationType::reference_type( |
|
1654 |
vmSymbols::java_lang_Throwable()); |
|
1655 |
current_frame.pop_stack(type, CHECK_VERIFY(this)); |
|
1656 |
no_control_flow = true; break; |
|
1657 |
default: |
|
1658 |
// We only need to check the valid bytecodes in class file. |
|
1659 |
// And jsr and ret are not in the new class file format in JDK1.5. |
|
13476 | 1660 |
verify_error(ErrorContext::bad_code(bci), |
1661 |
"Bad instruction: %02x", opcode); |
|
1 | 1662 |
no_control_flow = false; |
1663 |
return; |
|
1664 |
} // end switch |
|
1665 |
} // end Merge with the next instruction |
|
1666 |
||
1667 |
// Look for possible jump target in exception handlers and see if it |
|
1668 |
// matches current_frame |
|
1669 |
if (bci >= ex_min && bci < ex_max) { |
|
1670 |
verify_exception_handler_targets( |
|
1671 |
bci, this_uninit, ¤t_frame, &stackmap_table, CHECK_VERIFY(this)); |
|
1672 |
} |
|
1673 |
} // end while |
|
1674 |
||
1675 |
// Make sure that control flow does not fall through end of the method |
|
1676 |
if (!no_control_flow) { |
|
13476 | 1677 |
verify_error(ErrorContext::bad_code(code_length), |
1678 |
"Control flow falls through code end"); |
|
1 | 1679 |
return; |
1680 |
} |
|
1681 |
} |
|
1682 |
||
24424
2658d7834c6e
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
24351
diff
changeset
|
1683 |
#undef bad_type_message |
2658d7834c6e
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
24351
diff
changeset
|
1684 |
|
1 | 1685 |
char* ClassVerifier::generate_code_data(methodHandle m, u4 code_length, TRAPS) { |
1686 |
char* code_data = NEW_RESOURCE_ARRAY(char, code_length); |
|
1687 |
memset(code_data, 0, sizeof(char) * code_length); |
|
1688 |
RawBytecodeStream bcs(m); |
|
1689 |
||
1690 |
while (!bcs.is_last_bytecode()) { |
|
1691 |
if (bcs.raw_next() != Bytecodes::_illegal) { |
|
1692 |
int bci = bcs.bci(); |
|
5688 | 1693 |
if (bcs.raw_code() == Bytecodes::_new) { |
1 | 1694 |
code_data[bci] = NEW_OFFSET; |
1695 |
} else { |
|
1696 |
code_data[bci] = BYTECODE_OFFSET; |
|
1697 |
} |
|
1698 |
} else { |
|
13476 | 1699 |
verify_error(ErrorContext::bad_code(bcs.bci()), "Bad instruction"); |
1 | 1700 |
return NULL; |
1701 |
} |
|
1702 |
} |
|
1703 |
||
1704 |
return code_data; |
|
1705 |
} |
|
1706 |
||
1707 |
void ClassVerifier::verify_exception_handler_table(u4 code_length, char* code_data, int& min, int& max, TRAPS) { |
|
13282
9872915dd78d
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
12932
diff
changeset
|
1708 |
ExceptionTable exhandlers(_method()); |
9872915dd78d
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
12932
diff
changeset
|
1709 |
int exlength = exhandlers.length(); |
1 | 1710 |
constantPoolHandle cp (THREAD, _method->constants()); |
1711 |
||
13282
9872915dd78d
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
12932
diff
changeset
|
1712 |
for(int i = 0; i < exlength; i++) { |
9872915dd78d
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
12932
diff
changeset
|
1713 |
//reacquire the table in case a GC happened |
9872915dd78d
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
12932
diff
changeset
|
1714 |
ExceptionTable exhandlers(_method()); |
9872915dd78d
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
12932
diff
changeset
|
1715 |
u2 start_pc = exhandlers.start_pc(i); |
9872915dd78d
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
12932
diff
changeset
|
1716 |
u2 end_pc = exhandlers.end_pc(i); |
9872915dd78d
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
12932
diff
changeset
|
1717 |
u2 handler_pc = exhandlers.handler_pc(i); |
9872915dd78d
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
12932
diff
changeset
|
1718 |
if (start_pc >= code_length || code_data[start_pc] == 0) { |
9872915dd78d
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
12932
diff
changeset
|
1719 |
class_format_error("Illegal exception table start_pc %d", start_pc); |
9872915dd78d
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
12932
diff
changeset
|
1720 |
return; |
9872915dd78d
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
12932
diff
changeset
|
1721 |
} |
9872915dd78d
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
12932
diff
changeset
|
1722 |
if (end_pc != code_length) { // special case: end_pc == code_length |
9872915dd78d
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
12932
diff
changeset
|
1723 |
if (end_pc > code_length || code_data[end_pc] == 0) { |
9872915dd78d
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
12932
diff
changeset
|
1724 |
class_format_error("Illegal exception table end_pc %d", end_pc); |
1 | 1725 |
return; |
1726 |
} |
|
13282
9872915dd78d
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
12932
diff
changeset
|
1727 |
} |
9872915dd78d
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
12932
diff
changeset
|
1728 |
if (handler_pc >= code_length || code_data[handler_pc] == 0) { |
9872915dd78d
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
12932
diff
changeset
|
1729 |
class_format_error("Illegal exception table handler_pc %d", handler_pc); |
9872915dd78d
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
12932
diff
changeset
|
1730 |
return; |
9872915dd78d
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
12932
diff
changeset
|
1731 |
} |
9872915dd78d
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
12932
diff
changeset
|
1732 |
int catch_type_index = exhandlers.catch_type_index(i); |
9872915dd78d
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
12932
diff
changeset
|
1733 |
if (catch_type_index != 0) { |
9872915dd78d
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
12932
diff
changeset
|
1734 |
VerificationType catch_type = cp_index_to_type( |
9872915dd78d
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
12932
diff
changeset
|
1735 |
catch_type_index, cp, CHECK_VERIFY(this)); |
9872915dd78d
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
12932
diff
changeset
|
1736 |
VerificationType throwable = |
9872915dd78d
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
12932
diff
changeset
|
1737 |
VerificationType::reference_type(vmSymbols::java_lang_Throwable()); |
9872915dd78d
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
12932
diff
changeset
|
1738 |
bool is_subclass = throwable.is_assignable_from( |
9872915dd78d
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
12932
diff
changeset
|
1739 |
catch_type, this, CHECK_VERIFY(this)); |
9872915dd78d
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
12932
diff
changeset
|
1740 |
if (!is_subclass) { |
9872915dd78d
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
12932
diff
changeset
|
1741 |
// 4286534: should throw VerifyError according to recent spec change |
13476 | 1742 |
verify_error(ErrorContext::bad_type(handler_pc, |
1743 |
TypeOrigin::cp(catch_type_index, catch_type), |
|
1744 |
TypeOrigin::implicit(throwable)), |
|
1745 |
"Catch type is not a subclass " |
|
1746 |
"of Throwable in exception handler %d", handler_pc); |
|
1 | 1747 |
return; |
1748 |
} |
|
1749 |
} |
|
13282
9872915dd78d
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
12932
diff
changeset
|
1750 |
if (start_pc < min) min = start_pc; |
9872915dd78d
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
12932
diff
changeset
|
1751 |
if (end_pc > max) max = end_pc; |
1 | 1752 |
} |
1753 |
} |
|
1754 |
||
1755 |
void ClassVerifier::verify_local_variable_table(u4 code_length, char* code_data, TRAPS) { |
|
1756 |
int localvariable_table_length = _method()->localvariable_table_length(); |
|
1757 |
if (localvariable_table_length > 0) { |
|
1758 |
LocalVariableTableElement* table = _method()->localvariable_table_start(); |
|
1759 |
for (int i = 0; i < localvariable_table_length; i++) { |
|
1760 |
u2 start_bci = table[i].start_bci; |
|
1761 |
u2 length = table[i].length; |
|
1762 |
||
1763 |
if (start_bci >= code_length || code_data[start_bci] == 0) { |
|
1764 |
class_format_error( |
|
1765 |
"Illegal local variable table start_pc %d", start_bci); |
|
1766 |
return; |
|
1767 |
} |
|
1768 |
u4 end_bci = (u4)(start_bci + length); |
|
1769 |
if (end_bci != code_length) { |
|
1770 |
if (end_bci >= code_length || code_data[end_bci] == 0) { |
|
1771 |
class_format_error( "Illegal local variable table length %d", length); |
|
1772 |
return; |
|
1773 |
} |
|
1774 |
} |
|
1775 |
} |
|
1776 |
} |
|
1777 |
} |
|
1778 |
||
1779 |
u2 ClassVerifier::verify_stackmap_table(u2 stackmap_index, u2 bci, |
|
1780 |
StackMapFrame* current_frame, |
|
1781 |
StackMapTable* stackmap_table, |
|
1782 |
bool no_control_flow, TRAPS) { |
|
1783 |
if (stackmap_index < stackmap_table->get_frame_count()) { |
|
1784 |
u2 this_offset = stackmap_table->get_offset(stackmap_index); |
|
1785 |
if (no_control_flow && this_offset > bci) { |
|
13476 | 1786 |
verify_error(ErrorContext::missing_stackmap(bci), |
1787 |
"Expecting a stack map frame"); |
|
1 | 1788 |
return 0; |
1789 |
} |
|
1790 |
if (this_offset == bci) { |
|
13476 | 1791 |
ErrorContext ctx; |
1 | 1792 |
// See if current stack map can be assigned to the frame in table. |
1793 |
// current_frame is the stackmap frame got from the last instruction. |
|
1794 |
// If matched, current_frame will be updated by this method. |
|
13476 | 1795 |
bool matches = stackmap_table->match_stackmap( |
1 | 1796 |
current_frame, this_offset, stackmap_index, |
13476 | 1797 |
!no_control_flow, true, &ctx, CHECK_VERIFY_(this, 0)); |
1798 |
if (!matches) { |
|
1 | 1799 |
// report type error |
13476 | 1800 |
verify_error(ctx, "Instruction type does not match stack map"); |
1 | 1801 |
return 0; |
1802 |
} |
|
1803 |
stackmap_index++; |
|
1804 |
} else if (this_offset < bci) { |
|
1805 |
// current_offset should have met this_offset. |
|
1806 |
class_format_error("Bad stack map offset %d", this_offset); |
|
1807 |
return 0; |
|
1808 |
} |
|
1809 |
} else if (no_control_flow) { |
|
13476 | 1810 |
verify_error(ErrorContext::bad_code(bci), "Expecting a stack map frame"); |
1 | 1811 |
return 0; |
1812 |
} |
|
1813 |
return stackmap_index; |
|
1814 |
} |
|
1815 |
||
1816 |
void ClassVerifier::verify_exception_handler_targets(u2 bci, bool this_uninit, StackMapFrame* current_frame, |
|
1817 |
StackMapTable* stackmap_table, TRAPS) { |
|
1818 |
constantPoolHandle cp (THREAD, _method->constants()); |
|
13282
9872915dd78d
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
12932
diff
changeset
|
1819 |
ExceptionTable exhandlers(_method()); |
9872915dd78d
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
12932
diff
changeset
|
1820 |
int exlength = exhandlers.length(); |
9872915dd78d
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
12932
diff
changeset
|
1821 |
for(int i = 0; i < exlength; i++) { |
9872915dd78d
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
12932
diff
changeset
|
1822 |
//reacquire the table in case a GC happened |
9872915dd78d
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
12932
diff
changeset
|
1823 |
ExceptionTable exhandlers(_method()); |
9872915dd78d
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
12932
diff
changeset
|
1824 |
u2 start_pc = exhandlers.start_pc(i); |
9872915dd78d
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
12932
diff
changeset
|
1825 |
u2 end_pc = exhandlers.end_pc(i); |
9872915dd78d
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
12932
diff
changeset
|
1826 |
u2 handler_pc = exhandlers.handler_pc(i); |
9872915dd78d
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
12932
diff
changeset
|
1827 |
int catch_type_index = exhandlers.catch_type_index(i); |
9872915dd78d
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
12932
diff
changeset
|
1828 |
if(bci >= start_pc && bci < end_pc) { |
9872915dd78d
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
12932
diff
changeset
|
1829 |
u1 flags = current_frame->flags(); |
9872915dd78d
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
12932
diff
changeset
|
1830 |
if (this_uninit) { flags |= FLAG_THIS_UNINIT; } |
9872915dd78d
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
12932
diff
changeset
|
1831 |
StackMapFrame* new_frame = current_frame->frame_in_exception_handler(flags); |
9872915dd78d
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
12932
diff
changeset
|
1832 |
if (catch_type_index != 0) { |
9872915dd78d
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
12932
diff
changeset
|
1833 |
// We know that this index refers to a subclass of Throwable |
9872915dd78d
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
12932
diff
changeset
|
1834 |
VerificationType catch_type = cp_index_to_type( |
9872915dd78d
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
12932
diff
changeset
|
1835 |
catch_type_index, cp, CHECK_VERIFY(this)); |
9872915dd78d
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
12932
diff
changeset
|
1836 |
new_frame->push_stack(catch_type, CHECK_VERIFY(this)); |
9872915dd78d
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
12932
diff
changeset
|
1837 |
} else { |
9872915dd78d
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
12932
diff
changeset
|
1838 |
VerificationType throwable = |
9872915dd78d
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
12932
diff
changeset
|
1839 |
VerificationType::reference_type(vmSymbols::java_lang_Throwable()); |
9872915dd78d
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
12932
diff
changeset
|
1840 |
new_frame->push_stack(throwable, CHECK_VERIFY(this)); |
9872915dd78d
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
12932
diff
changeset
|
1841 |
} |
13476 | 1842 |
ErrorContext ctx; |
1843 |
bool matches = stackmap_table->match_stackmap( |
|
1844 |
new_frame, handler_pc, true, false, &ctx, CHECK_VERIFY(this)); |
|
1845 |
if (!matches) { |
|
1846 |
verify_error(ctx, "Stack map does not match the one at " |
|
1847 |
"exception handler %d", handler_pc); |
|
13282
9872915dd78d
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
12932
diff
changeset
|
1848 |
return; |
1 | 1849 |
} |
1850 |
} |
|
1851 |
} |
|
1852 |
} |
|
1853 |
||
13476 | 1854 |
void ClassVerifier::verify_cp_index( |
1855 |
u2 bci, constantPoolHandle cp, int index, TRAPS) { |
|
1 | 1856 |
int nconstants = cp->length(); |
1857 |
if ((index <= 0) || (index >= nconstants)) { |
|
13476 | 1858 |
verify_error(ErrorContext::bad_cp_index(bci, index), |
1859 |
"Illegal constant pool index %d in class %s", |
|
14391
df0a1573d5bd
8000725: NPG: method_holder() and pool_holder() and pool_holder field should be InstanceKlass
coleenp
parents:
14385
diff
changeset
|
1860 |
index, cp->pool_holder()->external_name()); |
1 | 1861 |
return; |
1862 |
} |
|
1863 |
} |
|
1864 |
||
1865 |
void ClassVerifier::verify_cp_type( |
|
13476 | 1866 |
u2 bci, int index, constantPoolHandle cp, unsigned int types, TRAPS) { |
1 | 1867 |
|
1868 |
// In some situations, bytecode rewriting may occur while we're verifying. |
|
1869 |
// In this case, a constant pool cache exists and some indices refer to that |
|
5693 | 1870 |
// instead. Be sure we don't pick up such indices by accident. |
1871 |
// We must check was_recursively_verified() before we get here. |
|
1872 |
guarantee(cp->cache() == NULL, "not rewritten yet"); |
|
1 | 1873 |
|
13476 | 1874 |
verify_cp_index(bci, cp, index, CHECK_VERIFY(this)); |
1 | 1875 |
unsigned int tag = cp->tag_at(index).value(); |
1876 |
if ((types & (1 << tag)) == 0) { |
|
13476 | 1877 |
verify_error(ErrorContext::bad_cp_index(bci, index), |
1 | 1878 |
"Illegal type at constant pool entry %d in class %s", |
14391
df0a1573d5bd
8000725: NPG: method_holder() and pool_holder() and pool_holder field should be InstanceKlass
coleenp
parents:
14385
diff
changeset
|
1879 |
index, cp->pool_holder()->external_name()); |
1 | 1880 |
return; |
1881 |
} |
|
1882 |
} |
|
1883 |
||
1884 |
void ClassVerifier::verify_cp_class_type( |
|
13476 | 1885 |
u2 bci, int index, constantPoolHandle cp, TRAPS) { |
1886 |
verify_cp_index(bci, cp, index, CHECK_VERIFY(this)); |
|
1 | 1887 |
constantTag tag = cp->tag_at(index); |
1888 |
if (!tag.is_klass() && !tag.is_unresolved_klass()) { |
|
13476 | 1889 |
verify_error(ErrorContext::bad_cp_index(bci, index), |
1890 |
"Illegal type at constant pool entry %d in class %s", |
|
14391
df0a1573d5bd
8000725: NPG: method_holder() and pool_holder() and pool_holder field should be InstanceKlass
coleenp
parents:
14385
diff
changeset
|
1891 |
index, cp->pool_holder()->external_name()); |
1 | 1892 |
return; |
1893 |
} |
|
1894 |
} |
|
1895 |
||
13476 | 1896 |
void ClassVerifier::verify_error(ErrorContext ctx, const char* msg, ...) { |
1897 |
stringStream ss; |
|
1 | 1898 |
|
13476 | 1899 |
ctx.reset_frames(); |
1 | 1900 |
_exception_type = vmSymbols::java_lang_VerifyError(); |
13476 | 1901 |
_error_context = ctx; |
1 | 1902 |
va_list va; |
13476 | 1903 |
va_start(va, msg); |
1904 |
ss.vprint(msg, va); |
|
1 | 1905 |
va_end(va); |
13476 | 1906 |
_message = ss.as_string(); |
1907 |
#ifdef ASSERT |
|
1908 |
ResourceMark rm; |
|
1909 |
const char* exception_name = _exception_type->as_C_string(); |
|
1910 |
Exceptions::debug_check_abort(exception_name, NULL); |
|
1911 |
#endif // ndef ASSERT |
|
1 | 1912 |
} |
1913 |
||
1914 |
void ClassVerifier::class_format_error(const char* msg, ...) { |
|
13476 | 1915 |
stringStream ss; |
1 | 1916 |
_exception_type = vmSymbols::java_lang_ClassFormatError(); |
1917 |
va_list va; |
|
1918 |
va_start(va, msg); |
|
13476 | 1919 |
ss.vprint(msg, va); |
1 | 1920 |
va_end(va); |
13476 | 1921 |
if (!_method.is_null()) { |
1922 |
ss.print(" in method %s", _method->name_and_sig_as_C_string()); |
|
1923 |
} |
|
1924 |
_message = ss.as_string(); |
|
1 | 1925 |
} |
1926 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13479
diff
changeset
|
1927 |
Klass* ClassVerifier::load_class(Symbol* name, TRAPS) { |
1 | 1928 |
// Get current loader and protection domain first. |
1929 |
oop loader = current_class()->class_loader(); |
|
1930 |
oop protection_domain = current_class()->protection_domain(); |
|
1931 |
||
1932 |
return SystemDictionary::resolve_or_fail( |
|
1933 |
name, Handle(THREAD, loader), Handle(THREAD, protection_domain), |
|
1934 |
true, CHECK_NULL); |
|
1935 |
} |
|
1936 |
||
1937 |
bool ClassVerifier::is_protected_access(instanceKlassHandle this_class, |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13479
diff
changeset
|
1938 |
Klass* target_class, |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7405
diff
changeset
|
1939 |
Symbol* field_name, |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7405
diff
changeset
|
1940 |
Symbol* field_sig, |
1 | 1941 |
bool is_method) { |
1942 |
No_Safepoint_Verifier nosafepoint; |
|
1943 |
||
1944 |
// If target class isn't a super class of this class, we don't worry about this case |
|
1945 |
if (!this_class->is_subclass_of(target_class)) { |
|
1946 |
return false; |
|
1947 |
} |
|
1948 |
// Check if the specified method or field is protected |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13479
diff
changeset
|
1949 |
InstanceKlass* target_instance = InstanceKlass::cast(target_class); |
1 | 1950 |
fieldDescriptor fd; |
1951 |
if (is_method) { |
|
23999
22eb7be3d99d
8033150: invokestatic: IncompatibleClassChangeError trying to invoke static method from a parent in presence of conflicting defaults.
lfoltan
parents:
21768
diff
changeset
|
1952 |
Method* m = target_instance->uncached_lookup_method(field_name, field_sig, Klass::normal); |
1 | 1953 |
if (m != NULL && m->is_protected()) { |
1954 |
if (!this_class->is_same_class_package(m->method_holder())) { |
|
1955 |
return true; |
|
1956 |
} |
|
1957 |
} |
|
1958 |
} else { |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13479
diff
changeset
|
1959 |
Klass* member_klass = target_instance->find_field(field_name, field_sig, &fd); |
13476 | 1960 |
if (member_klass != NULL && fd.is_protected()) { |
1 | 1961 |
if (!this_class->is_same_class_package(member_klass)) { |
1962 |
return true; |
|
1963 |
} |
|
1964 |
} |
|
1965 |
} |
|
1966 |
return false; |
|
1967 |
} |
|
1968 |
||
1969 |
void ClassVerifier::verify_ldc( |
|
13476 | 1970 |
int opcode, u2 index, StackMapFrame* current_frame, |
1971 |
constantPoolHandle cp, u2 bci, TRAPS) { |
|
1972 |
verify_cp_index(bci, cp, index, CHECK_VERIFY(this)); |
|
1 | 1973 |
constantTag tag = cp->tag_at(index); |
1974 |
unsigned int types; |
|
1975 |
if (opcode == Bytecodes::_ldc || opcode == Bytecodes::_ldc_w) { |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13479
diff
changeset
|
1976 |
if (!tag.is_unresolved_klass()) { |
1 | 1977 |
types = (1 << JVM_CONSTANT_Integer) | (1 << JVM_CONSTANT_Float) |
5882 | 1978 |
| (1 << JVM_CONSTANT_String) | (1 << JVM_CONSTANT_Class) |
1979 |
| (1 << JVM_CONSTANT_MethodHandle) | (1 << JVM_CONSTANT_MethodType); |
|
1980 |
// Note: The class file parser already verified the legality of |
|
1981 |
// MethodHandle and MethodType constants. |
|
13476 | 1982 |
verify_cp_type(bci, index, cp, types, CHECK_VERIFY(this)); |
1 | 1983 |
} |
1984 |
} else { |
|
1985 |
assert(opcode == Bytecodes::_ldc2_w, "must be ldc2_w"); |
|
1986 |
types = (1 << JVM_CONSTANT_Double) | (1 << JVM_CONSTANT_Long); |
|
13476 | 1987 |
verify_cp_type(bci, index, cp, types, CHECK_VERIFY(this)); |
1 | 1988 |
} |
1550
be2fc37a817f
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
670
diff
changeset
|
1989 |
if (tag.is_string() && cp->is_pseudo_string_at(index)) { |
7380
041cf7f1cce6
6865028: Illegal instructions passing verification prior to 'invokespecial Object.<init>'
kamg
parents:
6173
diff
changeset
|
1990 |
current_frame->push_stack(object_type(), CHECK_VERIFY(this)); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13479
diff
changeset
|
1991 |
} else if (tag.is_string()) { |
1 | 1992 |
current_frame->push_stack( |
1993 |
VerificationType::reference_type( |
|
1994 |
vmSymbols::java_lang_String()), CHECK_VERIFY(this)); |
|
1995 |
} else if (tag.is_klass() || tag.is_unresolved_klass()) { |
|
1996 |
current_frame->push_stack( |
|
1997 |
VerificationType::reference_type( |
|
1998 |
vmSymbols::java_lang_Class()), CHECK_VERIFY(this)); |
|
1999 |
} else if (tag.is_int()) { |
|
2000 |
current_frame->push_stack( |
|
2001 |
VerificationType::integer_type(), CHECK_VERIFY(this)); |
|
2002 |
} else if (tag.is_float()) { |
|
2003 |
current_frame->push_stack( |
|
2004 |
VerificationType::float_type(), CHECK_VERIFY(this)); |
|
2005 |
} else if (tag.is_double()) { |
|
2006 |
current_frame->push_stack_2( |
|
2007 |
VerificationType::double_type(), |
|
2008 |
VerificationType::double2_type(), CHECK_VERIFY(this)); |
|
2009 |
} else if (tag.is_long()) { |
|
2010 |
current_frame->push_stack_2( |
|
2011 |
VerificationType::long_type(), |
|
2012 |
VerificationType::long2_type(), CHECK_VERIFY(this)); |
|
5882 | 2013 |
} else if (tag.is_method_handle()) { |
2014 |
current_frame->push_stack( |
|
2015 |
VerificationType::reference_type( |
|
9116 | 2016 |
vmSymbols::java_lang_invoke_MethodHandle()), CHECK_VERIFY(this)); |
5882 | 2017 |
} else if (tag.is_method_type()) { |
2018 |
current_frame->push_stack( |
|
2019 |
VerificationType::reference_type( |
|
9116 | 2020 |
vmSymbols::java_lang_invoke_MethodType()), CHECK_VERIFY(this)); |
1 | 2021 |
} else { |
13476 | 2022 |
/* Unreachable? verify_cp_type has already validated the cp type. */ |
2023 |
verify_error( |
|
2024 |
ErrorContext::bad_cp_index(bci, index), "Invalid index in ldc"); |
|
1 | 2025 |
return; |
2026 |
} |
|
2027 |
} |
|
2028 |
||
2029 |
void ClassVerifier::verify_switch( |
|
2030 |
RawBytecodeStream* bcs, u4 code_length, char* code_data, |
|
2031 |
StackMapFrame* current_frame, StackMapTable* stackmap_table, TRAPS) { |
|
2032 |
int bci = bcs->bci(); |
|
2033 |
address bcp = bcs->bcp(); |
|
2034 |
address aligned_bcp = (address) round_to((intptr_t)(bcp + 1), jintSize); |
|
2035 |
||
16442
a929bb40c0e8
8010667: Non-zero padding is not allowed in splitverifier for tableswitch/lookupswitch instructions.
hseigel
parents:
15736
diff
changeset
|
2036 |
if (_klass->major_version() < NONZERO_PADDING_BYTES_IN_SWITCH_MAJOR_VERSION) { |
a929bb40c0e8
8010667: Non-zero padding is not allowed in splitverifier for tableswitch/lookupswitch instructions.
hseigel
parents:
15736
diff
changeset
|
2037 |
// 4639449 & 4647081: padding bytes must be 0 |
a929bb40c0e8
8010667: Non-zero padding is not allowed in splitverifier for tableswitch/lookupswitch instructions.
hseigel
parents:
15736
diff
changeset
|
2038 |
u2 padding_offset = 1; |
a929bb40c0e8
8010667: Non-zero padding is not allowed in splitverifier for tableswitch/lookupswitch instructions.
hseigel
parents:
15736
diff
changeset
|
2039 |
while ((bcp + padding_offset) < aligned_bcp) { |
a929bb40c0e8
8010667: Non-zero padding is not allowed in splitverifier for tableswitch/lookupswitch instructions.
hseigel
parents:
15736
diff
changeset
|
2040 |
if(*(bcp + padding_offset) != 0) { |
a929bb40c0e8
8010667: Non-zero padding is not allowed in splitverifier for tableswitch/lookupswitch instructions.
hseigel
parents:
15736
diff
changeset
|
2041 |
verify_error(ErrorContext::bad_code(bci), |
24663 | 2042 |
"Nonzero padding byte in lookupswitch or tableswitch"); |
16442
a929bb40c0e8
8010667: Non-zero padding is not allowed in splitverifier for tableswitch/lookupswitch instructions.
hseigel
parents:
15736
diff
changeset
|
2043 |
return; |
a929bb40c0e8
8010667: Non-zero padding is not allowed in splitverifier for tableswitch/lookupswitch instructions.
hseigel
parents:
15736
diff
changeset
|
2044 |
} |
a929bb40c0e8
8010667: Non-zero padding is not allowed in splitverifier for tableswitch/lookupswitch instructions.
hseigel
parents:
15736
diff
changeset
|
2045 |
padding_offset++; |
1 | 2046 |
} |
2047 |
} |
|
16442
a929bb40c0e8
8010667: Non-zero padding is not allowed in splitverifier for tableswitch/lookupswitch instructions.
hseigel
parents:
15736
diff
changeset
|
2048 |
|
1 | 2049 |
int default_offset = (int) Bytes::get_Java_u4(aligned_bcp); |
2050 |
int keys, delta; |
|
2051 |
current_frame->pop_stack( |
|
2052 |
VerificationType::integer_type(), CHECK_VERIFY(this)); |
|
5688 | 2053 |
if (bcs->raw_code() == Bytecodes::_tableswitch) { |
1 | 2054 |
jint low = (jint)Bytes::get_Java_u4(aligned_bcp + jintSize); |
2055 |
jint high = (jint)Bytes::get_Java_u4(aligned_bcp + 2*jintSize); |
|
2056 |
if (low > high) { |
|
13476 | 2057 |
verify_error(ErrorContext::bad_code(bci), |
2058 |
"low must be less than or equal to high in tableswitch"); |
|
1 | 2059 |
return; |
2060 |
} |
|
2061 |
keys = high - low + 1; |
|
2062 |
if (keys < 0) { |
|
13476 | 2063 |
verify_error(ErrorContext::bad_code(bci), "too many keys in tableswitch"); |
1 | 2064 |
return; |
2065 |
} |
|
2066 |
delta = 1; |
|
2067 |
} else { |
|
2068 |
keys = (int)Bytes::get_Java_u4(aligned_bcp + jintSize); |
|
2069 |
if (keys < 0) { |
|
13476 | 2070 |
verify_error(ErrorContext::bad_code(bci), |
2071 |
"number of keys in lookupswitch less than 0"); |
|
1 | 2072 |
return; |
2073 |
} |
|
2074 |
delta = 2; |
|
2075 |
// Make sure that the lookupswitch items are sorted |
|
2076 |
for (int i = 0; i < (keys - 1); i++) { |
|
2077 |
jint this_key = Bytes::get_Java_u4(aligned_bcp + (2+2*i)*jintSize); |
|
2078 |
jint next_key = Bytes::get_Java_u4(aligned_bcp + (2+2*i+2)*jintSize); |
|
2079 |
if (this_key >= next_key) { |
|
13476 | 2080 |
verify_error(ErrorContext::bad_code(bci), |
2081 |
"Bad lookupswitch instruction"); |
|
1 | 2082 |
return; |
2083 |
} |
|
2084 |
} |
|
2085 |
} |
|
2086 |
int target = bci + default_offset; |
|
2087 |
stackmap_table->check_jump_target(current_frame, target, CHECK_VERIFY(this)); |
|
2088 |
for (int i = 0; i < keys; i++) { |
|
12932 | 2089 |
// Because check_jump_target() may safepoint, the bytecode could have |
2090 |
// moved, which means 'aligned_bcp' is no good and needs to be recalculated. |
|
2091 |
aligned_bcp = (address)round_to((intptr_t)(bcs->bcp() + 1), jintSize); |
|
1 | 2092 |
target = bci + (jint)Bytes::get_Java_u4(aligned_bcp+(3+i*delta)*jintSize); |
2093 |
stackmap_table->check_jump_target( |
|
2094 |
current_frame, target, CHECK_VERIFY(this)); |
|
2095 |
} |
|
12932 | 2096 |
NOT_PRODUCT(aligned_bcp = NULL); // no longer valid at this point |
1 | 2097 |
} |
2098 |
||
2099 |
bool ClassVerifier::name_in_supers( |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7405
diff
changeset
|
2100 |
Symbol* ref_name, instanceKlassHandle current) { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13479
diff
changeset
|
2101 |
Klass* super = current->super(); |
1 | 2102 |
while (super != NULL) { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13479
diff
changeset
|
2103 |
if (super->name() == ref_name) { |
1 | 2104 |
return true; |
2105 |
} |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13479
diff
changeset
|
2106 |
super = super->super(); |
1 | 2107 |
} |
2108 |
return false; |
|
2109 |
} |
|
2110 |
||
2111 |
void ClassVerifier::verify_field_instructions(RawBytecodeStream* bcs, |
|
2112 |
StackMapFrame* current_frame, |
|
2113 |
constantPoolHandle cp, |
|
2114 |
TRAPS) { |
|
5688 | 2115 |
u2 index = bcs->get_index_u2(); |
13476 | 2116 |
verify_cp_type(bcs->bci(), index, cp, |
2117 |
1 << JVM_CONSTANT_Fieldref, CHECK_VERIFY(this)); |
|
1 | 2118 |
|
2119 |
// Get field name and signature |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7405
diff
changeset
|
2120 |
Symbol* field_name = cp->name_ref_at(index); |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7405
diff
changeset
|
2121 |
Symbol* field_sig = cp->signature_ref_at(index); |
1 | 2122 |
|
2123 |
if (!SignatureVerifier::is_valid_type_signature(field_sig)) { |
|
2124 |
class_format_error( |
|
2125 |
"Invalid signature for field in class %s referenced " |
|
2126 |
"from constant pool index %d", _klass->external_name(), index); |
|
2127 |
return; |
|
2128 |
} |
|
2129 |
||
2130 |
// Get referenced class type |
|
2131 |
VerificationType ref_class_type = cp_ref_index_to_type( |
|
2132 |
index, cp, CHECK_VERIFY(this)); |
|
2133 |
if (!ref_class_type.is_object()) { |
|
13476 | 2134 |
/* Unreachable? Class file parser verifies Fieldref contents */ |
2135 |
verify_error(ErrorContext::bad_type(bcs->bci(), |
|
2136 |
TypeOrigin::cp(index, ref_class_type)), |
|
2137 |
"Expecting reference to class in class %s at constant pool index %d", |
|
2138 |
_klass->external_name(), index); |
|
1 | 2139 |
return; |
2140 |
} |
|
2141 |
VerificationType target_class_type = ref_class_type; |
|
2142 |
||
2143 |
assert(sizeof(VerificationType) == sizeof(uintptr_t), |
|
2144 |
"buffer type must match VerificationType size"); |
|
2145 |
uintptr_t field_type_buffer[2]; |
|
2146 |
VerificationType* field_type = (VerificationType*)field_type_buffer; |
|
2147 |
// If we make a VerificationType[2] array directly, the compiler calls |
|
2148 |
// to the c-runtime library to do the allocation instead of just |
|
2149 |
// stack allocating it. Plus it would run constructors. This shows up |
|
2150 |
// in performance profiles. |
|
2151 |
||
2152 |
SignatureStream sig_stream(field_sig, false); |
|
2153 |
VerificationType stack_object_type; |
|
2154 |
int n = change_sig_to_verificationType( |
|
2155 |
&sig_stream, field_type, CHECK_VERIFY(this)); |
|
2156 |
u2 bci = bcs->bci(); |
|
2157 |
bool is_assignable; |
|
5688 | 2158 |
switch (bcs->raw_code()) { |
1 | 2159 |
case Bytecodes::_getstatic: { |
2160 |
for (int i = 0; i < n; i++) { |
|
2161 |
current_frame->push_stack(field_type[i], CHECK_VERIFY(this)); |
|
2162 |
} |
|
2163 |
break; |
|
2164 |
} |
|
2165 |
case Bytecodes::_putstatic: { |
|
2166 |
for (int i = n - 1; i >= 0; i--) { |
|
2167 |
current_frame->pop_stack(field_type[i], CHECK_VERIFY(this)); |
|
2168 |
} |
|
2169 |
break; |
|
2170 |
} |
|
2171 |
case Bytecodes::_getfield: { |
|
2172 |
stack_object_type = current_frame->pop_stack( |
|
2173 |
target_class_type, CHECK_VERIFY(this)); |
|
2174 |
for (int i = 0; i < n; i++) { |
|
2175 |
current_frame->push_stack(field_type[i], CHECK_VERIFY(this)); |
|
2176 |
} |
|
2177 |
goto check_protected; |
|
2178 |
} |
|
2179 |
case Bytecodes::_putfield: { |
|
2180 |
for (int i = n - 1; i >= 0; i--) { |
|
2181 |
current_frame->pop_stack(field_type[i], CHECK_VERIFY(this)); |
|
2182 |
} |
|
2183 |
stack_object_type = current_frame->pop_stack(CHECK_VERIFY(this)); |
|
2184 |
||
2185 |
// The JVMS 2nd edition allows field initialization before the superclass |
|
2186 |
// initializer, if the field is defined within the current class. |
|
2187 |
fieldDescriptor fd; |
|
2188 |
if (stack_object_type == VerificationType::uninitialized_this_type() && |
|
2189 |
target_class_type.equals(current_type()) && |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7405
diff
changeset
|
2190 |
_klass->find_local_field(field_name, field_sig, &fd)) { |
1 | 2191 |
stack_object_type = current_type(); |
2192 |
} |
|
2193 |
is_assignable = target_class_type.is_assignable_from( |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7405
diff
changeset
|
2194 |
stack_object_type, this, CHECK_VERIFY(this)); |
1 | 2195 |
if (!is_assignable) { |
13476 | 2196 |
verify_error(ErrorContext::bad_type(bci, |
2197 |
current_frame->stack_top_ctx(), |
|
2198 |
TypeOrigin::cp(index, target_class_type)), |
|
2199 |
"Bad type on operand stack in putfield"); |
|
1 | 2200 |
return; |
2201 |
} |
|
2202 |
} |
|
2203 |
check_protected: { |
|
2204 |
if (_this_type == stack_object_type) |
|
2205 |
break; // stack_object_type must be assignable to _current_class_type |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7405
diff
changeset
|
2206 |
Symbol* ref_class_name = |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7405
diff
changeset
|
2207 |
cp->klass_name_at(cp->klass_ref_index_at(index)); |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7405
diff
changeset
|
2208 |
if (!name_in_supers(ref_class_name, current_class())) |
1 | 2209 |
// stack_object_type must be assignable to _current_class_type since: |
2210 |
// 1. stack_object_type must be assignable to ref_class. |
|
2211 |
// 2. ref_class must be _current_class or a subclass of it. It can't |
|
2212 |
// be a superclass of it. See revised JVMS 5.4.4. |
|
2213 |
break; |
|
2214 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13479
diff
changeset
|
2215 |
Klass* ref_class_oop = load_class(ref_class_name, CHECK); |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7405
diff
changeset
|
2216 |
if (is_protected_access(current_class(), ref_class_oop, field_name, |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7405
diff
changeset
|
2217 |
field_sig, false)) { |
1 | 2218 |
// It's protected access, check if stack object is assignable to |
2219 |
// current class. |
|
2220 |
is_assignable = current_type().is_assignable_from( |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7405
diff
changeset
|
2221 |
stack_object_type, this, CHECK_VERIFY(this)); |
1 | 2222 |
if (!is_assignable) { |
13476 | 2223 |
verify_error(ErrorContext::bad_type(bci, |
2224 |
current_frame->stack_top_ctx(), |
|
2225 |
TypeOrigin::implicit(current_type())), |
|
2226 |
"Bad access to protected data in getfield"); |
|
1 | 2227 |
return; |
2228 |
} |
|
2229 |
} |
|
2230 |
break; |
|
2231 |
} |
|
2232 |
default: ShouldNotReachHere(); |
|
2233 |
} |
|
2234 |
} |
|
2235 |
||
2236 |
void ClassVerifier::verify_invoke_init( |
|
13476 | 2237 |
RawBytecodeStream* bcs, u2 ref_class_index, VerificationType ref_class_type, |
1 | 2238 |
StackMapFrame* current_frame, u4 code_length, bool *this_uninit, |
2239 |
constantPoolHandle cp, TRAPS) { |
|
2240 |
u2 bci = bcs->bci(); |
|
2241 |
VerificationType type = current_frame->pop_stack( |
|
2242 |
VerificationType::reference_check(), CHECK_VERIFY(this)); |
|
2243 |
if (type == VerificationType::uninitialized_this_type()) { |
|
12986 | 2244 |
// The method must be an <init> method of this class or its superclass |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13479
diff
changeset
|
2245 |
Klass* superk = current_class()->super(); |
6172 | 2246 |
if (ref_class_type.name() != current_class()->name() && |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13479
diff
changeset
|
2247 |
ref_class_type.name() != superk->name()) { |
13476 | 2248 |
verify_error(ErrorContext::bad_type(bci, |
2249 |
TypeOrigin::implicit(ref_class_type), |
|
2250 |
TypeOrigin::implicit(current_type())), |
|
2251 |
"Bad <init> method call"); |
|
1 | 2252 |
return; |
2253 |
} |
|
25505 | 2254 |
|
2255 |
// Make sure that this call is not jumped over. |
|
2256 |
if (bci < furthest_jump()) { |
|
2257 |
verify_error(ErrorContext::bad_code(bci), |
|
2258 |
"Bad <init> method call from inside of a branch"); |
|
2259 |
return; |
|
2260 |
} |
|
2261 |
||
2262 |
// Make sure that this call is not done from within a TRY block because |
|
2263 |
// that can result in returning an incomplete object. Simply checking |
|
2264 |
// (bci >= start_pc) also ensures that this call is not done after a TRY |
|
2265 |
// block. That is also illegal because this call must be the first Java |
|
2266 |
// statement in the constructor. |
|
2267 |
ExceptionTable exhandlers(_method()); |
|
2268 |
int exlength = exhandlers.length(); |
|
2269 |
for(int i = 0; i < exlength; i++) { |
|
2270 |
if (bci >= exhandlers.start_pc(i)) { |
|
2271 |
verify_error(ErrorContext::bad_code(bci), |
|
2272 |
"Bad <init> method call from after the start of a try block"); |
|
2273 |
return; |
|
2274 |
} |
|
2275 |
} |
|
2276 |
||
1 | 2277 |
current_frame->initialize_object(type, current_type()); |
2278 |
*this_uninit = true; |
|
2279 |
} else if (type.is_uninitialized()) { |
|
2280 |
u2 new_offset = type.bci(); |
|
2281 |
address new_bcp = bcs->bcp() - bci + new_offset; |
|
2282 |
if (new_offset > (code_length - 3) || (*new_bcp) != Bytecodes::_new) { |
|
13476 | 2283 |
/* Unreachable? Stack map parsing ensures valid type and new |
2284 |
* instructions have a valid BCI. */ |
|
2285 |
verify_error(ErrorContext::bad_code(new_offset), |
|
2286 |
"Expecting new instruction"); |
|
1 | 2287 |
return; |
2288 |
} |
|
2289 |
u2 new_class_index = Bytes::get_Java_u2(new_bcp + 1); |
|
13476 | 2290 |
verify_cp_class_type(bci, new_class_index, cp, CHECK_VERIFY(this)); |
1 | 2291 |
|
2292 |
// The method must be an <init> method of the indicated class |
|
2293 |
VerificationType new_class_type = cp_index_to_type( |
|
2294 |
new_class_index, cp, CHECK_VERIFY(this)); |
|
2295 |
if (!new_class_type.equals(ref_class_type)) { |
|
13476 | 2296 |
verify_error(ErrorContext::bad_type(bci, |
2297 |
TypeOrigin::cp(new_class_index, new_class_type), |
|
2298 |
TypeOrigin::cp(ref_class_index, ref_class_type)), |
|
2299 |
"Call to wrong <init> method"); |
|
1 | 2300 |
return; |
2301 |
} |
|
2302 |
// According to the VM spec, if the referent class is a superclass of the |
|
2303 |
// current class, and is in a different runtime package, and the method is |
|
2304 |
// protected, then the objectref must be the current class or a subclass |
|
2305 |
// of the current class. |
|
2306 |
VerificationType objectref_type = new_class_type; |
|
2307 |
if (name_in_supers(ref_class_type.name(), current_class())) { |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13479
diff
changeset
|
2308 |
Klass* ref_klass = load_class( |
1 | 2309 |
ref_class_type.name(), CHECK_VERIFY(this)); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13479
diff
changeset
|
2310 |
Method* m = InstanceKlass::cast(ref_klass)->uncached_lookup_method( |
1 | 2311 |
vmSymbols::object_initializer_name(), |
23999
22eb7be3d99d
8033150: invokestatic: IncompatibleClassChangeError trying to invoke static method from a parent in presence of conflicting defaults.
lfoltan
parents:
21768
diff
changeset
|
2312 |
cp->signature_ref_at(bcs->get_index_u2()), |
22eb7be3d99d
8033150: invokestatic: IncompatibleClassChangeError trying to invoke static method from a parent in presence of conflicting defaults.
lfoltan
parents:
21768
diff
changeset
|
2313 |
Klass::normal); |
25508 | 2314 |
if (m == NULL) { |
2315 |
verify_error(ErrorContext::bad_code(bci), |
|
2316 |
"Call to missing <init> method"); |
|
2317 |
return; |
|
2318 |
} |
|
1 | 2319 |
instanceKlassHandle mh(THREAD, m->method_holder()); |
2320 |
if (m->is_protected() && !mh->is_same_class_package(_klass())) { |
|
2321 |
bool assignable = current_type().is_assignable_from( |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7405
diff
changeset
|
2322 |
objectref_type, this, CHECK_VERIFY(this)); |
1 | 2323 |
if (!assignable) { |
13476 | 2324 |
verify_error(ErrorContext::bad_type(bci, |
2325 |
TypeOrigin::cp(new_class_index, objectref_type), |
|
2326 |
TypeOrigin::implicit(current_type())), |
|
2327 |
"Bad access to protected <init> method"); |
|
1 | 2328 |
return; |
2329 |
} |
|
2330 |
} |
|
2331 |
} |
|
2332 |
current_frame->initialize_object(type, new_class_type); |
|
2333 |
} else { |
|
13476 | 2334 |
verify_error(ErrorContext::bad_type(bci, current_frame->stack_top_ctx()), |
2335 |
"Bad operand type when invoking <init>"); |
|
1 | 2336 |
return; |
2337 |
} |
|
2338 |
} |
|
2339 |
||
21768
b7dba4cde1c6
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
21729
diff
changeset
|
2340 |
bool ClassVerifier::is_same_or_direct_interface( |
b7dba4cde1c6
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
21729
diff
changeset
|
2341 |
instanceKlassHandle klass, |
b7dba4cde1c6
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
21729
diff
changeset
|
2342 |
VerificationType klass_type, |
b7dba4cde1c6
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
21729
diff
changeset
|
2343 |
VerificationType ref_class_type) { |
b7dba4cde1c6
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
21729
diff
changeset
|
2344 |
if (ref_class_type.equals(klass_type)) return true; |
b7dba4cde1c6
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
21729
diff
changeset
|
2345 |
Array<Klass*>* local_interfaces = klass->local_interfaces(); |
b7dba4cde1c6
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
21729
diff
changeset
|
2346 |
if (local_interfaces != NULL) { |
b7dba4cde1c6
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
21729
diff
changeset
|
2347 |
for (int x = 0; x < local_interfaces->length(); x++) { |
b7dba4cde1c6
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
21729
diff
changeset
|
2348 |
Klass* k = local_interfaces->at(x); |
b7dba4cde1c6
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
21729
diff
changeset
|
2349 |
assert (k != NULL && k->is_interface(), "invalid interface"); |
b7dba4cde1c6
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
21729
diff
changeset
|
2350 |
if (ref_class_type.equals(VerificationType::reference_type(k->name()))) { |
b7dba4cde1c6
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
21729
diff
changeset
|
2351 |
return true; |
b7dba4cde1c6
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
21729
diff
changeset
|
2352 |
} |
b7dba4cde1c6
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
21729
diff
changeset
|
2353 |
} |
b7dba4cde1c6
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
21729
diff
changeset
|
2354 |
} |
b7dba4cde1c6
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
21729
diff
changeset
|
2355 |
return false; |
b7dba4cde1c6
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
21729
diff
changeset
|
2356 |
} |
b7dba4cde1c6
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
21729
diff
changeset
|
2357 |
|
1 | 2358 |
void ClassVerifier::verify_invoke_instructions( |
2359 |
RawBytecodeStream* bcs, u4 code_length, StackMapFrame* current_frame, |
|
2360 |
bool *this_uninit, VerificationType return_type, |
|
2361 |
constantPoolHandle cp, TRAPS) { |
|
2362 |
// Make sure the constant pool item is the right type |
|
5688 | 2363 |
u2 index = bcs->get_index_u2(); |
2364 |
Bytecodes::Code opcode = bcs->raw_code(); |
|
14385 | 2365 |
unsigned int types; |
2366 |
switch (opcode) { |
|
2367 |
case Bytecodes::_invokeinterface: |
|
2368 |
types = 1 << JVM_CONSTANT_InterfaceMethodref; |
|
2369 |
break; |
|
2370 |
case Bytecodes::_invokedynamic: |
|
2371 |
types = 1 << JVM_CONSTANT_InvokeDynamic; |
|
2372 |
break; |
|
2373 |
case Bytecodes::_invokespecial: |
|
16676
ea5bba2e47e9
8011671: JCK tests on static interface methods fail under b84: Illegal type at constant pool entry 5
bharadwaj
parents:
16445
diff
changeset
|
2374 |
case Bytecodes::_invokestatic: |
ea5bba2e47e9
8011671: JCK tests on static interface methods fail under b84: Illegal type at constant pool entry 5
bharadwaj
parents:
16445
diff
changeset
|
2375 |
types = (_klass->major_version() < STATIC_METHOD_IN_INTERFACE_MAJOR_VERSION) ? |
ea5bba2e47e9
8011671: JCK tests on static interface methods fail under b84: Illegal type at constant pool entry 5
bharadwaj
parents:
16445
diff
changeset
|
2376 |
(1 << JVM_CONSTANT_Methodref) : |
ea5bba2e47e9
8011671: JCK tests on static interface methods fail under b84: Illegal type at constant pool entry 5
bharadwaj
parents:
16445
diff
changeset
|
2377 |
((1 << JVM_CONSTANT_InterfaceMethodref) | (1 << JVM_CONSTANT_Methodref)); |
ea5bba2e47e9
8011671: JCK tests on static interface methods fail under b84: Illegal type at constant pool entry 5
bharadwaj
parents:
16445
diff
changeset
|
2378 |
break; |
14385 | 2379 |
default: |
2380 |
types = 1 << JVM_CONSTANT_Methodref; |
|
2381 |
} |
|
13476 | 2382 |
verify_cp_type(bcs->bci(), index, cp, types, CHECK_VERIFY(this)); |
1 | 2383 |
|
2384 |
// Get method name and signature |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7405
diff
changeset
|
2385 |
Symbol* method_name = cp->name_ref_at(index); |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7405
diff
changeset
|
2386 |
Symbol* method_sig = cp->signature_ref_at(index); |
1 | 2387 |
|
2388 |
if (!SignatureVerifier::is_valid_method_signature(method_sig)) { |
|
2389 |
class_format_error( |
|
2390 |
"Invalid method signature in class %s referenced " |
|
2391 |
"from constant pool index %d", _klass->external_name(), index); |
|
2392 |
return; |
|
2393 |
} |
|
2394 |
||
2395 |
// Get referenced class type |
|
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
1550
diff
changeset
|
2396 |
VerificationType ref_class_type; |
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
1550
diff
changeset
|
2397 |
if (opcode == Bytecodes::_invokedynamic) { |
24322 | 2398 |
if (_klass->major_version() < Verifier::INVOKEDYNAMIC_MAJOR_VERSION) { |
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
1550
diff
changeset
|
2399 |
class_format_error( |
24424
2658d7834c6e
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
24351
diff
changeset
|
2400 |
"invokedynamic instructions not supported by this class file version (%d), class %s", |
2658d7834c6e
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
24351
diff
changeset
|
2401 |
_klass->major_version(), _klass->external_name()); |
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
1550
diff
changeset
|
2402 |
return; |
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
1550
diff
changeset
|
2403 |
} |
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
1550
diff
changeset
|
2404 |
} else { |
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
1550
diff
changeset
|
2405 |
ref_class_type = cp_ref_index_to_type(index, cp, CHECK_VERIFY(this)); |
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
1550
diff
changeset
|
2406 |
} |
1 | 2407 |
|
2408 |
// For a small signature length, we just allocate 128 bytes instead |
|
2409 |
// of parsing the signature once to find its size. |
|
2410 |
// -3 is for '(', ')' and return descriptor; multiply by 2 is for |
|
2411 |
// longs/doubles to be consertive. |
|
2412 |
assert(sizeof(VerificationType) == sizeof(uintptr_t), |
|
2413 |
"buffer type must match VerificationType size"); |
|
2414 |
uintptr_t on_stack_sig_types_buffer[128]; |
|
2415 |
// If we make a VerificationType[128] array directly, the compiler calls |
|
2416 |
// to the c-runtime library to do the allocation instead of just |
|
2417 |
// stack allocating it. Plus it would run constructors. This shows up |
|
2418 |
// in performance profiles. |
|
2419 |
||
2420 |
VerificationType* sig_types; |
|
2421 |
int size = (method_sig->utf8_length() - 3) * 2; |
|
2422 |
if (size > 128) { |
|
2423 |
// Long and double occupies two slots here. |
|
2424 |
ArgumentSizeComputer size_it(method_sig); |
|
2425 |
size = size_it.size(); |
|
2426 |
sig_types = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, VerificationType, size); |
|
2427 |
} else{ |
|
2428 |
sig_types = (VerificationType*)on_stack_sig_types_buffer; |
|
2429 |
} |
|
2430 |
SignatureStream sig_stream(method_sig); |
|
2431 |
int sig_i = 0; |
|
2432 |
while (!sig_stream.at_return_type()) { |
|
2433 |
sig_i += change_sig_to_verificationType( |
|
2434 |
&sig_stream, &sig_types[sig_i], CHECK_VERIFY(this)); |
|
2435 |
sig_stream.next(); |
|
2436 |
} |
|
2437 |
int nargs = sig_i; |
|
2438 |
||
2439 |
#ifdef ASSERT |
|
2440 |
{ |
|
2441 |
ArgumentSizeComputer size_it(method_sig); |
|
2442 |
assert(nargs == size_it.size(), "Argument sizes do not match"); |
|
2443 |
assert(nargs <= (method_sig->utf8_length() - 3) * 2, "estimate of max size isn't conservative enough"); |
|
2444 |
} |
|
2445 |
#endif |
|
2446 |
||
2447 |
// Check instruction operands |
|
2448 |
u2 bci = bcs->bci(); |
|
2449 |
if (opcode == Bytecodes::_invokeinterface) { |
|
2450 |
address bcp = bcs->bcp(); |
|
2451 |
// 4905268: count operand in invokeinterface should be nargs+1, not nargs. |
|
2452 |
// JSR202 spec: The count operand of an invokeinterface instruction is valid if it is |
|
2453 |
// the difference between the size of the operand stack before and after the instruction |
|
2454 |
// executes. |
|
2455 |
if (*(bcp+3) != (nargs+1)) { |
|
13476 | 2456 |
verify_error(ErrorContext::bad_code(bci), |
2457 |
"Inconsistent args count operand in invokeinterface"); |
|
1 | 2458 |
return; |
2459 |
} |
|
2460 |
if (*(bcp+4) != 0) { |
|
13476 | 2461 |
verify_error(ErrorContext::bad_code(bci), |
2462 |
"Fourth operand byte of invokeinterface must be zero"); |
|
1 | 2463 |
return; |
2464 |
} |
|
2465 |
} |
|
2466 |
||
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
1550
diff
changeset
|
2467 |
if (opcode == Bytecodes::_invokedynamic) { |
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
1550
diff
changeset
|
2468 |
address bcp = bcs->bcp(); |
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
1550
diff
changeset
|
2469 |
if (*(bcp+3) != 0 || *(bcp+4) != 0) { |
13476 | 2470 |
verify_error(ErrorContext::bad_code(bci), |
2471 |
"Third and fourth operand bytes of invokedynamic must be zero"); |
|
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
1550
diff
changeset
|
2472 |
return; |
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
1550
diff
changeset
|
2473 |
} |
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
1550
diff
changeset
|
2474 |
} |
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
1550
diff
changeset
|
2475 |
|
1 | 2476 |
if (method_name->byte_at(0) == '<') { |
2477 |
// Make sure <init> can only be invoked by invokespecial |
|
2478 |
if (opcode != Bytecodes::_invokespecial || |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7405
diff
changeset
|
2479 |
method_name != vmSymbols::object_initializer_name()) { |
13476 | 2480 |
verify_error(ErrorContext::bad_code(bci), |
2481 |
"Illegal call to internal method"); |
|
1 | 2482 |
return; |
2483 |
} |
|
2484 |
} else if (opcode == Bytecodes::_invokespecial |
|
21768
b7dba4cde1c6
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
21729
diff
changeset
|
2485 |
&& !is_same_or_direct_interface(current_class(), current_type(), ref_class_type) |
1 | 2486 |
&& !ref_class_type.equals(VerificationType::reference_type( |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13479
diff
changeset
|
2487 |
current_class()->super()->name()))) { |
20718
c4a5c7c1f6c9
8026365: NoClassDefinitionFound for anonymous class invokespecial.
acorn
parents:
20395
diff
changeset
|
2488 |
bool subtype = false; |
21768
b7dba4cde1c6
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
21729
diff
changeset
|
2489 |
bool have_imr_indirect = cp->tag_at(index).value() == JVM_CONSTANT_InterfaceMethodref; |
20718
c4a5c7c1f6c9
8026365: NoClassDefinitionFound for anonymous class invokespecial.
acorn
parents:
20395
diff
changeset
|
2490 |
if (!current_class()->is_anonymous()) { |
c4a5c7c1f6c9
8026365: NoClassDefinitionFound for anonymous class invokespecial.
acorn
parents:
20395
diff
changeset
|
2491 |
subtype = ref_class_type.is_assignable_from( |
c4a5c7c1f6c9
8026365: NoClassDefinitionFound for anonymous class invokespecial.
acorn
parents:
20395
diff
changeset
|
2492 |
current_type(), this, CHECK_VERIFY(this)); |
c4a5c7c1f6c9
8026365: NoClassDefinitionFound for anonymous class invokespecial.
acorn
parents:
20395
diff
changeset
|
2493 |
} else { |
21768
b7dba4cde1c6
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
21729
diff
changeset
|
2494 |
VerificationType host_klass_type = |
b7dba4cde1c6
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
21729
diff
changeset
|
2495 |
VerificationType::reference_type(current_class()->host_klass()->name()); |
b7dba4cde1c6
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
21729
diff
changeset
|
2496 |
subtype = ref_class_type.is_assignable_from(host_klass_type, this, CHECK_VERIFY(this)); |
b7dba4cde1c6
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
21729
diff
changeset
|
2497 |
|
b7dba4cde1c6
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
21729
diff
changeset
|
2498 |
// If invokespecial of IMR, need to recheck for same or |
b7dba4cde1c6
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
21729
diff
changeset
|
2499 |
// direct interface relative to the host class |
b7dba4cde1c6
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
21729
diff
changeset
|
2500 |
have_imr_indirect = (have_imr_indirect && |
b7dba4cde1c6
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
21729
diff
changeset
|
2501 |
!is_same_or_direct_interface( |
b7dba4cde1c6
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
21729
diff
changeset
|
2502 |
InstanceKlass::cast(current_class()->host_klass()), |
b7dba4cde1c6
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
21729
diff
changeset
|
2503 |
host_klass_type, ref_class_type)); |
20718
c4a5c7c1f6c9
8026365: NoClassDefinitionFound for anonymous class invokespecial.
acorn
parents:
20395
diff
changeset
|
2504 |
} |
1 | 2505 |
if (!subtype) { |
20718
c4a5c7c1f6c9
8026365: NoClassDefinitionFound for anonymous class invokespecial.
acorn
parents:
20395
diff
changeset
|
2506 |
verify_error(ErrorContext::bad_code(bci), |
c4a5c7c1f6c9
8026365: NoClassDefinitionFound for anonymous class invokespecial.
acorn
parents:
20395
diff
changeset
|
2507 |
"Bad invokespecial instruction: " |
c4a5c7c1f6c9
8026365: NoClassDefinitionFound for anonymous class invokespecial.
acorn
parents:
20395
diff
changeset
|
2508 |
"current class isn't assignable to reference class."); |
c4a5c7c1f6c9
8026365: NoClassDefinitionFound for anonymous class invokespecial.
acorn
parents:
20395
diff
changeset
|
2509 |
return; |
21768
b7dba4cde1c6
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
21729
diff
changeset
|
2510 |
} else if (have_imr_indirect) { |
b7dba4cde1c6
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
21729
diff
changeset
|
2511 |
verify_error(ErrorContext::bad_code(bci), |
b7dba4cde1c6
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
21729
diff
changeset
|
2512 |
"Bad invokespecial instruction: " |
b7dba4cde1c6
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
21729
diff
changeset
|
2513 |
"interface method reference is in an indirect superinterface."); |
b7dba4cde1c6
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
21729
diff
changeset
|
2514 |
return; |
1 | 2515 |
} |
21768
b7dba4cde1c6
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
21729
diff
changeset
|
2516 |
|
1 | 2517 |
} |
2518 |
// Match method descriptor with operand stack |
|
2519 |
for (int i = nargs - 1; i >= 0; i--) { // Run backwards |
|
2520 |
current_frame->pop_stack(sig_types[i], CHECK_VERIFY(this)); |
|
2521 |
} |
|
2522 |
// Check objectref on operand stack |
|
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
1550
diff
changeset
|
2523 |
if (opcode != Bytecodes::_invokestatic && |
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
1550
diff
changeset
|
2524 |
opcode != Bytecodes::_invokedynamic) { |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7405
diff
changeset
|
2525 |
if (method_name == vmSymbols::object_initializer_name()) { // <init> method |
13476 | 2526 |
verify_invoke_init(bcs, index, ref_class_type, current_frame, |
1 | 2527 |
code_length, this_uninit, cp, CHECK_VERIFY(this)); |
2528 |
} else { // other methods |
|
2529 |
// Ensures that target class is assignable to method class. |
|
2530 |
if (opcode == Bytecodes::_invokespecial) { |
|
20395
55915f609319
8026022: Verifier: allow anon classes to invokespecial host class/intf methods.
acorn
parents:
19704
diff
changeset
|
2531 |
if (!current_class()->is_anonymous()) { |
55915f609319
8026022: Verifier: allow anon classes to invokespecial host class/intf methods.
acorn
parents:
19704
diff
changeset
|
2532 |
current_frame->pop_stack(current_type(), CHECK_VERIFY(this)); |
55915f609319
8026022: Verifier: allow anon classes to invokespecial host class/intf methods.
acorn
parents:
19704
diff
changeset
|
2533 |
} else { |
20718
c4a5c7c1f6c9
8026365: NoClassDefinitionFound for anonymous class invokespecial.
acorn
parents:
20395
diff
changeset
|
2534 |
// anonymous class invokespecial calls: check if the |
c4a5c7c1f6c9
8026365: NoClassDefinitionFound for anonymous class invokespecial.
acorn
parents:
20395
diff
changeset
|
2535 |
// objectref is a subtype of the host_klass of the current class |
20395
55915f609319
8026022: Verifier: allow anon classes to invokespecial host class/intf methods.
acorn
parents:
19704
diff
changeset
|
2536 |
// to allow an anonymous class to reference methods in the host_klass |
55915f609319
8026022: Verifier: allow anon classes to invokespecial host class/intf methods.
acorn
parents:
19704
diff
changeset
|
2537 |
VerificationType top = current_frame->pop_stack(CHECK_VERIFY(this)); |
20718
c4a5c7c1f6c9
8026365: NoClassDefinitionFound for anonymous class invokespecial.
acorn
parents:
20395
diff
changeset
|
2538 |
VerificationType hosttype = |
c4a5c7c1f6c9
8026365: NoClassDefinitionFound for anonymous class invokespecial.
acorn
parents:
20395
diff
changeset
|
2539 |
VerificationType::reference_type(current_class()->host_klass()->name()); |
c4a5c7c1f6c9
8026365: NoClassDefinitionFound for anonymous class invokespecial.
acorn
parents:
20395
diff
changeset
|
2540 |
bool subtype = hosttype.is_assignable_from(top, this, CHECK_VERIFY(this)); |
20395
55915f609319
8026022: Verifier: allow anon classes to invokespecial host class/intf methods.
acorn
parents:
19704
diff
changeset
|
2541 |
if (!subtype) { |
55915f609319
8026022: Verifier: allow anon classes to invokespecial host class/intf methods.
acorn
parents:
19704
diff
changeset
|
2542 |
verify_error( ErrorContext::bad_type(current_frame->offset(), |
55915f609319
8026022: Verifier: allow anon classes to invokespecial host class/intf methods.
acorn
parents:
19704
diff
changeset
|
2543 |
current_frame->stack_top_ctx(), |
55915f609319
8026022: Verifier: allow anon classes to invokespecial host class/intf methods.
acorn
parents:
19704
diff
changeset
|
2544 |
TypeOrigin::implicit(top)), |
55915f609319
8026022: Verifier: allow anon classes to invokespecial host class/intf methods.
acorn
parents:
19704
diff
changeset
|
2545 |
"Bad type on operand stack"); |
55915f609319
8026022: Verifier: allow anon classes to invokespecial host class/intf methods.
acorn
parents:
19704
diff
changeset
|
2546 |
return; |
55915f609319
8026022: Verifier: allow anon classes to invokespecial host class/intf methods.
acorn
parents:
19704
diff
changeset
|
2547 |
} |
55915f609319
8026022: Verifier: allow anon classes to invokespecial host class/intf methods.
acorn
parents:
19704
diff
changeset
|
2548 |
} |
1 | 2549 |
} else if (opcode == Bytecodes::_invokevirtual) { |
2550 |
VerificationType stack_object_type = |
|
2551 |
current_frame->pop_stack(ref_class_type, CHECK_VERIFY(this)); |
|
2552 |
if (current_type() != stack_object_type) { |
|
2553 |
assert(cp->cache() == NULL, "not rewritten yet"); |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7405
diff
changeset
|
2554 |
Symbol* ref_class_name = |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7405
diff
changeset
|
2555 |
cp->klass_name_at(cp->klass_ref_index_at(index)); |
1 | 2556 |
// See the comments in verify_field_instructions() for |
2557 |
// the rationale behind this. |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7405
diff
changeset
|
2558 |
if (name_in_supers(ref_class_name, current_class())) { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13479
diff
changeset
|
2559 |
Klass* ref_class = load_class(ref_class_name, CHECK); |
1 | 2560 |
if (is_protected_access( |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7405
diff
changeset
|
2561 |
_klass, ref_class, method_name, method_sig, true)) { |
1 | 2562 |
// It's protected access, check if stack object is |
2563 |
// assignable to current class. |
|
2564 |
bool is_assignable = current_type().is_assignable_from( |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7405
diff
changeset
|
2565 |
stack_object_type, this, CHECK_VERIFY(this)); |
1 | 2566 |
if (!is_assignable) { |
2567 |
if (ref_class_type.name() == vmSymbols::java_lang_Object() |
|
2568 |
&& stack_object_type.is_array() |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7405
diff
changeset
|
2569 |
&& method_name == vmSymbols::clone_name()) { |
1 | 2570 |
// Special case: arrays pretend to implement public Object |
2571 |
// clone(). |
|
2572 |
} else { |
|
13476 | 2573 |
verify_error(ErrorContext::bad_type(bci, |
2574 |
current_frame->stack_top_ctx(), |
|
2575 |
TypeOrigin::implicit(current_type())), |
|
2576 |
"Bad access to protected data in invokevirtual"); |
|
1 | 2577 |
return; |
2578 |
} |
|
2579 |
} |
|
2580 |
} |
|
2581 |
} |
|
2582 |
} |
|
2583 |
} else { |
|
2584 |
assert(opcode == Bytecodes::_invokeinterface, "Unexpected opcode encountered"); |
|
2585 |
current_frame->pop_stack(ref_class_type, CHECK_VERIFY(this)); |
|
2586 |
} |
|
2587 |
} |
|
2588 |
} |
|
2589 |
// Push the result type. |
|
2590 |
if (sig_stream.type() != T_VOID) { |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7405
diff
changeset
|
2591 |
if (method_name == vmSymbols::object_initializer_name()) { |
1 | 2592 |
// <init> method must have a void return type |
13476 | 2593 |
/* Unreachable? Class file parser verifies that methods with '<' have |
2594 |
* void return */ |
|
2595 |
verify_error(ErrorContext::bad_code(bci), |
|
2596 |
"Return type must be void in <init> method"); |
|
1 | 2597 |
return; |
2598 |
} |
|
2599 |
VerificationType return_type[2]; |
|
2600 |
int n = change_sig_to_verificationType( |
|
2601 |
&sig_stream, return_type, CHECK_VERIFY(this)); |
|
2602 |
for (int i = 0; i < n; i++) { |
|
2603 |
current_frame->push_stack(return_type[i], CHECK_VERIFY(this)); // push types backwards |
|
2604 |
} |
|
2605 |
} |
|
2606 |
} |
|
2607 |
||
2608 |
VerificationType ClassVerifier::get_newarray_type( |
|
2609 |
u2 index, u2 bci, TRAPS) { |
|
2610 |
const char* from_bt[] = { |
|
2611 |
NULL, NULL, NULL, NULL, "[Z", "[C", "[F", "[D", "[B", "[S", "[I", "[J", |
|
2612 |
}; |
|
2613 |
if (index < T_BOOLEAN || index > T_LONG) { |
|
13476 | 2614 |
verify_error(ErrorContext::bad_code(bci), "Illegal newarray instruction"); |
1 | 2615 |
return VerificationType::bogus_type(); |
2616 |
} |
|
2617 |
||
2618 |
// from_bt[index] contains the array signature which has a length of 2 |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7405
diff
changeset
|
2619 |
Symbol* sig = create_temporary_symbol( |
1 | 2620 |
from_bt[index], 2, CHECK_(VerificationType::bogus_type())); |
2621 |
return VerificationType::reference_type(sig); |
|
2622 |
} |
|
2623 |
||
2624 |
void ClassVerifier::verify_anewarray( |
|
13476 | 2625 |
u2 bci, u2 index, constantPoolHandle cp, |
2626 |
StackMapFrame* current_frame, TRAPS) { |
|
2627 |
verify_cp_class_type(bci, index, cp, CHECK_VERIFY(this)); |
|
1 | 2628 |
current_frame->pop_stack( |
2629 |
VerificationType::integer_type(), CHECK_VERIFY(this)); |
|
2630 |
||
2631 |
VerificationType component_type = |
|
2632 |
cp_index_to_type(index, cp, CHECK_VERIFY(this)); |
|
2633 |
int length; |
|
2634 |
char* arr_sig_str; |
|
2635 |
if (component_type.is_array()) { // it's an array |
|
2636 |
const char* component_name = component_type.name()->as_utf8(); |
|
2637 |
// add one dimension to component |
|
2638 |
length = (int)strlen(component_name) + 1; |
|
2639 |
arr_sig_str = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, length); |
|
2640 |
arr_sig_str[0] = '['; |
|
2641 |
strncpy(&arr_sig_str[1], component_name, length - 1); |
|
2642 |
} else { // it's an object or interface |
|
2643 |
const char* component_name = component_type.name()->as_utf8(); |
|
2644 |
// add one dimension to component with 'L' prepended and ';' postpended. |
|
2645 |
length = (int)strlen(component_name) + 3; |
|
2646 |
arr_sig_str = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, length); |
|
2647 |
arr_sig_str[0] = '['; |
|
2648 |
arr_sig_str[1] = 'L'; |
|
2649 |
strncpy(&arr_sig_str[2], component_name, length - 2); |
|
2650 |
arr_sig_str[length - 1] = ';'; |
|
2651 |
} |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7405
diff
changeset
|
2652 |
Symbol* arr_sig = create_temporary_symbol( |
1 | 2653 |
arr_sig_str, length, CHECK_VERIFY(this)); |
2654 |
VerificationType new_array_type = VerificationType::reference_type(arr_sig); |
|
2655 |
current_frame->push_stack(new_array_type, CHECK_VERIFY(this)); |
|
2656 |
} |
|
2657 |
||
2658 |
void ClassVerifier::verify_iload(u2 index, StackMapFrame* current_frame, TRAPS) { |
|
2659 |
current_frame->get_local( |
|
2660 |
index, VerificationType::integer_type(), CHECK_VERIFY(this)); |
|
2661 |
current_frame->push_stack( |
|
2662 |
VerificationType::integer_type(), CHECK_VERIFY(this)); |
|
2663 |
} |
|
2664 |
||
2665 |
void ClassVerifier::verify_lload(u2 index, StackMapFrame* current_frame, TRAPS) { |
|
2666 |
current_frame->get_local_2( |
|
2667 |
index, VerificationType::long_type(), |
|
2668 |
VerificationType::long2_type(), CHECK_VERIFY(this)); |
|
2669 |
current_frame->push_stack_2( |
|
2670 |
VerificationType::long_type(), |
|
2671 |
VerificationType::long2_type(), CHECK_VERIFY(this)); |
|
2672 |
} |
|
2673 |
||
2674 |
void ClassVerifier::verify_fload(u2 index, StackMapFrame* current_frame, TRAPS) { |
|
2675 |
current_frame->get_local( |
|
2676 |
index, VerificationType::float_type(), CHECK_VERIFY(this)); |
|
2677 |
current_frame->push_stack( |
|
2678 |
VerificationType::float_type(), CHECK_VERIFY(this)); |
|
2679 |
} |
|
2680 |
||
2681 |
void ClassVerifier::verify_dload(u2 index, StackMapFrame* current_frame, TRAPS) { |
|
2682 |
current_frame->get_local_2( |
|
2683 |
index, VerificationType::double_type(), |
|
2684 |
VerificationType::double2_type(), CHECK_VERIFY(this)); |
|
2685 |
current_frame->push_stack_2( |
|
2686 |
VerificationType::double_type(), |
|
2687 |
VerificationType::double2_type(), CHECK_VERIFY(this)); |
|
2688 |
} |
|
2689 |
||
2690 |
void ClassVerifier::verify_aload(u2 index, StackMapFrame* current_frame, TRAPS) { |
|
2691 |
VerificationType type = current_frame->get_local( |
|
2692 |
index, VerificationType::reference_check(), CHECK_VERIFY(this)); |
|
2693 |
current_frame->push_stack(type, CHECK_VERIFY(this)); |
|
2694 |
} |
|
2695 |
||
2696 |
void ClassVerifier::verify_istore(u2 index, StackMapFrame* current_frame, TRAPS) { |
|
2697 |
current_frame->pop_stack( |
|
2698 |
VerificationType::integer_type(), CHECK_VERIFY(this)); |
|
2699 |
current_frame->set_local( |
|
2700 |
index, VerificationType::integer_type(), CHECK_VERIFY(this)); |
|
2701 |
} |
|
2702 |
||
2703 |
void ClassVerifier::verify_lstore(u2 index, StackMapFrame* current_frame, TRAPS) { |
|
2704 |
current_frame->pop_stack_2( |
|
2705 |
VerificationType::long2_type(), |
|
2706 |
VerificationType::long_type(), CHECK_VERIFY(this)); |
|
2707 |
current_frame->set_local_2( |
|
2708 |
index, VerificationType::long_type(), |
|
2709 |
VerificationType::long2_type(), CHECK_VERIFY(this)); |
|
2710 |
} |
|
2711 |
||
2712 |
void ClassVerifier::verify_fstore(u2 index, StackMapFrame* current_frame, TRAPS) { |
|
2713 |
current_frame->pop_stack(VerificationType::float_type(), CHECK_VERIFY(this)); |
|
2714 |
current_frame->set_local( |
|
2715 |
index, VerificationType::float_type(), CHECK_VERIFY(this)); |
|
2716 |
} |
|
2717 |
||
2718 |
void ClassVerifier::verify_dstore(u2 index, StackMapFrame* current_frame, TRAPS) { |
|
2719 |
current_frame->pop_stack_2( |
|
2720 |
VerificationType::double2_type(), |
|
2721 |
VerificationType::double_type(), CHECK_VERIFY(this)); |
|
2722 |
current_frame->set_local_2( |
|
2723 |
index, VerificationType::double_type(), |
|
2724 |
VerificationType::double2_type(), CHECK_VERIFY(this)); |
|
2725 |
} |
|
2726 |
||
2727 |
void ClassVerifier::verify_astore(u2 index, StackMapFrame* current_frame, TRAPS) { |
|
2728 |
VerificationType type = current_frame->pop_stack( |
|
2729 |
VerificationType::reference_check(), CHECK_VERIFY(this)); |
|
2730 |
current_frame->set_local(index, type, CHECK_VERIFY(this)); |
|
2731 |
} |
|
2732 |
||
2733 |
void ClassVerifier::verify_iinc(u2 index, StackMapFrame* current_frame, TRAPS) { |
|
2734 |
VerificationType type = current_frame->get_local( |
|
2735 |
index, VerificationType::integer_type(), CHECK_VERIFY(this)); |
|
2736 |
current_frame->set_local(index, type, CHECK_VERIFY(this)); |
|
2737 |
} |
|
2738 |
||
2739 |
void ClassVerifier::verify_return_value( |
|
13476 | 2740 |
VerificationType return_type, VerificationType type, u2 bci, |
2741 |
StackMapFrame* current_frame, TRAPS) { |
|
1 | 2742 |
if (return_type == VerificationType::bogus_type()) { |
13476 | 2743 |
verify_error(ErrorContext::bad_type(bci, |
2744 |
current_frame->stack_top_ctx(), TypeOrigin::signature(return_type)), |
|
2745 |
"Method expects a return value"); |
|
1 | 2746 |
return; |
2747 |
} |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7405
diff
changeset
|
2748 |
bool match = return_type.is_assignable_from(type, this, CHECK_VERIFY(this)); |
1 | 2749 |
if (!match) { |
13476 | 2750 |
verify_error(ErrorContext::bad_type(bci, |
2751 |
current_frame->stack_top_ctx(), TypeOrigin::signature(return_type)), |
|
2752 |
"Bad return type"); |
|
1 | 2753 |
return; |
2754 |
} |
|
2755 |
} |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7405
diff
changeset
|
2756 |
|
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7405
diff
changeset
|
2757 |
// The verifier creates symbols which are substrings of Symbols. |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7405
diff
changeset
|
2758 |
// These are stored in the verifier until the end of verification so that |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7405
diff
changeset
|
2759 |
// they can be reference counted. |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7405
diff
changeset
|
2760 |
Symbol* ClassVerifier::create_temporary_symbol(const Symbol *s, int begin, |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7405
diff
changeset
|
2761 |
int end, TRAPS) { |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7405
diff
changeset
|
2762 |
Symbol* sym = SymbolTable::new_symbol(s, begin, end, CHECK_NULL); |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7405
diff
changeset
|
2763 |
_symbols->push(sym); |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7405
diff
changeset
|
2764 |
return sym; |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7405
diff
changeset
|
2765 |
} |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7405
diff
changeset
|
2766 |
|
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7405
diff
changeset
|
2767 |
Symbol* ClassVerifier::create_temporary_symbol(const char *s, int length, TRAPS) { |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7405
diff
changeset
|
2768 |
Symbol* sym = SymbolTable::new_symbol(s, length, CHECK_NULL); |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7405
diff
changeset
|
2769 |
_symbols->push(sym); |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7405
diff
changeset
|
2770 |
return sym; |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7405
diff
changeset
|
2771 |
} |