Skip to content

Commit 5c1e9d1

Browse files
committed
Revert "DataflowError.withDefaultTrace has BranchProfile as parameter"
This reverts commit baeddd0.
1 parent 0569585 commit 5c1e9d1

File tree

12 files changed

+26
-68
lines changed

12 files changed

+26
-68
lines changed

engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/error/ThrowErrorNode.java

+1-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import com.oracle.truffle.api.frame.VirtualFrame;
44
import com.oracle.truffle.api.nodes.Node;
5-
import com.oracle.truffle.api.profiles.BranchProfile;
65
import org.enso.interpreter.dsl.BuiltinMethod;
76
import org.enso.interpreter.runtime.error.DataflowError;
87
import org.enso.interpreter.runtime.state.State;
@@ -13,9 +12,7 @@
1312
description = "Returns a new value error with given payload.",
1413
inlineable = true)
1514
public class ThrowErrorNode extends Node {
16-
private final BranchProfile attachFullStackTraceProfile = BranchProfile.create();
17-
1815
public Object execute(VirtualFrame giveMeAStackFrame, State state, Object payload) {
19-
return DataflowError.withDefaultTrace(state, payload, this, attachFullStackTraceProfile);
16+
return DataflowError.withDefaultTrace(state, payload, this);
2017
}
2118
}

engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/number/decimal/FloatNode.java

+1-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import com.oracle.truffle.api.interop.TruffleObject;
55
import com.oracle.truffle.api.interop.UnsupportedMessageException;
66
import com.oracle.truffle.api.nodes.Node;
7-
import com.oracle.truffle.api.profiles.BranchProfile;
87
import org.enso.interpreter.node.expression.builtin.number.utils.ToEnsoNumberNode;
98
import org.enso.interpreter.runtime.EnsoContext;
109
import org.enso.interpreter.runtime.error.DataflowError;
@@ -13,7 +12,6 @@
1312

1413
abstract class FloatNode extends Node {
1514
static final String INTEROP_LIMIT = "3";
16-
private final BranchProfile attachFullStackTraceProfile = BranchProfile.create();
1715

1816
final boolean isForeignNumber(InteropLibrary iop, TruffleObject obj) {
1917
if (obj instanceof EnsoBigInteger) {
@@ -50,6 +48,6 @@ final PanicException panicOtherwise(double self, Object that) {
5048
final DataflowError incomparableError(Object self, Object that) {
5149
var builtins = EnsoContext.get(this).getBuiltins();
5250
var incomparableErr = builtins.error().makeIncomparableValues(self, that);
53-
return DataflowError.withDefaultTrace(incomparableErr, this, attachFullStackTraceProfile);
51+
return DataflowError.withDefaultTrace(incomparableErr, this);
5452
}
5553
}

engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/number/integer/BitShiftNode.java

+8-24
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,13 @@
22

33
import com.oracle.truffle.api.dsl.Cached;
44
import com.oracle.truffle.api.dsl.Cached.Exclusive;
5-
import com.oracle.truffle.api.dsl.Cached.Shared;
65
import com.oracle.truffle.api.dsl.Fallback;
76
import com.oracle.truffle.api.dsl.ImportStatic;
87
import com.oracle.truffle.api.dsl.NeverDefault;
98
import com.oracle.truffle.api.dsl.Specialization;
109
import com.oracle.truffle.api.interop.InteropLibrary;
1110
import com.oracle.truffle.api.interop.TruffleObject;
1211
import com.oracle.truffle.api.library.CachedLibrary;
13-
import com.oracle.truffle.api.profiles.BranchProfile;
1412
import com.oracle.truffle.api.profiles.CountingConditionProfile;
1513
import org.enso.interpreter.dsl.BuiltinMethod;
1614
import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps;
@@ -42,17 +40,14 @@ long doLongShiftLeft(long self, long that) {
4240
}
4341

4442
@Specialization(guards = "that >= 0", replaces = "doLongShiftLeft")
45-
Object doLongShiftLeftExplicit(
46-
long self, long that, @Shared @Cached BranchProfile attachFullStackTraceProfile) {
43+
Object doLongShiftLeftExplicit(long self, long that) {
4744
if (canShiftLeftInLongProfile.profile(canShiftLeftInLong(self, that))) {
4845
return doLongShiftLeft(self, that);
4946
} else if (positiveFitsInInt.profile(BigIntegerOps.fitsInInt(that))) {
5047
return toEnsoNumberNode.execute(BigIntegerOps.bitShiftLeft(self, (int) that));
5148
} else {
5249
return DataflowError.withDefaultTrace(
53-
EnsoContext.get(this).getBuiltins().error().getShiftAmountTooLargeError(),
54-
this,
55-
attachFullStackTraceProfile);
50+
EnsoContext.get(this).getBuiltins().error().getShiftAmountTooLargeError(), this);
5651
}
5752
}
5853

@@ -75,16 +70,13 @@ long doLongShiftRightExplicit(long self, long that) {
7570
}
7671

7772
@Specialization
78-
Object doBigInteger(
79-
long self, EnsoBigInteger that, @Cached BranchProfile attachFullStackTraceProfile) {
73+
Object doBigInteger(long self, EnsoBigInteger that) {
8074
if (!BigIntegerOps.nonNegative(that.getValue())) {
8175
return self >= 0 ? 0L : -1L;
8276
} else {
8377
// Note [Well-Formed BigIntegers]
8478
return DataflowError.withDefaultTrace(
85-
EnsoContext.get(this).getBuiltins().error().getShiftAmountTooLargeError(),
86-
this,
87-
attachFullStackTraceProfile);
79+
EnsoContext.get(this).getBuiltins().error().getShiftAmountTooLargeError(), this);
8880
}
8981
}
9082

@@ -97,15 +89,12 @@ EnsoBigInteger doBigIntShiftLeft(EnsoBigInteger self, long that) {
9789
Object doBigIntShiftLeftExplicit(
9890
EnsoBigInteger self,
9991
long that,
100-
@Exclusive @Cached CountingConditionProfile fitsInIntProfileLeftShift,
101-
@Cached BranchProfile attachFullStackTraceProfile) {
92+
@Exclusive @Cached CountingConditionProfile fitsInIntProfileLeftShift) {
10293
if (fitsInIntProfileLeftShift.profile(BigIntegerOps.fitsInInt(that))) {
10394
return doBigIntShiftLeft(self, that);
10495
} else {
10596
return DataflowError.withDefaultTrace(
106-
EnsoContext.get(this).getBuiltins().error().getShiftAmountTooLargeError(),
107-
this,
108-
attachFullStackTraceProfile);
97+
EnsoContext.get(this).getBuiltins().error().getShiftAmountTooLargeError(), this);
10998
}
11099
}
111100

@@ -127,17 +116,12 @@ Object doBigIntShiftRightExplicit(
127116
}
128117

129118
@Specialization
130-
Object doBigIntThat(
131-
EnsoBigInteger self,
132-
EnsoBigInteger that,
133-
@Shared @Cached BranchProfile attachFullStackTraceProfile) {
119+
Object doBigIntThat(EnsoBigInteger self, EnsoBigInteger that) {
134120
if (!BigIntegerOps.nonNegative(that.getValue())) {
135121
return BigIntegerOps.nonNegative(self.getValue()) ? 0L : -1L;
136122
} else {
137123
return DataflowError.withDefaultTrace(
138-
EnsoContext.get(this).getBuiltins().error().getShiftAmountTooLargeError(),
139-
this,
140-
attachFullStackTraceProfile);
124+
EnsoContext.get(this).getBuiltins().error().getShiftAmountTooLargeError(), this);
141125
}
142126
}
143127

engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/number/integer/GreaterNode.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import com.oracle.truffle.api.interop.InteropLibrary;
77
import com.oracle.truffle.api.interop.TruffleObject;
88
import com.oracle.truffle.api.library.CachedLibrary;
9-
import com.oracle.truffle.api.profiles.BranchProfile;
109
import org.enso.interpreter.dsl.BuiltinMethod;
1110
import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps;
1211
import org.enso.interpreter.runtime.EnsoContext;
@@ -62,9 +61,9 @@ Object doInterop(
6261
}
6362

6463
@Fallback
65-
Object doOther(Object self, Object that, @Cached BranchProfile attachFullStackTraceProfile) {
64+
Object doOther(Object self, Object that) {
6665
var builtins = EnsoContext.get(this).getBuiltins();
6766
var incomparableValsErr = builtins.error().makeIncomparableValues(self, that);
68-
return DataflowError.withDefaultTrace(incomparableValsErr, this, attachFullStackTraceProfile);
67+
return DataflowError.withDefaultTrace(incomparableValsErr, this);
6968
}
7069
}

engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/number/integer/GreaterOrEqualNode.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import com.oracle.truffle.api.interop.InteropLibrary;
77
import com.oracle.truffle.api.interop.TruffleObject;
88
import com.oracle.truffle.api.library.CachedLibrary;
9-
import com.oracle.truffle.api.profiles.BranchProfile;
109
import org.enso.interpreter.dsl.BuiltinMethod;
1110
import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps;
1211
import org.enso.interpreter.runtime.EnsoContext;
@@ -62,9 +61,9 @@ Object doInterop(
6261
}
6362

6463
@Fallback
65-
Object doOther(Object self, Object that, @Cached BranchProfile attachFullStackTraceProfile) {
64+
Object doOther(Object self, Object that) {
6665
var builtins = EnsoContext.get(this).getBuiltins();
6766
var incomparableValsErr = builtins.error().makeIncomparableValues(self, that);
68-
return DataflowError.withDefaultTrace(incomparableValsErr, this, attachFullStackTraceProfile);
67+
return DataflowError.withDefaultTrace(incomparableValsErr, this);
6968
}
7069
}

engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/number/integer/LessNode.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import com.oracle.truffle.api.interop.InteropLibrary;
77
import com.oracle.truffle.api.interop.TruffleObject;
88
import com.oracle.truffle.api.library.CachedLibrary;
9-
import com.oracle.truffle.api.profiles.BranchProfile;
109
import org.enso.interpreter.dsl.BuiltinMethod;
1110
import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps;
1211
import org.enso.interpreter.runtime.EnsoContext;
@@ -62,9 +61,9 @@ Object doInterop(
6261
}
6362

6463
@Fallback
65-
Object doOther(Object self, Object that, @Cached BranchProfile attachFullStackTraceProfile) {
64+
Object doOther(Object self, Object that) {
6665
var builtins = EnsoContext.get(this).getBuiltins();
6766
var incomparableValsErr = builtins.error().makeIncomparableValues(self, that);
68-
return DataflowError.withDefaultTrace(incomparableValsErr, this, attachFullStackTraceProfile);
67+
return DataflowError.withDefaultTrace(incomparableValsErr, this);
6968
}
7069
}

engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/number/integer/LessOrEqualNode.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import com.oracle.truffle.api.interop.InteropLibrary;
77
import com.oracle.truffle.api.interop.TruffleObject;
88
import com.oracle.truffle.api.library.CachedLibrary;
9-
import com.oracle.truffle.api.profiles.BranchProfile;
109
import org.enso.interpreter.dsl.BuiltinMethod;
1110
import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps;
1211
import org.enso.interpreter.runtime.EnsoContext;
@@ -63,9 +62,9 @@ Object doInterop(
6362
}
6463

6564
@Fallback
66-
Object doOther(Object self, Object that, @Cached BranchProfile attachFullStackTraceProfile) {
65+
Object doOther(Object self, Object that) {
6766
var builtins = EnsoContext.get(this).getBuiltins();
6867
var incomparableValsErr = builtins.error().makeIncomparableValues(self, that);
69-
return DataflowError.withDefaultTrace(incomparableValsErr, this, attachFullStackTraceProfile);
68+
return DataflowError.withDefaultTrace(incomparableValsErr, this);
7069
}
7170
}

engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/number/integer/ModNode.java

+2-5
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import com.oracle.truffle.api.interop.InteropLibrary;
88
import com.oracle.truffle.api.interop.TruffleObject;
99
import com.oracle.truffle.api.library.CachedLibrary;
10-
import com.oracle.truffle.api.profiles.BranchProfile;
1110
import java.math.BigInteger;
1211
import org.enso.interpreter.dsl.BuiltinMethod;
1312
import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps;
@@ -54,14 +53,12 @@ Object doBigInteger(long self, EnsoBigInteger that) {
5453
}
5554

5655
@Specialization
57-
Object doLong(EnsoBigInteger self, long that, @Cached BranchProfile attachFullStackTraceProfile) {
56+
Object doLong(EnsoBigInteger self, long that) {
5857
try {
5958
return toEnsoNumberNode.execute(BigIntegerOps.modulo(self.getValue(), that));
6059
} catch (ArithmeticException e) {
6160
return DataflowError.withDefaultTrace(
62-
EnsoContext.get(this).getBuiltins().error().getDivideByZeroError(),
63-
this,
64-
attachFullStackTraceProfile);
61+
EnsoContext.get(this).getBuiltins().error().getDivideByZeroError(), this);
6562
}
6663
}
6764

engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/number/integer/ParseIntegerNode.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ public final class ParseIntegerNode extends IntegerNode {
2020
@Child ToJavaStringNode toJavaString = ToJavaStringNode.build();
2121
private final BranchProfile noEx1 = BranchProfile.create();
2222
private final BranchProfile noEx2 = BranchProfile.create();
23-
private final BranchProfile attachFullStackTraceProfile = BranchProfile.create();
2423

2524
Object execute(Text value, long radix) {
2625
var r = Math.toIntExact(radix);
@@ -37,7 +36,7 @@ Object execute(Text value, long radix) {
3736
noEx2.enter();
3837
var errors = EnsoContext.get(this).getBuiltins().error();
3938
var err = errors.makeNumberParseError(ex.getMessage());
40-
return DataflowError.withDefaultTrace(err, this, attachFullStackTraceProfile);
39+
return DataflowError.withDefaultTrace(err, this);
4140
}
4241
}
4342
}

engine/runtime/src/main/java/org/enso/interpreter/node/expression/constant/LazyObjectNode.java

+1-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import com.oracle.truffle.api.frame.VirtualFrame;
44
import com.oracle.truffle.api.interop.TruffleObject;
55
import com.oracle.truffle.api.nodes.NodeInfo;
6-
import com.oracle.truffle.api.profiles.BranchProfile;
76
import java.util.function.Supplier;
87
import org.enso.interpreter.node.ExpressionNode;
98
import org.enso.interpreter.runtime.data.text.Text;
@@ -17,7 +16,6 @@ public final class LazyObjectNode extends ExpressionNode {
1716

1817
private final String error;
1918
private final CachingSupplier<? extends Object> supply;
20-
private final BranchProfile attachFullStackTraceProfile = BranchProfile.create();
2119

2220
private LazyObjectNode(String error, Supplier<? extends Object> supply) {
2321
this.error = error;
@@ -41,6 +39,6 @@ public Object executeGeneric(VirtualFrame frame) {
4139
if (result instanceof TruffleObject) {
4240
return result;
4341
}
44-
return DataflowError.withDefaultTrace(Text.create(error), this, attachFullStackTraceProfile);
42+
return DataflowError.withDefaultTrace(Text.create(error), this);
4543
}
4644
}

engine/runtime/src/main/java/org/enso/interpreter/runtime/data/hash/HashMapRemoveNode.java

+2-4
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
import com.oracle.truffle.api.interop.UnsupportedMessageException;
1414
import com.oracle.truffle.api.library.CachedLibrary;
1515
import com.oracle.truffle.api.nodes.Node;
16-
import com.oracle.truffle.api.profiles.BranchProfile;
1716
import org.enso.interpreter.dsl.BuiltinMethod;
1817
import org.enso.interpreter.node.expression.builtin.meta.EqualsNode;
1918
import org.enso.interpreter.node.expression.builtin.meta.HashCodeNode;
@@ -40,13 +39,12 @@ EnsoHashMap removeFromEnsoMap(
4039
EnsoHashMap ensoMap,
4140
Object key,
4241
@Shared("hash") @Cached HashCodeNode hashCodeNode,
43-
@Shared("equals") @Cached EqualsNode equalsNode,
44-
@Cached BranchProfile attachFullStackTraceProfile) {
42+
@Shared("equals") @Cached EqualsNode equalsNode) {
4543
var mapBuilder = ensoMap.getMapBuilder(frame, false, hashCodeNode, equalsNode);
4644
if (mapBuilder.remove(frame, key, hashCodeNode, equalsNode)) {
4745
return mapBuilder.build();
4846
} else {
49-
throw DataflowError.withDefaultTrace("No such key", null, attachFullStackTraceProfile);
47+
throw DataflowError.withDefaultTrace("No such key", null);
5048
}
5149
}
5250

engine/runtime/src/main/java/org/enso/interpreter/runtime/error/DataflowError.java

+2-11
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
import com.oracle.truffle.api.library.ExportLibrary;
1616
import com.oracle.truffle.api.library.ExportMessage;
1717
import com.oracle.truffle.api.nodes.Node;
18-
import com.oracle.truffle.api.profiles.BranchProfile;
1918
import java.util.Objects;
2019
import org.enso.interpreter.node.callable.IndirectInvokeMethodNode;
2120
import org.enso.interpreter.node.expression.builtin.text.util.TypeToDisplayTextNode;
@@ -50,19 +49,16 @@ public final class DataflowError extends AbstractTruffleException implements Ens
5049
*
5150
* @param payload the user-provided value carried by the error
5251
* @param location the node in which the error was created
53-
* @param attachFullStackTraceProfile
5452
* @return a new dataflow error
5553
*/
56-
public static DataflowError withDefaultTrace(
57-
State state, Object payload, Node location, BranchProfile attachFullStackTraceProfile) {
54+
public static DataflowError withDefaultTrace(State state, Object payload, Node location) {
5855
assert payload != null;
5956
boolean attachFullStackTrace =
6057
state == null
6158
|| EnsoContext.get(location)
6259
.getExecutionEnvironment()
6360
.hasContextEnabled("Dataflow_Stack_Trace");
6461
if (attachFullStackTrace) {
65-
attachFullStackTraceProfile.enter();
6662
var result = new DataflowError(payload, UNLIMITED_STACK_TRACE, location);
6763
TruffleStackTrace.fillIn(result);
6864
return result;
@@ -72,13 +68,8 @@ public static DataflowError withDefaultTrace(
7268
}
7369
}
7470

75-
public static DataflowError withDefaultTrace(
76-
Object payload, Node location, BranchProfile attachFullStackTraceProfile) {
77-
return withDefaultTrace(null, payload, location, attachFullStackTraceProfile);
78-
}
79-
8071
public static DataflowError withDefaultTrace(Object payload, Node location) {
81-
return withDefaultTrace(null, payload, location, BranchProfile.getUncached());
72+
return withDefaultTrace(null, payload, location);
8273
}
8374

8475
/**

0 commit comments

Comments
 (0)