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: d38b7b66e682
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 876eab61a31f
Choose a head ref
  • 16 commits
  • 21 files changed
  • 1 contributor

Commits on Apr 6, 2016

  1. [Truffle] Time is safe.

    chrisseaton committed Apr 6, 2016
    Copy the full SHA
    fa0fad6 View commit details
  2. Copy the full SHA
    eaedfe7 View commit details
  3. Copy the full SHA
    7cdff4e View commit details
  4. Copy the full SHA
    8422854 View commit details
  5. Copy the full SHA
    799971f View commit details
  6. Copy the full SHA
    3cdbb1d View commit details
  7. Copy the full SHA
    f7ac98c View commit details
  8. Copy the full SHA
    fdd0890 View commit details
  9. Copy the full SHA
    361c73f View commit details
  10. Copy the full SHA
    eb81113 View commit details
  11. Copy the full SHA
    47c6868 View commit details
  12. Copy the full SHA
    295a048 View commit details
  13. Copy the full SHA
    e8e9e7c View commit details
  14. Copy the full SHA
    a708a57 View commit details
  15. Copy the full SHA
    08b18d3 View commit details
  16. Copy the full SHA
    876eab6 View commit details
Showing with 167 additions and 120 deletions.
  1. +2 −1 core/src/main/java/org/jruby/util/cli/Options.java
  2. +6 −5 test/truffle/integration/safe.sh
  3. +0 −2 truffle/src/main/java/org/jruby/truffle/core/CoreMethod.java
  4. +3 −0 truffle/src/main/java/org/jruby/truffle/core/CoreMethodNodeManager.java
  5. +1 −1 truffle/src/main/java/org/jruby/truffle/core/kernel/KernelNodes.java
  6. +4 −3 truffle/src/main/java/org/jruby/truffle/core/rubinius/IOBufferPrimitiveNodes.java
  7. +17 −16 truffle/src/main/java/org/jruby/truffle/core/rubinius/IOPrimitiveNodes.java
  8. +1 −1 truffle/src/main/java/org/jruby/truffle/core/rubinius/NativeFunctionPrimitiveNodes.java
  9. +16 −15 truffle/src/main/java/org/jruby/truffle/core/rubinius/PointerPrimitiveNodes.java
  10. +29 −29 truffle/src/main/java/org/jruby/truffle/core/rubinius/PosixNodes.java
  11. +0 −2 truffle/src/main/java/org/jruby/truffle/core/rubinius/RubiniusPrimitive.java
  12. +1 −1 truffle/src/main/java/org/jruby/truffle/core/rubinius/RubiniusTypeNodes.java
  13. +17 −16 truffle/src/main/java/org/jruby/truffle/core/rubinius/StatPrimitiveNodes.java
  14. +10 −10 truffle/src/main/java/org/jruby/truffle/core/rubinius/TimePrimitiveNodes.java
  15. +29 −1 truffle/src/main/java/org/jruby/truffle/extra/TrufflePrimitiveNodes.java
  16. +2 −1 truffle/src/main/java/org/jruby/truffle/language/Options.java
  17. +1 −1 truffle/src/main/java/org/jruby/truffle/language/globals/CheckStdoutVariableTypeNode.java
  18. +1 −0 truffle/src/main/java/org/jruby/truffle/platform/UnsafeGroup.java
  19. +4 −2 truffle/src/main/ruby/core/main.rb
  20. +5 −1 truffle/src/main/ruby/core/rubinius/platform/pointer.rb
  21. +18 −12 truffle/src/main/ruby/core/shims.rb
3 changes: 2 additions & 1 deletion core/src/main/java/org/jruby/util/cli/Options.java
Original file line number Diff line number Diff line change
@@ -224,7 +224,8 @@ public class Options {

public static final Option<Boolean> TRUFFLE_PLATFORM_SAFE = bool(TRUFFLE, "truffle.platform.safe", true, "Default value for the safety of all operations.");
public static final Option<Boolean> TRUFFLE_PLATFORM_SAFE_LOAD = bool(TRUFFLE, "truffle.platform.safe.load", TRUFFLE_PLATFORM_SAFE.load(), "Treat loading, requiring and autoloading as safe.");
public static final Option<Boolean> TRUFFLE_PLATFORM_SAFE_IO = bool(TRUFFLE, "truffle.platform.safe.io", TRUFFLE_PLATFORM_SAFE.load(), "Treat any methods that deal perofrm IO as safe.");
public static final Option<Boolean> TRUFFLE_PLATFORM_SAFE_IO = bool(TRUFFLE, "truffle.platform.safe.io", TRUFFLE_PLATFORM_SAFE.load(), "Treat any methods that deal with IO as safe.");
public static final Option<Boolean> TRUFFLE_PLATFORM_SAFE_MEMORY = bool(TRUFFLE, "truffle.platform.safe.memory", TRUFFLE_PLATFORM_SAFE.load(), "Treat any methods that deal with unmanaged memory as safe.");
public static final Option<Boolean> TRUFFLE_PLATFORM_SAFE_THREADS = bool(TRUFFLE, "truffle.platform.safe.threads", TRUFFLE_PLATFORM_SAFE.load(), "Treat any methods that deal with threads as safe.");
public static final Option<Boolean> TRUFFLE_PLATFORM_SAFE_PROCESSES = bool(TRUFFLE, "truffle.platform.safe.processes", TRUFFLE_PLATFORM_SAFE.load(), "Treat any methods that deal with processes as safe.");
public static final Option<Boolean> TRUFFLE_PLATFORM_SAFE_SIGNALS = bool(TRUFFLE, "truffle.platform.safe.siganls", TRUFFLE_PLATFORM_SAFE.load(), "Treat any methods that deal with signals as safe.");
11 changes: 6 additions & 5 deletions test/truffle/integration/safe.sh
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@ function unsafe {

# Things that are alway safe

safe -e "14"
safe -e 14

# Check our safe_puts is safe

@@ -24,16 +24,17 @@ safe -e "Truffle::Primitive.safe_puts 'hello, world'"

unsafe -Xtruffle.platform.safe_puts=false -e "Truffle::Primitive.safe_puts 'hello, world'"

# Check default unsafe operations
# Try some unsafe operations

#unsafe -e "puts 'hello, world'"
unsafe -e "puts 'hello, world'"
unsafe -e '`echo foo`'
unsafe -e 'exit!'
unsafe -e 'Rubinius::FFI::Pointer.new(1).read_int'
unsafe -e "File.open('bad.txt')"

# Check we can enable some unsafe operations if we want to

safe -Xtruffle.platform.safe.processes=true -e '`echo foo`'
safe -Xtruffle.platform.safe.exit=true -e 'exit'
safe -Xtruffle.platform.safe.exit=true -e 'exit!'

# Check that safe_puts sanitises correctly

2 changes: 0 additions & 2 deletions truffle/src/main/java/org/jruby/truffle/core/CoreMethod.java
Original file line number Diff line number Diff line change
@@ -84,6 +84,4 @@

UnsafeGroup[] unsafe() default {};

boolean unsafeNeedsAudit() default false;

}
Original file line number Diff line number Diff line change
@@ -271,6 +271,9 @@ public static boolean isSafe(RubyContext context, UnsafeGroup[] groups) {
case IO:
option = options.PLATFORM_SAFE_IO;
break;
case MEMORY:
option = options.PLATFORM_SAFE_MEMORY;
break;
case THREADS:
option = options.PLATFORM_SAFE_THREADS;
break;
Original file line number Diff line number Diff line change
@@ -144,7 +144,7 @@
@CoreClass(name = "Kernel")
public abstract class KernelNodes {

@CoreMethod(names = "`", isModuleFunction = true, needsSelf = false, required = 1, unsafe = UnsafeGroup.PROCESSES)
@CoreMethod(names = "`", isModuleFunction = true, needsSelf = false, required = 1, unsafe = {UnsafeGroup.IO, UnsafeGroup.PROCESSES})
public abstract static class BacktickNode extends CoreMethodArrayArgumentsNode {

@Child private CallDispatchHeadNode toHashNode;
Original file line number Diff line number Diff line change
@@ -52,14 +52,15 @@
import org.jruby.truffle.language.control.RaiseException;
import org.jruby.truffle.language.objects.AllocateObjectNode;
import org.jruby.truffle.language.objects.AllocateObjectNodeGen;
import org.jruby.truffle.platform.UnsafeGroup;
import org.jruby.util.ByteList;

public abstract class IOBufferPrimitiveNodes {

private static final int IOBUFFER_SIZE = 32768;
private static final int STACK_BUF_SZ = 8192;

@RubiniusPrimitive(unsafeNeedsAudit = true, name = "iobuffer_allocate")
@RubiniusPrimitive(name = "iobuffer_allocate", unsafe = UnsafeGroup.IO)
public static abstract class IOBufferAllocatePrimitiveNode extends RubiniusPrimitiveArrayArgumentsNode {

@Child private AllocateObjectNode allocateNode;
@@ -80,7 +81,7 @@ public DynamicObject allocate(DynamicObject classToAllocate) {

}

@RubiniusPrimitive(unsafeNeedsAudit = true, name = "iobuffer_unshift", lowerFixnumParameters = 1)
@RubiniusPrimitive(name = "iobuffer_unshift", lowerFixnumParameters = 1, unsafe = UnsafeGroup.IO)
public static abstract class IOBufferUnshiftPrimitiveNode extends RubiniusPrimitiveArrayArgumentsNode {

public IOBufferUnshiftPrimitiveNode(RubyContext context, SourceSection sourceSection) {
@@ -112,7 +113,7 @@ public int unshift(VirtualFrame frame, DynamicObject ioBuffer, DynamicObject str

}

@RubiniusPrimitive(unsafeNeedsAudit = true, name = "iobuffer_fill")
@RubiniusPrimitive(name = "iobuffer_fill", unsafe = UnsafeGroup.IO)
public static abstract class IOBufferFillPrimitiveNode extends RubiniusPrimitiveArrayArgumentsNode {

public IOBufferFillPrimitiveNode(RubyContext context, SourceSection sourceSection) {
Original file line number Diff line number Diff line change
@@ -60,6 +60,7 @@
import org.jruby.truffle.language.dispatch.DispatchHeadNodeFactory;
import org.jruby.truffle.language.objects.AllocateObjectNode;
import org.jruby.truffle.language.objects.AllocateObjectNodeGen;
import org.jruby.truffle.platform.UnsafeGroup;
import org.jruby.truffle.stdlib.sockets.FDSet;
import org.jruby.truffle.stdlib.sockets.FDSetFactory;
import org.jruby.truffle.stdlib.sockets.FDSetFactoryFactory;
@@ -75,7 +76,7 @@ public abstract class IOPrimitiveNodes {

private static int STDOUT = 1;

@RubiniusPrimitive(unsafeNeedsAudit = true, name = "io_allocate")
@RubiniusPrimitive(name = "io_allocate", unsafe = UnsafeGroup.IO)
public static abstract class IOAllocatePrimitiveNode extends RubiniusPrimitiveArrayArgumentsNode {

@Child private CallDispatchHeadNode newBufferNode;
@@ -95,7 +96,7 @@ public DynamicObject allocate(VirtualFrame frame, DynamicObject classToAllocate)

}

@RubiniusPrimitive(unsafeNeedsAudit = true, name = "io_connect_pipe", needsSelf = false)
@RubiniusPrimitive(name = "io_connect_pipe", needsSelf = false, unsafe = UnsafeGroup.IO)
public static abstract class IOConnectPipeNode extends RubiniusPrimitiveArrayArgumentsNode {

private final int RDONLY;
@@ -150,7 +151,7 @@ private void newOpenFd(int newFd) {
}
}

@RubiniusPrimitive(unsafeNeedsAudit = true, name = "io_open", needsSelf = false, lowerFixnumParameters = { 1, 2 })
@RubiniusPrimitive(name = "io_open", needsSelf = false, lowerFixnumParameters = { 1, 2 }, unsafe = UnsafeGroup.IO)
public static abstract class IOOpenPrimitiveNode extends RubiniusPrimitiveArrayArgumentsNode {

public IOOpenPrimitiveNode(RubyContext context, SourceSection sourceSection) {
@@ -165,7 +166,7 @@ public int open(DynamicObject path, int mode, int permission) {
}


@RubiniusPrimitive(unsafeNeedsAudit = true, name = "io_truncate", needsSelf = false)
@RubiniusPrimitive(name = "io_truncate", needsSelf = false, unsafe = UnsafeGroup.IO)
public static abstract class IOTruncatePrimitiveNode extends RubiniusPrimitiveArrayArgumentsNode {

public IOTruncatePrimitiveNode(RubyContext context, SourceSection sourceSection) {
@@ -184,7 +185,7 @@ public int truncate(DynamicObject path, long length) {

}

@RubiniusPrimitive(unsafeNeedsAudit = true, name = "io_ftruncate")
@RubiniusPrimitive(name = "io_ftruncate", unsafe = UnsafeGroup.IO)
public static abstract class IOFTruncatePrimitiveNode extends RubiniusPrimitiveArrayArgumentsNode {

public IOFTruncatePrimitiveNode(RubyContext context, SourceSection sourceSection) {
@@ -199,7 +200,7 @@ public int ftruncate(VirtualFrame frame, DynamicObject io, long length) {

}

@RubiniusPrimitive(unsafeNeedsAudit = true, name = "io_fnmatch", needsSelf = false)
@RubiniusPrimitive(name = "io_fnmatch", needsSelf = false, unsafe = UnsafeGroup.IO)
public static abstract class IOFNMatchPrimitiveNode extends RubiniusPrimitiveArrayArgumentsNode {

public IOFNMatchPrimitiveNode(RubyContext context, SourceSection sourceSection) {
@@ -223,7 +224,7 @@ public boolean fnmatch(DynamicObject pattern, DynamicObject path, int flags) {

}

@RubiniusPrimitive(unsafeNeedsAudit = true, name = "io_ensure_open")
@RubiniusPrimitive(name = "io_ensure_open", unsafe = UnsafeGroup.IO)
public static abstract class IOEnsureOpenPrimitiveNode extends RubiniusPrimitiveArrayArgumentsNode {

public IOEnsureOpenPrimitiveNode(RubyContext context, SourceSection sourceSection) {
@@ -246,7 +247,7 @@ public DynamicObject ensureOpen(VirtualFrame frame, DynamicObject file) {

}

@RubiniusPrimitive(unsafeNeedsAudit = true, name = "io_read_if_available", lowerFixnumParameters = 0)
@RubiniusPrimitive(name = "io_read_if_available", lowerFixnumParameters = 0, unsafe = UnsafeGroup.IO)
public static abstract class IOReadIfAvailableNode extends RubiniusPrimitiveArrayArgumentsNode {

private static final FDSetFactory fdSetFactory = FDSetFactoryFactory.create();
@@ -298,7 +299,7 @@ public Object readIfAvailable(DynamicObject file, int numberOfBytes) {

}

@RubiniusPrimitive(unsafeNeedsAudit = true, name = "io_reopen")
@RubiniusPrimitive(name = "io_reopen", unsafe = UnsafeGroup.IO)
public static abstract class IOReopenPrimitiveNode extends RubiniusPrimitiveArrayArgumentsNode {

@Child private CallDispatchHeadNode resetBufferingNode;
@@ -338,7 +339,7 @@ public Object reopen(VirtualFrame frame, DynamicObject file, DynamicObject io) {

}

@RubiniusPrimitive(unsafeNeedsAudit = true, name = "io_reopen_path", lowerFixnumParameters = 1)
@RubiniusPrimitive(name = "io_reopen_path", lowerFixnumParameters = 1, unsafe = UnsafeGroup.IO)
public static abstract class IOReopenPathPrimitiveNode extends RubiniusPrimitiveArrayArgumentsNode {

@Child private CallDispatchHeadNode resetBufferingNode;
@@ -397,7 +398,7 @@ public Object reopenPath(VirtualFrame frame, DynamicObject file, DynamicObject p

}

@RubiniusPrimitive(unsafeNeedsAudit = true, name = "io_write")
@RubiniusPrimitive(name = "io_write", unsafe = UnsafeGroup.IO)
public static abstract class IOWritePrimitiveNode extends RubiniusPrimitiveArrayArgumentsNode {

public IOWritePrimitiveNode(RubyContext context, SourceSection sourceSection) {
@@ -441,7 +442,7 @@ public int write(DynamicObject file, DynamicObject string) {

}

@RubiniusPrimitive(unsafeNeedsAudit = true, name = "io_close")
@RubiniusPrimitive(name = "io_close", unsafe = UnsafeGroup.IO)
public static abstract class IOClosePrimitiveNode extends RubiniusPrimitiveArrayArgumentsNode {

@Child private CallDispatchHeadNode ensureOpenNode;
@@ -480,7 +481,7 @@ public int close(VirtualFrame frame, DynamicObject io) {

}

@RubiniusPrimitive(unsafeNeedsAudit = true, name = "io_seek", lowerFixnumParameters = {0, 1})
@RubiniusPrimitive(name = "io_seek", lowerFixnumParameters = {0, 1}, unsafe = UnsafeGroup.IO)
public static abstract class IOSeekPrimitiveNode extends RubiniusPrimitiveArrayArgumentsNode {

public IOSeekPrimitiveNode(RubyContext context, SourceSection sourceSection) {
@@ -495,7 +496,7 @@ public int seek(VirtualFrame frame, DynamicObject io, int amount, int whence) {

}

@RubiniusPrimitive(unsafeNeedsAudit = true, name = "io_accept")
@RubiniusPrimitive(name = "io_accept", unsafe = UnsafeGroup.IO)
public abstract static class AcceptNode extends RubiniusPrimitiveArrayArgumentsNode {

public AcceptNode(RubyContext context, SourceSection sourceSection) {
@@ -529,7 +530,7 @@ public int accept(DynamicObject io) {

}

@RubiniusPrimitive(unsafeNeedsAudit = true, name = "io_sysread")
@RubiniusPrimitive(name = "io_sysread", unsafe = UnsafeGroup.IO)
public static abstract class IOSysReadPrimitiveNode extends RubiniusPrimitiveArrayArgumentsNode {

public IOSysReadPrimitiveNode(RubyContext context, SourceSection sourceSection) {
@@ -569,7 +570,7 @@ public DynamicObject sysread(VirtualFrame frame, DynamicObject file, int length)

}

@RubiniusPrimitive(unsafeNeedsAudit = true, name = "io_select", needsSelf = false, lowerFixnumParameters = 3)
@RubiniusPrimitive(name = "io_select", needsSelf = false, lowerFixnumParameters = 3, unsafe = UnsafeGroup.IO)
public static abstract class IOSelectPrimitiveNode extends RubiniusPrimitiveArrayArgumentsNode {

private static final FDSetFactory fdSetFactory = FDSetFactoryFactory.create();
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@

public abstract class NativeFunctionPrimitiveNodes {

@RubiniusPrimitive(unsafeNeedsAudit = true, name = "nativefunction_type_size", needsSelf = false)
@RubiniusPrimitive(name = "nativefunction_type_size", needsSelf = false)
public static abstract class NativeFunctionTypeSizePrimitiveNode extends RubiniusPrimitiveArrayArgumentsNode {

public NativeFunctionTypeSizePrimitiveNode(RubyContext context, SourceSection sourceSection) {
Loading