< prev index next >

src/share/vm/runtime/os.cpp

Print this page




 320             warning("Exception %s occurred dispatching signal %s to handler"
 321                     "- the VM may need to be forcibly terminated",
 322                     klass_name, sig_name );
 323           }
 324           CLEAR_PENDING_EXCEPTION;
 325         }
 326       }
 327     }
 328   }
 329 }
 330 
 331 void os::init_before_ergo() {
 332   initialize_initial_active_processor_count();
 333   // We need to initialize large page support here because ergonomics takes some
 334   // decisions depending on large page support and the calculated large page size.
 335   large_page_init();
 336 
 337   // We need to adapt the configured number of stack protection pages given
 338   // in 4K pages to the actual os page size. We must do this before setting
 339   // up minimal stack sizes etc. in os::init_2().
 340   JavaThread::set_stack_red_zone_size     (align_size_up(StackRedPages      * 4 * K, vm_page_size()));
 341   JavaThread::set_stack_yellow_zone_size  (align_size_up(StackYellowPages   * 4 * K, vm_page_size()));
 342   JavaThread::set_stack_reserved_zone_size(align_size_up(StackReservedPages * 4 * K, vm_page_size()));
 343   JavaThread::set_stack_shadow_zone_size  (align_size_up(StackShadowPages   * 4 * K, vm_page_size()));
 344 
 345   // VM version initialization identifies some characteristics of the
 346   // platform that are used during ergonomic decisions.
 347   VM_Version::init_before_ergo();
 348 }
 349 
 350 void os::signal_init(TRAPS) {
 351   if (!ReduceSignalUsage) {
 352     // Setup JavaThread for processing signals
 353     Klass* k = SystemDictionary::resolve_or_fail(vmSymbols::java_lang_Thread(), true, CHECK);
 354     InstanceKlass* ik = InstanceKlass::cast(k);
 355     instanceHandle thread_oop = ik->allocate_instance_handle(CHECK);
 356 
 357     const char thread_name[] = "Signal Dispatcher";
 358     Handle string = java_lang_String::create_from_str(thread_name, CHECK);
 359 
 360     // Initialize thread_oop to put it into the system threadGroup
 361     Handle thread_group (THREAD, Universe::system_thread_group());
 362     JavaValue result(T_VOID);
 363     JavaCalls::call_special(&result, thread_oop,


1349   // the handler for stack overflow.  'instanceof' in the stack overflow
1350   // handler or a println uses at least 8k stack of VM and native code
1351   // respectively.
1352   const int framesize_in_bytes =
1353     Interpreter::size_top_interpreter_activation(method()) * wordSize;
1354 
1355   address limit = ((JavaThread*)thread)->stack_end() +
1356                   (JavaThread::stack_guard_zone_size() + JavaThread::stack_shadow_zone_size());
1357 
1358   return sp > (limit + framesize_in_bytes);
1359 }
1360 
1361 size_t os::page_size_for_region(size_t region_size, size_t min_pages, bool must_be_aligned) {
1362   assert(min_pages > 0, "sanity");
1363   if (UseLargePages) {
1364     const size_t max_page_size = region_size / min_pages;
1365 
1366     for (size_t i = 0; _page_sizes[i] != 0; ++i) {
1367       const size_t page_size = _page_sizes[i];
1368       if (page_size <= max_page_size) {
1369         if (!must_be_aligned || is_size_aligned(region_size, page_size)) {
1370           return page_size;
1371         }
1372       }
1373     }
1374   }
1375 
1376   return vm_page_size();
1377 }
1378 
1379 size_t os::page_size_for_region_aligned(size_t region_size, size_t min_pages) {
1380   return page_size_for_region(region_size, min_pages, true);
1381 }
1382 
1383 size_t os::page_size_for_region_unaligned(size_t region_size, size_t min_pages) {
1384   return page_size_for_region(region_size, min_pages, false);
1385 }
1386 
1387 static const char* errno_to_string (int e, bool short_text) {
1388   #define ALL_SHARED_ENUMS(X) \
1389     X(E2BIG, "Argument list too long") \




 320             warning("Exception %s occurred dispatching signal %s to handler"
 321                     "- the VM may need to be forcibly terminated",
 322                     klass_name, sig_name );
 323           }
 324           CLEAR_PENDING_EXCEPTION;
 325         }
 326       }
 327     }
 328   }
 329 }
 330 
 331 void os::init_before_ergo() {
 332   initialize_initial_active_processor_count();
 333   // We need to initialize large page support here because ergonomics takes some
 334   // decisions depending on large page support and the calculated large page size.
 335   large_page_init();
 336 
 337   // We need to adapt the configured number of stack protection pages given
 338   // in 4K pages to the actual os page size. We must do this before setting
 339   // up minimal stack sizes etc. in os::init_2().
 340   JavaThread::set_stack_red_zone_size     (align_up(StackRedPages      * 4 * K, vm_page_size()));
 341   JavaThread::set_stack_yellow_zone_size  (align_up(StackYellowPages   * 4 * K, vm_page_size()));
 342   JavaThread::set_stack_reserved_zone_size(align_up(StackReservedPages * 4 * K, vm_page_size()));
 343   JavaThread::set_stack_shadow_zone_size  (align_up(StackShadowPages   * 4 * K, vm_page_size()));
 344 
 345   // VM version initialization identifies some characteristics of the
 346   // platform that are used during ergonomic decisions.
 347   VM_Version::init_before_ergo();
 348 }
 349 
 350 void os::signal_init(TRAPS) {
 351   if (!ReduceSignalUsage) {
 352     // Setup JavaThread for processing signals
 353     Klass* k = SystemDictionary::resolve_or_fail(vmSymbols::java_lang_Thread(), true, CHECK);
 354     InstanceKlass* ik = InstanceKlass::cast(k);
 355     instanceHandle thread_oop = ik->allocate_instance_handle(CHECK);
 356 
 357     const char thread_name[] = "Signal Dispatcher";
 358     Handle string = java_lang_String::create_from_str(thread_name, CHECK);
 359 
 360     // Initialize thread_oop to put it into the system threadGroup
 361     Handle thread_group (THREAD, Universe::system_thread_group());
 362     JavaValue result(T_VOID);
 363     JavaCalls::call_special(&result, thread_oop,


1349   // the handler for stack overflow.  'instanceof' in the stack overflow
1350   // handler or a println uses at least 8k stack of VM and native code
1351   // respectively.
1352   const int framesize_in_bytes =
1353     Interpreter::size_top_interpreter_activation(method()) * wordSize;
1354 
1355   address limit = ((JavaThread*)thread)->stack_end() +
1356                   (JavaThread::stack_guard_zone_size() + JavaThread::stack_shadow_zone_size());
1357 
1358   return sp > (limit + framesize_in_bytes);
1359 }
1360 
1361 size_t os::page_size_for_region(size_t region_size, size_t min_pages, bool must_be_aligned) {
1362   assert(min_pages > 0, "sanity");
1363   if (UseLargePages) {
1364     const size_t max_page_size = region_size / min_pages;
1365 
1366     for (size_t i = 0; _page_sizes[i] != 0; ++i) {
1367       const size_t page_size = _page_sizes[i];
1368       if (page_size <= max_page_size) {
1369         if (!must_be_aligned || is_aligned(region_size, page_size)) {
1370           return page_size;
1371         }
1372       }
1373     }
1374   }
1375 
1376   return vm_page_size();
1377 }
1378 
1379 size_t os::page_size_for_region_aligned(size_t region_size, size_t min_pages) {
1380   return page_size_for_region(region_size, min_pages, true);
1381 }
1382 
1383 size_t os::page_size_for_region_unaligned(size_t region_size, size_t min_pages) {
1384   return page_size_for_region(region_size, min_pages, false);
1385 }
1386 
1387 static const char* errno_to_string (int e, bool short_text) {
1388   #define ALL_SHARED_ENUMS(X) \
1389     X(E2BIG, "Argument list too long") \


< prev index next >