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

Commits on May 19, 2016

  1. [Truffle] Normalize transfer before insert() to not invalidate.

    * insert() will invalidate.
    eregon committed May 19, 2016
    Copy the full SHA
    534cb71 View commit details
  2. Copy the full SHA
    1a7e030 View commit details
Showing with 437 additions and 381 deletions.
  1. +1 −1 truffle/src/main/java/org/jruby/truffle/builtins/YieldingCoreMethodNode.java
  2. +3 −3 truffle/src/main/java/org/jruby/truffle/core/CoreLibrary.java
  3. +5 −1 truffle/src/main/java/org/jruby/truffle/core/MathNodes.java
  4. +0 −1 truffle/src/main/java/org/jruby/truffle/core/ProcessNodes.java
  5. +4 −2 truffle/src/main/java/org/jruby/truffle/core/RaiseIfFrozenNode.java
  6. +1 −2 truffle/src/main/java/org/jruby/truffle/core/VMPrimitiveNodes.java
  7. +11 −8 truffle/src/main/java/org/jruby/truffle/core/array/ArrayNodes.java
  8. +10 −10 truffle/src/main/java/org/jruby/truffle/core/cast/ArrayAttributeCastNode.java
  9. +5 −3 truffle/src/main/java/org/jruby/truffle/core/cast/ArrayCastNode.java
  10. +8 −7 truffle/src/main/java/org/jruby/truffle/core/cast/CmpIntNode.java
  11. +5 −3 truffle/src/main/java/org/jruby/truffle/core/cast/HashCastNode.java
  12. +1 −3 truffle/src/main/java/org/jruby/truffle/core/cast/IntegerCastNode.java
  13. +6 −4 truffle/src/main/java/org/jruby/truffle/core/cast/NameToSymbolOrStringNode.java
  14. +6 −4 truffle/src/main/java/org/jruby/truffle/core/cast/NumericToFloatNode.java
  15. +5 −4 truffle/src/main/java/org/jruby/truffle/core/cast/SplatCastNode.java
  16. +6 −3 truffle/src/main/java/org/jruby/truffle/core/cast/ToAryNode.java
  17. +11 −8 truffle/src/main/java/org/jruby/truffle/core/cast/ToIntNode.java
  18. +5 −4 truffle/src/main/java/org/jruby/truffle/core/cast/ToProcNode.java
  19. +1 −1 truffle/src/main/java/org/jruby/truffle/core/cast/ToSNode.java
  20. +6 −4 truffle/src/main/java/org/jruby/truffle/core/cast/ToStrNode.java
  21. +1 −4 truffle/src/main/java/org/jruby/truffle/core/encoding/EncodingConverterNodes.java
  22. +0 −1 truffle/src/main/java/org/jruby/truffle/core/encoding/EncodingNodes.java
  23. +9 −6 truffle/src/main/java/org/jruby/truffle/core/fiber/FiberNodes.java
  24. +0 −2 truffle/src/main/java/org/jruby/truffle/core/format/read/bytes/ReadBinaryStringNode.java
  25. +12 −5 truffle/src/main/java/org/jruby/truffle/core/format/read/bytes/ReadUTF8CharacterNode.java
  26. +0 −1 truffle/src/main/java/org/jruby/truffle/core/hash/HashNodes.java
  27. +1 −1 truffle/src/main/java/org/jruby/truffle/core/hash/SetNode.java
  28. +51 −48 truffle/src/main/java/org/jruby/truffle/core/kernel/KernelNodes.java
  29. +21 −10 truffle/src/main/java/org/jruby/truffle/core/kernel/TruffleKernelNodes.java
  30. +5 −3 truffle/src/main/java/org/jruby/truffle/core/klass/ClassNodes.java
  31. +3 −6 truffle/src/main/java/org/jruby/truffle/core/method/MethodNodes.java
  32. +5 −2 truffle/src/main/java/org/jruby/truffle/core/method/UnboundMethodNodes.java
  33. +1 −2 truffle/src/main/java/org/jruby/truffle/core/module/ModuleFields.java
  34. +37 −26 truffle/src/main/java/org/jruby/truffle/core/module/ModuleNodes.java
  35. +2 −4 truffle/src/main/java/org/jruby/truffle/core/module/ModuleOperations.java
  36. +0 −1 truffle/src/main/java/org/jruby/truffle/core/numeric/BignumNodes.java
  37. +1 −3 truffle/src/main/java/org/jruby/truffle/core/numeric/FixnumNodes.java
  38. +12 −9 truffle/src/main/java/org/jruby/truffle/core/numeric/FloatNodes.java
  39. +5 −7 truffle/src/main/java/org/jruby/truffle/core/objectspace/ObjectSpaceNodes.java
  40. +5 −3 truffle/src/main/java/org/jruby/truffle/core/queue/QueueNodes.java
  41. +9 −7 truffle/src/main/java/org/jruby/truffle/core/queue/SizedQueueNodes.java
  42. +18 −4 truffle/src/main/java/org/jruby/truffle/core/regexp/InterpolatedRegexpNode.java
  43. +8 −10 truffle/src/main/java/org/jruby/truffle/core/regexp/MatchDataNodes.java
  44. +3 −4 truffle/src/main/java/org/jruby/truffle/core/rope/RopeNodes.java
  45. +4 −2 truffle/src/main/java/org/jruby/truffle/core/rubinius/ByteArrayNodes.java
  46. +5 −3 truffle/src/main/java/org/jruby/truffle/core/rubinius/IOBufferPrimitiveNodes.java
  47. +9 −5 truffle/src/main/java/org/jruby/truffle/core/rubinius/IOPrimitiveNodes.java
  48. +6 −7 truffle/src/main/java/org/jruby/truffle/core/rubinius/RegexpPrimitiveNodes.java
  49. +5 −2 truffle/src/main/java/org/jruby/truffle/core/rubinius/RubiniusLastStringReadNode.java
  50. +2 −3 truffle/src/main/java/org/jruby/truffle/core/rubinius/RubiniusLastStringWriteNode.java
  51. +52 −57 truffle/src/main/java/org/jruby/truffle/core/string/StringNodes.java
  52. +3 −3 truffle/src/main/java/org/jruby/truffle/core/string/StringOperations.java
  53. +9 −5 truffle/src/main/java/org/jruby/truffle/core/symbol/SymbolNodes.java
  54. +3 −3 truffle/src/main/java/org/jruby/truffle/core/symbol/SymbolTable.java
  55. +0 −1 truffle/src/main/java/org/jruby/truffle/core/time/TimeNodes.java
  56. +7 −9 truffle/src/main/java/org/jruby/truffle/extra/TrufflePosixNodes.java
  57. +5 −2 truffle/src/main/java/org/jruby/truffle/language/constants/GetConstantNode.java
  58. +1 −8 truffle/src/main/java/org/jruby/truffle/language/constants/LookupConstantNode.java
  59. +0 −2 truffle/src/main/java/org/jruby/truffle/language/constants/LookupConstantWithLexicalScopeNode.java
  60. +2 −13 truffle/src/main/java/org/jruby/truffle/language/dispatch/RubyCallNode.java
  61. +5 −1 truffle/src/main/java/org/jruby/truffle/language/methods/ExceptionTranslatingNode.java
  62. +1 −1 truffle/src/main/java/org/jruby/truffle/language/objects/DefineClassNode.java
  63. +3 −1 truffle/src/main/java/org/jruby/truffle/language/objects/ObjectGraph.java
  64. +4 −2 truffle/src/main/java/org/jruby/truffle/language/supercall/SuperCallNode.java
  65. +1 −4 truffle/src/main/java/org/jruby/truffle/language/supercall/ZSuperOutsideMethodNode.java
  66. +0 −1 truffle/src/main/java/org/jruby/truffle/stdlib/bigdecimal/BigDecimalNodes.java
  67. +1 −1 truffle/src/main/java/org/jruby/truffle/stdlib/psych/PsychParserNodes.java
Original file line number Diff line number Diff line change
@@ -34,7 +34,7 @@ public YieldingCoreMethodNode(RubyContext context, SourceSection sourceSection)

private boolean booleanCast(VirtualFrame frame, Object value) {
if (booleanCastNode == null) {
CompilerDirectives.transferToInterpreterAndInvalidate();
CompilerDirectives.transferToInterpreter();
booleanCastNode = insert(BooleanCastNodeGen.create(getContext(), getSourceSection(), null));
}
return booleanCastNode.executeBoolean(frame, value);
6 changes: 3 additions & 3 deletions truffle/src/main/java/org/jruby/truffle/core/CoreLibrary.java
Original file line number Diff line number Diff line change
@@ -11,6 +11,7 @@

import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.CompilerDirectives.CompilationFinal;
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.api.TruffleOptions;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.interop.java.JavaInterop;
@@ -110,7 +111,6 @@
import org.jruby.truffle.stdlib.psych.PsychParserNodesFactory;
import org.jruby.truffle.stdlib.psych.YAMLEncoding;
import org.jruby.util.cli.OutputStrings;

import java.io.File;
import java.io.IOException;
import java.util.HashMap;
@@ -985,6 +985,7 @@ public void defineConstant(int encodingListIndex, String constName) {
});
}

@TruffleBoundary
public DynamicObject getMetaClass(Object object) {
if (object instanceof DynamicObject) {
return Layouts.BASIC_OBJECT.getMetaClass(((DynamicObject) object));
@@ -1009,11 +1010,11 @@ public DynamicObject getMetaClass(Object object) {
} else if (object == null) {
throw new RuntimeException("Can't get metaclass for null");
} else {
CompilerDirectives.transferToInterpreter();
throw new UnsupportedOperationException(String.format("Don't know how to get the metaclass for %s", object.getClass()));
}
}

@TruffleBoundary
public DynamicObject getLogicalClass(Object object) {
if (object instanceof DynamicObject) {
return Layouts.BASIC_OBJECT.getLogicalClass(((DynamicObject) object));
@@ -1038,7 +1039,6 @@ public DynamicObject getLogicalClass(Object object) {
} else if (object == null) {
throw new RuntimeException();
} else {
CompilerDirectives.transferToInterpreter();
throw new UnsupportedOperationException(String.format("Don't know how to get the logical class for %s", object.getClass()));
}
}
6 changes: 5 additions & 1 deletion truffle/src/main/java/org/jruby/truffle/core/MathNodes.java
Original file line number Diff line number Diff line change
@@ -10,10 +10,12 @@
package org.jruby.truffle.core;

import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.dsl.Cached;
import com.oracle.truffle.api.dsl.Fallback;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.profiles.BranchProfile;
import com.oracle.truffle.api.source.SourceSection;
import org.jruby.RubyMath;
import org.jruby.truffle.Layouts;
@@ -264,6 +266,8 @@ protected double doFunction(double a) {
@CoreMethod(names = "frexp", isModuleFunction = true, required = 1)
public abstract static class FrExpNode extends CoreMethodArrayArgumentsNode {

private final BranchProfile errorProfile = BranchProfile.create();

@Child private IsANode isANode;
@Child private CallDispatchHeadNode floatNode;

@@ -318,7 +322,7 @@ public DynamicObject frexp(VirtualFrame frame, Object a) {
if (isANode.executeIsA(a, coreLibrary().getNumericClass())) {
return frexp(floatNode.callFloat(frame, a, "to_f", null));
} else {
CompilerDirectives.transferToInterpreter();
errorProfile.enter();
throw new RaiseException(coreExceptions().typeErrorCantConvertInto(a, "Float", this));
}
}
Original file line number Diff line number Diff line change
@@ -92,7 +92,6 @@ private Object clock_gettime_clock_id(int clock_id, DynamicObject unit) {
TimeSpec timeSpec = new TimeSpec(jnr.ffi.Runtime.getRuntime(libCClockGetTime));
int r = libCClockGetTime.clock_gettime(clock_id, timeSpec);
if (r != 0) {
CompilerDirectives.transferToInterpreter();
throw new RaiseException(coreExceptions().systemCallError("clock_gettime failed: " + r, this));
}
long nanos = timeSpec.getTVsec() * 1_000_000_000 + timeSpec.getTVnsec();
Original file line number Diff line number Diff line change
@@ -10,15 +10,17 @@

package org.jruby.truffle.core;

import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.profiles.BranchProfile;
import org.jruby.truffle.language.RubyNode;
import org.jruby.truffle.language.control.RaiseException;
import org.jruby.truffle.language.objects.IsFrozenNode;
import org.jruby.truffle.language.objects.IsFrozenNodeGen;

public class RaiseIfFrozenNode extends RubyNode {

private final BranchProfile errorProfile = BranchProfile.create();

@Child private RubyNode child;
@Child private IsFrozenNode isFrozenNode;

@@ -33,7 +35,7 @@ public Object execute(VirtualFrame frame) {
Object result = child.execute(frame);

if (isFrozenNode.executeIsFrozen(result)) {
CompilerDirectives.transferToInterpreter();
errorProfile.enter();
throw new RaiseException(coreExceptions().frozenError(result, this));
}

Original file line number Diff line number Diff line change
@@ -103,7 +103,7 @@ public CatchNode(RubyContext context, SourceSection sourceSection) {

private boolean areSame(VirtualFrame frame, Object left, Object right) {
if (referenceEqualNode == null) {
CompilerDirectives.transferToInterpreterAndInvalidate();
CompilerDirectives.transferToInterpreter();
referenceEqualNode = insert(BasicObjectNodesFactory.ReferenceEqualNodeFactory.create(null));
}
return referenceEqualNode.executeReferenceEqual(frame, left, right);
@@ -203,7 +203,6 @@ public DynamicObject vmGetUserHome(DynamicObject username) {
// TODO BJF 30-APR-2015 Review the more robust getHomeDirectoryPath implementation
final Passwd passwd = posix().getpwnam(username.toString());
if (passwd == null) {
CompilerDirectives.transferToInterpreter();
throw new RaiseException(coreExceptions().argumentError("user " + username.toString() + " does not exist", this));
}
return createString(StringOperations.encodeRope(passwd.getHome(), UTF8Encoding.INSTANCE));
19 changes: 11 additions & 8 deletions truffle/src/main/java/org/jruby/truffle/core/array/ArrayNodes.java
Original file line number Diff line number Diff line change
@@ -197,19 +197,21 @@ public MulNode(RubyContext context, SourceSection sourceSection) {
protected abstract Object executeMul(VirtualFrame frame, DynamicObject array, int count);

@Specialization(guards = "isNullArray(array)")
public DynamicObject mulEmpty(DynamicObject array, int count) {
public DynamicObject mulEmpty(DynamicObject array, int count,
@Cached("create()") BranchProfile errorProfile) {
if (count < 0) {
CompilerDirectives.transferToInterpreter();
errorProfile.enter();
throw new RaiseException(coreExceptions().argumentError("negative argument", this));
}
return allocateObjectNode.allocate(Layouts.BASIC_OBJECT.getLogicalClass(array), null, 0);
}

@Specialization(guards = { "strategy.matches(array)", "!isNullArray(array)" }, limit = "ARRAY_STRATEGIES")
public DynamicObject mulIntegerFixnum(DynamicObject array, int count,
@Cached("of(array)") ArrayStrategy strategy) {
public DynamicObject mulOther(DynamicObject array, int count,
@Cached("of(array)") ArrayStrategy strategy,
@Cached("create()") BranchProfile errorProfile) {
if (count < 0) {
CompilerDirectives.transferToInterpreter();
errorProfile.enter();
throw new RaiseException(coreExceptions().argumentError("negative argument", this));
}

@@ -483,12 +485,13 @@ public Object setStartLengthNotInt(VirtualFrame frame, DynamicObject array, Obje
@Specialization(guards = "isIntegerFixnumRange(range)")
public Object setRange(VirtualFrame frame, DynamicObject array, DynamicObject range, Object value, NotProvided unused,
@Cached("createBinaryProfile()") ConditionProfile negativeBeginProfile,
@Cached("createBinaryProfile()") ConditionProfile negativeEndProfile) {
@Cached("createBinaryProfile()") ConditionProfile negativeEndProfile,
@Cached("create()") BranchProfile errorProfile) {
final int size = getSize(array);
final int begin = Layouts.INTEGER_FIXNUM_RANGE.getBegin(range);
final int start = ArrayOperations.normalizeIndex(size, begin, negativeBeginProfile);
if (start < 0) {
CompilerDirectives.transferToInterpreter();
errorProfile.enter();
throw new RaiseException(coreExceptions().rangeError(range, this));
}
final int end = ArrayOperations.normalizeIndex(size, Layouts.INTEGER_FIXNUM_RANGE.getEnd(range), negativeEndProfile);
@@ -1625,7 +1628,7 @@ public abstract static class PopNode extends ArrayCoreMethodNode {
@Specialization
public Object pop(DynamicObject array, NotProvided n) {
if (popOneNode == null) {
CompilerDirectives.transferToInterpreterAndInvalidate();
CompilerDirectives.transferToInterpreter();
popOneNode = insert(ArrayPopOneNodeGen.create(getContext(), getEncapsulatingSourceSection(), null));
}

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

import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.api.dsl.Cached;
import com.oracle.truffle.api.dsl.Fallback;
import com.oracle.truffle.api.dsl.ImportStatic;
@@ -50,8 +50,7 @@ public int doLongFixnum(long value) {

@Specialization(guards = "!inBounds(value)")
public int doLongFixnumOutOfBounds(long value) {
CompilerDirectives.transferToInterpreter();
throw new RaiseException(coreExceptions().argumentError(String.format("%s out of int range", indexName), this));
throw new RaiseException(coreExceptions().argumentError(formatOutOfRangeErrorMessage(), this));
}

@Specialization(guards = "inBounds(value)")
@@ -61,14 +60,12 @@ public int doDouble(double value) {

@Specialization(guards = "!inBounds(value)")
public int doDoubleOutOfBounds(double value) {
CompilerDirectives.transferToInterpreter();
throw new RaiseException(coreExceptions().argumentError(String.format("%s out of int range", indexName), this));
throw new RaiseException(coreExceptions().argumentError(formatOutOfRangeErrorMessage(), this));
}

@Specialization(guards = "isRubyBignum(value)")
public DynamicObject doBignum(DynamicObject value) {
CompilerDirectives.transferToInterpreter();
throw new RaiseException(coreExceptions().argumentError(String.format("%s out of int range", indexName), this));
throw new RaiseException(coreExceptions().argumentError(formatOutOfRangeErrorMessage(), this));
}


@@ -90,9 +87,12 @@ public Object coerce(VirtualFrame frame, DynamicObject value,

@Fallback
public int doBasicObject(Object object) {
CompilerDirectives.transferToInterpreter();
throw new RaiseException(coreExceptions().
typeErrorIsNotA(object.toString(), "Fixnum (fitting in int)", this));
throw new RaiseException(coreExceptions().typeErrorIsNotA(object.toString(), "Fixnum (fitting in int)", this));
}

@TruffleBoundary
private String formatOutOfRangeErrorMessage() {
return String.format("%s out of int range", indexName);
}

protected static boolean inBounds(long value) {
Original file line number Diff line number Diff line change
@@ -9,11 +9,12 @@
*/
package org.jruby.truffle.core.cast;

import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.dsl.Cached;
import com.oracle.truffle.api.dsl.NodeChild;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.profiles.BranchProfile;
import com.oracle.truffle.api.source.SourceSection;
import org.jruby.truffle.Layouts;
import org.jruby.truffle.RubyContext;
@@ -96,7 +97,8 @@ public Object cast(Object nil) {
}

@Specialization(guards = {"!isNil(object)", "!isRubyBignum(object)", "!isRubyArray(object)"})
public Object cast(VirtualFrame frame, DynamicObject object) {
public Object cast(VirtualFrame frame, DynamicObject object,
@Cached("create()") BranchProfile errorProfile) {
final Object result = toArrayNode.call(frame, object, "to_ary", null);

if (result == nil()) {
@@ -108,7 +110,7 @@ public Object cast(VirtualFrame frame, DynamicObject object) {
}

if (!RubyGuards.isRubyArray(result)) {
CompilerDirectives.transferToInterpreter();
errorProfile.enter();
throw new RaiseException(coreExceptions().typeErrorCantConvertTo(object, "Array", "to_ary", result, this));
}

Original file line number Diff line number Diff line change
@@ -86,15 +86,16 @@ public int cmpBignum(DynamicObject value, Object receiver, Object other) {
return Layouts.BIGNUM.getValue(value).signum();
}

@TruffleBoundary
@Specialization(guards = "isNil(nil)")
public int cmpNil(Object nil, Object receiver, Object other) {
throw new RaiseException(
coreExceptions().argumentError(
String.format("comparison of %s with %s failed",
Layouts.MODULE.getFields(coreLibrary().getLogicalClass(receiver)).getName(),
Layouts.MODULE.getFields(coreLibrary().getLogicalClass(other)).getName()), this)
);
throw new RaiseException(coreExceptions().argumentError(formatMessage(receiver, other), this));
}

@TruffleBoundary
private String formatMessage(Object receiver, Object other) {
return String.format("comparison of %s with %s failed",
Layouts.MODULE.getFields(coreLibrary().getLogicalClass(receiver)).getName(),
Layouts.MODULE.getFields(coreLibrary().getLogicalClass(other)).getName());
}

@Specialization(guards = {
Original file line number Diff line number Diff line change
@@ -9,11 +9,12 @@
*/
package org.jruby.truffle.core.cast;

import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.dsl.Cached;
import com.oracle.truffle.api.dsl.NodeChild;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.profiles.BranchProfile;
import com.oracle.truffle.api.source.SourceSection;
import org.jruby.truffle.RubyContext;
import org.jruby.truffle.language.RubyGuards;
@@ -74,15 +75,16 @@ public DynamicObject castHash(DynamicObject hash) {
}

@Specialization(guards = {"!isNil(object)", "!isRubyBignum(object)", "!isRubyHash(object)"})
public Object cast(VirtualFrame frame, DynamicObject object) {
public Object cast(VirtualFrame frame, DynamicObject object,
@Cached("create()") BranchProfile errorProfile) {
final Object result = toHashNode.call(frame, object, "to_hash", null);

if (result == DispatchNode.MISSING) {
return nil();
}

if (!RubyGuards.isRubyHash(result)) {
CompilerDirectives.transferToInterpreter();
errorProfile.enter();
throw new RaiseException(coreExceptions().typeErrorCantConvertTo(object, "Hash", "to_hash", result, this));
}

Original file line number Diff line number Diff line change
@@ -48,9 +48,7 @@ public int doLongFixnum(long value) {

@Fallback
public int doBasicObject(Object object) {
CompilerDirectives.transferToInterpreter();
throw new RaiseException(coreExceptions().
typeErrorIsNotA(object.toString(), "Fixnum (fitting in int)", this));
throw new RaiseException(coreExceptions().typeErrorIsNotA(object.toString(), "Fixnum (fitting in int)", this));
}

}
Original file line number Diff line number Diff line change
@@ -10,11 +10,12 @@

package org.jruby.truffle.core.cast;

import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.dsl.Cached;
import com.oracle.truffle.api.dsl.NodeChild;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.profiles.BranchProfile;
import com.oracle.truffle.api.source.SourceSection;
import org.jruby.truffle.Layouts;
import org.jruby.truffle.RubyContext;
@@ -51,13 +52,14 @@ public DynamicObject coerceRubyString(DynamicObject string) {
}

@Specialization(guards = { "!isRubySymbol(object)", "!isRubyString(object)" })
public DynamicObject coerceObject(VirtualFrame frame, Object object) {
public DynamicObject coerceObject(VirtualFrame frame, Object object,
@Cached("create()") BranchProfile errorProfile) {
final Object coerced;
try {
coerced = toStr.call(frame, object, "to_str", null);
} catch (RaiseException e) {
errorProfile.enter();
if (Layouts.BASIC_OBJECT.getLogicalClass(e.getException()) == coreLibrary().getNoMethodErrorClass()) {
CompilerDirectives.transferToInterpreter();
throw new RaiseException(coreExceptions().typeErrorNoImplicitConversion(object, "String", this));
} else {
throw e;
@@ -67,7 +69,7 @@ public DynamicObject coerceObject(VirtualFrame frame, Object object) {
if (RubyGuards.isRubyString(coerced)) {
return (DynamicObject) coerced;
} else {
CompilerDirectives.transferToInterpreter();
errorProfile.enter();
throw new RaiseException(coreExceptions().typeErrorBadCoercion(object, "String", "to_str", coerced, this));
}
}
Loading