@@ -410,8 +410,8 @@ static void merge_ranges(SwitchRange* ranges, int& rp) {
410410void Parse::do_tableswitch () {
411411 // Get information about tableswitch
412412 int default_dest = iter ().get_dest_table (0 );
413- int lo_index = iter ().get_int_table (1 );
414- int hi_index = iter ().get_int_table (2 );
413+ jint lo_index = iter ().get_int_table (1 );
414+ jint hi_index = iter ().get_int_table (2 );
415415 int len = hi_index - lo_index + 1 ;
416416
417417 if (len < 1 ) {
@@ -438,19 +438,19 @@ void Parse::do_tableswitch() {
438438 SwitchRange* ranges = NEW_RESOURCE_ARRAY (SwitchRange, rnum);
439439 int rp = -1 ;
440440 if (lo_index != min_jint) {
441- uint cnt = 1 ;
441+ float cnt = 1 . 0F ;
442442 if (profile != NULL ) {
443- cnt = profile->default_count () / (hi_index != max_jint ? 2 : 1 );
443+ cnt = ( float ) profile->default_count () / (hi_index != max_jint ? 2 . 0F : 1 . 0F );
444444 }
445445 ranges[++rp].setRange (min_jint, lo_index-1 , default_dest, cnt);
446446 }
447447 for (int j = 0 ; j < len; j++) {
448448 jint match_int = lo_index+j;
449449 int dest = iter ().get_dest_table (j+3 );
450450 makes_backward_branch |= (dest <= bci ());
451- uint cnt = 1 ;
451+ float cnt = 1 . 0F ;
452452 if (profile != NULL ) {
453- cnt = profile->count_at (j);
453+ cnt = ( float ) profile->count_at (j);
454454 }
455455 if (rp < 0 || !ranges[rp].adjoin (match_int, dest, cnt, trim_ranges)) {
456456 ranges[++rp].set (match_int, dest, cnt);
@@ -459,9 +459,9 @@ void Parse::do_tableswitch() {
459459 jint highest = lo_index+(len-1 );
460460 assert (ranges[rp].hi () == highest, " " );
461461 if (highest != max_jint) {
462- uint cnt = 1 ;
462+ float cnt = 1 . 0F ;
463463 if (profile != NULL ) {
464- cnt = profile->default_count () / (lo_index != min_jint ? 2 : 1 );
464+ cnt = ( float ) profile->default_count () / (lo_index != min_jint ? 2 . 0F : 1 . 0F );
465465 }
466466 if (!ranges[rp].adjoinRange (highest+1 , max_jint, default_dest, cnt, trim_ranges)) {
467467 ranges[++rp].setRange (highest+1 , max_jint, default_dest, cnt);
@@ -487,7 +487,7 @@ void Parse::do_tableswitch() {
487487void Parse::do_lookupswitch () {
488488 // Get information about lookupswitch
489489 int default_dest = iter ().get_dest_table (0 );
490- int len = iter ().get_int_table (1 );
490+ jint len = iter ().get_int_table (1 );
491491
492492 if (len < 1 ) { // If this is a backward branch, add safepoint
493493 maybe_add_safepoint (default_dest);
@@ -513,26 +513,15 @@ void Parse::do_lookupswitch() {
513513 table[3 *j+0 ] = iter ().get_int_table (2 +2 *j);
514514 table[3 *j+1 ] = iter ().get_dest_table (2 +2 *j+1 );
515515 // Handle overflow when converting from uint to jint
516- table[3 *j+2 ] = (profile == NULL ) ? 1 : MIN2<uint>(max_jint, profile->count_at (j));
516+ table[3 *j+2 ] = (profile == NULL ) ? 1 : (jint) MIN2<uint>((uint) max_jint, profile->count_at (j));
517517 }
518518 qsort (table, len, 3 *sizeof (table[0 ]), jint_cmp);
519519 }
520520
521- float defaults = 0 ;
522- jint prev = min_jint;
523- for (int j = 0 ; j < len; j++) {
524- jint match_int = table[3 *j+0 ];
525- if (match_int != prev) {
526- defaults += (float )match_int - prev;
527- }
528- prev = match_int+1 ;
529- }
530- if (prev != min_jint) {
531- defaults += (float )max_jint - prev + 1 ;
532- }
533- float default_cnt = 1 ;
521+ float default_cnt = 1 .0F ;
534522 if (profile != NULL ) {
535- default_cnt = profile->default_count ()/defaults;
523+ juint defaults = max_juint - len;
524+ default_cnt = (float )profile->default_count ()/(float )defaults;
536525 }
537526
538527 int rnum = len*2 +1 ;
@@ -541,25 +530,25 @@ void Parse::do_lookupswitch() {
541530 int rp = -1 ;
542531 for (int j = 0 ; j < len; j++) {
543532 jint match_int = table[3 *j+0 ];
544- int dest = table[3 *j+1 ];
545- int cnt = table[3 *j+2 ];
546- int next_lo = rp < 0 ? min_jint : ranges[rp].hi ()+1 ;
533+ jint dest = table[3 *j+1 ];
534+ jint cnt = table[3 *j+2 ];
535+ jint next_lo = rp < 0 ? min_jint : ranges[rp].hi ()+1 ;
547536 makes_backward_branch |= (dest <= bci ());
548- float c = default_cnt * ((float )match_int - next_lo);
537+ float c = default_cnt * ((float )match_int - ( float ) next_lo);
549538 if (match_int != next_lo && (rp < 0 || !ranges[rp].adjoinRange (next_lo, match_int-1 , default_dest, c, trim_ranges))) {
550539 assert (default_dest != never_reached, " sentinel value for dead destinations" );
551540 ranges[++rp].setRange (next_lo, match_int-1 , default_dest, c);
552541 }
553- if (rp < 0 || !ranges[rp].adjoin (match_int, dest, cnt, trim_ranges)) {
542+ if (rp < 0 || !ranges[rp].adjoin (match_int, dest, ( float ) cnt, trim_ranges)) {
554543 assert (dest != never_reached, " sentinel value for dead destinations" );
555- ranges[++rp].set (match_int, dest, cnt);
544+ ranges[++rp].set (match_int, dest, ( float ) cnt);
556545 }
557546 }
558547 jint highest = table[3 *(len-1 )];
559548 assert (ranges[rp].hi () == highest, " " );
560549 if (highest != max_jint &&
561- !ranges[rp].adjoinRange (highest+1 , max_jint, default_dest, default_cnt * ((float )max_jint - highest), trim_ranges)) {
562- ranges[++rp].setRange (highest+1 , max_jint, default_dest, default_cnt * ((float )max_jint - highest));
550+ !ranges[rp].adjoinRange (highest+1 , max_jint, default_dest, default_cnt * ((float )max_jint - ( float ) highest), trim_ranges)) {
551+ ranges[++rp].setRange (highest+1 , max_jint, default_dest, default_cnt * ((float )max_jint - ( float ) highest));
563552 }
564553 assert (rp < rnum, " not too many ranges" );
565554
0 commit comments