Skip to content

Commit 39486ec

Browse files
committed
[GR-22265] RList - R vectors should use "storage strategy" pattern.
PullRequest: fastr/2410
2 parents 83d4df2 + e3aa848 commit 39486ec

File tree

25 files changed

+669
-974
lines changed

25 files changed

+669
-974
lines changed

com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/fastrGrid/ViewPort.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,10 +164,9 @@ public RList execute(VirtualFrame frame) {
164164

165165
GridDevice device = GridContext.getContext().getCurrentDevice();
166166
// TODO: properly set the scale according to the current device
167-
Object[] data = topVP.getDataWithoutCopying();
168-
data[ViewPort.VP_XSCALE] = RDataFactory.createDoubleVector(new double[]{0, device.getNativeWidth()}, RDataFactory.COMPLETE_VECTOR);
169-
data[ViewPort.VP_YSCALE] = RDataFactory.createDoubleVector(new double[]{device.getNativeHeight(), 0}, RDataFactory.COMPLETE_VECTOR);
170-
data[ViewPort.PVP_GPAR] = GridContext.getContext().getGridState().getGpar();
167+
topVP.setDataAt(ViewPort.VP_XSCALE, RDataFactory.createDoubleVector(new double[]{0, device.getNativeWidth()}, RDataFactory.COMPLETE_VECTOR));
168+
topVP.setDataAt(ViewPort.VP_YSCALE, RDataFactory.createDoubleVector(new double[]{device.getNativeHeight(), 0}, RDataFactory.COMPLETE_VECTOR));
169+
topVP.setDataAt(ViewPort.PVP_GPAR, GridContext.getContext().getGridState().getGpar());
171170
return DoSetViewPort.doSetViewPort(topVP, false, true);
172171
}
173172
}

com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Combine.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ private static Object combineRecursive(RArgsValuesAndNames args, Combine recursi
241241
for (int i = 0; i < argsArray.length; i++) {
242242
Object arg = argsArray[i];
243243
if (arg instanceof RList) {
244-
Object[] argsFromList = ((RList) arg).getDataWithoutCopying();
244+
Object[] argsFromList = ((RList) arg).getReadonlyData();
245245
newArgsArray[i] = recursiveCombine.executeCombine(new RArgsValuesAndNames(argsFromList,
246246
ArgumentsSignature.empty(argsFromList.length)), true);
247247
useNewArgs = true;

com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/CachedReplaceVectorNode.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@
5858
import com.oracle.truffle.r.runtime.data.RList;
5959
import com.oracle.truffle.r.runtime.data.RMissing;
6060
import com.oracle.truffle.r.runtime.data.RNull;
61-
import com.oracle.truffle.r.runtime.data.RScalarList;
6261
import com.oracle.truffle.r.runtime.data.RScalarVector;
6362
import com.oracle.truffle.r.runtime.data.RSharingAttributeStorage;
6463
import com.oracle.truffle.r.runtime.data.RStringVector;
@@ -200,7 +199,7 @@ public Object apply(RAbstractVector originalVector, Object[] originalPositions,
200199
} else {
201200
if ((castType == RType.List || castType == RType.Expression) && mode.isSubscript() && !isDeleteElements() && !(castValue instanceof RScalarVector)) {
202201
// wrap into a list when
203-
value = RScalarList.valueOf(castValue);
202+
value = RDataFactory.createListFromScalar(castValue);
204203
} else {
205204
value = (RAbstractContainer) castValue;
206205
}

com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/PrecedenceNode.java

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
import com.oracle.truffle.r.runtime.data.RDoubleVector;
4444
import com.oracle.truffle.r.runtime.data.RExpression;
4545
import com.oracle.truffle.r.runtime.data.RExternalPtr;
46-
import com.oracle.truffle.r.runtime.data.RForeignListWrapper;
4746
import com.oracle.truffle.r.runtime.data.RFunction;
4847
import com.oracle.truffle.r.runtime.data.RInteropScalar;
4948
import com.oracle.truffle.r.runtime.data.RPairList;
@@ -180,12 +179,6 @@ protected int doListRecursive(RList val, boolean recursive,
180179
return doListRecursiveInternal(val, precedenceNode, recursive);
181180
}
182181

183-
@Specialization(guards = "recursive")
184-
protected int doListRecursive(RForeignListWrapper val, boolean recursive,
185-
@Cached("createRecursive()") PrecedenceNode precedenceNode) {
186-
return doListRecursiveInternal(val, precedenceNode, recursive);
187-
}
188-
189182
private static int doListRecursiveInternal(RAbstractListVector val, PrecedenceNode precedenceNode, boolean recursive) {
190183
int precedence = -1;
191184
for (int i = 0; i < val.getLength(); i++) {
@@ -215,12 +208,6 @@ protected int doList(RList val, boolean recursive) {
215208
return LIST_PRECEDENCE;
216209
}
217210

218-
@Specialization(guards = "!recursive")
219-
@SuppressWarnings("unused")
220-
protected int doList(RForeignListWrapper val, boolean recursive) {
221-
return LIST_PRECEDENCE;
222-
}
223-
224211
@Specialization(guards = {"!recursive", "!val.isLanguage()"})
225212
@SuppressWarnings("unused")
226213
protected int doPairList(RPairList val, boolean recursive) {

com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RErrorHandling.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -432,10 +432,9 @@ static void signalError(RBaseNode callObj, Message msg, Object... args) {
432432
private static ReturnException gotoExitingHandler(Object cond, Object call, RList entry) throws ReturnException {
433433
REnvironment rho = (REnvironment) entry.getDataAt(ENTRY_TARGET_ENVIR);
434434
RList result = (RList) entry.getDataAt(ENTRY_RETURN_RESULT);
435-
Object[] resultData = result.getDataWithoutCopying();
436-
resultData[RESULT_COND] = cond;
437-
resultData[RESULT_CALL] = call;
438-
resultData[RESULT_HANDLER] = entry.getDataAt(ENTRY_HANDLER);
435+
result.setDataAt(RESULT_COND, cond);
436+
result.setDataAt(RESULT_CALL, call);
437+
result.setDataAt(RESULT_HANDLER, entry.getDataAt(ENTRY_HANDLER));
439438
throw new ReturnException(result, RArguments.getCall(rho.getFrame()));
440439
}
441440

com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/RComplex.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -86,7 +86,7 @@ public RAbstractVector castSafe(RType type, ConditionProfile isNAProfile, boolea
8686
case Character:
8787
return RString.valueOf(RContext.getRRuntimeASTAccess().encodeComplex(this));
8888
case List:
89-
return RScalarList.valueOf(this);
89+
return RDataFactory.createListFromScalar(this);
9090
default:
9191
return null;
9292
}

com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/RDataFactory.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1143,6 +1143,11 @@ public static RList createList() {
11431143
return createList(new Object[0]);
11441144
}
11451145

1146+
public static RList createListFromScalar(Object value) {
1147+
assert value != null;
1148+
return new RList(new Object[]{value});
1149+
}
1150+
11461151
public static RList createList(int n) {
11471152
return createList(createRNullArray(n));
11481153
}

com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/RDoubleForeignObjData.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2020, 2020, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it

com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/RForeignListWrapper.java

Lines changed: 0 additions & 153 deletions
This file was deleted.

0 commit comments

Comments
 (0)