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

Commits on Oct 6, 2016

  1. Copy the full SHA
    6e5df1b View commit details
  2. Copy the full SHA
    b48bdab View commit details
  3. 7
    Copy the full SHA
    998b16d View commit details
  4. Copy the full SHA
    f16e798 View commit details
  5. Copy the full SHA
    452df34 View commit details
  6. Copy the full SHA
    b756ba6 View commit details
Showing with 82 additions and 87 deletions.
  1. +1 −0 spec/truffle/tags/core/kernel/caller_locations_tags.txt
  2. +1 −2 truffle/src/main/java/org/jruby/truffle/builtins/CoreMethodNodeManager.java
  3. +1 −1 truffle/src/main/java/org/jruby/truffle/builtins/PrimitiveNodeConstructor.java
  4. +14 −0 truffle/src/main/java/org/jruby/truffle/core/CoreLibrary.java
  5. +3 −1 truffle/src/main/java/org/jruby/truffle/core/fiber/FiberNodes.java
  6. +0 −30 truffle/src/main/java/org/jruby/truffle/core/format/DescriptionTruncater.java
  7. +8 −5 truffle/src/main/java/org/jruby/truffle/core/format/FormatRootNode.java
  8. +1 −2 truffle/src/main/java/org/jruby/truffle/core/format/pack/PackCompiler.java
  9. +2 −3 truffle/src/main/java/org/jruby/truffle/core/format/printf/PrintfCompiler.java
  10. +1 −2 truffle/src/main/java/org/jruby/truffle/core/format/unpack/UnpackCompiler.java
  11. +8 −6 truffle/src/main/java/org/jruby/truffle/core/format/unpack/UnpackRootNode.java
  12. +1 −1 truffle/src/main/java/org/jruby/truffle/core/kernel/KernelNodes.java
  13. +2 −2 truffle/src/main/java/org/jruby/truffle/core/thread/ThreadBacktraceLocationNodes.java
  14. +3 −1 truffle/src/main/java/org/jruby/truffle/core/thread/ThreadManager.java
  15. +1 −1 truffle/src/main/java/org/jruby/truffle/language/CallStackManager.java
  16. +2 −2 truffle/src/main/java/org/jruby/truffle/language/RubySourceSection.java
  17. +12 −8 truffle/src/main/java/org/jruby/truffle/language/backtrace/BacktraceFormatter.java
  18. +2 −1 truffle/src/main/java/org/jruby/truffle/language/control/WhileNode.java
  19. +1 −1 truffle/src/main/java/org/jruby/truffle/language/methods/SharedMethodInfo.java
  20. +1 −1 truffle/src/main/java/org/jruby/truffle/parser/BodyTranslator.java
  21. +5 −2 truffle/src/main/java/org/jruby/truffle/parser/ReloadArgumentsTranslator.java
  22. +3 −5 truffle/src/main/java/org/jruby/truffle/parser/TranslatorDriver.java
  23. +9 −10 truffle/src/main/java/org/jruby/truffle/stdlib/CoverageManager.java
1 change: 1 addition & 0 deletions spec/truffle/tags/core/kernel/caller_locations_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fails:Kernel#caller_locations returns an Array of caller locations using a custom offset
Original file line number Diff line number Diff line change
@@ -169,7 +169,6 @@ private static void addMethod(RubyContext context, DynamicObject module, SharedM
private static SharedMethodInfo makeSharedMethodInfo(RubyContext context, MethodDetails methodDetails) {
final CoreMethod method = methodDetails.getMethodAnnotation();
final String methodName = method.names()[0];
final SourceSection sourceSection = SourceSection.createUnavailable("core", methodDetails.getIndicativeName());

final int required = method.required();
final int optional = method.optional();
@@ -178,7 +177,7 @@ private static SharedMethodInfo makeSharedMethodInfo(RubyContext context, Method

final Arity arity = new Arity(required, optional, method.rest());

return new SharedMethodInfo(sourceSection, LexicalScope.NONE, arity, methodName, false, null, context.getOptions().CORE_ALWAYS_CLONE, alwaysInline, needsCallerFrame);
return new SharedMethodInfo(context.getCoreLibrary().getSourceSection(), LexicalScope.NONE, arity, methodName, false, null, context.getOptions().CORE_ALWAYS_CLONE, alwaysInline, needsCallerFrame);
}

private static CallTarget makeGenericMethod(RubyContext context, MethodDetails methodDetails, SharedMethodInfo sharedMethodInfo) {
Original file line number Diff line number Diff line change
@@ -84,7 +84,7 @@ public RubyNode createCallPrimitiveNode(RubyContext context, SourceSection sourc
}

public RubyNode createInvokePrimitiveNode(RubyContext context, SourceSection sourceSection, RubyNode[] arguments) {
assert arguments.length == getPrimitiveArity() : sourceSection.getShortDescription();
assert arguments.length == getPrimitiveArity();

if (!CoreMethodNodeManager.isSafe(context, annotation.unsafe())) {
return new UnsafeNode(context, sourceSection);
14 changes: 14 additions & 0 deletions truffle/src/main/java/org/jruby/truffle/core/CoreLibrary.java
Original file line number Diff line number Diff line change
@@ -21,6 +21,8 @@
import com.oracle.truffle.api.object.DynamicObjectFactory;
import com.oracle.truffle.api.object.Layout;
import com.oracle.truffle.api.object.Property;
import com.oracle.truffle.api.source.Source;
import com.oracle.truffle.api.source.SourceSection;
import jnr.constants.platform.Errno;
import org.jcodings.EncodingDB;
import org.jcodings.specific.UTF8Encoding;
@@ -32,6 +34,7 @@
import org.jruby.runtime.encoding.EncodingService;
import org.jruby.truffle.Layouts;
import org.jruby.truffle.RubyContext;
import org.jruby.truffle.RubyLanguage;
import org.jruby.truffle.builtins.CoreMethodNodeManager;
import org.jruby.truffle.builtins.PrimitiveManager;
import org.jruby.truffle.cext.CExtNodesFactory;
@@ -152,6 +155,9 @@ public class CoreLibrary {

private final RubyContext context;

private final Source source = Source.newBuilder("").name("(core)").mimeType(RubyLanguage.MIME_TYPE).build();
private final SourceSection sourceSection = source.createUnavailableSection();

private final DynamicObject argumentErrorClass;
private final DynamicObject arrayClass;
private final DynamicObjectFactory arrayFactory;
@@ -1165,6 +1171,14 @@ public RubyContext getContext() {
return context;
}

public Source getSource() {
return source;
}

public SourceSection getSourceSection() {
return sourceSection;
}

public String getCoreLoadPath() {
return coreLoadPath;
}
Original file line number Diff line number Diff line change
@@ -36,6 +36,7 @@
import org.jruby.truffle.language.control.RaiseException;
import org.jruby.truffle.language.control.ReturnException;
import org.jruby.truffle.language.methods.UnsupportedOperationBehavior;
import org.jruby.truffle.parser.BodyTranslator;
import org.jruby.truffle.platform.UnsafeGroup;

import java.util.concurrent.CountDownLatch;
@@ -68,7 +69,8 @@ private static DynamicObject createFiber(RubyContext context, DynamicObject thre
}

public static void initialize(final RubyContext context, final DynamicObject fiber, final DynamicObject block, final Node currentNode) {
final String name = "Ruby Fiber@" + Layouts.PROC.getSharedMethodInfo(block).getSourceSection().getShortDescription();
final SourceSection sourceSection = Layouts.PROC.getSharedMethodInfo(block).getSourceSection();
final String name = String.format("Ruby Fiber@%s:%d", sourceSection.getSource().getName(), sourceSection.getStartLine());
final Thread thread = new Thread(() -> handleFiberExceptions(context, fiber, block, currentNode));
thread.setName(name);
thread.start();

This file was deleted.

Original file line number Diff line number Diff line change
@@ -25,16 +25,14 @@
*/
public class FormatRootNode extends RootNode implements InternalRootNode {

private final String description;
private final FormatEncoding encoding;

@Child private FormatNode child;

@CompilationFinal private int expectedLength = 0;

public FormatRootNode(String description, FormatEncoding encoding, FormatNode child) {
super(RubyLanguage.class, SourceSection.createUnavailable("pack", description), FormatFrameDescriptor.FRAME_DESCRIPTOR);
this.description = description;
public FormatRootNode(SourceSection sourceSection, FormatEncoding encoding, FormatNode child) {
super(RubyLanguage.class, sourceSection, FormatFrameDescriptor.FRAME_DESCRIPTOR);
this.encoding = encoding;
this.child = child;
}
@@ -116,9 +114,14 @@ public boolean isCloningAllowed() {
return true;
}

@Override
public String getName() {
return "unpack";
}

@Override
public String toString() {
return description;
return getName();
}

}
Original file line number Diff line number Diff line change
@@ -14,7 +14,6 @@
import org.antlr.v4.runtime.ANTLRInputStream;
import org.antlr.v4.runtime.CommonTokenStream;
import org.jruby.truffle.RubyContext;
import org.jruby.truffle.core.format.DescriptionTruncater;
import org.jruby.truffle.core.format.FormatErrorListener;
import org.jruby.truffle.core.format.FormatRootNode;
import org.jruby.truffle.core.format.LoopRecovery;
@@ -56,7 +55,7 @@ public CallTarget compile(String format) {
parser.sequence();

return Truffle.getRuntime().createCallTarget(
new FormatRootNode(DescriptionTruncater.trunate(format), builder.getEncoding(), builder.getNode()));
new FormatRootNode(currentNode.getEncapsulatingSourceSection(), builder.getEncoding(), builder.getNode()));
}

}
Original file line number Diff line number Diff line change
@@ -12,7 +12,6 @@
import com.oracle.truffle.api.CallTarget;
import com.oracle.truffle.api.Truffle;
import org.jruby.truffle.RubyContext;
import org.jruby.truffle.core.format.DescriptionTruncater;
import org.jruby.truffle.core.format.FormatEncoding;
import org.jruby.truffle.core.format.FormatRootNode;
import org.jruby.truffle.language.RubyNode;
@@ -29,13 +28,13 @@ public PrintfCompiler(RubyContext context, RubyNode currentNode) {
this.currentNode = currentNode;
}

public CallTarget compile(String formatString, byte[] format) {
public CallTarget compile(byte[] format) {
final PrintfSimpleParser parser = new PrintfSimpleParser(bytesToChars(format));
final List<SprintfConfig> configs = parser.parse();
final PrintfSimpleTreeBuilder builder = new PrintfSimpleTreeBuilder(context, configs);

return Truffle.getRuntime().createCallTarget(
new FormatRootNode(DescriptionTruncater.trunate(formatString),
new FormatRootNode(currentNode.getEncapsulatingSourceSection(),
FormatEncoding.DEFAULT, builder.getNode()));
}

Original file line number Diff line number Diff line change
@@ -14,7 +14,6 @@
import org.antlr.v4.runtime.ANTLRInputStream;
import org.antlr.v4.runtime.CommonTokenStream;
import org.jruby.truffle.RubyContext;
import org.jruby.truffle.core.format.DescriptionTruncater;
import org.jruby.truffle.core.format.FormatErrorListener;
import org.jruby.truffle.core.format.LoopRecovery;
import org.jruby.truffle.core.format.pack.PackLexer;
@@ -57,7 +56,7 @@ public CallTarget compile(String format) {
parser.sequence();

return Truffle.getRuntime().createCallTarget(
new UnpackRootNode(context, DescriptionTruncater.trunate(format), builder.getNode()));
new UnpackRootNode(context, currentNode.getEncapsulatingSourceSection(), builder.getNode()));
}

}
Original file line number Diff line number Diff line change
@@ -26,19 +26,16 @@ public class UnpackRootNode extends RootNode implements InternalRootNode {

private final RubyContext context;

private final String description;

@Child private FormatNode child;

@CompilationFinal private int expectedLength;

public UnpackRootNode(RubyContext context, String description, FormatNode child) {
public UnpackRootNode(RubyContext context, SourceSection sourceSection, FormatNode child) {
super(RubyLanguage.class,
SourceSection.createUnavailable("unpack", description),
sourceSection,
FormatFrameDescriptor.FRAME_DESCRIPTOR);

this.context = context;
this.description = description;
this.child = child;
expectedLength = context.getOptions().ARRAY_UNINITIALIZED_SIZE;
}
@@ -91,9 +88,14 @@ public boolean isCloningAllowed() {
return true;
}

@Override
public String getName() {
return "unpack";
}

@Override
public String toString() {
return description;
return getName();
}

}
Original file line number Diff line number Diff line change
@@ -1759,7 +1759,7 @@ protected CallTarget compileFormat(DynamicObject format) {

try {
return new PrintfCompiler(getContext(), this)
.compile(format.toString(), Layouts.STRING.getRope(format).getBytes());
.compile(Layouts.STRING.getRope(format).getBytes());
} catch (InvalidFormatException e) {
throw new RaiseException(coreExceptions().argumentError(e.getMessage(), this));
}
Original file line number Diff line number Diff line change
@@ -42,7 +42,7 @@ public DynamicObject absolutePath(DynamicObject threadBacktraceLocation) {
final SourceSection sourceSection = activation.getCallNode().getEncapsulatingSourceSection();

if (sourceSection.getSource() == null) {
return createString(StringOperations.encodeRope(sourceSection.getShortDescription(), UTF8Encoding.INSTANCE));
return createString(StringOperations.encodeRope(String.format("%s:%d", sourceSection.getSource().getName(), sourceSection.getStartLine()), UTF8Encoding.INSTANCE));
}

// TODO CS 30-Apr-15: not absolute - not sure how to solve that
@@ -93,7 +93,7 @@ public DynamicObject toS(DynamicObject threadBacktraceLocation) {
final SourceSection sourceSection = callNode.getEncapsulatingSourceSection();

if (sourceSection.getSource() == null) {
return createString(StringOperations.encodeRope(sourceSection.getShortDescription(), UTF8Encoding.INSTANCE));
return createString(StringOperations.encodeRope(String.format("%s:%d", sourceSection.getSource().getName(), sourceSection.getStartLine()), UTF8Encoding.INSTANCE));
}

return createString(RopeOperations.format(getContext(),
Original file line number Diff line number Diff line change
@@ -12,6 +12,7 @@
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.api.nodes.Node;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.source.SourceSection;
import jnr.posix.DefaultNativeTimeval;
import jnr.posix.Timeval;
import org.jruby.RubyThread.Status;
@@ -91,7 +92,8 @@ public static DynamicObject createThreadLocals(RubyContext context) {
}

public static void initialize(final DynamicObject thread, RubyContext context, Node currentNode, final Object[] arguments, final DynamicObject block) {
String info = Layouts.PROC.getSharedMethodInfo(block).getSourceSection().getShortDescription();
final SourceSection sourceSection = Layouts.PROC.getSharedMethodInfo(block).getSourceSection();
final String info = String.format("%s:%d", sourceSection.getSource().getName(), sourceSection.getStartLine());
initialize(thread, context, currentNode, info, () -> {
final Object value = ProcOperations.rootCall(block, arguments);
Layouts.THREAD.setValue(thread, value);
Original file line number Diff line number Diff line change
@@ -254,7 +254,7 @@ private boolean hasNullSourceSection(FrameInstance frameInstance) {
private Node getCallNode(FrameInstance frameInstance, final InternalMethod method) {
Node callNode = frameInstance.getCallNode();
if (callNode == null && method != null &&
BacktraceFormatter.isCore(method.getSharedMethodInfo().getSourceSection())) {
BacktraceFormatter.isCore(context, method.getSharedMethodInfo().getSourceSection())) {
callNode = ((RootCallTarget) method.getCallTarget()).getRootNode();
}
return callNode;
Original file line number Diff line number Diff line change
@@ -54,7 +54,7 @@ public int getEndLine() {

public SourceSection toSourceSection(Source source) {
if (source == null) {
return SourceSection.createUnavailable("core", "(identifier)");
throw new UnsupportedOperationException();
}

final int index = source.getLineStartOffset(startLine);
@@ -69,7 +69,7 @@ public SourceSection toSourceSection(Source source) {
length = Math.min(length, source.getLength() - index);
length = Math.max(0, length);

return source.createSection("(identifier)", index, length);
return source.createSection(index, length);
}

}
Original file line number Diff line number Diff line change
@@ -138,7 +138,7 @@ public String formatLine(List<Activation> activations, int n, DynamicObject exce
String reportedName;

if (isJavaCore(sourceSection) ||
(isCore(sourceSection) && !flags.contains(FormattingFlags.INCLUDE_CORE_FILES))) {
(isCore(context, sourceSection) && !flags.contains(FormattingFlags.INCLUDE_CORE_FILES))) {
final SourceSection nextUserSourceSection = nextUserSourceSection(activations, n);
// if there is no next source section use a core one to avoid ???
reportedSourceSection = nextUserSourceSection != null ? nextUserSourceSection : sourceSection;
@@ -151,7 +151,7 @@ public String formatLine(List<Activation> activations, int n, DynamicObject exce
if (reportedSourceSection == null) {
builder.append("???");
} else if (reportedSourceSection.getSource() == null) {
builder.append(reportedSourceSection.getShortDescription());
builder.append(String.format("%s:%d", reportedSourceSection.getSource().getName(), reportedSourceSection.getStartLine()));
} else {
builder.append(reportedSourceSection.getSource().getName());
builder.append(":");
@@ -203,7 +203,7 @@ private SourceSection nextUserSourceSection(List<Activation> activations, int n)
if (callNode != null) {
final SourceSection sourceSection = callNode.getEncapsulatingSourceSection();

if (!isCore(sourceSection)) {
if (!isCore(context, sourceSection)) {
return sourceSection;
}
}
@@ -217,11 +217,15 @@ public static boolean isJavaCore(SourceSection sourceSection) {
return sourceSection != null && sourceSection.getSource() == null;
}

public static boolean isCore(SourceSection sourceSection) {
public static boolean isCore(RubyContext context, SourceSection sourceSection) {
if (sourceSection == null) {
return true;
}

if (sourceSection.getSource() == context.getCoreLibrary().getSource()) {
return true;
}

final Source source = sourceSection.getSource();
if (source == null) {
return true;
@@ -242,7 +246,7 @@ public static boolean isCore(SourceSection sourceSection) {

/** For debug purposes. */
public static boolean isUserSourceSection(RubyContext context, SourceSection sourceSection) {
if (!BacktraceFormatter.isCore(sourceSection)) {
if (!BacktraceFormatter.isCore(context, sourceSection)) {
return false;
}

@@ -260,12 +264,12 @@ private String formatForeign(Node callNode) {
final SourceSection sourceSection = callNode.getEncapsulatingSourceSection();

if (sourceSection != null) {
final String shortDescription = sourceSection.getShortDescription();
final String shortDescription = String.format("%s:%d", sourceSection.getSource().getName(), sourceSection.getStartLine());

if (shortDescription.trim().equals(":")) {
builder.append(getRootOrTopmostNode(callNode).getClass().getSimpleName());
throw new UnsupportedOperationException();
} else {
builder.append(sourceSection.getShortDescription());
builder.append(shortDescription);

final RootNode rootNode = callNode.getRootNode();
final String identifier = rootNode.getName();
Loading