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

Commits on Feb 29, 2016

  1. Unverified

    This user has not yet uploaded their public signing key.
    Copy the full SHA
    22a1d60 View commit details
  2. Copy the full SHA
    bcfee12 View commit details
  3. Copy the full SHA
    6216462 View commit details
  4. Copy the full SHA
    6b8e98b View commit details
  5. Copy the full SHA
    6cc96c1 View commit details
Showing with 97 additions and 148 deletions.
  1. +10 −5 truffle/src/main/java/org/jruby/truffle/core/CoreLibrary.java
  2. +1 −1 truffle/src/main/java/org/jruby/truffle/core/CoreMethodNodeManager.java
  3. +1 −1 truffle/src/main/java/org/jruby/truffle/core/module/ModuleNodes.java
  4. +1 −1 truffle/src/main/java/org/jruby/truffle/core/symbol/SymbolNodes.java
  5. +0 −12 truffle/src/main/java/org/jruby/truffle/language/methods/Arity.java
  6. +4 −12 truffle/src/main/java/org/jruby/truffle/language/methods/CatchBreakNode.java
  7. +7 −9 truffle/src/main/java/org/jruby/truffle/language/methods/CatchForLambdaNode.java
  8. +7 −8 truffle/src/main/java/org/jruby/truffle/language/methods/CatchForMethodNode.java
  9. +3 −3 truffle/src/main/java/org/jruby/truffle/language/methods/CatchForProcNode.java
  10. +0 −3 truffle/src/main/java/org/jruby/truffle/language/methods/CatchNextNode.java
  11. +5 −3 truffle/src/main/java/org/jruby/truffle/language/methods/CatchRetryAsErrorNode.java
  12. +4 −5 truffle/src/main/java/org/jruby/truffle/language/methods/CatchReturnAsErrorNode.java
  13. +33 −31 truffle/src/main/java/org/jruby/truffle/language/methods/ExceptionTranslatingNode.java
  14. +0 −32 truffle/src/main/java/org/jruby/truffle/language/methods/MarkerNode.java
  15. +4 −3 truffle/src/main/java/org/jruby/truffle/language/parser/jruby/BodyTranslator.java
  16. +6 −19 truffle/src/main/java/org/jruby/truffle/language/parser/jruby/MethodTranslator.java
  17. +11 −0 truffle/src/main/java/org/jruby/truffle/language/parser/jruby/Translator.java
15 changes: 10 additions & 5 deletions truffle/src/main/java/org/jruby/truffle/core/CoreLibrary.java
Original file line number Diff line number Diff line change
@@ -925,9 +925,9 @@ public DynamicObject runtimeError(String message, Node currentNode) {
return ExceptionNodes.createRubyException(runtimeErrorClass, StringOperations.createString(context, StringOperations.encodeRope(message, UTF8Encoding.INSTANCE)), context.getCallStack().getBacktrace(currentNode));
}

public DynamicObject systemStackError(String message, Node currentNode) {
CompilerAsserts.neverPartOfCompilation();
return ExceptionNodes.createRubyException(systemStackErrorClass, StringOperations.createString(context, StringOperations.encodeRope(message, UTF8Encoding.INSTANCE)), context.getCallStack().getBacktrace(currentNode));
@TruffleBoundary
public DynamicObject systemStackErrorStackLevelTooDeep(Node currentNode, Throwable javaThrowable) {
return ExceptionNodes.createRubyException(systemStackErrorClass, StringOperations.createString(context, StringOperations.encodeRope("stack level too deep", UTF8Encoding.INSTANCE)), context.getCallStack().getBacktrace(currentNode, javaThrowable));
}

@TruffleBoundary
@@ -1033,8 +1033,8 @@ public DynamicObject breakFromProcClosure(Node currentNode) {
return localJumpError("break from proc-closure", currentNode);
}

@TruffleBoundary
public DynamicObject unexpectedReturn(Node currentNode) {
CompilerAsserts.neverPartOfCompilation();
return localJumpError("unexpected return", currentNode);
}

@@ -1289,8 +1289,13 @@ public DynamicObject notImplementedError(String message, Node currentNode) {
return ExceptionNodes.createRubyException(notImplementedErrorClass, StringOperations.createString(context, StringOperations.encodeRope(String.format("Method %s not implemented", message), UTF8Encoding.INSTANCE)), context.getCallStack().getBacktrace(currentNode));
}

@TruffleBoundary
public DynamicObject syntaxErrorInvalidRetry(Node currentNode) {
return syntaxError("Invalid retry", currentNode);
}

@TruffleBoundary
public DynamicObject syntaxError(String message, Node currentNode) {
CompilerAsserts.neverPartOfCompilation();
return ExceptionNodes.createRubyException(syntaxErrorClass, StringOperations.createString(context, StringOperations.encodeRope(message, UTF8Encoding.INSTANCE)), context.getCallStack().getBacktrace(currentNode));
}

Original file line number Diff line number Diff line change
@@ -231,7 +231,7 @@ private static RubyRootNode makeGenericMethod(RubyContext context, MethodDetails
AmbiguousOptionalArgumentChecker.verifyNoAmbiguousOptionalArguments(methodDetails);
}

final RubyNode checkArity = new CheckArityNode(context, sourceSection, arity);
final RubyNode checkArity = Translator.createCheckArityNode(context, sourceSection, arity);
RubyNode sequence = Translator.sequence(context, sourceSection, Arrays.asList(checkArity, methodNode));

if (method.returnsEnumeratorIfNoBlock()) {
Original file line number Diff line number Diff line change
@@ -421,7 +421,7 @@ public DynamicObject generateAccessor(VirtualFrame frame, DynamicObject module,
final String accessorName = isGetter ? name : name + "=";
final String indicativeName = name + "(attr_" + (isGetter ? "reader" : "writer") + ")";

final RubyNode checkArity = new CheckArityNode(getContext(), sourceSection, arity);
final RubyNode checkArity = Translator.createCheckArityNode(getContext(), sourceSection, arity);
final SharedMethodInfo sharedMethodInfo = new SharedMethodInfo(sourceSection, LexicalScope.NONE, arity, indicativeName, false, null, false, false, false);

final SelfNode self = new SelfNode(getContext(), sourceSection);
Original file line number Diff line number Diff line change
@@ -149,7 +149,7 @@ protected DynamicObject createProc(VirtualFrame frame, DynamicObject symbol) {
sourceSection, null, Arity.AT_LEAST_ONE, Layouts.SYMBOL.getString(symbol),
true, ArgumentDescriptor.ANON_REST, false, false, false);

final RubyRootNode rootNode = new RubyRootNode(getContext(), sourceSection, new FrameDescriptor(nil()), sharedMethodInfo, Translator.sequence(getContext(), sourceSection, Arrays.asList(new CheckArityNode(getContext(), sourceSection, Arity.AT_LEAST_ONE), new SymbolProcNode(getContext(), sourceSection, Layouts.SYMBOL.getString(symbol)))), false);
final RubyRootNode rootNode = new RubyRootNode(getContext(), sourceSection, new FrameDescriptor(nil()), sharedMethodInfo, Translator.sequence(getContext(), sourceSection, Arrays.asList(Translator.createCheckArityNode(getContext(), sourceSection, Arity.AT_LEAST_ONE), new SymbolProcNode(getContext(), sourceSection, Layouts.SYMBOL.getString(symbol)))), false);

final CallTarget callTarget = Truffle.getRuntime().createCallTarget(rootNode);
final InternalMethod method = RubyArguments.getMethod(frame);
Original file line number Diff line number Diff line change
@@ -48,10 +48,6 @@ public int getPreRequired() {
return preRequired;
}

public int getPostRequired() {
return postRequired;
}

public int getRequired() {
return preRequired + postRequired;
}
@@ -64,10 +60,6 @@ public boolean hasRest() {
return hasRest;
}

public int getRestPosition() {
return preRequired + optional;
}

public boolean acceptsKeywords() {
return hasKeywords() || hasKeywordsRest();
}
@@ -76,10 +68,6 @@ public boolean hasKeywords() {
return keywordArguments.length != 0;
}

public int getKeywordsCount() {
return keywordArguments.length;
}

public boolean hasKeywordsRest() {
return hasKeywordsRest;
}
Original file line number Diff line number Diff line change
@@ -10,40 +10,32 @@
package org.jruby.truffle.language.methods;

import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.profiles.BranchProfile;
import com.oracle.truffle.api.profiles.ConditionProfile;
import com.oracle.truffle.api.source.SourceSection;
import org.jruby.truffle.RubyContext;
import org.jruby.truffle.language.RubyNode;
import org.jruby.truffle.language.control.BreakException;
import org.jruby.truffle.language.control.BreakID;

/**
* Catch a {@code break} from a call with a block containing a break
* or inside a while/until loop.
*/
public class CatchBreakNode extends RubyNode {

@Child private RubyNode body;

private final BreakID breakID;

private final BranchProfile breakProfile = BranchProfile.create();
@Child private RubyNode body;

private final ConditionProfile matchingBreakProfile = ConditionProfile.createCountingProfile();

public CatchBreakNode(RubyContext context, SourceSection sourceSection, RubyNode body, BreakID breakID) {
public CatchBreakNode(RubyContext context, SourceSection sourceSection, BreakID breakID, RubyNode body) {
super(context, sourceSection);
this.body = body;
this.breakID = breakID;
this.body = body;
}

@Override
public Object execute(VirtualFrame frame) {
try {
return body.execute(frame);
} catch (BreakException e) {
breakProfile.enter();

if (matchingBreakProfile.profile(e.getBreakID() == breakID)) {
return e.getResult();
} else {
Original file line number Diff line number Diff line change
@@ -9,7 +9,6 @@
*/
package org.jruby.truffle.language.methods;

import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.profiles.BranchProfile;
import com.oracle.truffle.api.profiles.ConditionProfile;
@@ -26,20 +25,20 @@

public class CatchForLambdaNode extends RubyNode {

@Child private RubyNode body;
private final ReturnID returnID;

private final BranchProfile returnProfile = BranchProfile.create();
private final ConditionProfile matchingReturnProfile = ConditionProfile.createBinaryProfile();
@Child private RubyNode body;

private final ConditionProfile matchingReturnProfile = ConditionProfile.createBinaryProfile();
private final BranchProfile retryProfile = BranchProfile.create();
private final BranchProfile redoProfile = BranchProfile.create();
private final BranchProfile nextProfile = BranchProfile.create();
private final BranchProfile breakProfile = BranchProfile.create();

public CatchForLambdaNode(RubyContext context, SourceSection sourceSection, RubyNode body, ReturnID returnID) {
public CatchForLambdaNode(RubyContext context, SourceSection sourceSection, ReturnID returnID, RubyNode body) {
super(context, sourceSection);
this.body = body;
this.returnID = returnID;
this.body = body;
}

@Override
@@ -48,15 +47,14 @@ public Object execute(VirtualFrame frame) {
try {
return body.execute(frame);
} catch (ReturnException e) {
returnProfile.enter();
if (matchingReturnProfile.profile(e.getReturnID() == returnID)) {
return e.getValue();
} else {
throw e;
}
} catch (RetryException e) {
CompilerDirectives.transferToInterpreter();
throw new RaiseException(coreLibrary().syntaxError("Invalid retry", this));
retryProfile.enter();
throw new RaiseException(coreLibrary().syntaxErrorInvalidRetry(this));
} catch (RedoException e) {
redoProfile.enter();
getContext().getSafepointManager().poll(this);
Original file line number Diff line number Diff line change
@@ -9,7 +9,6 @@
*/
package org.jruby.truffle.language.methods;

import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.profiles.BranchProfile;
import com.oracle.truffle.api.profiles.ConditionProfile;
@@ -23,32 +22,32 @@

public class CatchForMethodNode extends RubyNode {

@Child private RubyNode body;
private final ReturnID returnID;

private final BranchProfile returnProfile = BranchProfile.create();
@Child private RubyNode body;

private final ConditionProfile matchingReturnProfile = ConditionProfile.createBinaryProfile();
private final BranchProfile retryProfile = BranchProfile.create();

public CatchForMethodNode(RubyContext context, SourceSection sourceSection, RubyNode body, ReturnID returnID) {
public CatchForMethodNode(RubyContext context, SourceSection sourceSection, ReturnID returnID, RubyNode body) {
super(context, sourceSection);
this.body = body;
this.returnID = returnID;
this.body = body;
}

@Override
public Object execute(VirtualFrame frame) {
try {
return body.execute(frame);
} catch (ReturnException e) {
returnProfile.enter();
if (matchingReturnProfile.profile(e.getReturnID() == returnID)) {
return e.getValue();
} else {
throw e;
}
} catch (RetryException e) {
CompilerDirectives.transferToInterpreter();
throw new RaiseException(coreLibrary().syntaxError("Invalid retry", this));
retryProfile.enter();
throw new RaiseException(coreLibrary().syntaxErrorInvalidRetry(this));
}
}

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

import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.profiles.BranchProfile;
import com.oracle.truffle.api.source.SourceSection;
@@ -26,6 +25,7 @@ public class CatchForProcNode extends RubyNode {

private final BranchProfile redoProfile = BranchProfile.create();
private final BranchProfile nextProfile = BranchProfile.create();
private final BranchProfile retryProfile = BranchProfile.create();

public CatchForProcNode(RubyContext context, SourceSection sourceSection, RubyNode body) {
super(context, sourceSection);
@@ -45,8 +45,8 @@ public Object execute(VirtualFrame frame) {
nextProfile.enter();
return e.getResult();
} catch (RetryException e) {
CompilerDirectives.transferToInterpreter();
throw new RaiseException(coreLibrary().syntaxError("Invalid retry", this));
retryProfile.enter();
throw new RaiseException(coreLibrary().syntaxErrorInvalidRetry(this));
}
}
}
Original file line number Diff line number Diff line change
@@ -16,9 +16,6 @@
import org.jruby.truffle.language.RubyNode;
import org.jruby.truffle.language.control.NextException;

/**
* Catch a {@code next} jump at the root of a method.
*/
public class CatchNextNode extends RubyNode {

@Child private RubyNode body;
Original file line number Diff line number Diff line change
@@ -9,8 +9,8 @@
*/
package org.jruby.truffle.language.methods;

import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.profiles.BranchProfile;
import com.oracle.truffle.api.source.SourceSection;
import org.jruby.truffle.RubyContext;
import org.jruby.truffle.language.RubyNode;
@@ -21,6 +21,8 @@ public class CatchRetryAsErrorNode extends RubyNode {

@Child private RubyNode body;

private final BranchProfile retryProfile = BranchProfile.create();

public CatchRetryAsErrorNode(RubyContext context, SourceSection sourceSection, RubyNode body) {
super(context, sourceSection);
this.body = body;
@@ -31,8 +33,8 @@ public Object execute(VirtualFrame frame) {
try {
return body.execute(frame);
} catch (RetryException e) {
CompilerDirectives.transferToInterpreter();
throw new RaiseException(coreLibrary().syntaxError("Invalid retry", this));
retryProfile.enter();
throw new RaiseException(coreLibrary().syntaxErrorInvalidRetry(this));
}
}

Original file line number Diff line number Diff line change
@@ -9,21 +9,20 @@
*/
package org.jruby.truffle.language.methods;

import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.profiles.BranchProfile;
import com.oracle.truffle.api.source.SourceSection;
import org.jruby.truffle.RubyContext;
import org.jruby.truffle.language.RubyNode;
import org.jruby.truffle.language.control.RaiseException;
import org.jruby.truffle.language.control.ReturnException;

/**
* Catch a {@code return} jump at the root of a method, and report it as an error.
*/
public class CatchReturnAsErrorNode extends RubyNode {

@Child private RubyNode body;

private final BranchProfile retryProfile = BranchProfile.create();

public CatchReturnAsErrorNode(RubyContext context, SourceSection sourceSection, RubyNode body) {
super(context, sourceSection);
this.body = body;
@@ -34,7 +33,7 @@ public Object execute(VirtualFrame frame) {
try {
return body.execute(frame);
} catch (ReturnException e) {
CompilerDirectives.transferToInterpreter();
retryProfile.enter();
throw new RaiseException(coreLibrary().unexpectedReturn(this));
}
}
Loading