Skip to content

Commit

Permalink
Try using truly thread-local $~ and $_. No perf testing yet.
Browse files Browse the repository at this point in the history
For #3031.
headius committed Mar 10, 2016
1 parent 9169d68 commit def9c87
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions core/src/main/java/org/jruby/runtime/Frame.java
Original file line number Diff line number Diff line change
@@ -82,10 +82,10 @@ public final class Frame {
private Visibility visibility = Visibility.PUBLIC;

/** backref **/
private IRubyObject backRef;
private final ThreadLocal<IRubyObject> backRef = new ThreadLocal<>();

/** lastline **/
private IRubyObject lastLine;
private final ThreadLocal<IRubyObject> lastLine = new ThreadLocal<>();

/** whether this frame has been captured into a binding **/
private boolean captured;
@@ -188,8 +188,8 @@ public Frame clear() {
this.self = null;
this.klazz = null;
this.block = Block.NULL_BLOCK;
this.backRef = null;
this.lastLine = null;
this.backRef.remove();
this.lastLine.remove();

return this;
}
@@ -297,21 +297,23 @@ public Block getBlock() {
}

public IRubyObject getBackRef(IRubyObject nil) {
IRubyObject backRef = this.backRef;
IRubyObject backRef = this.backRef.get();
return backRef == null ? nil : backRef;
}

public IRubyObject setBackRef(IRubyObject backRef) {
return this.backRef = backRef;
this.backRef.set(backRef);
return backRef;
}

public IRubyObject getLastLine(IRubyObject nil) {
IRubyObject lastLine = this.lastLine;
IRubyObject lastLine = this.lastLine.get();
return lastLine == null ? nil : lastLine;
}

public IRubyObject setLastLine(IRubyObject lastLine) {
return this.lastLine = lastLine;
this.lastLine.set(lastLine);
return lastLine;
}

public void setCaptured(boolean captured) {

0 comments on commit def9c87

Please sign in to comment.