comparison src/cpu/x86/vm/vm_version_x86.cpp @ 17780:606acabe7b5c

8031320: Use Intel RTM instructions for locks Summary: Use RTM for inflated locks and stack locks. Reviewed-by: iveresov, twisti, roland, dcubed
author kvn
date Thu, 20 Mar 2014 17:49:27 -0700
parents 98af1e198e73
children 0118c8c7b80f
comparison
equal deleted inserted replaced
17778:a48e16541e6b 17780:606acabe7b5c
473 // HT processor could be installed on a system which doesn't support HT. 473 // HT processor could be installed on a system which doesn't support HT.
474 _cpuFeatures &= ~CPU_HT; 474 _cpuFeatures &= ~CPU_HT;
475 } 475 }
476 476
477 char buf[256]; 477 char buf[256];
478 jio_snprintf(buf, sizeof(buf), "(%u cores per cpu, %u threads per core) family %d model %d stepping %d%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s", 478 jio_snprintf(buf, sizeof(buf), "(%u cores per cpu, %u threads per core) family %d model %d stepping %d%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
479 cores_per_cpu(), threads_per_core(), 479 cores_per_cpu(), threads_per_core(),
480 cpu_family(), _model, _stepping, 480 cpu_family(), _model, _stepping,
481 (supports_cmov() ? ", cmov" : ""), 481 (supports_cmov() ? ", cmov" : ""),
482 (supports_cmpxchg8() ? ", cx8" : ""), 482 (supports_cmpxchg8() ? ", cx8" : ""),
483 (supports_fxsr() ? ", fxsr" : ""), 483 (supports_fxsr() ? ", fxsr" : ""),
490 (supports_sse4_2() ? ", sse4.2" : ""), 490 (supports_sse4_2() ? ", sse4.2" : ""),
491 (supports_popcnt() ? ", popcnt" : ""), 491 (supports_popcnt() ? ", popcnt" : ""),
492 (supports_avx() ? ", avx" : ""), 492 (supports_avx() ? ", avx" : ""),
493 (supports_avx2() ? ", avx2" : ""), 493 (supports_avx2() ? ", avx2" : ""),
494 (supports_aes() ? ", aes" : ""), 494 (supports_aes() ? ", aes" : ""),
495 (supports_clmul() ? ", clmul" : ""), 495 (supports_clmul() ? ", clmul" : ""),
496 (supports_erms() ? ", erms" : ""), 496 (supports_erms() ? ", erms" : ""),
497 (supports_rtm() ? ", rtm" : ""),
497 (supports_mmx_ext() ? ", mmxext" : ""), 498 (supports_mmx_ext() ? ", mmxext" : ""),
498 (supports_3dnow_prefetch() ? ", 3dnowpref" : ""), 499 (supports_3dnow_prefetch() ? ", 3dnowpref" : ""),
499 (supports_lzcnt() ? ", lzcnt": ""), 500 (supports_lzcnt() ? ", lzcnt": ""),
500 (supports_sse4a() ? ", sse4a": ""), 501 (supports_sse4a() ? ", sse4a": ""),
501 (supports_ht() ? ", ht": ""), 502 (supports_ht() ? ", ht": ""),
532 if (FLAG_IS_DEFAULT(UseAES)) { 533 if (FLAG_IS_DEFAULT(UseAES)) {
533 UseAES = true; 534 UseAES = true;
534 } 535 }
535 } else if (UseAES) { 536 } else if (UseAES) {
536 if (!FLAG_IS_DEFAULT(UseAES)) 537 if (!FLAG_IS_DEFAULT(UseAES))
537 warning("AES instructions not available on this CPU"); 538 warning("AES instructions are not available on this CPU");
538 FLAG_SET_DEFAULT(UseAES, false); 539 FLAG_SET_DEFAULT(UseAES, false);
539 } 540 }
540 541
541 // Use CLMUL instructions if available. 542 // Use CLMUL instructions if available.
542 if (supports_clmul()) { 543 if (supports_clmul()) {
565 if (FLAG_IS_DEFAULT(UseAESIntrinsics)) { 566 if (FLAG_IS_DEFAULT(UseAESIntrinsics)) {
566 UseAESIntrinsics = true; 567 UseAESIntrinsics = true;
567 } 568 }
568 } else if (UseAESIntrinsics) { 569 } else if (UseAESIntrinsics) {
569 if (!FLAG_IS_DEFAULT(UseAESIntrinsics)) 570 if (!FLAG_IS_DEFAULT(UseAESIntrinsics))
570 warning("AES intrinsics not available on this CPU"); 571 warning("AES intrinsics are not available on this CPU");
571 FLAG_SET_DEFAULT(UseAESIntrinsics, false); 572 FLAG_SET_DEFAULT(UseAESIntrinsics, false);
572 } 573 }
574
575 // Adjust RTM (Restricted Transactional Memory) flags
576 if (!supports_rtm() && UseRTMLocking) {
577 // Can't continue because UseRTMLocking affects UseBiasedLocking flag
578 // setting during arguments processing. See use_biased_locking().
579 // VM_Version_init() is executed after UseBiasedLocking is used
580 // in Thread::allocate().
581 vm_exit_during_initialization("RTM instructions are not available on this CPU");
582 }
583
584 #if INCLUDE_RTM_OPT
585 if (UseRTMLocking) {
586 if (!FLAG_IS_CMDLINE(UseRTMLocking)) {
587 // RTM locking should be used only for applications with
588 // high lock contention. For now we do not use it by default.
589 vm_exit_during_initialization("UseRTMLocking flag should be only set on command line");
590 }
591 if (!is_power_of_2(RTMTotalCountIncrRate)) {
592 warning("RTMTotalCountIncrRate must be a power of 2, resetting it to 64");
593 FLAG_SET_DEFAULT(RTMTotalCountIncrRate, 64);
594 }
595 if (RTMAbortRatio < 0 || RTMAbortRatio > 100) {
596 warning("RTMAbortRatio must be in the range 0 to 100, resetting it to 50");
597 FLAG_SET_DEFAULT(RTMAbortRatio, 50);
598 }
599 } else { // !UseRTMLocking
600 if (UseRTMForStackLocks) {
601 if (!FLAG_IS_DEFAULT(UseRTMForStackLocks)) {
602 warning("UseRTMForStackLocks flag should be off when UseRTMLocking flag is off");
603 }
604 FLAG_SET_DEFAULT(UseRTMForStackLocks, false);
605 }
606 if (UseRTMDeopt) {
607 FLAG_SET_DEFAULT(UseRTMDeopt, false);
608 }
609 if (PrintPreciseRTMLockingStatistics) {
610 FLAG_SET_DEFAULT(PrintPreciseRTMLockingStatistics, false);
611 }
612 }
613 #else
614 if (UseRTMLocking) {
615 // Only C2 does RTM locking optimization.
616 // Can't continue because UseRTMLocking affects UseBiasedLocking flag
617 // setting during arguments processing. See use_biased_locking().
618 vm_exit_during_initialization("RTM locking optimization is not supported in this VM");
619 }
620 #endif
573 621
574 #ifdef COMPILER2 622 #ifdef COMPILER2
575 if (UseFPUForSpilling) { 623 if (UseFPUForSpilling) {
576 if (UseSSE < 2) { 624 if (UseSSE < 2) {
577 // Only supported with SSE2+ 625 // Only supported with SSE2+
911 } 959 }
912 } 960 }
913 #endif // !PRODUCT 961 #endif // !PRODUCT
914 } 962 }
915 963
964 bool VM_Version::use_biased_locking() {
965 #if INCLUDE_RTM_OPT
966 // RTM locking is most useful when there is high lock contention and
967 // low data contention. With high lock contention the lock is usually
968 // inflated and biased locking is not suitable for that case.
969 // RTM locking code requires that biased locking is off.
970 // Note: we can't switch off UseBiasedLocking in get_processor_features()
971 // because it is used by Thread::allocate() which is called before
972 // VM_Version::initialize().
973 if (UseRTMLocking && UseBiasedLocking) {
974 if (FLAG_IS_DEFAULT(UseBiasedLocking)) {
975 FLAG_SET_DEFAULT(UseBiasedLocking, false);
976 } else {
977 warning("Biased locking is not supported with RTM locking; ignoring UseBiasedLocking flag." );
978 UseBiasedLocking = false;
979 }
980 }
981 #endif
982 return UseBiasedLocking;
983 }
984
916 void VM_Version::initialize() { 985 void VM_Version::initialize() {
917 ResourceMark rm; 986 ResourceMark rm;
918 // Making this stub must be FIRST use of assembler 987 // Making this stub must be FIRST use of assembler
919 988
920 stub_blob = BufferBlob::create("getPsrInfo_stub", stub_size); 989 stub_blob = BufferBlob::create("getPsrInfo_stub", stub_size);