Skip to content

Commit 4ec9765

Browse files
committed
Remove unnecessary specializations.
1 parent 50ffc8c commit 4ec9765

File tree

3 files changed

+9
-53
lines changed

3 files changed

+9
-53
lines changed

com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/altrep/AltrepDownCallNodeImpl.java

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -62,19 +62,19 @@ public static AltrepDownCallNodeImpl getUncached() {
6262
return AltrepDownCallNodeImplNodeGen.getUncached();
6363
}
6464

65-
@Specialization(guards = "cachedLength == args.length", limit = "3")
65+
@Specialization(limit = "3")
6666
public Object doIt(AltrepMethodDescriptor altrepDowncallIn, boolean unwrapResult, boolean[] wrapArguments, Object[] args,
67-
@Cached("args.length") int cachedLength,
6867
@CachedLibrary("altrepDowncallIn.method") InteropLibrary methodInterop,
6968
@Cached(value = "createUnwrapNode(unwrapResult)", uncached = "createUncachedUnwrapNode()") FFIUnwrapNode unwrapNode,
7069
@CachedContext(TruffleRLanguage.class) ContextReference<RContext> ctxRef,
71-
@Cached("createMaterialized(wrapArguments)") FFIMaterializeNode[] materializeNodes,
72-
@Cached("createToNatives(wrapArguments)") FFIToNativeMirrorNode[] toNativeNodes,
70+
@Cached(value = "createMaterialized(wrapArguments)", allowUncached = true) FFIMaterializeNode[] materializeNodes,
71+
@Cached(value = "createToNatives(wrapArguments)", allowUncached = true) FFIToNativeMirrorNode[] toNativeNodes,
7372
@Cached("createBinaryProfile()") ConditionProfile isLLVMProfile,
7473
@Cached BranchProfile unwrapResultProfile,
7574
@Cached("createIdentityProfile()") ValueProfile identityProfile,
7675
@Cached AfterDownCallProfiles afterDownCallProfiles) {
7776
CompilerAsserts.partialEvaluationConstant(unwrapResult);
77+
CompilerAsserts.partialEvaluationConstant(args.length);
7878
AltrepMethodDescriptor altrepMethodDescriptor = identityProfile.profile(altrepDowncallIn);
7979

8080
assert methodInterop.isExecutable(altrepMethodDescriptor.method);
@@ -88,7 +88,7 @@ public Object doIt(AltrepMethodDescriptor altrepDowncallIn, boolean unwrapResult
8888
}
8989

9090
Object ret;
91-
try (FFIDownCallWrap ffiWrap = new FFIDownCallWrap(cachedLength)) {
91+
try (FFIDownCallWrap ffiWrap = new FFIDownCallWrap(args.length)) {
9292
Object[] wrappedArgs = ffiWrap.wrapSome(args, materializeNodes, toNativeNodes, wrapArguments);
9393
ret = methodInterop.execute(altrepMethodDescriptor.method, wrappedArgs);
9494
if (unwrapResult) {
@@ -108,26 +108,6 @@ public Object doIt(AltrepMethodDescriptor altrepDowncallIn, boolean unwrapResult
108108
return ret;
109109
}
110110

111-
@Specialization(guards = "cachedLength == args.length", replaces = "doIt")
112-
public Object doItWithDispatchedMethodInterop(
113-
AltrepMethodDescriptor altrepDowncall, boolean unwrapResult, boolean[] wrapArguments, Object[] args,
114-
@Cached("args.length") int cachedLength,
115-
@CachedLibrary(limit = "3") InteropLibrary methodInterop,
116-
@Cached(value = "createUnwrapNode(unwrapResult)", uncached = "createUncachedUnwrapNode()") FFIUnwrapNode unwrapNode,
117-
@CachedContext(TruffleRLanguage.class) ContextReference<RContext> ctxRef,
118-
@Cached(value = "createMaterialized(wrapArguments)", allowUncached = true) FFIMaterializeNode[] materializeNodes,
119-
@Cached(value = "createToNatives(wrapArguments)", allowUncached = true) FFIToNativeMirrorNode[] toNativeNodes,
120-
@Cached("createBinaryProfile()") ConditionProfile isLLVMProfile,
121-
@Cached BranchProfile unwrapResultProfile,
122-
@Cached("createIdentityProfile()") ValueProfile identityProfile,
123-
@Cached AfterDownCallProfiles afterDownCallProfiles) {
124-
return doIt(altrepDowncall, unwrapResult, wrapArguments, args, cachedLength, methodInterop, unwrapNode,
125-
ctxRef, materializeNodes, toNativeNodes, isLLVMProfile, unwrapResultProfile, identityProfile,
126-
afterDownCallProfiles);
127-
}
128-
129-
// TODO: Implement some uncached specialization?
130-
131111
protected static FFIUnwrapNode createUnwrapNode(boolean unwrapFlag) {
132112
if (unwrapFlag) {
133113
return FFIUnwrapNode.create();

com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/nodes/IsSortedNode.java

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -55,44 +55,24 @@ public int isIntSorted(RIntVector intVec,
5555
return isVectorSorted(intVec, dataLibrary);
5656
}
5757

58-
@Specialization(replaces = "isIntSorted")
59-
public int isIntSortedUncached(RIntVector intVec) {
60-
return isVectorSorted(intVec, VectorDataLibrary.getFactory().getUncached(intVec.getData()));
61-
}
62-
6358
@Specialization(limit = "getTypedVectorDataLibraryCacheSize()")
6459
public int isDoubleSorted(RDoubleVector doubleVector,
6560
@CachedLibrary("doubleVector.getData()") VectorDataLibrary dataLibrary) {
6661
return isVectorSorted(doubleVector, dataLibrary);
6762
}
6863

69-
@Specialization(replaces = "isDoubleSorted")
70-
public int isDoubleSortedUncached(RDoubleVector doubleVector) {
71-
return isVectorSorted(doubleVector, VectorDataLibrary.getFactory().getUncached(doubleVector.getData()));
72-
}
73-
7464
@Specialization(limit = "getTypedVectorDataLibraryCacheSize()")
7565
public int isLogicalSorted(RLogicalVector logicalVector,
7666
@CachedLibrary("logicalVector.getData()") VectorDataLibrary dataLibrary) {
7767
return isVectorSorted(logicalVector, dataLibrary);
7868
}
7969

80-
@Specialization(replaces = "isLogicalSorted")
81-
public int isLogicalSortedUncached(RLogicalVector logicalVector) {
82-
return isVectorSorted(logicalVector, VectorDataLibrary.getFactory().getUncached(logicalVector.getData()));
83-
}
84-
8570
@Specialization(limit = "getTypedVectorDataLibraryCacheSize()")
8671
public int isStringSorted(RStringVector stringVector,
8772
@CachedLibrary("stringVector.getData()") VectorDataLibrary dataLibrary) {
8873
return isVectorSorted(stringVector, dataLibrary);
8974
}
9075

91-
@Specialization(replaces = "isStringSorted")
92-
public int isStringSortedUncached(RStringVector stringVector) {
93-
return isVectorSorted(stringVector, VectorDataLibrary.getFactory().getUncached(stringVector.getData()));
94-
}
95-
9676
@Fallback
9777
public int isSortedFallback(@SuppressWarnings("unused") Object x) {
9878
return AltrepSortedness.UNKNOWN_SORTEDNESS.getValue();

com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/nodes/NoNANode.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@
2222
*/
2323
package com.oracle.truffle.r.ffi.impl.nodes;
2424

25+
import com.oracle.truffle.api.dsl.Fallback;
2526
import com.oracle.truffle.api.dsl.GenerateUncached;
2627
import com.oracle.truffle.api.dsl.Specialization;
2728
import com.oracle.truffle.api.library.CachedLibrary;
2829
import com.oracle.truffle.r.runtime.RRuntime;
29-
import com.oracle.truffle.r.runtime.data.RBaseObject;
3030
import com.oracle.truffle.r.runtime.data.VectorDataLibrary;
3131
import com.oracle.truffle.r.runtime.data.model.RAbstractContainer;
3232

@@ -39,15 +39,11 @@ public static NoNANode create() {
3939
@Specialization(limit = "getGenericDataLibraryCacheSize()")
4040
protected Object doContainer(RAbstractContainer container,
4141
@CachedLibrary("container.getData()") VectorDataLibrary dataLibrary) {
42-
if (dataLibrary.isComplete(container.getData())) {
43-
return RRuntime.LOGICAL_TRUE;
44-
} else {
45-
return RRuntime.LOGICAL_FALSE;
46-
}
42+
return RRuntime.asLogical(dataLibrary.isComplete(container.getData()));
4743
}
4844

49-
@Specialization(replaces = "doContainer")
50-
protected Object doOther(@SuppressWarnings("unused") RBaseObject rObject) {
45+
@Fallback
46+
protected Object doOther(@SuppressWarnings("unused") Object obj) {
5147
return RRuntime.LOGICAL_FALSE;
5248
}
5349
}

0 commit comments

Comments
 (0)