680 _features = VM_Version::unknown_m;
681
682 // Print the detection code.
683 if (PrintAssembly) {
684 ttyLocker ttyl;
685 tty->print_cr("Decoding cpu-feature detection stub at " INTPTR_FORMAT " before execution:", p2i(code));
686 Disassembler::decode((u_char*)code, (u_char*)code_end, tty);
687 }
688
689 // Measure cache line size.
690 memset(test_area, 0xFF, BUFFER_SIZE); // Fill test area with 0xFF.
691 (*zero_cacheline_func_ptr)(mid_of_test_area); // Call function which executes dcbz to the middle.
692 int count = 0; // count zeroed bytes
693 for (int i = 0; i < BUFFER_SIZE; i++) if (test_area[i] == 0) count++;
694 guarantee(is_power_of_2(count), "cache line size needs to be a power of 2");
695 _L1_data_cache_line_size = count;
696
697 // Execute code. Illegal instructions will be replaced by 0 in the signal handler.
698 VM_Version::_is_determine_features_test_running = true;
699 // We must align the first argument to 16 bytes because of the lqarx check.
700 (*test)(align_ptr_up(mid_of_test_area, 16), (uint64_t)0);
701 VM_Version::_is_determine_features_test_running = false;
702
703 // determine which instructions are legal.
704 int feature_cntr = 0;
705 if (code[feature_cntr++]) features |= fsqrt_m;
706 if (code[feature_cntr++]) features |= fsqrts_m;
707 if (code[feature_cntr++]) features |= isel_m;
708 if (code[feature_cntr++]) features |= lxarxeh_m;
709 if (code[feature_cntr++]) features |= cmpb_m;
710 if (code[feature_cntr++]) features |= popcntb_m;
711 if (code[feature_cntr++]) features |= popcntw_m;
712 if (code[feature_cntr++]) features |= fcfids_m;
713 if (code[feature_cntr++]) features |= vand_m;
714 if (code[feature_cntr++]) features |= lqarx_m;
715 if (code[feature_cntr++]) features |= vcipher_m;
716 if (code[feature_cntr++]) features |= vpmsumb_m;
717 if (code[feature_cntr++]) features |= tcheck_m;
718 if (code[feature_cntr++]) features |= mfdscr_m;
719 if (code[feature_cntr++]) features |= vsx_m;
720 if (code[feature_cntr++]) features |= ldbrx_m;
|
680 _features = VM_Version::unknown_m;
681
682 // Print the detection code.
683 if (PrintAssembly) {
684 ttyLocker ttyl;
685 tty->print_cr("Decoding cpu-feature detection stub at " INTPTR_FORMAT " before execution:", p2i(code));
686 Disassembler::decode((u_char*)code, (u_char*)code_end, tty);
687 }
688
689 // Measure cache line size.
690 memset(test_area, 0xFF, BUFFER_SIZE); // Fill test area with 0xFF.
691 (*zero_cacheline_func_ptr)(mid_of_test_area); // Call function which executes dcbz to the middle.
692 int count = 0; // count zeroed bytes
693 for (int i = 0; i < BUFFER_SIZE; i++) if (test_area[i] == 0) count++;
694 guarantee(is_power_of_2(count), "cache line size needs to be a power of 2");
695 _L1_data_cache_line_size = count;
696
697 // Execute code. Illegal instructions will be replaced by 0 in the signal handler.
698 VM_Version::_is_determine_features_test_running = true;
699 // We must align the first argument to 16 bytes because of the lqarx check.
700 (*test)(align_up(mid_of_test_area, 16), (uint64_t)0);
701 VM_Version::_is_determine_features_test_running = false;
702
703 // determine which instructions are legal.
704 int feature_cntr = 0;
705 if (code[feature_cntr++]) features |= fsqrt_m;
706 if (code[feature_cntr++]) features |= fsqrts_m;
707 if (code[feature_cntr++]) features |= isel_m;
708 if (code[feature_cntr++]) features |= lxarxeh_m;
709 if (code[feature_cntr++]) features |= cmpb_m;
710 if (code[feature_cntr++]) features |= popcntb_m;
711 if (code[feature_cntr++]) features |= popcntw_m;
712 if (code[feature_cntr++]) features |= fcfids_m;
713 if (code[feature_cntr++]) features |= vand_m;
714 if (code[feature_cntr++]) features |= lqarx_m;
715 if (code[feature_cntr++]) features |= vcipher_m;
716 if (code[feature_cntr++]) features |= vpmsumb_m;
717 if (code[feature_cntr++]) features |= tcheck_m;
718 if (code[feature_cntr++]) features |= mfdscr_m;
719 if (code[feature_cntr++]) features |= vsx_m;
720 if (code[feature_cntr++]) features |= ldbrx_m;
|