From 3fe1c7f1b493f1cfbab5668bce685dd68be2eb4b Mon Sep 17 00:00:00 2001 From: Roland Schatz Date: Thu, 16 Sep 2021 15:35:34 +0200 Subject: [PATCH] Remove deprecated ReferenceLibrary. --- sulong/CHANGELOG.md | 5 + sulong/mx.sulong/suite.py | 4 +- .../nodes/util/LLVMSameObjectNode.java | 14 +-- .../pointer/CommonPointerLibraries.java | 24 +--- .../pointer/ManagedPointerLibraries.java | 1 - .../pointer/NativePointerLibraries.java | 1 - .../truffle/llvm/spi/ReferenceLibrary.java | 79 ------------ .../interop/DeprecatedPointerCompareTest.java | 119 ------------------ 8 files changed, 8 insertions(+), 239 deletions(-) delete mode 100644 sulong/projects/com.oracle.truffle.llvm.spi/src/com/oracle/truffle/llvm/spi/ReferenceLibrary.java delete mode 100644 sulong/tests/com.oracle.truffle.llvm.tests/src/com/oracle/truffle/llvm/tests/interop/DeprecatedPointerCompareTest.java diff --git a/sulong/CHANGELOG.md b/sulong/CHANGELOG.md index e20d0b6e4915..2da64b36a43e 100644 --- a/sulong/CHANGELOG.md +++ b/sulong/CHANGELOG.md @@ -4,6 +4,11 @@ Changes: * Updated LLVM toolchain to version 12.0.0. +Removals: + +* Removed ReferenceLibrary (deprecated since version 20.2). + Implement InteropLibrary.isIdenticalOrUndefined instead. + # Version 21.2.0 Fixes: diff --git a/sulong/mx.sulong/suite.py b/sulong/mx.sulong/suite.py index 381891132b98..e9829b53129e 100644 --- a/sulong/mx.sulong/suite.py +++ b/sulong/mx.sulong/suite.py @@ -184,8 +184,6 @@ "license" : "BSD-new", "testProject" : True, "jacoco" : "exclude", - # TODO Remove deprecated ReferenceLibrary. [GR-24632] - "javac.lint.overrides" : "-deprecation", }, "com.oracle.truffle.llvm.tests.native" : { "subDir" : "tests", @@ -335,7 +333,7 @@ "workingSets" : "Truffle, LLVM", "license" : "BSD-new", "jacoco" : "include", - # TODO Remove deprecated ReferenceLibrary. [GR-24632] + # Using finalizer in signals implementation. GR-7018 "javac.lint.overrides" : "-deprecation", }, diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/util/LLVMSameObjectNode.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/util/LLVMSameObjectNode.java index 51d13db64b5b..111670460607 100644 --- a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/util/LLVMSameObjectNode.java +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/util/LLVMSameObjectNode.java @@ -48,7 +48,6 @@ * * For foreign objects, this node delegates to the {@link InteropLibrary#isIdentical} message. */ -@SuppressWarnings("deprecation") // for backwards compatibility @GenerateUncached public abstract class LLVMSameObjectNode extends LLVMNode { @@ -112,22 +111,11 @@ boolean doSame(Object a, Object b) { return true; } - // for backwards compatibility - @Specialization(limit = "3", guards = {"a != b", "references.isSame(a, b)"}) - @GenerateAOT.Exclude - boolean doReferenceLibrary(Object a, Object b, - @CachedLibrary("a") com.oracle.truffle.llvm.spi.ReferenceLibrary references) { - assert references.isSame(a, b); - return true; - } - - @Specialization(limit = "3", guards = {"a != b", "!references.isSame(a, b)"}) + @Specialization(limit = "3", guards = {"a != b"}) @GenerateAOT.Exclude boolean doIdentical(Object a, Object b, - @CachedLibrary("a") com.oracle.truffle.llvm.spi.ReferenceLibrary references, @CachedLibrary("a") InteropLibrary aInterop, @CachedLibrary("b") InteropLibrary bInterop) { - assert !references.isSame(a, b); return aInterop.isIdentical(a, b, bInterop); } } diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/pointer/CommonPointerLibraries.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/pointer/CommonPointerLibraries.java index 290ba26b97ba..eeda6062c5d1 100644 --- a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/pointer/CommonPointerLibraries.java +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/pointer/CommonPointerLibraries.java @@ -66,10 +66,7 @@ @ExportLibrary(value = InteropLibrary.class, receiverType = LLVMPointerImpl.class) @ExportLibrary(value = LLVMManagedWriteLibrary.class, receiverType = LLVMPointerImpl.class, useForAOT = true, useForAOTPriority = 1) @ExportLibrary(value = LLVMManagedReadLibrary.class, receiverType = LLVMPointerImpl.class, useForAOT = true, useForAOTPriority = 2) -@ExportLibrary(value = com.oracle.truffle.llvm.spi.ReferenceLibrary.class, receiverType = LLVMPointerImpl.class) -@SuppressWarnings({"static-method", "deprecation"}) - -// implements deprecated ReferenceLibrary for backwards compatibility +@SuppressWarnings({"static-method"}) abstract class CommonPointerLibraries { @ExportMessage static boolean isReadable(@SuppressWarnings("unused") LLVMPointerImpl receiver) { @@ -442,25 +439,6 @@ Object readArrayElement(long idx, } } - @ExportMessage - static class IsSame { - - @Specialization - static boolean doNative(LLVMPointerImpl receiver, LLVMPointerImpl other, - @Cached LLVMAddressEqualsNode.Operation equals) { - return equals.executeWithTarget(receiver, other); - } - - /** - * @param receiver - * @param other - */ - @Fallback - static boolean doOther(LLVMPointerImpl receiver, Object other) { - return false; - } - } - /** * @param receiver * @see InteropLibrary#hasLanguage(Object) diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/pointer/ManagedPointerLibraries.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/pointer/ManagedPointerLibraries.java index 9aa755ff61ad..47a0ad532871 100644 --- a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/pointer/ManagedPointerLibraries.java +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/pointer/ManagedPointerLibraries.java @@ -47,7 +47,6 @@ @ExportLibrary(value = InteropLibrary.class, receiverType = LLVMPointerImpl.class) @ExportLibrary(value = LLVMAsForeignLibrary.class, receiverType = LLVMPointerImpl.class, useForAOT = false) -@SuppressWarnings("deprecation") // needed because the superclass implements ReferenceLibrary abstract class ManagedPointerLibraries extends CommonPointerLibraries { @ExportMessage diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/pointer/NativePointerLibraries.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/pointer/NativePointerLibraries.java index 385ad3a3ee37..046bc682de99 100644 --- a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/pointer/NativePointerLibraries.java +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/pointer/NativePointerLibraries.java @@ -47,7 +47,6 @@ @ExportLibrary(value = InteropLibrary.class, receiverType = LLVMPointerImpl.class) @ExportLibrary(value = LLVMAsForeignLibrary.class, receiverType = LLVMPointerImpl.class, useForAOT = true, useForAOTPriority = 1) -@SuppressWarnings("deprecation") // needed because the superclass implements ReferenceLibrary abstract class NativePointerLibraries extends CommonPointerLibraries { @ExportMessage diff --git a/sulong/projects/com.oracle.truffle.llvm.spi/src/com/oracle/truffle/llvm/spi/ReferenceLibrary.java b/sulong/projects/com.oracle.truffle.llvm.spi/src/com/oracle/truffle/llvm/spi/ReferenceLibrary.java deleted file mode 100644 index 2295ea4b1816..000000000000 --- a/sulong/projects/com.oracle.truffle.llvm.spi/src/com/oracle/truffle/llvm/spi/ReferenceLibrary.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (c) 2019, 2020, Oracle and/or its affiliates. - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions and the following disclaimer in the documentation and/or other materials provided - * with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its contributors may be used to - * endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package com.oracle.truffle.llvm.spi; - -import com.oracle.truffle.api.interop.InteropLibrary; -import com.oracle.truffle.api.library.CachedLibrary; -import com.oracle.truffle.api.library.ExportLibrary; -import com.oracle.truffle.api.library.ExportMessage; -import com.oracle.truffle.api.library.GenerateLibrary; -import com.oracle.truffle.api.library.GenerateLibrary.Abstract; -import com.oracle.truffle.api.library.GenerateLibrary.DefaultExport; -import com.oracle.truffle.api.library.Library; -import com.oracle.truffle.api.library.LibraryFactory; - -/** - * Library for objects that have reference semantics. Pointer equality comparisons will use that - * library to determine if two objects are reference-equals. - * - * @deprecated Implement {@link InteropLibrary#isIdenticalOrUndefined} instead. - */ -@GenerateLibrary -@Deprecated -@DefaultExport(ReferenceLibrary.InteropFallback.class) -@SuppressWarnings("deprecation") -public abstract class ReferenceLibrary extends Library { - - /** - * Check whether two objects are a reference to the same thing. - * - * All implementations of this method must be reflexive, symmetric and transitive. - */ - @Abstract - public abstract boolean isSame(Object receiver, Object other); - - private static final LibraryFactory FACTORY = LibraryFactory.resolve(ReferenceLibrary.class); - - public static LibraryFactory getFactory() { - return FACTORY; - } - - @ExportLibrary(value = ReferenceLibrary.class, receiverType = Object.class) - @SuppressWarnings("deprecation") - static class InteropFallback { - - @ExportMessage - static boolean isSame(Object receiver, Object other, - @CachedLibrary("receiver") InteropLibrary receiverInterop, - @CachedLibrary(limit = "3") InteropLibrary otherInterop) { - return receiverInterop.isIdentical(receiver, other, otherInterop); - } - } -} diff --git a/sulong/tests/com.oracle.truffle.llvm.tests/src/com/oracle/truffle/llvm/tests/interop/DeprecatedPointerCompareTest.java b/sulong/tests/com.oracle.truffle.llvm.tests/src/com/oracle/truffle/llvm/tests/interop/DeprecatedPointerCompareTest.java deleted file mode 100644 index a752c58f8fc5..000000000000 --- a/sulong/tests/com.oracle.truffle.llvm.tests/src/com/oracle/truffle/llvm/tests/interop/DeprecatedPointerCompareTest.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Copyright (c) 2020, 2021, Oracle and/or its affiliates. - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions and the following disclaimer in the documentation and/or other materials provided - * with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its contributors may be used to - * endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package com.oracle.truffle.llvm.tests.interop; - -import com.oracle.truffle.api.CompilerDirectives; -import com.oracle.truffle.api.dsl.Fallback; -import com.oracle.truffle.api.dsl.Specialization; -import com.oracle.truffle.api.interop.InteropException; -import com.oracle.truffle.api.interop.InteropLibrary; -import com.oracle.truffle.api.interop.TruffleObject; -import com.oracle.truffle.api.library.ExportLibrary; -import com.oracle.truffle.api.library.ExportMessage; -import com.oracle.truffle.llvm.tests.interop.values.NativeValue; -import com.oracle.truffle.tck.TruffleRunner; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; - -@RunWith(TruffleRunner.class) -@SuppressWarnings("deprecation") // tests backwards compatibility to deprecated ReferenceLibrary -public class DeprecatedPointerCompareTest extends InteropTestBase { - - static final InteropLibrary INTEROP = InteropLibrary.getUncached(); - static final com.oracle.truffle.llvm.spi.ReferenceLibrary REFERENCES = com.oracle.truffle.llvm.spi.ReferenceLibrary.getFactory().getUncached(); - - static Object testPointerAdd; - - @BeforeClass - public static void loadLibrary() throws InteropException { - Object testLibrary = loadTestBitcodeInternal("pointerArithmetic.c"); - testPointerAdd = INTEROP.readMember(testLibrary, "test_pointer_add"); - } - - @ExportLibrary(com.oracle.truffle.llvm.spi.ReferenceLibrary.class) - @ExportLibrary(InteropLibrary.class) - @SuppressWarnings("deprecation") // tests backwards compatibility to deprecated ReferenceLibrary - static class ReferenceEqualObject implements TruffleObject { - - final int identity; - - ReferenceEqualObject(int identity) { - this.identity = identity; - } - - @ExportMessage - static class IsSame { - - @Specialization - static boolean doCompare(ReferenceEqualObject self, ReferenceEqualObject other) { - return self.identity == other.identity; - } - - @Fallback - static boolean doOther(@SuppressWarnings("unused") ReferenceEqualObject self, Object other) { - assert !(other instanceof ReferenceEqualObject); - return false; - } - } - - @ExportMessage - void toNative() { - CompilerDirectives.shouldNotReachHere("unexpected toNative"); - } - } - - private static Object ptr(long v) { - return new NativeValue(v); - } - - @Test - public void testIdenticalObject() throws InteropException { - Object ptr1 = INTEROP.execute(testPointerAdd, new ReferenceEqualObject(1), ptr(42)); - Object ptr2 = INTEROP.execute(testPointerAdd, new ReferenceEqualObject(1), ptr(42)); - Assert.assertTrue("equals", REFERENCES.isSame(ptr1, ptr2)); - } - - @Test - public void testSameAndIdenticalObject() throws InteropException { - ReferenceEqualObject obj = new ReferenceEqualObject(2); - Object ptr1 = INTEROP.execute(testPointerAdd, obj, ptr(42)); - Object ptr2 = INTEROP.execute(testPointerAdd, obj, ptr(42)); - Assert.assertTrue("equals", REFERENCES.isSame(ptr1, ptr2)); - } - - @Test - public void testNotIdenticalObject() throws InteropException { - Object ptr1 = INTEROP.execute(testPointerAdd, new ReferenceEqualObject(3), ptr(42)); - Object ptr2 = INTEROP.execute(testPointerAdd, new ReferenceEqualObject(4), ptr(42)); - Assert.assertFalse("!equals", REFERENCES.isSame(ptr1, ptr2)); - } -}