src/os/linux/vm/os_linux.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File warning2 Sdiff src/os/linux/vm

src/os/linux/vm/os_linux.cpp

Print this page
rev 3821 : [mq]: unused


 175   // Constructor
 176   MemNotifyThread(int fd);
 177 
 178   // Tester
 179   bool is_memnotify_thread() const { return true; }
 180 
 181   // Printing
 182   char* name() const { return (char*)"Linux MemNotify Thread"; }
 183 
 184   // Returns the single instance of the MemNotifyThread
 185   static MemNotifyThread* memnotify_thread() { return _memnotify_thread; }
 186 
 187   // Create and start the single instance of MemNotifyThread
 188   static void start();
 189 };
 190 #endif // JAVASE_EMBEDDED
 191 
 192 // utility functions
 193 
 194 static int SR_initialize();
 195 static int SR_finalize();
 196 
 197 julong os::available_memory() {
 198   return Linux::available_memory();
 199 }
 200 
 201 julong os::Linux::available_memory() {
 202   // values in struct sysinfo are "unsigned long"
 203   struct sysinfo si;
 204   sysinfo(&si);
 205 
 206   return (julong)si.freeram * si.mem_unit;
 207 }
 208 
 209 julong os::physical_memory() {
 210   return Linux::physical_memory();
 211 }
 212 
 213 julong os::allocatable_physical_memory(julong size) {
 214 #ifdef _LP64
 215   return size;


3538   /* Set up signal handler for suspend/resume */
3539   act.sa_flags = SA_RESTART|SA_SIGINFO;
3540   act.sa_handler = (void (*)(int)) SR_handler;
3541 
3542   // SR_signum is blocked by default.
3543   // 4528190 - We also need to block pthread restart signal (32 on all
3544   // supported Linux platforms). Note that LinuxThreads need to block
3545   // this signal for all threads to work properly. So we don't have
3546   // to use hard-coded signal number when setting up the mask.
3547   pthread_sigmask(SIG_BLOCK, NULL, &act.sa_mask);
3548 
3549   if (sigaction(SR_signum, &act, 0) == -1) {
3550     return -1;
3551   }
3552 
3553   // Save signal flag
3554   os::Linux::set_our_sigflags(SR_signum, act.sa_flags);
3555   return 0;
3556 }
3557 
3558 static int SR_finalize() {
3559   return 0;
3560 }
3561 
3562 
3563 // returns true on success and false on error - really an error is fatal
3564 // but this seems the normal response to library errors
3565 static bool do_suspend(OSThread* osthread) {
3566   // mark as suspended and send signal
3567   osthread->sr.set_suspend_action(SR_SUSPEND);
3568   int status = pthread_kill(osthread->pthread_id(), SR_signum);
3569   assert_status(status == 0, status, "pthread_kill");
3570 
3571   // check status and wait until notified of suspension
3572   if (status == 0) {
3573     for (int i = 0; !osthread->sr.is_suspended(); i++) {
3574       os::yield_all(i);
3575     }
3576     osthread->sr.set_suspend_action(SR_NONE);
3577     return true;
3578   }
3579   else {
3580     osthread->sr.set_suspend_action(SR_NONE);
3581     return false;


4385    if (is_NPTL()) {
4386       return pthread_cond_timedwait(_cond, _mutex, _abstime);
4387    } else {
4388 #ifndef IA64
4389       // 6292965: LinuxThreads pthread_cond_timedwait() resets FPU control
4390       // word back to default 64bit precision if condvar is signaled. Java
4391       // wants 53bit precision.  Save and restore current value.
4392       int fpu = get_fpu_control_word();
4393 #endif // IA64
4394       int status = pthread_cond_timedwait(_cond, _mutex, _abstime);
4395 #ifndef IA64
4396       set_fpu_control_word(fpu);
4397 #endif // IA64
4398       return status;
4399    }
4400 }
4401 
4402 ////////////////////////////////////////////////////////////////////////////////
4403 // debug support
4404 
4405 static address same_page(address x, address y) {
4406   int page_bits = -os::vm_page_size();
4407   if ((intptr_t(x) & page_bits) == (intptr_t(y) & page_bits))
4408     return x;
4409   else if (x > y)
4410     return (address)(intptr_t(y) | ~page_bits) + 1;
4411   else
4412     return (address)(intptr_t(y) & page_bits);
4413 }
4414 
4415 bool os::find(address addr, outputStream* st) {
4416   Dl_info dlinfo;
4417   memset(&dlinfo, 0, sizeof(dlinfo));
4418   if (dladdr(addr, &dlinfo)) {
4419     st->print(PTR_FORMAT ": ", addr);
4420     if (dlinfo.dli_sname != NULL) {
4421       st->print("%s+%#x", dlinfo.dli_sname,
4422                  addr - (intptr_t)dlinfo.dli_saddr);
4423     } else if (dlinfo.dli_fname) {
4424       st->print("<offset %#x>", addr - (intptr_t)dlinfo.dli_fbase);
4425     } else {
4426       st->print("<absolute address>");
4427     }
4428     if (dlinfo.dli_fname) {
4429       st->print(" in %s", dlinfo.dli_fname);
4430     }
4431     if (dlinfo.dli_fbase) {
4432       st->print(" at " PTR_FORMAT, dlinfo.dli_fbase);
4433     }
4434     st->cr();
4435 
4436     if (Verbose) {
4437       // decode some bytes around the PC
4438       address begin = same_page(addr-40, addr);
4439       address end   = same_page(addr+40, addr);
4440       address       lowest = (address) dlinfo.dli_sname;
4441       if (!lowest)  lowest = (address) dlinfo.dli_fbase;
4442       if (begin < lowest)  begin = lowest;
4443       Dl_info dlinfo2;
4444       if (dladdr(end, &dlinfo2) && dlinfo2.dli_saddr != dlinfo.dli_saddr
4445           && end > dlinfo2.dli_saddr && dlinfo2.dli_saddr > begin)
4446         end = (address) dlinfo2.dli_saddr;
4447       Disassembler::decode(begin, end, st);
4448     }
4449     return true;
4450   }
4451   return false;
4452 }
4453 
4454 ////////////////////////////////////////////////////////////////////////////////
4455 // misc
4456 
4457 // This does not do anything on Linux. This is basically a hook for being
4458 // able to use structured exception handling (thread-local exception filters)
4459 // on, e.g., Win32.




 175   // Constructor
 176   MemNotifyThread(int fd);
 177 
 178   // Tester
 179   bool is_memnotify_thread() const { return true; }
 180 
 181   // Printing
 182   char* name() const { return (char*)"Linux MemNotify Thread"; }
 183 
 184   // Returns the single instance of the MemNotifyThread
 185   static MemNotifyThread* memnotify_thread() { return _memnotify_thread; }
 186 
 187   // Create and start the single instance of MemNotifyThread
 188   static void start();
 189 };
 190 #endif // JAVASE_EMBEDDED
 191 
 192 // utility functions
 193 
 194 static int SR_initialize();

 195 
 196 julong os::available_memory() {
 197   return Linux::available_memory();
 198 }
 199 
 200 julong os::Linux::available_memory() {
 201   // values in struct sysinfo are "unsigned long"
 202   struct sysinfo si;
 203   sysinfo(&si);
 204 
 205   return (julong)si.freeram * si.mem_unit;
 206 }
 207 
 208 julong os::physical_memory() {
 209   return Linux::physical_memory();
 210 }
 211 
 212 julong os::allocatable_physical_memory(julong size) {
 213 #ifdef _LP64
 214   return size;


3537   /* Set up signal handler for suspend/resume */
3538   act.sa_flags = SA_RESTART|SA_SIGINFO;
3539   act.sa_handler = (void (*)(int)) SR_handler;
3540 
3541   // SR_signum is blocked by default.
3542   // 4528190 - We also need to block pthread restart signal (32 on all
3543   // supported Linux platforms). Note that LinuxThreads need to block
3544   // this signal for all threads to work properly. So we don't have
3545   // to use hard-coded signal number when setting up the mask.
3546   pthread_sigmask(SIG_BLOCK, NULL, &act.sa_mask);
3547 
3548   if (sigaction(SR_signum, &act, 0) == -1) {
3549     return -1;
3550   }
3551 
3552   // Save signal flag
3553   os::Linux::set_our_sigflags(SR_signum, act.sa_flags);
3554   return 0;
3555 }
3556 




3557 
3558 // returns true on success and false on error - really an error is fatal
3559 // but this seems the normal response to library errors
3560 static bool do_suspend(OSThread* osthread) {
3561   // mark as suspended and send signal
3562   osthread->sr.set_suspend_action(SR_SUSPEND);
3563   int status = pthread_kill(osthread->pthread_id(), SR_signum);
3564   assert_status(status == 0, status, "pthread_kill");
3565 
3566   // check status and wait until notified of suspension
3567   if (status == 0) {
3568     for (int i = 0; !osthread->sr.is_suspended(); i++) {
3569       os::yield_all(i);
3570     }
3571     osthread->sr.set_suspend_action(SR_NONE);
3572     return true;
3573   }
3574   else {
3575     osthread->sr.set_suspend_action(SR_NONE);
3576     return false;


4380    if (is_NPTL()) {
4381       return pthread_cond_timedwait(_cond, _mutex, _abstime);
4382    } else {
4383 #ifndef IA64
4384       // 6292965: LinuxThreads pthread_cond_timedwait() resets FPU control
4385       // word back to default 64bit precision if condvar is signaled. Java
4386       // wants 53bit precision.  Save and restore current value.
4387       int fpu = get_fpu_control_word();
4388 #endif // IA64
4389       int status = pthread_cond_timedwait(_cond, _mutex, _abstime);
4390 #ifndef IA64
4391       set_fpu_control_word(fpu);
4392 #endif // IA64
4393       return status;
4394    }
4395 }
4396 
4397 ////////////////////////////////////////////////////////////////////////////////
4398 // debug support
4399 










4400 bool os::find(address addr, outputStream* st) {
4401   Dl_info dlinfo;
4402   memset(&dlinfo, 0, sizeof(dlinfo));
4403   if (dladdr(addr, &dlinfo)) {
4404     st->print(PTR_FORMAT ": ", addr);
4405     if (dlinfo.dli_sname != NULL) {
4406       st->print("%s+%#x", dlinfo.dli_sname,
4407                  addr - (intptr_t)dlinfo.dli_saddr);
4408     } else if (dlinfo.dli_fname) {
4409       st->print("<offset %#x>", addr - (intptr_t)dlinfo.dli_fbase);
4410     } else {
4411       st->print("<absolute address>");
4412     }
4413     if (dlinfo.dli_fname) {
4414       st->print(" in %s", dlinfo.dli_fname);
4415     }
4416     if (dlinfo.dli_fbase) {
4417       st->print(" at " PTR_FORMAT, dlinfo.dli_fbase);
4418     }
4419     st->cr();
4420 
4421     if (Verbose) {
4422       // decode some bytes around the PC
4423       address begin = clamp_address_in_page(addr-40, addr);
4424       address end   = clamp_address_in_page(addr+40, addr);
4425       address       lowest = (address) dlinfo.dli_sname;
4426       if (!lowest)  lowest = (address) dlinfo.dli_fbase;
4427       if (begin < lowest)  begin = lowest;
4428       Dl_info dlinfo2;
4429       if (dladdr(end, &dlinfo2) && dlinfo2.dli_saddr != dlinfo.dli_saddr
4430           && end > dlinfo2.dli_saddr && dlinfo2.dli_saddr > begin)
4431         end = (address) dlinfo2.dli_saddr;
4432       Disassembler::decode(begin, end, st);
4433     }
4434     return true;
4435   }
4436   return false;
4437 }
4438 
4439 ////////////////////////////////////////////////////////////////////////////////
4440 // misc
4441 
4442 // This does not do anything on Linux. This is basically a hook for being
4443 // able to use structured exception handling (thread-local exception filters)
4444 // on, e.g., Win32.


src/os/linux/vm/os_linux.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File