Skip to content

Commit

Permalink
Only arity 0 print accesses $_
Browse files Browse the repository at this point in the history
We can reduce this deoptimization to when print is called with no
arguments. Other forms do not need access to $_.
  • Loading branch information
headius committed May 21, 2024
1 parent 309ef8d commit b5f94a9
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions core/src/main/java/org/jruby/ir/instructions/CallBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,14 @@ private void captureFrameReadsAndWrites() {
frameWrites = ALL;
}
} else {
// special cases
if (getId().equals("print") && argsCount != 0) {
// only arity 0 print requirest access to LASTLINE
frameReads = Collections.EMPTY_SET;
frameWrites = Collections.EMPTY_SET;
return;
}

frameReads = MethodIndex.METHOD_FRAME_READS.getOrDefault(getId(), Collections.EMPTY_SET);
frameWrites = MethodIndex.METHOD_FRAME_WRITES.getOrDefault(getId(), Collections.EMPTY_SET);
}
Expand Down

0 comments on commit b5f94a9

Please sign in to comment.