Skip to content

Commit

Permalink
Merge branch 'master' into truffle-head
Browse files Browse the repository at this point in the history
Conflicts:
	truffle/src/main/java/org/jruby/truffle/nodes/core/ArrayAllocationSite.java
	truffle/src/main/java/org/jruby/truffle/nodes/core/HashNodes.java
  • Loading branch information
chrisseaton committed Mar 12, 2015
2 parents ae33064 + 7fe3c36 commit 56be36f
Show file tree
Hide file tree
Showing 200 changed files with 2,629 additions and 1,447 deletions.
6 changes: 0 additions & 6 deletions .travis.yml
Expand Up @@ -67,12 +67,6 @@ matrix:
- env: COMMAND=tool/truffle-findbugs.sh
jdk: oraclejdk8
fast_finish: true
allow_failures:
- env: PHASE='-Pcomplete'
- env: PHASE='-Pmain'
- env: PHASE='-Prake -Dtask=spec:jrubyc'
- env: PHASE='-Prake -Dtask=spec:profiler'
- env: PHASE='-Prake -Dtask=test:mri:jit'

branches:
only:
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/RubyString.java
Expand Up @@ -267,7 +267,7 @@ final boolean singleByteOptimizable() {
}

final boolean singleByteOptimizable(Encoding enc) {
return getCodeRange() == CR_7BIT || enc.maxLength() == 1;
return StringSupport.isSingleByteOptimizable(this, enc);
}

// rb_enc_compatible
Expand Down
8 changes: 7 additions & 1 deletion core/src/main/java/org/jruby/ast/XStrNode.java
Expand Up @@ -42,11 +42,13 @@
*/
public class XStrNode extends Node implements ILiteralNode {
private final ByteList value;
private int coderange;

public XStrNode(ISourcePosition position, ByteList value) {
public XStrNode(ISourcePosition position, ByteList value, int coderange) {
// FIXME: Shouldn't this have codeRange like StrNode?
super(position, false);
this.value = (value == null ? ByteList.create("") : value);
this.coderange = coderange;
}

public NodeType getNodeType() {
Expand All @@ -68,6 +70,10 @@ public <T> T accept(NodeVisitor<T> iVisitor) {
public ByteList getValue() {
return value;
}

public int getCodeRange() {
return coderange;
}

public List<Node> childNodes() {
return EMPTY_LIST;
Expand Down
9 changes: 5 additions & 4 deletions core/src/main/java/org/jruby/ir/IRBuilder.java
Expand Up @@ -27,6 +27,7 @@
import java.io.FileInputStream;
import java.io.IOException;
import java.util.*;
import org.jruby.util.StringSupport;

import static org.jruby.ir.instructions.RuntimeHelperCall.Methods.*;

Expand Down Expand Up @@ -1003,10 +1004,10 @@ public Operand buildCall(CallNode callNode) {
Node callArgsNode = callNode.getArgsNode();
Node receiverNode = callNode.getReceiverNode();

// check for "string".freeze
// Frozen string optimization: check for "string".freeze
if (receiverNode instanceof StrNode && callNode.getName().equals("freeze")) {
// frozen string optimization
return new FrozenString(((StrNode)receiverNode).getValue());
StrNode asString = (StrNode) receiverNode;
return new FrozenString(asString.getValue(), asString.getCodeRange());
}

// Though you might be tempted to move this build into the CallInstr as:
Expand Down Expand Up @@ -3398,7 +3399,7 @@ public Operand buildWhile(final WhileNode whileNode) {
}

public Operand buildXStr(XStrNode node) {
return addResultInstr(new BacktickInstr(createTemporaryVariable(), new Operand[] { new StringLiteral(node.getValue())}));
return addResultInstr(new BacktickInstr(createTemporaryVariable(), new Operand[] { new StringLiteral(node.getValue(), node.getCodeRange())}));
}

public Operand buildYield(YieldNode node) {
Expand Down
17 changes: 7 additions & 10 deletions core/src/main/java/org/jruby/ir/IRScope.java
Expand Up @@ -13,7 +13,6 @@
import org.jruby.ir.operands.Float;
import org.jruby.ir.operands.Boolean;
import org.jruby.ir.passes.*;
import org.jruby.ir.persistence.IRReaderDecoder;
import org.jruby.ir.representations.BasicBlock;
import org.jruby.ir.representations.CFG;
import org.jruby.ir.transformations.inlining.CFGInliner;
Expand All @@ -22,6 +21,8 @@

import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import org.jruby.util.log.Logger;
import org.jruby.util.log.LoggerFactory;

import static org.jruby.ir.IRFlags.*;

Expand Down Expand Up @@ -55,6 +56,8 @@
* and so on ...
*/
public abstract class IRScope implements ParseResult {
public static final Logger LOG = LoggerFactory.getLogger("IRScope");

private static final Collection<IRClosure> NO_CLOSURES = Collections.unmodifiableCollection(new ArrayList<IRClosure>(0));

private static AtomicInteger globalScopeCount = new AtomicInteger();
Expand Down Expand Up @@ -107,9 +110,6 @@ public abstract class IRScope implements ParseResult {
/** Keeps track of types of prefix indexes for variables and labels */
private Map<String, Integer> nextVarIndex;

// FIXME: Persistence is completely disconnected for now
//private int instructionsOffsetInfoPersistenceBuffer = -1;
//private IRReaderDecoder persistenceStore = null;
private TemporaryLocalVariable currentModuleVariable;
private TemporaryLocalVariable currentScopeVariable;

Expand Down Expand Up @@ -220,6 +220,7 @@ protected void addChildScope(IRScope scope) {
}

public List<IRScope> getLexicalScopes() {
if (lexicalChildren == null) lexicalChildren = new ArrayList<>();
return lexicalChildren;
}

Expand Down Expand Up @@ -506,6 +507,8 @@ private void runCompilerPasses(List<CompilerPass> passes) {
public InterpreterContext allocateInterpreterContext(List<Instr> instructions) {
interpreterContext = new InterpreterContext(this, instructions);

if (RubyInstanceConfig.IR_COMPILER_DEBUG) LOG.info("" + interpreterContext);

return interpreterContext;
}

Expand Down Expand Up @@ -1093,10 +1096,4 @@ public boolean isTopLocalVariableScope() {
public boolean isScriptScope() {
return false;
}

public void savePersistenceInfo(int offset, IRReaderDecoder file) {
// FIXME: Persistence is disconnected for now.
// instructionsOffsetInfoPersistenceBuffer = offset;
// persistenceStore = file;
}
}
Expand Up @@ -198,9 +198,11 @@ public void addLoads(Map<Operand, Operand> varRenameMap) {
}
it.previous();
}
} else if (scopeBindingHasEscaped && (i.getOperation() == Operation.PUT_GLOBAL_VAR)) {
// global-var tracing can execute closures set up in previous trace-var calls
// in which case we would have the 'scopeBindingHasEscaped' flag set to true
} else if (scopeBindingHasEscaped && (i.getOperation() == Operation.PUT_GLOBAL_VAR
|| i.getOperation() == Operation.THREAD_POLL)) {
// 1. Global-var tracing can execute closures set up in previous trace-var calls
// in which case we would have the 'scopeBindingHasEscaped' flag set to true.
// 2. Threads can update bindings, so we treat thread poll boundaries the same way.
it.next();
for (LocalVariable v : reqdLoads) {
it.add(new LoadLocalVarInstr(scope, getLocalVarReplacement(v, scope, varRenameMap), v));
Expand Down
Expand Up @@ -260,9 +260,11 @@ public boolean addStores(Map<Operand, Operand> varRenameMap, Set<LocalVariable>
dirtyVars.clear();
}

if (scopeBindingHasEscaped && (i.getOperation() == Operation.PUT_GLOBAL_VAR)) {
// global-var tracing can execute closures set up in previous trace-var calls
// in which case we would have the 'scopeBindingHasEscaped' flag set to true
if (scopeBindingHasEscaped && (i.getOperation() == Operation.PUT_GLOBAL_VAR
|| i.getOperation() == Operation.THREAD_POLL)) {
// 1. Global-var tracing can execute closures set up in previous trace-var calls
// in which case we would have the 'scopeBindingHasEscaped' flag set to true.
// 2. Threads can update bindings, so we treat thread poll boundaries the same way.
instrs.previous();
for (LocalVariable v : dirtyVars) {
addedStores = true;
Expand Down
9 changes: 9 additions & 0 deletions core/src/main/java/org/jruby/ir/instructions/AliasInstr.java
Expand Up @@ -5,6 +5,7 @@
import org.jruby.ir.IRVisitor;
import org.jruby.ir.Operation;
import org.jruby.ir.operands.Operand;
import org.jruby.ir.persistence.IRWriterEncoder;
import org.jruby.ir.runtime.IRRuntimeHelpers;
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.parser.StaticScope;
Expand All @@ -26,6 +27,14 @@ public boolean computeScopeFlags(IRScope scope) {
return true;
}

@Override
public void encode(IRWriterEncoder e) {
super.encode(e);

e.encode(getNewName());
e.encode(getOldName());
}

@Override
public Instr clone(CloneInfo ii) {
return new AliasInstr(getNewName().cloneForInlining(ii), getOldName().cloneForInlining(ii));
Expand Down
Expand Up @@ -5,6 +5,7 @@
import org.jruby.ir.Operation;
import org.jruby.ir.instructions.specialized.OneArgOperandAttrAssignInstr;
import org.jruby.ir.operands.Operand;
import org.jruby.ir.persistence.IRWriterEncoder;
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.parser.StaticScope;
import org.jruby.runtime.*;
Expand Down
Expand Up @@ -6,6 +6,7 @@
import org.jruby.ir.Operation;
import org.jruby.ir.operands.Operand;
import org.jruby.ir.operands.Variable;
import org.jruby.ir.persistence.IRWriterEncoder;
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.parser.StaticScope;
import org.jruby.runtime.DynamicScope;
Expand All @@ -31,6 +32,12 @@ public Instr clone(CloneInfo ii) {
return new BacktickInstr(ii.getRenamedVariable(result), cloneOperands(ii));
}

@Override
public void encode(IRWriterEncoder e) {
super.encode(e);
e.encode(getPieces());
}

@Override
public Object interpret(ThreadContext context, StaticScope currScope, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
RubyString newString = context.runtime.newString();
Expand Down
Expand Up @@ -4,6 +4,7 @@
import org.jruby.ir.Operation;
import org.jruby.ir.operands.Operand;
import org.jruby.ir.operands.Variable;
import org.jruby.ir.persistence.IRWriterEncoder;
import org.jruby.ir.runtime.IRRuntimeHelpers;
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.parser.StaticScope;
Expand All @@ -29,6 +30,12 @@ public Instr clone(CloneInfo ii) {
return new BlockGivenInstr(ii.getRenamedVariable(result), getBlockArg().cloneForInlining(ii));
}

@Override
public void encode(IRWriterEncoder e) {
super.encode(e);
e.encode(getBlockArg());
}

@Override
public Object interpret(ThreadContext context, StaticScope currScope, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
Object blk = getBlockArg().retrieve(context, self, currScope, currDynScope, temp);
Expand Down
8 changes: 8 additions & 0 deletions core/src/main/java/org/jruby/ir/instructions/BreakInstr.java
Expand Up @@ -7,6 +7,7 @@
import org.jruby.ir.operands.Operand;
import org.jruby.ir.operands.StringLiteral;
import org.jruby.ir.operands.Variable;
import org.jruby.ir.persistence.IRWriterEncoder;
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.ir.transformations.inlining.InlineCloneInfo;
import org.jruby.ir.transformations.inlining.SimpleCloneInfo;
Expand Down Expand Up @@ -95,6 +96,13 @@ public Instr clone(CloneInfo info) {
}
}

@Override
public void encode(IRWriterEncoder e) {
super.encode(e);
e.encode(getReturnValue());
e.encode(getScopeName());
}

@Override
public void visit(IRVisitor visitor) {
visitor.BreakInstr(this);
Expand Down
Expand Up @@ -5,6 +5,7 @@
import org.jruby.ir.Operation;
import org.jruby.ir.operands.Operand;
import org.jruby.ir.operands.Variable;
import org.jruby.ir.persistence.IRWriterEncoder;
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.parser.StaticScope;
import org.jruby.runtime.DynamicScope;
Expand Down Expand Up @@ -42,6 +43,14 @@ public Instr clone(CloneInfo ii) {
getAppendedArg().cloneForInlining(ii), isArgsPush);
}

@Override
public void encode(IRWriterEncoder e) {
super.encode(e);
e.encode(getAppendingArg());
e.encode(getAppendedArg());
e.encode(isArgsPush());
}

@Override
public Object interpret(ThreadContext context, StaticScope currScope, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
IRubyObject v1 = (IRubyObject)getAppendingArg().retrieve(context, self, currScope, currDynScope, temp);
Expand Down
Expand Up @@ -7,6 +7,7 @@
import org.jruby.ir.operands.Operand;
import org.jruby.ir.operands.StringLiteral;
import org.jruby.ir.operands.Variable;
import org.jruby.ir.persistence.IRWriterEncoder;
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.parser.StaticScope;
import org.jruby.runtime.DynamicScope;
Expand Down Expand Up @@ -44,6 +45,13 @@ public boolean isSameEncodingAndCodeRange(RubyString str, StringLiteral newStr)
return newStr.bytelist.getEncoding() == encoding && newStr.getCodeRange() == str.getCodeRange();
}

@Override
public void encode(IRWriterEncoder e) {
super.encode(e);
e.encode(encoding == null ? "" : encoding.toString());
e.encode(getPieces());
}

@Override
public Object interpret(ThreadContext context, StaticScope currScope, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
ByteList bytes = new ByteList();
Expand Down
Expand Up @@ -6,6 +6,7 @@
import org.jruby.ir.Operation;
import org.jruby.ir.operands.Operand;
import org.jruby.ir.operands.Variable;
import org.jruby.ir.persistence.IRWriterEncoder;
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.parser.StaticScope;
import org.jruby.runtime.DynamicScope;
Expand Down Expand Up @@ -58,6 +59,13 @@ private RubyString[] retrievePieces(ThreadContext context, IRubyObject self, Sta
return strings;
}

@Override
public void encode(IRWriterEncoder e) {
super.encode(e);
e.encode(getPieces());
e.encode(getOptions().toEmbeddedOptions());
}

@Override
public Object interpret(ThreadContext context, StaticScope currScope, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
// FIXME (from RegexpNode.java): 1.9 should care about internal or external encoding and not kcode.
Expand Down
Expand Up @@ -5,6 +5,7 @@
import org.jruby.ir.IRVisitor;
import org.jruby.ir.Operation;
import org.jruby.ir.operands.*;
import org.jruby.ir.persistence.IRWriterEncoder;
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.lexer.yacc.ISourcePosition;
import org.jruby.parser.StaticScope;
Expand Down Expand Up @@ -53,6 +54,14 @@ public Operand getClosureArg() {
return operands[0];
}

@Override
public void encode(IRWriterEncoder e) {
super.encode(e);
e.encode(getLambdaBody());
e.encode(getPosition().getFile());
e.encode(getPosition().getLine());
}

@Override
public Object interpret(ThreadContext context, StaticScope currScope, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
// SSS FIXME: Copied this from ast/LambdaNode ... Is this required here as well?
Expand Down
Expand Up @@ -5,6 +5,7 @@
import org.jruby.ir.Operation;
import org.jruby.ir.operands.Variable;
import org.jruby.ir.operands.Operand;
import org.jruby.ir.persistence.IRWriterEncoder;
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.parser.StaticScope;
import org.jruby.runtime.DynamicScope;
Expand Down Expand Up @@ -48,6 +49,14 @@ public Instr clone(CloneInfo ii) {
getEnd().cloneForInlining(ii), exclusive);
}

@Override
public void encode(IRWriterEncoder e) {
super.encode(e);
e.encode(getBegin());
e.encode(getEnd());
e.encode(isExclusive());
}

@Override
public Object interpret(ThreadContext context, StaticScope currScope, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
return RubyRange.newRange(context,
Expand Down

0 comments on commit 56be36f

Please sign in to comment.