annotate src/share/vm/runtime/javaCalls.cpp @ 61:5a76ab815e34

6667833: Remove CacheTimeMillis Summary: Remove -XX:+CacheTimeMillis option and associated functionality Reviewed-by: acorn, never
author sbohne
date Wed, 19 Mar 2008 09:58:01 -0400
parents
children dc16daa0329d
rev   line source
duke@0 1 /*
duke@0 2 * Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved.
duke@0 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@0 4 *
duke@0 5 * This code is free software; you can redistribute it and/or modify it
duke@0 6 * under the terms of the GNU General Public License version 2 only, as
duke@0 7 * published by the Free Software Foundation.
duke@0 8 *
duke@0 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@0 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@0 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@0 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@0 13 * accompanied this code).
duke@0 14 *
duke@0 15 * You should have received a copy of the GNU General Public License version
duke@0 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@0 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@0 18 *
duke@0 19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
duke@0 20 * CA 95054 USA or visit www.sun.com if you need additional information or
duke@0 21 * have any questions.
duke@0 22 *
duke@0 23 */
duke@0 24
duke@0 25 #include "incls/_precompiled.incl"
duke@0 26 #include "incls/_javaCalls.cpp.incl"
duke@0 27
duke@0 28 // -----------------------------------------------------
duke@0 29 // Implementation of JavaCallWrapper
duke@0 30
duke@0 31 JavaCallWrapper::JavaCallWrapper(methodHandle callee_method, Handle receiver, JavaValue* result, TRAPS) {
duke@0 32 JavaThread* thread = (JavaThread *)THREAD;
duke@0 33 bool clear_pending_exception = true;
duke@0 34
duke@0 35 guarantee(thread->is_Java_thread(), "crucial check - the VM thread cannot and must not escape to Java code");
duke@0 36 assert(!thread->owns_locks(), "must release all locks when leaving VM");
duke@0 37 guarantee(!thread->is_Compiler_thread(), "cannot make java calls from the compiler");
duke@0 38 _result = result;
duke@0 39
duke@0 40 // Make sure that that the value of the higest_lock is at least the same as the current stackpointer,
duke@0 41 // since, the Java code is highly likely to use locks.
duke@0 42 // Use '(address)this' to guarantee that highest_lock address is conservative and inside our thread
duke@0 43 thread->update_highest_lock((address)this);
duke@0 44
duke@0 45 // Allocate handle block for Java code. This must be done before we change thread_state to _thread_in_Java_or_stub,
duke@0 46 // since it can potentially block.
duke@0 47 JNIHandleBlock* new_handles = JNIHandleBlock::allocate_block(thread);
duke@0 48
duke@0 49 // After this, we are official in JavaCode. This needs to be done before we change any of the thread local
duke@0 50 // info, since we cannot find oops before the new information is set up completely.
duke@0 51 ThreadStateTransition::transition(thread, _thread_in_vm, _thread_in_Java);
duke@0 52
duke@0 53 // Make sure that we handle asynchronous stops and suspends _before_ we clear all thread state
duke@0 54 // in JavaCallWrapper::JavaCallWrapper(). This way, we can decide if we need to do any pd actions
duke@0 55 // to prepare for stop/suspend (flush register windows on sparcs, cache sp, or other state).
duke@0 56 if (thread->has_special_runtime_exit_condition()) {
duke@0 57 thread->handle_special_runtime_exit_condition();
duke@0 58 if (HAS_PENDING_EXCEPTION) {
duke@0 59 clear_pending_exception = false;
duke@0 60 }
duke@0 61 }
duke@0 62
duke@0 63
duke@0 64 // Make sure to set the oop's after the thread transition - since we can block there. No one is GC'ing
duke@0 65 // the JavaCallWrapper before the entry frame is on the stack.
duke@0 66 _callee_method = callee_method();
duke@0 67 _receiver = receiver();
duke@0 68
duke@0 69 #ifdef CHECK_UNHANDLED_OOPS
duke@0 70 THREAD->allow_unhandled_oop(&_callee_method);
duke@0 71 THREAD->allow_unhandled_oop(&_receiver);
duke@0 72 #endif // CHECK_UNHANDLED_OOPS
duke@0 73
duke@0 74 _thread = (JavaThread *)thread;
duke@0 75 _handles = _thread->active_handles(); // save previous handle block & Java frame linkage
duke@0 76
duke@0 77 // For the profiler, the last_Java_frame information in thread must always be in
duke@0 78 // legal state. We have no last Java frame if last_Java_sp == NULL so
duke@0 79 // the valid transition is to clear _last_Java_sp and then reset the rest of
duke@0 80 // the (platform specific) state.
duke@0 81
duke@0 82 _anchor.copy(_thread->frame_anchor());
duke@0 83 _thread->frame_anchor()->clear();
duke@0 84
duke@0 85 debug_only(_thread->inc_java_call_counter());
duke@0 86 _thread->set_active_handles(new_handles); // install new handle block and reset Java frame linkage
duke@0 87
duke@0 88 assert (_thread->thread_state() != _thread_in_native, "cannot set native pc to NULL");
duke@0 89
duke@0 90 // clear any pending exception in thread (native calls start with no exception pending)
duke@0 91 if(clear_pending_exception) {
duke@0 92 _thread->clear_pending_exception();
duke@0 93 }
duke@0 94
duke@0 95 if (_anchor.last_Java_sp() == NULL) {
duke@0 96 _thread->record_base_of_stack_pointer();
duke@0 97 }
duke@0 98 }
duke@0 99
duke@0 100
duke@0 101 JavaCallWrapper::~JavaCallWrapper() {
duke@0 102 assert(_thread == JavaThread::current(), "must still be the same thread");
duke@0 103
duke@0 104 // restore previous handle block & Java frame linkage
duke@0 105 JNIHandleBlock *_old_handles = _thread->active_handles();
duke@0 106 _thread->set_active_handles(_handles);
duke@0 107
duke@0 108 _thread->frame_anchor()->zap();
duke@0 109
duke@0 110 debug_only(_thread->dec_java_call_counter());
duke@0 111
duke@0 112 if (_anchor.last_Java_sp() == NULL) {
duke@0 113 _thread->set_base_of_stack_pointer(NULL);
duke@0 114 }
duke@0 115
duke@0 116
duke@0 117 // Old thread-local info. has been restored. We are not back in the VM.
duke@0 118 ThreadStateTransition::transition_from_java(_thread, _thread_in_vm);
duke@0 119
duke@0 120 // State has been restored now make the anchor frame visible for the profiler.
duke@0 121 // Do this after the transition because this allows us to put an assert
duke@0 122 // the Java->vm transition which checks to see that stack is not walkable
duke@0 123 // on sparc/ia64 which will catch violations of the reseting of last_Java_frame
duke@0 124 // invariants (i.e. _flags always cleared on return to Java)
duke@0 125
duke@0 126 _thread->frame_anchor()->copy(&_anchor);
duke@0 127
duke@0 128 // Release handles after we are marked as being inside the VM again, since this
duke@0 129 // operation might block
duke@0 130 JNIHandleBlock::release_block(_old_handles, _thread);
duke@0 131 }
duke@0 132
duke@0 133
duke@0 134 void JavaCallWrapper::oops_do(OopClosure* f) {
duke@0 135 f->do_oop((oop*)&_callee_method);
duke@0 136 f->do_oop((oop*)&_receiver);
duke@0 137 handles()->oops_do(f);
duke@0 138 }
duke@0 139
duke@0 140
duke@0 141 // Helper methods
duke@0 142 static BasicType runtime_type_from(JavaValue* result) {
duke@0 143 switch (result->get_type()) {
duke@0 144 case T_BOOLEAN: // fall through
duke@0 145 case T_CHAR : // fall through
duke@0 146 case T_SHORT : // fall through
duke@0 147 case T_INT : // fall through
duke@0 148 #ifndef _LP64
duke@0 149 case T_OBJECT : // fall through
duke@0 150 case T_ARRAY : // fall through
duke@0 151 #endif
duke@0 152 case T_BYTE : // fall through
duke@0 153 case T_VOID : return T_INT;
duke@0 154 case T_LONG : return T_LONG;
duke@0 155 case T_FLOAT : return T_FLOAT;
duke@0 156 case T_DOUBLE : return T_DOUBLE;
duke@0 157 #ifdef _LP64
duke@0 158 case T_ARRAY : // fall through
duke@0 159 case T_OBJECT: return T_OBJECT;
duke@0 160 #endif
duke@0 161 }
duke@0 162 ShouldNotReachHere();
duke@0 163 return T_ILLEGAL;
duke@0 164 }
duke@0 165
duke@0 166 // ===== object constructor calls =====
duke@0 167
duke@0 168 void JavaCalls::call_default_constructor(JavaThread* thread, methodHandle method, Handle receiver, TRAPS) {
duke@0 169 assert(method->name() == vmSymbols::object_initializer_name(), "Should only be called for default constructor");
duke@0 170 assert(method->signature() == vmSymbols::void_method_signature(), "Should only be called for default constructor");
duke@0 171
duke@0 172 instanceKlass* ik = instanceKlass::cast(method->method_holder());
duke@0 173 if (ik->is_initialized() && ik->has_vanilla_constructor()) {
duke@0 174 // safe to skip constructor call
duke@0 175 } else {
duke@0 176 static JavaValue result(T_VOID);
duke@0 177 JavaCallArguments args(receiver);
duke@0 178 call(&result, method, &args, CHECK);
duke@0 179 }
duke@0 180 }
duke@0 181
duke@0 182 // ============ Virtual calls ============
duke@0 183
duke@0 184 void JavaCalls::call_virtual(JavaValue* result, KlassHandle spec_klass, symbolHandle name, symbolHandle signature, JavaCallArguments* args, TRAPS) {
duke@0 185 CallInfo callinfo;
duke@0 186 Handle receiver = args->receiver();
duke@0 187 KlassHandle recvrKlass(THREAD, receiver.is_null() ? (klassOop)NULL : receiver->klass());
duke@0 188 LinkResolver::resolve_virtual_call(
duke@0 189 callinfo, receiver, recvrKlass, spec_klass, name, signature,
duke@0 190 KlassHandle(), false, true, CHECK);
duke@0 191 methodHandle method = callinfo.selected_method();
duke@0 192 assert(method.not_null(), "should have thrown exception");
duke@0 193
duke@0 194 // Invoke the method
duke@0 195 JavaCalls::call(result, method, args, CHECK);
duke@0 196 }
duke@0 197
duke@0 198
duke@0 199 void JavaCalls::call_virtual(JavaValue* result, Handle receiver, KlassHandle spec_klass, symbolHandle name, symbolHandle signature, TRAPS) {
duke@0 200 JavaCallArguments args(receiver); // One oop argument
duke@0 201 call_virtual(result, spec_klass, name, signature, &args, CHECK);
duke@0 202 }
duke@0 203
duke@0 204
duke@0 205 void JavaCalls::call_virtual(JavaValue* result, Handle receiver, KlassHandle spec_klass, symbolHandle name, symbolHandle signature, Handle arg1, TRAPS) {
duke@0 206 JavaCallArguments args(receiver); // One oop argument
duke@0 207 args.push_oop(arg1);
duke@0 208 call_virtual(result, spec_klass, name, signature, &args, CHECK);
duke@0 209 }
duke@0 210
duke@0 211
duke@0 212
duke@0 213 void JavaCalls::call_virtual(JavaValue* result, Handle receiver, KlassHandle spec_klass, symbolHandle name, symbolHandle signature, Handle arg1, Handle arg2, TRAPS) {
duke@0 214 JavaCallArguments args(receiver); // One oop argument
duke@0 215 args.push_oop(arg1);
duke@0 216 args.push_oop(arg2);
duke@0 217 call_virtual(result, spec_klass, name, signature, &args, CHECK);
duke@0 218 }
duke@0 219
duke@0 220
duke@0 221 // ============ Special calls ============
duke@0 222
duke@0 223 void JavaCalls::call_special(JavaValue* result, KlassHandle klass, symbolHandle name, symbolHandle signature, JavaCallArguments* args, TRAPS) {
duke@0 224 CallInfo callinfo;
duke@0 225 LinkResolver::resolve_special_call(callinfo, klass, name, signature, KlassHandle(), false, CHECK);
duke@0 226 methodHandle method = callinfo.selected_method();
duke@0 227 assert(method.not_null(), "should have thrown exception");
duke@0 228
duke@0 229 // Invoke the method
duke@0 230 JavaCalls::call(result, method, args, CHECK);
duke@0 231 }
duke@0 232
duke@0 233
duke@0 234 void JavaCalls::call_special(JavaValue* result, Handle receiver, KlassHandle klass, symbolHandle name, symbolHandle signature, TRAPS) {
duke@0 235 JavaCallArguments args(receiver); // One oop argument
duke@0 236 call_special(result, klass, name, signature, &args, CHECK);
duke@0 237 }
duke@0 238
duke@0 239
duke@0 240 void JavaCalls::call_special(JavaValue* result, Handle receiver, KlassHandle klass, symbolHandle name, symbolHandle signature, Handle arg1, TRAPS) {
duke@0 241 JavaCallArguments args(receiver); // One oop argument
duke@0 242 args.push_oop(arg1);
duke@0 243 call_special(result, klass, name, signature, &args, CHECK);
duke@0 244 }
duke@0 245
duke@0 246
duke@0 247 void JavaCalls::call_special(JavaValue* result, Handle receiver, KlassHandle klass, symbolHandle name, symbolHandle signature, Handle arg1, Handle arg2, TRAPS) {
duke@0 248 JavaCallArguments args(receiver); // One oop argument
duke@0 249 args.push_oop(arg1);
duke@0 250 args.push_oop(arg2);
duke@0 251 call_special(result, klass, name, signature, &args, CHECK);
duke@0 252 }
duke@0 253
duke@0 254
duke@0 255 // ============ Static calls ============
duke@0 256
duke@0 257 void JavaCalls::call_static(JavaValue* result, KlassHandle klass, symbolHandle name, symbolHandle signature, JavaCallArguments* args, TRAPS) {
duke@0 258 CallInfo callinfo;
duke@0 259 LinkResolver::resolve_static_call(callinfo, klass, name, signature, KlassHandle(), false, true, CHECK);
duke@0 260 methodHandle method = callinfo.selected_method();
duke@0 261 assert(method.not_null(), "should have thrown exception");
duke@0 262
duke@0 263 // Invoke the method
duke@0 264 JavaCalls::call(result, method, args, CHECK);
duke@0 265 }
duke@0 266
duke@0 267
duke@0 268 void JavaCalls::call_static(JavaValue* result, KlassHandle klass, symbolHandle name, symbolHandle signature, TRAPS) {
duke@0 269 JavaCallArguments args; // No argument
duke@0 270 call_static(result, klass, name, signature, &args, CHECK);
duke@0 271 }
duke@0 272
duke@0 273
duke@0 274 void JavaCalls::call_static(JavaValue* result, KlassHandle klass, symbolHandle name, symbolHandle signature, Handle arg1, TRAPS) {
duke@0 275 JavaCallArguments args(arg1); // One oop argument
duke@0 276 call_static(result, klass, name, signature, &args, CHECK);
duke@0 277 }
duke@0 278
duke@0 279
duke@0 280 void JavaCalls::call_static(JavaValue* result, KlassHandle klass, symbolHandle name, symbolHandle signature, Handle arg1, Handle arg2, TRAPS) {
duke@0 281 JavaCallArguments args; // One oop argument
duke@0 282 args.push_oop(arg1);
duke@0 283 args.push_oop(arg2);
duke@0 284 call_static(result, klass, name, signature, &args, CHECK);
duke@0 285 }
duke@0 286
duke@0 287
duke@0 288 // -------------------------------------------------
duke@0 289 // Implementation of JavaCalls (low level)
duke@0 290
duke@0 291
duke@0 292 void JavaCalls::call(JavaValue* result, methodHandle method, JavaCallArguments* args, TRAPS) {
duke@0 293 // Check if we need to wrap a potential OS exception handler around thread
duke@0 294 // This is used for e.g. Win32 structured exception handlers
duke@0 295 assert(THREAD->is_Java_thread(), "only JavaThreads can make JavaCalls");
duke@0 296 // Need to wrap each and everytime, since there might be native code down the
duke@0 297 // stack that has installed its own exception handlers
duke@0 298 os::os_exception_wrapper(call_helper, result, &method, args, THREAD);
duke@0 299 }
duke@0 300
duke@0 301 void JavaCalls::call_helper(JavaValue* result, methodHandle* m, JavaCallArguments* args, TRAPS) {
duke@0 302 methodHandle method = *m;
duke@0 303 JavaThread* thread = (JavaThread*)THREAD;
duke@0 304 assert(thread->is_Java_thread(), "must be called by a java thread");
duke@0 305 assert(method.not_null(), "must have a method to call");
duke@0 306 assert(!SafepointSynchronize::is_at_safepoint(), "call to Java code during VM operation");
duke@0 307 assert(!thread->handle_area()->no_handle_mark_active(), "cannot call out to Java here");
duke@0 308
duke@0 309
duke@0 310 CHECK_UNHANDLED_OOPS_ONLY(thread->clear_unhandled_oops();)
duke@0 311
duke@0 312 // Make sure that the arguments have the right type
duke@0 313 debug_only(args->verify(method, result->get_type(), thread));
duke@0 314
duke@0 315 // Ignore call if method is empty
duke@0 316 if (method->is_empty_method()) {
duke@0 317 assert(result->get_type() == T_VOID, "an empty method must return a void value");
duke@0 318 return;
duke@0 319 }
duke@0 320
duke@0 321
duke@0 322 #ifdef ASSERT
duke@0 323 { klassOop holder = method->method_holder();
duke@0 324 // A klass might not be initialized since JavaCall's might be used during the executing of
duke@0 325 // the <clinit>. For example, a Thread.start might start executing on an object that is
duke@0 326 // not fully initialized! (bad Java programming style)
duke@0 327 assert(instanceKlass::cast(holder)->is_linked(), "rewritting must have taken place");
duke@0 328 }
duke@0 329 #endif
duke@0 330
duke@0 331
duke@0 332 assert(!thread->is_Compiler_thread(), "cannot compile from the compiler");
duke@0 333 if (CompilationPolicy::mustBeCompiled(method)) {
duke@0 334 CompileBroker::compile_method(method, InvocationEntryBci,
duke@0 335 methodHandle(), 0, "mustBeCompiled", CHECK);
duke@0 336 }
duke@0 337
duke@0 338 // Since the call stub sets up like the interpreter we call the from_interpreted_entry
duke@0 339 // so we can go compiled via a i2c. Otherwise initial entry method will always
duke@0 340 // run interpreted.
duke@0 341 address entry_point = method->from_interpreted_entry();
duke@0 342 if (JvmtiExport::can_post_interpreter_events() && thread->is_interp_only_mode()) {
duke@0 343 entry_point = method->interpreter_entry();
duke@0 344 }
duke@0 345
duke@0 346 // Figure out if the result value is an oop or not (Note: This is a different value
duke@0 347 // than result_type. result_type will be T_INT of oops. (it is about size)
duke@0 348 BasicType result_type = runtime_type_from(result);
duke@0 349 bool oop_result_flag = (result->get_type() == T_OBJECT || result->get_type() == T_ARRAY);
duke@0 350
duke@0 351 // NOTE: if we move the computation of the result_val_address inside
duke@0 352 // the call to call_stub, the optimizer produces wrong code.
duke@0 353 intptr_t* result_val_address = (intptr_t*)(result->get_value_addr());
duke@0 354
duke@0 355 // Find receiver
duke@0 356 Handle receiver = (!method->is_static()) ? args->receiver() : Handle();
duke@0 357
duke@0 358 // When we reenter Java, we need to reenable the yellow zone which
duke@0 359 // might already be disabled when we are in VM.
duke@0 360 if (thread->stack_yellow_zone_disabled()) {
duke@0 361 thread->reguard_stack();
duke@0 362 }
duke@0 363
duke@0 364 // Check that there are shadow pages available before changing thread state
duke@0 365 // to Java
duke@0 366 if (!os::stack_shadow_pages_available(THREAD, method)) {
duke@0 367 // Throw stack overflow exception with preinitialized exception.
duke@0 368 Exceptions::throw_stack_overflow_exception(THREAD, __FILE__, __LINE__);
duke@0 369 return;
duke@0 370 } else {
duke@0 371 // Touch pages checked if the OS needs them to be touched to be mapped.
duke@0 372 os::bang_stack_shadow_pages();
duke@0 373 }
duke@0 374
duke@0 375 // do call
duke@0 376 { JavaCallWrapper link(method, receiver, result, CHECK);
duke@0 377 { HandleMark hm(thread); // HandleMark used by HandleMarkCleaner
duke@0 378
duke@0 379 StubRoutines::call_stub()(
duke@0 380 (address)&link,
duke@0 381 // (intptr_t*)&(result->_value), // see NOTE above (compiler problem)
duke@0 382 result_val_address, // see NOTE above (compiler problem)
duke@0 383 result_type,
duke@0 384 method(),
duke@0 385 entry_point,
duke@0 386 args->parameters(),
duke@0 387 args->size_of_parameters(),
duke@0 388 CHECK
duke@0 389 );
duke@0 390
duke@0 391 result = link.result(); // circumvent MS C++ 5.0 compiler bug (result is clobbered across call)
duke@0 392 // Preserve oop return value across possible gc points
duke@0 393 if (oop_result_flag) {
duke@0 394 thread->set_vm_result((oop) result->get_jobject());
duke@0 395 }
duke@0 396 }
duke@0 397 } // Exit JavaCallWrapper (can block - potential return oop must be preserved)
duke@0 398
duke@0 399 // Check if a thread stop or suspend should be executed
duke@0 400 // The following assert was not realistic. Thread.stop can set that bit at any moment.
duke@0 401 //assert(!thread->has_special_runtime_exit_condition(), "no async. exceptions should be installed");
duke@0 402
duke@0 403 // Restore possible oop return
duke@0 404 if (oop_result_flag) {
duke@0 405 result->set_jobject((jobject)thread->vm_result());
duke@0 406 thread->set_vm_result(NULL);
duke@0 407 }
duke@0 408 }
duke@0 409
duke@0 410
duke@0 411 //--------------------------------------------------------------------------------------
duke@0 412 // Implementation of JavaCallArguments
duke@0 413
duke@0 414 intptr_t* JavaCallArguments::parameters() {
duke@0 415 // First convert all handles to oops
duke@0 416 for(int i = 0; i < _size; i++) {
duke@0 417 if (_is_oop[i]) {
duke@0 418 // Handle conversion
duke@0 419 _value[i] = (intptr_t)Handle::raw_resolve((oop *)_value[i]);
duke@0 420 }
duke@0 421 // The parameters are moved to the parameters array to include the tags.
duke@0 422 if (TaggedStackInterpreter) {
duke@0 423 // Tags are interspersed with arguments. Tags are first.
duke@0 424 int tagged_index = i*2;
duke@0 425 _parameters[tagged_index] = _is_oop[i] ? frame::TagReference :
duke@0 426 frame::TagValue;
duke@0 427 _parameters[tagged_index+1] = _value[i];
duke@0 428 }
duke@0 429 }
duke@0 430 // Return argument vector
duke@0 431 return TaggedStackInterpreter ? _parameters : _value;
duke@0 432 }
duke@0 433
duke@0 434 //--------------------------------------------------------------------------------------
duke@0 435 // Non-Product code
duke@0 436 #ifndef PRODUCT
duke@0 437
duke@0 438 class SignatureChekker : public SignatureIterator {
duke@0 439 private:
duke@0 440 bool *_is_oop;
duke@0 441 int _pos;
duke@0 442 BasicType _return_type;
duke@0 443
duke@0 444 public:
duke@0 445 bool _is_return;
duke@0 446
duke@0 447 SignatureChekker(symbolHandle signature, BasicType return_type, bool is_static, bool* is_oop) : SignatureIterator(signature) {
duke@0 448 _is_oop = is_oop;
duke@0 449 _is_return = false;
duke@0 450 _return_type = return_type;
duke@0 451 _pos = 0;
duke@0 452 if (!is_static) {
duke@0 453 check_value(true); // Receiver must be an oop
duke@0 454 }
duke@0 455 }
duke@0 456
duke@0 457 void check_value(bool type) {
duke@0 458 guarantee(_is_oop[_pos++] == type, "signature does not match pushed arguments");
duke@0 459 }
duke@0 460
duke@0 461 void check_doing_return(bool state) { _is_return = state; }
duke@0 462
duke@0 463 void check_return_type(BasicType t) {
duke@0 464 guarantee(_is_return && t == _return_type, "return type does not match");
duke@0 465 }
duke@0 466
duke@0 467 void check_int(BasicType t) {
duke@0 468 if (_is_return) {
duke@0 469 check_return_type(t);
duke@0 470 return;
duke@0 471 }
duke@0 472 check_value(false);
duke@0 473 }
duke@0 474
duke@0 475 void check_double(BasicType t) { check_long(t); }
duke@0 476
duke@0 477 void check_long(BasicType t) {
duke@0 478 if (_is_return) {
duke@0 479 check_return_type(t);
duke@0 480 return;
duke@0 481 }
duke@0 482
duke@0 483 check_value(false);
duke@0 484 check_value(false);
duke@0 485 }
duke@0 486
duke@0 487 void check_obj(BasicType t) {
duke@0 488 if (_is_return) {
duke@0 489 check_return_type(t);
duke@0 490 return;
duke@0 491 }
duke@0 492 check_value(true);
duke@0 493 }
duke@0 494
duke@0 495 void do_bool() { check_int(T_BOOLEAN); }
duke@0 496 void do_char() { check_int(T_CHAR); }
duke@0 497 void do_float() { check_int(T_FLOAT); }
duke@0 498 void do_double() { check_double(T_DOUBLE); }
duke@0 499 void do_byte() { check_int(T_BYTE); }
duke@0 500 void do_short() { check_int(T_SHORT); }
duke@0 501 void do_int() { check_int(T_INT); }
duke@0 502 void do_long() { check_long(T_LONG); }
duke@0 503 void do_void() { check_return_type(T_VOID); }
duke@0 504 void do_object(int begin, int end) { check_obj(T_OBJECT); }
duke@0 505 void do_array(int begin, int end) { check_obj(T_OBJECT); }
duke@0 506 };
duke@0 507
duke@0 508 void JavaCallArguments::verify(methodHandle method, BasicType return_type,
duke@0 509 Thread *thread) {
duke@0 510 guarantee(method->size_of_parameters() == size_of_parameters(), "wrong no. of arguments pushed");
duke@0 511
duke@0 512 // Treat T_OBJECT and T_ARRAY as the same
duke@0 513 if (return_type == T_ARRAY) return_type = T_OBJECT;
duke@0 514
duke@0 515 // Check that oop information is correct
duke@0 516 symbolHandle signature (thread, method->signature());
duke@0 517
duke@0 518 SignatureChekker sc(signature, return_type, method->is_static(),_is_oop);
duke@0 519 sc.iterate_parameters();
duke@0 520 sc.check_doing_return(true);
duke@0 521 sc.iterate_returntype();
duke@0 522 }
duke@0 523
duke@0 524 #endif // PRODUCT