src/share/vm/runtime/stubRoutines.hpp

changeset 5400
980532a806a5
parent 5353
b800986664f4
child 6457
94c202aa2646
     1.1 --- a/src/share/vm/runtime/stubRoutines.hpp	Thu Jul 04 14:56:49 2013 -0700
     1.2 +++ b/src/share/vm/runtime/stubRoutines.hpp	Thu Jun 20 15:02:05 2013 +0200
     1.3 @@ -221,6 +221,14 @@
     1.4    static double (*_intrinsic_cos)(double);
     1.5    static double (*_intrinsic_tan)(double);
     1.6  
     1.7 +  // Safefetch stubs.
     1.8 +  static address _safefetch32_entry;
     1.9 +  static address _safefetch32_fault_pc;
    1.10 +  static address _safefetch32_continuation_pc;
    1.11 +  static address _safefetchN_entry;
    1.12 +  static address _safefetchN_fault_pc;
    1.13 +  static address _safefetchN_continuation_pc;
    1.14 +
    1.15   public:
    1.16    // Initialization/Testing
    1.17    static void    initialize1();                            // must happen before universe::genesis
    1.18 @@ -382,6 +390,34 @@
    1.19    }
    1.20  
    1.21    //
    1.22 +  // Safefetch stub support
    1.23 +  //
    1.24 +
    1.25 +  typedef int      (*SafeFetch32Stub)(int*      adr, int      errValue);
    1.26 +  typedef intptr_t (*SafeFetchNStub) (intptr_t* adr, intptr_t errValue);
    1.27 +
    1.28 +  static SafeFetch32Stub SafeFetch32_stub() { return CAST_TO_FN_PTR(SafeFetch32Stub, _safefetch32_entry); }
    1.29 +  static SafeFetchNStub  SafeFetchN_stub()  { return CAST_TO_FN_PTR(SafeFetchNStub,  _safefetchN_entry); }
    1.30 +
    1.31 +  static bool is_safefetch_fault(address pc) {
    1.32 +    return pc != NULL &&
    1.33 +          (pc == _safefetch32_fault_pc ||
    1.34 +           pc == _safefetchN_fault_pc);
    1.35 +  }
    1.36 +
    1.37 +  static address continuation_for_safefetch_fault(address pc) {
    1.38 +    assert(_safefetch32_continuation_pc != NULL &&
    1.39 +           _safefetchN_continuation_pc  != NULL,
    1.40 +           "not initialized");
    1.41 +
    1.42 +    if (pc == _safefetch32_fault_pc) return _safefetch32_continuation_pc;
    1.43 +    if (pc == _safefetchN_fault_pc)  return _safefetchN_continuation_pc;
    1.44 +
    1.45 +    ShouldNotReachHere();
    1.46 +    return NULL;
    1.47 +  }
    1.48 +
    1.49 +  //
    1.50    // Default versions of the above arraycopy functions for platforms which do
    1.51    // not have specialized versions
    1.52    //
    1.53 @@ -400,4 +436,15 @@
    1.54    static void arrayof_oop_copy_uninit(HeapWord* src, HeapWord* dest, size_t count);
    1.55  };
    1.56  
    1.57 +// Safefetch allows to load a value from a location that's not known
    1.58 +// to be valid. If the load causes a fault, the error value is returned.
    1.59 +inline int SafeFetch32(int* adr, int errValue) {
    1.60 +  assert(StubRoutines::SafeFetch32_stub(), "stub not yet generated");
    1.61 +  return StubRoutines::SafeFetch32_stub()(adr, errValue);
    1.62 +}
    1.63 +inline intptr_t SafeFetchN(intptr_t* adr, intptr_t errValue) {
    1.64 +  assert(StubRoutines::SafeFetchN_stub(), "stub not yet generated");
    1.65 +  return StubRoutines::SafeFetchN_stub()(adr, errValue);
    1.66 +}
    1.67 +
    1.68  #endif // SHARE_VM_RUNTIME_STUBROUTINES_HPP

mercurial