Skip to content
Permalink
Browse files
Merge branch 'master' into truffle-head
  • Loading branch information
chrisseaton committed Dec 6, 2014
2 parents 4917d7d + 3cbe259 commit 13285c6eaf13a447d2c82afc85b2ba9be4ff665c
Showing with 412 additions and 130 deletions.
  1. +1 −0 .travis.yml
  2. +1 −0 BUILDING.md
  3. +6 −29 core/src/main/java/org/jruby/ir/IRBuilder.java
  4. +8 −0 core/src/main/java/org/jruby/ir/operands/Hash.java
  5. +10 −5 core/src/main/java/org/jruby/parser/ParserSupport.java
  6. +2 −1 core/src/main/java/org/jruby/parser/RubyParser.java
  7. +2 −2 core/src/main/java/org/jruby/parser/RubyParser.y
  8. +162 −32 core/src/main/java/org/jruby/truffle/nodes/RubyNode.java
  9. +32 −0 core/src/main/java/org/jruby/truffle/nodes/ThreadLocalObjectNode.java
  10. +1 −1 core/src/main/java/org/jruby/truffle/nodes/cast/ArrayCastNode.java
  11. +1 −1 core/src/main/java/org/jruby/truffle/nodes/cast/BooleanCastNode.java
  12. +1 −1 core/src/main/java/org/jruby/truffle/nodes/cast/SplatCastNode.java
  13. +1 −1 core/src/main/java/org/jruby/truffle/nodes/cast/StringToRegexpNode.java
  14. +1 −1 core/src/main/java/org/jruby/truffle/nodes/core/FalseClassNodes.java
  15. +5 −5 core/src/main/java/org/jruby/truffle/nodes/core/FloatNodes.java
  16. +36 −1 core/src/main/java/org/jruby/truffle/nodes/core/KernelNodes.java
  17. +1 −1 core/src/main/java/org/jruby/truffle/nodes/core/NilClassNodes.java
  18. +21 −3 core/src/main/java/org/jruby/truffle/nodes/core/RegexpNodes.java
  19. +4 −4 core/src/main/java/org/jruby/truffle/nodes/core/StringNodes.java
  20. +2 −2 core/src/main/java/org/jruby/truffle/nodes/core/TrueClassNodes.java
  21. +1 −1 core/src/main/java/org/jruby/truffle/nodes/methods/AliasNode.java
  22. +8 −3 core/src/main/java/org/jruby/truffle/runtime/ModuleOperations.java
  23. +2 −2 core/src/main/java/org/jruby/truffle/runtime/RubyConstant.java
  24. +2 −12 core/src/main/java/org/jruby/truffle/runtime/core/RubyModule.java
  25. +8 −10 core/src/main/java/org/jruby/truffle/runtime/core/RubyRegexp.java
  26. +10 −0 core/src/main/java/org/jruby/truffle/runtime/core/RubyThread.java
  27. +36 −6 core/src/main/java/org/jruby/truffle/translator/BodyTranslator.java
  28. +10 −0 core/src/test/java/org/jruby/parser/DetailedSourcePositionTest.java
  29. +4 −0 lib/ruby/stdlib/rexml/document.rb
  30. +4 −3 spec/java_integration/globals/classpath_spec.rb
  31. +1 −1 spec/truffle/tags/core/kernel/eval_tags.txt
  32. +26 −0 spec/truffle/tags/core/regexp/new_tags.txt
  33. +1 −0 spec/truffle/tags/language/predefined_tags.txt
  34. +0 −2 spec/truffle/tags/language/regexp_tags.txt
  35. +1 −0 spec/truffle/truffle.mspec
  36. BIN test/classpath_test.jar
@@ -3,6 +3,7 @@ before_script:
- unset GEM_PATH GEM_HOME IRBRC JRUBY_OPTS
- "export PATH=`pwd`/bin:$PATH"
- "export JAVA_OPTS='-XX:+TieredCompilation -XX:TieredStopAtLevel=1'"
- echo $HOME

jdk:
- openjdk7
@@ -6,6 +6,7 @@ Prerequisites:
* A Java 7-compatible (or higher) Java development kit (JDK)
* Maven 3+
* Apache Ant 1.8+ (see https://github.com/jruby/jruby/issues/2236)
* make and a C++ compiler for installing the jruby-launcher gem

JRuby uses Maven for building and bootstrapping itself, along with Rake,
RSpec, and MSpec for running integration tests.
@@ -1715,23 +1715,6 @@ public Operand buildDefs(DefsNode node, IRScope s) { // Class method
return new Symbol(method.getName());
}

protected int receiveOptArgs(final ArgsNode argsNode, IRScope s, int opt, int argIndex) {
ListNode optArgs = argsNode.getOptArgs();
for (int j = 0; j < opt; j++, argIndex++) {
// Jump to 'l' if this arg is not null. If null, fall through and build the default value!
Label l = s.getNewLabel();
LocalAsgnNode n = (LocalAsgnNode)optArgs.get(j);
String argName = n.getName();
Variable av = s.getLocalVariable(argName, 0);
if (s instanceof IRMethod) ((IRMethod)s).addArgDesc(IRMethodArgs.ArgType.opt, argName);
addInstr(s, new ReceiveOptArgInstr(av, argIndex-j, argIndex-j, j));
addInstr(s, BNEInstr.create(av, UndefinedValue.UNDEFINED, l)); // if 'av' is not undefined, go to default
build(n, s);
addInstr(s, new LabelInstr(l));
}
return argIndex;
}

protected LocalVariable getArgVariable(IRScope s, String name, int depth) {
// For non-loops, this name will override any name that exists in outer scopes
return s instanceof IRFor ? s.getLocalVariable(name, depth) : s.getNewLocalVariable(name, 0);
@@ -2041,17 +2024,6 @@ public void receiveBlockArgs(final IterNode node, IRScope s) {
}
}

public String buildType(Node typeNode) {
switch (typeNode.getNodeType()) {
case CONSTNODE:
return ((ConstNode)typeNode).getName();
case SYMBOLNODE:
return ((SymbolNode)typeNode).getName();
default:
return "unknown_type";
}
}

public Operand buildDot(final DotNode dotNode, IRScope s) {
Variable res = s.createTemporaryVariable();
addInstr(s, new BuildRangeInstr(res, build(dotNode.getBeginNode(), s), build(dotNode.getEndNode(), s), dotNode.isExclusive()));
@@ -3510,7 +3482,12 @@ private Operand[] adjustVariableDepth(Operand[] args, int depthFromSuper) {
Operand[] newArgs = new Operand[args.length];

for (int i = 0; i < args.length; i++) {
newArgs[i] = ((DepthCloneable) args[i]).cloneForDepth(depthFromSuper);
// Because of keyword args, we can have a keyword-arg hash in the call args.
if (args[i] instanceof Hash) {
newArgs[i] = ((Hash) args[i]).cloneForLVarDepth(depthFromSuper);
} else {
newArgs[i] = ((DepthCloneable) args[i]).cloneForDepth(depthFromSuper);
}
}

return newArgs;
@@ -71,6 +71,14 @@ public void addUsedVariables(List<Variable> l) {
}
}

public Operand cloneForLVarDepth(int newDepth) {
List<KeyValuePair<Operand, Operand>> newPairs = new java.util.ArrayList<KeyValuePair<Operand, Operand>>();
for (KeyValuePair<Operand, Operand> pair : pairs) {
newPairs.add(new KeyValuePair(pair.getKey(), ((DepthCloneable) pair.getValue()).cloneForDepth(newDepth)));
}
return new Hash(newPairs, isKWArgsHash);
}

@Override
public Operand cloneForInlining(CloneInfo ii) {
if (hasKnownValue())
@@ -173,15 +173,20 @@ public Node newline_node(Node node, ISourcePosition position) {
return node instanceof NewlineNode ? node : new NewlineNode(position, node);
}

public Node addRootNode(Node topOfAST, ISourcePosition position) {
position = topOfAST != null ? topOfAST.getPosition() : position;

public Node addRootNode(Node topOfAST) {
if (result.getBeginNodes().isEmpty()) {
if (topOfAST == null) topOfAST = NilImplicitNode.NIL;
ISourcePosition position;
if (topOfAST == null) {
topOfAST = NilImplicitNode.NIL;
position = lexer.getPosition();
} else {
position = topOfAST.getPosition();
}

return new RootNode(position, result.getScope(), topOfAST);
}


ISourcePosition position = topOfAST != null ? topOfAST.getPosition() : result.getBeginNodes().get(0).getPosition();
BlockNode newTopOfAST = new BlockNode(position);
for (Node beginNode: result.getBeginNodes()) {
appendToBlock(newTopOfAST, beginNode);
@@ -44,6 +44,7 @@
import org.jruby.ast.BlockNode;
import org.jruby.ast.BlockPassNode;
import org.jruby.ast.BreakNode;
import org.jruby.ast.CallNode;
import org.jruby.ast.ClassNode;
import org.jruby.ast.ClassVarNode;
import org.jruby.ast.ClassVarAsgnNode;
@@ -1694,7 +1695,7 @@ public Object yyparse (RubyLexer yyLex) throws java.io.IOException {
support.checkUselessStatement(((Node)yyVals[0+yyTop]));
}
}
support.getResult().setAST(support.addRootNode(((Node)yyVals[0+yyTop]), support.getPosition(((Node)yyVals[0+yyTop]))));
support.getResult().setAST(support.addRootNode(((Node)yyVals[0+yyTop])));
return yyVal;
}
};
@@ -309,7 +309,7 @@ program : {
support.checkUselessStatement($2);
}
}
support.getResult().setAST(support.addRootNode($2, support.getPosition($2)));
support.getResult().setAST(support.addRootNode($2));
}

top_compstmt : top_stmts opt_terms {
@@ -2099,7 +2099,7 @@ var_ref : /*mri:user_variable*/ tIDENTIFIER {
support.getConfiguration().getRuntime().getEncodingService().getLocaleEncoding()));
}
| k__LINE__ {
$$ = new FixnumNode(lexer.getPosition(), lexer.tokline.getStartLine()+1);
$$ = new FixnumNode(lexer.getPosition(), lexer.tokline.getLine()+1);
}
| k__ENCODING__ {
$$ = new EncodingNode(lexer.getPosition(), lexer.getEncoding());
@@ -10,6 +10,7 @@
package org.jruby.truffle.nodes;

import com.oracle.truffle.api.CompilerAsserts;
import com.oracle.truffle.api.dsl.ImportGuards;
import com.oracle.truffle.api.source.SourceSection;
import com.oracle.truffle.api.dsl.TypeSystemReference;
import com.oracle.truffle.api.frame.VirtualFrame;
@@ -214,68 +215,197 @@ public static void notDesignedForCompilation() {
CompilerAsserts.neverPartOfCompilation();
}

public static boolean isNil(Object o) {
return o instanceof RubyNilClass;
public boolean isTrue(boolean value) {
return value;
}

public static boolean isTrue(boolean b) {
return b;
public RubyBignum bignum(int value) {
return bignum((long) value);
}

public static boolean isModule(RubyBasicObject o) {
return o instanceof RubyModule;
public RubyBignum bignum(long value) {
return bignum(BigInteger.valueOf(value));
}

public static boolean isArray(Object o) {
return o instanceof RubyArray;
public RubyBignum bignum(BigInteger value) {
return new RubyBignum(getContext().getCoreLibrary().getBignumClass(), value);
}

public static boolean isFixnum(Object o) {
return o instanceof Integer || o instanceof Long;
// Copied from RubyTypesGen

@SuppressWarnings("static-method")
public boolean isDispatchAction(Object value) {
return value instanceof Dispatch.DispatchAction;
}

public static boolean isBignum(Object o) {
return o instanceof RubyBignum;
@SuppressWarnings("static-method")
public boolean isLexicalScope(Object value) {
return value instanceof LexicalScope;
}

public static boolean isFloat(Object o) {
return o instanceof Double;
@SuppressWarnings("static-method")
public boolean isUndefinedPlaceholder(Object value) {
return value instanceof UndefinedPlaceholder;
}

public static boolean isFirstFixnum(Object o) {
return o instanceof Integer || o instanceof Long;
@SuppressWarnings("static-method")
public boolean isBoolean(Object value) {
return value instanceof Boolean;
}

public static boolean isFirstBignum(Object o) {
return o instanceof RubyBignum;
@SuppressWarnings("static-method")
public boolean isInteger(Object value) {
return value instanceof Integer;
}

public static boolean isFirstFloat(Object o) {
return o instanceof Double;
@SuppressWarnings("static-method")
public boolean isLong(Object value) {
return value instanceof Long;
}

public static boolean isSecondFixnum(Object a, Object b) {
return b instanceof Integer || b instanceof Long;
@SuppressWarnings("static-method")
public boolean isDouble(Object value) {
return value instanceof Double;
}

public static boolean isSecondBignum(Object a, Object b) {
return b instanceof RubyBignum;
@SuppressWarnings("static-method")
public boolean isString(Object value) {
return value instanceof String;
}

public static boolean isSecondFloat(Object a, Object b) {
return b instanceof Double;
@SuppressWarnings("static-method")
public boolean isRubyBignum(Object value) {
return value instanceof RubyBignum;
}

public RubyBignum bignum(int value) {
return bignum((long) value);
@SuppressWarnings("static-method")
public boolean isIntegerFixnumRange(Object value) {
return value instanceof RubyRange.IntegerFixnumRange;
}

public RubyBignum bignum(long value) {
return bignum(BigInteger.valueOf(value));
@SuppressWarnings("static-method")
public boolean isLongFixnumRange(Object value) {
return value instanceof RubyRange.LongFixnumRange;
}

public RubyBignum bignum(BigInteger value) {
return new RubyBignum(getContext().getCoreLibrary().getBignumClass(), value);
@SuppressWarnings("static-method")
public boolean isObjectRange(Object value) {
return value instanceof RubyRange.ObjectRange;
}

@SuppressWarnings("static-method")
public boolean isRubyArray(Object value) {
return value instanceof RubyArray;
}

@SuppressWarnings("static-method")
public boolean isRubyBinding(Object value) {
return value instanceof RubyBinding;
}

@SuppressWarnings("static-method")
public boolean isRubyClass(Object value) {
return value instanceof RubyClass;
}

@SuppressWarnings("static-method")
public boolean isRubyException(Object value) {
return value instanceof RubyException;
}

@SuppressWarnings("static-method")
public boolean isRubyFiber(Object value) {
return value instanceof RubyFiber;
}

@SuppressWarnings("static-method")
public boolean isRubyFile(Object value) {
return value instanceof RubyFile;
}

@SuppressWarnings("static-method")
public boolean isRubyHash(Object value) {
return value instanceof RubyHash;
}

@SuppressWarnings("static-method")
public boolean isRubyMatchData(Object value) {
return value instanceof RubyMatchData;
}

@SuppressWarnings("static-method")
public boolean isRubyModule(Object value) {
return value instanceof RubyModule;
}

@SuppressWarnings("static-method")
public boolean isRubyNilClass(Object value) {
return value instanceof RubyNilClass;
}

@SuppressWarnings("static-method")
public boolean isRubyProc(Object value) {
return value instanceof RubyProc;
}

@SuppressWarnings("static-method")
public boolean isRubyRange(Object value) {
return value instanceof RubyRange;
}

@SuppressWarnings("static-method")
public boolean isRubyRegexp(Object value) {
return value instanceof RubyRegexp;
}

@SuppressWarnings("static-method")
public boolean isRubyString(Object value) {
return value instanceof RubyString;
}

@SuppressWarnings("static-method")
public boolean isRubyEncoding(Object value) {
return value instanceof RubyEncoding;
}

@SuppressWarnings("static-method")
public boolean isRubySymbol(Object value) {
return value instanceof RubySymbol;
}

@SuppressWarnings("static-method")
public boolean isRubyThread(Object value) {
return value instanceof RubyThread;
}

@SuppressWarnings("static-method")
public boolean isRubyTime(Object value) {
return value instanceof RubyTime;
}

@SuppressWarnings("static-method")
public boolean isRubiniusChannel(Object value) {
return value instanceof RubiniusChannel;
}

@SuppressWarnings("static-method")
public boolean isRubiniusByteArray(Object value) {
return value instanceof RubiniusByteArray;
}

@SuppressWarnings("static-method")
public boolean isRubyEncodingConverter(Object value) {
return value instanceof RubyEncodingConverter;
}

@SuppressWarnings("static-method")
public boolean isRubyBasicObject(Object value) {
return value instanceof RubyBasicObject;
}

@SuppressWarnings("static-method")
public boolean isObjectArray(Object value) {
return value instanceof Object[];
}

}

0 comments on commit 13285c6

Please sign in to comment.