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: a5e6a7b81e23
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 27504e2d3f1a
Choose a head ref
  • 2 commits
  • 6 files changed
  • 1 contributor

Commits on Mar 5, 2015

  1. New IRScope.{get,put}StoreLocalVarPlacementProblem. fic is only refer…

    …ences in IRScope now.
    enebo committed Mar 5, 2015
    Copy the full SHA
    2be82aa View commit details
  2. Copy the full SHA
    27504e2 View commit details
19 changes: 17 additions & 2 deletions core/src/main/java/org/jruby/ir/IRScope.java
Original file line number Diff line number Diff line change
@@ -3,9 +3,8 @@
import org.jruby.ParseResult;
import org.jruby.RubyInstanceConfig;
import org.jruby.RubyModule;
import org.jruby.ir.dataflow.DataFlowProblem;
import org.jruby.ir.dataflow.analyses.LiveVariablesProblem;
import org.jruby.ir.dataflow.analyses.UnboxableOpsAnalysisNode;
import org.jruby.ir.dataflow.analyses.StoreLocalVarPlacementProblem;
import org.jruby.ir.dataflow.analyses.UnboxableOpsAnalysisProblem;
import org.jruby.ir.instructions.*;
import org.jruby.ir.interpreter.FullInterpreterContext;
@@ -407,6 +406,22 @@ public LiveVariablesProblem getLiveVariablesProblem() {
return (LiveVariablesProblem) fullInterpreterContext.getDataFlowProblems().get(LiveVariablesProblem.NAME);
}

public void putStoreLocalVarPlacementProblem(StoreLocalVarPlacementProblem problem) {
// Technically this is if a pass is invalidated which has never run on a scope with no CFG/FIC yet.
if (fullInterpreterContext == null) {
// This should never trigger unless we got sloppy
if (problem != null) throw new IllegalStateException("StoreLocalVarPlacementProblem being stored when no FIC");
return;
}
fullInterpreterContext.getDataFlowProblems().put(StoreLocalVarPlacementProblem.NAME, problem);
}

public StoreLocalVarPlacementProblem getStoreLocalVarPlacementProblem() {
if (fullInterpreterContext == null) return null; // no fic so no pass-related info

return (StoreLocalVarPlacementProblem) fullInterpreterContext.getDataFlowProblems().get(UnboxableOpsAnalysisProblem.NAME);
}

public void putUnboxableOpsAnalysisProblem(UnboxableOpsAnalysisProblem problem) {
// Technically this is if a pass is invalidated which has never run on a scope with no CFG/FIC yet.
if (fullInterpreterContext == null) {
Original file line number Diff line number Diff line change
@@ -8,8 +8,6 @@
import org.jruby.ir.representations.BasicBlock;
import org.jruby.ir.representations.CFG;

import java.util.Arrays;
import java.util.List;
import java.util.ListIterator;

public class AddCallProtocolInstructions extends CompilerPass {
@@ -32,7 +30,7 @@ public Object execute(IRScope scope, Object... data) {
// If the scope uses $_ or $~ family of vars, has local load/stores, or if its binding has escaped, we have
// to allocate a dynamic scope for it and add binding push/pop instructions.
if (explicitCallProtocolSupported(scope)) {
StoreLocalVarPlacementProblem slvpp = (StoreLocalVarPlacementProblem)scope.getFullInterpreterContext().getDataFlowProblems().get(StoreLocalVarPlacementProblem.NAME);
StoreLocalVarPlacementProblem slvpp = scope.getStoreLocalVarPlacementProblem();
boolean scopeHasLocalVarStores = false;
boolean bindingHasEscaped = scope.bindingHasEscaped();

Original file line number Diff line number Diff line change
@@ -7,7 +7,6 @@
import org.jruby.ir.dataflow.analyses.StoreLocalVarPlacementProblem;
import org.jruby.ir.instructions.Instr;
import org.jruby.ir.operands.Operand;
import org.jruby.ir.operands.Variable;
import org.jruby.ir.representations.BasicBlock;

import java.util.Arrays;
@@ -70,20 +69,20 @@ public Object execute(IRScope s, Object... data) {
(new LiveVariableAnalysis()).invalidate(s);
}

s.getFullInterpreterContext().getDataFlowProblems().put(StoreLocalVarPlacementProblem.NAME, slvp);
s.putStoreLocalVarPlacementProblem(slvp);

return slvp;
}

@Override
public Object previouslyRun(IRScope scope) {
return scope.getFullInterpreterContext().getDataFlowProblems().get(StoreLocalVarPlacementProblem.NAME);
return scope.getStoreLocalVarPlacementProblem();
}

@Override
public boolean invalidate(IRScope scope) {
super.invalidate(scope);
scope.getFullInterpreterContext().getDataFlowProblems().put(StoreLocalVarPlacementProblem.NAME, null);
scope.putStoreLocalVarPlacementProblem(null);
return true;
}
}
Original file line number Diff line number Diff line change
@@ -9,9 +9,7 @@
import org.jruby.ir.representations.BasicBlock;
import org.jruby.ir.representations.CFG;

import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

public class EnsureTempsAssigned extends CompilerPass {
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
package org.jruby.ir.passes;

import org.jruby.ir.IRClosure;
import org.jruby.ir.IRScope;
import org.jruby.ir.Operation;
import org.jruby.ir.instructions.CopyInstr;
import org.jruby.ir.instructions.Instr;
import org.jruby.ir.instructions.ResultInstr;
import org.jruby.ir.operands.Operand;
import org.jruby.ir.operands.Variable;
import org.jruby.ir.representations.BasicBlock;
import org.jruby.ir.representations.CFG;

import java.util.*;

2 changes: 1 addition & 1 deletion core/src/main/ruby/jruby/jruby.rb
Original file line number Diff line number Diff line change
@@ -72,7 +72,7 @@ def compile(content = nil, filename = (default_filename = true; '-'), extra_posi
end

runtime = JRuby.runtime
irscope = org.jruby.ir.IRBuilder.build_root runtime.getIRManager(), node
irscope = org.jruby.ir.IRBuilder.build_root(runtime.getIRManager(), node).scope

visitor = org.jruby.ir.targets.JVMVisitor.new
bytes = visitor.compile_to_bytecode(irscope);