src/share/vm/runtime/stubRoutines.hpp

Print this page
rev 4810 : 8016697: PPC64 (part 5): Use stubs to implement safefetch
Summary: Implement Safefetch as stub routines. This reduces compiler and os dependencies.
Reviewed-by: twisti, kvn


 204 
 205   static address _aescrypt_encryptBlock;
 206   static address _aescrypt_decryptBlock;
 207   static address _cipherBlockChaining_encryptAESCrypt;
 208   static address _cipherBlockChaining_decryptAESCrypt;
 209 
 210   // These are versions of the java.lang.Math methods which perform
 211   // the same operations as the intrinsic version.  They are used for
 212   // constant folding in the compiler to ensure equivalence.  If the
 213   // intrinsic version returns the same result as the strict version
 214   // then they can be set to the appropriate function from
 215   // SharedRuntime.
 216   static double (*_intrinsic_log)(double);
 217   static double (*_intrinsic_log10)(double);
 218   static double (*_intrinsic_exp)(double);
 219   static double (*_intrinsic_pow)(double, double);
 220   static double (*_intrinsic_sin)(double);
 221   static double (*_intrinsic_cos)(double);
 222   static double (*_intrinsic_tan)(double);
 223 








 224  public:
 225   // Initialization/Testing
 226   static void    initialize1();                            // must happen before universe::genesis
 227   static void    initialize2();                            // must happen after  universe::genesis
 228 
 229   static bool is_stub_code(address addr)                   { return contains(addr); }
 230 
 231   static bool contains(address addr) {
 232     return
 233       (_code1 != NULL && _code1->blob_contains(addr)) ||
 234       (_code2 != NULL && _code2->blob_contains(addr)) ;
 235   }
 236 
 237   static CodeBlob* code1() { return _code1; }
 238   static CodeBlob* code2() { return _code2; }
 239 
 240   // Debugging
 241   static jint    verify_oop_count()                        { return _verify_oop_count; }
 242   static jint*   verify_oop_count_addr()                   { return &_verify_oop_count; }
 243   // a subroutine for debugging the GC


 362     return _intrinsic_exp(d);
 363   }
 364   static double  intrinsic_pow(double d, double d2) {
 365     assert(_intrinsic_pow != NULL, "must be defined");
 366     return _intrinsic_pow(d, d2);
 367   }
 368   static double  intrinsic_sin(double d) {
 369     assert(_intrinsic_sin != NULL, "must be defined");
 370     return _intrinsic_sin(d);
 371   }
 372   static double  intrinsic_cos(double d) {
 373     assert(_intrinsic_cos != NULL, "must be defined");
 374     return _intrinsic_cos(d);
 375   }
 376   static double  intrinsic_tan(double d) {
 377     assert(_intrinsic_tan != NULL, "must be defined");
 378     return _intrinsic_tan(d);
 379   }
 380 
 381   //




























 382   // Default versions of the above arraycopy functions for platforms which do
 383   // not have specialized versions
 384   //
 385   static void jbyte_copy     (jbyte*  src, jbyte*  dest, size_t count);
 386   static void jshort_copy    (jshort* src, jshort* dest, size_t count);
 387   static void jint_copy      (jint*   src, jint*   dest, size_t count);
 388   static void jlong_copy     (jlong*  src, jlong*  dest, size_t count);
 389   static void oop_copy       (oop*    src, oop*    dest, size_t count);
 390   static void oop_copy_uninit(oop*    src, oop*    dest, size_t count);
 391 
 392   static void arrayof_jbyte_copy     (HeapWord* src, HeapWord* dest, size_t count);
 393   static void arrayof_jshort_copy    (HeapWord* src, HeapWord* dest, size_t count);
 394   static void arrayof_jint_copy      (HeapWord* src, HeapWord* dest, size_t count);
 395   static void arrayof_jlong_copy     (HeapWord* src, HeapWord* dest, size_t count);
 396   static void arrayof_oop_copy       (HeapWord* src, HeapWord* dest, size_t count);
 397   static void arrayof_oop_copy_uninit(HeapWord* src, HeapWord* dest, size_t count);
 398 };
 399 











 400 #endif // SHARE_VM_RUNTIME_STUBROUTINES_HPP


 204 
 205   static address _aescrypt_encryptBlock;
 206   static address _aescrypt_decryptBlock;
 207   static address _cipherBlockChaining_encryptAESCrypt;
 208   static address _cipherBlockChaining_decryptAESCrypt;
 209 
 210   // These are versions of the java.lang.Math methods which perform
 211   // the same operations as the intrinsic version.  They are used for
 212   // constant folding in the compiler to ensure equivalence.  If the
 213   // intrinsic version returns the same result as the strict version
 214   // then they can be set to the appropriate function from
 215   // SharedRuntime.
 216   static double (*_intrinsic_log)(double);
 217   static double (*_intrinsic_log10)(double);
 218   static double (*_intrinsic_exp)(double);
 219   static double (*_intrinsic_pow)(double, double);
 220   static double (*_intrinsic_sin)(double);
 221   static double (*_intrinsic_cos)(double);
 222   static double (*_intrinsic_tan)(double);
 223 
 224   // Safefetch stubs.
 225   static address _safefetch32_entry;
 226   static address _safefetch32_fault_pc;
 227   static address _safefetch32_continuation_pc;
 228   static address _safefetchN_entry;
 229   static address _safefetchN_fault_pc;
 230   static address _safefetchN_continuation_pc;
 231 
 232  public:
 233   // Initialization/Testing
 234   static void    initialize1();                            // must happen before universe::genesis
 235   static void    initialize2();                            // must happen after  universe::genesis
 236 
 237   static bool is_stub_code(address addr)                   { return contains(addr); }
 238 
 239   static bool contains(address addr) {
 240     return
 241       (_code1 != NULL && _code1->blob_contains(addr)) ||
 242       (_code2 != NULL && _code2->blob_contains(addr)) ;
 243   }
 244 
 245   static CodeBlob* code1() { return _code1; }
 246   static CodeBlob* code2() { return _code2; }
 247 
 248   // Debugging
 249   static jint    verify_oop_count()                        { return _verify_oop_count; }
 250   static jint*   verify_oop_count_addr()                   { return &_verify_oop_count; }
 251   // a subroutine for debugging the GC


 370     return _intrinsic_exp(d);
 371   }
 372   static double  intrinsic_pow(double d, double d2) {
 373     assert(_intrinsic_pow != NULL, "must be defined");
 374     return _intrinsic_pow(d, d2);
 375   }
 376   static double  intrinsic_sin(double d) {
 377     assert(_intrinsic_sin != NULL, "must be defined");
 378     return _intrinsic_sin(d);
 379   }
 380   static double  intrinsic_cos(double d) {
 381     assert(_intrinsic_cos != NULL, "must be defined");
 382     return _intrinsic_cos(d);
 383   }
 384   static double  intrinsic_tan(double d) {
 385     assert(_intrinsic_tan != NULL, "must be defined");
 386     return _intrinsic_tan(d);
 387   }
 388 
 389   //
 390   // Safefetch stub support
 391   //
 392 
 393   typedef int      (*SafeFetch32Stub)(int*      adr, int      errValue);
 394   typedef intptr_t (*SafeFetchNStub) (intptr_t* adr, intptr_t errValue);
 395 
 396   static SafeFetch32Stub SafeFetch32_stub() { return CAST_TO_FN_PTR(SafeFetch32Stub, _safefetch32_entry); }
 397   static SafeFetchNStub  SafeFetchN_stub()  { return CAST_TO_FN_PTR(SafeFetchNStub,  _safefetchN_entry); }
 398 
 399   static bool is_safefetch_fault(address pc) {
 400     return pc != NULL &&
 401           (pc == _safefetch32_fault_pc ||
 402            pc == _safefetchN_fault_pc);
 403   }
 404 
 405   static address continuation_for_safefetch_fault(address pc) {
 406     assert(_safefetch32_continuation_pc != NULL &&
 407            _safefetchN_continuation_pc  != NULL,
 408            "not initialized");
 409 
 410     if (pc == _safefetch32_fault_pc) return _safefetch32_continuation_pc;
 411     if (pc == _safefetchN_fault_pc)  return _safefetchN_continuation_pc;
 412 
 413     ShouldNotReachHere();
 414     return NULL;
 415   }
 416 
 417   //
 418   // Default versions of the above arraycopy functions for platforms which do
 419   // not have specialized versions
 420   //
 421   static void jbyte_copy     (jbyte*  src, jbyte*  dest, size_t count);
 422   static void jshort_copy    (jshort* src, jshort* dest, size_t count);
 423   static void jint_copy      (jint*   src, jint*   dest, size_t count);
 424   static void jlong_copy     (jlong*  src, jlong*  dest, size_t count);
 425   static void oop_copy       (oop*    src, oop*    dest, size_t count);
 426   static void oop_copy_uninit(oop*    src, oop*    dest, size_t count);
 427 
 428   static void arrayof_jbyte_copy     (HeapWord* src, HeapWord* dest, size_t count);
 429   static void arrayof_jshort_copy    (HeapWord* src, HeapWord* dest, size_t count);
 430   static void arrayof_jint_copy      (HeapWord* src, HeapWord* dest, size_t count);
 431   static void arrayof_jlong_copy     (HeapWord* src, HeapWord* dest, size_t count);
 432   static void arrayof_oop_copy       (HeapWord* src, HeapWord* dest, size_t count);
 433   static void arrayof_oop_copy_uninit(HeapWord* src, HeapWord* dest, size_t count);
 434 };
 435 
 436 // Safefetch allows to load a value from a location that's not known
 437 // to be valid. If the load causes a fault, the error value is returned.
 438 inline int SafeFetch32(int* adr, int errValue) {
 439   assert(StubRoutines::SafeFetch32_stub(), "stub not yet generated");
 440   return StubRoutines::SafeFetch32_stub()(adr, errValue);
 441 }
 442 inline intptr_t SafeFetchN(intptr_t* adr, intptr_t errValue) {
 443   assert(StubRoutines::SafeFetchN_stub(), "stub not yet generated");
 444   return StubRoutines::SafeFetchN_stub()(adr, errValue);
 445 }
 446 
 447 #endif // SHARE_VM_RUNTIME_STUBROUTINES_HPP