bool ShortLoopOptimizer::process(BlockBegin* loop_header) { TRACE_VALUE_NUMBERING(tty->print_cr("** loop header block")); _too_complicated_loop = false; _loop_blocks.clear(); _loop_blocks.append(loop_header); for (int i = 0; i < _loop_blocks.length(); i++) { BlockBegin* block = _loop_blocks.at(i); TRACE_VALUE_NUMBERING(tty->print_cr("processing loop block B%d", block->block_id())); if (block->is_set(BlockBegin::exception_entry_flag)) { // this would be too complicated return false; } // add predecessors to worklist for (int j = block->number_of_preds() - 1; j >= 0; j--) { BlockBegin* pred = block->pred_at(j); if (pred->is_set(BlockBegin::osr_entry_flag)) { return false; } ValueMap* pred_map = value_map_of(pred); if (pred_map != NULL) { current_map()->kill_map(pred_map); } else if (!_loop_blocks.contains(pred)) { if (_loop_blocks.length() >= ValueMapMaxLoopSize) { return false; } _loop_blocks.append(pred); } } // use the instruction visitor for killing values for (Value instr = block->next(); instr != NULL; instr = instr->next()) { instr->visit(this); if (_too_complicated_loop) { return false; } } } bool optimistic = this->_gvn->compilation()->is_optimistic(); if (UseLoopInvariantCodeMotion && optimistic) { LoopInvariantCodeMotion code_motion(this, _gvn, loop_header, &_loop_blocks); } TRACE_VALUE_NUMBERING(tty->print_cr("** loop successfully optimized")); return true; }
void process_bin_file(char *file_name) { int seq = 0; FILE *fp = fopen(file_name, "rb"); if (!fp) { abort_("[read_bin_file] File %s cound not be opened for reading", file_name); } fseek(fp, 0, SEEK_END); long file_size = ftell(fp); if (file_size % BLOCK_SIZE) { abort_("[read_bin_file] File %s bad size", file_name); } fseek(fp, 0, SEEK_SET); Block block; block.resize(BLOCK_SIZE); BlockList blockList; for (int i=0; i<file_size/BLOCK_SIZE; ++i) { if (BLOCK_SIZE != fread(&(block.front()), 1, BLOCK_SIZE, fp)) { abort_("[read_bin_file] Fild %s read error", file_name); } if (0 == memcmp(&block.front(), FCC_TEX1, 4)) { if (!blockList.empty()) { ostringstream bc_file_name; bc_file_name << file_name << "-" << seq << ".bc"; write_bc_file(blockList, bc_file_name.str()); seq ++; blockList.clear(); } blockList.push_back(block); } else { blockList.push_back(block); } } fclose(fp); cout << "Done" << endl; }