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

additional profiles in vector extract nodes

parent 5095715d
No related branches found
No related tags found
No related merge requests found
......@@ -330,7 +330,7 @@ final class CachedExtractVectorNode extends CachedVectorNode {
Object result;
if (dataAt == RNull.instance) {
result = RNull.instance;
} else if (positions[i] instanceof RAbstractContainer && ((RAbstractContainer) positions[i]).getLength() == 0) {
} else if (positionsCheckNode.isEmptyPosition(i, positions[i])) {
result = RNull.instance;
} else {
result = extract(i, (RAbstractStringVector) dataAt, positions[i], positionProfile[i]);
......
......@@ -37,6 +37,7 @@ import com.oracle.truffle.r.runtime.RError;
import com.oracle.truffle.r.runtime.RRuntime;
import com.oracle.truffle.r.runtime.RType;
import com.oracle.truffle.r.runtime.data.RDataFactory;
import com.oracle.truffle.r.runtime.data.REmpty;
import com.oracle.truffle.r.runtime.data.RMissing;
import com.oracle.truffle.r.runtime.data.RTypedValue;
import com.oracle.truffle.r.runtime.data.model.RAbstractContainer;
......@@ -52,6 +53,7 @@ abstract class PositionCheckNode extends Node {
protected final int numDimensions;
private final VectorLengthProfile positionLengthProfile = VectorLengthProfile.create();
private final ConditionProfile nullDimensionsProfile = ConditionProfile.createBinaryProfile();
private final ValueProfile positionClassProfile = ValueProfile.createClassProfile();
protected final BranchProfile error = BranchProfile.create();
protected final boolean replace;
protected final RType containerType;
......@@ -277,4 +279,12 @@ abstract class PositionCheckNode extends Node {
}
public boolean isEmptyPosition(Object position) {
if (positionClass == REmpty.class) {
return false;
}
Object castPosition = positionClassProfile.profile(position);
return castPosition instanceof RAbstractContainer && ((RAbstractContainer) castPosition).getLength() == 0;
}
}
......@@ -100,9 +100,7 @@ abstract class PositionCheckSubscriptNode extends PositionCheckNode {
}
assert positionLength == 1;
positionNACheck.enable(position);
RAbstractVector result = doIntegerImpl(profile, dimSize, position.getDataAt(0), position, getNamesNode);
return result;
return doIntegerImpl(profile, dimSize, position.getDataAt(0), position, getNamesNode);
}
private RAbstractVector doIntegerImpl(PositionProfile profile, int dimSize, int value, RAbstractVector originalVector, GetNamesAttributeNode getNamesNode) {
......
......@@ -194,4 +194,8 @@ final class PositionsCheckNode extends Node {
boolean containsNA;
}
public boolean isEmptyPosition(int i, Object position) {
return positionsCheck[i].isEmptyPosition(position);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment