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