Skip to content

Commit

Permalink
[Truffle] Adding int long specialization to Fixnum#>>.
Browse files Browse the repository at this point in the history
  • Loading branch information
bjfish committed Apr 19, 2015
1 parent 0902cd3 commit 787bdf0
Showing 1 changed file with 22 additions and 0 deletions.
Expand Up @@ -1328,6 +1328,28 @@ public Object rightShift(VirtualFrame frame, int a, int b) {
}
}

@Specialization
public Object rightShift(VirtualFrame frame, int a, long b) {
if (b > 0) {
if (b >= BITS - 1) {
if (a < 0) {
return -1;
} else {
return 0;
}
} else {
return a >> b;
}
} else {
if (leftShiftNode == null) {
CompilerDirectives.transferToInterpreter();
leftShiftNode = insert(FixnumNodesFactory.LeftShiftNodeFactory.create(getContext(), getSourceSection(), new RubyNode[]{null, null}));
}

return leftShiftNode.executeLeftShift(frame, a, -b);
}
}

@Specialization
public Object rightShift(VirtualFrame frame, long a, int b) {
if (b > 0) {
Expand Down

0 comments on commit 787bdf0

Please sign in to comment.