Skip to content

Commit

Permalink
Whenever we request to build a closure we will build back to top most…
Browse files Browse the repository at this point in the history
… variable scope (also known as hard scope)
  • Loading branch information
enebo committed Dec 16, 2016
1 parent 131e748 commit 70d4921
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
2 changes: 2 additions & 0 deletions core/src/main/java/org/jruby/compiler/FullBuildTask.java
Expand Up @@ -16,6 +16,8 @@ class FullBuildTask implements Runnable {

public void run() {
try {
method.getIRScope().getTopLevelScope().prepareFullBuild();

method.completeBuild(method.getIRScope().prepareFullBuild());

if (jitCompiler.config.isJitLogging()) {
Expand Down
8 changes: 8 additions & 0 deletions core/src/main/java/org/jruby/ir/IRScope.java
Expand Up @@ -562,6 +562,10 @@ public synchronized FullInterpreterContext prepareFullBuild() {
// or generated instructions.
if (fullInterpreterContext != null && fullInterpreterContext.buildComplete()) return fullInterpreterContext;

for (IRScope scope: getClosures()) {
scope.prepareFullBuild();
}

prepareFullBuildCommon();
runCompilerPasses(getManager().getCompilerPasses(this));
getManager().optimizeIfSimpleScope(this);
Expand All @@ -581,6 +585,10 @@ public synchronized BasicBlock[] prepareForCompilation() {
// or generated instructions.
if (fullInterpreterContext != null && fullInterpreterContext.buildComplete()) return fullInterpreterContext.getLinearizedBBList();

for (IRScope scope: getClosures()) {
scope.prepareForCompilation();
}

prepareFullBuildCommon();

runCompilerPasses(getManager().getJITPasses(this));
Expand Down
Expand Up @@ -166,7 +166,7 @@ protected void promoteToFullBuild(ThreadContext context) {
if (callCount >= 0) {
// ensure we've got code ready for JIT
ensureInstrsReady();
closure.prepareForCompilation();
closure.getNearestTopLocalVariableScope().prepareForCompilation();

// if we don't have an explicit protocol, disable JIT
if (!closure.hasExplicitCallProtocol()) {
Expand Down

0 comments on commit 70d4921

Please sign in to comment.