< prev index next >
hotspot/src/share/vm/c1/c1_LinearScan.cpp
Print this page
rev 10451 : imported patch s/find_from_end/find/g
*** 493,504 ****
for (i = 0; i < num_blocks; i++) {
num_instructions += block_at(i)->lir()->instructions_list()->length();
}
// initialize with correct length
! _lir_ops = LIR_OpArray(num_instructions);
! _block_of_op = BlockBeginArray(num_instructions);
int op_id = 0;
int idx = 0;
for (i = 0; i < num_blocks; i++) {
--- 493,504 ----
for (i = 0; i < num_blocks; i++) {
num_instructions += block_at(i)->lir()->instructions_list()->length();
}
// initialize with correct length
! _lir_ops = LIR_OpArray(num_instructions, num_instructions, NULL);
! _block_of_op = BlockBeginArray(num_instructions, num_instructions, NULL);
int op_id = 0;
int idx = 0;
for (i = 0; i < num_blocks; i++) {
*** 2504,2514 ****
LocationValue* _illegal_value = new (ResourceObj::C_HEAP, mtCompiler) LocationValue(Location());
void LinearScan::init_compute_debug_info() {
// cache for frequently used scope values
// (cpu registers and stack slots)
! _scope_value_cache = ScopeValueArray((LinearScan::nof_cpu_regs + frame_map()->argcount() + max_spills()) * 2, NULL);
}
MonitorValue* LinearScan::location_for_monitor_index(int monitor_index) {
Location loc;
if (!frame_map()->location_for_monitor_object(monitor_index, &loc)) {
--- 2504,2515 ----
LocationValue* _illegal_value = new (ResourceObj::C_HEAP, mtCompiler) LocationValue(Location());
void LinearScan::init_compute_debug_info() {
// cache for frequently used scope values
// (cpu registers and stack slots)
! int cache_size = (LinearScan::nof_cpu_regs + frame_map()->argcount() + max_spills()) * 2;
! _scope_value_cache = ScopeValueArray(cache_size, cache_size, NULL);
}
MonitorValue* LinearScan::location_for_monitor_index(int monitor_index) {
Location loc;
if (!frame_map()->location_for_monitor_object(monitor_index, &loc)) {
*** 3039,3049 ****
instructions->at_put(insert_point, op);
}
insert_point++;
}
}
! instructions->truncate(insert_point);
}
}
void LinearScan::assign_reg_num() {
TIME_LINEAR_SCAN(timer_assign_reg_num);
--- 3040,3050 ----
instructions->at_put(insert_point, op);
}
insert_point++;
}
}
! instructions->trunc_to(insert_point);
}
}
void LinearScan::assign_reg_num() {
TIME_LINEAR_SCAN(timer_assign_reg_num);
*** 3443,3453 ****
public:
RegisterVerifier(LinearScan* allocator)
: _allocator(allocator)
, _work_list(16)
! , _saved_states(BlockBegin::number_of_blocks(), NULL)
{ }
void verify(BlockBegin* start);
};
--- 3444,3454 ----
public:
RegisterVerifier(LinearScan* allocator)
: _allocator(allocator)
, _work_list(16)
! , _saved_states(BlockBegin::number_of_blocks(), BlockBegin::number_of_blocks(), NULL)
{ }
void verify(BlockBegin* start);
};
*** 4449,4459 ****
int i;
for (i = start_idx + 2; i < total_len; i++) {
new_use_pos_and_kinds.append(_use_pos_and_kinds.at(i));
}
! _use_pos_and_kinds.truncate(start_idx + 2);
result->_use_pos_and_kinds = _use_pos_and_kinds;
_use_pos_and_kinds = new_use_pos_and_kinds;
#ifdef ASSERT
assert(_use_pos_and_kinds.length() % 2 == 0, "must have use kind for each use pos");
--- 4450,4460 ----
int i;
for (i = start_idx + 2; i < total_len; i++) {
new_use_pos_and_kinds.append(_use_pos_and_kinds.at(i));
}
! _use_pos_and_kinds.trunc_to(start_idx + 2);
result->_use_pos_and_kinds = _use_pos_and_kinds;
_use_pos_and_kinds = new_use_pos_and_kinds;
#ifdef ASSERT
assert(_use_pos_and_kinds.length() % 2 == 0, "must have use kind for each use pos");
*** 5537,5547 ****
if (regHi != any_reg) {
IntervalList* processed = _spill_intervals[reg];
for (int i = 0; i < _spill_intervals[regHi]->length(); i++) {
Interval* it = _spill_intervals[regHi]->at(i);
! if (processed->find_from_end(it) == -1) {
remove_from_list(it);
split_and_spill_interval(it);
}
}
}
--- 5538,5548 ----
if (regHi != any_reg) {
IntervalList* processed = _spill_intervals[reg];
for (int i = 0; i < _spill_intervals[regHi]->length(); i++) {
Interval* it = _spill_intervals[regHi]->at(i);
! if (processed->find(it) == -1) {
remove_from_list(it);
split_and_spill_interval(it);
}
}
}
*** 6208,6218 ****
// predecessor list is necessary
int j;
_original_preds.clear();
for (j = block->number_of_preds() - 1; j >= 0; j--) {
BlockBegin* pred = block->pred_at(j);
! if (_original_preds.index_of(pred) == -1) {
_original_preds.append(pred);
}
}
for (j = _original_preds.length() - 1; j >= 0; j--) {
--- 6209,6219 ----
// predecessor list is necessary
int j;
_original_preds.clear();
for (j = block->number_of_preds() - 1; j >= 0; j--) {
BlockBegin* pred = block->pred_at(j);
! if (_original_preds.find(pred) == -1) {
_original_preds.append(pred);
}
}
for (j = _original_preds.length() - 1; j >= 0; j--) {
*** 6228,6238 ****
}
new_pos++;
}
old_pos++;
}
! code->truncate(new_pos);
DEBUG_ONLY(verify(code));
}
void ControlFlowOptimizer::delete_unnecessary_jumps(BlockList* code) {
--- 6229,6239 ----
}
new_pos++;
}
old_pos++;
}
! code->trunc_to(new_pos);
DEBUG_ONLY(verify(code));
}
void ControlFlowOptimizer::delete_unnecessary_jumps(BlockList* code) {
*** 6253,6263 ****
if (last_branch->block() == code->at(i + 1)) {
TRACE_LINEAR_SCAN(3, tty->print_cr("Deleting unconditional branch at end of block B%d", block->block_id()));
// delete last branch instruction
! instructions->truncate(instructions->length() - 1);
} else {
LIR_Op* prev_op = instructions->at(instructions->length() - 2);
if (prev_op->code() == lir_branch || prev_op->code() == lir_cond_float_branch) {
assert(prev_op->as_OpBranch() != NULL, "branch must be of type LIR_OpBranch");
--- 6254,6264 ----
if (last_branch->block() == code->at(i + 1)) {
TRACE_LINEAR_SCAN(3, tty->print_cr("Deleting unconditional branch at end of block B%d", block->block_id()));
// delete last branch instruction
! instructions->trunc_to(instructions->length() - 1);
} else {
LIR_Op* prev_op = instructions->at(instructions->length() - 2);
if (prev_op->code() == lir_branch || prev_op->code() == lir_cond_float_branch) {
assert(prev_op->as_OpBranch() != NULL, "branch must be of type LIR_OpBranch");
*** 6292,6302 ****
// eliminate a conditional branch to the immediate successor
prev_branch->change_block(last_branch->block());
prev_branch->negate_cond();
prev_cmp->set_condition(prev_branch->cond());
! instructions->truncate(instructions->length() - 1);
// if we do change the condition, we have to change the cmove as well
if (prev_cmove != NULL) {
prev_cmove->set_condition(prev_branch->cond());
LIR_Opr t = prev_cmove->in_opr1();
prev_cmove->set_in_opr1(prev_cmove->in_opr2());
--- 6293,6303 ----
// eliminate a conditional branch to the immediate successor
prev_branch->change_block(last_branch->block());
prev_branch->negate_cond();
prev_cmp->set_condition(prev_branch->cond());
! instructions->trunc_to(instructions->length() - 1);
// if we do change the condition, we have to change the cmove as well
if (prev_cmove != NULL) {
prev_cmove->set_condition(prev_branch->cond());
LIR_Opr t = prev_cmove->in_opr1();
prev_cmove->set_in_opr1(prev_cmove->in_opr2());
*** 6375,6397 ****
int j;
for (j = 0; j < instructions->length(); j++) {
LIR_OpBranch* op_branch = instructions->at(j)->as_OpBranch();
if (op_branch != NULL) {
! assert(op_branch->block() == NULL || code->index_of(op_branch->block()) != -1, "branch target not valid");
! assert(op_branch->ublock() == NULL || code->index_of(op_branch->ublock()) != -1, "branch target not valid");
}
}
for (j = 0; j < block->number_of_sux() - 1; j++) {
BlockBegin* sux = block->sux_at(j);
! assert(code->index_of(sux) != -1, "successor not valid");
}
for (j = 0; j < block->number_of_preds() - 1; j++) {
BlockBegin* pred = block->pred_at(j);
! assert(code->index_of(pred) != -1, "successor not valid");
}
}
}
#endif
--- 6376,6398 ----
int j;
for (j = 0; j < instructions->length(); j++) {
LIR_OpBranch* op_branch = instructions->at(j)->as_OpBranch();
if (op_branch != NULL) {
! assert(op_branch->block() == NULL || code->find(op_branch->block()) != -1, "branch target not valid");
! assert(op_branch->ublock() == NULL || code->find(op_branch->ublock()) != -1, "branch target not valid");
}
}
for (j = 0; j < block->number_of_sux() - 1; j++) {
BlockBegin* sux = block->sux_at(j);
! assert(code->find(sux) != -1, "successor not valid");
}
for (j = 0; j < block->number_of_preds() - 1; j++) {
BlockBegin* pred = block->pred_at(j);
! assert(code->find(pred) != -1, "successor not valid");
}
}
}
#endif
< prev index next >