Drop java 11, bump GraalVM to 23.0 (#439)

* Remove unnecessary strictfp modifier
* Add annotations to address Truffle DSL warnings (@Idempotent, @Exclusive)
* Adjust build logic to allow building cross-arch on macOS
* Add warning suppression for specialization limit (left this one as a TODO)
This commit is contained in:
Daniel Chao
2024-04-24 19:17:19 -04:00
committed by GitHub
parent 583dfc6927
commit 3ab9e4184e
55 changed files with 252 additions and 953 deletions

View File

@@ -42,7 +42,7 @@ class MemberRegistryGenerator : AbstractProcessor() {
override fun getSupportedAnnotationTypes(): Set<String> = setOf(GeneratedBy::class.java.name)
override fun getSupportedSourceVersion(): SourceVersion = SourceVersion.RELEASE_11
override fun getSupportedSourceVersion(): SourceVersion = SourceVersion.RELEASE_17
override fun process(annotations: Set<TypeElement>, roundEnv: RoundEnvironment): Boolean {
if (annotations.isEmpty()) return true

View File

@@ -22,7 +22,7 @@ import org.pkl.core.util.MathUtils;
import org.pkl.core.util.Nullable;
/** Java representation of a {@code pkl.base#DataSize} value. */
public final strictfp class DataSize implements Value {
public final class DataSize implements Value {
private static final long serialVersionUID = 0L;
private final double value;

View File

@@ -21,7 +21,7 @@ import org.pkl.core.util.Nullable;
* The unit of a {@link DataSize}. In Pkl, data size units are represented as String {@link
* #getSymbol() symbols}.
*/
public strictfp enum DataSizeUnit {
public enum DataSizeUnit {
BYTES(1, "b"),
KILOBYTES(1000, "kb"),
KIBIBYTES(1024, "kib"),

View File

@@ -22,7 +22,7 @@ import org.pkl.core.util.DurationUtils;
import org.pkl.core.util.Nullable;
/** Java representation of a {@code pkl.base#Duration} value. */
public final strictfp class Duration implements Value {
public final class Duration implements Value {
private static final long serialVersionUID = 0L;
private final double value;

View File

@@ -18,6 +18,7 @@ package org.pkl.core.ast.expression.binary;
import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.api.dsl.Cached;
import com.oracle.truffle.api.dsl.Cached.Exclusive;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.nodes.IndirectCallNode;
import com.oracle.truffle.api.nodes.NodeInfo;
@@ -72,7 +73,7 @@ public abstract class SubscriptNode extends BinaryExpressionNode {
@Specialization
protected Object eval(
VmListing listing, long index, @Cached("create()") IndirectCallNode callNode) {
VmListing listing, long index, @Exclusive @Cached("create()") IndirectCallNode callNode) {
var result = VmUtils.readMemberOrNull(listing, index, callNode);
if (result != null) return result;
@@ -85,14 +86,14 @@ public abstract class SubscriptNode extends BinaryExpressionNode {
@Specialization
protected Object eval(
VmMapping mapping, Object key, @Cached("create()") IndirectCallNode callNode) {
VmMapping mapping, Object key, @Exclusive @Cached("create()") IndirectCallNode callNode) {
return readMember(mapping, key, callNode);
}
@Specialization
protected Object eval(
VmDynamic dynamic, Object key, @Cached("create()") IndirectCallNode callNode) {
VmDynamic dynamic, Object key, @Exclusive @Cached("create()") IndirectCallNode callNode) {
return readMember(dynamic, key, callNode);
}

View File

@@ -18,6 +18,7 @@ package org.pkl.core.ast.expression.generator;
import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.api.CompilerDirectives.ValueType;
import com.oracle.truffle.api.dsl.Idempotent;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.source.SourceSection;
import java.util.Arrays;
@@ -46,11 +47,13 @@ public abstract class GeneratorMemberNode extends PklNode {
.build();
}
@Idempotent
protected static boolean isTypedObjectClass(VmClass clazz) {
assert clazz.isInstantiable();
return !(clazz.isListingClass() || clazz.isMappingClass() || clazz.isDynamicClass());
}
@Idempotent
protected boolean checkIsValidTypedProperty(VmClass clazz, ObjectMember member) {
if (member.isLocal() || clazz.hasProperty(member.getName())) return true;

View File

@@ -19,6 +19,7 @@ import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.api.dsl.Cached;
import com.oracle.truffle.api.dsl.Fallback;
import com.oracle.truffle.api.dsl.Idempotent;
import com.oracle.truffle.api.dsl.ImportStatic;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.frame.FrameDescriptor;
@@ -112,7 +113,8 @@ public abstract class GeneratorObjectLiteralNode extends ObjectLiteralNode {
protected Object evalFunction(
VirtualFrame frame,
VmFunction parent,
@Cached("createAmendFunctionNode(frame)") AmendFunctionNode amendFunctionNode) {
@Cached(value = "createAmendFunctionNode(frame)", neverDefault = true)
AmendFunctionNode amendFunctionNode) {
return amendFunctionNode.execute(frame, parent);
}
@@ -164,6 +166,7 @@ public abstract class GeneratorObjectLiteralNode extends ObjectLiteralNode {
throw exceptionBuilder().unreachableCode().build();
}
@Idempotent
protected boolean checkObjectCannotHaveParameters() {
if (parametersDescriptor == null) return true;
@@ -174,6 +177,7 @@ public abstract class GeneratorObjectLiteralNode extends ObjectLiteralNode {
.build();
}
@Idempotent
protected boolean checkListingCannotHaveParameters() {
if (parametersDescriptor == null) return true;
@@ -184,6 +188,7 @@ public abstract class GeneratorObjectLiteralNode extends ObjectLiteralNode {
.build();
}
@Idempotent
protected boolean checkMappingCannotHaveParameters() {
if (parametersDescriptor == null) return true;

View File

@@ -17,6 +17,7 @@ package org.pkl.core.ast.expression.generator;
import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.dsl.Fallback;
import com.oracle.truffle.api.dsl.Idempotent;
import com.oracle.truffle.api.dsl.ImportStatic;
import com.oracle.truffle.api.dsl.Specialization;
import org.pkl.core.ast.member.ObjectMember;
@@ -94,6 +95,7 @@ public abstract class GeneratorPropertyNode extends GeneratorMemberNode {
.build();
}
@Idempotent
protected boolean checkIsValidListingProperty() {
if (member.isLocal() || member.getName() == Identifier.DEFAULT) return true;
@@ -104,6 +106,7 @@ public abstract class GeneratorPropertyNode extends GeneratorMemberNode {
.build();
}
@Idempotent
protected boolean checkIsValidMappingProperty() {
if (member.isLocal() || member.getName() == Identifier.DEFAULT) return true;

View File

@@ -94,7 +94,8 @@ public abstract class ConstantEntriesLiteralNode extends SpecializedObjectLitera
protected VmFunction evalFunction(
VirtualFrame frame,
VmFunction parent,
@Cached("createAmendFunctionNode(frame)") AmendFunctionNode amendFunctionNode) {
@Cached(value = "createAmendFunctionNode(frame)", neverDefault = true)
AmendFunctionNode amendFunctionNode) {
return amendFunctionNode.execute(frame, parent);
}

View File

@@ -114,7 +114,8 @@ public abstract class ElementsEntriesLiteralNode extends SpecializedObjectLitera
protected VmFunction evalFunction(
VirtualFrame frame,
VmFunction parent,
@Cached("createAmendFunctionNode(frame)") AmendFunctionNode amendFunctionNode) {
@Cached(value = "createAmendFunctionNode(frame)", neverDefault = true)
AmendFunctionNode amendFunctionNode) {
return amendFunctionNode.execute(frame, parent);
}

View File

@@ -104,7 +104,8 @@ public abstract class ElementsLiteralNode extends SpecializedObjectLiteralNode {
protected VmFunction evalFunction(
VirtualFrame frame,
VmFunction parent,
@Cached("createAmendFunctionNode(frame)") AmendFunctionNode amendFunctionNode) {
@Cached(value = "createAmendFunctionNode(frame)", neverDefault = true)
AmendFunctionNode amendFunctionNode) {
return amendFunctionNode.execute(frame, parent);
}
@@ -118,7 +119,8 @@ public abstract class ElementsLiteralNode extends SpecializedObjectLiteralNode {
protected VmListing evalListingClass(
VirtualFrame frame,
@SuppressWarnings("unused") VmClass parent,
@Cached("createMembers(0)") UnmodifiableEconomicMap<Object, ObjectMember> members) {
@Cached(value = "createMembers(0)", neverDefault = true)
UnmodifiableEconomicMap<Object, ObjectMember> members) {
return new VmListing(
frame.materialize(), BaseModule.getListingClass().getPrototype(), members, elements.length);
@@ -128,7 +130,8 @@ public abstract class ElementsLiteralNode extends SpecializedObjectLiteralNode {
protected VmDynamic evalDynamicClass(
VirtualFrame frame,
@SuppressWarnings("unused") VmClass parent,
@Cached("createMembers(0)") UnmodifiableEconomicMap<Object, ObjectMember> members) {
@Cached(value = "createMembers(0)", neverDefault = true)
UnmodifiableEconomicMap<Object, ObjectMember> members) {
return new VmDynamic(
frame.materialize(), BaseModule.getDynamicClass().getPrototype(), members, elements.length);
}

View File

@@ -116,7 +116,8 @@ public abstract class EntriesLiteralNode extends SpecializedObjectLiteralNode {
protected VmFunction evalFunction(
VirtualFrame frame,
VmFunction parent,
@Cached("createAmendFunctionNode(frame)") AmendFunctionNode amendFunctionNode) {
@Cached(value = "createAmendFunctionNode(frame)", neverDefault = true)
AmendFunctionNode amendFunctionNode) {
return amendFunctionNode.execute(frame, parent);
}

View File

@@ -16,6 +16,7 @@
package org.pkl.core.ast.expression.literal;
import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.dsl.Idempotent;
import com.oracle.truffle.api.dsl.NodeChild;
import com.oracle.truffle.api.frame.FrameDescriptor;
import com.oracle.truffle.api.frame.VirtualFrame;
@@ -68,6 +69,7 @@ public abstract class ObjectLiteralNode extends ExpressionNode {
return new AmendFunctionNode(this, resolvedParameterTypes, frame.getFrameDescriptor());
}
@Idempotent
protected static boolean isTypedObjectClass(VmClass clazz) {
return !(clazz.isListingClass() || clazz.isMappingClass() || clazz.isDynamicClass());
}

View File

@@ -115,7 +115,8 @@ public abstract class PropertiesLiteralNode extends SpecializedObjectLiteralNode
protected VmFunction evalFunction(
VirtualFrame frame,
VmFunction parent,
@Cached("createAmendFunctionNode(frame)") AmendFunctionNode amendFunctionNode) {
@Cached(value = "createAmendFunctionNode(frame)", neverDefault = true)
AmendFunctionNode amendFunctionNode) {
return amendFunctionNode.execute(frame, parent);
}

View File

@@ -18,6 +18,7 @@ package org.pkl.core.ast.expression.literal;
import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.CompilerDirectives.CompilationFinal;
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.api.dsl.Idempotent;
import com.oracle.truffle.api.frame.FrameDescriptor;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.nodes.ExplodeLoop;
@@ -67,6 +68,7 @@ public abstract class SpecializedObjectLiteralNode extends ObjectLiteralNode {
// only runs once per VmClass (which often means once per PropertiesLiteralNode)
// unless an XYZUncached specialization is active
@TruffleBoundary
@Idempotent
protected boolean checkIsValidTypedAmendment(Object parent) {
var parentClass = parent instanceof VmClass ? (VmClass) parent : VmUtils.getClass(parent);
VmUtils.checkIsInstantiable(parentClass, getParentNode());
@@ -110,7 +112,9 @@ public abstract class SpecializedObjectLiteralNode extends ObjectLiteralNode {
return true;
}
@SuppressWarnings("SameReturnValue")
@TruffleBoundary
@Idempotent
protected final boolean checkIsValidListingAmendment() {
if (maxListingMemberIndex != Long.MIN_VALUE) return true;
@@ -161,7 +165,9 @@ public abstract class SpecializedObjectLiteralNode extends ObjectLiteralNode {
return true;
}
@SuppressWarnings("SameReturnValue")
@TruffleBoundary
@Idempotent
protected final boolean checkIsValidMappingAmendment() {
if (checkedIsValidMappingAmendment) return true;
@@ -190,6 +196,7 @@ public abstract class SpecializedObjectLiteralNode extends ObjectLiteralNode {
return true;
}
@Idempotent
protected final boolean checkMaxListingMemberIndex(int parentLength) {
assert maxListingMemberIndex != Long.MIN_VALUE;
if (maxListingMemberIndex < parentLength) return true;

View File

@@ -18,6 +18,7 @@ package org.pkl.core.ast.expression.member;
import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.RootCallTarget;
import com.oracle.truffle.api.dsl.Cached;
import com.oracle.truffle.api.dsl.Cached.Exclusive;
import com.oracle.truffle.api.dsl.ImportStatic;
import com.oracle.truffle.api.dsl.NodeChild;
import com.oracle.truffle.api.dsl.Specialization;
@@ -100,7 +101,7 @@ public abstract class InvokeMethodVirtualNode extends ExpressionNode {
VirtualFrame frame,
VmFunction receiver,
@SuppressWarnings("unused") VmClass receiverClass,
@Cached("create()") IndirectCallNode callNode) {
@Exclusive @Cached("create()") IndirectCallNode callNode) {
var args = new Object[2 + argumentNodes.length];
args[0] = receiver.getThisValue();
@@ -138,7 +139,7 @@ public abstract class InvokeMethodVirtualNode extends ExpressionNode {
VirtualFrame frame,
Object receiver,
VmClass receiverClass,
@Cached("create()") IndirectCallNode callNode) {
@Exclusive @Cached("create()") IndirectCallNode callNode) {
var method = resolveMethod(receiverClass);
var args = new Object[2 + argumentNodes.length];

View File

@@ -51,7 +51,7 @@ public abstract class InvokeSuperMethodNode extends ExpressionNode {
@Specialization
protected Object eval(
VirtualFrame frame,
@Cached("findSupermethod(frame)") ClassMethod supermethod,
@Cached(value = "findSupermethod(frame)", neverDefault = true) ClassMethod supermethod,
@Cached("create(supermethod.getCallTarget(sourceSection))") DirectCallNode callNode) {
var args = new Object[2 + argumentNodes.length];

View File

@@ -60,7 +60,8 @@ public abstract class ToStringNode extends UnaryExpressionNode {
protected String evalTyped(
VirtualFrame frame,
VmTyped value,
@Cached("createInvokeNode()") InvokeMethodVirtualNode invokeNode) {
@Cached(value = "createInvokeNode()", neverDefault = true)
InvokeMethodVirtualNode invokeNode) {
return (String) invokeNode.executeWith(frame, value, value.getVmClass());
}

View File

@@ -59,7 +59,7 @@ public abstract class TypeConstraintNode extends PklNode {
protected void eval(
VirtualFrame frame,
VmFunction function,
@Cached("createApplyNode()") ApplyVmFunction1Node applyNode) {
@Cached(value = "createApplyNode()", neverDefault = true) ApplyVmFunction1Node applyNode) {
initConstraintSlot(frame);
var value = frame.getAuxiliarySlot(customThisSlot);

View File

@@ -17,6 +17,7 @@ package org.pkl.core.runtime;
import com.oracle.truffle.api.CompilerDirectives.CompilationFinal;
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.api.dsl.Idempotent;
import com.oracle.truffle.api.frame.FrameDescriptor;
import com.oracle.truffle.api.source.SourceSection;
import java.util.*;
@@ -343,79 +344,98 @@ public final class VmClass extends VmValue {
return prototype;
}
@Idempotent
public boolean isAbstract() {
return VmModifier.isAbstract(modifiers);
}
@Idempotent
public boolean isExternal() {
return VmModifier.isExternal(modifiers);
}
@Idempotent
public boolean isOpen() {
return VmModifier.isOpen(modifiers);
}
@Idempotent
public boolean isClosed() {
return VmModifier.isClosed(modifiers);
}
@Idempotent
public boolean isInstantiable() {
return VmModifier.isInstantiable(modifiers);
}
@Idempotent
public boolean isNullClass() {
return isClass(BaseModule.getNullClass(), "pkl.base#Null");
}
@Idempotent
public boolean isCollectionClass() {
return isClass(BaseModule.getCollectionClass(), "pkl.base#Collection");
}
@Idempotent
public boolean isListClass() {
return isClass(BaseModule.getListClass(), "pkl.base#List");
}
@Idempotent
public boolean isSetClass() {
return isClass(BaseModule.getSetClass(), "pkl.base#Set");
}
@Idempotent
public boolean isMapClass() {
return isClass(BaseModule.getMapClass(), "pkl.base#Map");
}
@Idempotent
public boolean isListingClass() {
return isClass(BaseModule.getListingClass(), "pkl.base#Listing");
}
@Idempotent
public boolean isMappingClass() {
return isClass(BaseModule.getMappingClass(), "pkl.base#Mapping");
}
@Idempotent
public boolean isDynamicClass() {
return isClass(BaseModule.getDynamicClass(), "pkl.base#Dynamic");
}
@Idempotent
public boolean isPairClass() {
return isClass(BaseModule.getPairClass(), "pkl.base#Pair");
}
@Idempotent
public boolean isFunctionClass() {
return isClass(BaseModule.getFunctionClass(), "pkl.base#Function");
}
@Idempotent
public boolean isFunctionNClass() {
return superclass != null
&& superclass.isClass(BaseModule.getFunctionClass(), "pkl.base#Function");
}
@Idempotent
public boolean isModuleClass() {
return isClass(BaseModule.getModuleClass(), "pkl.base#Module");
}
@Idempotent
public boolean isClassClass() {
return isClass(BaseModule.getClassClass(), "pkl.base#Class");
}
@Idempotent
public boolean isVarArgsClass() {
return isClass(BaseModule.getVarArgsClass(), "pkl.base#VarArgs");
}

View File

@@ -26,7 +26,7 @@ import org.pkl.core.util.MathUtils;
import org.pkl.core.util.Nullable;
@ValueType
public final strictfp class VmDataSize extends VmValue implements Comparable<VmDataSize> {
public final class VmDataSize extends VmValue implements Comparable<VmDataSize> {
private static final Map<Identifier, DataSizeUnit> UNITS =
Map.ofEntries(
entry(Identifier.B, DataSizeUnit.BYTES),

View File

@@ -22,7 +22,7 @@ import org.pkl.core.util.DurationUtils;
import org.pkl.core.util.Nullable;
@ValueType
public final strictfp class VmDuration extends VmValue implements Comparable<VmDuration> {
public final class VmDuration extends VmValue implements Comparable<VmDuration> {
private static final Map<Identifier, DurationUnit> UNITS =
Map.of(
Identifier.NS, DurationUnit.NANOS,

View File

@@ -27,7 +27,7 @@ import org.pkl.core.util.MathUtils;
* optimization by Graal. To control error messages in a single place (namely here),
* [ArithmeticException]s thrown by [java.lang.StrictMath] are caught and rethrown.
*/
public final strictfp class VmSafeMath {
public final class VmSafeMath {
private VmSafeMath() {}
public static long negate(long x) {

View File

@@ -215,7 +215,7 @@ public final class IntNodes {
}
}
public abstract static strictfp class toFloat extends ExternalMethod0Node {
public abstract static class toFloat extends ExternalMethod0Node {
@Specialization
protected double eval(long self) {
return self;

View File

@@ -24,7 +24,6 @@ import org.pkl.core.stdlib.ExternalPropertyNode;
import org.pkl.core.util.MathUtils;
// implementation notes:
// make sure to use strictfp for all fp operations
// according to graal folks, it shouldn't be necessary to put
// java.lang.Math calls behind a @TruffleBoundary, and doing so
// could prevent Graal from applying its java.lang.Math intrinsics
@@ -202,7 +201,7 @@ public final class MathNodes {
}
}
public abstract static strictfp class log2 extends ExternalMethod1Node {
public abstract static class log2 extends ExternalMethod1Node {
@Specialization
protected double eval(VmTyped self, long x) {
// based on com.google.common.math.DoubleMath.log2, but uses StrictMath
@@ -311,7 +310,7 @@ public final class MathNodes {
}
}
public abstract static strictfp class lcm extends ExternalMethod2Node {
public abstract static class lcm extends ExternalMethod2Node {
@TruffleBoundary
@Specialization
protected long eval(VmTyped self, long x, long y) {

View File

@@ -17,7 +17,7 @@ package org.pkl.core.util;
import org.pkl.core.DurationUnit;
public final strictfp class DurationUtils {
public final class DurationUtils {
private DurationUtils() {}
public static String toPklString(double value, DurationUnit unit) {

View File

@@ -18,7 +18,7 @@ package org.pkl.core.util;
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import java.math.RoundingMode;
public final strictfp class MathUtils {
public final class MathUtils {
private static final long FLOOR_SQRT_MAX_LONG = 3037000499L;
// The mask for the significand, according to the {@link