hotspot/src/os/aix/vm/os_aix.cpp
changeset 34624 b04133a76825
parent 34621 7676bec20997
child 34633 2a6c7c7b30a7
equal deleted inserted replaced
34623:3aff37e35ebe 34624:b04133a76825
  2261   }
  2261   }
  2262 }
  2262 }
  2263 
  2263 
  2264 bool os::pd_commit_memory(char* addr, size_t size, bool exec) {
  2264 bool os::pd_commit_memory(char* addr, size_t size, bool exec) {
  2265 
  2265 
  2266   assert0(is_aligned_to(addr, os::vm_page_size()));
  2266   assert(is_aligned_to(addr, os::vm_page_size()),
  2267   assert0(is_aligned_to(size, os::vm_page_size()));
  2267     "addr " PTR_FORMAT " not aligned to vm_page_size (" PTR_FORMAT ")",
       
  2268     p2i(addr), os::vm_page_size());
       
  2269   assert(is_aligned_to(size, os::vm_page_size()),
       
  2270     "size " PTR_FORMAT " not aligned to vm_page_size (" PTR_FORMAT ")",
       
  2271     size, os::vm_page_size());
  2268 
  2272 
  2269   vmembk_t* const vmi = vmembk_find(addr);
  2273   vmembk_t* const vmi = vmembk_find(addr);
  2270   assert0(vmi);
  2274   assert0(vmi);
  2271   vmi->assert_is_valid_subrange(addr, size);
  2275   vmi->assert_is_valid_subrange(addr, size);
  2272 
  2276 
  2285   // Alignment_hint is ignored on this OS.
  2289   // Alignment_hint is ignored on this OS.
  2286   pd_commit_memory_or_exit(addr, size, exec, mesg);
  2290   pd_commit_memory_or_exit(addr, size, exec, mesg);
  2287 }
  2291 }
  2288 
  2292 
  2289 bool os::pd_uncommit_memory(char* addr, size_t size) {
  2293 bool os::pd_uncommit_memory(char* addr, size_t size) {
  2290   assert0(is_aligned_to(addr, os::vm_page_size()));
  2294   assert(is_aligned_to(addr, os::vm_page_size()),
  2291   assert0(is_aligned_to(size, os::vm_page_size()));
  2295     "addr " PTR_FORMAT " not aligned to vm_page_size (" PTR_FORMAT ")",
       
  2296     p2i(addr), os::vm_page_size());
       
  2297   assert(is_aligned_to(size, os::vm_page_size()),
       
  2298     "size " PTR_FORMAT " not aligned to vm_page_size (" PTR_FORMAT ")",
       
  2299     size, os::vm_page_size());
  2292 
  2300 
  2293   // Dynamically do different things for mmap/shmat.
  2301   // Dynamically do different things for mmap/shmat.
  2294   const vmembk_t* const vmi = vmembk_find(addr);
  2302   const vmembk_t* const vmi = vmembk_find(addr);
  2295   assert0(vmi);
  2303   assert0(vmi);
  2296   vmi->assert_is_valid_subrange(addr, size);
  2304   vmi->assert_is_valid_subrange(addr, size);
  4297   // where I create an own stack and pass this to pthread_create, it seems not to
  4305   // where I create an own stack and pass this to pthread_create, it seems not to
  4298   // work (the returned stack size in that case is 0).
  4306   // work (the returned stack size in that case is 0).
  4299 
  4307 
  4300   pthread_t tid = pthread_self();
  4308   pthread_t tid = pthread_self();
  4301   struct __pthrdsinfo pinfo;
  4309   struct __pthrdsinfo pinfo;
  4302   char dummy[1]; // We only need this to satisfy the api and to not get E.
  4310   char dummy[1]; // Just needed to satisfy pthread_getthrds_np.
  4303   int dummy_size = sizeof(dummy);
  4311   int dummy_size = sizeof(dummy);
  4304 
  4312 
  4305   memset(&pinfo, 0, sizeof(pinfo));
  4313   memset(&pinfo, 0, sizeof(pinfo));
  4306 
  4314 
  4307   const int rc = pthread_getthrds_np(&tid, PTHRDSINFO_QUERY_ALL, &pinfo,
  4315   const int rc = pthread_getthrds_np(&tid, PTHRDSINFO_QUERY_ALL, &pinfo,
  4318   // on a user provided stack (when handing down a stack to pthread create, see
  4326   // on a user provided stack (when handing down a stack to pthread create, see
  4319   // pthread_attr_setstackaddr).
  4327   // pthread_attr_setstackaddr).
  4320   // Not sure what to do here - I feel inclined to forbid this use case completely.
  4328   // Not sure what to do here - I feel inclined to forbid this use case completely.
  4321   guarantee0(pinfo.__pi_stacksize);
  4329   guarantee0(pinfo.__pi_stacksize);
  4322 
  4330 
  4323   // Note: the pthread stack on AIX seems to look like this:
  4331   // Note: we get three values from pthread_getthrds_np:
       
  4332   //       __pi_stackaddr, __pi_stacksize, __pi_stackend
  4324   //
  4333   //
  4325   // ---------------------   real base ? at page border ?
  4334   // high addr    ---------------------
  4326   //
  4335   //
  4327   //     pthread internal data, like ~2K, see also
  4336   //    |         pthread internal data, like ~2K
  4328   //     http://publib.boulder.ibm.com/infocenter/pseries/v5r3/index.jsp?topic=/com.ibm.aix.prftungd/doc/prftungd/thread_supp_tun_params.htm
  4337   //    |
       
  4338   //    |         ---------------------   __pi_stackend   (usually not page aligned, (xxxxF890))
       
  4339   //    |
       
  4340   //    |
       
  4341   //    |
       
  4342   //    |
       
  4343   //    |
       
  4344   //    |
       
  4345   //    |          ---------------------   (__pi_stackend - __pi_stacksize)
       
  4346   //    |
       
  4347   //    |          padding to align the following AIX guard pages, if enabled.
       
  4348   //    |
       
  4349   //    V          ---------------------   __pi_stackaddr
  4329   //
  4350   //
  4330   // ---------------------   __pi_stackend - not page aligned, (xxxxF890)
  4351   // low addr      AIX guard pages, if enabled (AIXTHREAD_GUARDPAGES > 0)
  4331   //
  4352   //
  4332   //     stack
  4353 
  4333   //      ....
  4354   address stack_base = (address)(pinfo.__pi_stackend);
  4334   //
  4355   address stack_low_addr = (address)align_ptr_up(pinfo.__pi_stackaddr,  os::vm_page_size());
  4335   //     stack
  4356   size_t stack_size = stack_base - stack_low_addr;
  4336   //
       
  4337   // ---------------------   __pi_stackend  - __pi_stacksize
       
  4338   //
       
  4339   //     padding due to AIX guard pages (?) see AIXTHREAD_GUARDPAGES
       
  4340   // ---------------------   __pi_stackaddr  (page aligned if AIXTHREAD_GUARDPAGES > 0)
       
  4341   //
       
  4342   //   AIX guard pages (?)
       
  4343   //
       
  4344 
       
  4345   // So, the safe thing to do is to use the area from __pi_stackend to __pi_stackaddr;
       
  4346   // __pi_stackend however is almost never page aligned.
       
  4347   //
       
  4348 
  4357 
  4349   if (p_stack_base) {
  4358   if (p_stack_base) {
  4350     (*p_stack_base) = (address) (pinfo.__pi_stackend);
  4359     *p_stack_base = stack_base;
  4351   }
  4360   }
  4352 
  4361 
  4353   if (p_stack_size) {
  4362   if (p_stack_size) {
  4354     (*p_stack_size) = pinfo.__pi_stackend - pinfo.__pi_stackaddr;
  4363     *p_stack_size = stack_size;
  4355   }
  4364   }
  4356 
  4365 
  4357   return true;
  4366   return true;
  4358 }
  4367 }
  4359 
  4368