hotspot/src/share/vm/runtime/objectMonitor.cpp
changeset 25633 4cd9c4622c8c
parent 25472 381638db28e6
child 26683 a02753d5a0b2
equal deleted inserted replaced
25632:d200adafaee5 25633:4cd9c4622c8c
  2495   SETKNOB(ResetEvent);
  2495   SETKNOB(ResetEvent);
  2496   SETKNOB(MoveNotifyee);
  2496   SETKNOB(MoveNotifyee);
  2497   SETKNOB(FastHSSEC);
  2497   SETKNOB(FastHSSEC);
  2498   #undef SETKNOB
  2498   #undef SETKNOB
  2499 
  2499 
       
  2500   if (Knob_Verbose) {
       
  2501     sanity_checks();
       
  2502   }
       
  2503 
  2500   if (os::is_MP()) {
  2504   if (os::is_MP()) {
  2501      BackOffMask = (1 << Knob_SpinBackOff) - 1;
  2505      BackOffMask = (1 << Knob_SpinBackOff) - 1;
  2502      if (Knob_ReportSettings) ::printf("BackOffMask=%X\n", BackOffMask);
  2506      if (Knob_ReportSettings) ::printf("BackOffMask=%X\n", BackOffMask);
  2503      // CONSIDER: BackOffMask = ROUNDUP_NEXT_POWER2 (ncpus-1)
  2507      // CONSIDER: BackOffMask = ROUNDUP_NEXT_POWER2 (ncpus-1)
  2504   } else {
  2508   } else {
  2515   free(knobs);
  2519   free(knobs);
  2516   OrderAccess::fence();
  2520   OrderAccess::fence();
  2517   InitDone = 1;
  2521   InitDone = 1;
  2518 }
  2522 }
  2519 
  2523 
       
  2524 void ObjectMonitor::sanity_checks() {
       
  2525   int error_cnt = 0;
       
  2526   int warning_cnt = 0;
       
  2527   bool verbose = Knob_Verbose != 0 NOT_PRODUCT(|| VerboseInternalVMTests);
       
  2528 
       
  2529   if (verbose) {
       
  2530     tty->print_cr("INFO: sizeof(ObjectMonitor)=" SIZE_FORMAT,
       
  2531                   sizeof(ObjectMonitor));
       
  2532   }
       
  2533 
       
  2534   uint cache_line_size = VM_Version::L1_data_cache_line_size();
       
  2535   if (verbose) {
       
  2536     tty->print_cr("INFO: L1_data_cache_line_size=%u", cache_line_size);
       
  2537   }
       
  2538 
       
  2539   ObjectMonitor dummy;
       
  2540   u_char *addr_begin  = (u_char*)&dummy;
       
  2541   u_char *addr_header = (u_char*)&dummy._header;
       
  2542   u_char *addr_owner  = (u_char*)&dummy._owner;
       
  2543 
       
  2544   uint offset_header = (uint)(addr_header - addr_begin);
       
  2545   if (verbose) tty->print_cr("INFO: offset(_header)=%u", offset_header);
       
  2546 
       
  2547   uint offset_owner = (uint)(addr_owner - addr_begin);
       
  2548   if (verbose) tty->print_cr("INFO: offset(_owner)=%u", offset_owner);
       
  2549 
       
  2550   if ((uint)(addr_header - addr_begin) != 0) {
       
  2551     tty->print_cr("ERROR: offset(_header) must be zero (0).");
       
  2552     error_cnt++;
       
  2553   }
       
  2554 
       
  2555   if (cache_line_size != 0) {
       
  2556     // We were able to determine the L1 data cache line size so
       
  2557     // do some cache line specific sanity checks
       
  2558 
       
  2559     if ((offset_owner - offset_header) < cache_line_size) {
       
  2560       tty->print_cr("WARNING: the _header and _owner fields are closer "
       
  2561                     "than a cache line which permits false sharing.");
       
  2562       warning_cnt++;
       
  2563     }
       
  2564 
       
  2565     if ((sizeof(ObjectMonitor) % cache_line_size) != 0) {
       
  2566       tty->print_cr("WARNING: ObjectMonitor size is not a multiple of "
       
  2567                     "a cache line which permits false sharing.");
       
  2568       warning_cnt++;
       
  2569     }
       
  2570   }
       
  2571 
       
  2572   ObjectSynchronizer::sanity_checks(verbose, cache_line_size, &error_cnt,
       
  2573                                     &warning_cnt);
       
  2574 
       
  2575   if (verbose || error_cnt != 0 || warning_cnt != 0) {
       
  2576     tty->print_cr("INFO: error_cnt=%d", error_cnt);
       
  2577     tty->print_cr("INFO: warning_cnt=%d", warning_cnt);
       
  2578   }
       
  2579 
       
  2580   guarantee(error_cnt == 0,
       
  2581             "Fatal error(s) found in ObjectMonitor::sanity_checks()");
       
  2582 }
       
  2583 
  2520 #ifndef PRODUCT
  2584 #ifndef PRODUCT
  2521 void ObjectMonitor::verify() {
  2585 void ObjectMonitor::verify() {
  2522 }
  2586 }
  2523 
  2587 
  2524 void ObjectMonitor::print() {
  2588 void ObjectMonitor::print() {