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

Commits on Oct 9, 2015

  1. Copy the full SHA
    f27429b View commit details
  2. Copy the full SHA
    d51f23c View commit details
  3. Copy the full SHA
    95c30c2 View commit details
Showing with 95 additions and 101 deletions.
  1. +0 −17 spec/truffle/tags/core/kernel/exit_tags.txt
  2. +0 −8 spec/truffle/tags/core/process/exit_tags.txt
  3. +1 −1 tool/jruby_eclipse
  4. +1 −1 truffle/src/main/java/org/jruby/truffle/nodes/coerce/NameToJavaStringNode.java
  5. +1 −1 truffle/src/main/java/org/jruby/truffle/nodes/coerce/NameToSymbolOrStringNode.java
  6. +1 −1 truffle/src/main/java/org/jruby/truffle/nodes/coerce/ToAryNode.java
  7. +1 −1 truffle/src/main/java/org/jruby/truffle/nodes/coerce/ToFNode.java
  8. +1 −1 truffle/src/main/java/org/jruby/truffle/nodes/coerce/ToIntNode.java
  9. +1 −1 truffle/src/main/java/org/jruby/truffle/nodes/coerce/ToStrNode.java
  10. +1 −1 truffle/src/main/java/org/jruby/truffle/nodes/constants/ReadConstantWithLexicalScopeNode.java
  11. +3 −3 truffle/src/main/java/org/jruby/truffle/nodes/constants/ReadLiteralConstantNode.java
  12. +1 −1 truffle/src/main/java/org/jruby/truffle/nodes/core/FiberNodes.java
  13. +0 −53 truffle/src/main/java/org/jruby/truffle/nodes/core/KernelNodes.java
  14. +1 −1 truffle/src/main/java/org/jruby/truffle/nodes/core/StringNodes.java
  15. +12 −3 truffle/src/main/java/org/jruby/truffle/nodes/exceptions/TopLevelRaiseHandler.java
  16. +26 −0 truffle/src/main/java/org/jruby/truffle/nodes/rubinius/VMPrimitiveNodes.java
  17. +5 −3 truffle/src/main/java/org/jruby/truffle/runtime/control/RaiseException.java
  18. +6 −1 truffle/src/main/java/org/jruby/truffle/runtime/core/CoreLibrary.java
  19. +3 −3 truffle/src/main/java/org/jruby/truffle/runtime/layouts/ThreadLayout.java
  20. +30 −0 truffle/src/main/ruby/core/rubinius/alpha.rb
17 changes: 0 additions & 17 deletions spec/truffle/tags/core/kernel/exit_tags.txt

This file was deleted.

8 changes: 0 additions & 8 deletions spec/truffle/tags/core/process/exit_tags.txt

This file was deleted.

2 changes: 1 addition & 1 deletion tool/jruby_eclipse
Original file line number Diff line number Diff line change
@@ -34,7 +34,7 @@ if rest.include?('-X+T')
bootclasspath << TRUFFLEJAR
classpath << SNAKEYAMLJAR
classpath << "#{JRUBY}/truffle/build.eclipse"
java_flags << "-Djruby.truffle.core.load_path=truffle/src/main/ruby"
java_flags << "-Djruby.truffle.core.load_path=#{JRUBY}/truffle/src/main/ruby"
end

args = [java]
Original file line number Diff line number Diff line change
@@ -57,7 +57,7 @@ public String coerceObject(VirtualFrame frame, Object object) {
try {
coerced = toStr.call(frame, object, "to_str", null);
} catch (RaiseException e) {
if (Layouts.BASIC_OBJECT.getLogicalClass(((DynamicObject) e.getRubyException())) == getContext().getCoreLibrary().getNoMethodErrorClass()) {
if (Layouts.BASIC_OBJECT.getLogicalClass(e.getRubyException()) == getContext().getCoreLibrary().getNoMethodErrorClass()) {
CompilerDirectives.transferToInterpreter();
throw new RaiseException(getContext().getCoreLibrary().typeErrorNoImplicitConversion(object, "String", this));
} else {
Original file line number Diff line number Diff line change
@@ -57,7 +57,7 @@ public DynamicObject coerceObject(VirtualFrame frame, Object object) {
try {
coerced = toStr.call(frame, object, "to_str", null);
} catch (RaiseException e) {
if (Layouts.BASIC_OBJECT.getLogicalClass(((DynamicObject) e.getRubyException())) == getContext().getCoreLibrary().getNoMethodErrorClass()) {
if (Layouts.BASIC_OBJECT.getLogicalClass(e.getRubyException()) == getContext().getCoreLibrary().getNoMethodErrorClass()) {
CompilerDirectives.transferToInterpreter();
throw new RaiseException(getContext().getCoreLibrary().typeErrorNoImplicitConversion(object, "String", this));
} else {
Original file line number Diff line number Diff line change
@@ -50,7 +50,7 @@ public DynamicObject coerceObject(VirtualFrame frame, Object object) {
try {
coerced = toAryNode.call(frame, object, "to_ary", null);
} catch (RaiseException e) {
if (Layouts.BASIC_OBJECT.getLogicalClass(((DynamicObject) e.getRubyException())) == getContext().getCoreLibrary().getNoMethodErrorClass()) {
if (Layouts.BASIC_OBJECT.getLogicalClass(e.getRubyException()) == getContext().getCoreLibrary().getNoMethodErrorClass()) {
CompilerDirectives.transferToInterpreter();

throw new RaiseException(
Original file line number Diff line number Diff line change
@@ -81,7 +81,7 @@ private double coerceObject(VirtualFrame frame, Object object) {
try {
coerced = toFNode.call(frame, object, "to_f", null);
} catch (RaiseException e) {
if (Layouts.BASIC_OBJECT.getLogicalClass(((DynamicObject) e.getRubyException())) == getContext().getCoreLibrary().getNoMethodErrorClass()) {
if (Layouts.BASIC_OBJECT.getLogicalClass(e.getRubyException()) == getContext().getCoreLibrary().getNoMethodErrorClass()) {
CompilerDirectives.transferToInterpreter();
throw new RaiseException(getContext().getCoreLibrary().typeErrorNoImplicitConversion(object, "Float", this));
} else {
Original file line number Diff line number Diff line change
@@ -101,7 +101,7 @@ private Object coerceObject(VirtualFrame frame, Object object) {
try {
coerced = toIntNode.call(frame, object, "to_int", null);
} catch (RaiseException e) {
if (Layouts.BASIC_OBJECT.getLogicalClass(((DynamicObject) e.getRubyException())) == getContext().getCoreLibrary().getNoMethodErrorClass()) {
if (Layouts.BASIC_OBJECT.getLogicalClass(e.getRubyException()) == getContext().getCoreLibrary().getNoMethodErrorClass()) {
CompilerDirectives.transferToInterpreter();
throw new RaiseException(getContext().getCoreLibrary().typeErrorNoImplicitConversion(object, "Integer", this));
} else {
Original file line number Diff line number Diff line change
@@ -48,7 +48,7 @@ public DynamicObject coerceObject(VirtualFrame frame, Object object) {
try {
coerced = toStrNode.call(frame, object, "to_str", null);
} catch (RaiseException e) {
if (Layouts.BASIC_OBJECT.getLogicalClass(((DynamicObject) e.getRubyException())) == getContext().getCoreLibrary().getNoMethodErrorClass()) {
if (Layouts.BASIC_OBJECT.getLogicalClass(e.getRubyException()) == getContext().getCoreLibrary().getNoMethodErrorClass()) {
CompilerDirectives.transferToInterpreter();
throw new RaiseException(getContext().getCoreLibrary().typeErrorNoImplicitConversion(object, "String", this));
} else {
Original file line number Diff line number Diff line change
@@ -56,7 +56,7 @@ public Object isDefined(VirtualFrame frame) {
try {
constant = lookupConstantNode.executeLookupConstant(frame);
} catch (RaiseException e) {
if (Layouts.BASIC_OBJECT.getLogicalClass(((DynamicObject) e.getRubyException())) == getContext().getCoreLibrary().getNameErrorClass()) {
if (Layouts.BASIC_OBJECT.getLogicalClass(e.getRubyException()) == getContext().getCoreLibrary().getNameErrorClass()) {
// private constant
return nil();
}
Original file line number Diff line number Diff line change
@@ -51,7 +51,7 @@ public Object isDefined(VirtualFrame frame) {
*
* We should maybe try to see if receiver.isDefined() but we also need its value if it is,
* and we do not want to execute receiver twice. */
if (Layouts.BASIC_OBJECT.getLogicalClass(((DynamicObject) e.getRubyException())) == context.getCoreLibrary().getNameErrorClass()) {
if (Layouts.BASIC_OBJECT.getLogicalClass(e.getRubyException()) == context.getCoreLibrary().getNameErrorClass()) {
return nil();
}
throw e;
@@ -61,10 +61,10 @@ public Object isDefined(VirtualFrame frame) {
try {
constant = readConstantNode.lookupConstantNode.executeLookupConstant(frame, module, name);
} catch (RaiseException e) {
if (Layouts.BASIC_OBJECT.getLogicalClass(((DynamicObject) e.getRubyException())) == context.getCoreLibrary().getTypeErrorClass()) {
if (Layouts.BASIC_OBJECT.getLogicalClass(e.getRubyException()) == context.getCoreLibrary().getTypeErrorClass()) {
// module is not a class/module
return nil();
} else if (Layouts.BASIC_OBJECT.getLogicalClass(((DynamicObject) e.getRubyException())) == context.getCoreLibrary().getNameErrorClass()) {
} else if (Layouts.BASIC_OBJECT.getLogicalClass(e.getRubyException()) == context.getCoreLibrary().getNameErrorClass()) {
// private constant
return nil();
}
Original file line number Diff line number Diff line change
@@ -87,7 +87,7 @@ public void run() {
} catch (ReturnException e) {
Layouts.FIBER.getMessageQueue(Layouts.FIBER.getLastResumedByFiber(fiber)).add(new FiberExceptionMessage(context.getCoreLibrary().unexpectedReturn(null)));
} catch (RaiseException e) {
Layouts.FIBER.getMessageQueue(Layouts.FIBER.getLastResumedByFiber(fiber)).add(new FiberExceptionMessage((DynamicObject) e.getRubyException()));
Layouts.FIBER.getMessageQueue(Layouts.FIBER.getLastResumedByFiber(fiber)).add(new FiberExceptionMessage(e.getRubyException()));
}
}
});
Original file line number Diff line number Diff line change
@@ -754,59 +754,6 @@ public Integer block() throws InterruptedException {

}

@CoreMethod(names = "exit", isModuleFunction = true, optional = 1, lowerFixnumParameters = 0)
public abstract static class ExitNode extends CoreMethodArrayArgumentsNode {

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

@Specialization
public Object exit(NotProvided exitCode) {
return exit(0);
}

@Specialization
public Object exit(int exitCode) {
CompilerDirectives.transferToInterpreter();

getContext().shutdown();
System.exit(exitCode);
return null;
}

@Specialization
public Object exit(boolean status) {
CompilerDirectives.transferToInterpreter();

getContext().shutdown();
System.exit(status ? 0 : -1);
return null;
}

}

@CoreMethod(names = "exit!", isModuleFunction = true, optional = 1)
public abstract static class ExitBangNode extends CoreMethodArrayArgumentsNode {

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

@Specialization
public DynamicObject exit(NotProvided exitCode) {
return exit(1);
}

@TruffleBoundary
@Specialization
public DynamicObject exit(int exitCode) {
getContext().innerShutdown(false);
throw new MainExitException(exitCode, true);
}

}

@CoreMethod(names = "fork", isModuleFunction = true, rest = true)
public abstract static class ForkNode extends CoreMethodArrayArgumentsNode {

Original file line number Diff line number Diff line change
@@ -260,7 +260,7 @@ public Object compare(VirtualFrame frame, DynamicObject a, Object b) {

return compare(a, coerced);
} catch (RaiseException e) {
if (Layouts.BASIC_OBJECT.getLogicalClass(((DynamicObject) e.getRubyException())) == getContext().getCoreLibrary().getTypeErrorClass()) {
if (Layouts.BASIC_OBJECT.getLogicalClass(e.getRubyException()) == getContext().getCoreLibrary().getTypeErrorClass()) {
return nil();
} else {
throw e;
Original file line number Diff line number Diff line change
@@ -13,6 +13,7 @@
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.source.SourceSection;

import org.jruby.truffle.nodes.RubyNode;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.backtrace.BacktraceFormatter;
@@ -44,11 +45,19 @@ public Object execute(VirtualFrame frame) {

@TruffleBoundary
private void handleException(RaiseException e) {
final Object rubyException = e.getRubyException();
final DynamicObject rubyException = e.getRubyException();
final int status;

if (Layouts.BASIC_OBJECT.getLogicalClass(rubyException) == getContext().getCoreLibrary().getSystemExitClass()) {
status = (int) rubyException.get("@status", null);
} else {
status = 1;
BacktraceFormatter.createDefaultFormatter(getContext()).printBacktrace((DynamicObject) rubyException, Layouts.EXCEPTION.getBacktrace((DynamicObject) rubyException));
}

BacktraceFormatter.createDefaultFormatter(getContext()).printBacktrace((DynamicObject) rubyException, Layouts.EXCEPTION.getBacktrace((DynamicObject) rubyException));
getContext().shutdown();

System.exit(1);
System.exit(status);
}

}
Original file line number Diff line number Diff line change
@@ -39,13 +39,16 @@

import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.api.dsl.Fallback;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.source.SourceSection;

import jnr.constants.platform.Sysconf;
import jnr.posix.Passwd;
import jnr.posix.Times;

import org.jcodings.specific.UTF8Encoding;
import org.jruby.truffle.nodes.RubyGuards;
import org.jruby.truffle.nodes.RubyNode;
@@ -141,6 +144,29 @@ public DynamicObject vmGCStart() {

}

// The hard #exit!
@RubiniusPrimitive(name = "vm_exit", needsSelf = false)
public static abstract class VMExitPrimitiveNode extends RubiniusPrimitiveNode {

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

@Specialization
public Object vmExit(int status) {
getContext().innerShutdown(false);

System.exit(status);
return nil();
}

@Fallback
public Object vmExit(Object status) {
return null; // Primitive failure
}

}

@RubiniusPrimitive(name = "vm_get_module_name", needsSelf = false)
public static abstract class VMGetModuleNamePrimitiveNode extends RubiniusPrimitiveNode {

Original file line number Diff line number Diff line change
@@ -9,6 +9,8 @@
*/
package org.jruby.truffle.runtime.control;

import com.oracle.truffle.api.object.DynamicObject;

/**
* Ruby exceptions are just Ruby objects, so they cannot also be exceptions unless we made all Ruby
* objects exceptions. A simpler approach is to wrap Ruby exceptions in Java exceptions when we want
@@ -19,9 +21,9 @@ public class RaiseException extends RuntimeException {

// TODO CS 1-Mar-15 shouldn't this be a ControlFlowException?

private final Object rubyException;
private final DynamicObject rubyException;

public RaiseException(Object rubyException) {
public RaiseException(DynamicObject rubyException) {
this.rubyException = rubyException;
}

@@ -35,7 +37,7 @@ public String getMessage() {
return rubyException.toString();
}

public Object getRubyException() {
public DynamicObject getRubyException() {
return rubyException;
}

Original file line number Diff line number Diff line change
@@ -125,6 +125,7 @@ public class CoreLibrary {
private final DynamicObject symbolClass;
private final DynamicObject syntaxErrorClass;
private final DynamicObject systemCallErrorClass;
private final DynamicObject systemExitClass;
private final DynamicObject threadClass;
private final DynamicObject threadBacktraceClass;
private final DynamicObject threadBacktraceLocationClass;
@@ -327,7 +328,7 @@ public CoreLibrary(RubyContext context) {
defineClass(signalExceptionClass, "Interrupt");

// SystemExit
defineClass(exceptionClass, "SystemExit");
systemExitClass = defineClass(exceptionClass, "SystemExit");

// SystemStackError
defineClass(exceptionClass, "SystemStackError");
@@ -1574,4 +1575,8 @@ public DynamicObjectFactory getTimeFactory() {
return timeFactory;
}

public DynamicObject getSystemExitClass() {
return systemExitClass;
}

}
Original file line number Diff line number Diff line change
@@ -39,7 +39,7 @@ DynamicObject createThread(DynamicObjectFactory factory,
InterruptMode interruptMode,
@Nullable @Volatile Thread thread,
@Volatile RubyThread.Status status,
@Nullable @Volatile Object exception,
@Nullable @Volatile DynamicObject exception,
@Nullable @Volatile Object value,
AtomicBoolean wakeUp,
@Volatile int priority);
@@ -70,8 +70,8 @@ DynamicObject createThread(DynamicObjectFactory factory,
RubyThread.Status getStatus(DynamicObject object);
void setStatus(DynamicObject object, RubyThread.Status status);

Object getException(DynamicObject object);
void setException(DynamicObject object, Object exception);
DynamicObject getException(DynamicObject object);
void setException(DynamicObject object, DynamicObject exception);

Object getValue(DynamicObject object);
void setValue(DynamicObject object, Object value);
30 changes: 30 additions & 0 deletions truffle/src/main/ruby/core/rubinius/alpha.rb
Original file line number Diff line number Diff line change
@@ -26,6 +26,36 @@

# Only part of Rubinius' alpha.rb

module Process
# Terminate with given status code.
#
def self.exit(code=0)
case code
when true
code = 0
when false
code = 1
else
code = Rubinius::Type.coerce_to code, Integer, :to_int
end

raise SystemExit.new(code)
end

def self.exit!(code=1)
Rubinius.primitive :vm_exit

case code
when true
exit! 0
when false
exit! 1
else
exit! Rubinius::Type.coerce_to(code, Integer, :to_int)
end
end
end

class Module

# :internal: