Skip to content
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 rbx integration #2414

Merged
merged 16 commits into from
Jan 5, 2015
Merged

Truffle rbx integration #2414

merged 16 commits into from
Jan 5, 2015

Conversation

chrisseaton
Copy link
Contributor

This is the first big push towards implementing the Rubinius primitive system. Before we were using the standard library Struct from Rubinius, which was pure Ruby code. Here I've pulled in Rational and Time, which is tightly integrated into the Rubinius primitive system (they're like native calls).

Doing this we've got the majority of the specs passing for both of these classes in about a day. The work we're doing here will also apply for some standard library classes which also uses these primitives.

This is quite a lot of code here, but you can skip most of the Ruby files. To help you understand what's going on, I've added one comment where Ruby code calls a primitive, and another where that's implemented in Java.

@eregon, @nirvdrum, @thomaswue please review

@headius, @enebo, if you want to keep up with what we're doing, this might be a good commit to cast an eye over, but don't feel obliged to spend your time reviewing our code

# raise PrimitiveFailure, "Time.now primitive failed"
#end
def self.now
Rubinius.primitive :time_s_now
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Primitive call here. Note the unusual semantics - fall through for cases not handled.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. I wasn't following how this works.

@thomaswue
Copy link
Contributor

And as a general comment: This looks like awesome progress and the absolute right direction (i.e., implementing large parts of the standard library in Ruby itself). This gives a couple of hundreds passing specs in just one go :)!

@@ -192,7 +192,7 @@ public RubyBignum pow(RubyBignum a, RubyBignum b) {

}

@CoreMethod(names = "/", required = 1)
@CoreMethod(names = {"/", "__slash__"}, required = 1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the addition of __slash__?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rubinius calls it from here https://github.com/jruby/jruby/pull/2414/files#diff-1eabf0e4bde8dc8dce596aa4d27d7042R41. I didn't do the digging yet to figure out if it's supposed to mean something special - such as never monkey patched.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably their way to not be polluted by mathn which redefines /.
I wonder why div or quo is not sufficient though.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

__slash__ is used to define div.

@nirvdrum
Copy link
Contributor

nirvdrum commented Jan 5, 2015

This looks great. I had a few small comments, but otherwise thumbs up from me to merge.

@CompilerDirectives.TruffleBoundary
@Specialization
public boolean even(RubyBignum value) {
return value.bigIntegerValue().getLowestSetBit() != 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's got to be a better way for this, but it seems even BigInteger.intValue() goes to crazy lengths ...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BigInteger is not highly optimised, so this is probably the least of our concerns with the performance of Bignum. It is cached, however, as it's used internally for many other operations.

* Node which wraps a {@link RubiniusPrimitiveNode}, providing the implicit control flow that you get with calls to
* Rubinius primitives.
*/
public class CallRubiniusPrimitiveNode extends RubyNode {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 for not having a boolean flag all around!

@eregon
Copy link
Member

eregon commented Jan 5, 2015

Looks good to me for compatibility!
For perf, we definitely need a few adjustments.
Can we now drop the boolean rubiniusPrimitive in RubyCallNode?
And in DispatchHeadNode?

@chrisseaton
Copy link
Contributor Author

Yeah, I'll remove those. If we're going to worry about performance we need a good benchmark first!

Conflicts:
	core/src/main/java/org/jruby/truffle/nodes/core/TimeNodes.java
	core/src/main/java/org/jruby/truffle/runtime/RubyContext.java
	core/src/main/java/org/jruby/truffle/runtime/core/RubyTime.java
chrisseaton added a commit that referenced this pull request Jan 5, 2015
@chrisseaton chrisseaton merged commit 7179a58 into master Jan 5, 2015
@chrisseaton chrisseaton deleted the truffle-rbx-integration branch January 5, 2015 14:12
@chrisseaton chrisseaton modified the milestone: truffle-dev May 4, 2015
@enebo enebo added this to the Non-Release milestone Dec 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants