src/share/vm/runtime/objectMonitor.cpp

changeset 8729
402618d5afc9
parent 8067
c1374141598c
child 8856
ac27a9c85bea
child 8887
b55756ea22d8
equal deleted inserted replaced
8728:8119c543f2af 8729:402618d5afc9
2527 SETKNOB(ResetEvent) ; 2527 SETKNOB(ResetEvent) ;
2528 SETKNOB(MoveNotifyee) ; 2528 SETKNOB(MoveNotifyee) ;
2529 SETKNOB(FastHSSEC) ; 2529 SETKNOB(FastHSSEC) ;
2530 #undef SETKNOB 2530 #undef SETKNOB
2531 2531
2532 if (Knob_Verbose) {
2533 sanity_checks();
2534 }
2535
2532 if (os::is_MP()) { 2536 if (os::is_MP()) {
2533 BackOffMask = (1 << Knob_SpinBackOff) - 1 ; 2537 BackOffMask = (1 << Knob_SpinBackOff) - 1 ;
2534 if (Knob_ReportSettings) ::printf ("BackOffMask=%X\n", BackOffMask) ; 2538 if (Knob_ReportSettings) ::printf ("BackOffMask=%X\n", BackOffMask) ;
2535 // CONSIDER: BackOffMask = ROUNDUP_NEXT_POWER2 (ncpus-1) 2539 // CONSIDER: BackOffMask = ROUNDUP_NEXT_POWER2 (ncpus-1)
2536 } else { 2540 } else {
2547 free (knobs) ; 2551 free (knobs) ;
2548 OrderAccess::fence() ; 2552 OrderAccess::fence() ;
2549 InitDone = 1 ; 2553 InitDone = 1 ;
2550 } 2554 }
2551 2555
2556 void ObjectMonitor::sanity_checks() {
2557 int error_cnt = 0;
2558 int warning_cnt = 0;
2559 bool verbose = Knob_Verbose != 0 NOT_PRODUCT(|| VerboseInternalVMTests);
2560
2561 if (verbose) {
2562 tty->print_cr("INFO: sizeof(ObjectMonitor)=" SIZE_FORMAT,
2563 sizeof(ObjectMonitor));
2564 }
2565
2566 uint cache_line_size = VM_Version::L1_data_cache_line_size();
2567 if (verbose) {
2568 tty->print_cr("INFO: L1_data_cache_line_size=%u", cache_line_size);
2569 }
2570
2571 ObjectMonitor dummy;
2572 u_char *addr_begin = (u_char*)&dummy;
2573 u_char *addr_header = (u_char*)&dummy._header;
2574 u_char *addr_owner = (u_char*)&dummy._owner;
2575
2576 uint offset_header = (uint)(addr_header - addr_begin);
2577 if (verbose) tty->print_cr("INFO: offset(_header)=%u", offset_header);
2578
2579 uint offset_owner = (uint)(addr_owner - addr_begin);
2580 if (verbose) tty->print_cr("INFO: offset(_owner)=%u", offset_owner);
2581
2582 if ((uint)(addr_header - addr_begin) != 0) {
2583 tty->print_cr("ERROR: offset(_header) must be zero (0).");
2584 error_cnt++;
2585 }
2586
2587 if (cache_line_size != 0) {
2588 // We were able to determine the L1 data cache line size so
2589 // do some cache line specific sanity checks
2590
2591 if ((offset_owner - offset_header) < cache_line_size) {
2592 tty->print_cr("WARNING: the _header and _owner fields are closer "
2593 "than a cache line which permits false sharing.");
2594 warning_cnt++;
2595 }
2596
2597 if ((sizeof(ObjectMonitor) % cache_line_size) != 0) {
2598 tty->print_cr("WARNING: ObjectMonitor size is not a multiple of "
2599 "a cache line which permits false sharing.");
2600 warning_cnt++;
2601 }
2602 }
2603
2604 ObjectSynchronizer::sanity_checks(verbose, cache_line_size, &error_cnt,
2605 &warning_cnt);
2606
2607 if (verbose || error_cnt != 0 || warning_cnt != 0) {
2608 tty->print_cr("INFO: error_cnt=%d", error_cnt);
2609 tty->print_cr("INFO: warning_cnt=%d", warning_cnt);
2610 }
2611
2612 guarantee(error_cnt == 0,
2613 "Fatal error(s) found in ObjectMonitor::sanity_checks()");
2614 }
2615
2552 #ifndef PRODUCT 2616 #ifndef PRODUCT
2553 void ObjectMonitor::verify() { 2617 void ObjectMonitor::verify() {
2554 } 2618 }
2555 2619
2556 void ObjectMonitor::print() { 2620 void ObjectMonitor::print() {

mercurial