< prev index next >

src/share/vm/runtime/sharedRuntime.cpp

Print this page




  45 #include "runtime/arguments.hpp"
  46 #include "runtime/biasedLocking.hpp"
  47 #include "runtime/handles.inline.hpp"
  48 #include "runtime/init.hpp"
  49 #include "runtime/interfaceSupport.hpp"
  50 #include "runtime/javaCalls.hpp"
  51 #include "runtime/sharedRuntime.hpp"
  52 #include "runtime/stubRoutines.hpp"
  53 #include "runtime/vframe.hpp"
  54 #include "runtime/vframeArray.hpp"
  55 #include "utilities/copy.hpp"
  56 #include "utilities/dtrace.hpp"
  57 #include "utilities/events.hpp"
  58 #include "utilities/hashtable.inline.hpp"
  59 #include "utilities/macros.hpp"
  60 #include "utilities/xmlstream.hpp"
  61 #ifdef TARGET_ARCH_x86
  62 # include "nativeInst_x86.hpp"
  63 # include "vmreg_x86.inline.hpp"
  64 #endif




  65 #ifdef TARGET_ARCH_sparc
  66 # include "nativeInst_sparc.hpp"
  67 # include "vmreg_sparc.inline.hpp"
  68 #endif
  69 #ifdef TARGET_ARCH_zero
  70 # include "nativeInst_zero.hpp"
  71 # include "vmreg_zero.inline.hpp"
  72 #endif
  73 #ifdef TARGET_ARCH_arm
  74 # include "nativeInst_arm.hpp"
  75 # include "vmreg_arm.inline.hpp"
  76 #endif
  77 #ifdef TARGET_ARCH_ppc
  78 # include "nativeInst_ppc.hpp"
  79 # include "vmreg_ppc.inline.hpp"
  80 #endif
  81 #ifdef COMPILER1
  82 #include "c1/c1_Runtime1.hpp"
  83 #endif
  84 


 218 #endif // PRODUCT
 219 
 220 #if INCLUDE_ALL_GCS
 221 
 222 // G1 write-barrier pre: executed before a pointer store.
 223 JRT_LEAF(void, SharedRuntime::g1_wb_pre(oopDesc* orig, JavaThread *thread))
 224   if (orig == NULL) {
 225     assert(false, "should be optimized out");
 226     return;
 227   }
 228   assert(orig->is_oop(true /* ignore mark word */), "Error");
 229   // store the original value that was in the field reference
 230   thread->satb_mark_queue().enqueue(orig);
 231 JRT_END
 232 
 233 // G1 write-barrier post: executed after a pointer store.
 234 JRT_LEAF(void, SharedRuntime::g1_wb_post(void* card_addr, JavaThread* thread))
 235   thread->dirty_card_queue().enqueue(card_addr);
 236 JRT_END
 237 






 238 #endif // INCLUDE_ALL_GCS
 239 
 240 
 241 JRT_LEAF(jlong, SharedRuntime::lmul(jlong y, jlong x))
 242   return x * y;
 243 JRT_END
 244 
 245 
 246 JRT_LEAF(jlong, SharedRuntime::ldiv(jlong y, jlong x))
 247   if (x == min_jlong && y == CONST64(-1)) {
 248     return x;
 249   } else {
 250     return x / y;
 251   }
 252 JRT_END
 253 
 254 
 255 JRT_LEAF(jlong, SharedRuntime::lrem(jlong y, jlong x))
 256   if (x == min_jlong && y == CONST64(-1)) {
 257     return 0;


1865   _monitor_enter_ctr++;             // monitor enter slow
1866 #endif
1867   if (PrintBiasedLockingStatistics) {
1868     Atomic::inc(BiasedLocking::slow_path_entry_count_addr());
1869   }
1870   Handle h_obj(THREAD, obj);
1871   if (UseBiasedLocking) {
1872     // Retry fast entry if bias is revoked to avoid unnecessary inflation
1873     ObjectSynchronizer::fast_enter(h_obj, lock, true, CHECK);
1874   } else {
1875     ObjectSynchronizer::slow_enter(h_obj, lock, CHECK);
1876   }
1877   assert(!HAS_PENDING_EXCEPTION, "Should have no exception here");
1878 JRT_END
1879 
1880 #ifndef PRODUCT
1881 int SharedRuntime::_monitor_exit_ctr=0;
1882 #endif
1883 // Handles the uncommon cases of monitor unlocking in compiled code
1884 JRT_LEAF(void, SharedRuntime::complete_monitor_unlocking_C(oopDesc* _obj, BasicLock* lock))
1885    oop obj(_obj);
1886 #ifndef PRODUCT
1887   _monitor_exit_ctr++;              // monitor exit slow
1888 #endif
1889   Thread* THREAD = JavaThread::current();
1890   // I'm not convinced we need the code contained by MIGHT_HAVE_PENDING anymore
1891   // testing was unable to ever fire the assert that guarded it so I have removed it.
1892   assert(!HAS_PENDING_EXCEPTION, "Do we need code below anymore?");
1893 #undef MIGHT_HAVE_PENDING
1894 #ifdef MIGHT_HAVE_PENDING
1895   // Save and restore any pending_exception around the exception mark.
1896   // While the slow_exit must not throw an exception, we could come into
1897   // this routine with one set.
1898   oop pending_excep = NULL;
1899   const char* pending_file;
1900   int pending_line;
1901   if (HAS_PENDING_EXCEPTION) {
1902     pending_excep = PENDING_EXCEPTION;
1903     pending_file  = THREAD->exception_file();
1904     pending_line  = THREAD->exception_line();
1905     CLEAR_PENDING_EXCEPTION;


2802           new_in_regs[argcnt  ].set2(reg.first());
2803           new_in_regs[argcnt+1].set_bad();
2804           argcnt++;
2805           break;
2806         default:
2807           // No conversion needed.
2808           new_in_sig_bt[argcnt] = bt;
2809           new_in_regs[argcnt]   = reg;
2810           break;
2811       }
2812     }
2813     assert(argcnt == i2l_argcnt, "must match");
2814 
2815     in_regs = new_in_regs;
2816     in_sig_bt = new_in_sig_bt;
2817     in_args_count = i2l_argcnt;
2818   } else {
2819     assert(0, "This should not be needed on this platform");
2820   }
2821 }
















2822 
2823 // -------------------------------------------------------------------------
2824 // Java-Java calling convention
2825 // (what you use when Java calls Java)
2826 
2827 //------------------------------name_for_receiver----------------------------------
2828 // For a given signature, return the VMReg for parameter 0.
2829 VMReg SharedRuntime::name_for_receiver() {
2830   VMRegPair regs;
2831   BasicType sig_bt = T_OBJECT;
2832   (void) java_calling_convention(&sig_bt, &regs, 1, true);
2833   // Return argument 0 register.  In the LP64 build pointers
2834   // take 2 registers, but the VM wants only the 'main' name.
2835   return regs.first();
2836 }
2837 
2838 VMRegPair *SharedRuntime::find_callee_arguments(Symbol* sig, bool has_receiver, bool has_appendix, int* arg_size) {
2839   // This method is returning a data structure allocating as a
2840   // ResourceObject, so do not put any ResourceMarks in here.
2841   char *s = sig->as_C_string();




  45 #include "runtime/arguments.hpp"
  46 #include "runtime/biasedLocking.hpp"
  47 #include "runtime/handles.inline.hpp"
  48 #include "runtime/init.hpp"
  49 #include "runtime/interfaceSupport.hpp"
  50 #include "runtime/javaCalls.hpp"
  51 #include "runtime/sharedRuntime.hpp"
  52 #include "runtime/stubRoutines.hpp"
  53 #include "runtime/vframe.hpp"
  54 #include "runtime/vframeArray.hpp"
  55 #include "utilities/copy.hpp"
  56 #include "utilities/dtrace.hpp"
  57 #include "utilities/events.hpp"
  58 #include "utilities/hashtable.inline.hpp"
  59 #include "utilities/macros.hpp"
  60 #include "utilities/xmlstream.hpp"
  61 #ifdef TARGET_ARCH_x86
  62 # include "nativeInst_x86.hpp"
  63 # include "vmreg_x86.inline.hpp"
  64 #endif
  65 #ifdef TARGET_ARCH_aarch64
  66 # include "nativeInst_aarch64.hpp"
  67 # include "vmreg_aarch64.inline.hpp"
  68 #endif
  69 #ifdef TARGET_ARCH_sparc
  70 # include "nativeInst_sparc.hpp"
  71 # include "vmreg_sparc.inline.hpp"
  72 #endif
  73 #ifdef TARGET_ARCH_zero
  74 # include "nativeInst_zero.hpp"
  75 # include "vmreg_zero.inline.hpp"
  76 #endif
  77 #ifdef TARGET_ARCH_arm
  78 # include "nativeInst_arm.hpp"
  79 # include "vmreg_arm.inline.hpp"
  80 #endif
  81 #ifdef TARGET_ARCH_ppc
  82 # include "nativeInst_ppc.hpp"
  83 # include "vmreg_ppc.inline.hpp"
  84 #endif
  85 #ifdef COMPILER1
  86 #include "c1/c1_Runtime1.hpp"
  87 #endif
  88 


 222 #endif // PRODUCT
 223 
 224 #if INCLUDE_ALL_GCS
 225 
 226 // G1 write-barrier pre: executed before a pointer store.
 227 JRT_LEAF(void, SharedRuntime::g1_wb_pre(oopDesc* orig, JavaThread *thread))
 228   if (orig == NULL) {
 229     assert(false, "should be optimized out");
 230     return;
 231   }
 232   assert(orig->is_oop(true /* ignore mark word */), "Error");
 233   // store the original value that was in the field reference
 234   thread->satb_mark_queue().enqueue(orig);
 235 JRT_END
 236 
 237 // G1 write-barrier post: executed after a pointer store.
 238 JRT_LEAF(void, SharedRuntime::g1_wb_post(void* card_addr, JavaThread* thread))
 239   thread->dirty_card_queue().enqueue(card_addr);
 240 JRT_END
 241 
 242 // Shenandoah clone barrier: makes sure that references point to to-space
 243 // in cloned objects.
 244 JRT_LEAF(void, SharedRuntime::shenandoah_clone_barrier(oopDesc* obj))
 245   oopDesc::bs()->write_region(MemRegion((HeapWord*) obj, obj->size()));
 246 JRT_END
 247 
 248 #endif // INCLUDE_ALL_GCS
 249 
 250 
 251 JRT_LEAF(jlong, SharedRuntime::lmul(jlong y, jlong x))
 252   return x * y;
 253 JRT_END
 254 
 255 
 256 JRT_LEAF(jlong, SharedRuntime::ldiv(jlong y, jlong x))
 257   if (x == min_jlong && y == CONST64(-1)) {
 258     return x;
 259   } else {
 260     return x / y;
 261   }
 262 JRT_END
 263 
 264 
 265 JRT_LEAF(jlong, SharedRuntime::lrem(jlong y, jlong x))
 266   if (x == min_jlong && y == CONST64(-1)) {
 267     return 0;


1875   _monitor_enter_ctr++;             // monitor enter slow
1876 #endif
1877   if (PrintBiasedLockingStatistics) {
1878     Atomic::inc(BiasedLocking::slow_path_entry_count_addr());
1879   }
1880   Handle h_obj(THREAD, obj);
1881   if (UseBiasedLocking) {
1882     // Retry fast entry if bias is revoked to avoid unnecessary inflation
1883     ObjectSynchronizer::fast_enter(h_obj, lock, true, CHECK);
1884   } else {
1885     ObjectSynchronizer::slow_enter(h_obj, lock, CHECK);
1886   }
1887   assert(!HAS_PENDING_EXCEPTION, "Should have no exception here");
1888 JRT_END
1889 
1890 #ifndef PRODUCT
1891 int SharedRuntime::_monitor_exit_ctr=0;
1892 #endif
1893 // Handles the uncommon cases of monitor unlocking in compiled code
1894 JRT_LEAF(void, SharedRuntime::complete_monitor_unlocking_C(oopDesc* _obj, BasicLock* lock))
1895   oop obj(_obj);
1896 #ifndef PRODUCT
1897   _monitor_exit_ctr++;              // monitor exit slow
1898 #endif
1899   Thread* THREAD = JavaThread::current();
1900   // I'm not convinced we need the code contained by MIGHT_HAVE_PENDING anymore
1901   // testing was unable to ever fire the assert that guarded it so I have removed it.
1902   assert(!HAS_PENDING_EXCEPTION, "Do we need code below anymore?");
1903 #undef MIGHT_HAVE_PENDING
1904 #ifdef MIGHT_HAVE_PENDING
1905   // Save and restore any pending_exception around the exception mark.
1906   // While the slow_exit must not throw an exception, we could come into
1907   // this routine with one set.
1908   oop pending_excep = NULL;
1909   const char* pending_file;
1910   int pending_line;
1911   if (HAS_PENDING_EXCEPTION) {
1912     pending_excep = PENDING_EXCEPTION;
1913     pending_file  = THREAD->exception_file();
1914     pending_line  = THREAD->exception_line();
1915     CLEAR_PENDING_EXCEPTION;


2812           new_in_regs[argcnt  ].set2(reg.first());
2813           new_in_regs[argcnt+1].set_bad();
2814           argcnt++;
2815           break;
2816         default:
2817           // No conversion needed.
2818           new_in_sig_bt[argcnt] = bt;
2819           new_in_regs[argcnt]   = reg;
2820           break;
2821       }
2822     }
2823     assert(argcnt == i2l_argcnt, "must match");
2824 
2825     in_regs = new_in_regs;
2826     in_sig_bt = new_in_sig_bt;
2827     in_args_count = i2l_argcnt;
2828   } else {
2829     assert(0, "This should not be needed on this platform");
2830   }
2831 }
2832 
2833 JRT_LEAF(oopDesc*, SharedRuntime::pin_object(JavaThread* thread, oopDesc* obj))
2834   assert(Universe::heap()->supports_object_pinning(), "Why we here?");
2835   assert(obj != NULL, "Should not be null");
2836   oop o(obj);
2837   o = Universe::heap()->pin_object(thread, o);
2838   assert(o != NULL, "Should not be null");
2839   return o;
2840 JRT_END
2841 
2842 JRT_LEAF(void, SharedRuntime::unpin_object(JavaThread* thread, oopDesc* obj))
2843   assert(Universe::heap()->supports_object_pinning(), "Why we here?");
2844   assert(obj != NULL, "Should not be null");
2845   oop o(obj);
2846   Universe::heap()->unpin_object(thread, o);
2847 JRT_END
2848 
2849 // -------------------------------------------------------------------------
2850 // Java-Java calling convention
2851 // (what you use when Java calls Java)
2852 
2853 //------------------------------name_for_receiver----------------------------------
2854 // For a given signature, return the VMReg for parameter 0.
2855 VMReg SharedRuntime::name_for_receiver() {
2856   VMRegPair regs;
2857   BasicType sig_bt = T_OBJECT;
2858   (void) java_calling_convention(&sig_bt, &regs, 1, true);
2859   // Return argument 0 register.  In the LP64 build pointers
2860   // take 2 registers, but the VM wants only the 'main' name.
2861   return regs.first();
2862 }
2863 
2864 VMRegPair *SharedRuntime::find_callee_arguments(Symbol* sig, bool has_receiver, bool has_appendix, int* arg_size) {
2865   // This method is returning a data structure allocating as a
2866   // ResourceObject, so do not put any ResourceMarks in here.
2867   char *s = sig->as_C_string();


< prev index next >