6969import com .oracle .graal .python .builtins .objects .bytes .PBytes ;
7070import com .oracle .graal .python .builtins .objects .bytes .PIBytesLike ;
7171import com .oracle .graal .python .builtins .objects .cell .PCell ;
72- import com .oracle .graal .python .builtins .objects .cext .CExtNodes .FromNativeSubclassNode ;
73- import com .oracle .graal .python .builtins .objects .cext .NativeCAPISymbols ;
74- import com .oracle .graal .python .builtins .objects .cext .PythonNativeClass ;
75- import com .oracle .graal .python .builtins .objects .cext .PythonNativeObject ;
7672import com .oracle .graal .python .builtins .objects .common .HashingStorage .DictEntry ;
7773import com .oracle .graal .python .builtins .objects .common .HashingStorageNodes ;
7874import com .oracle .graal .python .builtins .objects .complex .PComplex ;
155151import com .oracle .truffle .api .dsl .Specialization ;
156152import com .oracle .truffle .api .dsl .TypeSystemReference ;
157153import com .oracle .truffle .api .nodes .UnexpectedResultException ;
154+ import com .oracle .truffle .api .profiles .BranchProfile ;
158155import com .oracle .truffle .api .profiles .ConditionProfile ;
159156
160157@ CoreFunctions (defineModule = "builtins" )
@@ -490,11 +487,13 @@ public Object floatFromNone(PythonClass cls, @SuppressWarnings("unused") PNone a
490487 }
491488
492489 @ Specialization
493- Object doPythonObject (PythonClass cls , PythonObject obj ,
494- @ Cached ("create(__FLOAT__)" ) LookupAndCallUnaryNode callFloatNode ) {
490+ Object doPythonObject (PythonClass cls , Object obj ,
491+ @ Cached ("create(__FLOAT__)" ) LookupAndCallUnaryNode callFloatNode ,
492+ @ Cached ("create()" ) BranchProfile gotException ) {
495493 try {
496494 return floatFromFloat (cls , callFloatNode .executeDouble (obj ));
497495 } catch (UnexpectedResultException e ) {
496+ gotException .enter ();
498497 Object result = e .getResult ();
499498 if (result == PNone .NO_VALUE ) {
500499 throw raise (TypeError , "must be real number, not %p" , obj );
@@ -507,21 +506,6 @@ Object doPythonObject(PythonClass cls, PythonObject obj,
507506 }
508507 }
509508
510- protected static FromNativeSubclassNode cacheGetFloat () {
511- return FromNativeSubclassNode .create (PythonBuiltinClassType .PFloat , NativeCAPISymbols .FUN_PY_FLOAT_AS_DOUBLE );
512- }
513-
514- @ Specialization
515- Object doNativeFloat (@ SuppressWarnings ("unused" ) PythonNativeClass cls , PythonNativeObject possibleBase ,
516- @ Cached ("cacheGetFloat()" ) FromNativeSubclassNode getFloat ) {
517- Object convertedFloat = getFloat .execute (possibleBase );
518- if (convertedFloat instanceof Double ) {
519- return possibleBase ; // TODO (tfel): we really need to call back into C
520- } else {
521- throw raise (TypeError , "must be real number, not %p" , possibleBase );
522- }
523- }
524-
525509 @ Fallback
526510 @ TruffleBoundary
527511 public Object floatFromObject (@ SuppressWarnings ("unused" ) Object cls , Object arg ) {
0 commit comments