src/os_cpu/bsd_zero/vm/os_bsd_zero.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File 8022956 Sdiff src/os_cpu/bsd_zero/vm

src/os_cpu/bsd_zero/vm/os_bsd_zero.cpp

Print this page




  49 #include "runtime/frame.inline.hpp"
  50 #include "runtime/interfaceSupport.hpp"
  51 #include "runtime/java.hpp"
  52 #include "runtime/javaCalls.hpp"
  53 #include "runtime/mutexLocker.hpp"
  54 #include "runtime/osThread.hpp"
  55 #include "runtime/sharedRuntime.hpp"
  56 #include "runtime/stubRoutines.hpp"
  57 #include "runtime/thread.inline.hpp"
  58 #include "runtime/timer.hpp"
  59 #include "utilities/events.hpp"
  60 #include "utilities/vmError.hpp"
  61 
  62 address os::current_stack_pointer() {
  63   address dummy = (address) &dummy;
  64   return dummy;
  65 }
  66 
  67 frame os::get_sender_for_C_frame(frame* fr) {
  68   ShouldNotCallThis();

  69 }
  70 
  71 frame os::current_frame() {
  72   // The only thing that calls this is the stack printing code in
  73   // VMError::report:
  74   //   - Step 110 (printing stack bounds) uses the sp in the frame
  75   //     to determine the amount of free space on the stack.  We
  76   //     set the sp to a close approximation of the real value in
  77   //     order to allow this step to complete.
  78   //   - Step 120 (printing native stack) tries to walk the stack.
  79   //     The frame we create has a NULL pc, which is ignored as an
  80   //     invalid frame.
  81   frame dummy = frame();
  82   dummy.set_sp((intptr_t *) current_stack_pointer());
  83   return dummy;
  84 }
  85 
  86 char* os::non_memory_address_word() {
  87   // Must never look like an address returned by reserve_memory,
  88   // even in its subfields (as defined by the CPU immediate fields,
  89   // if the CPU splits constants across multiple instructions).
  90 #ifdef SPARC
  91   // On SPARC, 0 != %hi(any real address), because there is no
  92   // allocation in the first 1Kb of the virtual address space.
  93   return (char *) 0;
  94 #else
  95   // This is the value for x86; works pretty well for PPC too.
  96   return (char *) -1;
  97 #endif // SPARC
  98 }
  99 
 100 void os::initialize_thread(Thread* thr) {
 101   // Nothing to do.
 102 }
 103 
 104 address os::Bsd::ucontext_get_pc(ucontext_t* uc) {
 105   ShouldNotCallThis();

 106 }
 107 
 108 ExtendedPC os::fetch_frame_from_context(void* ucVoid,
 109                                         intptr_t** ret_sp,
 110                                         intptr_t** ret_fp) {
 111   ShouldNotCallThis();

 112 }
 113 
 114 frame os::fetch_frame_from_context(void* ucVoid) {
 115   ShouldNotCallThis();

 116 }
 117 
 118 extern "C" JNIEXPORT int
 119 JVM_handle_bsd_signal(int sig,
 120                         siginfo_t* info,
 121                         void* ucVoid,
 122                         int abort_if_unrecognized) {
 123   ucontext_t* uc = (ucontext_t*) ucVoid;
 124 
 125   Thread* t = ThreadLocalStorage::get_thread_slow();
 126 
 127   SignalHandlerMark shm(t);
 128 
 129   // Note: it's not uncommon that JNI code uses signal/sigset to
 130   // install then restore certain signal handler (e.g. to temporarily
 131   // block SIGPIPE, or have a SIGILL handler when detecting CPU
 132   // type). When that happens, JVM_handle_bsd_signal() might be
 133   // invoked with junk info/ucVoid. To avoid unnecessary crash when
 134   // libjsig is not preloaded, try handle signals that do not require
 135   // siginfo/ucontext first.


 223 #ifndef PRODUCT
 224   if (sig == SIGSEGV) {
 225     fatal("\n#"
 226           "\n#    /--------------------\\"
 227           "\n#    | segmentation fault |"
 228           "\n#    \\---\\ /--------------/"
 229           "\n#        /"
 230           "\n#    [-]        |\\_/|    "
 231           "\n#    (+)=C      |o o|__  "
 232           "\n#    | |        =-*-=__\\ "
 233           "\n#    OOO        c_c_(___)");
 234   }
 235 #endif // !PRODUCT
 236 
 237   const char *fmt =
 238       "caught unhandled signal " INT32_FORMAT " at address " PTR_FORMAT;
 239   char buf[128];
 240 
 241   sprintf(buf, fmt, sig, info->si_addr);
 242   fatal(buf);

 243 }
 244 
 245 void os::Bsd::init_thread_fpu_state(void) {
 246   // Nothing to do
 247 }
 248 
 249 bool os::is_allocatable(size_t bytes) {
 250 #ifdef _LP64
 251   return true;
 252 #else
 253   if (bytes < 2 * G) {
 254     return true;
 255   }
 256 
 257   char* addr = reserve_memory(bytes, NULL);
 258 
 259   if (addr != NULL) {
 260     release_memory(addr, bytes);
 261   }
 262 


 356   return size;
 357 }
 358 
 359 /////////////////////////////////////////////////////////////////////////////
 360 // helper functions for fatal error handler
 361 
 362 void os::print_context(outputStream* st, void* context) {
 363   ShouldNotCallThis();
 364 }
 365 
 366 void os::print_register_info(outputStream *st, void *context) {
 367   ShouldNotCallThis();
 368 }
 369 
 370 /////////////////////////////////////////////////////////////////////////////
 371 // Stubs for things that would be in bsd_zero.s if it existed.
 372 // You probably want to disassemble these monkeys to check they're ok.
 373 
 374 extern "C" {
 375   int SpinPause() {
 376   }
 377 
 378   int SafeFetch32(int *adr, int errValue) {
 379     int value = errValue;
 380     value = *adr;
 381     return value;
 382   }
 383   intptr_t SafeFetchN(intptr_t *adr, intptr_t errValue) {
 384     intptr_t value = errValue;
 385     value = *adr;
 386     return value;
 387   }
 388 
 389   void _Copy_conjoint_jshorts_atomic(jshort* from, jshort* to, size_t count) {
 390     if (from > to) {
 391       jshort *end = from + count;
 392       while (from < end)
 393         *(to++) = *(from++);
 394     }
 395     else if (from < to) {
 396       jshort *end = from;
 397       from += count - 1;
 398       to   += count - 1;
 399       while (from >= end)
 400         *(to--) = *(from--);
 401     }
 402   }
 403   void _Copy_conjoint_jints_atomic(jint* from, jint* to, size_t count) {
 404     if (from > to) {
 405       jint *end = from + count;
 406       while (from < end)




  49 #include "runtime/frame.inline.hpp"
  50 #include "runtime/interfaceSupport.hpp"
  51 #include "runtime/java.hpp"
  52 #include "runtime/javaCalls.hpp"
  53 #include "runtime/mutexLocker.hpp"
  54 #include "runtime/osThread.hpp"
  55 #include "runtime/sharedRuntime.hpp"
  56 #include "runtime/stubRoutines.hpp"
  57 #include "runtime/thread.inline.hpp"
  58 #include "runtime/timer.hpp"
  59 #include "utilities/events.hpp"
  60 #include "utilities/vmError.hpp"
  61 
  62 address os::current_stack_pointer() {
  63   address dummy = (address) &dummy;
  64   return dummy;
  65 }
  66 
  67 frame os::get_sender_for_C_frame(frame* fr) {
  68   ShouldNotCallThis();
  69   return frame();
  70 }
  71 
  72 frame os::current_frame() {
  73   // The only thing that calls this is the stack printing code in
  74   // VMError::report:
  75   //   - Step 110 (printing stack bounds) uses the sp in the frame
  76   //     to determine the amount of free space on the stack.  We
  77   //     set the sp to a close approximation of the real value in
  78   //     order to allow this step to complete.
  79   //   - Step 120 (printing native stack) tries to walk the stack.
  80   //     The frame we create has a NULL pc, which is ignored as an
  81   //     invalid frame.
  82   frame dummy = frame();
  83   dummy.set_sp((intptr_t *) current_stack_pointer());
  84   return dummy;
  85 }
  86 
  87 char* os::non_memory_address_word() {
  88   // Must never look like an address returned by reserve_memory,
  89   // even in its subfields (as defined by the CPU immediate fields,
  90   // if the CPU splits constants across multiple instructions).
  91 #ifdef SPARC
  92   // On SPARC, 0 != %hi(any real address), because there is no
  93   // allocation in the first 1Kb of the virtual address space.
  94   return (char *) 0;
  95 #else
  96   // This is the value for x86; works pretty well for PPC too.
  97   return (char *) -1;
  98 #endif // SPARC
  99 }
 100 
 101 void os::initialize_thread(Thread* thr) {
 102   // Nothing to do.
 103 }
 104 
 105 address os::Bsd::ucontext_get_pc(ucontext_t* uc) {
 106   ShouldNotCallThis();
 107   return NULL;
 108 }
 109 
 110 ExtendedPC os::fetch_frame_from_context(void* ucVoid,
 111                                         intptr_t** ret_sp,
 112                                         intptr_t** ret_fp) {
 113   ShouldNotCallThis();
 114   return ExtendedPC();
 115 }
 116 
 117 frame os::fetch_frame_from_context(void* ucVoid) {
 118   ShouldNotCallThis();
 119   return frame();
 120 }
 121 
 122 extern "C" JNIEXPORT int
 123 JVM_handle_bsd_signal(int sig,
 124                         siginfo_t* info,
 125                         void* ucVoid,
 126                         int abort_if_unrecognized) {
 127   ucontext_t* uc = (ucontext_t*) ucVoid;
 128 
 129   Thread* t = ThreadLocalStorage::get_thread_slow();
 130 
 131   SignalHandlerMark shm(t);
 132 
 133   // Note: it's not uncommon that JNI code uses signal/sigset to
 134   // install then restore certain signal handler (e.g. to temporarily
 135   // block SIGPIPE, or have a SIGILL handler when detecting CPU
 136   // type). When that happens, JVM_handle_bsd_signal() might be
 137   // invoked with junk info/ucVoid. To avoid unnecessary crash when
 138   // libjsig is not preloaded, try handle signals that do not require
 139   // siginfo/ucontext first.


 227 #ifndef PRODUCT
 228   if (sig == SIGSEGV) {
 229     fatal("\n#"
 230           "\n#    /--------------------\\"
 231           "\n#    | segmentation fault |"
 232           "\n#    \\---\\ /--------------/"
 233           "\n#        /"
 234           "\n#    [-]        |\\_/|    "
 235           "\n#    (+)=C      |o o|__  "
 236           "\n#    | |        =-*-=__\\ "
 237           "\n#    OOO        c_c_(___)");
 238   }
 239 #endif // !PRODUCT
 240 
 241   const char *fmt =
 242       "caught unhandled signal " INT32_FORMAT " at address " PTR_FORMAT;
 243   char buf[128];
 244 
 245   sprintf(buf, fmt, sig, info->si_addr);
 246   fatal(buf);
 247   return false;
 248 }
 249 
 250 void os::Bsd::init_thread_fpu_state(void) {
 251   // Nothing to do
 252 }
 253 
 254 bool os::is_allocatable(size_t bytes) {
 255 #ifdef _LP64
 256   return true;
 257 #else
 258   if (bytes < 2 * G) {
 259     return true;
 260   }
 261 
 262   char* addr = reserve_memory(bytes, NULL);
 263 
 264   if (addr != NULL) {
 265     release_memory(addr, bytes);
 266   }
 267 


 361   return size;
 362 }
 363 
 364 /////////////////////////////////////////////////////////////////////////////
 365 // helper functions for fatal error handler
 366 
 367 void os::print_context(outputStream* st, void* context) {
 368   ShouldNotCallThis();
 369 }
 370 
 371 void os::print_register_info(outputStream *st, void *context) {
 372   ShouldNotCallThis();
 373 }
 374 
 375 /////////////////////////////////////////////////////////////////////////////
 376 // Stubs for things that would be in bsd_zero.s if it existed.
 377 // You probably want to disassemble these monkeys to check they're ok.
 378 
 379 extern "C" {
 380   int SpinPause() {
 381     return 1;










 382   }
 383 
 384   void _Copy_conjoint_jshorts_atomic(jshort* from, jshort* to, size_t count) {
 385     if (from > to) {
 386       jshort *end = from + count;
 387       while (from < end)
 388         *(to++) = *(from++);
 389     }
 390     else if (from < to) {
 391       jshort *end = from;
 392       from += count - 1;
 393       to   += count - 1;
 394       while (from >= end)
 395         *(to--) = *(from--);
 396     }
 397   }
 398   void _Copy_conjoint_jints_atomic(jint* from, jint* to, size_t count) {
 399     if (from > to) {
 400       jint *end = from + count;
 401       while (from < end)


src/os_cpu/bsd_zero/vm/os_bsd_zero.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File