Skip to content
Snippets Groups Projects
Commit 023fa976 authored by Zbynek Slajchrt's avatar Zbynek Slajchrt
Browse files

several inlining issues fixed

parent d769de52
No related branches found
No related tags found
No related merge requests found
......@@ -387,9 +387,10 @@ public abstract class Bind extends RBaseNode {
}
protected int[] getDimensions(RAbstractVector vector) {
int[] dimensions = getVectorDimensions(vector);
RAbstractVector vectorProfiled = vectorProfile.profile(vector);
int[] dimensions = getVectorDimensions(vectorProfiled);
if (dimensions == null || dimensions.length != 2) {
return type == BindType.cbind ? new int[]{vector.getLength(), 1} : new int[]{1, vector.getLength()};
return type == BindType.cbind ? new int[]{vectorProfiled.getLength(), 1} : new int[]{1, vectorProfiled.getLength()};
} else {
assert dimensions.length == 2;
return dimensions;
......@@ -493,7 +494,8 @@ public abstract class Bind extends RBaseNode {
int[] resultDimensions = new int[2];
int[] secondDims = new int[vectors.length];
boolean notEqualRows = getResultDimensions(vectors, resultDimensions, secondDims);
RVector<?> result = resultProfile.profile(vectors[0].createEmptySameType(resultDimensions[0] * resultDimensions[1], complete));
RAbstractVector first = vectorProfile.profile(vectors[0]);
RVector<?> result = resultProfile.profile(first.createEmptySameType(resultDimensions[0] * resultDimensions[1], complete));
int ind = 0;
Object rowDimResultNames = RNull.instance;
......
......@@ -30,7 +30,10 @@ import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.object.Location;
import com.oracle.truffle.api.object.Shape;
import com.oracle.truffle.api.profiles.BranchProfile;
import com.oracle.truffle.api.profiles.ConditionProfile;
import com.oracle.truffle.api.profiles.ValueProfile;
import com.oracle.truffle.r.runtime.data.RAttributable;
import com.oracle.truffle.r.runtime.data.RAttributeStorage;
/**
* This node is responsible for retrieving a value from an arbitrary attribute. It accepts both
......@@ -70,8 +73,17 @@ public abstract class GetAttributeNode extends AttributeAccessNode {
@Specialization
protected Object getAttrFromAttributable(RAttributable x, String name,
@Cached("create()") BranchProfile attrNullProfile) {
DynamicObject attributes = x.getAttributes();
@Cached("create()") BranchProfile attrNullProfile,
@Cached("createBinaryProfile()") ConditionProfile attrStorageProfile,
@Cached("createClassProfile()") ValueProfile xTypeProfile) {
DynamicObject attributes;
if (attrStorageProfile.profile(x instanceof RAttributeStorage)) {
attributes = ((RAttributeStorage) x).getAttributes();
} else {
attributes = xTypeProfile.profile(x).getAttributes();
}
if (attributes == null) {
attrNullProfile.enter();
return null;
......
......@@ -30,9 +30,12 @@ import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.object.Location;
import com.oracle.truffle.api.object.Shape;
import com.oracle.truffle.api.profiles.BranchProfile;
import com.oracle.truffle.api.profiles.ConditionProfile;
import com.oracle.truffle.api.profiles.ValueProfile;
import com.oracle.truffle.r.nodes.attributes.SpecialAttributesFunctions.GetDimAttributeNode;
import com.oracle.truffle.r.runtime.RRuntime;
import com.oracle.truffle.r.runtime.data.RAttributable;
import com.oracle.truffle.r.runtime.data.RAttributeStorage;
/**
* This node is responsible for retrieving a value from the predefined (fixed) attribute. It accepts
......@@ -88,8 +91,17 @@ public abstract class GetFixedAttributeNode extends FixedAttributeAccessNode {
@Specialization
protected Object getAttrFromAttributable(RAttributable x,
@Cached("create()") BranchProfile attrNullProfile) {
DynamicObject attributes = x.getAttributes();
@Cached("create()") BranchProfile attrNullProfile,
@Cached("createBinaryProfile()") ConditionProfile attrStorageProfile,
@Cached("createClassProfile()") ValueProfile xTypeProfile) {
DynamicObject attributes;
if (attrStorageProfile.profile(x instanceof RAttributeStorage)) {
attributes = ((RAttributeStorage) x).getAttributes();
} else {
attributes = xTypeProfile.profile(x).getAttributes();
}
if (attributes == null) {
attrNullProfile.enter();
return null;
......
......@@ -30,9 +30,12 @@ import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.object.Location;
import com.oracle.truffle.api.object.Shape;
import com.oracle.truffle.api.profiles.BranchProfile;
import com.oracle.truffle.api.profiles.ConditionProfile;
import com.oracle.truffle.api.profiles.ValueProfile;
import com.oracle.truffle.r.nodes.attributes.SpecialAttributesFunctions.GetDimAttributeNode;
import com.oracle.truffle.r.runtime.RRuntime;
import com.oracle.truffle.r.runtime.data.RAttributable;
import com.oracle.truffle.r.runtime.data.RAttributeStorage;
/**
* This node is responsible for determining the existence of the predefined (fixed) attribute. It
......@@ -80,8 +83,17 @@ public abstract class HasFixedAttributeNode extends FixedAttributeAccessNode {
@Specialization
protected boolean hasAttrFromAttributable(RAttributable x,
@Cached("create()") BranchProfile attrNullProfile) {
DynamicObject attributes = x.getAttributes();
@Cached("create()") BranchProfile attrNullProfile,
@Cached("createBinaryProfile()") ConditionProfile attrStorageProfile,
@Cached("createClassProfile()") ValueProfile xTypeProfile) {
DynamicObject attributes;
if (attrStorageProfile.profile(x instanceof RAttributeStorage)) {
attributes = ((RAttributeStorage) x).getAttributes();
} else {
attributes = xTypeProfile.profile(x).getAttributes();
}
if (attributes == null) {
attrNullProfile.enter();
return false;
......
......@@ -202,7 +202,8 @@ public final class SpecialAttributesFunctions {
}
@Specialization
protected void setNamesInContainer(RAbstractContainer x, RStringVector names, @Cached("createClassProfile()") ValueProfile contClassProfile) {
protected void setNamesInContainer(RAbstractContainer x, RStringVector names,
@Cached("createClassProfile()") ValueProfile contClassProfile) {
RAbstractContainer xProfiled = contClassProfile.profile(x);
xProfiled.setNames(names);
}
......@@ -215,16 +216,30 @@ public final class SpecialAttributesFunctions {
}
@Specialization
protected void setOneDimInContainer(RAbstractContainer x, Integer dim, @Cached("createClassProfile()") ValueProfile contClassProfile) {
RAbstractContainer xProfiled = contClassProfile.profile(x);
// xProfiled.setDimensions(new int[]{dim});
xProfiled.setAttr(RRuntime.DIM_ATTR_KEY, new int[]{dim});
protected void setOneDimInContainer(RAbstractContainer x, Integer dim,
@Cached("createClassProfile()") ValueProfile contClassProfile,
@Cached("createBinaryProfile()") ConditionProfile vectorProfile) {
int[] dims = new int[]{dim};
if (vectorProfile.profile(x instanceof RVector)) {
((RVector<?>) x).setDimensions(dims);
} else {
RAbstractContainer xProfiled = contClassProfile.profile(x);
xProfiled.setDimensions(dims);
}
}
@Specialization
protected void setDimsInContainer(RAbstractContainer x, RAbstractIntVector dims, @Cached("createClassProfile()") ValueProfile contClassProfile) {
RAbstractContainer xProfiled = contClassProfile.profile(x);
xProfiled.setDimensions(dims.materialize().getDataCopy());
protected void setDimsInContainer(RAbstractContainer x, RAbstractIntVector dims,
@Cached("createClassProfile()") ValueProfile contClassProfile,
@Cached("createBinaryProfile()") ConditionProfile vectorProfile) {
int[] dimsArr = dims.materialize().getDataCopy();
if (vectorProfile.profile(x instanceof RVector)) {
((RVector<?>) x).setDimensions(dimsArr);
} else {
RAbstractContainer xProfiled = contClassProfile.profile(x);
xProfiled.setDimensions(dimsArr);
}
}
}
......
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