hotspot/src/share/vm/runtime/sharedRuntime.cpp
changeset 28947 2ea471384931
parent 28039 bf5a8340bf8a
child 29070 b0a5fc9c59c8
equal deleted inserted replaced
28946:24261e03ba4c 28947:2ea471384931
  2608   // Lock and unlock a critical section to give the system a chance to block
  2608   // Lock and unlock a critical section to give the system a chance to block
  2609   GC_locker::lock_critical(thread);
  2609   GC_locker::lock_critical(thread);
  2610   GC_locker::unlock_critical(thread);
  2610   GC_locker::unlock_critical(thread);
  2611 JRT_END
  2611 JRT_END
  2612 
  2612 
  2613 #ifdef HAVE_DTRACE_H
       
  2614 /**
       
  2615  * Create a dtrace nmethod for this method.  The wrapper converts the
       
  2616  * Java-compiled calling convention to the native convention, makes a dummy call
       
  2617  * (actually nops for the size of the call instruction, which become a trap if
       
  2618  * probe is enabled), and finally returns to the caller. Since this all looks like a
       
  2619  * leaf, no thread transition is needed.
       
  2620  */
       
  2621 nmethod *AdapterHandlerLibrary::create_dtrace_nmethod(methodHandle method) {
       
  2622   ResourceMark rm;
       
  2623   nmethod* nm = NULL;
       
  2624 
       
  2625   if (PrintCompilation) {
       
  2626     ttyLocker ttyl;
       
  2627     tty->print("---   n  ");
       
  2628     method->print_short_name(tty);
       
  2629     if (method->is_static()) {
       
  2630       tty->print(" (static)");
       
  2631     }
       
  2632     tty->cr();
       
  2633   }
       
  2634 
       
  2635   {
       
  2636     // perform the work while holding the lock, but perform any printing
       
  2637     // outside the lock
       
  2638     MutexLocker mu(AdapterHandlerLibrary_lock);
       
  2639     // See if somebody beat us to it
       
  2640     nm = method->code();
       
  2641     if (nm) {
       
  2642       return nm;
       
  2643     }
       
  2644 
       
  2645     ResourceMark rm;
       
  2646 
       
  2647     BufferBlob*  buf = buffer_blob(); // the temporary code buffer in CodeCache
       
  2648     if (buf != NULL) {
       
  2649       CodeBuffer buffer(buf);
       
  2650       // Need a few relocation entries
       
  2651       double locs_buf[20];
       
  2652       buffer.insts()->initialize_shared_locs(
       
  2653         (relocInfo*)locs_buf, sizeof(locs_buf) / sizeof(relocInfo));
       
  2654       MacroAssembler _masm(&buffer);
       
  2655 
       
  2656       // Generate the compiled-to-native wrapper code
       
  2657       nm = SharedRuntime::generate_dtrace_nmethod(&_masm, method);
       
  2658     }
       
  2659   }
       
  2660   return nm;
       
  2661 }
       
  2662 
       
  2663 // the dtrace method needs to convert java lang string to utf8 string.
       
  2664 void SharedRuntime::get_utf(oopDesc* src, address dst) {
       
  2665   typeArrayOop jlsValue  = java_lang_String::value(src);
       
  2666   int          jlsOffset = java_lang_String::offset(src);
       
  2667   int          jlsLen    = java_lang_String::length(src);
       
  2668   jchar*       jlsPos    = (jlsLen == 0) ? NULL :
       
  2669                                            jlsValue->char_at_addr(jlsOffset);
       
  2670   assert(TypeArrayKlass::cast(jlsValue->klass())->element_type() == T_CHAR, "compressed string");
       
  2671   (void) UNICODE::as_utf8(jlsPos, jlsLen, (char *)dst, max_dtrace_string_size);
       
  2672 }
       
  2673 #endif // ndef HAVE_DTRACE_H
       
  2674 
       
  2675 int SharedRuntime::convert_ints_to_longints_argcnt(int in_args_count, BasicType* in_sig_bt) {
  2613 int SharedRuntime::convert_ints_to_longints_argcnt(int in_args_count, BasicType* in_sig_bt) {
  2676   int argcnt = in_args_count;
  2614   int argcnt = in_args_count;
  2677   if (CCallingConventionRequiresIntsAsLongs) {
  2615   if (CCallingConventionRequiresIntsAsLongs) {
  2678     for (int in = 0; in < in_args_count; in++) {
  2616     for (int in = 0; in < in_args_count; in++) {
  2679       BasicType bt = in_sig_bt[in];
  2617       BasicType bt = in_sig_bt[in];