Skip to content

Commit 6cefdca

Browse files
committed
removed not necessary brach profiles before "throw raise()"
1 parent ef73bd5 commit 6cefdca

File tree

8 files changed

+10
-42
lines changed

8 files changed

+10
-42
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/ChainBuiltins.java

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -176,35 +176,28 @@ Object setState(VirtualFrame frame, PChain self, Object state,
176176
@Cached LenNode lenNode,
177177
@Cached GetItemNode getItemNode,
178178
@Cached PyObjectLookupAttr getAttrNode,
179-
@Cached BranchProfile isNotTupleProfile,
180-
@Cached BranchProfile wrongLenProfile,
181-
@Cached BranchProfile len2Profile,
182-
@Cached BranchProfile sourceIteratorProfile,
183-
@Cached BranchProfile activeIteratorProfile) {
179+
@Cached BranchProfile len2Profile) {
184180
if (!(state instanceof PTuple)) {
185-
isNotTupleProfile.enter();
186181
throw raise(TypeError, IS_NOT_A, "state", "a length 1 or 2 tuple");
187182
}
188183
int len = (int) lenNode.execute(frame, state);
189184
if (len < 1 || len > 2) {
190-
wrongLenProfile.enter();
191185
throw raise(TypeError, IS_NOT_A, "state", "a length 1 or 2 tuple");
192186
}
193187
Object source = getItemNode.execute(frame, state, 0);
194-
checkIterator(frame, getAttrNode, source, sourceIteratorProfile);
188+
checkIterator(frame, getAttrNode, source);
195189
self.setSource(source);
196190
if (len == 2) {
197191
len2Profile.enter();
198192
Object active = getItemNode.execute(frame, state, 1);
199-
checkIterator(frame, getAttrNode, active, activeIteratorProfile);
193+
checkIterator(frame, getAttrNode, active);
200194
self.setActive(active);
201195
}
202196
return PNone.NONE;
203197
}
204198

205-
private void checkIterator(VirtualFrame frame, PyObjectLookupAttr getAttrNode, Object obj, BranchProfile profile) throws PException {
199+
private void checkIterator(VirtualFrame frame, PyObjectLookupAttr getAttrNode, Object obj) throws PException {
206200
if (getAttrNode.execute(frame, obj, __NEXT__) == PNone.NO_VALUE) {
207-
profile.enter();
208201
throw raise(TypeError, ARGUMENTS_MUST_BE_ITERATORS);
209202
}
210203
}

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/CombinationsBuiltins.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,12 +232,10 @@ Object setState(VirtualFrame frame, PAbstractCombinations self, Object state,
232232
@Cached ConditionProfile noResultProfile,
233233
@Cached LoopConditionProfile indicesProfile) {
234234
if (!(state instanceof PTuple)) {
235-
isNotTupleProfile.enter();
236235
throw raise(TypeError, IS_NOT_A, "state", "a length 1 or 2 tuple");
237236
}
238237
int len = (int) lenNode.execute(frame, state);
239238
if (len != 3) {
240-
wrongLenProfile.enter();
241239
throw raise(TypeError, IS_NOT_A, "state", "a length 1 or 2 tuple");
242240
}
243241

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/CycleBuiltins.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,10 +214,8 @@ Object setState(VirtualFrame frame, PCycle self, Object state,
214214
@Cached GetItemNode getItemNode,
215215
@Cached IsBuiltinClassProfile isTypeErrorProfile,
216216
@Cached ToArrayNode toArrayNode,
217-
@Cached PyNumberAsSizeNode asSizeNode,
218-
@Cached BranchProfile isNotTupleProfile) {
217+
@Cached PyNumberAsSizeNode asSizeNode) {
219218
if (!((state instanceof PTuple) && ((int) lenNode.execute(frame, state) == 2))) {
220-
isNotTupleProfile.enter();
221219
throw raise(TypeError, IS_NOT_A, "state", "2-tuple");
222220
}
223221
Object obj = getItemNode.execute(frame, state, 0);

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/DropwhileBuiltins.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,12 +129,10 @@ Object reduce(PDropwhile self,
129129
public abstract static class SetStateNode extends PythonBinaryBuiltinNode {
130130
@Specialization
131131
Object setState(PDropwhile self, Object state,
132-
@Cached CastToJavaBooleanNode castToBoolean,
133-
@Cached BranchProfile exceptionProfile) {
132+
@Cached CastToJavaBooleanNode castToBoolean) {
134133
try {
135134
self.setDoneDropping(castToBoolean.execute(state));
136135
} catch (CannotCastException e) {
137-
exceptionProfile.enter();
138136
throw raise(ValueError, INVALID_ARGS, __SETSTATE__);
139137
}
140138
return PNone.NONE;

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/GroupByBuiltins.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,10 +179,8 @@ public abstract static class SetStateNode extends PythonBinaryBuiltinNode {
179179
@Specialization
180180
Object setState(VirtualFrame frame, PGroupBy self, Object state,
181181
@Cached TupleBuiltins.LenNode lenNode,
182-
@Cached TupleBuiltins.GetItemNode getItemNode,
183-
@Cached BranchProfile isNotTupleProfile) {
182+
@Cached TupleBuiltins.GetItemNode getItemNode) {
184183
if (!(state instanceof PTuple) || (int) lenNode.execute(frame, state) != 3) {
185-
isNotTupleProfile.enter();
186184
throw raise(TypeError, IS_NOT_A, "state", "3-tuple");
187185
}
188186

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/PermutationsBuiltins.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -189,18 +189,14 @@ Object setState(VirtualFrame frame, PPermutations self, Object state,
189189
@Cached PyObjectSizeNode sizeNode,
190190
@Cached GetItemNode getItemNode,
191191
@Cached LoopConditionProfile indicesProfile,
192-
@Cached LoopConditionProfile cyclesProfile,
193-
@Cached BranchProfile wrongStateSizeProfile,
194-
@Cached BranchProfile wrongValuesSizeProfile) {
192+
@Cached LoopConditionProfile cyclesProfile) {
195193
if (sizeNode.execute(frame, state) != 3) {
196-
wrongStateSizeProfile.enter();
197194
throw raise(ValueError, INVALID_ARGS, __SETSTATE__);
198195
}
199196
Object indices = getItemNode.execute(frame, state, 0);
200197
Object cycles = getItemNode.execute(frame, state, 1);
201198
int poolLen = self.getPool().length;
202199
if (sizeNode.execute(frame, indices) != poolLen || sizeNode.execute(frame, cycles) != self.getR()) {
203-
wrongValuesSizeProfile.enter();
204200
throw raise(ValueError, INVALID_ARGS, __SETSTATE__);
205201
}
206202

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/TeeBuiltins.java

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@
7979
import com.oracle.truffle.api.dsl.NodeFactory;
8080
import com.oracle.truffle.api.dsl.Specialization;
8181
import com.oracle.truffle.api.frame.VirtualFrame;
82-
import com.oracle.truffle.api.profiles.BranchProfile;
8382
import com.oracle.truffle.api.profiles.ConditionProfile;
8483

8584
@CoreFunctions(extendClasses = {PythonBuiltinClassType.PTee})
@@ -177,18 +176,13 @@ public abstract static class SetStateNode extends PythonBinaryBuiltinNode {
177176
Object setState(VirtualFrame frame, PTee self, Object state,
178177
@Cached LenNode lenNode,
179178
@Cached TupleBuiltins.GetItemNode getItemNode,
180-
@Cached CastToJavaIntLossyNode castToIntNode,
181-
@Cached BranchProfile isNotTupleProfile,
182-
@Cached BranchProfile isNotTeeDOProfile,
183-
@Cached BranchProfile wrongIndexProfile) {
179+
@Cached CastToJavaIntLossyNode castToIntNode) {
184180

185181
if (!(state instanceof PTuple) || (int) lenNode.execute(frame, state) != 2) {
186-
isNotTupleProfile.enter();
187182
throw raise(TypeError, IS_NOT_A, "state", "2-tuple");
188183
}
189184
Object dataObject = getItemNode.execute(frame, state, 0);
190185
if (!(dataObject instanceof PTeeDataObject)) {
191-
isNotTeeDOProfile.enter();
192186
throw raise(TypeError, IS_NOT_A, "state", "_tee_dataobject");
193187
}
194188
self.setDataObj((PTeeDataObject) dataObject);
@@ -200,7 +194,6 @@ Object setState(VirtualFrame frame, PTee self, Object state,
200194
throw raise(TypeError, INTEGER_REQUIRED_GOT, secondElement);
201195
}
202196
if (index < 0 || index > LINKCELLS) {
203-
wrongIndexProfile.enter();
204197
throw raise(ValueError, INDEX_OUT_OF_RANGE);
205198
}
206199
self.setIndex(index);

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/TeeDataObjectBuiltins.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -124,22 +124,16 @@ private static void init(PTeeDataObject self, Object it, PTeeDataObject nxt) {
124124
Object init(VirtualFrame frame, PTeeDataObject self, Object it, PList values, Object nxt,
125125
@Cached LenNode lenNode,
126126
@Cached GetSequenceStorageNode getStorageNode,
127-
@Cached BranchProfile numreadLCProfile,
128-
@Cached BranchProfile numreadTooHighProfile,
129-
@Cached BranchProfile nxtNotDOProfile,
130-
@Cached BranchProfile nxtNotNoneProfile) {
127+
@Cached BranchProfile numreadLCProfile) {
131128
int numread = (int) lenNode.execute(frame, values);
132129
if (numread == LINKCELLS) {
133130
numreadLCProfile.enter();
134131
if (!(nxt instanceof PTeeDataObject)) {
135-
nxtNotDOProfile.enter();
136132
throw raise(ValueError, S_MUST_BE_S, "_tee_dataobject next link", "_tee_dataobject");
137133
}
138134
} else if (numread > LINKCELLS) {
139-
numreadTooHighProfile.enter();
140135
throw raise(ValueError, TDATAOBJECT_SHOULD_NOT_HAVE_MORE_LINKS, LINKCELLS);
141136
} else if (!(nxt instanceof PNone)) {
142-
nxtNotNoneProfile.enter();
143137
throw raise(ValueError, TDATAOBJECT_SHOULDNT_HAVE_NEXT);
144138
}
145139
self.setIt(it);

0 commit comments

Comments
 (0)