Skip to content

Commit

Permalink
[Truffle] Fixed more specs for 64-bit ropes.
Browse files Browse the repository at this point in the history
nirvdrum committed Apr 8, 2016
1 parent c240e8c commit 7f397bc
Showing 3 changed files with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -106,7 +106,7 @@ public Object downto(VirtualFrame frame, Object from, Object to, DynamicObject b

}

@CoreMethod(names = "times", needsBlock = true)
@CoreMethod(names = "times", needsBlock = true, lowerFixnumSelf = true)
public abstract static class TimesNode extends YieldingCoreMethodNode {

// TODO CS 2-May-15 we badly need OSR in this node
Original file line number Diff line number Diff line change
@@ -551,12 +551,17 @@ public IOSysReadPrimitiveNode(RubyContext context, SourceSection sourceSection)
}

@Specialization
public DynamicObject sysread(VirtualFrame frame, DynamicObject file, int length) {
public DynamicObject sysread(VirtualFrame frame, DynamicObject file, long length) {
if (!CoreLibrary.fitsIntoInteger(length)) {
CompilerDirectives.transferToInterpreter();
throw new RopeTooLongException("Can't work with lengths larger than int range");
}

final int fd = Layouts.IO.getDescriptor(file);

final ByteBuffer buffer = ByteBuffer.allocate(length);
final ByteBuffer buffer = ByteBuffer.allocate((int) length);

int toRead = length;
int toRead = (int) length;

while (toRead > 0) {
getContext().getSafepointManager().poll(this);
Original file line number Diff line number Diff line change
@@ -687,12 +687,12 @@ public StringFindCharacterNode(RubyContext context, SourceSection sourceSection)
}

@Specialization(guards = "offset < 0")
public Object stringFindCharacterNegativeOffset(DynamicObject string, int offset) {
public Object stringFindCharacterNegativeOffset(DynamicObject string, long offset) {
return nil();
}

@Specialization(guards = { "offset >= 0", "isSingleByte(string)" })
public Object stringFindCharacterSingleByte(DynamicObject string, int offset,
public Object stringFindCharacterSingleByte(DynamicObject string, long offset,
@Cached("createBinaryProfile()") ConditionProfile offsetTooLargeProfile) {
// Taken from Rubinius's String::find_character.

@@ -707,7 +707,7 @@ public Object stringFindCharacterSingleByte(DynamicObject string, int offset,
}

@Specialization(guards = { "offset >= 0", "!isSingleByte(string)" })
public Object stringFindCharacter(DynamicObject string, int offset,
public Object stringFindCharacter(DynamicObject string, long offset,
@Cached("createBinaryProfile()") ConditionProfile offsetTooLargeProfile) {
// Taken from Rubinius's String::find_character.

0 comments on commit 7f397bc

Please sign in to comment.