Skip to content
Snippets Groups Projects
Commit 72ac8c95 authored by Lukas Stadler's avatar Lukas Stadler
Browse files

don’t use sequences in vector fast paths

parent 2c47cd13
Branches
No related tags found
No related merge requests found
...@@ -25,7 +25,7 @@ package com.oracle.truffle.r.nodes.builtin.base.fastpaths; ...@@ -25,7 +25,7 @@ package com.oracle.truffle.r.nodes.builtin.base.fastpaths;
import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Cached;
import com.oracle.truffle.api.dsl.Fallback; import com.oracle.truffle.api.dsl.Fallback;
import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.profiles.ConditionProfile; import com.oracle.truffle.r.nodes.profile.VectorLengthProfile;
import com.oracle.truffle.r.runtime.data.RDataFactory; import com.oracle.truffle.r.runtime.data.RDataFactory;
import com.oracle.truffle.r.runtime.data.RMissing; import com.oracle.truffle.r.runtime.data.RMissing;
import com.oracle.truffle.r.runtime.data.model.RAbstractDoubleVector; import com.oracle.truffle.r.runtime.data.model.RAbstractDoubleVector;
...@@ -43,20 +43,18 @@ public abstract class VectorFastPaths { ...@@ -43,20 +43,18 @@ public abstract class VectorFastPaths {
@Specialization @Specialization
protected RAbstractIntVector get(int length, protected RAbstractIntVector get(int length,
@Cached("createBinaryProfile()") ConditionProfile emptyProfile) { @Cached("create()") VectorLengthProfile profile) {
if (emptyProfile.profile(length == 0)) { if (length > 0) {
return RDataFactory.createIntVector(0); return RDataFactory.createIntVector(profile.profile(length));
} else if (length > 0) {
return RDataFactory.createIntSequence(0, 0, length);
} }
return null; return null;
} }
@Specialization @Specialization
protected RAbstractIntVector get(double length, protected RAbstractIntVector get(double length,
@Cached("createBinaryProfile()") ConditionProfile emptyProfile) { @Cached("create()") VectorLengthProfile profile) {
if (!Double.isNaN(length)) { if (!Double.isNaN(length)) {
return get((int) length, emptyProfile); return get((int) length, profile);
} }
return null; return null;
} }
...@@ -77,20 +75,18 @@ public abstract class VectorFastPaths { ...@@ -77,20 +75,18 @@ public abstract class VectorFastPaths {
@Specialization @Specialization
protected RAbstractDoubleVector get(int length, protected RAbstractDoubleVector get(int length,
@Cached("createBinaryProfile()") ConditionProfile emptyProfile) { @Cached("create()") VectorLengthProfile profile) {
if (emptyProfile.profile(length == 0)) { if (length > 0) {
return RDataFactory.createDoubleVector(0); return RDataFactory.createDoubleVector(profile.profile(length));
} else if (length > 0) {
return RDataFactory.createDoubleSequence(0, 0, length);
} }
return null; return null;
} }
@Specialization @Specialization
protected RAbstractDoubleVector get(double length, protected RAbstractDoubleVector get(double length,
@Cached("createBinaryProfile()") ConditionProfile emptyProfile) { @Cached("create()") VectorLengthProfile profile) {
if (!Double.isNaN(length)) { if (!Double.isNaN(length)) {
return get((int) length, emptyProfile); return get((int) length, profile);
} }
return null; return null;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment