Skip to content

Commit 7507f10

Browse files
committed
[GR-31070] Removing unreachable specialization in PRaiseNode.
PullRequest: graalpython/1776
2 parents 4dc9060 + 25b4bf7 commit 7507f10

File tree

2 files changed

+5
-51
lines changed

2 files changed

+5
-51
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/PythonAbstractObject.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1009,7 +1009,7 @@ public Object asPIntWithState(ThreadState state,
10091009
return result;
10101010
}
10111011

1012-
private static int longToInt(long longResult, BranchProfile overflow, ConditionProfile ignoreOverflow, Object type, PRaiseNode raise, Object result) throws PException {
1012+
private static int longToInt(long longResult, BranchProfile overflow, ConditionProfile ignoreOverflow, PythonBuiltinClassType type, PRaiseNode raise, Object result) throws PException {
10131013
try {
10141014
return PInt.intValueExact(longResult);
10151015
} catch (OverflowException e) {

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/PRaiseNode.java

Lines changed: 4 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@
4444
import com.oracle.graal.python.builtins.PythonBuiltinClassType;
4545
import com.oracle.graal.python.builtins.objects.PNone;
4646
import com.oracle.graal.python.builtins.objects.exception.PBaseException;
47-
import com.oracle.graal.python.builtins.objects.type.PythonBuiltinClass;
48-
import com.oracle.graal.python.builtins.objects.type.PythonManagedClass;
4947
import com.oracle.graal.python.runtime.PythonOptions;
5048
import com.oracle.graal.python.runtime.exception.PException;
5149
import com.oracle.graal.python.runtime.object.PythonObjectFactory;
@@ -65,7 +63,7 @@
6563
@GenerateUncached
6664
public abstract class PRaiseNode extends Node {
6765

68-
public abstract PException execute(Node raisingNode, Object type, Object cause, Object format, Object[] arguments);
66+
public abstract PException execute(Node raisingNode, PythonBuiltinClassType type, Object cause, Object format, Object[] arguments);
6967

7068
public final PException raise(PythonBuiltinClassType type) {
7169
throw execute(this, type, PNone.NO_VALUE, PNone.NO_VALUE, PythonUtils.EMPTY_OBJECT_ARRAY);
@@ -91,11 +89,11 @@ public final PException raise(PythonBuiltinClassType type, PBaseException cause,
9189
throw execute(this, type, cause, format, arguments);
9290
}
9391

94-
public static PException raiseUncached(Node raisingNode, Object exceptionType) {
92+
public static PException raiseUncached(Node raisingNode, PythonBuiltinClassType exceptionType) {
9593
throw PRaiseNodeGen.getUncached().execute(raisingNode, exceptionType, PNone.NO_VALUE, PNone.NO_VALUE, PythonUtils.EMPTY_OBJECT_ARRAY);
9694
}
9795

98-
public static PException raiseUncached(Node raisingNode, Object exceptionType, Object message) {
96+
public static PException raiseUncached(Node raisingNode, PythonBuiltinClassType exceptionType, Object message) {
9997
throw PRaiseNodeGen.getUncached().execute(raisingNode, exceptionType, PNone.NO_VALUE, message, PythonUtils.EMPTY_OBJECT_ARRAY);
10098
}
10199

@@ -119,7 +117,7 @@ public static PException raiseUncached(Node raisingNode, PythonBuiltinClassType
119117
* Raise an error saying that the {@code result} cannot fit into an index-sized integer. Use the
120118
* specified {@code type} as exception class.
121119
*/
122-
public final PException raiseNumberTooLarge(Object type, Object result) {
120+
public final PException raiseNumberTooLarge(PythonBuiltinClassType type, Object result) {
123121
return execute(this, type, PNone.NO_VALUE, ErrorMessages.CANNOT_FIT_P_INTO_INDEXSIZED_INT, new Object[]{result});
124122
}
125123

@@ -170,50 +168,6 @@ protected static Assumption singleContextAssumption() {
170168
return PythonLanguage.getCurrent().singleContextAssumption;
171169
}
172170

173-
@Specialization(guards = {"isNoValue(cause)", "isNoValue(format)", "arguments.length == 0", "exceptionType == cachedType"}, limit = "3", assumptions = "singleContextAssumption()")
174-
static PException doPythonBuiltinClassCached(Node raisingNode, @SuppressWarnings("unused") PythonBuiltinClass exceptionType, @SuppressWarnings("unused") PNone cause,
175-
@SuppressWarnings("unused") PNone format,
176-
@SuppressWarnings("unused") Object[] arguments,
177-
@Cached("exceptionType") PythonBuiltinClass cachedType,
178-
@Cached PythonObjectFactory factory,
179-
@CachedLanguage PythonLanguage language) {
180-
throw raiseExceptionObject(raisingNode, factory.createBaseException(cachedType), language);
181-
}
182-
183-
@Specialization(guards = {"isNoValue(cause)", "isNoValue(format)", "arguments.length == 0", "exceptionType.getType() == cachedType"}, limit = "3")
184-
static PException doPythonBuiltinClassCachedMulti(Node raisingNode, @SuppressWarnings("unused") PythonBuiltinClass exceptionType, @SuppressWarnings("unused") PNone cause,
185-
@SuppressWarnings("unused") PNone format,
186-
@SuppressWarnings("unused") Object[] arguments,
187-
@Cached("exceptionType.getType()") PythonBuiltinClassType cachedType,
188-
@Cached PythonObjectFactory factory,
189-
@CachedLanguage PythonLanguage language) {
190-
throw raiseExceptionObject(raisingNode, factory.createBaseException(cachedType), language);
191-
}
192-
193-
@Specialization(guards = {"isNoValue(cause)", "isNoValue(format)", "arguments.length == 0"}, replaces = {"doPythonBuiltinClassCached", "doPythonBuiltinClassCachedMulti"})
194-
static PException doPythonBuiltinClass(Node raisingNode, PythonBuiltinClass exceptionType, @SuppressWarnings("unused") PNone cause, @SuppressWarnings("unused") PNone format,
195-
@SuppressWarnings("unused") Object[] arguments,
196-
@Shared("factory") @Cached PythonObjectFactory factory,
197-
@Shared("language") @CachedLanguage PythonLanguage language) {
198-
throw raiseExceptionObject(raisingNode, factory.createBaseException(exceptionType), language);
199-
}
200-
201-
@Specialization(guards = {"isNoValue(cause)"})
202-
static PException doBuiltinClass(Node raisingNode, PythonBuiltinClass exceptionType, @SuppressWarnings("unused") PNone cause, String format, Object[] arguments,
203-
@Shared("factory") @Cached PythonObjectFactory factory,
204-
@Shared("language") @CachedLanguage PythonLanguage language) {
205-
assert format != null;
206-
throw doBuiltinType(raisingNode, exceptionType.getType(), cause, format, arguments, factory, language);
207-
}
208-
209-
@Specialization(guards = {"isNoValue(cause)", "isNoValue(format)", "arguments.length == 0"})
210-
static PException doPythonManagedClass(Node raisingNode, PythonManagedClass exceptionType, @SuppressWarnings("unused") PNone cause, @SuppressWarnings("unused") PNone format,
211-
@SuppressWarnings("unused") Object[] arguments,
212-
@Shared("factory") @Cached PythonObjectFactory factory,
213-
@Shared("language") @CachedLanguage PythonLanguage language) {
214-
throw raiseExceptionObject(raisingNode, factory.createBaseException(exceptionType), language);
215-
}
216-
217171
@Specialization(guards = {"isNoValue(cause)", "isNoValue(format)", "arguments.length > 0"})
218172
static PException doBuiltinType(Node raisingNode, PythonBuiltinClassType type, @SuppressWarnings("unused") PNone cause, @SuppressWarnings("unused") PNone format, Object[] arguments,
219173
@Shared("factory") @Cached PythonObjectFactory factory,

0 commit comments

Comments
 (0)