Skip to content

Commit

Permalink
Merge branch 'master' into truffle-head
Browse files Browse the repository at this point in the history
Conflicts:
	core/src/main/java/org/jruby/truffle/nodes/core/BignumNodes.java
	core/src/main/java/org/jruby/truffle/nodes/core/FixnumNodes.java
	core/src/main/java/org/jruby/truffle/nodes/core/FloatNodes.java
	core/src/main/java/org/jruby/truffle/nodes/core/StringNodes.java
  • Loading branch information
chrisseaton committed Nov 4, 2014
2 parents a15994c + 0e4c83c commit 383b10a
Show file tree
Hide file tree
Showing 57 changed files with 301 additions and 827 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -27,7 +27,7 @@ env:
- TARGET='-Prake -Dtask=spec:compiler'
- TARGET='-Prake -Dtask=spec:ffi'
- TARGET='-Prake -Dtask=spec:regression'
- TARGET='-Prake -Dtask=spec:ci_interpreted_travis'
- TARGET='-Prake -Dtask=spec:ruby:fast'
- TARGET='-Ptruffle-specs-language'
- TARGET='-Ptruffle-specs-core'

Expand Down
2 changes: 1 addition & 1 deletion core/.classpath
Expand Up @@ -24,7 +24,7 @@
<classpathentry kind="var" path="M2_REPO/org/jruby/jcodings/jcodings/1.0.12-SNAPSHOT/jcodings-1.0.12-SNAPSHOT.jar"/>
<classpathentry kind="var" path="M2_REPO/org/jruby/extras/bytelist/1.0.12-SNAPSHOT/bytelist-1.0.12-SNAPSHOT.jar"/>
<classpathentry kind="var" path="M2_REPO/org/jruby/yecht/1.0/yecht-1.0.jar"/>
<classpathentry kind="var" path="M2_REPO/com/headius/invokebinder/1.4-SNAPSHOT/invokebinder-1.4-SNAPSHOT.jar"/>
<classpathentry kind="var" path="M2_REPO/com/headius/invokebinder/1.4/invokebinder-1.4.jar"/>
<classpathentry kind="var" path="M2_REPO/com/headius/options/1.1/options-1.1.jar"/>
<classpathentry kind="var" path="M2_REPO/com/headius/coro-mock/1.0/coro-mock-1.0.jar"/>
<classpathentry kind="var" path="M2_REPO/com/headius/unsafe-mock/8.0/unsafe-mock-8.0.jar"/>
Expand Down
2 changes: 1 addition & 1 deletion core/pom.rb
Expand Up @@ -45,7 +45,7 @@
jar 'org.jruby.extras:bytelist:1.0.12-SNAPSHOT'
jar 'org.jruby.jcodings:jcodings:1.0.12-SNAPSHOT'

jar 'com.headius:invokebinder:1.4-SNAPSHOT'
jar 'com.headius:invokebinder:1.4'
jar 'com.headius:options:1.1'
jar 'com.headius:coro-mock:1.0', :scope => 'provided'
jar 'com.headius:unsafe-mock', '${unsafe.version}', :scope => 'provided'
Expand Down
2 changes: 1 addition & 1 deletion core/pom.xml
Expand Up @@ -112,7 +112,7 @@
<dependency>
<groupId>com.headius</groupId>
<artifactId>invokebinder</artifactId>
<version>1.4-SNAPSHOT</version>
<version>1.4</version>
</dependency>
<dependency>
<groupId>com.headius</groupId>
Expand Down
6 changes: 6 additions & 0 deletions core/src/main/java/org/jruby/Ruby.java
Expand Up @@ -3497,6 +3497,10 @@ public RaiseException newErrnoEINVALError() {
return newRaiseException(getErrno().getClass("EINVAL"), "Invalid file");
}

public RaiseException newErrnoELOOPError() {
return newRaiseException(getErrno().getClass("ELOOP"), "Too many levels of symbolic links");
}

public RaiseException newErrnoENOENTError() {
return newRaiseException(getErrno().getClass("ENOENT"), "File not found");
}
Expand Down Expand Up @@ -3854,6 +3858,8 @@ public RaiseException newIOErrorFromException(IOException e) {
|| "An existing connection was forcibly closed by the remote host".equals(e.getMessage()) ||
(Platform.IS_WINDOWS && e.getMessage().contains("connection was aborted"))) {
return newErrnoECONNRESETError();
} else if ("Too many levels of symbolic links".equals(e.getMessage())) {
return newErrnoELOOPError();
}
return newRaiseException(getIOError(), e.getMessage());
} else {
Expand Down
1 change: 0 additions & 1 deletion core/src/main/java/org/jruby/parser/Parser.java
Expand Up @@ -122,7 +122,6 @@ public Node parse(String file, LexerSource lexerSource, DynamicScope blockScope,
// but I am not sure which conditions leads to this...so lame message.
throw runtime.newSyntaxError("Problem reading source: " + e);
} catch (SyntaxException e) {
e.printStackTrace();
switch (e.getPid()) {
case UNKNOWN_ENCODING:
case NOT_ASCII_COMPATIBLE:
Expand Down
133 changes: 40 additions & 93 deletions core/src/main/java/org/jruby/truffle/nodes/cast/BoxingNode.java
Expand Up @@ -9,12 +9,12 @@
*/
package org.jruby.truffle.nodes.cast;

import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.source.SourceSection;
import com.oracle.truffle.api.dsl.NodeChild;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.nodes.Node;
import com.oracle.truffle.api.source.SourceSection;
import com.oracle.truffle.api.utilities.ConditionProfile;
import org.jruby.truffle.nodes.RubyNode;
import org.jruby.truffle.runtime.core.*;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.core.RubyBasicObject;
import org.jruby.truffle.runtime.core.RubyBignum;
Expand All @@ -23,112 +23,59 @@

import java.math.BigInteger;

public class BoxingNode extends RubyNode {

@Child protected RubyNode child;
@NodeChild("child")
public abstract class BoxingNode extends RubyNode {

@CompilerDirectives.CompilationFinal private boolean seenBoxed = false;
@CompilerDirectives.CompilationFinal private boolean seenNil = false;
@CompilerDirectives.CompilationFinal private boolean seenBoolean = false;
@CompilerDirectives.CompilationFinal private boolean seenInteger = false;
@CompilerDirectives.CompilationFinal private boolean seenLong = false;
@CompilerDirectives.CompilationFinal private boolean seenDouble = false;
@CompilerDirectives.CompilationFinal private boolean seenBigInteger = false;
private final ConditionProfile booleanProfile = ConditionProfile.createCountingProfile();

public BoxingNode(RubyContext context, SourceSection sourceSection) {
this(context, sourceSection, null);
}

public BoxingNode(RubyContext context, SourceSection sourceSection, RubyNode child) {
super(context, sourceSection);
this.child = child;
}

@Override
public RubyBasicObject executeRubyBasicObject(VirtualFrame frame) {
return box(child.execute(frame));
public BoxingNode(BoxingNode prev) {
super(prev);
}

@Override
public Object execute(VirtualFrame frame) {
return executeRubyBasicObject(frame);
}

public RubyBasicObject box(Object value) {
if (seenBoxed && value instanceof RubyBasicObject) {
return (RubyBasicObject) value;
}

if (seenNil && value instanceof RubyNilClass) {
return getContext().getCoreLibrary().getNilObject();
}
public abstract RubyBasicObject executeRubyBasicObject(VirtualFrame frame);

if (seenBoolean && value instanceof Boolean) {
if ((boolean) value) {
return getContext().getCoreLibrary().getTrueObject();
} else {
return getContext().getCoreLibrary().getFalseObject();
}
}

if (seenInteger && value instanceof Integer) {
return new RubyFixnum.IntegerFixnum(getContext().getCoreLibrary().getFixnumClass(), (int) value);
}

if (seenLong && value instanceof Long) {
return new RubyFixnum.LongFixnum(getContext().getCoreLibrary().getFixnumClass(), (long) value);
}

if (seenDouble && value instanceof Double) {
return new RubyFloat(getContext().getCoreLibrary().getFloatClass(), (double) value);
}
protected abstract RubyBasicObject executeRubyBasicObject(VirtualFrame frame, Object value);

if (seenBigInteger && value instanceof BigInteger) {
return new RubyBignum(getContext().getCoreLibrary().getFixnumClass(), (BigInteger) value);
}

CompilerDirectives.transferToInterpreterAndInvalidate();

if (value instanceof RubyBasicObject) {
seenBoxed = true;
return (RubyBasicObject) value;
}

if (value instanceof RubyNilClass) {
seenNil = true;
return getContext().getCoreLibrary().getNilObject();
}
public RubyBasicObject box(Object value) {
return executeRubyBasicObject(null, value);
}

if (value instanceof Boolean) {
seenBoolean = true;
if ((boolean) value) {
return getContext().getCoreLibrary().getTrueObject();
} else {
return getContext().getCoreLibrary().getFalseObject();
}
}
@Specialization
public RubyBasicObject box(RubyBasicObject object) {
return object;
}

if (value instanceof Integer) {
seenInteger = true;
return new RubyFixnum.IntegerFixnum(getContext().getCoreLibrary().getFixnumClass(), (int) value);
@Specialization
public RubyBasicObject box(boolean value) {
if (booleanProfile.profile(value)) {
return getContext().getCoreLibrary().getTrueObject();
} else {
return getContext().getCoreLibrary().getFalseObject();
}
}

if (value instanceof Long) {
seenLong = true;
return new RubyFixnum.LongFixnum(getContext().getCoreLibrary().getFixnumClass(), (long) value);
}
@Specialization
public RubyBasicObject box(int value) {
return new RubyFixnum.IntegerFixnum(getContext().getCoreLibrary().getFixnumClass(), value);
}

if (value instanceof Double) {
seenDouble = true;
return new RubyFloat(getContext().getCoreLibrary().getFloatClass(), (double) value);
}
@Specialization
public RubyBasicObject box(long value) {
return new RubyFixnum.LongFixnum(getContext().getCoreLibrary().getFixnumClass(), value);
}

if (value instanceof BigInteger) {
seenBigInteger = true;
return new RubyBignum(getContext().getCoreLibrary().getFixnumClass(), (BigInteger) value);
}
@Specialization
public RubyBasicObject box(double value) {
return new RubyFloat(getContext().getCoreLibrary().getFloatClass(), value);
}

throw new UnsupportedOperationException(value.getClass().getName());
@Specialization
public RubyBasicObject box(BigInteger value) {
return new RubyBignum(getContext().getCoreLibrary().getFixnumClass(), value);
}

}
Expand Up @@ -23,6 +23,7 @@
* a non-void type is used. It is not executed at all if a void typed execute method is used.
* Therefore it should not perform any observable side effects.
*/
@NodeInfo(cost = NodeCost.NONE)
public class ElidableResultNode extends RubyNode {

@Child protected RubyNode required;
Expand Down
Expand Up @@ -10,6 +10,8 @@
package org.jruby.truffle.nodes.control;

import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.nodes.NodeCost;
import com.oracle.truffle.api.nodes.NodeInfo;
import com.oracle.truffle.api.nodes.UnexpectedResultException;
import org.jruby.truffle.nodes.RubyNode;
import org.jruby.truffle.runtime.core.*;
Expand Down
Expand Up @@ -25,6 +25,7 @@
/**
* A sequence of statements to be executed in serial.
*/
@NodeInfo(cost = NodeCost.NONE)
public final class SequenceNode extends RubyNode {

@Children protected final RubyNode[] body;
Expand Down
Expand Up @@ -45,9 +45,7 @@ public boolean executeBoolean(VirtualFrame frame) {
}

for (Object value : array.slowToArray()) {
// TODO(CS): how to cast this to a boolean?

if ((boolean) dispatchCaseEqual.call(frame, caseExpression, "===", null, value)) {
if (dispatchCaseEqual.callIsTruthy(frame, caseExpression, "===", null, value)) {
return true;
}
}
Expand Down

0 comments on commit 383b10a

Please sign in to comment.