Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 6c228c700b57
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: c893eac528e6
Choose a head ref
  • 2 commits
  • 5 files changed
  • 1 contributor

Commits on Jul 1, 2015

  1. [Truffle] Use primitive types classes for primitives in static proper…

    …ties.
    
    * Integer.class would be for the case when we need to allow null.
    eregon committed Jul 1, 2015
    Copy the full SHA
    5e82154 View commit details
  2. Copy the full SHA
    c893eac View commit details
Original file line number Diff line number Diff line change
@@ -67,8 +67,8 @@ public static class SymbolType extends BasicObjectType {

STRING_PROPERTY = Property.create(STRING_IDENTIFIER, allocator.locationForType(String.class, EnumSet.of(LocationModifier.NonNull, LocationModifier.Final)), 0);
BYTE_LIST_PROPERTY = Property.create(BYTE_LIST_IDENTIFIER, allocator.locationForType(ByteList.class, EnumSet.of(LocationModifier.NonNull, LocationModifier.Final)), 0);
HASH_CODE_PROPERTY = Property.create(HASH_CODE_IDENTIFIER, allocator.locationForType(int.class, EnumSet.of(LocationModifier.NonNull, LocationModifier.Final)), 0);
CODE_RANGE_PROPERTY = Property.create(CODE_RANGE_IDENTIFIER, allocator.locationForType(int.class, EnumSet.of(LocationModifier.NonNull)), 0);
HASH_CODE_PROPERTY = Property.create(HASH_CODE_IDENTIFIER, allocator.locationForType(int.class, EnumSet.of(LocationModifier.Final)), 0);
CODE_RANGE_PROPERTY = Property.create(CODE_RANGE_IDENTIFIER, allocator.locationForType(int.class), 0);
CODE_RANGEABLE_WRAPPER_PROPERTY = Property.create(CODE_RANGEABLE_WRAPPER_IDENTIFIER, allocator.locationForType(SymbolCodeRangeableWrapper.class), 0);

final Shape shape = RubyBasicObject.LAYOUT.createShape(SYMBOL_TYPE)
Original file line number Diff line number Diff line change
@@ -28,6 +28,7 @@
import org.jruby.truffle.runtime.cext.CExtManager;
import org.jruby.truffle.runtime.cext.CExtSubsystem;
import org.jruby.truffle.runtime.control.RaiseException;
import org.jruby.truffle.runtime.core.CoreLibrary;
import org.jruby.truffle.runtime.core.RubyBasicObject;
import org.jruby.truffle.runtime.core.RubyBinding;
import org.jruby.truffle.runtime.core.RubyProc;
@@ -491,4 +492,32 @@ public Object installRubiniusPrimitive(RubyBasicObject rubyMethod) {
}
}

@CoreMethod(names = "fixnum_lower", isModuleFunction = true, required = 1)
public abstract static class FixnumLowerPrimitiveNode extends UnaryCoreMethodNode {

public FixnumLowerPrimitiveNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public int lower(int value) {
return value;
}

@Specialization(guards = "canLower(value)")
public int lower(long value) {
return (int) value;
}

@Specialization(guards = "!canLower(value)")
public long lowerFails(long value) {
return value;
}

protected static boolean canLower(long value) {
return CoreLibrary.fitsIntoInteger(value);
}

}

}
Original file line number Diff line number Diff line change
@@ -79,11 +79,11 @@ public abstract class IOBufferPrimitiveNodes {
static {
final Shape.Allocator allocator = RubyBasicObject.LAYOUT.createAllocator();

WRITE_SYNCED_PROPERTY = Property.create(WRITE_SYNCED_IDENTIFIER, allocator.locationForType(Boolean.class, EnumSet.of(LocationModifier.NonNull)), 0);
WRITE_SYNCED_PROPERTY = Property.create(WRITE_SYNCED_IDENTIFIER, allocator.locationForType(boolean.class), 0);
STORAGE_PROPERTY = Property.create(STORAGE_IDENTIFIER, allocator.locationForType(RubyBasicObject.class, EnumSet.of(LocationModifier.NonNull)), 0);
USED_PROPERTY = Property.create(USED_IDENTIFIER, allocator.locationForType(Integer.class, EnumSet.of(LocationModifier.NonNull)), 0);
START_PROPERTY = Property.create(START_IDENTIFIER, allocator.locationForType(Integer.class, EnumSet.of(LocationModifier.NonNull)), 0);
TOTAL_PROPERTY = Property.create(TOTAL_IDENTIFIER, allocator.locationForType(Integer.class, EnumSet.of(LocationModifier.NonNull)), 0);
USED_PROPERTY = Property.create(USED_IDENTIFIER, allocator.locationForType(int.class), 0);
START_PROPERTY = Property.create(START_IDENTIFIER, allocator.locationForType(int.class), 0);
TOTAL_PROPERTY = Property.create(TOTAL_IDENTIFIER, allocator.locationForType(int.class), 0);

IO_BUFFER_FACTORY = RubyBasicObject.EMPTY_SHAPE
.addProperty(WRITE_SYNCED_PROPERTY)
Original file line number Diff line number Diff line change
@@ -93,9 +93,9 @@ public abstract class IOPrimitiveNodes {
final Shape.Allocator allocator = RubyBasicObject.LAYOUT.createAllocator();

IBUFFER_PROPERTY = Property.create(IBUFFER_IDENTIFIER, allocator.locationForType(RubyBasicObject.class, EnumSet.of(LocationModifier.NonNull)), 0);
LINENO_PROPERTY = Property.create(LINENO_IDENTIFIER, allocator.locationForType(Integer.class, EnumSet.of(LocationModifier.NonNull)), 0);
DESCRIPTOR_PROPERTY = Property.create(DESCRIPTOR_IDENTIFIER, allocator.locationForType(Integer.class, EnumSet.of(LocationModifier.NonNull)), 0);
MODE_PROPERTY = Property.create(MODE_IDENTIFIER, allocator.locationForType(Integer.class, EnumSet.of(LocationModifier.NonNull)), 0);
LINENO_PROPERTY = Property.create(LINENO_IDENTIFIER, allocator.locationForType(int.class), 0);
DESCRIPTOR_PROPERTY = Property.create(DESCRIPTOR_IDENTIFIER, allocator.locationForType(int.class), 0);
MODE_PROPERTY = Property.create(MODE_IDENTIFIER, allocator.locationForType(int.class), 0);

IO_FACTORY = RubyBasicObject.EMPTY_SHAPE
.addProperty(IBUFFER_PROPERTY)
5 changes: 5 additions & 0 deletions truffle/src/main/ruby/core/rubinius/api/shims/io.rb
Original file line number Diff line number Diff line change
@@ -26,6 +26,11 @@

class IO

# Truffle: redefine setter to lower
def mode=(value)
@mode = Truffle::Primitive.fixnum_lower(value)
end

#
# Internally associate +io+ with the given descriptor.
#