Skip to content

Commit 3c3c0b0

Browse files
committed
Remove generic int/long specializations and report polymorphism.
1 parent 9545d94 commit 3c3c0b0

File tree

1 file changed

+9
-54
lines changed
  • graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext

1 file changed

+9
-54
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/CExtNodes.java

Lines changed: 9 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@
149149
import com.oracle.truffle.api.dsl.GeneratedBy;
150150
import com.oracle.truffle.api.dsl.ImportStatic;
151151
import com.oracle.truffle.api.dsl.NodeFactory;
152+
import com.oracle.truffle.api.dsl.ReportPolymorphism;
152153
import com.oracle.truffle.api.dsl.Specialization;
153154
import com.oracle.truffle.api.dsl.TypeSystemReference;
154155
import com.oracle.truffle.api.frame.Frame;
@@ -317,6 +318,7 @@ public static FromNativeSubclassNode create() {
317318

318319
// -----------------------------------------------------------------------------------------------------------------
319320
@GenerateUncached
321+
@ReportPolymorphism
320322
@ImportStatic({PGuards.class, CApiGuards.class})
321323
public abstract static class ToSulongNode extends CExtToNativeNode {
322324

@@ -351,20 +353,11 @@ static PrimitiveNativeWrapper doIntegerSmall(@SuppressWarnings("unused") CExtCon
351353
return PrimitiveNativeWrapper.createInt(i);
352354
}
353355

354-
@Specialization(guards = "!isSmallInteger(i)", replaces = "doIntegerSmall")
356+
@Specialization(guards = "!isSmallInteger(i)")
355357
static PrimitiveNativeWrapper doInteger(@SuppressWarnings("unused") CExtContext cextContext, int i) {
356358
return PrimitiveNativeWrapper.createInt(i);
357359
}
358360

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-
368361
@Specialization(guards = "isSmallLong(l)")
369362
static PrimitiveNativeWrapper doLongSmall(@SuppressWarnings("unused") CExtContext cextContext, long l,
370363
@Shared("contextRef") @CachedContext(PythonLanguage.class) ContextReference<PythonContext> contextRef) {
@@ -375,20 +368,11 @@ static PrimitiveNativeWrapper doLongSmall(@SuppressWarnings("unused") CExtContex
375368
return PrimitiveNativeWrapper.createLong(l);
376369
}
377370

378-
@Specialization(guards = "!isSmallLong(l)", replaces = "doLongSmall")
371+
@Specialization(guards = "!isSmallLong(l)")
379372
static PrimitiveNativeWrapper doLong(@SuppressWarnings("unused") CExtContext cextContext, long l) {
380373
return PrimitiveNativeWrapper.createLong(l);
381374
}
382375

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-
392376
@Specialization(guards = "!isNaN(d)")
393377
static Object doDouble(@SuppressWarnings("unused") CExtContext cextContext, double d) {
394378
return PrimitiveNativeWrapper.createDouble(d);
@@ -548,6 +532,7 @@ public static ToSulongNode getUncached() {
548532
*/
549533
@GenerateUncached
550534
@ImportStatic({PGuards.class, CApiGuards.class})
535+
@ReportPolymorphism
551536
public abstract static class ToNewRefNode extends CExtToNativeNode {
552537

553538
public final Object executeInt(int i) {
@@ -597,20 +582,11 @@ static PrimitiveNativeWrapper doIntegerSmall(@SuppressWarnings("unused") CExtCon
597582
return PrimitiveNativeWrapper.createInt(i);
598583
}
599584

600-
@Specialization(guards = "!isSmallInteger(i)", replaces = "doIntegerSmall")
585+
@Specialization(guards = "!isSmallInteger(i)")
601586
static PrimitiveNativeWrapper doInteger(@SuppressWarnings("unused") CExtContext cextContext, int i) {
602587
return PrimitiveNativeWrapper.createInt(i);
603588
}
604589

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-
614590
@Specialization(guards = "isSmallLong(l)")
615591
static PrimitiveNativeWrapper doLongSmall(@SuppressWarnings("unused") CExtContext cextContext, long l,
616592
@Shared("contextRef") @CachedContext(PythonLanguage.class) ContextReference<PythonContext> contextRef) {
@@ -623,20 +599,11 @@ static PrimitiveNativeWrapper doLongSmall(@SuppressWarnings("unused") CExtContex
623599
return PrimitiveNativeWrapper.createLong(l);
624600
}
625601

626-
@Specialization(guards = "!isSmallLong(l)", replaces = "doLongSmall")
602+
@Specialization(guards = "!isSmallLong(l)")
627603
static PrimitiveNativeWrapper doLong(@SuppressWarnings("unused") CExtContext cextContext, long l) {
628604
return PrimitiveNativeWrapper.createLong(l);
629605
}
630606

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-
640607
@Specialization(guards = "!isNaN(d)")
641608
static Object doDouble(CExtContext cextContext, double d) {
642609
return ToSulongNode.doDouble(cextContext, d);
@@ -811,34 +778,22 @@ static PrimitiveNativeWrapper doIntegerSmall(CExtContext cextContext, int i,
811778
return ToNewRefNode.doIntegerSmall(cextContext, i, contextRef);
812779
}
813780

814-
@Specialization(guards = "!isSmallInteger(i)", replaces = "doIntegerSmall")
781+
@Specialization(guards = "!isSmallInteger(i)")
815782
static PrimitiveNativeWrapper doInteger(CExtContext cextContext, int i) {
816783
return ToNewRefNode.doInteger(cextContext, i);
817784
}
818785

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-
825786
@Specialization(guards = "isSmallLong(l)")
826787
static PrimitiveNativeWrapper doLongSmall(CExtContext cextContext, long l,
827788
@Shared("contextRef") @CachedContext(PythonLanguage.class) ContextReference<PythonContext> contextRef) {
828789
return ToNewRefNode.doLongSmall(cextContext, l, contextRef);
829790
}
830791

831-
@Specialization(guards = "!isSmallLong(l)", replaces = "doLongSmall")
792+
@Specialization(guards = "!isSmallLong(l)")
832793
static PrimitiveNativeWrapper doLong(@SuppressWarnings("unused") CExtContext cextContext, long l) {
833794
return ToNewRefNode.doLong(cextContext, l);
834795
}
835796

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-
842797
@Specialization(guards = "!isNaN(d)")
843798
static Object doDouble(CExtContext cextContext, double d) {
844799
return ToSulongNode.doDouble(cextContext, d);

0 commit comments

Comments
 (0)