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: 75c651fceb6f
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: a17b22c0d7a2
Choose a head ref
  • 8 commits
  • 13 files changed
  • 1 contributor

Commits on Apr 6, 2016

  1. Copy the full SHA
    d50a06e View commit details
  2. Copy the full SHA
    a1a3049 View commit details
  3. Copy the full SHA
    406c12b View commit details
  4. Copy the full SHA
    d6d8205 View commit details
  5. Copy the full SHA
    7053114 View commit details
  6. Copy the full SHA
    547844d View commit details
  7. Copy the full SHA
    9632ab4 View commit details
  8. Copy the full SHA
    a17b22c View commit details
2 changes: 2 additions & 0 deletions core/src/main/java/org/jruby/util/cli/Options.java
Original file line number Diff line number Diff line change
@@ -223,10 +223,12 @@ public class Options {
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", 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_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_AT_EXIT = bool(TRUFFLE, "truffle.platform.safe.at_exit", TRUFFLE_PLATFORM_SAFE.load(), "Treat #at_exit 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.");

Original file line number Diff line number Diff line change
@@ -265,6 +265,9 @@ public static boolean isSafe(RubyContext context, UnsafeGroup[] groups) {
final boolean option;

switch (group) {
case LOAD:
option = options.PLATFORM_SAFE_LOAD;
break;
case IO:
option = options.PLATFORM_SAFE_IO;
break;
@@ -277,6 +280,9 @@ public static boolean isSafe(RubyContext context, UnsafeGroup[] groups) {
case EXIT:
option = options.PLATFORM_SAFE_EXIT;
break;
case AT_EXIT:
option = options.PLATFORM_SAFE_AT_EXIT;
break;
case SAFE_PUTS:
option = options.PLATFORM_SAFE_PUTS;
break;
Original file line number Diff line number Diff line change
@@ -22,6 +22,7 @@
import org.jruby.truffle.language.RubyGuards;
import org.jruby.truffle.language.RubyNode;
import org.jruby.truffle.language.control.RaiseException;
import org.jruby.truffle.platform.UnsafeGroup;
import org.jruby.truffle.platform.posix.ClockGetTime;
import org.jruby.truffle.platform.posix.TimeSpec;
import org.jruby.truffle.platform.signal.Signal;
@@ -121,7 +122,7 @@ protected static boolean isMonotonicRaw(int clock_id) {

}

@CoreMethod(unsafeNeedsAudit = true, names = "kill", onSingleton = true, required = 2)
@CoreMethod(names = "kill", onSingleton = true, required = 2, unsafe = UnsafeGroup.PROCESSES)
public abstract static class KillNode extends CoreMethodArrayArgumentsNode {

public KillNode(RubyContext context, SourceSection sourceSection) {
@@ -153,7 +154,7 @@ private int raise(String signalName) {

}

@CoreMethod(unsafeNeedsAudit = true, names = "pid", onSingleton = true)
@CoreMethod(names = "pid", onSingleton = true)
public abstract static class PidNode extends CoreMethodArrayArgumentsNode {

public PidNode(RubyContext context, SourceSection sourceSection) {
Original file line number Diff line number Diff line change
@@ -46,7 +46,7 @@ public static DynamicObject createEncodingConverter(DynamicObject rubyClass, ECo
}

@RubiniusOnly
@CoreMethod(unsafeNeedsAudit = true, names = "initialize_jruby", required = 2, optional = 1, visibility = Visibility.PRIVATE)
@CoreMethod(names = "initialize_jruby", required = 2, optional = 1, visibility = Visibility.PRIVATE)
public abstract static class InitializeNode extends CoreMethodArrayArgumentsNode {

public InitializeNode(RubyContext context, SourceSection sourceSection) {
@@ -128,7 +128,7 @@ private IRubyObject toJRuby(Object object) {
}

@RubiniusOnly
@CoreMethod(unsafeNeedsAudit = true, names = "transcoding_map", onSingleton = true)
@CoreMethod(names = "transcoding_map", onSingleton = true)
public abstract static class TranscodingMapNode extends CoreMethodArrayArgumentsNode {

@Child private CallDispatchHeadNode upcaseNode;
@@ -175,7 +175,7 @@ public Object transcodingMap(VirtualFrame frame) {
}
}

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

public AllocateNode(RubyContext context, SourceSection sourceSection) {
Original file line number Diff line number Diff line change
@@ -362,7 +362,7 @@ public DynamicObject calleeName() {
}
}

@CoreMethod(unsafeNeedsAudit = true, names = "caller_locations", isModuleFunction = true, optional = 2, lowerFixnumParameters = { 0, 1 })
@CoreMethod(names = "caller_locations", isModuleFunction = true, optional = 2, lowerFixnumParameters = { 0, 1 })
public abstract static class CallerLocationsNode extends CoreMethodArrayArgumentsNode {

public CallerLocationsNode(RubyContext context, SourceSection sourceSection) {
@@ -847,7 +847,7 @@ public boolean isFrozen(Object self) {

}

@CoreMethod(unsafeNeedsAudit = true, names = "gets", isModuleFunction = true)
@CoreMethod(names = "gets", isModuleFunction = true, unsafe = UnsafeGroup.IO)
public abstract static class GetsNode extends CoreMethodArrayArgumentsNode {

public GetsNode(RubyContext context, SourceSection sourceSection) {
@@ -1567,7 +1567,7 @@ public long randNonZero(long max) {

}

@CoreMethod(unsafeNeedsAudit = true, names = "require", isModuleFunction = true, required = 1)
@CoreMethod(names = "require", isModuleFunction = true, required = 1, unsafe = UnsafeGroup.LOAD)
@NodeChildren({
@NodeChild(type = RubyNode.class, value = "feature")
})
@@ -1616,7 +1616,7 @@ private boolean callerIs(String caller) {
}
}

@CoreMethod(unsafeNeedsAudit = true, names = "require_relative", isModuleFunction = true, required = 1)
@CoreMethod(names = "require_relative", isModuleFunction = true, required = 1, unsafe = UnsafeGroup.LOAD)
public abstract static class RequireRelativeNode extends CoreMethodArrayArgumentsNode {

public RequireRelativeNode(RubyContext context, SourceSection sourceSection) {
@@ -1760,7 +1760,7 @@ public boolean doesRespondToMissingSymbol(Object object, DynamicObject name, Obj

}

@CoreMethod(unsafeNeedsAudit = true, names = "set_trace_func", isModuleFunction = true, required = 1)
@CoreMethod(names = "set_trace_func", isModuleFunction = true, required = 1)
public abstract static class SetTraceFuncNode extends CoreMethodArrayArgumentsNode {

public SetTraceFuncNode(RubyContext context, SourceSection sourceSection) {
@@ -1855,7 +1855,7 @@ public Object string(VirtualFrame frame, Object value) {

}

@CoreMethod(unsafeNeedsAudit = true, names = "sleep", isModuleFunction = true, optional = 1)
@CoreMethod(names = "sleep", isModuleFunction = true, optional = 1)
public abstract static class SleepNode extends CoreMethodArrayArgumentsNode {

@Child NumericToFloatNode floatCastNode;
Original file line number Diff line number Diff line change
@@ -93,6 +93,7 @@
import org.jruby.truffle.language.parser.ParserContext;
import org.jruby.truffle.language.parser.jruby.Translator;
import org.jruby.truffle.language.yield.YieldNode;
import org.jruby.truffle.platform.UnsafeGroup;
import org.jruby.util.ByteList;
import org.jruby.util.IdUtil;

@@ -540,7 +541,7 @@ public DynamicObject attrWriter(VirtualFrame frame, DynamicObject module, Object

}

@CoreMethod(unsafeNeedsAudit = true, names = "autoload", required = 2)
@CoreMethod(names = "autoload", required = 2, unsafe = UnsafeGroup.LOAD)
@NodeChildren({
@NodeChild(type = RubyNode.class, value = "module"),
@NodeChild(type = RubyNode.class, value = "name"),
@@ -588,7 +589,7 @@ public DynamicObject autoload(DynamicObject module, String name, DynamicObject f
}
}

@CoreMethod(unsafeNeedsAudit = true, names = "autoload?", required = 1)
@CoreMethod(names = "autoload?", required = 1)
public abstract static class AutoloadQueryNode extends CoreMethodArrayArgumentsNode {

public AutoloadQueryNode(RubyContext context, SourceSection sourceSection) {
Original file line number Diff line number Diff line change
@@ -34,7 +34,7 @@
@CoreClass(name = "Mutex")
public abstract class MutexNodes {

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

@Child private AllocateObjectNode allocateNode;
@@ -51,7 +51,7 @@ public DynamicObject allocate(DynamicObject rubyClass) {

}

@CoreMethod(unsafeNeedsAudit = true, names = "lock")
@CoreMethod(names = "lock")
public abstract static class LockNode extends UnaryCoreMethodNode {

public LockNode(RubyContext context, SourceSection sourceSection) {
@@ -91,7 +91,7 @@ public Boolean block() throws InterruptedException {

}

@CoreMethod(unsafeNeedsAudit = true, names = "locked?")
@CoreMethod(names = "locked?")
public abstract static class IsLockedNode extends UnaryCoreMethodNode {

public IsLockedNode(RubyContext context, SourceSection sourceSection) {
@@ -105,7 +105,7 @@ public boolean isLocked(DynamicObject mutex) {

}

@CoreMethod(unsafeNeedsAudit = true, names = "owned?")
@CoreMethod(names = "owned?")
public abstract static class IsOwnedNode extends UnaryCoreMethodNode {

public IsOwnedNode(RubyContext context, SourceSection sourceSection) {
@@ -119,7 +119,7 @@ public boolean isOwned(DynamicObject mutex) {

}

@CoreMethod(unsafeNeedsAudit = true, names = "try_lock")
@CoreMethod(names = "try_lock")
public abstract static class TryLockNode extends UnaryCoreMethodNode {

public TryLockNode(RubyContext context, SourceSection sourceSection) {
@@ -150,7 +150,7 @@ private boolean doTryLock(final ReentrantLock lock) {

}

@CoreMethod(unsafeNeedsAudit = true, names = "unlock")
@CoreMethod(names = "unlock")
public abstract static class UnlockNode extends UnaryCoreMethodNode {

public UnlockNode(RubyContext context, SourceSection sourceSection) {
@@ -188,7 +188,7 @@ protected static void unlock(ReentrantLock lock, DynamicObject thread, RubyNode

}

@CoreMethod(unsafeNeedsAudit = true, names = "sleep", optional = 1)
@CoreMethod(names = "sleep", optional = 1)
public abstract static class SleepNode extends CoreMethodArrayArgumentsNode {

public SleepNode(RubyContext context, SourceSection sourceSection) {
Original file line number Diff line number Diff line change
@@ -25,7 +25,7 @@
@CoreClass(name = "Thread::Backtrace::Location")
public class ThreadBacktraceLocationNodes {

@CoreMethod(unsafeNeedsAudit = true, names = { "absolute_path", "path" })
@CoreMethod(names = { "absolute_path", "path" })
// TODO (eregon, 8 July 2015): these two methods are slightly different (path can be relative if it is the main script)
public abstract static class AbsolutePathNode extends UnaryCoreMethodNode {

@@ -61,7 +61,7 @@ public DynamicObject absolutePath(DynamicObject threadBacktraceLocation) {

}

@CoreMethod(unsafeNeedsAudit = true, names = "lineno")
@CoreMethod(names = "lineno")
public abstract static class LinenoNode extends UnaryCoreMethodNode {

public LinenoNode(RubyContext context, SourceSection sourceSection) {
@@ -80,7 +80,7 @@ public int lineno(DynamicObject threadBacktraceLocation) {

}

@CoreMethod(unsafeNeedsAudit = true, names = {"to_s", "inspect"})
@CoreMethod(names = {"to_s", "inspect"})
public abstract static class ToSNode extends UnaryCoreMethodNode {

public ToSNode(RubyContext context, SourceSection sourceSection) {
Original file line number Diff line number Diff line change
@@ -221,7 +221,7 @@ public void run(DynamicObject thread, Node currentNode) {

}

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

public CurrentNode(RubyContext context, SourceSection sourceSection) {
@@ -551,7 +551,7 @@ public DynamicObject allocate(DynamicObject rubyClass) {

}

@CoreMethod(unsafeNeedsAudit = true, names = "list", onSingleton = true)
@CoreMethod(names = "list", onSingleton = true)
public abstract static class ListNode extends CoreMethodArrayArgumentsNode {

public ListNode(RubyContext context, SourceSection sourceSection) {
Original file line number Diff line number Diff line change
@@ -464,7 +464,7 @@ public DynamicObject convertToMutableRope(DynamicObject string) {
}
}

@CoreMethod(unsafeNeedsAudit = true, names = "debug_print_rope", onSingleton = true, required = 1, optional = 1, unsafe = UnsafeGroup.IO)
@CoreMethod(names = "debug_print_rope", onSingleton = true, required = 1, optional = 1, unsafe = UnsafeGroup.IO)
public abstract static class DebugPrintRopeNode extends CoreMethodArrayArgumentsNode {

@Child private RopeNodes.DebugPrintRopeNode debugPrintRopeNode;
@@ -571,7 +571,7 @@ public DynamicObject hostOS() {

}

@CoreMethod(unsafeNeedsAudit = true, names = "at_exit", isModuleFunction = true, needsBlock = true, required = 1)
@CoreMethod(names = "at_exit", isModuleFunction = true, needsBlock = true, required = 1, unsafe = UnsafeGroup.AT_EXIT)
public abstract static class AtExitSystemNode extends CoreMethodArrayArgumentsNode {

public AtExitSystemNode(RubyContext context, SourceSection sourceSection) {
@@ -816,7 +816,7 @@ public RubyContext context() {
}
}

@CoreMethod(unsafeNeedsAudit = true, names = "load", isModuleFunction = true, required = 1, optional = 1)
@CoreMethod(names = "load", isModuleFunction = true, required = 1, optional = 1, unsafe = UnsafeGroup.LOAD)
public abstract static class LoadNode extends CoreMethodArrayArgumentsNode {

public LoadNode(RubyContext context, SourceSection sourceSection) {
@@ -948,7 +948,7 @@ public DynamicObject originalArgv() {

}

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

public OriginalLoadPathNode(RubyContext context, SourceSection sourceSection) {
@@ -984,4 +984,29 @@ public boolean ioSafe() {

}

@CoreMethod(names = "require_core", isModuleFunction = true, required = 1)
public abstract static class RequireCoreNode extends CoreMethodArrayArgumentsNode {

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

@Specialization(guards = "isRubyString(feature)")
public boolean requireRelative(VirtualFrame frame, DynamicObject feature, @Cached("create()") IndirectCallNode callNode) {
if (!(getContext().getCoreLibrary().isLoadingRubyCore() || getContext().getOptions().PLATFORM_SAFE_LOAD)) {
throw new RaiseException(getContext().getCoreLibrary().internalErrorUnsafe(this));
}

try {
final RubyRootNode rootNode = getContext().getCodeLoader().parse(getContext().getSourceCache().getSource(getContext().getCoreLibrary().getCoreLoadPath() + "/" + feature.toString() + ".rb"), UTF8Encoding.INSTANCE, ParserContext.TOP_LEVEL, null, true, this);
final CodeLoader.DeferredCall deferredCall = getContext().getCodeLoader().prepareExecute(ParserContext.TOP_LEVEL, DeclarationContext.TOP_LEVEL, rootNode, null, getContext().getCoreLibrary().getMainObject());
deferredCall.getCallTarget().call(deferredCall.getArguments());
} catch (IOException e) {
throw new RuntimeException(e);
}

return true;
}
}

}
4 changes: 4 additions & 0 deletions truffle/src/main/java/org/jruby/truffle/language/Options.java
Original file line number Diff line number Diff line change
@@ -51,8 +51,10 @@
import static org.jruby.util.cli.Options.TRUFFLE_PACK_RECOVER_LOOP_MIN;
import static org.jruby.util.cli.Options.TRUFFLE_PACK_UNROLL_LIMIT;
import static org.jruby.util.cli.Options.TRUFFLE_PLATFORM_SAFE;
import static org.jruby.util.cli.Options.TRUFFLE_PLATFORM_SAFE_AT_EXIT;
import static org.jruby.util.cli.Options.TRUFFLE_PLATFORM_SAFE_EXIT;
import static org.jruby.util.cli.Options.TRUFFLE_PLATFORM_SAFE_IO;
import static org.jruby.util.cli.Options.TRUFFLE_PLATFORM_SAFE_LOAD;
import static org.jruby.util.cli.Options.TRUFFLE_PLATFORM_SAFE_PROCESSES;
import static org.jruby.util.cli.Options.TRUFFLE_PLATFORM_SAFE_PUTS;
import static org.jruby.util.cli.Options.TRUFFLE_PLATFORM_SAFE_THREADS;
@@ -72,10 +74,12 @@ public class Options {
// Platform

public final boolean PLATFORM_SAFE = TRUFFLE_PLATFORM_SAFE.load();
public final boolean PLATFORM_SAFE_LOAD = TRUFFLE_PLATFORM_SAFE_LOAD.load();
public final boolean PLATFORM_SAFE_IO = TRUFFLE_PLATFORM_SAFE_IO.load();
public final boolean PLATFORM_SAFE_THREADS = TRUFFLE_PLATFORM_SAFE_THREADS.load();
public final boolean PLATFORM_SAFE_PROCESSES = TRUFFLE_PLATFORM_SAFE_PROCESSES.load();
public final boolean PLATFORM_SAFE_EXIT = TRUFFLE_PLATFORM_SAFE_EXIT.load();
public final boolean PLATFORM_SAFE_AT_EXIT = TRUFFLE_PLATFORM_SAFE_AT_EXIT.load();
public final boolean PLATFORM_SAFE_PUTS = TRUFFLE_PLATFORM_SAFE_PUTS.load();
public final boolean PLATFORM_USE_JAVA = TRUFFLE_PLATFORM_USE_JAVA.load();

Original file line number Diff line number Diff line change
@@ -10,9 +10,11 @@
package org.jruby.truffle.platform;

public enum UnsafeGroup {
LOAD,
IO,
THREADS,
PROCESSES,
EXIT,
AT_EXIT,
SAFE_PUTS
}
Loading