Skip to content

Commit 7af15c0

Browse files
committed
[GR-66839] Deprecate Location#isFinal as it always returns false
1 parent b5d1007 commit 7af15c0

File tree

7 files changed

+8
-39
lines changed

7 files changed

+8
-39
lines changed

truffle/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ This changelog summarizes major changes between Truffle versions relevant to lan
44

55
## Version 26.0
66
* GR-65048: Introduced `InternalResource.OS.UNSUPPORTED` and `InternalResource.CPUArchitecture.UNSUPPORTED` to represent unsupported platforms. Execution on unsupported platforms must be explicitly enabled using the system property `-Dpolyglot.engine.allowUnsupportedPlatform=true`. If this property is not set, calls to `OS.getCurrent()` or `CPUArchitecture.getCurrent()` will throw an `IllegalStateException` when running on an unsupported platform. `InternalResource` implementations should handle the unsupported platform and describe possible steps in the error message on how to proceed.
7+
* GR-66839: Deprecate `Location#isFinal()` as it always returns false.
78

89
## Version 25.0
910
* GR-31495 Added ability to specify language and instrument specific options using `Source.Builder.option(String, String)`. Languages may describe available source options by implementing `TruffleLanguage.getSourceOptionDescriptors()` and `TruffleInstrument.getSourceOptionDescriptors()` respectively.

truffle/src/com.oracle.truffle.api.object/snapshot.sigtest

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ meth public boolean isConstant()
196196
meth public boolean isDeclared()
197197
anno 0 java.lang.Deprecated(boolean forRemoval=false, java.lang.String since="22.2")
198198
meth public boolean isFinal()
199+
anno 0 java.lang.Deprecated(boolean forRemoval=false, java.lang.String since="26.0")
199200
meth public boolean isPrimitive()
200201
meth public boolean isValue()
201202
meth public com.oracle.truffle.api.Assumption getFinalAssumption()

truffle/src/com.oracle.truffle.api.object/src/com/oracle/truffle/api/object/DynamicObjectLibraryImpl.java

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1318,8 +1318,6 @@ protected boolean putImpl(DynamicObject object, Shape cachedShape, Object key, O
13181318
DynamicObjectSupport.grow(object, oldShape, newShape);
13191319
location.setSafe(object, value, guardCondition, true);
13201320
DynamicObjectSupport.setShapeWithStoreFence(object, newShape);
1321-
} else if (location.isFinal()) {
1322-
continue;
13231321
} else {
13241322
location.setSafe(object, value, guardCondition, false);
13251323
}
@@ -1358,8 +1356,6 @@ protected boolean putIntImpl(DynamicObject object, Shape cachedShape, Object key
13581356
DynamicObjectSupport.grow(object, oldShape, newShape);
13591357
location.setIntSafe(object, value, guardCondition, true);
13601358
DynamicObjectSupport.setShapeWithStoreFence(object, newShape);
1361-
} else if (location.isFinal()) {
1362-
continue;
13631359
} else {
13641360
location.setIntSafe(object, value, guardCondition, false);
13651361
}
@@ -1370,8 +1366,6 @@ protected boolean putIntImpl(DynamicObject object, Shape cachedShape, Object key
13701366
DynamicObjectSupport.grow(object, oldShape, newShape);
13711367
location.setLongSafe(object, value, guardCondition, true);
13721368
DynamicObjectSupport.setShapeWithStoreFence(object, newShape);
1373-
} else if (location.isFinal()) {
1374-
continue;
13751369
} else {
13761370
location.setLongSafe(object, value, guardCondition, false);
13771371
}
@@ -1382,8 +1376,6 @@ protected boolean putIntImpl(DynamicObject object, Shape cachedShape, Object key
13821376
DynamicObjectSupport.grow(object, oldShape, newShape);
13831377
location.setDoubleSafe(object, value, guardCondition, true);
13841378
DynamicObjectSupport.setShapeWithStoreFence(object, newShape);
1385-
} else if (location.isFinal()) {
1386-
continue;
13871379
} else {
13881380
location.setDoubleSafe(object, value, guardCondition, false);
13891381
}
@@ -1394,8 +1386,6 @@ protected boolean putIntImpl(DynamicObject object, Shape cachedShape, Object key
13941386
DynamicObjectSupport.grow(object, oldShape, newShape);
13951387
location.setSafe(object, value, guardCondition, true);
13961388
DynamicObjectSupport.setShapeWithStoreFence(object, newShape);
1397-
} else if (location.isFinal()) {
1398-
continue;
13991389
} else {
14001390
location.setSafe(object, value, guardCondition, false);
14011391
}
@@ -1434,8 +1424,6 @@ protected boolean putLongImpl(DynamicObject object, Shape cachedShape, Object ke
14341424
DynamicObjectSupport.grow(object, oldShape, newShape);
14351425
location.setLongSafe(object, value, guardCondition, true);
14361426
DynamicObjectSupport.setShapeWithStoreFence(object, newShape);
1437-
} else if (location.isFinal()) {
1438-
continue;
14391427
} else {
14401428
location.setLongSafe(object, value, guardCondition, false);
14411429
}
@@ -1447,8 +1435,6 @@ protected boolean putLongImpl(DynamicObject object, Shape cachedShape, Object ke
14471435
DynamicObjectSupport.grow(object, oldShape, newShape);
14481436
location.setSafe(object, value, guardCondition, true);
14491437
DynamicObjectSupport.setShapeWithStoreFence(object, newShape);
1450-
} else if (location.isFinal()) {
1451-
continue;
14521438
} else {
14531439
location.setSafe(object, value, guardCondition, false);
14541440
}
@@ -1487,8 +1473,6 @@ protected boolean putDoubleImpl(DynamicObject object, Shape cachedShape, Object
14871473
DynamicObjectSupport.grow(object, oldShape, newShape);
14881474
location.setDoubleSafe(object, value, guardCondition, true);
14891475
DynamicObjectSupport.setShapeWithStoreFence(object, newShape);
1490-
} else if (location.isFinal()) {
1491-
continue;
14921476
} else {
14931477
location.setDoubleSafe(object, value, guardCondition, false);
14941478
}
@@ -1500,8 +1484,6 @@ protected boolean putDoubleImpl(DynamicObject object, Shape cachedShape, Object
15001484
DynamicObjectSupport.grow(object, oldShape, newShape);
15011485
location.setSafe(object, value, guardCondition, true);
15021486
DynamicObjectSupport.setShapeWithStoreFence(object, newShape);
1503-
} else if (location.isFinal()) {
1504-
continue;
15051487
} else {
15061488
location.setSafe(object, value, guardCondition, false);
15071489
}

truffle/src/com.oracle.truffle.api.object/src/com/oracle/truffle/api/object/ExtAllocator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ protected Location locationForValueUpcast(Object value, Location oldLocation, in
379379
}
380380

381381
// Object-typed locations should be able to store all values and therefore not reach here.
382-
assert !oldLocation.isFinal() && !(oldLocation instanceof AbstractObjectLocation) : oldLocation;
382+
assert !(oldLocation instanceof AbstractObjectLocation) : oldLocation;
383383
final boolean decorateFinal = false;
384384
Location newLocation = null;
385385
// if shape is shared, transition to an untyped location directly

truffle/src/com.oracle.truffle.api.object/src/com/oracle/truffle/api/object/Location.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,11 @@ public boolean canStore(Object value) {
205205
/**
206206
* Returns {@code true} if this is a final location, i.e. readonly once set.
207207
*
208+
* @see #isAssumedFinal()
208209
* @since 0.8 or earlier
210+
* @deprecated Use {@link #isAssumedFinal()} instead or replace by {@code false}.
209211
*/
212+
@Deprecated(since = "26.0")
210213
public boolean isFinal() {
211214
return false;
212215
}

truffle/src/com.oracle.truffle.api.object/src/com/oracle/truffle/api/object/LocationImpl.java

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -179,22 +179,14 @@ protected boolean canStoreFinal(DynamicObject store, Object value) {
179179
return true;
180180
}
181181

182-
@Override
183-
public boolean isFinal() {
184-
return false;
185-
}
186-
187182
@Override
188183
public boolean isConstant() {
189184
return false;
190185
}
191186

192187
@Override
193188
public int hashCode() {
194-
final int prime = 31;
195-
int result = 1;
196-
result = prime * result + (isFinal() ? 1231 : 1237);
197-
return result;
189+
return 1;
198190
}
199191

200192
@Override
@@ -213,9 +205,8 @@ public boolean equals(Object obj) {
213205

214206
@Override
215207
public String toString() {
216-
String finalString = isFinal() ? "f" : "";
217208
String typeString = Objects.requireNonNullElse(getType(), Object.class).getSimpleName();
218-
return finalString + typeString + getWhereString();
209+
return typeString + getWhereString();
219210
}
220211

221212
protected String getWhereString() {

truffle/src/com.oracle.truffle.api.object/src/com/oracle/truffle/api/object/Obsolescence.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -220,15 +220,6 @@ protected static boolean isLocationEquivalent(Location thisLoc, Location otherLo
220220
}
221221

222222
protected static boolean isLocationAssignableFrom(LayoutImpl layout, Location destination, Location source) {
223-
if (destination.isFinal()) {
224-
// allowed Final<X>Location => Final<X>Location
225-
// allowed FinalIntLocation => Final{Int,Double}Location
226-
// allowed: Final{Int,Double,TypedObject}Location => FinalObjectLocation
227-
if (!source.isFinal()) {
228-
return false;
229-
}
230-
}
231-
232223
if (destination instanceof IntLocation) {
233224
return (source instanceof IntLocation);
234225
} else if (destination instanceof DoubleLocation) {

0 commit comments

Comments
 (0)