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

Commits on May 26, 2016

  1. [Truffle] reset buffer before reopening

    otherwise reopend io will inherit unclean buffer
    pitr-ch committed May 26, 2016
    Copy the full SHA
    9b255cf View commit details
  2. Copy the full SHA
    e73f65e View commit details
  3. Copy the full SHA
    86aebed View commit details
  4. Copy the full SHA
    bbb5009 View commit details
  5. Copy the full SHA
    05effd1 View commit details
  6. Copy the full SHA
    a48d113 View commit details
  7. Copy the full SHA
    75e7a35 View commit details
  8. Copy the full SHA
    5d8f696 View commit details
5 changes: 0 additions & 5 deletions spec/truffle/tags/core/io/eof_tags.txt

This file was deleted.

1 change: 0 additions & 1 deletion spec/truffle/tags/core/io/seek_tags.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
fails:IO#seek does not accept Bignums that don't fit in a C long
fails:IO#seek moves the read position relative to the current position with SEEK_CUR
Original file line number Diff line number Diff line change
@@ -533,8 +533,7 @@ public static abstract class IOSeekPrimitiveNode extends IOPrimitiveArrayArgumen
@Specialization
public int seek(DynamicObject io, int amount, int whence) {
final int fd = Layouts.IO.getDescriptor(io);
// TODO (pitr-ch 15-Apr-2016): should it have ensureSuccessful too?
return posix().lseek(fd, amount, whence);
return ensureSuccessful(posix().lseek(fd, amount, whence));
}

}
@@ -564,7 +563,7 @@ public int accept(DynamicObject io) {

}

@Primitive(name = "io_sysread", unsafe = UnsafeGroup.IO)
@Primitive(name = "io_sysread", unsafe = UnsafeGroup.IO, lowerFixnumParameters = 0)
public static abstract class IOSysReadPrimitiveNode extends IOPrimitiveArrayArgumentsNode {

@TruffleBoundary(throwsControlFlowException = true)
24 changes: 18 additions & 6 deletions truffle/src/main/ruby/core/io.rb
Original file line number Diff line number Diff line change
@@ -268,6 +268,7 @@ class InternalBuffer
def initialize
# Truffle: other fields are initialized in Java.
@start = 0
@eof = false
end

##
@@ -348,9 +349,9 @@ def full?
end

def inspect # :nodoc:
"#<IO::InternalBuffer:0x%x total=%p start=%p used=%p data=%p>" % [
object_id, @total, @start, @used, @storage
]
content = (@start..@used).map { |i| @storage[i].chr }.join.inspect
format "#<IO::InternalBuffer:0x%x total=%p start=%p used=%p data=%p %s>",
object_id, @total, @start, @used, @storage, content
end

##
@@ -919,6 +920,9 @@ def self.pipe(external=nil, internal=nil, options=nil)
lhs = allocate
rhs = allocate

lhs.send :initialize_allocated
rhs.send :initialize_allocated

connect_pipe(lhs, rhs)

lhs.set_encoding external || Encoding.default_external,
@@ -1218,6 +1222,7 @@ def self.setup(io, fd, mode=nil, sync=false)
# Create a new IO associated with the given fd.
#
def initialize(fd, mode=undefined, options=undefined)
initialize_allocated
if block_given?
warn 'IO::new() does not take block; use IO::open() instead'
end
@@ -1257,6 +1262,12 @@ def initialize(fd, mode=undefined, options=undefined)

private :initialize

def initialize_allocated
@eof = false
end

private :initialize_allocated

##
# Obtains a new duplicate descriptor for the current one.
def initialize_copy(original) # :nodoc:
@@ -1929,7 +1940,7 @@ def pipe?
#
def pos
flush
@ibuffer.unseek! self
reset_buffering

prim_seek 0, SEEK_CUR
end
@@ -2296,6 +2307,7 @@ def reopen(other, mode=undefined)
mode = IO.parse_mode(mode)
end

reset_buffering
reopen_path Rubinius::Type.coerce_to_path(other), mode
seek 0, SEEK_SET
end
@@ -2341,7 +2353,7 @@ def rewind
def seek(amount, whence=SEEK_SET)
flush

@ibuffer.unseek! self
reset_buffering
@eof = false

prim_seek Integer(amount), whence
@@ -2640,7 +2652,7 @@ def write(data)
if @sync
prim_write(data)
else
@ibuffer.unseek! self
reset_buffering
bytes_to_write = data.bytesize

while bytes_to_write > 0