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: cb73db6432a7
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 22d6044b33b6
Choose a head ref
  • 7 commits
  • 1 file changed
  • 1 contributor

Commits on Jan 2, 2016

  1. Copy the full SHA
    87ab220 View commit details
  2. Copy the full SHA
    08c6d3a View commit details
  3. Copy the full SHA
    c01ddc7 View commit details
  4. Copy the full SHA
    2f8aa8d View commit details
  5. Copy the full SHA
    8bd0523 View commit details
  6. Copy the full SHA
    7b515db View commit details
  7. Copy the full SHA
    22d6044 View commit details
Showing with 7 additions and 60 deletions.
  1. +7 −60 truffle/src/main/java/org/jruby/truffle/runtime/RubyContext.java
67 changes: 7 additions & 60 deletions truffle/src/main/java/org/jruby/truffle/runtime/RubyContext.java
Original file line number Diff line number Diff line change
@@ -20,14 +20,11 @@
import com.oracle.truffle.api.source.SourceSection;
import com.oracle.truffle.tools.CoverageTracker;
import jnr.ffi.LibraryLoader;
import jnr.ffi.Runtime;
import jnr.ffi.provider.MemoryManager;
import jnr.posix.POSIX;
import jnr.posix.POSIXFactory;
import org.jcodings.Encoding;
import org.jcodings.specific.UTF8Encoding;
import org.jruby.Ruby;
import org.jruby.RubyNil;
import org.jruby.ext.ffi.Platform;
import org.jruby.ext.ffi.Platform.OS_TYPE;
import org.jruby.runtime.Visibility;
@@ -88,7 +85,6 @@ public class RubyContext extends ExecutionContext {
private final POSIX posix;
private final NativeSockets nativeSockets;
private final LibCClockGetTime libCClockGetTime;
private final MemoryManager memoryManager = Runtime.getSystemRuntime().getMemoryManager();

private final CoreLibrary coreLibrary;
private final FeatureLoader featureLoader;
@@ -451,79 +447,36 @@ public IRubyObject toJRuby(Object object) {
} else if (RubyGuards.isRubyString(object)) {
return toJRubyString((DynamicObject) object);
} else if (RubyGuards.isRubyEncoding(object)) {
return toJRubyEncoding((DynamicObject) object);
return runtime.getEncodingService().rubyEncodingFromObject(runtime.newString(Layouts.ENCODING.getName((DynamicObject) object)));
} else {
throw getRuntime().newRuntimeError("cannot pass " + object + " (" + object.getClass().getName() + ") to JRuby");
throw new UnsupportedOperationException();
}
}

@TruffleBoundary
public IRubyObject toJRubyEncoding(DynamicObject encoding) {
assert RubyGuards.isRubyEncoding(encoding);
return runtime.getEncodingService().rubyEncodingFromObject(runtime.newString(Layouts.ENCODING.getName(encoding)));
}

@TruffleBoundary
public org.jruby.RubyString toJRubyString(DynamicObject string) {
assert RubyGuards.isRubyString(string);

final org.jruby.RubyString jrubyString = runtime.newString(StringOperations.getByteList(string).dup());

final Object tainted = string.get(Layouts.TAINTED_IDENTIFIER, coreLibrary.getNilObject());

if (tainted instanceof Boolean && (boolean) tainted) {
jrubyString.setTaint(true);
}

return jrubyString;
return runtime.newString(StringOperations.getByteList(string).dup());
}

@TruffleBoundary
public Object toTruffle(IRubyObject object) {
if (object instanceof RubyNil) {
return getCoreLibrary().getNilObject();
} else if (object instanceof org.jruby.RubyFixnum) {
if (object instanceof org.jruby.RubyFixnum) {
final long value = ((org.jruby.RubyFixnum) object).getLongValue();

if (value < Integer.MIN_VALUE || value > Integer.MAX_VALUE) {
return value;
}

return (int) value;
} else if (object instanceof org.jruby.RubyFloat) {
return ((org.jruby.RubyFloat) object).getDoubleValue();
} else if (object instanceof org.jruby.RubyBignum) {
final BigInteger value = ((org.jruby.RubyBignum) object).getBigIntegerValue();
return Layouts.BIGNUM.createBignum(coreLibrary.getBignumFactory(), value);
} else if (object instanceof org.jruby.RubyString) {
return toTruffle((org.jruby.RubyString) object);
} else if (object instanceof org.jruby.RubyException) {
return toTruffle((org.jruby.RubyException) object, null);
return StringOperations.createString(this, ((org.jruby.RubyString) object).getByteList().dup());
} else {
throw object.getRuntime().newRuntimeError("cannot pass " + object.inspect() + " (" + object.getClass().getName() + ") to Truffle");
}
}

@TruffleBoundary
public DynamicObject toTruffle(org.jruby.RubyArray array) {
final Object[] store = new Object[array.size()];

for (int n = 0; n < store.length; n++) {
store[n] = toTruffle(array.entry(n));
throw new UnsupportedOperationException();
}

return Layouts.ARRAY.createArray(coreLibrary.getArrayFactory(), store, store.length);
}

@TruffleBoundary
public DynamicObject toTruffle(org.jruby.RubyString jrubyString) {
final DynamicObject truffleString = StringOperations.createString(this, jrubyString.getByteList().dup());

if (jrubyString.isTaint()) {
truffleString.define(Layouts.TAINTED_IDENTIFIER, true, 0);
}

return truffleString;
}

@TruffleBoundary
@@ -533,13 +486,11 @@ public DynamicObject toTruffle(org.jruby.RubyException jrubyException, RubyNode
return getCoreLibrary().argumentError(jrubyException.getMessage().toString(), currentNode);
case "Encoding::CompatibilityError":
return getCoreLibrary().encodingCompatibilityError(jrubyException.getMessage().toString(), currentNode);
case "TypeError":
return getCoreLibrary().typeError(jrubyException.getMessage().toString(), currentNode);
case "RegexpError":
return getCoreLibrary().regexpError(jrubyException.getMessage().toString(), currentNode);
}

throw new UnsupportedOperationException("Don't know how to translate " + jrubyException.getMetaClass().getName());
throw new UnsupportedOperationException();
}

public Ruby getRuntime() {
@@ -697,10 +648,6 @@ public Options getOptions() {
return options;
}

public MemoryManager getMemoryManager() {
return memoryManager;
}

public TruffleLanguage.Env getEnv() {
return env;
}