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: 82b27f2f8ca7
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 1359326e7eae
Choose a head ref
  • 2 commits
  • 7 files changed
  • 1 contributor

Commits on Nov 14, 2016

  1. [Truffle] Favor flattenBytes over extractRange.

    While generally extractRange should be fine and eliminates one extra level of rope unpeeling, since it currently force flattens the rope being extracted from, it's considerably more expensive that a flattenBytes operation that takes the bounds of the substring into account.
    nirvdrum committed Nov 14, 2016
    Copy the full SHA
    1c435d1 View commit details
  2. [Truffle] Added AOT-specific error-handling or workarounds for calls …

    …not available at runtime.
    nirvdrum committed Nov 14, 2016
    Copy the full SHA
    1359326 View commit details
3 changes: 2 additions & 1 deletion truffle/src/main/java/org/jruby/truffle/RubyContext.java
Original file line number Diff line number Diff line change
@@ -190,7 +190,8 @@ public RubyContext(RubyInstanceConfig instanceConfig, TruffleLanguage.Env env) {
final PrintStream configStandardOut = instanceConfig.getOutput();
debugStandardOut = (configStandardOut == System.out) ? null : configStandardOut;

if (options.INSTRUMENTATION_SERVER_PORT != 0) {
// The instrumentation server can't be run with AOT because com.sun.net.httpserver.spi.HttpServerProvider uses runtime class loading.
if (!TruffleOptions.AOT && options.INSTRUMENTATION_SERVER_PORT != 0) {
instrumentationServerManager = new InstrumentationServerManager(this, options.INSTRUMENTATION_SERVER_PORT);
instrumentationServerManager.start();
} else {
Original file line number Diff line number Diff line change
@@ -10,6 +10,7 @@
package org.jruby.truffle.core;

import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.api.TruffleOptions;
import com.oracle.truffle.api.dsl.Specialization;
import org.jruby.RubyGC;
import org.jruby.truffle.builtins.CoreClass;
@@ -25,6 +26,10 @@ public abstract static class CountNode extends CoreMethodArrayArgumentsNode {
@TruffleBoundary
@Specialization
public int count() {
if (TruffleOptions.AOT) {
throw new UnsupportedOperationException("Memory manager is not available with AOT.");
}

return RubyGC.getCollectionCount();
}

@@ -36,6 +41,10 @@ public abstract static class TimeNode extends CoreMethodArrayArgumentsNode {
@TruffleBoundary
@Specialization
public long time() {
if (TruffleOptions.AOT) {
throw new UnsupportedOperationException("Memory manager is not available with AOT.");
}

return RubyGC.getCollectionTime();
}

11 changes: 11 additions & 0 deletions truffle/src/main/java/org/jruby/truffle/core/VMPrimitiveNodes.java
Original file line number Diff line number Diff line change
@@ -38,6 +38,7 @@
package org.jruby.truffle.core;

import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.api.TruffleOptions;
import com.oracle.truffle.api.dsl.Cached;
import com.oracle.truffle.api.dsl.Fallback;
import com.oracle.truffle.api.dsl.Specialization;
@@ -449,6 +450,11 @@ public boolean watchSignalProc(DynamicObject signalName, DynamicObject proc) {

@TruffleBoundary
private boolean handleDefault(DynamicObject signalName) {
// We can't work with signals with AOT.
if (TruffleOptions.AOT) {
return true;
}

Signal signal = getContext().getNativePlatform().getSignalManager().createSignal(signalName.toString());
try {
getContext().getNativePlatform().getSignalManager().watchDefaultForSignal(signal);
@@ -460,6 +466,11 @@ private boolean handleDefault(DynamicObject signalName) {

@TruffleBoundary
private boolean handle(DynamicObject signalName, SignalHandler newHandler) {
// We can't work with signals with AOT.
if (TruffleOptions.AOT) {
return true;
}

Signal signal = getContext().getNativePlatform().getSignalManager().createSignal(signalName.toString());
try {
getContext().getNativePlatform().getSignalManager().watchSignal(signal, newHandler);
Original file line number Diff line number Diff line change
@@ -13,6 +13,7 @@
import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.api.Truffle;
import com.oracle.truffle.api.TruffleOptions;
import com.oracle.truffle.api.dsl.Cached;
import com.oracle.truffle.api.dsl.CreateCast;
import com.oracle.truffle.api.dsl.ImportStatic;
@@ -228,6 +229,10 @@ public DynamicObject backtick(VirtualFrame frame, DynamicObject command) {

@TruffleBoundary
private ExecuteResult spawnAndCaptureOutput(DynamicObject command, final DynamicObject envAsHash) {
if (TruffleOptions.AOT) {
throw new UnsupportedOperationException("ProcessEnvironment.environment not supported with AOT");
}

// We need to run via bash to get the variable and other expansion we expect
String[] cmdArray = new String[] { "bash", "-c", command.toString() };

@@ -741,6 +746,10 @@ public abstract static class ExecNode extends CoreMethodArrayArgumentsNode {

@Specialization
public Object exec(VirtualFrame frame, Object command, Object[] args) {
if (TruffleOptions.AOT) {
throw new UnsupportedOperationException("ProcessEnvironment.environment not supported with AOT.");
}

if (toHashNode == null) {
CompilerDirectives.transferToInterpreterAndInvalidate();
toHashNode = insert(DispatchHeadNodeFactory.createMethodCall(getContext()));
Original file line number Diff line number Diff line change
@@ -11,6 +11,7 @@

import com.oracle.truffle.api.Assumption;
import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.TruffleOptions;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.utilities.CyclicAssumption;
import org.jruby.RubyGC;
@@ -108,6 +109,11 @@ public synchronized void undefineFinalizer(DynamicObject object) {
private void runFinalizers() {
// Run in a loop

if (TruffleOptions.AOT) {
// ReferenceQueue#remove is not available with AOT.
return;
}

while (true) {
// Wait on the finalizer queue
FinalizerReference finalizerReference = (FinalizerReference) context.getThreadManager().runUntilResult(null, () -> finalizerQueue.remove());
@@ -159,6 +165,10 @@ public void traceAllocationsStop() {
}

public void traceAllocation(DynamicObject object, DynamicObject classPath, DynamicObject methodId, DynamicObject sourcefile, int sourceline) {
if (TruffleOptions.AOT) {
throw new UnsupportedOperationException("Memory manager is not available with AOT.");
}

if (tracingPaused) {
return;
}
Original file line number Diff line number Diff line change
@@ -57,7 +57,7 @@ protected byte[] getBytesSlow() {
return ret;
}

return RopeOperations.extractRange(child, offset, byteLength());
return RopeOperations.flattenBytes(this);
}

@Override
Original file line number Diff line number Diff line change
@@ -12,6 +12,7 @@
import com.kenai.jffi.MemoryIO;
import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.api.TruffleOptions;
import com.oracle.truffle.api.dsl.ImportStatic;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.object.DynamicObject;
@@ -321,6 +322,16 @@ public DynamicObject readNullPointer(DynamicObject pointer) {
@TruffleBoundary
@Specialization(guards = "!isNullPointer(pointer)")
public DynamicObject readStringToNull(DynamicObject pointer) {
if (TruffleOptions.AOT) {
final jnr.ffi.Pointer ptr = Layouts.POINTER.getPointer(pointer);
final int nullOffset = ptr.indexOf(0, (byte) 0);
final byte[] bytes = new byte[nullOffset];

ptr.get(0, bytes, 0, bytes.length);

return StringOperations.createString(getContext(), new ByteList(bytes));
}

return createString(MemoryIO.getInstance().getZeroTerminatedByteArray(Layouts.POINTER.getPointer(pointer).address()), ASCIIEncoding.INSTANCE);
}