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/control/TraceNode.java
	truffle/src/main/java/org/jruby/truffle/nodes/core/ThreadBacktraceLocationNodes.java
	truffle/src/main/java/org/jruby/truffle/nodes/rubinius/TimePrimitiveNodes.java
	truffle/src/main/java/org/jruby/truffle/nodes/rubinius/VMPrimitiveNodes.java
chrisseaton committed Oct 13, 2015
2 parents ac267fa + 7d8367c commit bd337d3
Showing 116 changed files with 671 additions and 638 deletions.
Original file line number Diff line number Diff line change
@@ -74,4 +74,10 @@ public MethodData getMethodData() {
}
return methodData;
}

// Used by racc extension, needed for backward-compat with 1.7.
@Deprecated
public AttrReaderMethod(RubyModule implementationClass, Visibility visibility, CallConfiguration callConfiguration, String variableName) {
this(implementationClass, visibility, variableName);
}
}
Original file line number Diff line number Diff line change
@@ -76,4 +76,10 @@ public MethodData getMethodData() {
}
return methodData;
}

// Used by racc extension, needed for backward-compat with 1.7.
@Deprecated
public AttrWriterMethod(RubyModule implementationClass, Visibility visibility, CallConfiguration callConfiguration, String variableName) {
this(implementationClass, visibility, variableName);
}
}
13 changes: 9 additions & 4 deletions core/src/main/java/org/jruby/ir/IRBuilder.java
Original file line number Diff line number Diff line change
@@ -2246,15 +2246,20 @@ public Operand buildEnsureInternal(Node ensureBodyNode, Node ensurerNode) {
activeRescuers.push(ebi.dummyRescueBlockLabel);

// Generate IR for code being protected
Variable ensureExprValue = createTemporaryVariable();
Operand rv = ensureBodyNode instanceof RescueNode ? buildRescueInternal((RescueNode) ensureBodyNode, ebi) : build(ensureBodyNode);

// End of protected region
addInstr(new ExceptionRegionEndMarkerInstr());
activeRescuers.pop();

// Clone the ensure body and jump to the end. Don't bother if the protected body ended in a return
// OR if we are really processing a rescue node
if (ensurerNode != null && rv != U_NIL && !(ensureBodyNode instanceof RescueNode)) {
// Is this a begin..(rescue..)?ensure..end node that actually computes a value?
// (vs. returning from protected body)
boolean isEnsureExpr = ensurerNode != null && rv != U_NIL && !(ensureBodyNode instanceof RescueNode);

// Clone the ensure body and jump to the end
if (isEnsureExpr) {
addInstr(new CopyInstr(ensureExprValue, rv));
ebi.cloneIntoHostScope(this);
addInstr(new JumpInstr(ebi.end));
}
@@ -2290,7 +2295,7 @@ public Operand buildEnsureInternal(Node ensureBodyNode, Node ensurerNode) {
// End label for the exception region
addInstr(new LabelInstr(ebi.end));

return rv;
return isEnsureExpr ? ensureExprValue : rv;
}

public Operand buildEvStr(EvStrNode node) {
9 changes: 7 additions & 2 deletions core/src/main/java/org/jruby/runtime/IRBlockBody.java
Original file line number Diff line number Diff line change
@@ -120,7 +120,10 @@ private IRubyObject[] toAry(ThreadContext context, IRubyObject value) {
protected IRubyObject doYieldLambda(ThreadContext context, IRubyObject value, Binding binding, Type type) {
// Lambda does not splat arrays even if a rest arg is present when it wants a single parameter filled.
IRubyObject[] args;
if (signature.required() == 1 || signature.arityValue() == -1) {

if (value == null) { // no args case from BlockBody.yieldSpecific
args = IRubyObject.NULL_ARRAY;
} else if (signature.required() == 1 || signature.arityValue() == -1) {
args = new IRubyObject[] { value };
} else {
args = toAry(context, value);
@@ -138,7 +141,9 @@ public IRubyObject doYield(ThreadContext context, IRubyObject value, Binding bin
int blockArity = getSignature().arityValue();

IRubyObject[] args;
if (blockArity >= -1 && blockArity <= 1) {
if (value == null) { // no args case from BlockBody.yieldSpecific
args = IRubyObject.NULL_ARRAY;
} else if (blockArity >= -1 && blockArity <= 1) {
args = new IRubyObject[] { value };
} else {
args = toAry(context, value);
12 changes: 12 additions & 0 deletions spec/ruby/language/defined_spec.rb
Original file line number Diff line number Diff line change
@@ -755,10 +755,22 @@
defined?(DefinedSpecs::Child::B).should be_nil
end

it "returns nil when a constant is scoped to an undefined constant" do
defined?(Undefined::Object).should be_nil
end

it "returns nil when the undefined constant is scoped to an undefined constant" do
defined?(DefinedSpecs::Undefined::Undefined).should be_nil
end

it "returns nil when a constant is defined on top-level but not on the module" do
defined?(DefinedSpecs::String).should be_nil
end

it "returns 'constant' when a constant is defined on top-level but not on the class" do
defined?(DefinedSpecs::Basic::String).should == "constant"
end

it "returns 'constant' if the scoped-scoped constant is defined" do
defined?(DefinedSpecs::Child::A).should == "constant"
end
22 changes: 22 additions & 0 deletions spec/ruby/language/ensure_spec.rb
Original file line number Diff line number Diff line change
@@ -74,6 +74,28 @@
end
end

describe "The value of an ensure expression," do
it "in no-exception scenarios, is the value of the last stmt of the protected body" do
begin
v = 1
eval('x=1') # to prevent opts from triggering
v
ensure
v = 2
end.should == 1
end

it "when an exception is rescued, is the value of the rescuing block" do
begin
raise 'foo'
rescue
v = 3
ensure
v = 2
end.should == 3
end
end

describe "An ensure block inside a method" do
before :each do
@obj = EnsureSpec::Container.new
17 changes: 0 additions & 17 deletions spec/truffle/tags/core/kernel/exit_tags.txt

This file was deleted.

8 changes: 0 additions & 8 deletions spec/truffle/tags/core/kernel/instance_variable_get_tags.txt

This file was deleted.

7 changes: 0 additions & 7 deletions spec/truffle/tags/core/kernel/instance_variable_set_tags.txt

This file was deleted.

This file was deleted.

1 change: 0 additions & 1 deletion spec/truffle/tags/core/marshal/dump_tags.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
fails:Marshal.dump dumps an extended_object
fails:Marshal.dump dumps an object that has had an ivar added and removed as though the ivar never was set
fails:Marshal.dump with a Float dumps a Float
fails:Marshal.dump with a String dumps a String extended with a Module
fails:Marshal.dump with a Regexp dumps a Regexp
8 changes: 0 additions & 8 deletions spec/truffle/tags/core/process/exit_tags.txt

This file was deleted.

10 changes: 0 additions & 10 deletions spec/truffle/tags/core/thread/alive_tags.txt

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
fails:Thread::Backtrace::Location#path outside a main script returns an absolute path
fails:Thread::Backtrace::Location#path in a main script when the script is in the working directory when using a relative script path returns a path relative to the working directory
fails:Thread::Backtrace::Location#path in a main script when the script is in the working directory when using an absolute script path returns an absolute path
fails:Thread::Backtrace::Location#path in a main script when the script is in a sub directory of the working directory when using a relative script path returns a path relative to the working directory
fails:Thread::Backtrace::Location#path in a main script when the script is in a sub directory of the working directory when using an absolute script path returns an absolute path
fails:Thread::Backtrace::Location#path in a main script when the script is outside of the working directory when using a relative script path returns a path relative to the working directory
fails:Thread::Backtrace::Location#path in a main script when the script is outside of the working directory when using an absolute path returns an absolute path
slow:Thread::Backtrace::Location#path in a main script when the script is in the working directory when using an absolute script path returns an absolute path
slow:Thread::Backtrace::Location#path in a main script when the script is in a sub directory of the working directory when using an absolute script path returns an absolute path
slow:Thread::Backtrace::Location#path in a main script when the script is outside of the working directory when using an absolute path returns an absolute path

This file was deleted.

8 changes: 0 additions & 8 deletions spec/truffle/tags/core/thread/inspect_tags.txt

This file was deleted.

1 change: 0 additions & 1 deletion spec/truffle/tags/core/thread/list_tags.txt

This file was deleted.

2 changes: 0 additions & 2 deletions spec/truffle/tags/core/thread/new_tags.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
fails:Thread.new raises an exception when not given a block
fails:Thread.new creates a subclass of thread calls super with a block in initialize
fails:Thread.new calls #initialize and raises an error if super not used
fails:Thread.new calls and respects #initialize for the block to use
3 changes: 0 additions & 3 deletions spec/truffle/tags/core/thread/raise_tags.txt

This file was deleted.

1 change: 0 additions & 1 deletion spec/truffle/tags/core/thread/set_trace_func_tags.txt

This file was deleted.

2 changes: 0 additions & 2 deletions spec/truffle/tags/core/thread/start_tags.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
fails:Thread.start Thread.start raises an ArgumentError if not passed a block
fails:Thread.start Thread.start spawns a new Thread running the block
fails:Thread.start Thread.start respects Thread subclasses
fails:Thread.start Thread.start does not call #initialize
8 changes: 0 additions & 8 deletions spec/truffle/tags/core/thread/status_tags.txt

This file was deleted.

10 changes: 0 additions & 10 deletions spec/truffle/tags/core/thread/stop_tags.txt

This file was deleted.

1 change: 0 additions & 1 deletion spec/truffle/tags/language/defined_tags.txt

This file was deleted.

2 changes: 1 addition & 1 deletion tool/jruby_eclipse
Original file line number Diff line number Diff line change
@@ -34,7 +34,7 @@ if rest.include?('-X+T')
bootclasspath << TRUFFLEJAR
classpath << SNAKEYAMLJAR
classpath << "#{JRUBY}/truffle/build.eclipse"
java_flags << "-Djruby.truffle.core.load_path=truffle/src/main/ruby"
java_flags << "-Djruby.truffle.core.load_path=#{JRUBY}/truffle/src/main/ruby"
end

args = [java]
Original file line number Diff line number Diff line change
@@ -16,6 +16,7 @@
class Symbol
alias :to_str :to_s
end
bundler.rb: "module Bundler; def self.setup; end; end"
# mock method_source gem
method_source.rb: nil
@@ -25,3 +26,6 @@
:run:
:require:
- shims
- date
- bigdecimal
- rubygems
13 changes: 12 additions & 1 deletion truffle/src/main/java/org/jruby/truffle/nodes/RubyNode.java
Original file line number Diff line number Diff line change
@@ -42,6 +42,7 @@
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.object.DynamicObjectFactory;
import com.oracle.truffle.api.source.SourceSection;
import org.jcodings.specific.USASCIIEncoding;

@TypeSystemReference(RubyTypes.class)
@ImportStatic(RubyGuards.class)
@@ -67,7 +68,7 @@ public RubyNode(RubyContext context, SourceSection sourceSection) {
public abstract Object execute(VirtualFrame frame);

public Object isDefined(VirtualFrame frame) {
return Layouts.STRING.createString(Layouts.CLASS.getInstanceFactory(getContext().getCoreLibrary().getStringClass()), StringOperations.encodeByteList("expression", UTF8Encoding.INSTANCE), StringSupport.CR_7BIT, null);
return create7BitString(StringOperations.encodeByteList("expression", UTF8Encoding.INSTANCE));
}

// Execute without returning the result
@@ -172,6 +173,16 @@ public DynamicObject getSymbol(ByteList name) {
return getContext().getSymbol(name);
}

/** Creates a String from the ByteList, with unknown CR */
protected DynamicObject createString(ByteList bytes) {
return StringOperations.createString(getContext(), bytes);
}

/** Creates a String from the ByteList, with 7-bit CR */
protected DynamicObject create7BitString(ByteList bytes) {
return StringOperations.create7BitString(getContext(), bytes);
}

protected POSIX posix() {
return getContext().getPosix();
}
Original file line number Diff line number Diff line change
@@ -31,7 +31,7 @@ public IntegerCastNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

public abstract int executeInteger(VirtualFrame frame, Object value);
public abstract int executeCastInt(Object value);

@Override
public abstract int executeInteger(VirtualFrame frame);
Original file line number Diff line number Diff line change
@@ -117,7 +117,7 @@ object, getContext().getCoreLibrary().getArrayClass(), method, array, this)

@CompilerDirectives.TruffleBoundary
private DynamicObject makeMethodNameString(String methodName) {
return Layouts.STRING.createString(getContext().getCoreLibrary().getStringFactory(), StringOperations.encodeByteList(methodName, UTF8Encoding.INSTANCE), StringSupport.CR_UNKNOWN, null);
return createString(StringOperations.encodeByteList(methodName, UTF8Encoding.INSTANCE));
}

}
Original file line number Diff line number Diff line change
@@ -57,7 +57,7 @@ public String coerceObject(VirtualFrame frame, Object object) {
try {
coerced = toStr.call(frame, object, "to_str", null);
} catch (RaiseException e) {
if (Layouts.BASIC_OBJECT.getLogicalClass(((DynamicObject) e.getRubyException())) == getContext().getCoreLibrary().getNoMethodErrorClass()) {
if (Layouts.BASIC_OBJECT.getLogicalClass(e.getRubyException()) == getContext().getCoreLibrary().getNoMethodErrorClass()) {
CompilerDirectives.transferToInterpreter();
throw new RaiseException(getContext().getCoreLibrary().typeErrorNoImplicitConversion(object, "String", this));
} else {
Original file line number Diff line number Diff line change
@@ -57,7 +57,7 @@ public DynamicObject coerceObject(VirtualFrame frame, Object object) {
try {
coerced = toStr.call(frame, object, "to_str", null);
} catch (RaiseException e) {
if (Layouts.BASIC_OBJECT.getLogicalClass(((DynamicObject) e.getRubyException())) == getContext().getCoreLibrary().getNoMethodErrorClass()) {
if (Layouts.BASIC_OBJECT.getLogicalClass(e.getRubyException()) == getContext().getCoreLibrary().getNoMethodErrorClass()) {
CompilerDirectives.transferToInterpreter();
throw new RaiseException(getContext().getCoreLibrary().typeErrorNoImplicitConversion(object, "String", this));
} else {
Original file line number Diff line number Diff line change
@@ -50,7 +50,7 @@ public DynamicObject coerceObject(VirtualFrame frame, Object object) {
try {
coerced = toAryNode.call(frame, object, "to_ary", null);
} catch (RaiseException e) {
if (Layouts.BASIC_OBJECT.getLogicalClass(((DynamicObject) e.getRubyException())) == getContext().getCoreLibrary().getNoMethodErrorClass()) {
if (Layouts.BASIC_OBJECT.getLogicalClass(e.getRubyException()) == getContext().getCoreLibrary().getNoMethodErrorClass()) {
CompilerDirectives.transferToInterpreter();

throw new RaiseException(
Original file line number Diff line number Diff line change
@@ -81,7 +81,7 @@ private double coerceObject(VirtualFrame frame, Object object) {
try {
coerced = toFNode.call(frame, object, "to_f", null);
} catch (RaiseException e) {
if (Layouts.BASIC_OBJECT.getLogicalClass(((DynamicObject) e.getRubyException())) == getContext().getCoreLibrary().getNoMethodErrorClass()) {
if (Layouts.BASIC_OBJECT.getLogicalClass(e.getRubyException()) == getContext().getCoreLibrary().getNoMethodErrorClass()) {
CompilerDirectives.transferToInterpreter();
throw new RaiseException(getContext().getCoreLibrary().typeErrorNoImplicitConversion(object, "Float", this));
} else {
Loading

0 comments on commit bd337d3

Please sign in to comment.