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: 41e1f5f40f79
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 0655a20314da
Choose a head ref
  • 3 commits
  • 3 files changed
  • 1 contributor

Commits on Jan 25, 2016

  1. Copy the full SHA
    dc55fc3 View commit details
  2. Copy the full SHA
    4447fc3 View commit details
  3. Copy the full SHA
    0655a20 View commit details
8 changes: 8 additions & 0 deletions truffle/src/main/java/org/jruby/truffle/nodes/RubyGuards.java
Original file line number Diff line number Diff line change
@@ -35,6 +35,10 @@ public static boolean isDouble(Object value) {
return value instanceof Double;
}

public static boolean isJavaCharSequence(Object value) {
return value instanceof CharSequence;
}

// Ruby types

public static boolean isRubyBasicObject(Object object) {
@@ -223,6 +227,10 @@ public static boolean isThreadLocal(Object value) {
return value instanceof ThreadLocalObject;
}

public static boolean isTruffleObject(Object object) {
return object instanceof TruffleObject;
}

public static boolean isForeignObject(Object object) {
return object instanceof TruffleObject && !isRubyBasicObject(object);
}
Original file line number Diff line number Diff line change
@@ -113,11 +113,21 @@ public IsBoxedPrimitiveNode(RubyContext context, SourceSection sourceSection) {
this.node = Message.IS_BOXED.createNode();
}

@Specialization
public boolean isBoxedPrimitive(VirtualFrame frame, CharSequence receiver) {
return true;
}

@Specialization
public boolean isBoxedPrimitive(VirtualFrame frame, TruffleObject receiver) {
return (boolean) ForeignAccess.execute(node, frame, receiver);
}

@Specialization(guards = {"!isTruffleObject(receiver)", "!isJavaCharSequence(receiver)"})
public boolean isBoxedPrimitive(VirtualFrame frame, Object receiver) {
return false;
}

}

@CoreMethod(names = "null?", isModuleFunction = true, needsSelf = false, required = 1)
@@ -267,6 +277,13 @@ public UnboxValueNode(RubyContext context, SourceSection sourceSection) {
this.node = Message.UNBOX.createNode();
}

@Specialization
public DynamicObject executeForeign(VirtualFrame frame, CharSequence receiver) {
// TODO CS-21-Dec-15 this shouldn't be needed - we need to convert j.l.String to Ruby's String automatically

return Layouts.STRING.createString(getContext().getCoreLibrary().getStringFactory(), ByteList.create(receiver), StringSupport.CR_UNKNOWN, null);
}

@Specialization
public Object executeForeign(VirtualFrame frame, TruffleObject receiver) {
return ForeignAccess.execute(node, frame, receiver);
@@ -337,7 +354,6 @@ protected static String rubyStringToString(DynamicObject rubyString) {
@CoreMethod(names = "import", isModuleFunction = true, needsSelf = false, required = 1)
public abstract static class ImportNode extends CoreMethodArrayArgumentsNode {


public ImportNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}
Original file line number Diff line number Diff line change
@@ -241,7 +241,7 @@ public DynamicObject ensureOpen(VirtualFrame frame, DynamicObject file) {

}

@RubiniusPrimitive(name = "io_read_if_available")
@RubiniusPrimitive(name = "io_read_if_available", lowerFixnumParameters = 0)
public static abstract class IOReadIfAvailableNode extends RubiniusPrimitiveNode {

private static final FDSetFactory fdSetFactory = FDSetFactoryFactory.create();
@@ -564,7 +564,7 @@ public DynamicObject sysread(VirtualFrame frame, DynamicObject file, int length)

}

@RubiniusPrimitive(name = "io_select", needsSelf = false)
@RubiniusPrimitive(name = "io_select", needsSelf = false, lowerFixnumParameters = 3)
public static abstract class IOSelectPrimitiveNode extends RubiniusPrimitiveNode {

private static final FDSetFactory fdSetFactory = FDSetFactoryFactory.create();