< prev index next >

src/share/vm/jvmci/jvmciRuntime.cpp

Print this page




 222 // been deoptimized. If that is the case we return the deopt blob
 223 // unpack_with_exception entry instead. This makes life for the exception blob easier
 224 // because making that same check and diverting is painful from assembly language.
 225 JRT_ENTRY_NO_ASYNC(static address, exception_handler_for_pc_helper(JavaThread* thread, oopDesc* ex, address pc, CompiledMethod*& cm))
 226   // Reset method handle flag.
 227   thread->set_is_method_handle_return(false);
 228 
 229   Handle exception(thread, ex);
 230   cm = CodeCache::find_compiled(pc);
 231   assert(cm != NULL, "this is not a compiled method");
 232   // Adjust the pc as needed/
 233   if (cm->is_deopt_pc(pc)) {
 234     RegisterMap map(thread, false);
 235     frame exception_frame = thread->last_frame().sender(&map);
 236     // if the frame isn't deopted then pc must not correspond to the caller of last_frame
 237     assert(exception_frame.is_deoptimized_frame(), "must be deopted");
 238     pc = exception_frame.pc();
 239   }
 240 #ifdef ASSERT
 241   assert(exception.not_null(), "NULL exceptions should be handled by throw_exception");
 242   assert(exception->is_oop(), "just checking");
 243   // Check that exception is a subclass of Throwable, otherwise we have a VerifyError
 244   if (!(exception->is_a(SystemDictionary::Throwable_klass()))) {
 245     if (ExitVMOnVerifyError) vm_exit(-1);
 246     ShouldNotReachHere();
 247   }
 248 #endif
 249 
 250   // Check the stack guard pages and reenable them if necessary and there is
 251   // enough space on the stack to do so.  Use fast exceptions only if the guard
 252   // pages are enabled.
 253   bool guard_pages_enabled = thread->stack_guards_enabled();
 254   if (!guard_pages_enabled) guard_pages_enabled = thread->reguard_stack();
 255 
 256   if (JvmtiExport::can_post_on_exceptions()) {
 257     // To ensure correct notification of exception catches and throws
 258     // we have to deoptimize here.  If we attempted to notify the
 259     // catches and throws during this exception lookup it's possible
 260     // we could deoptimize on the way out of the VM and end back in
 261     // the interpreter at the throw site.  This would result in double
 262     // notifications since the interpreter would also notify about


 368   }
 369 
 370   assert(continuation != NULL, "no handler found");
 371   return continuation;
 372 }
 373 
 374 JRT_ENTRY_NO_ASYNC(void, JVMCIRuntime::monitorenter(JavaThread* thread, oopDesc* obj, BasicLock* lock))
 375   IF_TRACE_jvmci_3 {
 376     char type[O_BUFLEN];
 377     obj->klass()->name()->as_C_string(type, O_BUFLEN);
 378     markOop mark = obj->mark();
 379     TRACE_jvmci_3("%s: entered locking slow case with obj=" INTPTR_FORMAT ", type=%s, mark=" INTPTR_FORMAT ", lock=" INTPTR_FORMAT, thread->name(), p2i(obj), type, p2i(mark), p2i(lock));
 380     tty->flush();
 381   }
 382 #ifdef ASSERT
 383   if (PrintBiasedLockingStatistics) {
 384     Atomic::inc(BiasedLocking::slow_path_entry_count_addr());
 385   }
 386 #endif
 387   Handle h_obj(thread, obj);
 388   assert(h_obj()->is_oop(), "must be NULL or an object");
 389   if (UseBiasedLocking) {
 390     // Retry fast entry if bias is revoked to avoid unnecessary inflation
 391     ObjectSynchronizer::fast_enter(h_obj, lock, true, CHECK);
 392   } else {
 393     if (JVMCIUseFastLocking) {
 394       // When using fast locking, the compiled code has already tried the fast case
 395       ObjectSynchronizer::slow_enter(h_obj, lock, THREAD);
 396     } else {
 397       ObjectSynchronizer::fast_enter(h_obj, lock, false, THREAD);
 398     }
 399   }
 400   TRACE_jvmci_3("%s: exiting locking slow with obj=" INTPTR_FORMAT, thread->name(), p2i(obj));
 401 JRT_END
 402 
 403 JRT_LEAF(void, JVMCIRuntime::monitorexit(JavaThread* thread, oopDesc* obj, BasicLock* lock))
 404   assert(thread == JavaThread::current(), "threads must correspond");
 405   assert(thread->last_Java_sp(), "last_Java_sp must be set");
 406   // monitorexit is non-blocking (leaf routine) => no exceptions can be thrown
 407   EXCEPTION_MARK;
 408 
 409 #ifdef DEBUG
 410   if (!obj->is_oop()) {
 411     ResetNoHandleMark rhm;
 412     nmethod* method = thread->last_frame().cb()->as_nmethod_or_null();
 413     if (method != NULL) {
 414       tty->print_cr("ERROR in monitorexit in method %s wrong obj " INTPTR_FORMAT, method->name(), p2i(obj));
 415     }
 416     thread->print_stack_on(tty);
 417     assert(false, "invalid lock object pointer dected");
 418   }
 419 #endif
 420 
 421   if (JVMCIUseFastLocking) {
 422     // When using fast locking, the compiled code has already tried the fast case
 423     ObjectSynchronizer::slow_exit(obj, lock, THREAD);
 424   } else {
 425     ObjectSynchronizer::fast_exit(obj, lock, THREAD);
 426   }
 427   IF_TRACE_jvmci_3 {
 428     char type[O_BUFLEN];
 429     obj->klass()->name()->as_C_string(type, O_BUFLEN);
 430     TRACE_jvmci_3("%s: exited locking slow case with obj=" INTPTR_FORMAT ", type=%s, mark=" INTPTR_FORMAT ", lock=" INTPTR_FORMAT, thread->name(), p2i(obj), type, p2i(obj->mark()), p2i(lock));


 438 JRT_END
 439 
 440 JRT_ENTRY(void, JVMCIRuntime::throw_klass_external_name_exception(JavaThread* thread, const char* exception, Klass* klass))
 441   ResourceMark rm(thread);
 442   TempNewSymbol symbol = SymbolTable::new_symbol(exception, CHECK);
 443   SharedRuntime::throw_and_post_jvmti_exception(thread, symbol, klass->external_name());
 444 JRT_END
 445 
 446 JRT_ENTRY(void, JVMCIRuntime::throw_class_cast_exception(JavaThread* thread, const char* exception, Klass* caster_klass, Klass* target_klass))
 447   ResourceMark rm(thread);
 448   const char* message = SharedRuntime::generate_class_cast_message(caster_klass, target_klass);
 449   TempNewSymbol symbol = SymbolTable::new_symbol(exception, CHECK);
 450   SharedRuntime::throw_and_post_jvmti_exception(thread, symbol, message);
 451 JRT_END
 452 
 453 JRT_LEAF(void, JVMCIRuntime::log_object(JavaThread* thread, oopDesc* obj, bool as_string, bool newline))
 454   ttyLocker ttyl;
 455 
 456   if (obj == NULL) {
 457     tty->print("NULL");
 458   } else if (obj->is_oop_or_null(true) && (!as_string || !java_lang_String::is_instance(obj))) {
 459     if (obj->is_oop_or_null(true)) {
 460       char buf[O_BUFLEN];
 461       tty->print("%s@" INTPTR_FORMAT, obj->klass()->name()->as_C_string(buf, O_BUFLEN), p2i(obj));
 462     } else {
 463       tty->print(INTPTR_FORMAT, p2i(obj));
 464     }
 465   } else {
 466     ResourceMark rm;
 467     assert(obj != NULL && java_lang_String::is_instance(obj), "must be");
 468     char *buf = java_lang_String::as_utf8_string(obj);
 469     tty->print_raw(buf);
 470   }
 471   if (newline) {
 472     tty->cr();
 473   }
 474 JRT_END
 475 
 476 JRT_LEAF(void, JVMCIRuntime::write_barrier_pre(JavaThread* thread, oopDesc* obj))
 477   thread->satb_mark_queue().enqueue(obj);
 478 JRT_END
 479 




 222 // been deoptimized. If that is the case we return the deopt blob
 223 // unpack_with_exception entry instead. This makes life for the exception blob easier
 224 // because making that same check and diverting is painful from assembly language.
 225 JRT_ENTRY_NO_ASYNC(static address, exception_handler_for_pc_helper(JavaThread* thread, oopDesc* ex, address pc, CompiledMethod*& cm))
 226   // Reset method handle flag.
 227   thread->set_is_method_handle_return(false);
 228 
 229   Handle exception(thread, ex);
 230   cm = CodeCache::find_compiled(pc);
 231   assert(cm != NULL, "this is not a compiled method");
 232   // Adjust the pc as needed/
 233   if (cm->is_deopt_pc(pc)) {
 234     RegisterMap map(thread, false);
 235     frame exception_frame = thread->last_frame().sender(&map);
 236     // if the frame isn't deopted then pc must not correspond to the caller of last_frame
 237     assert(exception_frame.is_deoptimized_frame(), "must be deopted");
 238     pc = exception_frame.pc();
 239   }
 240 #ifdef ASSERT
 241   assert(exception.not_null(), "NULL exceptions should be handled by throw_exception");

 242   // Check that exception is a subclass of Throwable, otherwise we have a VerifyError
 243   if (!(exception->is_a(SystemDictionary::Throwable_klass()))) {
 244     if (ExitVMOnVerifyError) vm_exit(-1);
 245     ShouldNotReachHere();
 246   }
 247 #endif
 248 
 249   // Check the stack guard pages and reenable them if necessary and there is
 250   // enough space on the stack to do so.  Use fast exceptions only if the guard
 251   // pages are enabled.
 252   bool guard_pages_enabled = thread->stack_guards_enabled();
 253   if (!guard_pages_enabled) guard_pages_enabled = thread->reguard_stack();
 254 
 255   if (JvmtiExport::can_post_on_exceptions()) {
 256     // To ensure correct notification of exception catches and throws
 257     // we have to deoptimize here.  If we attempted to notify the
 258     // catches and throws during this exception lookup it's possible
 259     // we could deoptimize on the way out of the VM and end back in
 260     // the interpreter at the throw site.  This would result in double
 261     // notifications since the interpreter would also notify about


 367   }
 368 
 369   assert(continuation != NULL, "no handler found");
 370   return continuation;
 371 }
 372 
 373 JRT_ENTRY_NO_ASYNC(void, JVMCIRuntime::monitorenter(JavaThread* thread, oopDesc* obj, BasicLock* lock))
 374   IF_TRACE_jvmci_3 {
 375     char type[O_BUFLEN];
 376     obj->klass()->name()->as_C_string(type, O_BUFLEN);
 377     markOop mark = obj->mark();
 378     TRACE_jvmci_3("%s: entered locking slow case with obj=" INTPTR_FORMAT ", type=%s, mark=" INTPTR_FORMAT ", lock=" INTPTR_FORMAT, thread->name(), p2i(obj), type, p2i(mark), p2i(lock));
 379     tty->flush();
 380   }
 381 #ifdef ASSERT
 382   if (PrintBiasedLockingStatistics) {
 383     Atomic::inc(BiasedLocking::slow_path_entry_count_addr());
 384   }
 385 #endif
 386   Handle h_obj(thread, obj);

 387   if (UseBiasedLocking) {
 388     // Retry fast entry if bias is revoked to avoid unnecessary inflation
 389     ObjectSynchronizer::fast_enter(h_obj, lock, true, CHECK);
 390   } else {
 391     if (JVMCIUseFastLocking) {
 392       // When using fast locking, the compiled code has already tried the fast case
 393       ObjectSynchronizer::slow_enter(h_obj, lock, THREAD);
 394     } else {
 395       ObjectSynchronizer::fast_enter(h_obj, lock, false, THREAD);
 396     }
 397   }
 398   TRACE_jvmci_3("%s: exiting locking slow with obj=" INTPTR_FORMAT, thread->name(), p2i(obj));
 399 JRT_END
 400 
 401 JRT_LEAF(void, JVMCIRuntime::monitorexit(JavaThread* thread, oopDesc* obj, BasicLock* lock))
 402   assert(thread == JavaThread::current(), "threads must correspond");
 403   assert(thread->last_Java_sp(), "last_Java_sp must be set");
 404   // monitorexit is non-blocking (leaf routine) => no exceptions can be thrown
 405   EXCEPTION_MARK;
 406 
 407 #ifdef DEBUG
 408   if (!oopDesc::is_oop(obj)) {
 409     ResetNoHandleMark rhm;
 410     nmethod* method = thread->last_frame().cb()->as_nmethod_or_null();
 411     if (method != NULL) {
 412       tty->print_cr("ERROR in monitorexit in method %s wrong obj " INTPTR_FORMAT, method->name(), p2i(obj));
 413     }
 414     thread->print_stack_on(tty);
 415     assert(false, "invalid lock object pointer dected");
 416   }
 417 #endif
 418 
 419   if (JVMCIUseFastLocking) {
 420     // When using fast locking, the compiled code has already tried the fast case
 421     ObjectSynchronizer::slow_exit(obj, lock, THREAD);
 422   } else {
 423     ObjectSynchronizer::fast_exit(obj, lock, THREAD);
 424   }
 425   IF_TRACE_jvmci_3 {
 426     char type[O_BUFLEN];
 427     obj->klass()->name()->as_C_string(type, O_BUFLEN);
 428     TRACE_jvmci_3("%s: exited locking slow case with obj=" INTPTR_FORMAT ", type=%s, mark=" INTPTR_FORMAT ", lock=" INTPTR_FORMAT, thread->name(), p2i(obj), type, p2i(obj->mark()), p2i(lock));


 436 JRT_END
 437 
 438 JRT_ENTRY(void, JVMCIRuntime::throw_klass_external_name_exception(JavaThread* thread, const char* exception, Klass* klass))
 439   ResourceMark rm(thread);
 440   TempNewSymbol symbol = SymbolTable::new_symbol(exception, CHECK);
 441   SharedRuntime::throw_and_post_jvmti_exception(thread, symbol, klass->external_name());
 442 JRT_END
 443 
 444 JRT_ENTRY(void, JVMCIRuntime::throw_class_cast_exception(JavaThread* thread, const char* exception, Klass* caster_klass, Klass* target_klass))
 445   ResourceMark rm(thread);
 446   const char* message = SharedRuntime::generate_class_cast_message(caster_klass, target_klass);
 447   TempNewSymbol symbol = SymbolTable::new_symbol(exception, CHECK);
 448   SharedRuntime::throw_and_post_jvmti_exception(thread, symbol, message);
 449 JRT_END
 450 
 451 JRT_LEAF(void, JVMCIRuntime::log_object(JavaThread* thread, oopDesc* obj, bool as_string, bool newline))
 452   ttyLocker ttyl;
 453 
 454   if (obj == NULL) {
 455     tty->print("NULL");
 456   } else if (oopDesc::is_oop_or_null(obj, true) && (!as_string || !java_lang_String::is_instance(obj))) {
 457     if (oopDesc::is_oop_or_null(obj, true)) {
 458       char buf[O_BUFLEN];
 459       tty->print("%s@" INTPTR_FORMAT, obj->klass()->name()->as_C_string(buf, O_BUFLEN), p2i(obj));
 460     } else {
 461       tty->print(INTPTR_FORMAT, p2i(obj));
 462     }
 463   } else {
 464     ResourceMark rm;
 465     assert(obj != NULL && java_lang_String::is_instance(obj), "must be");
 466     char *buf = java_lang_String::as_utf8_string(obj);
 467     tty->print_raw(buf);
 468   }
 469   if (newline) {
 470     tty->cr();
 471   }
 472 JRT_END
 473 
 474 JRT_LEAF(void, JVMCIRuntime::write_barrier_pre(JavaThread* thread, oopDesc* obj))
 475   thread->satb_mark_queue().enqueue(obj);
 476 JRT_END
 477 


< prev index next >