Skip to content

Commit 787bdf0

Browse files
committed
[Truffle] Adding int long specialization to Fixnum#>>.
1 parent 0902cd3 commit 787bdf0

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

truffle/src/main/java/org/jruby/truffle/nodes/core/FixnumNodes.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1328,6 +1328,28 @@ public Object rightShift(VirtualFrame frame, int a, int b) {
13281328
}
13291329
}
13301330

1331+
@Specialization
1332+
public Object rightShift(VirtualFrame frame, int a, long b) {
1333+
if (b > 0) {
1334+
if (b >= BITS - 1) {
1335+
if (a < 0) {
1336+
return -1;
1337+
} else {
1338+
return 0;
1339+
}
1340+
} else {
1341+
return a >> b;
1342+
}
1343+
} else {
1344+
if (leftShiftNode == null) {
1345+
CompilerDirectives.transferToInterpreter();
1346+
leftShiftNode = insert(FixnumNodesFactory.LeftShiftNodeFactory.create(getContext(), getSourceSection(), new RubyNode[]{null, null}));
1347+
}
1348+
1349+
return leftShiftNode.executeLeftShift(frame, a, -b);
1350+
}
1351+
}
1352+
13311353
@Specialization
13321354
public Object rightShift(VirtualFrame frame, long a, int b) {
13331355
if (b > 0) {

0 commit comments

Comments
 (0)