Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into truffle-head
Browse files Browse the repository at this point in the history
  • Loading branch information
eregon committed Mar 10, 2016
2 parents 88e39cf + 9b1ae22 commit 0bd7fa2
Show file tree
Hide file tree
Showing 11 changed files with 41 additions and 85 deletions.
2 changes: 0 additions & 2 deletions appveyor.yml
Expand Up @@ -4,8 +4,6 @@ build: off

environment:
matrix:
- JAVA_HOME: C:\Program Files\Java\jdk1.7.0
- JAVA_HOME: C:\Program Files (x86)\Java\jdk1.7.0
- JAVA_HOME: C:\Program Files\Java\jdk1.8.0
- JAVA_HOME: C:\Program Files (x86)\Java\jdk1.8.0

Expand Down
8 changes: 4 additions & 4 deletions core/pom.rb
Expand Up @@ -42,12 +42,12 @@

# exclude jnr-ffi to avoid problems with shading and relocation of the asm packages
jar 'com.github.jnr:jnr-netdb:1.1.5', :exclusions => ['com.github.jnr:jnr-ffi']
jar 'com.github.jnr:jnr-enxio:0.11', :exclusions => ['com.github.jnr:jnr-ffi']
jar 'com.github.jnr:jnr-enxio:0.12', :exclusions => ['com.github.jnr:jnr-ffi']
jar 'com.github.jnr:jnr-x86asm:1.0.2', :exclusions => ['com.github.jnr:jnr-ffi']
jar 'com.github.jnr:jnr-unixsocket:0.11', :exclusions => ['com.github.jnr:jnr-ffi']
jar 'com.github.jnr:jnr-posix:3.0.28', :exclusions => ['com.github.jnr:jnr-ffi']
jar 'com.github.jnr:jnr-unixsocket:0.12', :exclusions => ['com.github.jnr:jnr-ffi']
jar 'com.github.jnr:jnr-posix:3.0.29', :exclusions => ['com.github.jnr:jnr-ffi']
jar 'com.github.jnr:jnr-constants:0.9.1', :exclusions => ['com.github.jnr:jnr-ffi']
jar 'com.github.jnr:jnr-ffi:2.0.8'
jar 'com.github.jnr:jnr-ffi:2.0.9'
jar 'com.github.jnr:jffi:${jffi.version}'
jar 'com.github.jnr:jffi:${jffi.version}:native'

Expand Down
8 changes: 4 additions & 4 deletions core/pom.xml
Expand Up @@ -103,7 +103,7 @@ DO NOT MODIFIY - GENERATED CODE
<dependency>
<groupId>com.github.jnr</groupId>
<artifactId>jnr-enxio</artifactId>
<version>0.11</version>
<version>0.12</version>
<exclusions>
<exclusion>
<artifactId>jnr-ffi</artifactId>
Expand All @@ -125,7 +125,7 @@ DO NOT MODIFIY - GENERATED CODE
<dependency>
<groupId>com.github.jnr</groupId>
<artifactId>jnr-unixsocket</artifactId>
<version>0.11</version>
<version>0.12</version>
<exclusions>
<exclusion>
<artifactId>jnr-ffi</artifactId>
Expand All @@ -136,7 +136,7 @@ DO NOT MODIFIY - GENERATED CODE
<dependency>
<groupId>com.github.jnr</groupId>
<artifactId>jnr-posix</artifactId>
<version>3.0.28</version>
<version>3.0.29</version>
<exclusions>
<exclusion>
<artifactId>jnr-ffi</artifactId>
Expand All @@ -158,7 +158,7 @@ DO NOT MODIFIY - GENERATED CODE
<dependency>
<groupId>com.github.jnr</groupId>
<artifactId>jnr-ffi</artifactId>
<version>2.0.8</version>
<version>2.0.9</version>
</dependency>
<dependency>
<groupId>com.github.jnr</groupId>
Expand Down
14 changes: 1 addition & 13 deletions core/src/main/java/org/jruby/ir/IRManager.java
Expand Up @@ -30,7 +30,7 @@
public class IRManager {
public static final String SAFE_COMPILER_PASSES = "";
public static final String DEFAULT_BUILD_PASSES = "";
public static final String DEFAULT_JIT_PASSES = "OptimizeDelegationPass,DeadCodeElimination,AddLocalVarLoadStoreInstructions,OptimizeDynScopesPass,AddCallProtocolInstructions,EnsureTempsAssigned";
public static final String DEFAULT_JIT_PASSES = "LocalOptimizationPass,OptimizeDelegationPass,DeadCodeElimination,AddLocalVarLoadStoreInstructions,OptimizeDynScopesPass,AddCallProtocolInstructions,EnsureTempsAssigned";
public static final String DEFAULT_INLINING_COMPILER_PASSES = "LocalOptimizationPass";

private final CompilerPass deadCodeEliminationPass = new DeadCodeElimination();
Expand All @@ -53,7 +53,6 @@ public class IRManager {
private InstructionsListener instrsListener = null;
private IRScopeListener irScopeListener = null;


// FIXME: Eventually make these attrs into either a) set b) part of state machine
private List<CompilerPass> compilerPasses;
private List<CompilerPass> inliningCompilerPasses;
Expand Down Expand Up @@ -266,17 +265,6 @@ public TemporaryLocalVariable newTemporaryLocalVariable(int index) {
return tempVar;
}

public Instr[] optimizeTemporaryVariablesIfEnabled(IRScope scope, Instr[] instrs) {
// Local opts don't move instrs across basic-block boundaries
// and are safe to run before the opt-tmp-vars pass.
// 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.
// FIXME: LOP + Opttempvars cannot cope with y,d = d,y it propagates the intermediate temp var away
//return OptimizeTempVarsPass.optimizeTmpVars(scope, instrs);
return instrs;
}

/**
* For scopes that don't require a dynamic scope we can run DCE and some other passes which cannot
* be stymied by escaped bindings.
Expand Down
11 changes: 2 additions & 9 deletions core/src/main/java/org/jruby/ir/IRScope.java
Expand Up @@ -482,7 +482,6 @@ protected boolean isUnsafeScope() {
}

public List<CompilerPass> getExecutedPasses() {
// FIXME: Super annoying...because OptimizeTempVars is a pre-CFG pass we have no full build info yet
return fullInterpreterContext == null ? new ArrayList<CompilerPass>(1) : fullInterpreterContext.getExecutedPasses();
}

Expand Down Expand Up @@ -550,15 +549,9 @@ private void prepareFullBuildCommon() {

// Clone instrs from startup interpreter so we do not swap out instrs out from under the
// startup interpreter as we are building the full interpreter.
Instr[] instrs = cloneInstrs();

// This is a complicating pseudo-pass which needs to be run before CFG is generated. This
// necessitates us needing a clonedInstrs field on IRScope. If we can rewrite this to a full
// CFG using pass we can eliminate this intermediate save and field.
instrs = getManager().optimizeTemporaryVariablesIfEnabled(this, instrs);

fullInterpreterContext = new FullInterpreterContext(this, instrs);
fullInterpreterContext = new FullInterpreterContext(this, cloneInstrs());
}

/**
* This initializes a more complete(full) InterpreterContext which if used in mixed mode will be
* used by the JIT and if used in pure-interpreted mode it will be used by an interpreter engine.
Expand Down
Expand Up @@ -159,7 +159,7 @@ private void markLocalVariables(Collection<Variable> varsToBox, Set<Variable> va
}
}

private void updateUnboxedVarsInfo(Instr i, UnboxState state, Variable dst, boolean hasRescuer, boolean isDFBarrier) {
private void updateUnboxedVarsInfoForBoxedInstr(Instr i, UnboxState state, Variable dst, boolean hasRescuer, boolean isDFBarrier) {
HashSet<Variable> varsToBox = new HashSet<Variable>();

// Special treatment for instructions that can raise exceptions
Expand Down Expand Up @@ -188,6 +188,7 @@ private void updateUnboxedVarsInfo(Instr i, UnboxState state, Variable dst, bool

// We have to re-unbox all local variables (dirty or not) as necessary since
// we don't know how they are going to change once we get past this instruction.
// Temp vars can continue in their unboxed state, even if dirty.
List<Variable> lvs = new ArrayList<Variable>();
markLocalVariables(lvs, state.unboxedVars.keySet());
state.unboxedVars.keySet().removeAll(lvs);
Expand Down Expand Up @@ -331,7 +332,7 @@ public void applyTransferFunction(Instr i) {
} else {
// Since the instruction didn't run in unboxed form,
// dirty unboxed vars will have to get boxed here.
updateUnboxedVarsInfo(i, tmpState, dst, hasExceptionsRescued(), hitDFBarrier);
updateUnboxedVarsInfoForBoxedInstr(i, tmpState, dst, hasExceptionsRescued(), hitDFBarrier);
}
}

Expand Down

This file was deleted.

6 changes: 4 additions & 2 deletions core/src/main/java/org/jruby/ir/operands/Hash.java
Expand Up @@ -63,8 +63,10 @@ public boolean hasKnownValue() {
public Operand getSimplifiedOperand(Map<Operand, Operand> valueMap, boolean force) {
List<KeyValuePair<Operand, Operand>> newPairs = new java.util.ArrayList<>();
for (KeyValuePair<Operand, Operand> pair : pairs) {
newPairs.add(new KeyValuePair(pair.getKey().getSimplifiedOperand(valueMap, force), pair
.getValue().getSimplifiedOperand(valueMap, force)));
newPairs.add(new KeyValuePair(
pair.getKey().getSimplifiedOperand(valueMap, force),
pair.getValue().getSimplifiedOperand(valueMap, force)
));
}

return new Hash(newPairs, isKWArgsHash);
Expand Down
Expand Up @@ -105,7 +105,6 @@ public AsciiCompatibleNode(RubyContext context, SourceSection sourceSection) {

@Specialization
public Object isCompatible(DynamicObject encoding) {
CompilerDirectives.transferToInterpreter();
return EncodingOperations.getEncoding(encoding).isAsciiCompatible();
}
}
Expand Down
Expand Up @@ -26,8 +26,6 @@ public static Encoding getEncoding(DynamicObject rubyEncoding) {
Encoding encoding = Layouts.ENCODING.getEncoding(rubyEncoding);

if (encoding == null) {
CompilerDirectives.transferToInterpreter();

final ByteList name = Layouts.ENCODING.getName(rubyEncoding);
encoding = loadEncoding(name);
Layouts.ENCODING.setEncoding(rubyEncoding, encoding);
Expand Down
Expand Up @@ -14,6 +14,7 @@
import com.oracle.truffle.api.dsl.Cached;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.nodes.ExplodeLoop;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.profiles.ConditionProfile;
import com.oracle.truffle.api.source.SourceSection;
Expand Down Expand Up @@ -146,7 +147,21 @@ public PowNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
@Specialization(guards = {
"exponent == cachedExponent",
"cachedExponent >= 0",
"cachedExponent < 10" }, limit = "10")
@ExplodeLoop
public double powCached(double base, long exponent,
@Cached("exponent") long cachedExponent) {
double result = 1.0;
for (int i = 0; i < cachedExponent; i++) {
result *= base;
}
return result;
}

@Specialization(contains = "powCached")
public double pow(double a, long b) {
return Math.pow(a, b);
}
Expand Down Expand Up @@ -745,22 +760,21 @@ public DynamicObject toS(double value) {
str += ".0";
}

final int dot = str.indexOf('.');
assert dot != -1;

final int e = str.indexOf('e');
final boolean hasE = e != -1;

// Remove trailing zeroes
// Remove trailing zeroes, but keep at least one after the dot
final int start = hasE ? e : str.length();
int i = start;
while (i > 0 && str.charAt(i - 1) == '0') {
int i = start - 1; // last digit we keep, inclusive
while (i > dot + 1 && str.charAt(i) == '0') {
i--;
}

// But keep at least one after the dot
if (i > 0 && str.charAt(i - 1) == '.') {
i++;
}
final String formatted = str.substring(0, i + 1) + str.substring(start, str.length());

final String formatted = str.substring(0, i) + str.substring(start, str.length());
return create7BitString(formatted, USASCIIEncoding.INSTANCE);
}

Expand Down

0 comments on commit 0bd7fa2

Please sign in to comment.