< prev index next >

src/hotspot/share/runtime/os.cpp

Print this page




1007   int elsecs = (eltime - day_secs - hour_secs - minute_secs);
1008   st->print_cr(" elapsed time: %d seconds (%dd %dh %dm %ds)", eltime, eldays, elhours, elmins, elsecs);
1009 }
1010 
1011 
1012 // Check if pointer can be read from (4-byte read access).
1013 // Helps to prove validity of a not-NULL pointer.
1014 // Returns true in very early stages of VM life when stub is not yet generated.
1015 #define SAFEFETCH_DEFAULT true
1016 bool os::is_readable_pointer(const void* p) {
1017   if (!CanUseSafeFetch32()) {
1018     return SAFEFETCH_DEFAULT;
1019   }
1020   int* const aligned = (int*) align_down((intptr_t)p, 4);
1021   int cafebabe = 0xcafebabe;  // tester value 1
1022   int deadbeef = 0xdeadbeef;  // tester value 2
1023   return (SafeFetch32(aligned, cafebabe) != cafebabe) || (SafeFetch32(aligned, deadbeef) != deadbeef);
1024 }
1025 
1026 bool os::is_readable_range(const void* from, const void* to) {
1027   if ((uintptr_t)from >= (uintptr_t)to) return false;
1028   for (uintptr_t p = align_down((uintptr_t)from, min_page_size()); p < (uintptr_t)to; p += min_page_size()) {
1029     if (!is_readable_pointer((const void*)p)) {
1030       return false;
1031     }
1032   }
1033   return true;
1034 }
1035 
1036 
1037 // moved from debug.cpp (used to be find()) but still called from there
1038 // The verbose parameter is only set by the debug code in one case
1039 void os::print_location(outputStream* st, intptr_t x, bool verbose) {
1040   address addr = (address)x;
1041   // Handle NULL first, so later checks don't need to protect against it.
1042   if (addr == NULL) {
1043     st->print_cr("0x0 is NULL");
1044     return;
1045   }
1046 
1047   // Check if addr points into a code blob.
1048   CodeBlob* b = CodeCache::find_blob_unsafe(addr);
1049   if (b != NULL) {




1007   int elsecs = (eltime - day_secs - hour_secs - minute_secs);
1008   st->print_cr(" elapsed time: %d seconds (%dd %dh %dm %ds)", eltime, eldays, elhours, elmins, elsecs);
1009 }
1010 
1011 
1012 // Check if pointer can be read from (4-byte read access).
1013 // Helps to prove validity of a not-NULL pointer.
1014 // Returns true in very early stages of VM life when stub is not yet generated.
1015 #define SAFEFETCH_DEFAULT true
1016 bool os::is_readable_pointer(const void* p) {
1017   if (!CanUseSafeFetch32()) {
1018     return SAFEFETCH_DEFAULT;
1019   }
1020   int* const aligned = (int*) align_down((intptr_t)p, 4);
1021   int cafebabe = 0xcafebabe;  // tester value 1
1022   int deadbeef = 0xdeadbeef;  // tester value 2
1023   return (SafeFetch32(aligned, cafebabe) != cafebabe) || (SafeFetch32(aligned, deadbeef) != deadbeef);
1024 }
1025 
1026 bool os::is_readable_range(const void* from, const void* to) {
1027   for (address p = align_down((address)from, min_page_size()); p < to; p += min_page_size()) {
1028     if (!is_readable_pointer(p)) {

1029       return false;
1030     }
1031   }
1032   return true;
1033 }
1034 
1035 
1036 // moved from debug.cpp (used to be find()) but still called from there
1037 // The verbose parameter is only set by the debug code in one case
1038 void os::print_location(outputStream* st, intptr_t x, bool verbose) {
1039   address addr = (address)x;
1040   // Handle NULL first, so later checks don't need to protect against it.
1041   if (addr == NULL) {
1042     st->print_cr("0x0 is NULL");
1043     return;
1044   }
1045 
1046   // Check if addr points into a code blob.
1047   CodeBlob* b = CodeCache::find_blob_unsafe(addr);
1048   if (b != NULL) {


< prev index next >