Skip to content

Commit

Permalink
Make IRScope know if it has optimized it's temp vars
Browse files Browse the repository at this point in the history
  • Loading branch information
enebo committed Oct 7, 2014
1 parent 8071211 commit 0f9cb24
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
1 change: 1 addition & 0 deletions core/src/main/java/org/jruby/ir/IRFlags.java
Expand Up @@ -44,6 +44,7 @@ public enum IRFlags {
HAS_EXPLICIT_CALL_PROTOCOL, // contains call protocol instrs. if so we don't need to manage bindings frame implicitly.
HAS_LOOPS, // has a loop
HAS_NONLOCAL_RETURNS, // has a non-local return
HAS_OPTIMIZED_TEMPORARY_VARIABLES, // we simplified number of temp vars (before CFG was built). we can only do once.
HAS_UNUSED_IMPLICIT_BLOCK_ARG,// Is %block implicit block arg unused?
RECEIVES_CLOSURE_ARG, // This scope (or parent receives a closure
RECEIVES_KEYWORD_ARGS, // receives keyword args
Expand Down
8 changes: 8 additions & 0 deletions core/src/main/java/org/jruby/ir/IRScope.java
Expand Up @@ -400,6 +400,14 @@ public boolean isNestedInClosure(IRClosure closure) {
return false;
}

public boolean hasHasOptimizedTemporaryVariables() {
return flags.contains(HAS_OPTIMIZED_TEMPORARY_VARIABLES);
}

public void setHasOptimizedTemporaryVariables() {
flags.add(HAS_OPTIMIZED_TEMPORARY_VARIABLES);
}

public void setHasLoopsFlag() {
flags.add(HAS_LOOPS);
}
Expand Down
Expand Up @@ -10,8 +10,6 @@
import java.util.*;

public class OptimizeTempVarsPass extends CompilerPass {
boolean optimizedTempVars = false;

@Override
public String getLabel() {
return "Temporary Variable Reduction";
Expand All @@ -25,14 +23,14 @@ public Object execute(IRScope s, Object... data) {

optimizeTmpVars(s);

optimizedTempVars = true;
s.hasHasOptimizedTemporaryVariables();

return null;
}

@Override
public Object previouslyRun(IRScope scope) {
return optimizedTempVars ? new Object() : null;
return scope.hasHasOptimizedTemporaryVariables();
}

@Override
Expand Down

0 comments on commit 0f9cb24

Please sign in to comment.