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

Commits on Feb 18, 2015

  1. [Truffle] Move the interrupted check upper for clarity.

    * getting the stream should not be part of the blocking action.
    eregon committed Feb 18, 2015
    Copy the full SHA
    36d2611 View commit details
  2. 2
    Copy the full SHA
    2a34c11 View commit details
  3. Copy the full SHA
    5ffb663 View commit details
19 changes: 10 additions & 9 deletions truffle/src/main/java/org/jruby/truffle/nodes/core/IONodes.java
Original file line number Diff line number Diff line change
@@ -31,6 +31,7 @@
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
@@ -101,11 +102,16 @@ public int write(RubyString string) {
final int length = byteList.getRealSize();
final byte[] bytes = byteList.getUnsafeBytes();

// TODO (nirvdrum 17-Feb-15) This shouldn't always just write to STDOUT, but that's the only use case we're supporting currently.
final PrintStream stream = getContext().getRuntime().getInstanceConfig().getOutput();

getContext().getThreadManager().runUntilResult(new ThreadManager.BlockingActionWithoutGlobalLock<Boolean>() {
@Override
public Boolean block() throws InterruptedException {
write(bytes, offset, length);

if (Thread.interrupted()) {
throw new InterruptedException();
}
write(stream, bytes, offset, length);
return SUCCESS;
}
});
@@ -114,13 +120,8 @@ public Boolean block() throws InterruptedException {
}

@CompilerDirectives.TruffleBoundary
private void write(byte[] bytes, int offset, int length) throws InterruptedException {
if (Thread.interrupted()) {
throw new InterruptedException();
}

// TODO (nirvdrum 17-Feb-15) This shouldn't always just write to STDOUT, but that's the only use case we're supporting currently.
getContext().getRuntime().getInstanceConfig().getOutput().write(bytes, offset, length);
private void write(PrintStream stream, byte[] bytes, int offset, int length) throws InterruptedException {
stream.write(bytes, offset, length);
}

}
Original file line number Diff line number Diff line change
@@ -435,7 +435,7 @@ private RubyNilClass autoload(RubyModule module, String name, RubyString filenam
throw new RaiseException(getContext().getCoreLibrary().argumentError("empty file name", this));
}

module.setAutoloadConstant(this, name.toString(), filename);
module.setAutoloadConstant(this, name, filename);

return getContext().getCoreLibrary().getNilObject();
}
69 changes: 25 additions & 44 deletions truffle/src/main/ruby/core/shims.rb
Original file line number Diff line number Diff line change
@@ -13,82 +13,63 @@
class Channel
end

module STDIN
def self.external_encoding
@external || Encoding.default_external
class IO
def external_encoding
@external
end

def self.internal_encoding
def internal_encoding
@internal
end

def self.set_encoding(external, internal)
def set_encoding(external, internal)
@external = external
@internal = internal
end
end

class STDOUT < IO
def self.puts(*values)
STDIN = IO.new

class << STDIN
def external_encoding
super || Encoding.default_external
end
end

STDOUT = IO.new
$stdout = STDOUT

class << STDOUT
def puts(*values)
Kernel.send(:puts, *values)
end

def self.print(*values)
def print(*values)
Kernel.send(:print, *values)
end

def self.printf(*values)
def printf(*values)
Kernel.send(:printf, *values)
end

def self.write(value)
IO.new.write value
end

def self.flush
def flush
Truffle::Debug.flush_stdout
end

def self.sync
def sync
false
end

def self.sync=(value)
end

def self.external_encoding
@external
end

def self.internal_encoding
@internal
end

def self.set_encoding(external, internal)
@external = external
@internal = internal
def sync=(value)
end
end

$stdout = STDOUT
STDERR = IO.new

module STDERR
class << STDERR
def self.puts(*values)
Kernel.send(:puts, *values)
end

def self.external_encoding
@external
end

def self.internal_encoding
@internal
end

def self.set_encoding(external, internal)
@external = external
@internal = internal
end
end

ARGF = Object.new