Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 77dad38d61a4
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: c59253906357
Choose a head ref
  • 3 commits
  • 4 files changed
  • 1 contributor

Commits on Sep 2, 2015

  1. [Truffle] Typo in spec.

    chrisseaton committed Sep 2, 2015
    Copy the full SHA
    06f76d4 View commit details
  2. Copy the full SHA
    6cf2303 View commit details
  3. Copy the full SHA
    c592539 View commit details
2 changes: 1 addition & 1 deletion spec/truffle/specs/truffle/substrate_spec.rb
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@
describe "Truffle.substrate?" do

it "returns a Boolean value" do
Truffle.graal?.should be_true_or_false
Truffle.substrate?.should be_true_or_false
end

end
6 changes: 5 additions & 1 deletion truffle/src/main/java/org/jruby/truffle/nodes/RubyNode.java
Original file line number Diff line number Diff line change
@@ -219,9 +219,13 @@ protected Object ruby(VirtualFrame frame, String expression, Object... arguments

protected Object rubyWithSelf(VirtualFrame frame, Object self, String expression, Object... arguments) {
final MaterializedFrame evalFrame = setupFrame(RubyArguments.getSelf(frame.getArguments()), arguments);

final DynamicObject binding = Layouts.BINDING.createBinding(getContext().getCoreLibrary().getBindingFactory(), self, evalFrame);
return getContext().eval(expression, binding, true, "inline-ruby", this);
}

protected Object rubyWithSelf(Object self, String expression, Object... arguments) {
final MaterializedFrame evalFrame = setupFrame(self, arguments);
final DynamicObject binding = Layouts.BINDING.createBinding(getContext().getCoreLibrary().getBindingFactory(), self, evalFrame);
return getContext().eval(expression, binding, true, "inline-ruby", this);
}

Original file line number Diff line number Diff line change
@@ -262,23 +262,26 @@ public Object readIfAvailable(DynamicObject file, int numberOfBytes) {
// Taken from Rubinius's IO::read_if_available.

if (numberOfBytes == 0) {
return Layouts.STRING.createString(getContext().getCoreLibrary().getStringFactory(), new ByteList(), StringSupport.CR_UNKNOWN, null);
return Layouts.STRING.createString(getContext().getCoreLibrary().getStringFactory(),
new ByteList(), StringSupport.CR_UNKNOWN, null);
}

final int fd = Layouts.IO.getDescriptor(file);

final FDSet fdSet = fdSetFactory.create();
fdSet.set(fd);

final Pointer timeout = jnr.ffi.Runtime.getSystemRuntime().getMemoryManager().allocateDirect(8 * 2); // Needs to be two longs.
// TODO CS 2-Sep-15 why are longs 8 bytes? Is that always the case?
final Pointer timeout = getContext().getMemoryManager().allocateDirect(8 * 2); // Needs to be two longs.
timeout.putLong(0, 0);
timeout.putLong(8, 0);

final int res = nativeSockets().select(fd + 1, fdSet.getPointer(), PointerNodes.NULL_POINTER, PointerNodes.NULL_POINTER, timeout);
final int res = nativeSockets().select(fd + 1, fdSet.getPointer(),
PointerNodes.NULL_POINTER, PointerNodes.NULL_POINTER, timeout);

if (res == 0) {
CompilerDirectives.transferToInterpreter();
throw new RaiseException(getContext().getCoreLibrary().errnoError(Errno.EAGAIN.intValue(), this));
rubyWithSelf(file, "IO::EAGAINWaitReadable.new");
}

if (res < 0) {
@@ -295,10 +298,12 @@ public Object readIfAvailable(DynamicObject file, int numberOfBytes) {
}

if (bytesRead == 0) {
return Layouts.STRING.createString(getContext().getCoreLibrary().getStringFactory(), new ByteList(), StringSupport.CR_UNKNOWN, null);
return Layouts.STRING.createString(getContext().getCoreLibrary().getStringFactory(),
new ByteList(), StringSupport.CR_UNKNOWN, null);
}

return Layouts.STRING.createString(getContext().getCoreLibrary().getStringFactory(), new ByteList(bytes), StringSupport.CR_UNKNOWN, null);
return Layouts.STRING.createString(getContext().getCoreLibrary().getStringFactory(),
new ByteList(bytes), StringSupport.CR_UNKNOWN, null);
}

}
Original file line number Diff line number Diff line change
@@ -21,6 +21,7 @@
import com.oracle.truffle.api.source.SourceSection;
import com.oracle.truffle.api.tools.CoverageTracker;
import jnr.ffi.LibraryLoader;
import jnr.ffi.provider.MemoryManager;
import jnr.posix.POSIX;
import jnr.posix.POSIXFactory;
import org.jcodings.Encoding;
@@ -70,6 +71,7 @@
import java.util.Random;
import java.util.concurrent.ThreadLocalRandom;
import java.util.concurrent.atomic.AtomicLong;
import jnr.ffi.Runtime;

/**
* The global state of a running Ruby system.
@@ -84,6 +86,7 @@ public class RubyContext extends ExecutionContext implements TruffleContextInter

private final POSIX posix;
private final NativeSockets nativeSockets;
private final MemoryManager memoryManager = Runtime.getSystemRuntime().getMemoryManager();

private final CoreLibrary coreLibrary;
private final FeatureLoader featureLoader;
@@ -682,4 +685,7 @@ public Options getOptions() {
return options;
}

public MemoryManager getMemoryManager() {
return memoryManager;
}
}