size_t ParMarkBitMap::live_words_in_range(HeapWord* beg_addr, HeapWord* end_addr) const { assert(beg_addr <= end_addr, "bad range"); idx_t live_bits = 0; // The bitmap routines require the right boundary to be word-aligned. const idx_t end_bit = addr_to_bit(end_addr); const idx_t range_end = BitMap::word_align_up(end_bit); idx_t beg_bit = find_obj_beg(addr_to_bit(beg_addr), range_end); while (beg_bit < end_bit) { idx_t tmp_end = find_obj_end(beg_bit, range_end); if (tmp_end < end_bit) { live_bits += tmp_end - beg_bit + 1; beg_bit = find_obj_beg(tmp_end + 1, range_end); } else { live_bits += end_bit - beg_bit; // No + 1 here; end_bit is not counted. return bits_to_words(live_bits); } } return bits_to_words(live_bits); }
size_t ParMarkBitMap::live_words_in_range(HeapWord* beg_addr, oop end_obj) const { assert(beg_addr <= (HeapWord*)end_obj, "bad range"); assert(is_marked(end_obj), "end_obj must be live"); idx_t live_bits = 0; // The bitmap routines require the right boundary to be word-aligned. const idx_t end_bit = addr_to_bit((HeapWord*)end_obj); const idx_t range_end = BitMap::word_align_up(end_bit); idx_t beg_bit = find_obj_beg(addr_to_bit(beg_addr), range_end); while (beg_bit < end_bit) { idx_t tmp_end = find_obj_end(beg_bit, range_end); assert(tmp_end < end_bit, "missing end bit"); live_bits += tmp_end - beg_bit + 1; beg_bit = find_obj_beg(tmp_end + 1, range_end); } return bits_to_words(live_bits); }
void initialize_bit_table(gc_bit_table* table, long bit_count) { table->bits = (os_word*)calloc(bits_to_words(bit_count), sizeof(os_word)); table->bit_count = bit_count; }
void clear_bit_table(gc_bit_table* table) { os_word table_bytes = bits_to_words(table->bit_count) * sizeof(os_word); memset(table->bits, 0, table_bytes); }
void encoder(Word16 number_of_available_bits, Word16 number_of_regions, Word16 *mlt_coefs, Word16 mag_shift, Word16 *out_words) { Word16 num_categorization_control_bits; Word16 num_categorization_control_possibilities; Word16 number_of_bits_per_frame; Word16 number_of_envelope_bits; Word16 categorization_control; Word16 region; Word16 absolute_region_power_index[MAX_NUMBER_OF_REGIONS]; Word16 power_categories[MAX_NUMBER_OF_REGIONS]; Word16 category_balances[MAX_NUM_CATEGORIZATION_CONTROL_POSSIBILITIES-1]; Word16 drp_num_bits[MAX_NUMBER_OF_REGIONS+1]; UWord16 drp_code_bits[MAX_NUMBER_OF_REGIONS+1]; Word16 region_mlt_bit_counts[MAX_NUMBER_OF_REGIONS]; UWord32 region_mlt_bits[4*MAX_NUMBER_OF_REGIONS]; Word16 mag_shift_offset; Word16 temp; /* initialize variables */ test(); if (number_of_regions == NUMBER_OF_REGIONS) { num_categorization_control_bits = NUM_CATEGORIZATION_CONTROL_BITS; move16(); num_categorization_control_possibilities = NUM_CATEGORIZATION_CONTROL_POSSIBILITIES; move16(); } else { num_categorization_control_bits = MAX_NUM_CATEGORIZATION_CONTROL_BITS; move16(); num_categorization_control_possibilities = MAX_NUM_CATEGORIZATION_CONTROL_POSSIBILITIES; move16(); } number_of_bits_per_frame = number_of_available_bits; move16(); for (region=0; region<number_of_regions; region++) { region_mlt_bit_counts[region] = 0; move16(); } /* Estimate power envelope. */ number_of_envelope_bits = compute_region_powers(mlt_coefs, mag_shift, drp_num_bits, drp_code_bits, absolute_region_power_index, number_of_regions); /* Adjust number of available bits based on power envelope estimate */ temp = sub(number_of_available_bits,number_of_envelope_bits); number_of_available_bits = sub(temp,num_categorization_control_bits); /* get categorizations */ categorize(number_of_available_bits, number_of_regions, num_categorization_control_possibilities, absolute_region_power_index, power_categories, category_balances); /* Adjust absolute_region_category_index[] for mag_shift. This assumes that REGION_POWER_STEPSIZE_DB is defined to be exactly 3.010299957 or 20.0 times log base 10 of square root of 2. */ temp = shl_nocheck(mag_shift,1); mag_shift_offset = add(temp,REGION_POWER_TABLE_NUM_NEGATIVES); for (region=0; region<number_of_regions; region++) { absolute_region_power_index[region] = add(absolute_region_power_index[region],mag_shift_offset); move16(); } /* adjust the absolute power region index based on the mlt coefs */ adjust_abs_region_power_index(absolute_region_power_index,mlt_coefs,number_of_regions); /* quantize and code the mlt coefficients based on categorizations */ vector_quantize_mlts(number_of_available_bits, number_of_regions, num_categorization_control_possibilities, mlt_coefs, absolute_region_power_index, power_categories, category_balances, &categorization_control, region_mlt_bit_counts, region_mlt_bits); /* stuff bits into words */ bits_to_words(region_mlt_bits, region_mlt_bit_counts, drp_num_bits, drp_code_bits, out_words, categorization_control, number_of_regions, num_categorization_control_bits, number_of_bits_per_frame); }