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

Commits on May 12, 2015

  1. Copy the full SHA
    14ae2c4 View commit details
  2. Disable opttempvars for -X-C and JIT. The recent optimizations to fix…

    … multiple assignment
    
    does not work with opttempvars pass anymore.  In the scenario of:
    
      def s3e(y, d)
        y, d = d, y
        p y
      end
    
    s3e "23","1999"
    s3e "23","1999"
    
    jruby -X-C -Xjit.background=false -Xjit.threshold=1 ../snippets/date1.rb
    
    When full build occurs here we run LOP and then OTV. Instr.simplifyAndGetResult  will remove y and d
    from the literal rhs Array and replace masgn_required with a %t1 = copy(y); %t2 = copy(d).
    Now that it is in a copy assigning to a temp var OTV will propagate y and d but this removal
    of these intermediary copys ends up breaking the swap since we have created something like
    'y =d; d = y' so both values end up being d's value.
    
    This will affect -X-C performance in some cases (although fannkuch showed almost no difference on
    Java 8 but was 25% slower on Java 7).  JIT performance is not affected at all and I think this is
    because it converts to an SSA form internally so these extra temps emitted in bytecode really don't
    affect the end result.  I added a FIXME to look at addressing this for -X-C perf if it becomes
    important for other platforms like Android.
    enebo committed May 12, 2015
    Copy the full SHA
    e4ce268 View commit details
Showing with 8 additions and 9 deletions.
  1. +3 −1 core/src/main/java/org/jruby/ir/IRManager.java
  2. +5 −8 core/src/main/java/org/jruby/lexer/yacc/RubyLexer.java
4 changes: 3 additions & 1 deletion core/src/main/java/org/jruby/ir/IRManager.java
Original file line number Diff line number Diff line change
@@ -226,7 +226,9 @@ public Instr[] optimizeTemporaryVariablesIfEnabled(IRScope scope, Instr[] instrs
// This ensures that local opts aren't affected by RAW hazards.
(new LocalOptimizationPass()).runLocalOptsOnInstrArray(scope, instrs);
// FIXME: Make this check ir.passes and not run if ir.passes is set and does not contain opttempvars.
return OptimizeTempVarsPass.optimizeTmpVars(scope, instrs);
// FIXME: LOP + Opttempvars cannot cope with y,d = d,y it propagates the intermediate temp var away
//return OptimizeTempVarsPass.optimizeTmpVars(scope, instrs);
return instrs;
}

/**
13 changes: 5 additions & 8 deletions core/src/main/java/org/jruby/lexer/yacc/RubyLexer.java
Original file line number Diff line number Diff line change
@@ -385,6 +385,7 @@ public final void reset() {
parenNest = 0;
braceNest = 0;
tokp = 0;
ruby_sourceline = src.getLineOffset() - 1;
last_cr_line = -1;

parser_prepare();
@@ -483,10 +484,6 @@ public int column() {
return tokp - lex_pbeg;
}

public int lineno() {
return ruby_sourceline + src.getLineOffset() - 1;
}

public boolean was_bol() {
return lex_p == lex_pbeg + 1;
}
@@ -588,16 +585,16 @@ public Object value() {
}

public ISourcePosition getPosition() {
if (tokline != null && lineno() == tokline.getLine()) return tokline;
return new SimpleSourcePosition(src.getFilename(), lineno());
if (tokline != null && ruby_sourceline == tokline.getLine()) return tokline;
return new SimpleSourcePosition(src.getFilename(), ruby_sourceline);
}

public ISourcePosition getPosition(ISourcePosition startPosition) {
if (startPosition != null) return startPosition;

if (tokline != null && lineno() == tokline.getLine()) return tokline;
if (tokline != null && ruby_sourceline == tokline.getLine()) return tokline;

return new SimpleSourcePosition(src.getFilename(), lineno());
return new SimpleSourcePosition(src.getFilename(), ruby_sourceline);
}

public String getCurrentLine() {