comparison src/share/vm/runtime/stubRoutines.hpp @ 11127:980532a806a5

8016697: Use stubs to implement safefetch Summary: Implement Safefetch as stub routines. This reduces compiler and os dependencies. Reviewed-by: twisti, kvn
author goetz
date Thu, 20 Jun 2013 15:02:05 +0200
parents b800986664f4
children 6b0fd0964b87 94c202aa2646
comparison
equal deleted inserted replaced
11088:ea4d24c1e0c6 11127:980532a806a5
219 static double (*_intrinsic_pow)(double, double); 219 static double (*_intrinsic_pow)(double, double);
220 static double (*_intrinsic_sin)(double); 220 static double (*_intrinsic_sin)(double);
221 static double (*_intrinsic_cos)(double); 221 static double (*_intrinsic_cos)(double);
222 static double (*_intrinsic_tan)(double); 222 static double (*_intrinsic_tan)(double);
223 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
224 public: 232 public:
225 // Initialization/Testing 233 // Initialization/Testing
226 static void initialize1(); // must happen before universe::genesis 234 static void initialize1(); // must happen before universe::genesis
227 static void initialize2(); // must happen after universe::genesis 235 static void initialize2(); // must happen after universe::genesis
228 236
380 assert(_intrinsic_tan != NULL, "must be defined"); 388 assert(_intrinsic_tan != NULL, "must be defined");
381 return _intrinsic_tan(d); 389 return _intrinsic_tan(d);
382 } 390 }
383 391
384 // 392 //
393 // Safefetch stub support
394 //
395
396 typedef int (*SafeFetch32Stub)(int* adr, int errValue);
397 typedef intptr_t (*SafeFetchNStub) (intptr_t* adr, intptr_t errValue);
398
399 static SafeFetch32Stub SafeFetch32_stub() { return CAST_TO_FN_PTR(SafeFetch32Stub, _safefetch32_entry); }
400 static SafeFetchNStub SafeFetchN_stub() { return CAST_TO_FN_PTR(SafeFetchNStub, _safefetchN_entry); }
401
402 static bool is_safefetch_fault(address pc) {
403 return pc != NULL &&
404 (pc == _safefetch32_fault_pc ||
405 pc == _safefetchN_fault_pc);
406 }
407
408 static address continuation_for_safefetch_fault(address pc) {
409 assert(_safefetch32_continuation_pc != NULL &&
410 _safefetchN_continuation_pc != NULL,
411 "not initialized");
412
413 if (pc == _safefetch32_fault_pc) return _safefetch32_continuation_pc;
414 if (pc == _safefetchN_fault_pc) return _safefetchN_continuation_pc;
415
416 ShouldNotReachHere();
417 return NULL;
418 }
419
420 //
385 // Default versions of the above arraycopy functions for platforms which do 421 // Default versions of the above arraycopy functions for platforms which do
386 // not have specialized versions 422 // not have specialized versions
387 // 423 //
388 static void jbyte_copy (jbyte* src, jbyte* dest, size_t count); 424 static void jbyte_copy (jbyte* src, jbyte* dest, size_t count);
389 static void jshort_copy (jshort* src, jshort* dest, size_t count); 425 static void jshort_copy (jshort* src, jshort* dest, size_t count);
398 static void arrayof_jlong_copy (HeapWord* src, HeapWord* dest, size_t count); 434 static void arrayof_jlong_copy (HeapWord* src, HeapWord* dest, size_t count);
399 static void arrayof_oop_copy (HeapWord* src, HeapWord* dest, size_t count); 435 static void arrayof_oop_copy (HeapWord* src, HeapWord* dest, size_t count);
400 static void arrayof_oop_copy_uninit(HeapWord* src, HeapWord* dest, size_t count); 436 static void arrayof_oop_copy_uninit(HeapWord* src, HeapWord* dest, size_t count);
401 }; 437 };
402 438
439 // Safefetch allows to load a value from a location that's not known
440 // to be valid. If the load causes a fault, the error value is returned.
441 inline int SafeFetch32(int* adr, int errValue) {
442 assert(StubRoutines::SafeFetch32_stub(), "stub not yet generated");
443 return StubRoutines::SafeFetch32_stub()(adr, errValue);
444 }
445 inline intptr_t SafeFetchN(intptr_t* adr, intptr_t errValue) {
446 assert(StubRoutines::SafeFetchN_stub(), "stub not yet generated");
447 return StubRoutines::SafeFetchN_stub()(adr, errValue);
448 }
449
403 #endif // SHARE_VM_RUNTIME_STUBROUTINES_HPP 450 #endif // SHARE_VM_RUNTIME_STUBROUTINES_HPP