Skip to content

Commit

Permalink
Fix comments from aph
Browse files Browse the repository at this point in the history
  • Loading branch information
Fei Gao committed Nov 23, 2023
1 parent eea5610 commit 4637dd8
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions src/hotspot/share/opto/output.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,11 +169,10 @@ class Scheduling {
// Add a node to the current bundle
void AddNodeToBundle(Node *n, const Block *bb);

// Return true only when the stack offset of the first spill node is
// greater than the stack offset of the second one. Otherwise, return false.
// When compare_two_spill_nodes(first, second) returns true, we think that
// "second" should be scheduled before "first" in the final basic block.
bool compare_two_spill_nodes(Node* first, Node* second);
// Return an integer less than, equal to, or greater than zero
// if the stack offset of the first argument is respectively
// less than, equal to, or greater than the second.
int compare_two_spill_nodes(Node* first, Node* second);

// Add a node to the list of available nodes
void AddNodeToAvailableList(Node *n);
Expand Down Expand Up @@ -2277,7 +2276,7 @@ Node * Scheduling::ChooseNodeToBundle() {
return _available[0];
}

bool Scheduling::compare_two_spill_nodes(Node* first, Node* second) {
int Scheduling::compare_two_spill_nodes(Node* first, Node* second) {
assert(first->is_MachSpillCopy() && second->is_MachSpillCopy(), "");

OptoReg::Name first_src_lo = _regalloc->get_reg_first(first->in(1));
Expand All @@ -2288,16 +2287,16 @@ bool Scheduling::compare_two_spill_nodes(Node* first, Node* second) {
// Comparison between stack -> reg and stack -> reg
if (OptoReg::is_stack(first_src_lo) && OptoReg::is_stack(second_src_lo) &&
OptoReg::is_reg(first_dst_lo) && OptoReg::is_reg(second_dst_lo)) {
return _regalloc->reg2offset(first_src_lo) > _regalloc->reg2offset(second_src_lo);
return _regalloc->reg2offset(first_src_lo) - _regalloc->reg2offset(second_src_lo);
}

// Comparison between reg -> stack and reg -> stack
if (OptoReg::is_stack(first_dst_lo) && OptoReg::is_stack(second_dst_lo) &&
OptoReg::is_reg(first_src_lo) && OptoReg::is_reg(second_src_lo)) {
return _regalloc->reg2offset(first_dst_lo) > _regalloc->reg2offset(second_dst_lo);
return _regalloc->reg2offset(first_dst_lo) - _regalloc->reg2offset(second_dst_lo);
}

return false;
return 0; // Not comparable
}

void Scheduling::AddNodeToAvailableList(Node *n) {
Expand All @@ -2313,15 +2312,15 @@ void Scheduling::AddNodeToAvailableList(Node *n) {

// Insert in latency order (insertion sort). If two MachSpillCopyNodes
// for stack spilling or unspilling have the same latency, we sort
// them in the order of stack offset. Some backends (aarch64) may also
// them in the order of stack offset. Some ports (e.g. aarch64) may also
// have more opportunities to do ld/st merging
uint i;
for (i = 0; i < _available.size(); i++) {
if (_current_latency[_available[i]->_idx] > latency) {
break;
} else if (_current_latency[_available[i]->_idx] == latency &&
n->is_MachSpillCopy() && _available[i]->is_MachSpillCopy() &&
compare_two_spill_nodes(n, _available[i])) {
compare_two_spill_nodes(n, _available[i]) > 0) {
break;
}
}
Expand Down

0 comments on commit 4637dd8

Please sign in to comment.