Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 3a88f098d8bf^
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: a4e148da0017
Choose a head ref
  • 2 commits
  • 4 files changed
  • 1 contributor

Commits on Mar 14, 2017

  1. also treat NONE eval-type as a (thread-local) null when its set

    this is a follow-up on 0badff8 (from #4215)
    
    resolves #4529
    kares committed Mar 14, 2017
    Copy the full SHA
    3a88f09 View commit details
  2. introduce getEvalType on BlockBody (there's setter already)

    ... so that Block does not need to check for IRBlockBody impl
    kares committed Mar 14, 2017
    Copy the full SHA
    a4e148d View commit details
6 changes: 2 additions & 4 deletions core/src/main/java/org/jruby/runtime/Block.java
Original file line number Diff line number Diff line change
@@ -103,15 +103,13 @@ public DynamicScope allocScope(DynamicScope parentScope) {
//
// FIXME: Rather than modify static-scope, it seems we ought to set a field in block-body which is then
// used to tell dynamic-scope that it is a dynamic scope for a thread body. Anyway, to be revisited later!
EvalType evalType = ((IRBlockBody)body).getEvalType();
DynamicScope newScope = DynamicScope.newDynamicScope(body.getStaticScope(), parentScope, evalType);
DynamicScope newScope = DynamicScope.newDynamicScope(body.getStaticScope(), parentScope, body.getEvalType());
if (type == Block.Type.LAMBDA) newScope.setLambda(true);
return newScope;
}

public EvalType getEvalType() {
// SSS FIXME: This is smelly
return body instanceof IRBlockBody ? ((IRBlockBody)body).getEvalType() : null;
return body.getEvalType();
}

public void setEvalType(EvalType evalType) {
5 changes: 5 additions & 0 deletions core/src/main/java/org/jruby/runtime/BlockBody.java
Original file line number Diff line number Diff line change
@@ -60,7 +60,12 @@ public Signature getSignature() {
return signature;
}

public EvalType getEvalType() {
return null; // method should be abstract - isn't due compatibility
}

public void setEvalType(EvalType evalType) {
// NOOP - but "real" block bodies should track their eval-type
}

public boolean canCallDirect() {
9 changes: 7 additions & 2 deletions core/src/main/java/org/jruby/runtime/IRBlockBody.java
Original file line number Diff line number Diff line change
@@ -29,8 +29,13 @@ public final EvalType getEvalType() {
return type == null ? EvalType.NONE : type;
}

public void setEvalType(EvalType evalType) {
this.evalType.set(evalType);
public void setEvalType(final EvalType type) {
if (type == null || type == EvalType.NONE) {
this.evalType.remove();
}
else {
this.evalType.set(type);
}
}

@Override
Original file line number Diff line number Diff line change
@@ -40,7 +40,7 @@ public MixedModeIRBlockBody(IRClosure closure, Signature signature) {

@Override
public void setEvalType(EvalType evalType) {
if (jittedBody == null) this.evalType.set(evalType);
if (jittedBody == null) super.setEvalType(evalType);
else jittedBody.setEvalType(evalType);
}