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: f79afdafcb59
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 35bfe638f795
Choose a head ref
  • 5 commits
  • 3 files changed
  • 1 contributor

Commits on Apr 11, 2016

  1. [Truffle] fix IO#reopen

    pitr-ch committed Apr 11, 2016
    Copy the full SHA
    c98d8f8 View commit details
  2. Copy the full SHA
    ee8cd9a View commit details
  3. Copy the full SHA
    a735815 View commit details
  4. [Truffle] Formatting

    pitr-ch committed Apr 11, 2016
    Copy the full SHA
    5c0c54b View commit details
  5. Copy the full SHA
    35bfe63 View commit details
Showing with 24 additions and 28 deletions.
  1. +0 −3 spec/truffle/tags/core/io/reopen_tags.txt
  2. +1 −1 tool/jt.rb
  3. +23 −24 truffle/src/main/java/org/jruby/truffle/core/rubinius/IOPrimitiveNodes.java
3 changes: 0 additions & 3 deletions spec/truffle/tags/core/io/reopen_tags.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
fails:IO#reopen with a String effects exec/system/fork performed after it
fails:IO#reopen with a String opens a path after writing to the original file descriptor
fails:IO#reopen with an IO reads from the beginning if the other IO has not been read from
fails:IO#reopen with an IO reads from the current position of the other IO's stream
fails:IO#reopen with an IO associates the IO instance with the other IO's stream
slow:IO#reopen with a String effects exec/system/fork performed after it
2 changes: 1 addition & 1 deletion tool/jt.rb
Original file line number Diff line number Diff line change
@@ -410,7 +410,7 @@ def test(*args)
test_tck
test_specs('run')
# test_mri # TODO (pitr-ch 29-Mar-2016): temporarily disabled
test_integration({'CI' => true, 'HAS_REDIS' => true}, 'all')
test_integration({'CI' => 'true', 'HAS_REDIS' => 'true'}, 'all')
test_compiler
when 'compiler' then test_compiler(*rest)
when 'integration' then test_integration({}, *rest)
Original file line number Diff line number Diff line change
@@ -163,7 +163,6 @@ public int open(DynamicObject path, int mode, int permission) {

}


@RubiniusPrimitive(name = "io_truncate", needsSelf = false, unsafe = UnsafeGroup.IO)
public static abstract class IOTruncatePrimitiveNode extends RubiniusPrimitiveArrayArgumentsNode {

@@ -206,7 +205,7 @@ public IOFNMatchPrimitiveNode(RubyContext context, SourceSection sourceSection)
}

@TruffleBoundary
@Specialization(guards = {"isRubyString(pattern)", "isRubyString(path)"})
@Specialization(guards = { "isRubyString(pattern)", "isRubyString(path)" })
public boolean fnmatch(DynamicObject pattern, DynamicObject path, int flags) {
final Rope patternRope = rope(pattern);
final Rope pathRope = rope(path);
@@ -235,10 +234,10 @@ public DynamicObject ensureOpen(VirtualFrame frame, DynamicObject file) {
final int fd = Layouts.IO.getDescriptor(file);
if (fd == -1) {
CompilerDirectives.transferToInterpreter();
throw new RaiseException(coreLibrary().ioError("closed stream",this));
throw new RaiseException(coreLibrary().ioError("closed stream", this));
} else if (fd == -2) {
CompilerDirectives.transferToInterpreter();
throw new RaiseException(coreLibrary().ioError("shutdown stream",this));
throw new RaiseException(coreLibrary().ioError("shutdown stream", this));
}
return nil();
}
@@ -267,7 +266,7 @@ public Object readIfAvailable(DynamicObject file, int numberOfBytes) {
fdSet.set(fd);

final Timeval timeoutObject = new DefaultNativeTimeval(jnr.ffi.Runtime.getSystemRuntime());
timeoutObject.setTime(new long[] { 0, 0 });
timeoutObject.setTime(new long[]{ 0, 0 });

final int res = nativeSockets().select(fd + 1, fdSet.getPointer(),
PointerPrimitiveNodes.NULL_POINTER, PointerPrimitiveNodes.NULL_POINTER, timeoutObject);
@@ -306,22 +305,22 @@ public IOReopenPrimitiveNode(RubyContext context, SourceSection sourceSection) {
}

@TruffleBoundary
private void performReopen(DynamicObject file, DynamicObject io) {
final int fd = Layouts.IO.getDescriptor(file);
final int fdOther = Layouts.IO.getDescriptor(io);
private void performReopen(DynamicObject self, DynamicObject target) {
final int fdSelf = Layouts.IO.getDescriptor(self);
final int fdTarget = Layouts.IO.getDescriptor(target);

final int result = posix().dup2(fd, fdOther);
if (result == -1) {
CompilerDirectives.transferToInterpreter();
throw new RaiseException(coreLibrary().errnoError(posix().errno(), this));
}
ensureSuccessful(posix().dup2(fdTarget, fdSelf));

final int mode = posix().fcntl(fd, Fcntl.F_GETFL);
if (mode < 0) {
final int newSelfMode = ensureSuccessful(posix().fcntl(fdSelf, Fcntl.F_GETFL));
Layouts.IO.setMode(self, newSelfMode);
}

private int ensureSuccessful(int result) {
if (result < 0) {
CompilerDirectives.transferToInterpreter();
throw new RaiseException(coreLibrary().errnoError(posix().errno(), this));
}
Layouts.IO.setMode(file, mode);
return result;
}

@Specialization
@@ -477,7 +476,7 @@ public int close(VirtualFrame frame, DynamicObject io) {

}

@RubiniusPrimitive(name = "io_seek", lowerFixnumParameters = {0, 1}, unsafe = UnsafeGroup.IO)
@RubiniusPrimitive(name = "io_seek", lowerFixnumParameters = { 0, 1 }, unsafe = UnsafeGroup.IO)
public static abstract class IOSeekPrimitiveNode extends RubiniusPrimitiveArrayArgumentsNode {

public IOSeekPrimitiveNode(RubyContext context, SourceSection sourceSection) {
@@ -505,7 +504,7 @@ public AcceptNode(RubyContext context, SourceSection sourceSection) {
public int accept(DynamicObject io) {
final int fd = Layouts.IO.getDescriptor(io);

final int[] addressLength = {16};
final int[] addressLength = { 16 };
final long address = UnsafeHolder.U.allocateMemory(addressLength[0]);

final int newFd;
@@ -584,7 +583,7 @@ public Object select(DynamicObject readables, DynamicObject writables, DynamicOb
}

@TruffleBoundary
@Specialization(guards = {"isRubyArray(readables)", "isNil(writables)", "isNil(errorables)"})
@Specialization(guards = { "isRubyArray(readables)", "isNil(writables)", "isNil(errorables)" })
public Object select(DynamicObject readables, DynamicObject writables, DynamicObject errorables, int timeoutMicros) {
final Object[] readableObjects = ArrayOperations.toObjectArray(readables);
final int[] readableFds = getFileDescriptors(readables);
@@ -631,10 +630,10 @@ private int callSelect(int nfds, FDSet readableSet, Timeval timeoutToUse) {
return nil();
}

return Layouts.ARRAY.createArray(coreLibrary().getArrayFactory(), new Object[] {
getSetObjects(readableObjects, readableFds, readableSet),
Layouts.ARRAY.createArray(coreLibrary().getArrayFactory(), null, 0),
Layouts.ARRAY.createArray(coreLibrary().getArrayFactory(), null, 0) },
return Layouts.ARRAY.createArray(coreLibrary().getArrayFactory(), new Object[]{
getSetObjects(readableObjects, readableFds, readableSet),
Layouts.ARRAY.createArray(coreLibrary().getArrayFactory(), null, 0),
Layouts.ARRAY.createArray(coreLibrary().getArrayFactory(), null, 0) },
3);
}

@@ -678,7 +677,7 @@ private int callSelect(int nfds, FDSet writableSet) {
return Layouts.ARRAY.createArray(coreLibrary().getArrayFactory(), new Object[]{
Layouts.ARRAY.createArray(coreLibrary().getArrayFactory(), null, 0),
getSetObjects(writableObjects, writableFds, writableSet),
Layouts.ARRAY.createArray(coreLibrary().getArrayFactory(), null, 0)},
Layouts.ARRAY.createArray(coreLibrary().getArrayFactory(), null, 0) },
3);
}