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: 963d34365e0e
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 746f24f9858f
Choose a head ref
  • 3 commits
  • 28 files changed
  • 2 contributors

Commits on Aug 5, 2015

  1. [Truffle] Do not print stack trace in appendValue

    Removing this keeps printStackTrace from being inlined during
    compilation. An ArrayIndexOutOfBoundsException will still be thrown in
    the case of an invalid index.
    bbelleville committed Aug 5, 2015
    Copy the full SHA
    93f9614 View commit details
  2. [Truffle] Add TruffleBoundary to limit compilation

    This change lowers the number of methods available for runtime
    compilation from over 33,000 to less than 15,000. Some methods that
    could not be annotated with TruffleBoundary were split in order to
    introduce a boundary.
    bbelleville committed Aug 5, 2015
    Copy the full SHA
    a1ccef9 View commit details
  3. Merge pull request #3226 from bbelleville/boundaries

    [Truffle] Limit the number of methods available for runtime compilation
    chrisseaton committed Aug 5, 2015
    Copy the full SHA
    746f24f View commit details
Showing with 141 additions and 37 deletions.
  1. +2 −0 truffle/src/main/java/org/jruby/truffle/nodes/cast/CmpIntNode.java
  2. +7 −2 truffle/src/main/java/org/jruby/truffle/nodes/core/EncodingNodes.java
  3. +2 −0 truffle/src/main/java/org/jruby/truffle/nodes/core/ExceptionNodes.java
  4. +2 −0 truffle/src/main/java/org/jruby/truffle/nodes/core/KernelNodes.java
  5. +1 −0 truffle/src/main/java/org/jruby/truffle/nodes/core/MethodNodes.java
  6. +1 −0 truffle/src/main/java/org/jruby/truffle/nodes/core/ProcessNodes.java
  7. +6 −0 truffle/src/main/java/org/jruby/truffle/nodes/core/QueueNodes.java
  8. +1 −0 truffle/src/main/java/org/jruby/truffle/nodes/core/RegexpNodes.java
  9. +7 −0 truffle/src/main/java/org/jruby/truffle/nodes/core/SizedQueueNodes.java
  10. +11 −0 truffle/src/main/java/org/jruby/truffle/nodes/core/StringNodes.java
  11. +2 −0 truffle/src/main/java/org/jruby/truffle/nodes/core/ThreadNodes.java
  12. +2 −0 truffle/src/main/java/org/jruby/truffle/nodes/core/TimeNodes.java
  13. +0 −4 truffle/src/main/java/org/jruby/truffle/nodes/core/array/ArrayBuilderNode.java
  14. +2 −0 truffle/src/main/java/org/jruby/truffle/nodes/core/array/ArrayNodes.java
  15. +13 −7 truffle/src/main/java/org/jruby/truffle/nodes/exceptions/TopLevelRaiseHandler.java
  16. +2 −0 truffle/src/main/java/org/jruby/truffle/nodes/globals/GetFromThreadLocalNode.java
  17. +2 −0 truffle/src/main/java/org/jruby/truffle/nodes/rubinius/EncodingConverterPrimitiveNodes.java
  18. +22 −16 truffle/src/main/java/org/jruby/truffle/nodes/rubinius/IOBufferPrimitiveNodes.java
  19. +19 −6 truffle/src/main/java/org/jruby/truffle/nodes/rubinius/IOPrimitiveNodes.java
  20. +3 −0 truffle/src/main/java/org/jruby/truffle/nodes/rubinius/PointerPrimitiveNodes.java
  21. +12 −0 truffle/src/main/java/org/jruby/truffle/nodes/rubinius/PosixNodes.java
  22. +7 −1 truffle/src/main/java/org/jruby/truffle/nodes/rubinius/RubiniusLastStringReadNode.java
  23. +4 −0 truffle/src/main/java/org/jruby/truffle/nodes/rubinius/StatPrimitiveNodes.java
  24. +1 −0 truffle/src/main/java/org/jruby/truffle/nodes/rubinius/StringPrimitiveNodes.java
  25. +1 −0 truffle/src/main/java/org/jruby/truffle/nodes/rubinius/TimePrimitiveNodes.java
  26. +1 −0 truffle/src/main/java/org/jruby/truffle/nodes/rubinius/VMPrimitiveNodes.java
  27. +1 −0 truffle/src/main/java/org/jruby/truffle/runtime/subsystems/ThreadManager.java
  28. +7 −1 truffle/src/main/java/org/jruby/truffle/translator/DeadNode.java
Original file line number Diff line number Diff line change
@@ -21,6 +21,7 @@
package org.jruby.truffle.nodes.cast;

import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.api.dsl.NodeChild;
import com.oracle.truffle.api.dsl.NodeChildren;
import com.oracle.truffle.api.dsl.Specialization;
@@ -86,6 +87,7 @@ public int cmpBignum(RubyBasicObject value, Object receiver, Object other) {
return BignumNodes.getBigIntegerValue(value).signum();
}

@TruffleBoundary
@Specialization(guards = "isNil(nil)")
public int cmpNil(Object nil, Object receiver, Object other) {
throw new RaiseException(
Original file line number Diff line number Diff line change
@@ -435,17 +435,22 @@ public Object encodingMap(VirtualFrame frame) {
final Object externalTuple = getContext().makeTuple(frame, newTupleNode, createString("external"), indexLookup(encodings, defaultExternalEncoding));
lookupTableWriteNode.call(frame, ret, "[]=", null, getSymbol("EXTERNAL"), externalTuple);

final Encoding localeEncoding = getContext().getRuntime().getEncodingService().getLocaleEncoding();
final Encoding localeEncoding = getLocaleEncoding();
final Object localeTuple = getContext().makeTuple(frame, newTupleNode, createString("locale"), indexLookup(encodings, localeEncoding));
lookupTableWriteNode.call(frame, ret, "[]=", null, getSymbol("LOCALE"), localeTuple);

final Encoding filesystemEncoding = getContext().getRuntime().getEncodingService().getLocaleEncoding();
final Encoding filesystemEncoding = getLocaleEncoding();
final Object filesystemTuple = getContext().makeTuple(frame, newTupleNode, createString("filesystem"), indexLookup(encodings, filesystemEncoding));
lookupTableWriteNode.call(frame, ret, "[]=", null, getSymbol("FILESYSTEM"), filesystemTuple);

return ret;
}

@TruffleBoundary
private Encoding getLocaleEncoding() {
return getContext().getRuntime().getEncodingService().getLocaleEncoding();
}

@TruffleBoundary
public Object indexLookup(RubyBasicObject[] encodings, Encoding encoding) {
// TODO (nirvdrum 25-Mar-15): Build up this lookup table in RubyEncoding as we register encodings.
Original file line number Diff line number Diff line change
@@ -9,6 +9,7 @@
*/
package org.jruby.truffle.nodes.core;

import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.nodes.Node;
import com.oracle.truffle.api.source.SourceSection;
@@ -114,6 +115,7 @@ public BacktraceNode(RubyContext context, SourceSection sourceSection) {
readCustomBacktrace = new ReadHeadObjectFieldNode("@custom_backtrace");
}

@TruffleBoundary
@Specialization
public Object backtrace(RubyBasicObject exception) {
if (readCustomBacktrace.isSet(exception)) {
Original file line number Diff line number Diff line change
@@ -889,6 +889,7 @@ public int hash(boolean value) {
return Boolean.valueOf(value).hashCode();
}

@TruffleBoundary
@Specialization
public int hash(RubyBasicObject self) {
// TODO(CS 8 Jan 15) we shouldn't use the Java class hierarchy like this - every class should define it's
@@ -1969,6 +1970,7 @@ private RubyBasicObject finishFormat(ByteList format, PackResult result) {
return string;
}

@TruffleBoundary
protected CallTarget compileFormat(RubyBasicObject format) {
assert RubyGuards.isRubyString(format);

Original file line number Diff line number Diff line change
@@ -304,6 +304,7 @@ public RubyBasicObject toProcUncached(RubyBasicObject methodObject) {
null);
}

@TruffleBoundary
protected CallTarget method2proc(RubyBasicObject methodObject) {
// translate to something like:
// lambda { |same args list| method.call(args) }
Original file line number Diff line number Diff line change
@@ -84,6 +84,7 @@ protected Object clock_gettime_realtime(int clock_id, RubyBasicObject unit) {
return timeToUnit(time, unit);
}

@TruffleBoundary
@Specialization(guards = { "isThreadCPUTime(clock_id)", "isRubySymbol(unit)" })
protected Object clock_gettime_thread_cputime(int clock_id, RubyBasicObject unit,
@Cached("getLibCClockGetTime()") LibCClockGetTime libCClockGetTime) {
Original file line number Diff line number Diff line change
@@ -76,6 +76,7 @@ public PushNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@TruffleBoundary
@Specialization
public RubyBasicObject push(RubyBasicObject self, final Object value) {
final BlockingQueue<Object> queue = getQueue(self);
@@ -102,6 +103,7 @@ public RubyNode coerceToBoolean(RubyNode nonBlocking) {
return BooleanCastWithDefaultNodeGen.create(getContext(), getSourceSection(), false, nonBlocking);
}

@TruffleBoundary
@Specialization(guards = "!nonBlocking")
public Object popBlocking(RubyBasicObject self, boolean nonBlocking) {
final BlockingQueue<Object> queue = getQueue(self);
@@ -114,6 +116,7 @@ public Object block() throws InterruptedException {
});
}

@TruffleBoundary
@Specialization(guards = "nonBlocking")
public Object popNonBlock(RubyBasicObject self, boolean nonBlocking) {
final BlockingQueue<Object> queue = getQueue(self);
@@ -187,6 +190,7 @@ public EmptyNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@TruffleBoundary
@Specialization
public boolean empty(RubyBasicObject self) {
final BlockingQueue<Object> queue = getQueue(self);
@@ -202,6 +206,7 @@ public SizeNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@TruffleBoundary
@Specialization
public int size(RubyBasicObject self) {
final BlockingQueue<Object> queue = getQueue(self);
@@ -217,6 +222,7 @@ public ClearNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@TruffleBoundary
@Specialization
public RubyBasicObject clear(RubyBasicObject self) {
final BlockingQueue<Object> queue = getQueue(self);
Original file line number Diff line number Diff line change
@@ -640,6 +640,7 @@ public ToSNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@TruffleBoundary
@Specialization
public RubyBasicObject toS(RubyBasicObject regexp) {
return createString(((org.jruby.RubyString) org.jruby.RubyRegexp.newRegexp(getContext().getRuntime(), getSource(regexp), getRegex(regexp).getOptions()).to_s()).getByteList());
Original file line number Diff line number Diff line change
@@ -10,6 +10,7 @@
package org.jruby.truffle.nodes.core;

import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.api.dsl.CreateCast;
import com.oracle.truffle.api.dsl.NodeChild;
import com.oracle.truffle.api.dsl.NodeChildren;
@@ -107,6 +108,7 @@ public SetMaxNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@TruffleBoundary
@Specialization
public int setMax(RubyBasicObject self, int newCapacity) {
if (newCapacity <= 0) {
@@ -136,6 +138,7 @@ public MaxNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@TruffleBoundary
@Specialization
public int max(RubyBasicObject self) {
final BlockingQueue<Object> queue = getQueue(self);
@@ -178,6 +181,7 @@ public Boolean block() throws InterruptedException {
return self;
}

@TruffleBoundary
@Specialization(guards = "nonBlocking")
public RubyBasicObject pushNonBlock(RubyBasicObject self, final Object value, boolean nonBlocking) {
final BlockingQueue<Object> queue = getQueue(self);
@@ -221,6 +225,7 @@ public Object block() throws InterruptedException {
});
}

@TruffleBoundary
@Specialization(guards = "nonBlocking")
public Object popNonBlock(RubyBasicObject self, boolean nonBlocking) {
final BlockingQueue<Object> queue = getQueue(self);
@@ -243,6 +248,7 @@ public EmptyNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@TruffleBoundary
@Specialization
public boolean empty(RubyBasicObject self) {
final BlockingQueue<Object> queue = getQueue(self);
@@ -273,6 +279,7 @@ public ClearNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@TruffleBoundary
@Specialization
public RubyBasicObject clear(RubyBasicObject self) {
final BlockingQueue<Object> queue = getQueue(self);
Original file line number Diff line number Diff line change
@@ -1477,6 +1477,7 @@ public LstripBangNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@TruffleBoundary
@Specialization(guards = "isSingleByteOptimizable(string)")
public Object lstripBangSingleByte(RubyBasicObject string) {
// Taken from org.jruby.RubyString#lstrip_bang19 and org.jruby.RubyString#singleByteLStrip.
@@ -1501,6 +1502,7 @@ public Object lstripBangSingleByte(RubyBasicObject string) {
return nil();
}

@TruffleBoundary
@Specialization(guards = "!isSingleByteOptimizable(string)")
public Object lstripBang(RubyBasicObject string) {
// Taken from org.jruby.RubyString#lstrip_bang19 and org.jruby.RubyString#multiByteLStrip.
@@ -1615,6 +1617,7 @@ public RstripBangNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@TruffleBoundary
@Specialization(guards = "isSingleByteOptimizable(string)")
public Object rstripBangSingleByte(RubyBasicObject string) {
// Taken from org.jruby.RubyString#rstrip_bang19 and org.jruby.RubyString#singleByteRStrip19.
@@ -1640,6 +1643,7 @@ public Object rstripBangSingleByte(RubyBasicObject string) {
return nil();
}

@TruffleBoundary
@Specialization(guards = "!isSingleByteOptimizable(string)")
public Object rstripBang(RubyBasicObject string) {
// Taken from org.jruby.RubyString#rstrip_bang19 and org.jruby.RubyString#multiByteRStrip19.
@@ -1687,6 +1691,7 @@ public SwapcaseBangNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@TruffleBoundary
@Specialization
public RubyBasicObject swapcaseSingleByte(RubyBasicObject string) {
// Taken from org.jruby.RubyString#swapcase_bang19.
@@ -1747,6 +1752,7 @@ public RubyBasicObject dumpAsciiCompatible(RubyBasicObject string) {
return result;
}

@TruffleBoundary
@Specialization(guards = "!isAsciiCompatible(string)")
public RubyBasicObject dump(RubyBasicObject string) {
// Taken from org.jruby.RubyString#dump
@@ -1887,6 +1893,11 @@ public Object squeezeBang(VirtualFrame frame, RubyBasicObject string, Object...
for (int i = 0; i < args.length; i++) {
otherStrings[i] = toStrNode.executeToStr(frame, args[i]);
}
return performSqueezeBang(string, otherStrings);
}

@TruffleBoundary
private Object performSqueezeBang(RubyBasicObject string, RubyBasicObject[] otherStrings) {

RubyBasicObject otherStr = otherStrings[0];
Encoding enc = checkEncoding(string, getCodeRangeable(otherStr), this);
Original file line number Diff line number Diff line change
@@ -10,6 +10,7 @@
package org.jruby.truffle.nodes.core;

import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.nodes.Node;
@@ -377,6 +378,7 @@ public InitializeNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@TruffleBoundary
@Specialization(guards = "isRubyProc(block)")
public RubyBasicObject initialize(RubyBasicObject thread, Object[] arguments, RubyBasicObject block) {
ThreadNodes.initialize(thread, getContext(), this, arguments, block);
Original file line number Diff line number Diff line change
@@ -9,6 +9,7 @@
*/
package org.jruby.truffle.nodes.core;

import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.api.dsl.NodeChild;
import com.oracle.truffle.api.dsl.NodeChildren;
import com.oracle.truffle.api.dsl.Specialization;
@@ -97,6 +98,7 @@ public InternalSetGMTNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@TruffleBoundary
@Specialization
public boolean internalSetGMT(RubyBasicObject time, boolean isGMT) {
if (isGMT) {
Original file line number Diff line number Diff line change
@@ -494,10 +494,6 @@ public Object appendArray(Object store, int index, RubyBasicObject array) {

@Override
public Object appendValue(Object store, int index, Object value) {
if (index >= ((Object[]) store).length) {
new Exception().printStackTrace();
}

((Object[]) store)[index] = value;
return store;
}
Original file line number Diff line number Diff line change
@@ -12,6 +12,7 @@
import com.oracle.truffle.api.CallTarget;
import com.oracle.truffle.api.CompilerAsserts;
import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.api.Truffle;
import com.oracle.truffle.api.dsl.*;
import com.oracle.truffle.api.frame.FrameDescriptor;
@@ -2830,6 +2831,7 @@ public Object pack(VirtualFrame frame, RubyBasicObject array, Object format) {
return ruby(frame, "pack(format.to_str)", "format", format);
}

@TruffleBoundary
protected CallTarget compileFormat(RubyBasicObject format) {
assert RubyGuards.isRubyString(format);
try {
Original file line number Diff line number Diff line change
@@ -9,6 +9,7 @@
*/
package org.jruby.truffle.nodes.exceptions;

import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.source.SourceSection;
import org.jruby.truffle.nodes.RubyNode;
@@ -33,18 +34,23 @@ public Object execute(VirtualFrame frame) {
try {
return body.execute(frame);
} catch (RaiseException e) {
final Object rubyException = e.getRubyException();

for (String line : Backtrace.DISPLAY_FORMATTER.format(getContext(), (RubyBasicObject) rubyException, ExceptionNodes.getBacktrace((RubyBasicObject) rubyException))) {
System.err.println(line);
}

System.exit(1);
handleException(e);
} catch (ThreadExitException e) {
// Ignore
}

return nil();
}

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

for (String line : Backtrace.DISPLAY_FORMATTER.format(getContext(), (RubyBasicObject) rubyException, ExceptionNodes.getBacktrace((RubyBasicObject) rubyException))) {
System.err.println(line);
}

System.exit(1);
}

}
Original file line number Diff line number Diff line change
@@ -9,6 +9,7 @@
*/
package org.jruby.truffle.nodes.globals;

import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.api.dsl.NodeChild;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.source.SourceSection;
@@ -32,6 +33,7 @@ public GetFromThreadLocalNode(RubyContext context, SourceSection sourceSection)
super(context, sourceSection);
}

@TruffleBoundary
@Specialization
public Object get(ThreadLocalObject threadLocal) {
return threadLocal.get();
Original file line number Diff line number Diff line change
@@ -12,6 +12,7 @@
package org.jruby.truffle.nodes.rubinius;

import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.source.SourceSection;
@@ -82,6 +83,7 @@ public Object encodingConverterPrimitiveConvert(RubyBasicObject encodingConverte
return primitiveConvertHelper(encodingConverter, StringNodes.getByteList(source), source, target, offset, size, options);
}

@TruffleBoundary
private Object primitiveConvertHelper(RubyBasicObject encodingConverter, ByteList inBytes, RubyBasicObject source,
RubyBasicObject target, int offset, int size, int options) {
// Taken from org.jruby.RubyConverter#primitive_convert.
Loading