-
-
Notifications
You must be signed in to change notification settings - Fork 925
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Truffle] New IO implementation #2866
Conversation
…ading the kernel.
Conflicts: truffle/src/main/java/org/jruby/truffle/runtime/core/CoreLibrary.java
Conflicts: truffle/src/main/java/org/jruby/truffle/translator/BodyTranslator.java
//if (!state -> check_async(calling_environment)) | ||
// return NULL; | ||
//io -> ensure_open(state); | ||
getContext().getSafepointManager().poll(this); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this actually works on STDIN, this will be awesome!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
STDIN.each_line do |line|
puts line
end
With both tty and piped input works. Is that what you meant?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, exactly 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean, the ability to interrupt reading from STDIN is what interests me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, I'm afraid it doesn't appear to work at the moment. Can you interrupt all reads in a process somehow?
Conflicts: truffle/src/main/ruby/core/rubinius/common/kernel.rb truffle/src/main/ruby/core/shims.rb
[Truffle] New IO implementation
Merged, but still open for comments |
public EachNode(RubyContext context, SourceSection sourceSection) { | ||
super(context, sourceSection); | ||
eachSymbol = getContext().getSymbolTable().getSymbol("each"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we use getContext().newSymbol()
almost exclusively. It might make future refactorings easier to stick with that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't know about that. I would expect it to be getContext().getSymbol()
since this will likely not create a new Symbol everytime.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's perhaps a bit misleadingly named. It just does return symbolTable.getSymbol(name, ASCIIEncoding.INSTANCE);
, which will return a cached Symbol
if it already exists or creates a new one and populates the cache otherwise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 5c53e3c
This reimplements Truffle's File and IO classes using Rubinius, on top of a few Rubinius primitives and some POSIX calls. There's now no reference to File or IO in the Java code at all.
This gives patch alone gives us 761 new passing specs (about 5% of the entire core specs), but it also opens the door for the rest of IO and things like Socket.
The primitives use
ruby()
a lot, mainly to read and write instance variables, which we might want to remove sooner rather than later.There is also a lot of copying going on here. I think
puts
will copy at least four times. The Rubinius primitives also rely on stack allocation of large buffers being efficient, which does not translate well into Java.@eregon @nirvdrum @thomaswue