47
47
import com .oracle .graal .python .annotations .ClinicConverterFactory .DefaultValue ;
48
48
import com .oracle .graal .python .annotations .ClinicConverterFactory .UseDefaultForNone ;
49
49
import com .oracle .graal .python .builtins .PythonBuiltinClassType ;
50
+ import com .oracle .graal .python .builtins .objects .function .PArguments ;
50
51
import com .oracle .graal .python .builtins .objects .object .PythonObjectLibrary ;
51
52
import com .oracle .graal .python .nodes .ErrorMessages ;
52
53
import com .oracle .graal .python .nodes .classes .IsSubtypeNode ;
53
- import com .oracle .graal .python .nodes .object .IsBuiltinClassProfile ;
54
- import com .oracle .graal .python .runtime .exception .PException ;
54
+ import com .oracle .graal .python .nodes .util .CastToJavaLongLossyNode ;
55
55
import com .oracle .truffle .api .dsl .Cached ;
56
56
import com .oracle .truffle .api .dsl .Specialization ;
57
57
import com .oracle .truffle .api .frame .VirtualFrame ;
@@ -67,19 +67,13 @@ protected JavaIntConversionNode(int defaultValue, boolean useDefaultForNone) {
67
67
int doOthers (VirtualFrame frame , Object value ,
68
68
@ Cached IsSubtypeNode isSubtypeNode ,
69
69
@ Cached BranchProfile isFloatProfile ,
70
- @ Cached IsBuiltinClassProfile exceptionProfle ,
71
- @ CachedLibrary ( "value" ) PythonObjectLibrary lib ) {
70
+ @ CachedLibrary ( "value" ) PythonObjectLibrary lib ,
71
+ @ Cached CastToJavaLongLossyNode castToLongNode ) {
72
72
if (isSubtypeNode .execute (lib .getLazyPythonClass (value ), PythonBuiltinClassType .PFloat )) {
73
73
isFloatProfile .enter ();
74
74
throw raise (TypeError , ErrorMessages .INTEGER_EXPECTED_GOT_FLOAT );
75
75
}
76
- long result ;
77
- try {
78
- result = lib .asJavaLong (value , frame );
79
- } catch (PException e ) {
80
- e .expect (TypeError , exceptionProfle );
81
- throw raise (TypeError , ErrorMessages .VALUE_TOO_LARGE_TO_FIT_INTO_INDEX );
82
- }
76
+ long result = castToLongNode .execute (lib .asPIntWithState (value , PArguments .getThreadState (frame )));
83
77
if (!fitsInInt (result )) {
84
78
throw raise (TypeError , ErrorMessages .VALUE_TOO_LARGE_TO_FIT_INTO_INDEX );
85
79
}
0 commit comments