149
149
import com .oracle .truffle .api .dsl .GeneratedBy ;
150
150
import com .oracle .truffle .api .dsl .ImportStatic ;
151
151
import com .oracle .truffle .api .dsl .NodeFactory ;
152
+ import com .oracle .truffle .api .dsl .ReportPolymorphism ;
152
153
import com .oracle .truffle .api .dsl .Specialization ;
153
154
import com .oracle .truffle .api .dsl .TypeSystemReference ;
154
155
import com .oracle .truffle .api .frame .Frame ;
@@ -317,6 +318,7 @@ public static FromNativeSubclassNode create() {
317
318
318
319
// -----------------------------------------------------------------------------------------------------------------
319
320
@ GenerateUncached
321
+ @ ReportPolymorphism
320
322
@ ImportStatic ({PGuards .class , CApiGuards .class })
321
323
public abstract static class ToSulongNode extends CExtToNativeNode {
322
324
@@ -351,20 +353,11 @@ static PrimitiveNativeWrapper doIntegerSmall(@SuppressWarnings("unused") CExtCon
351
353
return PrimitiveNativeWrapper .createInt (i );
352
354
}
353
355
354
- @ Specialization (guards = "!isSmallInteger(i)" , replaces = "doIntegerSmall" )
356
+ @ Specialization (guards = "!isSmallInteger(i)" )
355
357
static PrimitiveNativeWrapper doInteger (@ SuppressWarnings ("unused" ) CExtContext cextContext , int i ) {
356
358
return PrimitiveNativeWrapper .createInt (i );
357
359
}
358
360
359
- @ Specialization (replaces = {"doIntegerSmall" , "doInteger" })
360
- static PrimitiveNativeWrapper doIntegerGeneric (@ SuppressWarnings ("unused" ) CExtContext cextContext , int i ,
361
- @ Shared ("contextRef" ) @ CachedContext (PythonLanguage .class ) ContextReference <PythonContext > contextRef ) {
362
- if (CApiGuards .isSmallInteger (i )) {
363
- return doIntegerSmall (cextContext , i , contextRef );
364
- }
365
- return PrimitiveNativeWrapper .createInt (i );
366
- }
367
-
368
361
@ Specialization (guards = "isSmallLong(l)" )
369
362
static PrimitiveNativeWrapper doLongSmall (@ SuppressWarnings ("unused" ) CExtContext cextContext , long l ,
370
363
@ Shared ("contextRef" ) @ CachedContext (PythonLanguage .class ) ContextReference <PythonContext > contextRef ) {
@@ -375,20 +368,11 @@ static PrimitiveNativeWrapper doLongSmall(@SuppressWarnings("unused") CExtContex
375
368
return PrimitiveNativeWrapper .createLong (l );
376
369
}
377
370
378
- @ Specialization (guards = "!isSmallLong(l)" , replaces = "doLongSmall" )
371
+ @ Specialization (guards = "!isSmallLong(l)" )
379
372
static PrimitiveNativeWrapper doLong (@ SuppressWarnings ("unused" ) CExtContext cextContext , long l ) {
380
373
return PrimitiveNativeWrapper .createLong (l );
381
374
}
382
375
383
- @ Specialization (replaces = {"doLongSmall" , "doLong" })
384
- static PrimitiveNativeWrapper doLongGeneric (@ SuppressWarnings ("unused" ) CExtContext cextContext , long l ,
385
- @ Shared ("contextRef" ) @ CachedContext (PythonLanguage .class ) ContextReference <PythonContext > contextRef ) {
386
- if (CApiGuards .isSmallLong (l )) {
387
- return doLongSmall (cextContext , l , contextRef );
388
- }
389
- return PrimitiveNativeWrapper .createLong (l );
390
- }
391
-
392
376
@ Specialization (guards = "!isNaN(d)" )
393
377
static Object doDouble (@ SuppressWarnings ("unused" ) CExtContext cextContext , double d ) {
394
378
return PrimitiveNativeWrapper .createDouble (d );
@@ -548,6 +532,7 @@ public static ToSulongNode getUncached() {
548
532
*/
549
533
@ GenerateUncached
550
534
@ ImportStatic ({PGuards .class , CApiGuards .class })
535
+ @ ReportPolymorphism
551
536
public abstract static class ToNewRefNode extends CExtToNativeNode {
552
537
553
538
public final Object executeInt (int i ) {
@@ -597,20 +582,11 @@ static PrimitiveNativeWrapper doIntegerSmall(@SuppressWarnings("unused") CExtCon
597
582
return PrimitiveNativeWrapper .createInt (i );
598
583
}
599
584
600
- @ Specialization (guards = "!isSmallInteger(i)" , replaces = "doIntegerSmall" )
585
+ @ Specialization (guards = "!isSmallInteger(i)" )
601
586
static PrimitiveNativeWrapper doInteger (@ SuppressWarnings ("unused" ) CExtContext cextContext , int i ) {
602
587
return PrimitiveNativeWrapper .createInt (i );
603
588
}
604
589
605
- @ Specialization (replaces = {"doIntegerSmall" , "doInteger" })
606
- static PrimitiveNativeWrapper doIntegerGeneric (CExtContext cextContext , int i ,
607
- @ Shared ("contextRef" ) @ CachedContext (PythonLanguage .class ) ContextReference <PythonContext > contextRef ) {
608
- if (CApiGuards .isSmallInteger (i )) {
609
- return doIntegerSmall (cextContext , i , contextRef );
610
- }
611
- return PrimitiveNativeWrapper .createInt (i );
612
- }
613
-
614
590
@ Specialization (guards = "isSmallLong(l)" )
615
591
static PrimitiveNativeWrapper doLongSmall (@ SuppressWarnings ("unused" ) CExtContext cextContext , long l ,
616
592
@ Shared ("contextRef" ) @ CachedContext (PythonLanguage .class ) ContextReference <PythonContext > contextRef ) {
@@ -623,20 +599,11 @@ static PrimitiveNativeWrapper doLongSmall(@SuppressWarnings("unused") CExtContex
623
599
return PrimitiveNativeWrapper .createLong (l );
624
600
}
625
601
626
- @ Specialization (guards = "!isSmallLong(l)" , replaces = "doLongSmall" )
602
+ @ Specialization (guards = "!isSmallLong(l)" )
627
603
static PrimitiveNativeWrapper doLong (@ SuppressWarnings ("unused" ) CExtContext cextContext , long l ) {
628
604
return PrimitiveNativeWrapper .createLong (l );
629
605
}
630
606
631
- @ Specialization (replaces = {"doLongSmall" , "doLong" })
632
- static PrimitiveNativeWrapper doLongGeneric (CExtContext cextContext , long l ,
633
- @ Shared ("contextRef" ) @ CachedContext (PythonLanguage .class ) ContextReference <PythonContext > contextRef ) {
634
- if (CApiGuards .isSmallLong (l )) {
635
- return doLongSmall (cextContext , l , contextRef );
636
- }
637
- return PrimitiveNativeWrapper .createLong (l );
638
- }
639
-
640
607
@ Specialization (guards = "!isNaN(d)" )
641
608
static Object doDouble (CExtContext cextContext , double d ) {
642
609
return ToSulongNode .doDouble (cextContext , d );
@@ -811,34 +778,22 @@ static PrimitiveNativeWrapper doIntegerSmall(CExtContext cextContext, int i,
811
778
return ToNewRefNode .doIntegerSmall (cextContext , i , contextRef );
812
779
}
813
780
814
- @ Specialization (guards = "!isSmallInteger(i)" , replaces = "doIntegerSmall" )
781
+ @ Specialization (guards = "!isSmallInteger(i)" )
815
782
static PrimitiveNativeWrapper doInteger (CExtContext cextContext , int i ) {
816
783
return ToNewRefNode .doInteger (cextContext , i );
817
784
}
818
785
819
- @ Specialization (replaces = {"doIntegerSmall" , "doInteger" })
820
- static PrimitiveNativeWrapper doIntegerGeneric (CExtContext cextContext , int i ,
821
- @ Shared ("contextRef" ) @ CachedContext (PythonLanguage .class ) ContextReference <PythonContext > contextRef ) {
822
- return ToNewRefNode .doIntegerGeneric (cextContext , i , contextRef );
823
- }
824
-
825
786
@ Specialization (guards = "isSmallLong(l)" )
826
787
static PrimitiveNativeWrapper doLongSmall (CExtContext cextContext , long l ,
827
788
@ Shared ("contextRef" ) @ CachedContext (PythonLanguage .class ) ContextReference <PythonContext > contextRef ) {
828
789
return ToNewRefNode .doLongSmall (cextContext , l , contextRef );
829
790
}
830
791
831
- @ Specialization (guards = "!isSmallLong(l)" , replaces = "doLongSmall" )
792
+ @ Specialization (guards = "!isSmallLong(l)" )
832
793
static PrimitiveNativeWrapper doLong (@ SuppressWarnings ("unused" ) CExtContext cextContext , long l ) {
833
794
return ToNewRefNode .doLong (cextContext , l );
834
795
}
835
796
836
- @ Specialization (replaces = {"doLongSmall" , "doLong" })
837
- static PrimitiveNativeWrapper doLongGeneric (CExtContext cextContext , long l ,
838
- @ Shared ("contextRef" ) @ CachedContext (PythonLanguage .class ) ContextReference <PythonContext > contextRef ) {
839
- return ToNewRefNode .doLongGeneric (cextContext , l , contextRef );
840
- }
841
-
842
797
@ Specialization (guards = "!isNaN(d)" )
843
798
static Object doDouble (CExtContext cextContext , double d ) {
844
799
return ToSulongNode .doDouble (cextContext , d );
@@ -958,12 +913,14 @@ static byte doByteNativeWrapper(@SuppressWarnings("unused") CExtContext cextCont
958
913
}
959
914
960
915
@ Specialization (guards = {"object.isInt()" , "mayUsePrimitive(isPointerNode, object)" }, limit = "1" )
961
- static int doIntNativeWrappe (@ SuppressWarnings ("unused" ) CExtContext cextContext , PrimitiveNativeWrapper object ,
916
+ static int doIntNativeWrapper (@ SuppressWarnings ("unused" ) CExtContext cextContext , PrimitiveNativeWrapper object ,
962
917
@ Shared ("isPointerNode" ) @ Cached @ SuppressWarnings ("unused" ) IsPointerNode isPointerNode ) {
963
918
return object .getInt ();
964
919
}
965
920
966
- @ Specialization (guards = {"object.isLong()" , "mayUsePrimitive(isPointerNode, object)" }, limit = "1" )
921
+ @ Specialization (guards = {"object.isInt() || object.isLong()" , "mayUsePrimitive(isPointerNode, object)" }, //
922
+ limit = "1" , //
923
+ replaces = "doIntNativeWrapper" )
967
924
static long doLongNativeWrapper (@ SuppressWarnings ("unused" ) CExtContext cextContext , PrimitiveNativeWrapper object ,
968
925
@ Shared ("isPointerNode" ) @ Cached @ SuppressWarnings ("unused" ) IsPointerNode isPointerNode ) {
969
926
return object .getLong ();
0 commit comments