335
336 double loop1_seconds,loop2_seconds, rel_diff;
337 uint64_t start1, stop1;
338
339 start1 = os::current_thread_cpu_time(false);
340 (*test1)();
341 stop1 = os::current_thread_cpu_time(false);
342 loop1_seconds = (stop1- start1) / (1000 *1000 *1000.0);
343
344
345 start1 = os::current_thread_cpu_time(false);
346 (*test2)();
347 stop1 = os::current_thread_cpu_time(false);
348
349 loop2_seconds = (stop1 - start1) / (1000 *1000 *1000.0);
350
351 rel_diff = (loop2_seconds - loop1_seconds) / loop1_seconds *100;
352
353 if (PrintAssembly) {
354 ttyLocker ttyl;
355 tty->print_cr("Decoding section size detection stub at " INTPTR_FORMAT " before execution:", code);
356 Disassembler::decode((u_char*)code, (u_char*)code_end, tty);
357 tty->print_cr("Time loop1 :%f", loop1_seconds);
358 tty->print_cr("Time loop2 :%f", loop2_seconds);
359 tty->print_cr("(time2 - time1) / time1 = %f %%", rel_diff);
360
361 if (rel_diff > 12.0) {
362 tty->print_cr("Section Size 8 Instructions");
363 } else{
364 tty->print_cr("Section Size 32 Instructions or Power5");
365 }
366 }
367
368 #if 0 // TODO: PPC port
369 // Set sector size (if not set explicitly).
370 if (FLAG_IS_DEFAULT(Power6SectorSize128PPC64)) {
371 if (rel_diff > 12.0) {
372 PdScheduling::power6SectorSize = 0x20;
373 } else {
374 PdScheduling::power6SectorSize = 0x80;
375 }
418 a->cmpb(R7, R5, R6); // code[4] -> bcmp
419 //a->mftgpr(R7, F3); // code[5] -> mftgpr
420 a->popcntb(R7, R5); // code[6] -> popcntb
421 a->popcntw(R7, R5); // code[7] -> popcntw
422 a->fcfids(F3, F4); // code[8] -> fcfids
423 a->vand(VR0, VR0, VR0); // code[9] -> vand
424 a->blr();
425
426 // Emit function to set one cache line to zero. Emit function descriptor and get pointer to it.
427 void (*zero_cacheline_func_ptr)(char*) = (void(*)(char*))(void *)a->function_entry();
428 a->dcbz(R3_ARG1); // R3_ARG1 = addr
429 a->blr();
430
431 uint32_t *code_end = (uint32_t *)a->pc();
432 a->flush();
433 _features = VM_Version::unknown_m;
434
435 // Print the detection code.
436 if (PrintAssembly) {
437 ttyLocker ttyl;
438 tty->print_cr("Decoding cpu-feature detection stub at " INTPTR_FORMAT " before execution:", code);
439 Disassembler::decode((u_char*)code, (u_char*)code_end, tty);
440 }
441
442 // Measure cache line size.
443 memset(test_area, 0xFF, BUFFER_SIZE); // Fill test area with 0xFF.
444 (*zero_cacheline_func_ptr)(mid_of_test_area); // Call function which executes dcbz to the middle.
445 int count = 0; // count zeroed bytes
446 for (int i = 0; i < BUFFER_SIZE; i++) if (test_area[i] == 0) count++;
447 guarantee(is_power_of_2(count), "cache line size needs to be a power of 2");
448 _measured_cache_line_size = count;
449
450 // Execute code. Illegal instructions will be replaced by 0 in the signal handler.
451 VM_Version::_is_determine_features_test_running = true;
452 (*test)((address)mid_of_test_area, (uint64_t)0);
453 VM_Version::_is_determine_features_test_running = false;
454
455 // determine which instructions are legal.
456 int feature_cntr = 0;
457 if (code[feature_cntr++]) features |= fsqrt_m;
458 if (code[feature_cntr++]) features |= fsqrts_m;
459 if (code[feature_cntr++]) features |= isel_m;
460 if (code[feature_cntr++]) features |= lxarxeh_m;
461 if (code[feature_cntr++]) features |= cmpb_m;
462 //if(code[feature_cntr++])features |= mftgpr_m;
463 if (code[feature_cntr++]) features |= popcntb_m;
464 if (code[feature_cntr++]) features |= popcntw_m;
465 if (code[feature_cntr++]) features |= fcfids_m;
466 if (code[feature_cntr++]) features |= vand_m;
467
468 // Print the detection code.
469 if (PrintAssembly) {
470 ttyLocker ttyl;
471 tty->print_cr("Decoding cpu-feature detection stub at " INTPTR_FORMAT " after execution:", code);
472 Disassembler::decode((u_char*)code, (u_char*)code_end, tty);
473 }
474
475 _features = features;
476 }
477
478
479 static int saved_features = 0;
480
481 void VM_Version::allow_all() {
482 saved_features = _features;
483 _features = all_features_m;
484 }
485
486 void VM_Version::revert() {
487 _features = saved_features;
488 }
|
335
336 double loop1_seconds,loop2_seconds, rel_diff;
337 uint64_t start1, stop1;
338
339 start1 = os::current_thread_cpu_time(false);
340 (*test1)();
341 stop1 = os::current_thread_cpu_time(false);
342 loop1_seconds = (stop1- start1) / (1000 *1000 *1000.0);
343
344
345 start1 = os::current_thread_cpu_time(false);
346 (*test2)();
347 stop1 = os::current_thread_cpu_time(false);
348
349 loop2_seconds = (stop1 - start1) / (1000 *1000 *1000.0);
350
351 rel_diff = (loop2_seconds - loop1_seconds) / loop1_seconds *100;
352
353 if (PrintAssembly) {
354 ttyLocker ttyl;
355 tty->print_cr("Decoding section size detection stub at " INTPTR_FORMAT " before execution:", p2i(code));
356 Disassembler::decode((u_char*)code, (u_char*)code_end, tty);
357 tty->print_cr("Time loop1 :%f", loop1_seconds);
358 tty->print_cr("Time loop2 :%f", loop2_seconds);
359 tty->print_cr("(time2 - time1) / time1 = %f %%", rel_diff);
360
361 if (rel_diff > 12.0) {
362 tty->print_cr("Section Size 8 Instructions");
363 } else{
364 tty->print_cr("Section Size 32 Instructions or Power5");
365 }
366 }
367
368 #if 0 // TODO: PPC port
369 // Set sector size (if not set explicitly).
370 if (FLAG_IS_DEFAULT(Power6SectorSize128PPC64)) {
371 if (rel_diff > 12.0) {
372 PdScheduling::power6SectorSize = 0x20;
373 } else {
374 PdScheduling::power6SectorSize = 0x80;
375 }
418 a->cmpb(R7, R5, R6); // code[4] -> bcmp
419 //a->mftgpr(R7, F3); // code[5] -> mftgpr
420 a->popcntb(R7, R5); // code[6] -> popcntb
421 a->popcntw(R7, R5); // code[7] -> popcntw
422 a->fcfids(F3, F4); // code[8] -> fcfids
423 a->vand(VR0, VR0, VR0); // code[9] -> vand
424 a->blr();
425
426 // Emit function to set one cache line to zero. Emit function descriptor and get pointer to it.
427 void (*zero_cacheline_func_ptr)(char*) = (void(*)(char*))(void *)a->function_entry();
428 a->dcbz(R3_ARG1); // R3_ARG1 = addr
429 a->blr();
430
431 uint32_t *code_end = (uint32_t *)a->pc();
432 a->flush();
433 _features = VM_Version::unknown_m;
434
435 // Print the detection code.
436 if (PrintAssembly) {
437 ttyLocker ttyl;
438 tty->print_cr("Decoding cpu-feature detection stub at " INTPTR_FORMAT " before execution:", p2i(code));
439 Disassembler::decode((u_char*)code, (u_char*)code_end, tty);
440 }
441
442 // Measure cache line size.
443 memset(test_area, 0xFF, BUFFER_SIZE); // Fill test area with 0xFF.
444 (*zero_cacheline_func_ptr)(mid_of_test_area); // Call function which executes dcbz to the middle.
445 int count = 0; // count zeroed bytes
446 for (int i = 0; i < BUFFER_SIZE; i++) if (test_area[i] == 0) count++;
447 guarantee(is_power_of_2(count), "cache line size needs to be a power of 2");
448 _measured_cache_line_size = count;
449
450 // Execute code. Illegal instructions will be replaced by 0 in the signal handler.
451 VM_Version::_is_determine_features_test_running = true;
452 (*test)((address)mid_of_test_area, (uint64_t)0);
453 VM_Version::_is_determine_features_test_running = false;
454
455 // determine which instructions are legal.
456 int feature_cntr = 0;
457 if (code[feature_cntr++]) features |= fsqrt_m;
458 if (code[feature_cntr++]) features |= fsqrts_m;
459 if (code[feature_cntr++]) features |= isel_m;
460 if (code[feature_cntr++]) features |= lxarxeh_m;
461 if (code[feature_cntr++]) features |= cmpb_m;
462 //if(code[feature_cntr++])features |= mftgpr_m;
463 if (code[feature_cntr++]) features |= popcntb_m;
464 if (code[feature_cntr++]) features |= popcntw_m;
465 if (code[feature_cntr++]) features |= fcfids_m;
466 if (code[feature_cntr++]) features |= vand_m;
467
468 // Print the detection code.
469 if (PrintAssembly) {
470 ttyLocker ttyl;
471 tty->print_cr("Decoding cpu-feature detection stub at " INTPTR_FORMAT " after execution:", p2i(code));
472 Disassembler::decode((u_char*)code, (u_char*)code_end, tty);
473 }
474
475 _features = features;
476 }
477
478
479 static int saved_features = 0;
480
481 void VM_Version::allow_all() {
482 saved_features = _features;
483 _features = all_features_m;
484 }
485
486 void VM_Version::revert() {
487 _features = saved_features;
488 }
|