@@ -2695,14 +2695,16 @@ public Object doGeneric(VirtualFrame frame, Object iterable, Object start) {
2695
2695
@ GenerateNodeFactory
2696
2696
public abstract static class DistNode extends PythonBuiltinNode {
2697
2697
2698
- @ Child private TupleNodes .ConstructTupleNode tupleCtor = TupleNodes .ConstructTupleNode .create ();
2699
- @ Child private SequenceNodes .GetObjectArrayNode getObjectArray = SequenceNodes .GetObjectArrayNode .create ();
2700
- private final LoopConditionProfile loopProfile1 = LoopConditionProfile .createCountingProfile ();
2701
- private final LoopConditionProfile loopProfile2 = LoopConditionProfile .createCountingProfile ();
2702
-
2703
2698
@ Specialization
2704
2699
public double doGeneric (VirtualFrame frame , Object p , Object q ,
2705
- @ CachedLibrary (limit = "4" ) PythonObjectLibrary lib ) {
2700
+ @ CachedLibrary (limit = "4" ) PythonObjectLibrary lib ,
2701
+ @ Cached TupleNodes .ConstructTupleNode tupleCtor ,
2702
+ @ Cached SequenceNodes .GetObjectArrayNode getObjectArray ,
2703
+ @ Cached ("createCountingProfile()" ) LoopConditionProfile loopProfile1 ,
2704
+ @ Cached ("createCountingProfile()" ) LoopConditionProfile loopProfile2 ,
2705
+ @ Cached ("createBinaryProfile()" ) ConditionProfile infProfile ,
2706
+ @ Cached ("createBinaryProfile()" ) ConditionProfile nanProfile ,
2707
+ @ Cached ("createBinaryProfile()" ) ConditionProfile trivialProfile ) {
2706
2708
// adapted from CPython math_dist_impl and vector_norm
2707
2709
Object [] ps = getObjectArray .execute (tupleCtor .execute (frame , p ));
2708
2710
Object [] qs = getObjectArray .execute (tupleCtor .execute (frame , q ));
@@ -2724,13 +2726,13 @@ public double doGeneric(VirtualFrame frame, Object p, Object q,
2724
2726
max = x ;
2725
2727
}
2726
2728
}
2727
- if (Double .isInfinite (max )) {
2729
+ if (infProfile . profile ( Double .isInfinite (max ) )) {
2728
2730
return max ;
2729
2731
}
2730
- if (foundNan ) {
2732
+ if (nanProfile . profile ( foundNan ) ) {
2731
2733
return Double .NaN ;
2732
2734
}
2733
- if (max == 0.0 || len <= 1 ) {
2735
+ if (trivialProfile . profile ( max == 0.0 || len <= 1 ) ) {
2734
2736
return max ;
2735
2737
}
2736
2738
0 commit comments