src/hotspot/os/solaris/os_solaris.cpp
changeset 48005 9fd89aabb6cd
parent 47903 7f22774a5f42
child 48153 cfa2c43e58c2
equal deleted inserted replaced
48003:e1ec73e3325e 48005:9fd89aabb6cd
   198   assert((address)&st < (address)st.ss_sp, "Invalid stack base returned");
   198   assert((address)&st < (address)st.ss_sp, "Invalid stack base returned");
   199   assert((address)&st > (address)st.ss_sp-st.ss_size, "Invalid stack size returned");
   199   assert((address)&st > (address)st.ss_sp-st.ss_size, "Invalid stack size returned");
   200   return st;
   200   return st;
   201 }
   201 }
   202 
   202 
   203 address os::current_stack_base() {
   203 bool os::is_primordial_thread(void) {
   204   int r = thr_main();
   204   int r = thr_main();
   205   guarantee(r == 0 || r == 1, "CR6501650 or CR6493689");
   205   guarantee(r == 0 || r == 1, "CR6501650 or CR6493689");
   206   bool is_primordial_thread = r;
   206   return r == 1;
       
   207 }
       
   208 
       
   209 address os::current_stack_base() {
       
   210   bool _is_primordial_thread = is_primordial_thread();
   207 
   211 
   208   // Workaround 4352906, avoid calls to thr_stksegment by
   212   // Workaround 4352906, avoid calls to thr_stksegment by
   209   // thr_main after the first one (it looks like we trash
   213   // thr_main after the first one (it looks like we trash
   210   // some data, causing the value for ss_sp to be incorrect).
   214   // some data, causing the value for ss_sp to be incorrect).
   211   if (!is_primordial_thread || os::Solaris::_main_stack_base == NULL) {
   215   if (!_is_primordial_thread || os::Solaris::_main_stack_base == NULL) {
   212     stack_t st = get_stack_info();
   216     stack_t st = get_stack_info();
   213     if (is_primordial_thread) {
   217     if (_is_primordial_thread) {
   214       // cache initial value of stack base
   218       // cache initial value of stack base
   215       os::Solaris::_main_stack_base = (address)st.ss_sp;
   219       os::Solaris::_main_stack_base = (address)st.ss_sp;
   216     }
   220     }
   217     return (address)st.ss_sp;
   221     return (address)st.ss_sp;
   218   } else {
   222   } else {
   222 }
   226 }
   223 
   227 
   224 size_t os::current_stack_size() {
   228 size_t os::current_stack_size() {
   225   size_t size;
   229   size_t size;
   226 
   230 
   227   int r = thr_main();
   231   if (!is_primordial_thread()) {
   228   guarantee(r == 0 || r == 1, "CR6501650 or CR6493689");
       
   229   if (!r) {
       
   230     size = get_stack_info().ss_size;
   232     size = get_stack_info().ss_size;
   231   } else {
   233   } else {
   232     struct rlimit limits;
   234     struct rlimit limits;
   233     getrlimit(RLIMIT_STACK, &limits);
   235     getrlimit(RLIMIT_STACK, &limits);
   234     size = adjust_stack_size(os::Solaris::_main_stack_base, (size_t)limits.rlim_cur);
   236     size = adjust_stack_size(os::Solaris::_main_stack_base, (size_t)limits.rlim_cur);
  1100 }
  1102 }
  1101 
  1103 
  1102 
  1104 
  1103 // First crack at OS-specific initialization, from inside the new thread.
  1105 // First crack at OS-specific initialization, from inside the new thread.
  1104 void os::initialize_thread(Thread* thr) {
  1106 void os::initialize_thread(Thread* thr) {
  1105   int r = thr_main();
  1107   if (is_primordial_thread()) {
  1106   guarantee(r == 0 || r == 1, "CR6501650 or CR6493689");
       
  1107   if (r) {
       
  1108     JavaThread* jt = (JavaThread *)thr;
  1108     JavaThread* jt = (JavaThread *)thr;
  1109     assert(jt != NULL, "Sanity check");
  1109     assert(jt != NULL, "Sanity check");
  1110     size_t stack_size;
  1110     size_t stack_size;
  1111     address base = jt->stack_base();
  1111     address base = jt->stack_base();
  1112     if (Arguments::created_by_java_launcher()) {
  1112     if (Arguments::created_by_java_launcher()) {
  4201   void * hdl = dlopen("libdl.so", RTLD_NOW);
  4201   void * hdl = dlopen("libdl.so", RTLD_NOW);
  4202   if (hdl) {
  4202   if (hdl) {
  4203     dladdr1_func = CAST_TO_FN_PTR(dladdr1_func_type, dlsym(hdl, "dladdr1"));
  4203     dladdr1_func = CAST_TO_FN_PTR(dladdr1_func_type, dlsym(hdl, "dladdr1"));
  4204   }
  4204   }
  4205 
  4205 
       
  4206   // main_thread points to the thread that created/loaded the JVM.
  4206   main_thread = thr_self();
  4207   main_thread = thr_self();
  4207 
  4208 
  4208   // dynamic lookup of functions that may not be available in our lowest
  4209   // dynamic lookup of functions that may not be available in our lowest
  4209   // supported Solaris release
  4210   // supported Solaris release
  4210   void * handle = dlopen("libc.so.1", RTLD_LAZY);
  4211   void * handle = dlopen("libc.so.1", RTLD_LAZY);