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: 919cf42e6466
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: b94d8a36ee29
Choose a head ref
  • 17 commits
  • 20 files changed
  • 1 contributor

Commits on Apr 5, 2016

  1. Copy the full SHA
    c4a638b View commit details
  2. Copy the full SHA
    0b6d540 View commit details
  3. Copy the full SHA
    938a2db View commit details
  4. Copy the full SHA
    9e7a948 View commit details
  5. Copy the full SHA
    3ddde4e View commit details
  6. Copy the full SHA
    787b7f8 View commit details
  7. Copy the full SHA
    f12ac67 View commit details
  8. Copy the full SHA
    0354cee View commit details
  9. Copy the full SHA
    c7c8e33 View commit details
  10. Copy the full SHA
    c3a5e82 View commit details
  11. Copy the full SHA
    9e141b4 View commit details
  12. Copy the full SHA
    0ef6821 View commit details
  13. Copy the full SHA
    65f4d33 View commit details
  14. Copy the full SHA
    ae0f29c View commit details
  15. Copy the full SHA
    cca948d View commit details
  16. Copy the full SHA
    bf6867a View commit details
  17. Copy the full SHA
    b94d8a3 View commit details
Showing with 258 additions and 242 deletions.
  1. +5 −3 core/src/main/java/org/jruby/util/cli/Options.java
  2. +1 −1 test/truffle/integration/safe.sh
  3. +7 −1 truffle/src/main/java/org/jruby/truffle/core/CoreMethodNodeManager.java
  4. +7 −6 truffle/src/main/java/org/jruby/truffle/core/fiber/FiberNodes.java
  5. +47 −47 truffle/src/main/java/org/jruby/truffle/core/kernel/KernelNodes.java
  6. +10 −10 truffle/src/main/java/org/jruby/truffle/core/method/MethodNodes.java
  7. +9 −9 truffle/src/main/java/org/jruby/truffle/core/method/UnboundMethodNodes.java
  8. +58 −58 truffle/src/main/java/org/jruby/truffle/core/module/ModuleNodes.java
  9. +12 −12 truffle/src/main/java/org/jruby/truffle/core/regexp/MatchDataNodes.java
  10. +8 −8 truffle/src/main/java/org/jruby/truffle/core/regexp/RegexpNodes.java
  11. +5 −5 truffle/src/main/java/org/jruby/truffle/core/rubinius/AtomicReferenceNodes.java
  12. +6 −6 truffle/src/main/java/org/jruby/truffle/core/rubinius/ByteArrayNodes.java
  13. +2 −2 truffle/src/main/java/org/jruby/truffle/core/rubinius/RubiniusPrimitiveNodeConstructor.java
  14. +16 −15 truffle/src/main/java/org/jruby/truffle/core/thread/ThreadNodes.java
  15. +4 −0 truffle/src/main/java/org/jruby/truffle/language/Options.java
  16. +2 −0 truffle/src/main/java/org/jruby/truffle/platform/UnsafeGroup.java
  17. +29 −29 truffle/src/main/java/org/jruby/truffle/stdlib/BigDecimalNodes.java
  18. +10 −10 truffle/src/main/java/org/jruby/truffle/stdlib/DigestNodes.java
  19. +18 −18 truffle/src/main/java/org/jruby/truffle/stdlib/psych/PsychEmitterNodes.java
  20. +2 −2 truffle/src/main/java/org/jruby/truffle/stdlib/psych/PsychParserNodes.java
8 changes: 5 additions & 3 deletions core/src/main/java/org/jruby/util/cli/Options.java
Original file line number Diff line number Diff line change
@@ -222,9 +222,11 @@ public class Options {
public static final Option<Boolean> CLI_STRIP_HEADER = bool(CLI, "cli.strip.header", false, "Strip text before shebang in script. Same as -x.");
public static final Option<Boolean> CLI_LOAD_GEMFILE = bool(CLI, "cli.load.gemfile", false, "Load a bundler Gemfile in cwd before running. Same as -G.");

public static final Option<Boolean> TRUFFLE_PLATFORM_SAFE = bool(TRUFFLE, "truffle.platform.safe", false, "Disallow any unsafe access to the platform, such as IO, processes and so on.");
public static final Option<Boolean> TRUFFLE_PLATFORM_SAFE_PROCESSES = bool(TRUFFLE, "truffle.platform.safe.processes", false, "Treat any methods that deal with processes as safe.");
public static final Option<Boolean> TRUFFLE_PLATFORM_SAFE_EXIT = bool(TRUFFLE, "truffle.platform.safe.exit", false, "Treat #exit! (hard exiting the VM) as safe.");
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_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_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_EXIT = bool(TRUFFLE, "truffle.platform.safe.exit", TRUFFLE_PLATFORM_SAFE.load(), "Treat #exit! (hard exiting the VM) as safe.");
public static final Option<Boolean> TRUFFLE_PLATFORM_SAFE_PUTS = bool(TRUFFLE, "truffle.platform.safe_puts", true, "Treat Truffle::Primitive.safe_puts as safe.");
public static final Option<Boolean> TRUFFLE_PLATFORM_USE_JAVA = bool(TRUFFLE, "truffle.platform.use_java", false, "Use a pure-Java platform, so no native POSIX.");

2 changes: 1 addition & 1 deletion test/truffle/integration/safe.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash

function run {
ruby -X+T -Xtruffle.platform.safe=true "$@"
ruby -X+T -Xtruffle.platform.safe=false "$@"
}

function safe {
Original file line number Diff line number Diff line change
@@ -236,7 +236,7 @@ private static RubyRootNode makeGenericMethod(RubyContext context, MethodDetails

RubyNode sequence;

if (context.getOptions().PLATFORM_SAFE && !isSafe(context, method.unsafe())) {
if (!isSafe(context, method.unsafe())) {
sequence = new UnsafeNode(context, sourceSection);
} else {
sequence = Translator.sequence(context, sourceSection, Arrays.asList(checkArity, methodNode));
@@ -265,6 +265,12 @@ public static boolean isSafe(RubyContext context, UnsafeGroup[] groups) {
final boolean option;

switch (group) {
case IO:
option = options.PLATFORM_SAFE_IO;
break;
case THREADS:
option = options.PLATFORM_SAFE_THREADS;
break;
case PROCESSES:
option = options.PLATFORM_SAFE_PROCESSES;
break;
Original file line number Diff line number Diff line change
@@ -35,6 +35,7 @@
import org.jruby.truffle.language.control.RaiseException;
import org.jruby.truffle.language.control.ReturnException;
import org.jruby.truffle.language.methods.UnsupportedOperationBehavior;
import org.jruby.truffle.platform.UnsafeGroup;

import java.util.concurrent.CountDownLatch;
import java.util.concurrent.LinkedBlockingQueue;
@@ -244,7 +245,7 @@ protected Object transfer(VirtualFrame frame, DynamicObject fiber, boolean isYie

}

@CoreMethod(unsafeNeedsAudit = true, names = "initialize", needsBlock = true, unsupportedOperationBehavior = UnsupportedOperationBehavior.ARGUMENT_ERROR)
@CoreMethod(names = "initialize", needsBlock = true, unsupportedOperationBehavior = UnsupportedOperationBehavior.ARGUMENT_ERROR, unsafe = UnsafeGroup.THREADS)
public abstract static class InitializeNode extends CoreMethodArrayArgumentsNode {

public InitializeNode(RubyContext context, SourceSection sourceSection) {
@@ -260,7 +261,7 @@ public DynamicObject initialize(DynamicObject fiber, DynamicObject block) {

}

@CoreMethod(unsafeNeedsAudit = true, names = "resume", rest = true)
@CoreMethod(names = "resume", rest = true, unsafe = UnsafeGroup.THREADS)
public abstract static class ResumeNode extends CoreMethodArrayArgumentsNode {

@Child FiberTransferNode fiberTransferNode;
@@ -277,7 +278,7 @@ public Object resume(VirtualFrame frame, DynamicObject fiberBeingResumed, Object

}

@CoreMethod(unsafeNeedsAudit = true, names = "yield", onSingleton = true, rest = true)
@CoreMethod(names = "yield", onSingleton = true, rest = true, unsafe = UnsafeGroup.THREADS)
public abstract static class YieldNode extends CoreMethodArrayArgumentsNode {

@Child FiberTransferNode fiberTransferNode;
@@ -351,7 +352,7 @@ public static class FiberExitException extends ControlFlowException {
private static final long serialVersionUID = 1522270454305076317L;
}

@CoreMethod(unsafeNeedsAudit = true, names = "alive?")
@CoreMethod(names = "alive?", unsafe = UnsafeGroup.THREADS)
public abstract static class AliveNode extends UnaryCoreMethodNode {

public AliveNode(RubyContext context, SourceSection sourceSection) {
@@ -365,7 +366,7 @@ public boolean alive(DynamicObject fiber) {

}

@CoreMethod(unsafeNeedsAudit = true, names = "current", onSingleton = true)
@CoreMethod(names = "current", onSingleton = true)
public abstract static class CurrentNode extends CoreMethodNode {

public CurrentNode(RubyContext context, SourceSection sourceSection) {
@@ -380,7 +381,7 @@ public DynamicObject current() {

}

@CoreMethod(unsafeNeedsAudit = true, names = "allocate", constructor = true)
@CoreMethod(unsafeNeedsAudit = true, names = "allocate", constructor = true, unsafe = UnsafeGroup.THREADS)
public abstract static class AllocateNode extends CoreMethodArrayArgumentsNode {

public AllocateNode(RubyContext context, SourceSection sourceSection) {
Loading