diff --git a/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/truffle/test/AbstractSplittingStrategyTest.java b/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/truffle/test/AbstractSplittingStrategyTest.java index f9f37972974e..bc687cd0a94d 100644 --- a/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/truffle/test/AbstractSplittingStrategyTest.java +++ b/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/truffle/test/AbstractSplittingStrategyTest.java @@ -35,13 +35,12 @@ import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.DirectCallNode; import com.oracle.truffle.api.nodes.Node; -import com.oracle.truffle.api.nodes.NodeCost; import com.oracle.truffle.api.nodes.RootNode; import com.oracle.truffle.api.test.ReflectionUtils; -import com.oracle.truffle.runtime.OptimizedTruffleRuntime; -import com.oracle.truffle.runtime.OptimizedTruffleRuntimeListener; import com.oracle.truffle.runtime.OptimizedCallTarget; import com.oracle.truffle.runtime.OptimizedDirectCallNode; +import com.oracle.truffle.runtime.OptimizedTruffleRuntime; +import com.oracle.truffle.runtime.OptimizedTruffleRuntimeListener; public class AbstractSplittingStrategyTest extends TestWithPolyglotOptions { @@ -183,10 +182,6 @@ public void onCompilationSplit(OptimizedDirectCallNode callNode) { static class DummyRootNode extends RootNode { @Child private Node polymorphic = new Node() { - @Override - public NodeCost getCost() { - return NodeCost.POLYMORPHIC; - } }; protected DummyRootNode() { diff --git a/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/truffle/test/OptimizedBlockNodeTest.java b/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/truffle/test/OptimizedBlockNodeTest.java index d14f8f7e3e32..f6154726c6a9 100644 --- a/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/truffle/test/OptimizedBlockNodeTest.java +++ b/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/truffle/test/OptimizedBlockNodeTest.java @@ -37,8 +37,6 @@ import java.util.List; import java.util.concurrent.Callable; -import com.oracle.truffle.sl.runtime.SLStrings; -import jdk.graal.compiler.test.SubprocessUtil; import org.graalvm.polyglot.Context; import org.graalvm.polyglot.Value; import org.junit.After; @@ -54,7 +52,6 @@ import com.oracle.truffle.api.nodes.BlockNode; import com.oracle.truffle.api.nodes.BlockNode.ElementExecutor; import com.oracle.truffle.api.nodes.Node; -import com.oracle.truffle.api.nodes.NodeCost; import com.oracle.truffle.api.nodes.NodeVisitor; import com.oracle.truffle.api.nodes.RootNode; import com.oracle.truffle.api.nodes.UnexpectedResultException; @@ -62,9 +59,12 @@ import com.oracle.truffle.api.source.SourceSection; import com.oracle.truffle.api.test.polyglot.ProxyLanguage; import com.oracle.truffle.runtime.OptimizedBlockNode; -import com.oracle.truffle.runtime.OptimizedCallTarget; import com.oracle.truffle.runtime.OptimizedBlockNode.PartialBlocks; +import com.oracle.truffle.runtime.OptimizedCallTarget; import com.oracle.truffle.sl.runtime.SLContext; +import com.oracle.truffle.sl.runtime.SLStrings; + +import jdk.graal.compiler.test.SubprocessUtil; public class OptimizedBlockNodeTest { @@ -87,7 +87,7 @@ public void testExactlyBlockSize() { @Test public void testFirstBlockElementExceedsLimit() { setup(1); - OptimizedBlockNode block = createBlock(2, 1, null, new TestElementExecutor(), 5); + OptimizedBlockNode block = createBlock(2, 1, null, new TestElementExecutor()); OptimizedCallTarget target = createTest(block); target.computeBlockCompilations(); target.call(); @@ -367,7 +367,7 @@ public void testStartsWithCompilation() { setup(2); - block = createBlock(5, 1, null, new StartsWithExecutor(), 0); + block = createBlock(5, 1, null, new StartsWithExecutor()); target = createTest(block); elementExecuted = ((TestRootNode) block.getRootNode()).elementExecuted; expectedResult = 4; @@ -429,9 +429,12 @@ public void testHierarchicalBlocks() { target.compile(true); partialBlocks = block.getPartialBlocks(); - assertEquals(2, partialBlocks.getBlockTargets().length); - assertEquals(1, partialBlocks.getBlockRanges().length); - assertEquals(3, partialBlocks.getBlockRanges()[0]); + assertEquals(5, partialBlocks.getBlockTargets().length); + assertEquals(4, partialBlocks.getBlockRanges().length); + assertEquals(1, partialBlocks.getBlockRanges()[0]); + assertEquals(2, partialBlocks.getBlockRanges()[1]); + assertEquals(3, partialBlocks.getBlockRanges()[2]); + assertEquals(4, partialBlocks.getBlockRanges()[3]); block = createBlock(5, 3, null); target = createTest(block); @@ -440,9 +443,12 @@ public void testHierarchicalBlocks() { target.compile(true); partialBlocks = block.getPartialBlocks(); - assertEquals(2, partialBlocks.getBlockTargets().length); - assertEquals(1, partialBlocks.getBlockRanges().length); - assertEquals(3, partialBlocks.getBlockRanges()[0]); + assertEquals(5, partialBlocks.getBlockTargets().length); + assertEquals(4, partialBlocks.getBlockRanges().length); + assertEquals(1, partialBlocks.getBlockRanges()[0]); + assertEquals(2, partialBlocks.getBlockRanges()[1]); + assertEquals(3, partialBlocks.getBlockRanges()[2]); + assertEquals(4, partialBlocks.getBlockRanges()[3]); } @Test @@ -460,10 +466,12 @@ public void testHierarchicalUnbalanced() { target.compile(true); partialBlocks = block.getPartialBlocks(); - assertEquals(3, partialBlocks.getBlockTargets().length); - assertEquals(2, partialBlocks.getBlockRanges().length); - assertEquals(4, partialBlocks.getBlockRanges()[0]); - assertEquals(8, partialBlocks.getBlockRanges()[1]); + assertEquals(5, partialBlocks.getBlockTargets().length); + assertEquals(4, partialBlocks.getBlockRanges().length); + assertEquals(2, partialBlocks.getBlockRanges()[0]); + assertEquals(4, partialBlocks.getBlockRanges()[1]); + assertEquals(6, partialBlocks.getBlockRanges()[2]); + assertEquals(8, partialBlocks.getBlockRanges()[3]); } @Test @@ -581,26 +589,16 @@ private static OptimizedBlockNode createBlock(int blockSize, int de } private static OptimizedBlockNode createBlock(int blockSize, int depth, Object returnValue) { - return createBlock(blockSize, depth, returnValue, new TestElementExecutor(), 0); + return createBlock(blockSize, depth, returnValue, new TestElementExecutor()); } - private static OptimizedBlockNode createBlock(int blockSize, int depth, Object returnValue, ElementExecutor executor, int extraChildrenOfFirstElement) { + private static OptimizedBlockNode createBlock(int blockSize, int depth, Object returnValue, ElementExecutor executor) { if (depth == 0) { return null; } TestElement[] elements = new TestElement[blockSize]; for (int i = 0; i < blockSize; i++) { - Node[] extraDummyChildren; - if (i == 0 && extraChildrenOfFirstElement > 0) { - extraDummyChildren = new Node[extraChildrenOfFirstElement]; - for (int j = 0; j < extraDummyChildren.length; j++) { - extraDummyChildren[j] = new Node() { - }; - } - } else { - extraDummyChildren = new Node[0]; - } - elements[i] = new TestElement(createBlock(blockSize, depth - 1, returnValue), returnValue == null ? i : returnValue, i, extraDummyChildren); + elements[i] = new TestElement(createBlock(blockSize, depth - 1, returnValue), returnValue == null ? i : returnValue, i); } return (OptimizedBlockNode) BlockNode.create(elements, executor); } @@ -705,12 +703,6 @@ private void setup(int blockCompilationSize, int maxGraalNodeCount, String... ad static class ElementChildNode extends Node { - @Override - public NodeCost getCost() { - // we don't want this to contribute to node costs - return NodeCost.NONE; - } - } static class StartsWithExecutor extends TestElementExecutor { @@ -756,8 +748,6 @@ public Object executeGeneric(VirtualFrame frame, TestElement node, int index, in static class TestElement extends Node { @Child BlockNode childBlock; - @Child ElementChildNode childNode = new ElementChildNode(); - @Children Node[] extraDummyChildren; final Object returnValue; final int childIndex; @@ -765,11 +755,10 @@ static class TestElement extends Node { @CompilationFinal TestRootNode root; SourceSection sourceSection; - TestElement(BlockNode childBlock, Object returnValue, int childIndex, Node[] extraDummyChildren) { + TestElement(BlockNode childBlock, Object returnValue, int childIndex) { this.childBlock = childBlock; this.returnValue = returnValue; this.childIndex = childIndex; - this.extraDummyChildren = extraDummyChildren; } void onAdopt() { @@ -777,7 +766,7 @@ void onAdopt() { } public void simulateReplace() { - childNode.replace(new ElementChildNode()); + this.replace(this); } public Object execute(VirtualFrame frame) { diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/interop/convert/ForeignToLLVM.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/interop/convert/ForeignToLLVM.java index f973410ac497..2bab6928da88 100644 --- a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/interop/convert/ForeignToLLVM.java +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/interop/convert/ForeignToLLVM.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2023, Oracle and/or its affiliates. + * Copyright (c) 2017, 2024, Oracle and/or its affiliates. * * All rights reserved. * @@ -32,7 +32,7 @@ import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.interop.UnsupportedTypeException; -import com.oracle.truffle.api.nodes.NodeCost; +import com.oracle.truffle.api.nodes.UnadoptableNode; import com.oracle.truffle.api.profiles.BranchProfile; import com.oracle.truffle.llvm.runtime.except.LLVMPolyglotException; import com.oracle.truffle.llvm.runtime.floating.LLVM128BitFloat; @@ -217,7 +217,7 @@ public static SlowPathForeignToLLVM getSlowPath() { return SlowPathForeignToLLVM.INSTANCE; } - public static final class SlowPathForeignToLLVM extends ForeignToLLVM { + public static final class SlowPathForeignToLLVM extends ForeignToLLVM implements UnadoptableNode { private static final SlowPathForeignToLLVM INSTANCE = new SlowPathForeignToLLVM(); @@ -277,14 +277,5 @@ public Object executeWithForeignToLLVMType(Object value, LLVMInteropType.Structu } } - @Override - public boolean isAdoptable() { - return false; - } - - @Override - public NodeCost getCost() { - return NodeCost.MEGAMORPHIC; - } } } diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/api/LLVMFrameNuller.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/api/LLVMFrameNuller.java index b25a1aa27008..213e84ffe863 100644 --- a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/api/LLVMFrameNuller.java +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/api/LLVMFrameNuller.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2021, Oracle and/or its affiliates. + * Copyright (c) 2017, 2024, Oracle and/or its affiliates. * * All rights reserved. * @@ -33,14 +33,11 @@ import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.ExplodeLoop; -import com.oracle.truffle.api.nodes.NodeCost; -import com.oracle.truffle.api.nodes.NodeInfo; import com.oracle.truffle.llvm.runtime.nodes.base.LLVMFrameNullerUtil; /** * Nulls out the given set of frame slots after evaluating the given statement. */ -@NodeInfo(cost = NodeCost.NONE) // this node reduces the compiled code size public abstract class LLVMFrameNuller extends LLVMStatementNode { @CompilationFinal(dimensions = 1) private final int[] frameSlots; diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/api/LLVMFrameNullerExpression.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/api/LLVMFrameNullerExpression.java index 7277a154b23d..927e5530e6d4 100644 --- a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/api/LLVMFrameNullerExpression.java +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/api/LLVMFrameNullerExpression.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2021, Oracle and/or its affiliates. + * Copyright (c) 2017, 2024, Oracle and/or its affiliates. * * All rights reserved. * @@ -33,15 +33,12 @@ import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.ExplodeLoop; -import com.oracle.truffle.api.nodes.NodeCost; -import com.oracle.truffle.api.nodes.NodeInfo; import com.oracle.truffle.api.nodes.UnexpectedResultException; import com.oracle.truffle.llvm.runtime.nodes.base.LLVMFrameNullerUtil; /** * Nulls out the given set of frame slots after evaluating the given expression. */ -@NodeInfo(cost = NodeCost.NONE) // this node reduces the compiled code size public abstract class LLVMFrameNullerExpression extends LLVMExpressionNode { @CompilationFinal(dimensions = 1) private final int[] frameSlots; diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/api/LLVMVoidStatementNode.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/api/LLVMVoidStatementNode.java index e2d42d71ad1b..7abe3ffb1912 100644 --- a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/api/LLVMVoidStatementNode.java +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/api/LLVMVoidStatementNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2019, Oracle and/or its affiliates. + * Copyright (c) 2016, 2024, Oracle and/or its affiliates. * * All rights reserved. * @@ -31,14 +31,11 @@ import com.oracle.truffle.api.dsl.NodeChild; import com.oracle.truffle.api.dsl.Specialization; -import com.oracle.truffle.api.nodes.NodeCost; -import com.oracle.truffle.api.nodes.NodeInfo; /** * This node is used to execute an expression as a statement, discarding the result. */ @NodeChild(value = "value", type = LLVMExpressionNode.class) -@NodeInfo(cost = NodeCost.NONE) public abstract class LLVMVoidStatementNode extends LLVMStatementNode { @Specialization diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/vars/LLVMReadNode.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/vars/LLVMReadNode.java index 73d364897a0f..b9f4736ab2c0 100644 --- a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/vars/LLVMReadNode.java +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/vars/LLVMReadNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2023, Oracle and/or its affiliates. + * Copyright (c) 2016, 2024, Oracle and/or its affiliates. * * All rights reserved. * @@ -38,7 +38,6 @@ import com.oracle.truffle.api.frame.FrameSlotTypeException; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.library.CachedLibrary; -import com.oracle.truffle.api.nodes.NodeCost; import com.oracle.truffle.llvm.runtime.interop.LLVMTypedForeignObject; import com.oracle.truffle.llvm.runtime.interop.access.LLVMInteropType; import com.oracle.truffle.llvm.runtime.library.internal.LLVMAsForeignLibrary; @@ -100,10 +99,6 @@ public final boolean isAdoptable() { return false; } - @Override - public NodeCost getCost() { - return NodeCost.MONOMORPHIC; - } } protected final int slot; diff --git a/tools/src/com.oracle.truffle.tools.profiler/src/com/oracle/truffle/tools/profiler/CPUTracer.java b/tools/src/com.oracle.truffle.tools.profiler/src/com/oracle/truffle/tools/profiler/CPUTracer.java index 415b7d94ab21..a7fe855322cf 100644 --- a/tools/src/com.oracle.truffle.tools.profiler/src/com/oracle/truffle/tools/profiler/CPUTracer.java +++ b/tools/src/com.oracle.truffle.tools.profiler/src/com/oracle/truffle/tools/profiler/CPUTracer.java @@ -47,7 +47,6 @@ import com.oracle.truffle.api.instrumentation.StandardTags.StatementTag; import com.oracle.truffle.api.instrumentation.TruffleInstrument; import com.oracle.truffle.api.instrumentation.TruffleInstrument.Env; -import com.oracle.truffle.api.nodes.NodeCost; import com.oracle.truffle.api.source.SourceSection; import com.oracle.truffle.tools.profiler.impl.CPUTracerInstrument; import com.oracle.truffle.tools.profiler.impl.ProfilerToolFactory; @@ -302,10 +301,6 @@ protected void onEnter(VirtualFrame frame) { } } - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } } static ProfilerToolFactory createFactory() { diff --git a/tools/src/com.oracle.truffle.tools.profiler/src/com/oracle/truffle/tools/profiler/ShadowStack.java b/tools/src/com.oracle.truffle.tools.profiler/src/com/oracle/truffle/tools/profiler/ShadowStack.java index dc12a3821254..a1e2b9727fbc 100644 --- a/tools/src/com.oracle.truffle.tools.profiler/src/com/oracle/truffle/tools/profiler/ShadowStack.java +++ b/tools/src/com.oracle.truffle.tools.profiler/src/com/oracle/truffle/tools/profiler/ShadowStack.java @@ -46,7 +46,6 @@ import com.oracle.truffle.api.instrumentation.SourceSectionFilter; import com.oracle.truffle.api.instrumentation.StandardTags; import com.oracle.truffle.api.nodes.Node; -import com.oracle.truffle.api.nodes.NodeCost; /** * Custom more efficient stack representations for profilers. @@ -226,11 +225,6 @@ private ThreadLocalStack getStack() { return stack; } - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - } final class ThreadLocalStack { diff --git a/truffle/CHANGELOG.md b/truffle/CHANGELOG.md index 28eea69aa815..595e96b743fb 100644 --- a/truffle/CHANGELOG.md +++ b/truffle/CHANGELOG.md @@ -18,6 +18,8 @@ This changelog summarizes major changes between Truffle versions relevant to lan * GR-49484 Deprecated `RootNode.isCaptureFramesForTrace()`. Implementers should use `RootNode.isCaptureFramesForTrace(Node)` instead. * GR-28866 Added `TruffleLanguage.Env.getScopePublic(LanguageInfo)` and `TruffleLanguage.Env.getScopeInternal(LanguageInfo)` to allow languages direct access to other language scopes to implement new polyglot builtins. * GR-28866 Deprecated `TruffleLanguage.Env.isPolyglotEvalAllowed()`. Replace usages with `TruffleLanguage.Env.isPolyglotEvalAllowed(LanguageInfo)`. Please see javadoc for the updated usage. +* GR-52843 Deprecated `Node.getCost()` and the associated `NodeCost` class without replacement. Truffle DSL no longer generates implementations of this method automatically and will therefore always return `NodeCost.MONOMORPHIC` by default. This is intended to reduce the binary footprint. +* GR-52843 Added the `UnadoptableNode` interface. This is interface should be preferred to overriding `Node.isAdoptable()` if the result is statically known. ## Version 24.0.0 diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/NeverDefaultTest.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/NeverDefaultTest.java index 5661a3f6d33b..0386fe9eeae4 100644 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/NeverDefaultTest.java +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/NeverDefaultTest.java @@ -792,8 +792,8 @@ public void testSingleInstanceNodeCacheNode() throws InterruptedException { SingleInstanceNodeCacheNode returnNull = adoptNode(SingleInstanceNodeCacheNodeGen.create()).get(); GuardCacheNode.returnNull = true; assertFails(() -> returnNull.execute(null, 1), NullPointerException.class, (e) -> { - assertEquals("Specialization 's0(int, GuardCacheNode)' cache 'cachedNode' returned a 'null' default value. " + - "The cache initializer must never return a default value for this cache. Use @Cached(neverDefault=false) to allow default values for this cached value or make sure the cache initializer never returns 'null'.", + assertEquals("A specialization cache returned a default value. The cache initializer must never return a default value for this cache. " + + "Use @Cached(neverDefault=false) to allow default values for this cached value or make sure the cache initializer never returns the default value.", e.getMessage()); }); GuardCacheNode.returnNull = false; diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/NodeCostTest.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/NodeCostTest.java deleted file mode 100644 index d10cf8f7cb91..000000000000 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/NodeCostTest.java +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * The Universal Permissive License (UPL), Version 1.0 - * - * Subject to the condition set forth below, permission is hereby granted to any - * person obtaining a copy of this software, associated documentation and/or - * data (collectively the "Software"), free of charge and under any and all - * copyright rights in the Software, and any and all patent rights owned or - * freely licensable by each licensor hereunder covering either (i) the - * unmodified Software as contributed to or provided by such licensor, or (ii) - * the Larger Works (as defined below), to deal in both - * - * (a) the Software, and - * - * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if - * one is included with the Software each a "Larger Work" to which the Software - * is contributed by such licensors), - * - * without restriction, including without limitation the rights to copy, create - * derivative works of, display, perform, and distribute the Software and make, - * use, sell, offer for sale, import, export, have made, and have sold the - * Software and the Larger Work(s), and to sublicense the foregoing rights on - * either these or other terms. - * - * This license is subject to the following condition: - * - * The above copyright notice and either this complete permission notice or at a - * minimum a reference to the UPL must be included in all copies or substantial - * portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -package com.oracle.truffle.api.dsl.test; - -import static com.oracle.truffle.api.dsl.test.TestHelper.executeWith; -import static org.junit.Assert.assertEquals; - -import org.junit.Test; - -import com.oracle.truffle.api.dsl.NodeChild; -import com.oracle.truffle.api.dsl.Specialization; -import com.oracle.truffle.api.dsl.test.TypeSystemTest.TestRootNode; -import com.oracle.truffle.api.dsl.test.TypeSystemTest.ValueNode; -import com.oracle.truffle.api.nodes.NodeCost; -import com.oracle.truffle.api.nodes.NodeInfo; - -public class NodeCostTest { - - @Test - public void testNodeCost() { - TestRootNode node = TestHelper.createRoot(NodeCostTestFactory.CostTestNodeFactory.getInstance()); - assertEquals(NodeCost.UNINITIALIZED, node.getNode().getCost()); - assertEquals(21, executeWith(node, 21)); - assertEquals(NodeCost.MONOMORPHIC, node.getNode().getCost()); - assertEquals(true, executeWith(node, true)); - assertEquals(NodeCost.POLYMORPHIC, node.getNode().getCost()); - assertEquals("s", executeWith(node, "s")); - assertEquals(NodeCost.MONOMORPHIC, node.getNode().getCost()); - } - - @NodeChild - abstract static class CostTestNode extends ValueNode { - - @Specialization - int costInt(int left) { - return left; - } - - @Specialization - boolean costBool(boolean left) { - return left; - } - - @Specialization(replaces = {"costInt", "costBool"}) - Object cost(Object left) { - return left; - } - - } - - @Test - public void testNodeCostViaMethodOverride() { - TestRootNode node = TestHelper.createRoot(NodeCostTestFactory.CostViaMethodOverrideNodeFactory.getInstance()); - assertEquals(NodeCost.NONE, node.getNode().getCost()); - assertEquals(21, executeWith(node, 21)); - assertEquals(NodeCost.NONE, node.getNode().getCost()); - } - - @NodeChild - abstract static class CostViaMethodOverrideNode extends ValueNode { - - @Specialization - int costInt(int left) { - return left; - } - - @Override - public final NodeCost getCost() { - return NodeCost.NONE; - } - - } - - @Test - public void testNodeCostWithNodeInfo() { - TestRootNode node = TestHelper.createRoot(NodeCostTestFactory.CostWithNodeInfoNodeFactory.getInstance()); - assertEquals(NodeCost.NONE, node.getNode().getCost()); - assertEquals(21, executeWith(node, 21)); - assertEquals(NodeCost.NONE, node.getNode().getCost()); - assertEquals(true, executeWith(node, true)); - assertEquals(NodeCost.NONE, node.getNode().getCost()); - assertEquals("s", executeWith(node, "s")); - assertEquals(NodeCost.NONE, node.getNode().getCost()); - } - - @NodeInfo(cost = NodeCost.NONE) - @NodeChild - abstract static class CostWithNodeInfoNode extends ValueNode { - - @Specialization - int costInt(int left) { - return left; - } - - @Specialization - boolean costBool(boolean left) { - return left; - } - - @Specialization(replaces = {"costInt", "costBool"}) - Object cost(Object left) { - return left; - } - - } - -} diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/PolymorphicTest.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/PolymorphicTest.java index 02db7a9d2167..f2e49cdaaa02 100644 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/PolymorphicTest.java +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/PolymorphicTest.java @@ -61,7 +61,6 @@ import com.oracle.truffle.api.dsl.test.TypeSystemTest.TestRootNode; import com.oracle.truffle.api.dsl.test.TypeSystemTest.ValueNode; import com.oracle.truffle.api.nodes.Node; -import com.oracle.truffle.api.nodes.NodeCost; import com.oracle.truffle.api.nodes.NodeUtil; public class PolymorphicTest { @@ -107,9 +106,6 @@ public void afterExecution(TestRootNode node, int index, Ob Polymorphic1 polymorphic = ((Polymorphic1) node.getNode()); assertParent(node.getNode(), polymorphic.getA()); assertNoDuplicates(polymorphic, polymorphic.getA()); - if (index == 0) { - assertEquals(NodeCost.MONOMORPHIC, node.getNode().getCost()); - } } }); } @@ -151,9 +147,6 @@ public void afterExecution(TestRootNode node, int index, Ob Polymorphic2 polymorphic = ((Polymorphic2) node.getNode()); assertParent(node.getNode(), polymorphic.getA()); assertNoDuplicates(polymorphic, polymorphic.getA()); - if (index == 0) { - assertEquals(NodeCost.MONOMORPHIC, node.getNode().getCost()); - } } }); } diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/PolymorphicTest2.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/PolymorphicTest2.java index 8f76a83d2f55..0a15dd7397c0 100644 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/PolymorphicTest2.java +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/PolymorphicTest2.java @@ -49,7 +49,6 @@ import com.oracle.truffle.api.dsl.test.BinaryNodeTest.BinaryNode; import com.oracle.truffle.api.dsl.test.PolymorphicTest2Factory.Polymorphic1Factory; import com.oracle.truffle.api.dsl.test.TypeSystemTest.TestRootNode; -import com.oracle.truffle.api.nodes.NodeCost; public class PolymorphicTest2 { @@ -60,7 +59,6 @@ public void testMultipleTypes() { assertEquals(21, executeWith(node, false, false)); assertEquals(42, executeWith(node, 21, 21)); assertEquals("(boolean,int)", executeWith(node, false, 42)); - assertEquals(NodeCost.POLYMORPHIC, node.getNode().getCost()); } @SuppressWarnings("unused") diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ReplacesTest.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ReplacesTest.java index 1186510656bf..08e54bd7f0be 100644 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ReplacesTest.java +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ReplacesTest.java @@ -47,7 +47,6 @@ import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertThat; -import org.junit.Assert; import org.junit.Test; import com.oracle.truffle.api.dsl.Idempotent; @@ -62,7 +61,6 @@ import com.oracle.truffle.api.dsl.test.TestHelper.TestExecutionListener; import com.oracle.truffle.api.dsl.test.TypeSystemTest.TestRootNode; import com.oracle.truffle.api.dsl.test.TypeSystemTest.ValueNode; -import com.oracle.truffle.api.nodes.NodeCost; @SuppressWarnings({"truffle-inlining", "truffle-neverdefault", "truffle-sharing", "unused"}) public class ReplacesTest { @@ -114,8 +112,6 @@ public void testReplaces3() { array(-2, 2, -2, -3, -4), // new TestExecutionListener() { public void afterExecution(TestRootNode node, int index, Object value, Object expectedResult, Object actualResult, boolean last) { - // assert that we are always monomorphic - Assert.assertEquals(NodeCost.MONOMORPHIC, node.getNode().getCost()); } }); } @@ -166,7 +162,6 @@ public void testReplaces4() { array(1, 0, 1, 2), // new TestExecutionListener() { public void afterExecution(TestRootNode node, int index, Object value, Object expectedResult, Object actualResult, boolean last) { - Assert.assertEquals(NodeCost.MONOMORPHIC, node.getNode().getCost()); } }); } @@ -692,7 +687,6 @@ public void testPolymorphicToMonomorphic0() { assertThat((int) executeWith(root, 1), is(1)); assertThat((int) executeWith(root, 2), is(2)); assertThat((int) executeWith(root, 3), is(3)); - assertThat(root.getNode().getCost(), is(NodeCost.MONOMORPHIC)); } @NodeChild("a") diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/SharedCachedTest.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/SharedCachedTest.java index f9c5fabda24b..da56b08c6999 100644 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/SharedCachedTest.java +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/SharedCachedTest.java @@ -443,8 +443,7 @@ public void testObjectReference() { SharedStringInGuardNode errorNode = SharedStringInGuardNodeGen.create(); AbstractPolyglotTest.assertFails(() -> errorNode.execute(null), IllegalStateException.class, (e) -> { - assertEquals("Specialization 's0(String, String)' contains a shared cache with name 'cachedName' that returned a default value for the cached initializer. " + - "Default values are not supported for shared cached initializers because the default value is reserved for the uninitialized state.", + assertEquals("A specialization returned a default value for a cached initializer. Default values are not supported for shared cached initializers because the default value is reserved for the uninitialized state.", e.getMessage()); }); } diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/TestSerialization.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/TestSerialization.java index 1ba8a2cae2b6..67e48655db6e 100644 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/TestSerialization.java +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/TestSerialization.java @@ -51,7 +51,6 @@ import com.oracle.truffle.api.dsl.test.TestSerializationFactory.SerializedNodeFactory; import com.oracle.truffle.api.dsl.test.TypeSystemTest.TestRootNode; import com.oracle.truffle.api.dsl.test.TypeSystemTest.ValueNode; -import com.oracle.truffle.api.nodes.NodeCost; import com.oracle.truffle.api.nodes.NodeUtil; public class TestSerialization { @@ -64,7 +63,6 @@ public void testUpdateRoot() { assertEquals(21, executeWith(node, 21)); assertEquals("s", executeWith(node, "s")); assertEquals(3, node.getNode().invocations); - assertEquals(NodeCost.POLYMORPHIC, node.getNode().getCost()); TestRootNode copiedNode = NodeUtil.cloneNode(node); copiedNode.adoptChildren(); diff --git a/truffle/src/com.oracle.truffle.api.dsl/snapshot.sigtest b/truffle/src/com.oracle.truffle.api.dsl/snapshot.sigtest index 07ce939d9571..40ba88470832 100644 --- a/truffle/src/com.oracle.truffle.api.dsl/snapshot.sigtest +++ b/truffle/src/com.oracle.truffle.api.dsl/snapshot.sigtest @@ -118,7 +118,7 @@ meth public abstract !hasdefault boolean inherit() meth public abstract !hasdefault boolean value() CLSS public abstract interface !annotation com.oracle.truffle.api.dsl.GeneratePackagePrivate - anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy value=RUNTIME) + anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy value=CLASS) anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] value=[TYPE]) intf java.lang.annotation.Annotation @@ -454,7 +454,7 @@ meth public static com.oracle.truffle.api.dsl.SpecializationStatistics$NodeStati supr java.lang.Object CLSS public abstract interface !annotation com.oracle.truffle.api.dsl.SuppressPackageWarnings - anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy value=RUNTIME) + anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy value=CLASS) anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] value=[PACKAGE]) intf java.lang.annotation.Annotation meth public abstract java.lang.String[] value() diff --git a/truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/GeneratePackagePrivate.java b/truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/GeneratePackagePrivate.java index ae2409fdd688..57a96eaf0b90 100644 --- a/truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/GeneratePackagePrivate.java +++ b/truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/GeneratePackagePrivate.java @@ -51,7 +51,7 @@ * * @since 22.1 */ -@Retention(RetentionPolicy.RUNTIME) +@Retention(RetentionPolicy.CLASS) @Target({ElementType.TYPE}) public @interface GeneratePackagePrivate { } diff --git a/truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/GeneratedBy.java b/truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/GeneratedBy.java index a19bf9e1f57c..d3987635888f 100644 --- a/truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/GeneratedBy.java +++ b/truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/GeneratedBy.java @@ -50,7 +50,7 @@ * * @since 0.8 or earlier */ -@Retention(RetentionPolicy.RUNTIME) +@Retention(RetentionPolicy.RUNTIME) // still used by GraalPy as RUNTIME @Target({ElementType.TYPE}) public @interface GeneratedBy { /** @since 0.8 or earlier */ diff --git a/truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/SuppressPackageWarnings.java b/truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/SuppressPackageWarnings.java index 45f2630e92a8..052f5824cc01 100644 --- a/truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/SuppressPackageWarnings.java +++ b/truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/SuppressPackageWarnings.java @@ -53,7 +53,7 @@ * * @since 23.0 */ -@Retention(RetentionPolicy.RUNTIME) +@Retention(RetentionPolicy.CLASS) @Target({ElementType.PACKAGE}) public @interface SuppressPackageWarnings { diff --git a/truffle/src/com.oracle.truffle.api.instrumentation/snapshot.sigtest b/truffle/src/com.oracle.truffle.api.instrumentation/snapshot.sigtest index 0ab378b7dfbc..32d410afbb46 100644 --- a/truffle/src/com.oracle.truffle.api.instrumentation/snapshot.sigtest +++ b/truffle/src/com.oracle.truffle.api.instrumentation/snapshot.sigtest @@ -229,7 +229,6 @@ hfds anchorStart,column,line,theTags CLSS public final com.oracle.truffle.api.instrumentation.ProbeNode fld public final static java.lang.Object UNWIND_ACTION_REENTER meth public com.oracle.truffle.api.nodes.Node copy() -meth public com.oracle.truffle.api.nodes.NodeCost getCost() meth public java.lang.Object onReturnExceptionalOrUnwind(com.oracle.truffle.api.frame.VirtualFrame,java.lang.Throwable,boolean) meth public void onEnter(com.oracle.truffle.api.frame.VirtualFrame) meth public void onResume(com.oracle.truffle.api.frame.VirtualFrame) @@ -512,6 +511,7 @@ meth public boolean isAdoptable() meth public com.oracle.truffle.api.nodes.Node copy() meth public com.oracle.truffle.api.nodes.Node deepCopy() meth public com.oracle.truffle.api.nodes.NodeCost getCost() + anno 0 java.lang.Deprecated(boolean forRemoval=false, java.lang.String since="") meth public com.oracle.truffle.api.source.SourceSection getEncapsulatingSourceSection() meth public com.oracle.truffle.api.source.SourceSection getSourceSection() meth public final <%0 extends com.oracle.truffle.api.nodes.Node> {%%0} insert({%%0}) @@ -533,16 +533,6 @@ meth public java.util.Map getDebugProperties( supr java.lang.Object hfds GIL_LOCK,PARENT_LIMIT,SAME_LANGUAGE_CHECK_VISITOR,parent -CLSS public abstract interface !annotation com.oracle.truffle.api.nodes.NodeInfo - anno 0 java.lang.annotation.Inherited() - anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy value=RUNTIME) - anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] value=[TYPE]) -intf java.lang.annotation.Annotation -meth public abstract !hasdefault com.oracle.truffle.api.nodes.NodeCost cost() -meth public abstract !hasdefault java.lang.String description() -meth public abstract !hasdefault java.lang.String language() -meth public abstract !hasdefault java.lang.String shortName() - CLSS public abstract interface com.oracle.truffle.api.nodes.NodeInterface CLSS public abstract interface java.lang.Cloneable @@ -588,12 +578,6 @@ CLSS public abstract interface !annotation java.lang.annotation.Documented anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] value=[ANNOTATION_TYPE]) intf java.lang.annotation.Annotation -CLSS public abstract interface !annotation java.lang.annotation.Inherited - anno 0 java.lang.annotation.Documented() - anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy value=RUNTIME) - anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] value=[ANNOTATION_TYPE]) -intf java.lang.annotation.Annotation - CLSS public abstract interface !annotation java.lang.annotation.Retention anno 0 java.lang.annotation.Documented() anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy value=RUNTIME) diff --git a/truffle/src/com.oracle.truffle.api.instrumentation/src/com/oracle/truffle/api/instrumentation/ExecutionEventNode.java b/truffle/src/com.oracle.truffle.api.instrumentation/src/com/oracle/truffle/api/instrumentation/ExecutionEventNode.java index ded00a92c36b..9756d63ae885 100644 --- a/truffle/src/com.oracle.truffle.api.instrumentation/src/com/oracle/truffle/api/instrumentation/ExecutionEventNode.java +++ b/truffle/src/com.oracle.truffle.api.instrumentation/src/com/oracle/truffle/api/instrumentation/ExecutionEventNode.java @@ -41,11 +41,11 @@ package com.oracle.truffle.api.instrumentation; import com.oracle.truffle.api.CompilerDirectives; +import com.oracle.truffle.api.frame.Frame; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.instrumentation.ProbeNode.EventProviderWithInputChainNode; import com.oracle.truffle.api.nodes.Node; -import com.oracle.truffle.api.nodes.NodeCost; -import com.oracle.truffle.api.nodes.NodeInfo; +import com.oracle.truffle.api.nodes.RootNode; /** * An event node created by an {@link ExecutionEventNodeFactory} for a specific locations of a guest @@ -55,7 +55,6 @@ * * @since 0.12 */ -@NodeInfo(cost = NodeCost.NONE) @SuppressWarnings("unused") public abstract class ExecutionEventNode extends Node { /** @since 0.12 */ diff --git a/truffle/src/com.oracle.truffle.api.instrumentation/src/com/oracle/truffle/api/instrumentation/ProbeNode.java b/truffle/src/com.oracle.truffle.api.instrumentation/src/com/oracle/truffle/api/instrumentation/ProbeNode.java index 1a806df5012d..5940bfeb69e5 100644 --- a/truffle/src/com.oracle.truffle.api.instrumentation/src/com/oracle/truffle/api/instrumentation/ProbeNode.java +++ b/truffle/src/com.oracle.truffle.api.instrumentation/src/com/oracle/truffle/api/instrumentation/ProbeNode.java @@ -56,13 +56,13 @@ import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.Truffle; import com.oracle.truffle.api.TruffleLogger; +import com.oracle.truffle.api.frame.Frame; import com.oracle.truffle.api.frame.FrameDescriptor; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.instrumentation.InstrumentableNode.WrapperNode; import com.oracle.truffle.api.instrumentation.InstrumentationHandler.InstrumentClientInstrumenter; import com.oracle.truffle.api.nodes.ExplodeLoop; import com.oracle.truffle.api.nodes.Node; -import com.oracle.truffle.api.nodes.NodeCost; import com.oracle.truffle.api.nodes.NodeUtil; import com.oracle.truffle.api.nodes.NodeVisitor; import com.oracle.truffle.api.nodes.RootNode; @@ -725,12 +725,6 @@ static void exceptionEventForClientInstrument(EventBinding.Source b, String e logger.log(Level.SEVERE, message, t); } - /** @since 0.12 */ - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - private static boolean checkInteropType(Object value, EventBinding.Source binding) { if (value != null && value != UNWIND_ACTION_REENTER && value != UNWIND_ACTION_IGNORED && !InstrumentAccessor.ACCESSOR.isTruffleObject(value)) { Class clazz = value.getClass(); @@ -918,11 +912,6 @@ ProbeNode.EventChainNode getNext() { return next; } - @Override - public final NodeCost getCost() { - return NodeCost.NONE; - } - final void profileBranch(int flag) { if ((seen & flag) == 0) { // if not seen CompilerDirectives.transferToInterpreterAndInvalidate(); diff --git a/truffle/src/com.oracle.truffle.api.interop/snapshot.sigtest b/truffle/src/com.oracle.truffle.api.interop/snapshot.sigtest index ddfa19318ced..59d7cc22625f 100644 --- a/truffle/src/com.oracle.truffle.api.interop/snapshot.sigtest +++ b/truffle/src/com.oracle.truffle.api.interop/snapshot.sigtest @@ -297,6 +297,7 @@ meth public boolean isAdoptable() meth public com.oracle.truffle.api.nodes.Node copy() meth public com.oracle.truffle.api.nodes.Node deepCopy() meth public com.oracle.truffle.api.nodes.NodeCost getCost() + anno 0 java.lang.Deprecated(boolean forRemoval=false, java.lang.String since="") meth public com.oracle.truffle.api.source.SourceSection getEncapsulatingSourceSection() meth public com.oracle.truffle.api.source.SourceSection getSourceSection() meth public final <%0 extends com.oracle.truffle.api.nodes.Node> {%%0} insert({%%0}) diff --git a/truffle/src/com.oracle.truffle.api.library.test/src/com/oracle/truffle/api/library/test/GenerateLibraryTest.java b/truffle/src/com.oracle.truffle.api.library.test/src/com/oracle/truffle/api/library/test/GenerateLibraryTest.java index 30d176086239..64ebc4bfa803 100644 --- a/truffle/src/com.oracle.truffle.api.library.test/src/com/oracle/truffle/api/library/test/GenerateLibraryTest.java +++ b/truffle/src/com.oracle.truffle.api.library.test/src/com/oracle/truffle/api/library/test/GenerateLibraryTest.java @@ -41,7 +41,6 @@ package com.oracle.truffle.api.library.test; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertSame; import static org.junit.Assert.fail; import org.junit.Test; @@ -56,7 +55,6 @@ import com.oracle.truffle.api.library.Library; import com.oracle.truffle.api.library.test.CachedLibraryTest.SimpleDispatchedNode; import com.oracle.truffle.api.nodes.Node; -import com.oracle.truffle.api.nodes.NodeCost; import com.oracle.truffle.api.test.AbstractLibraryTest; import com.oracle.truffle.api.test.ExpectError; @@ -149,7 +147,6 @@ public void testDispatched() { } uncached = getUncachedDispatch(SampleLibrary.class); - assertSame(NodeCost.MEGAMORPHIC, uncached.getCost()); assertEquals("s1_uncached", uncached.call(s1)); assertEquals("s1_uncached", uncached.call(s1)); assertEquals("s2_uncached", uncached.call(s2)); @@ -173,45 +170,29 @@ public void testDispatched() { } cached = createCachedDispatch(SampleLibrary.class, 0); - assertSame(NodeCost.MEGAMORPHIC, cached.getCost()); assertEquals("s1_uncached", cached.call(s1)); - assertSame(NodeCost.MEGAMORPHIC, cached.getCost()); cached = createCachedDispatch(SampleLibrary.class, 1); - assertSame(NodeCost.UNINITIALIZED, cached.getCost()); assertEquals("s1_cached", cached.call(s1)); - assertSame(NodeCost.MONOMORPHIC, cached.getCost()); assertEquals("s1_cached", cached.call(s1)); - assertSame(NodeCost.MONOMORPHIC, cached.getCost()); assertEquals("s2_uncached", cached.call(s2)); - assertSame(NodeCost.MEGAMORPHIC, cached.getCost()); assertEquals("s3_uncached", cached.call(s3)); assertEquals("s1_uncached", cached.call(s1)); cached = createCachedDispatch(SampleLibrary.class, 2); - assertSame(NodeCost.UNINITIALIZED, cached.getCost()); assertEquals("s1_cached", cached.call(s1)); - assertSame(NodeCost.MONOMORPHIC, cached.getCost()); assertEquals("s1_cached", cached.call(s1)); - assertSame(NodeCost.MONOMORPHIC, cached.getCost()); assertEquals("s2_cached", cached.call(s2)); - assertSame(NodeCost.POLYMORPHIC, cached.getCost()); assertEquals("s3_uncached", cached.call(s3)); - assertSame(NodeCost.MEGAMORPHIC, cached.getCost()); assertEquals("s2_uncached", cached.call(s2)); assertEquals("s1_uncached", cached.call(s1)); SimpleDispatchedNode.limit = 3; cached = createCachedDispatch(SampleLibrary.class, 3); - assertSame(NodeCost.UNINITIALIZED, cached.getCost()); assertEquals("s1_cached", cached.call(s1)); - assertSame(NodeCost.MONOMORPHIC, cached.getCost()); assertEquals("s1_cached", cached.call(s1)); - assertSame(NodeCost.MONOMORPHIC, cached.getCost()); assertEquals("s2_cached", cached.call(s2)); - assertSame(NodeCost.POLYMORPHIC, cached.getCost()); assertEquals("s3_cached", cached.call(s3)); - assertSame(NodeCost.POLYMORPHIC, cached.getCost()); } diff --git a/truffle/src/com.oracle.truffle.api.library/snapshot.sigtest b/truffle/src/com.oracle.truffle.api.library/snapshot.sigtest index d15023eaf07f..8e23b3b6977e 100644 --- a/truffle/src/com.oracle.truffle.api.library/snapshot.sigtest +++ b/truffle/src/com.oracle.truffle.api.library/snapshot.sigtest @@ -215,6 +215,7 @@ meth public boolean isAdoptable() meth public com.oracle.truffle.api.nodes.Node copy() meth public com.oracle.truffle.api.nodes.Node deepCopy() meth public com.oracle.truffle.api.nodes.NodeCost getCost() + anno 0 java.lang.Deprecated(boolean forRemoval=false, java.lang.String since="") meth public com.oracle.truffle.api.source.SourceSection getEncapsulatingSourceSection() meth public com.oracle.truffle.api.source.SourceSection getSourceSection() meth public final <%0 extends com.oracle.truffle.api.nodes.Node> {%%0} insert({%%0}) diff --git a/truffle/src/com.oracle.truffle.api.library/src/com/oracle/truffle/api/library/LibraryFactory.java b/truffle/src/com.oracle.truffle.api.library/src/com/oracle/truffle/api/library/LibraryFactory.java index 43b9b6c74f92..f024cc50ca7e 100644 --- a/truffle/src/com.oracle.truffle.api.library/src/com/oracle/truffle/api/library/LibraryFactory.java +++ b/truffle/src/com.oracle.truffle.api.library/src/com/oracle/truffle/api/library/LibraryFactory.java @@ -59,13 +59,11 @@ import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.TruffleOptions; -import com.oracle.truffle.api.dsl.GeneratedBy; import com.oracle.truffle.api.library.LibraryExport.DelegateExport; -import com.oracle.truffle.api.nodes.EncapsulatingNodeReference; -import com.oracle.truffle.api.nodes.Node; -import com.oracle.truffle.api.nodes.NodeCost; import com.oracle.truffle.api.library.provider.DefaultExportProvider; import com.oracle.truffle.api.library.provider.EagerExportProvider; +import com.oracle.truffle.api.nodes.EncapsulatingNodeReference; +import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.utilities.FinalBitSet; /** @@ -88,15 +86,12 @@ * instances designed to be used in ASTs. Cached instances are typically {@link Node#isAdoptable() * adoptable} and store additional profiling information for the cached export. This allows to * generate call-site specific profiling information for libray calls. Before a cached instance can - * be used it must be {@link Node#insert(Node) adopted} by a parent node. Cached instances of - * libraries have a {@link Node#getCost() cost} of {@link NodeCost#MONOMORPHIC} for each manually - * cached library. + * be used it must be {@link Node#insert(Node) adopted} by a parent node. *

* Uncached versions are designed to be used from slow-path runtime methods or whenever call-site * specific profiling is not desired. All uncached versions of a library are annotated with * {@linkplain TruffleBoundary @TruffleBoundary}. Uncached instances always return - * false for {@link Node#isAdoptable()}. Uncached instances of libraries have a - * {@link Node#getCost() cost} of {@link NodeCost#MEGAMORPHIC}. + * false for {@link Node#isAdoptable()}. *

* This class is intended to be sub-classed by generated code only. Do not sub-class * {@link LibraryFactory} manually. @@ -189,8 +184,6 @@ private static void removeClassesLoadedDuringImageBuild(Map, @SuppressWarnings("unchecked") protected LibraryFactory(Class libraryClass, List messages) { assert this.getClass().getName().endsWith(LibraryExport.GENERATED_CLASS_SUFFIX); - assert this.getClass().getAnnotation(GeneratedBy.class) != null; - assert this.getClass().getAnnotation(GeneratedBy.class).value() == libraryClass; this.libraryClass = libraryClass; this.messages = Collections.unmodifiableList(messages); Map messagesMap = new LinkedHashMap<>(); diff --git a/truffle/src/com.oracle.truffle.api.object/snapshot.sigtest b/truffle/src/com.oracle.truffle.api.object/snapshot.sigtest index 1b01a3e64e7e..77223f23cb3e 100644 --- a/truffle/src/com.oracle.truffle.api.object/snapshot.sigtest +++ b/truffle/src/com.oracle.truffle.api.object/snapshot.sigtest @@ -47,6 +47,7 @@ meth public boolean isAdoptable() meth public com.oracle.truffle.api.nodes.Node copy() meth public com.oracle.truffle.api.nodes.Node deepCopy() meth public com.oracle.truffle.api.nodes.NodeCost getCost() + anno 0 java.lang.Deprecated(boolean forRemoval=false, java.lang.String since="") meth public com.oracle.truffle.api.source.SourceSection getEncapsulatingSourceSection() meth public com.oracle.truffle.api.source.SourceSection getSourceSection() meth public final <%0 extends com.oracle.truffle.api.nodes.Node> {%%0} insert({%%0}) diff --git a/truffle/src/com.oracle.truffle.api.strings/snapshot.sigtest b/truffle/src/com.oracle.truffle.api.strings/snapshot.sigtest index 3a43975c1868..9b93475ae5b1 100644 --- a/truffle/src/com.oracle.truffle.api.strings/snapshot.sigtest +++ b/truffle/src/com.oracle.truffle.api.strings/snapshot.sigtest @@ -18,7 +18,7 @@ meth public abstract !hasdefault boolean inlineByDefault() meth public abstract !hasdefault boolean value() CLSS public abstract interface !annotation com.oracle.truffle.api.dsl.GeneratePackagePrivate - anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy value=RUNTIME) + anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy value=CLASS) anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] value=[TYPE]) intf java.lang.annotation.Annotation @@ -55,6 +55,7 @@ meth public boolean isAdoptable() meth public com.oracle.truffle.api.nodes.Node copy() meth public com.oracle.truffle.api.nodes.Node deepCopy() meth public com.oracle.truffle.api.nodes.NodeCost getCost() + anno 0 java.lang.Deprecated(boolean forRemoval=false, java.lang.String since="") meth public com.oracle.truffle.api.source.SourceSection getEncapsulatingSourceSection() meth public com.oracle.truffle.api.source.SourceSection getSourceSection() meth public final <%0 extends com.oracle.truffle.api.nodes.Node> {%%0} insert({%%0}) diff --git a/truffle/src/com.oracle.truffle.api/snapshot.sigtest b/truffle/src/com.oracle.truffle.api/snapshot.sigtest index 5ae0a765113c..db2fbcc78f12 100644 --- a/truffle/src/com.oracle.truffle.api/snapshot.sigtest +++ b/truffle/src/com.oracle.truffle.api/snapshot.sigtest @@ -728,7 +728,9 @@ fld public final static boolean AOT fld public final static boolean DetailedRewriteReasons fld public final static boolean TraceRewrites fld public final static com.oracle.truffle.api.nodes.NodeCost TraceRewritesFilterFromCost + anno 0 java.lang.Deprecated(boolean forRemoval=false, java.lang.String since="") fld public final static com.oracle.truffle.api.nodes.NodeCost TraceRewritesFilterToCost + anno 0 java.lang.Deprecated(boolean forRemoval=false, java.lang.String since="") fld public final static java.lang.String TraceRewritesFilterClass supr java.lang.Object @@ -1069,7 +1071,6 @@ meth public abstract java.lang.Object executeGeneric(com.oracle.truffle.api.fram meth public abstract long executeLong(com.oracle.truffle.api.frame.VirtualFrame,int) throws com.oracle.truffle.api.nodes.UnexpectedResultException meth public abstract short executeShort(com.oracle.truffle.api.frame.VirtualFrame,int) throws com.oracle.truffle.api.nodes.UnexpectedResultException meth public abstract void executeVoid(com.oracle.truffle.api.frame.VirtualFrame,int) -meth public final com.oracle.truffle.api.nodes.NodeCost getCost() meth public final {com.oracle.truffle.api.nodes.BlockNode%0}[] getElements() meth public static <%0 extends com.oracle.truffle.api.nodes.Node> com.oracle.truffle.api.nodes.BlockNode<{%%0}> create({%%0}[],com.oracle.truffle.api.nodes.BlockNode$ElementExecutor<{%%0}>) supr com.oracle.truffle.api.nodes.Node @@ -1217,6 +1218,7 @@ meth public boolean isAdoptable() meth public com.oracle.truffle.api.nodes.Node copy() meth public com.oracle.truffle.api.nodes.Node deepCopy() meth public com.oracle.truffle.api.nodes.NodeCost getCost() + anno 0 java.lang.Deprecated(boolean forRemoval=false, java.lang.String since="") meth public com.oracle.truffle.api.source.SourceSection getEncapsulatingSourceSection() meth public com.oracle.truffle.api.source.SourceSection getSourceSection() meth public final <%0 extends com.oracle.truffle.api.nodes.Node> {%%0} insert({%%0}) @@ -1276,6 +1278,7 @@ meth protected java.lang.Object clone() supr java.lang.Object CLSS public final !enum com.oracle.truffle.api.nodes.NodeCost + anno 0 java.lang.Deprecated(boolean forRemoval=false, java.lang.String since="") fld public final static com.oracle.truffle.api.nodes.NodeCost MEGAMORPHIC fld public final static com.oracle.truffle.api.nodes.NodeCost MONOMORPHIC fld public final static com.oracle.truffle.api.nodes.NodeCost NONE @@ -1293,6 +1296,7 @@ CLSS public abstract interface !annotation com.oracle.truffle.api.nodes.NodeInfo anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] value=[TYPE]) intf java.lang.annotation.Annotation meth public abstract !hasdefault com.oracle.truffle.api.nodes.NodeCost cost() + anno 0 java.lang.Deprecated(boolean forRemoval=false, java.lang.String since="") meth public abstract !hasdefault java.lang.String description() meth public abstract !hasdefault java.lang.String language() meth public abstract !hasdefault java.lang.String shortName() @@ -1394,6 +1398,8 @@ meth public final java.lang.Throwable fillInStackTrace() supr java.lang.Exception hfds serialVersionUID +CLSS public abstract interface com.oracle.truffle.api.nodes.UnadoptableNode + CLSS public final com.oracle.truffle.api.nodes.UnexpectedResultException cons public init(java.lang.Object) meth public java.lang.Object getResult() diff --git a/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/TruffleOptions.java b/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/TruffleOptions.java index ea5840075781..ec8a1b591aa7 100644 --- a/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/TruffleOptions.java +++ b/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/TruffleOptions.java @@ -43,9 +43,6 @@ import java.security.AccessController; import java.security.PrivilegedAction; -import com.oracle.truffle.api.nodes.NodeCost; -import com.oracle.truffle.api.nodes.NodeInfo; - /** * Class containing general Truffle options. * @@ -85,26 +82,16 @@ private TruffleOptions() { public static final String TraceRewritesFilterClass; /** - * Filters rewrites which does not contain the {@link NodeCost} in its source {@link NodeInfo}. - * If no {@link NodeInfo} is defined the element is filtered if the filter value is set. - *

- * Can be set with - * {@code -Dtruffle.TraceRewritesFilterFromCost=NONE|MONOMORPHIC|POLYMORPHIC|MEGAMORPHIC}. - * * @since 0.8 or earlier + * @deprecated in 24.1 without replacement */ - public static final NodeCost TraceRewritesFilterFromCost; + @SuppressWarnings("deprecation") @Deprecated public static final com.oracle.truffle.api.nodes.NodeCost TraceRewritesFilterFromCost; /** - * Filters rewrites which does not contain the {@link NodeCost} in its target {@link NodeInfo}. - * If no {@link NodeInfo} is defined the element is filtered if the filter value is set. - *

- * Can be set with - * {@code -Dtruffle.TraceRewritesFilterToKind=UNINITIALIZED|SPECIALIZED|POLYMORPHIC|GENERIC}. - * * @since 0.8 or earlier + * @deprecated in 24.1 without replacement */ - public static final NodeCost TraceRewritesFilterToCost; + @SuppressWarnings("deprecation") @Deprecated public static final com.oracle.truffle.api.nodes.NodeCost TraceRewritesFilterToCost; /** * Forces ahead-of-time initialization. @@ -113,12 +100,13 @@ private TruffleOptions() { */ public static final boolean AOT; - private static NodeCost parseNodeInfoKind(String kind) { + @SuppressWarnings("deprecation") + private static com.oracle.truffle.api.nodes.NodeCost parseNodeInfoKind(String kind) { if (kind == null) { return null; } - return NodeCost.valueOf(kind); + return com.oracle.truffle.api.nodes.NodeCost.valueOf(kind); } static { @@ -127,8 +115,8 @@ class GetOptions implements PrivilegedAction { boolean traceRewrites; boolean detailedRewriteReasons; String traceRewritesFilterClass; - NodeCost traceRewritesFilterFromCost; - NodeCost traceRewritesFilterToCost; + @SuppressWarnings("deprecation") com.oracle.truffle.api.nodes.NodeCost traceRewritesFilterFromCost; + @SuppressWarnings("deprecation") com.oracle.truffle.api.nodes.NodeCost traceRewritesFilterToCost; @Override public Void run() { diff --git a/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/BlockNode.java b/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/BlockNode.java index a601cb557f15..d917e6fb7f16 100644 --- a/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/BlockNode.java +++ b/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/BlockNode.java @@ -72,15 +72,15 @@ *

*

Simple Usage:

The following example shows how a language with untyped execute methods, * but with blocks that return values would use the block node. - * - * {@snippet file="com/oracle/truffle/api/nodes/BlockNode.java" - * region="com.oracle.truffle.api.nodes.BlockNodeSnippets.LanguageBlockNode"} + * + * {@snippet file = "com/oracle/truffle/api/nodes/BlockNode.java" region = + * "com.oracle.truffle.api.nodes.BlockNodeSnippets.LanguageBlockNode"} * *

Resumable Usage:

The following example shows how the block node can be used to implement * resumable blocks, e.g. for generator implementations: - * - * {@snippet file="com/oracle/truffle/api/nodes/BlockNode.java" - * region="com.oracle.truffle.api.nodes.BlockNodeSnippets.ResumableBlockNode"} + * + * {@snippet file = "com/oracle/truffle/api/nodes/BlockNode.java" region = + * "com.oracle.truffle.api.nodes.BlockNodeSnippets.ResumableBlockNode"} * * @param the type of the block element node * @since 19.3 @@ -246,18 +246,6 @@ public final T[] getElements() { return elements; } - /** - * Block nodes always have {@link NodeCost#NONE}. - * - * {@inheritDoc} - * - * @since 19.3 - */ - @Override - public final NodeCost getCost() { - return NodeCost.NONE; - } - /** * Creates a new block node. The elements array of the block node must not be empty or an * {@link IllegalArgumentException} is thrown. Elements of a block must at least extend diff --git a/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/Node.java b/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/Node.java index de1389148849..bee27c914608 100644 --- a/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/Node.java +++ b/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/Node.java @@ -155,13 +155,16 @@ private boolean validateNewParent(Node newParent) { * default value. * * @since 0.8 or earlier + * @deprecated in 24.1 without replacement */ - public NodeCost getCost() { + @SuppressWarnings("deprecation") + @Deprecated + public com.oracle.truffle.api.nodes.NodeCost getCost() { NodeInfo info = getClass().getAnnotation(NodeInfo.class); if (info != null) { return info.cost(); } - return NodeCost.MONOMORPHIC; + return com.oracle.truffle.api.nodes.NodeCost.MONOMORPHIC; } /** @@ -172,14 +175,14 @@ public NodeCost getCost() { * be called on any thread and without a language context being active. *

* Simple example implementation using a simple implementation using a field: - * - * {@snippet file="com/oracle/truffle/api/nodes/Node.java" - * region="com.oracle.truffle.api.nodes.NodeSnippets.SimpleNode"} + * + * {@snippet file = "com/oracle/truffle/api/nodes/Node.java" region = + * "com.oracle.truffle.api.nodes.NodeSnippets.SimpleNode"} *

* Recommended implementation computing the source section lazily from primitive fields: - * - * {@snippet file="com/oracle/truffle/api/nodes/Node.java" - * region="com.oracle.truffle.api.nodes.NodeSnippets.RecommendedNode"} + * + * {@snippet file = "com/oracle/truffle/api/nodes/Node.java" region = + * "com.oracle.truffle.api.nodes.NodeSnippets.RecommendedNode"} * * @return the source code represented by this Node * @since 0.8 or earlier @@ -216,13 +219,16 @@ public SourceSection getEncapsulatingSourceSection() { * adoptable then then it is guaranteed that the {@link #getParent() parent} pointer remains * null at all times, even if the node is tried to be adopted by a parent. *

+ * If the result of this method is statically known then it is recommended to make the node + * implement {@link UnadoptableNode} instead. + *

* Implementations of {@link #isAdoptable()} are required to fold to a constant result when * compiled with a constant receiver. * * @since 19.0 */ public boolean isAdoptable() { - return true; + return !(this instanceof UnadoptableNode); } /** diff --git a/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/NodeCost.java b/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/NodeCost.java index dfa2c7d7f3ef..3532f1ab8b38 100644 --- a/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/NodeCost.java +++ b/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/NodeCost.java @@ -48,7 +48,9 @@ * * @see Node#getCost() * @since 0.8 or earlier + * @deprecated in 24.1 without replacement */ +@Deprecated public enum NodeCost { /** diff --git a/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/NodeInfo.java b/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/NodeInfo.java index f14fd507cdd5..b9d3a49a490e 100644 --- a/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/NodeInfo.java +++ b/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/NodeInfo.java @@ -71,7 +71,10 @@ * @see Node#getCost() * @see NodeCost * @since 0.8 or earlier + * @deprecated in 24.1 without replacement */ + @SuppressWarnings("deprecation") + @Deprecated NodeCost cost() default NodeCost.MONOMORPHIC; /** diff --git a/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/NodeUtil.java b/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/NodeUtil.java index 56197455b635..10b976c323e5 100644 --- a/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/NodeUtil.java +++ b/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/NodeUtil.java @@ -1000,6 +1000,7 @@ private static String toStringWithClass(Object obj) { return obj == null ? "null" : obj + "(" + obj.getClass().getName() + ")"; } + @SuppressWarnings("deprecation") static void traceRewrite(Node oldNode, Node newNode, CharSequence reason) { if (TruffleOptions.TraceRewritesFilterFromCost != null) { if (filterByKind(oldNode, TruffleOptions.TraceRewritesFilterFromCost)) { @@ -1043,6 +1044,7 @@ private static String formatLocation(SourceSection sourceSection) { } } + @SuppressWarnings("deprecation") private static String formatNodeInfo(Node node) { String cost = "?"; switch (node.getCost()) { @@ -1065,7 +1067,8 @@ private static String formatNodeInfo(Node node) { return cost + " " + nodeName(node); } - private static boolean filterByKind(Node node, NodeCost cost) { + @SuppressWarnings("deprecation") + private static boolean filterByKind(Node node, com.oracle.truffle.api.nodes.NodeCost cost) { return node.getCost() == cost; } diff --git a/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/UnadoptableNode.java b/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/UnadoptableNode.java new file mode 100644 index 000000000000..20f2794cb353 --- /dev/null +++ b/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/UnadoptableNode.java @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2012, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.oracle.truffle.api.nodes; + +/** + * Marks a node unadoptable, this means that the parent pointer will never be written by the Truffle + * framework. If nodes need to be statically shared then they must not be adoptable, because + * otherwise the parent reference might cause a memory leak. If a node is not adoptable then then it + * is guaranteed that the {@link Node#getParent() parent} pointer remains null at all + * times, even if the node is tried to be adopted by a parent. + *

+ * Node that unadoptable nodes should usually also be annotated with {@link DenyReplace}. + * + * @see Node#isAdoptable() + * @see DenyReplace + * @since 24.1 + */ +public interface UnadoptableNode { + +} diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/InstrumentableProcessor.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/InstrumentableProcessor.java index e71bcd4af655..311f7285516a 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/InstrumentableProcessor.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/InstrumentableProcessor.java @@ -52,6 +52,7 @@ import javax.annotation.processing.SupportedAnnotationTypes; import javax.lang.model.SourceVersion; import javax.lang.model.element.AnnotationMirror; +import javax.lang.model.element.AnnotationValue; import javax.lang.model.element.Element; import javax.lang.model.element.ElementKind; import javax.lang.model.element.ExecutableElement; @@ -78,7 +79,6 @@ import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; import com.oracle.truffle.dsl.processor.java.transform.FixWarningsVisitor; import com.oracle.truffle.dsl.processor.java.transform.GenerateOverrideVisitor; -import javax.lang.model.element.AnnotationValue; @SupportedAnnotationTypes({ TruffleTypes.GenerateWrapper_Name}) @@ -368,13 +368,6 @@ private CodeTypeElement generateWrapper(ProcessorContext context, Element e, boo wrapperType.add(getter); } - if (isOverrideableOrUndeclared(sourceType, METHOD_GET_NODE_COST)) { - TypeMirror returnType = types.NodeCost; - CodeExecutableElement getInstrumentationTags = new CodeExecutableElement(ElementUtils.modifiers(Modifier.PUBLIC), returnType, METHOD_GET_NODE_COST); - getInstrumentationTags.createBuilder().startReturn().staticReference(returnType, "NONE").end(); - wrapperType.add(getInstrumentationTags); - } - boolean isResume = resumeMethodPrefix != null && !resumeMethodPrefix.isEmpty(); List wrappedMethods = new ArrayList<>(); List wrappedExecuteMethods = new ArrayList<>(); @@ -758,11 +751,6 @@ private static TypeMirror boxed(TypeMirror type, Types types) { } } - private static boolean isOverrideableOrUndeclared(TypeElement sourceType, String methodName) { - List elements = ElementUtils.getDeclaredMethodsInSuperTypes(sourceType, methodName); - return elements.isEmpty() || !elements.iterator().next().getModifiers().contains(Modifier.FINAL); - } - private static CodeVariableElement createNodeChild(ProcessorContext context, TypeMirror type, String name) { CodeVariableElement var = new CodeVariableElement(ElementUtils.modifiers(Modifier.PRIVATE), type, name); var.addAnnotationMirror(new CodeAnnotationMirror(context.getTypes().Node_Child)); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/OptionProcessor.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/OptionProcessor.java index bf886895001c..00c6b4806958 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/OptionProcessor.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/OptionProcessor.java @@ -40,9 +40,6 @@ */ package com.oracle.truffle.dsl.processor; -import static com.oracle.truffle.dsl.processor.LanguageRegistrationProcessor.resolveLanguageId; -import static javax.lang.model.element.Modifier.ABSTRACT; - import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -197,7 +194,7 @@ private boolean processElement(Element element, AnnotationMirror elementAnnotati if (context.getEnvironment().getTypeUtils().isAssignable(info.type.asType(), erasedTruffleType)) { AnnotationMirror registration = ElementUtils.findAnnotationMirror(info.type, types.TruffleLanguage_Registration); if (registration != null) { - String languageId = resolveLanguageId(info.type, registration); + String languageId = LanguageRegistrationProcessor.resolveLanguageId(info.type, registration); groupPrefixStrings = Arrays.asList(languageId); if (groupPrefixStrings.get(0).isEmpty()) { error(element, elementAnnotation, "%s must specify an id such that Truffle options can infer their prefix.", @@ -380,7 +377,7 @@ private static CodeTypeElement generateDescriptors(ProcessorContext context, Ele ExecutableElement get = ElementUtils.findExecutableElement(types.OptionDescriptors, "get"); CodeExecutableElement getMethod = CodeExecutableElement.clone(get); - getMethod.getModifiers().remove(ABSTRACT); + getMethod.getModifiers().remove(Modifier.ABSTRACT); CodeTreeBuilder builder = getMethod.createBuilder(); String nameVariableName = getMethod.getParameters().get(0).getSimpleName().toString(); @@ -423,7 +420,7 @@ private static CodeTypeElement generateDescriptors(ProcessorContext context, Ele descriptors.add(getMethod); CodeExecutableElement sandboxPolicyMethod = CodeExecutableElement.clone(ElementUtils.findExecutableElement(types.TruffleOptionDescriptors, "getSandboxPolicy", 1)); - sandboxPolicyMethod.getModifiers().remove(ABSTRACT); + sandboxPolicyMethod.getModifiers().remove(Modifier.ABSTRACT); sandboxPolicyMethod.renameArguments("optionName"); Map> groupedOptions = new LinkedHashMap<>(); @@ -498,7 +495,7 @@ private static CodeTypeElement generateDescriptors(ProcessorContext context, Ele descriptors.add(sandboxPolicyMethod); CodeExecutableElement iteratorMethod = CodeExecutableElement.clone(ElementUtils.findExecutableElement(types.OptionDescriptors, "iterator")); - iteratorMethod.getModifiers().remove(ABSTRACT); + iteratorMethod.getModifiers().remove(Modifier.ABSTRACT); builder = iteratorMethod.createBuilder(); builder.startReturn(); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java index 82357d6f859c..9f0b667ef898 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java @@ -143,6 +143,7 @@ public class TruffleTypes { public static final String TruffleLanguage_Registration_Name = "com.oracle.truffle.api.TruffleLanguage.Registration"; public static final String TruffleOptions_Name = "com.oracle.truffle.api.TruffleOptions"; public static final String TruffleOptionDescriptors_Name = "com.oracle.truffle.api.TruffleOptionDescriptors"; + public static final String UnadoptableNode_Name = "com.oracle.truffle.api.nodes.UnadoptableNode"; public static final String UnexpectedResultException_Name = "com.oracle.truffle.api.nodes.UnexpectedResultException"; public static final String VirtualFrame_Name = "com.oracle.truffle.api.frame.VirtualFrame"; public static final String HostLanguage_Name = "com.oracle.truffle.polyglot.HostLanguage"; @@ -186,6 +187,7 @@ public class TruffleTypes { public final DeclaredType TruffleLanguage_Registration = c.getDeclaredType(TruffleLanguage_Registration_Name); public final DeclaredType TruffleOptions = c.getDeclaredType(TruffleOptions_Name); public final DeclaredType TruffleOptionDescriptors = c.getDeclaredType(TruffleOptionDescriptors_Name); + public final DeclaredType UnadoptableNode = c.getDeclaredType(UnadoptableNode_Name); public final DeclaredType UnexpectedResultException = c.getDeclaredType(UnexpectedResultException_Name); public final DeclaredType VirtualFrame = c.getDeclaredType(VirtualFrame_Name); public final DeclaredType HostLanguage = c.getDeclaredTypeOptional(HostLanguage_Name); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java index 28266d40c17f..3b12d2a6ce3e 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java @@ -901,12 +901,6 @@ public CodeTypeElement create(CodeTypeElement clazz) { List genericExecutableTypes = new ArrayList<>(); List specializedExecutableTypes = new ArrayList<>(); List voidExecutableTypes = new ArrayList<>(); - AnnotationMirror nodeInfo = null; - try { - nodeInfo = ElementUtils.findAnnotationMirror(node.getTemplateType(), types.NodeInfo); - } catch (UnsupportedOperationException e) { - } - final String cost = nodeInfo != null ? ElementUtils.getAnnotationValue(VariableElement.class, nodeInfo, "cost").getSimpleName().toString() : null; GeneratorUtils.mergeSuppressWarnings(clazz, "javadoc"); @@ -1025,12 +1019,6 @@ public CodeTypeElement create(CodeTypeElement clazz) { } } - if ((cost == null || cost.equals("MONOMORPHIC") /* the default */) && isUndeclaredOrOverrideable(clazz, "getCost")) { - if (primaryNode) { - clazz.add(createGetCostMethod(false)); - } - } - for (TypeMirror type : uniqueSortedTypes(expectedTypes, false)) { if (!typeSystem.hasType(type)) { clazz.addOptional(TypeSystemCodeGenerator.createExpectMethod(PRIVATE, typeSystem, @@ -1161,9 +1149,7 @@ public CodeTypeElement create(CodeTypeElement clazz) { inlined.getEnclosedElements().addAll(removeThisMethods.values()); - CodeExecutableElement isAdoptable = CodeExecutableElement.cloneNoAnnotations(ElementUtils.findExecutableElement(types.Node, "isAdoptable")); - isAdoptable.createBuilder().returnFalse(); - inlined.add(isAdoptable); + inlined.getImplements().add(types.UnadoptableNode); if (isGenerateIntrospection()) { generateIntrospectionInfo(inlined, true); @@ -1224,12 +1210,7 @@ public CodeTypeElement create(CodeTypeElement clazz) { wrapWithTraceOnReturn(uncached.add(createUncachedExecute(type))); } - if ((cost == null || cost.equals("MONOMORPHIC") /* the default */) && isUndeclaredOrOverrideable(uncached, "getCost")) { - uncached.add(createGetCostMethod(true)); - } - CodeExecutableElement isAdoptable = CodeExecutableElement.cloneNoAnnotations(ElementUtils.findExecutableElement(types.Node, "isAdoptable")); - isAdoptable.createBuilder().returnFalse(); - uncached.add(isAdoptable); + uncached.getImplements().add(types.UnadoptableNode); clazz.add(uncached); GeneratedTypeMirror uncachedType = new GeneratedTypeMirror("", uncached.getSimpleName().toString()); @@ -2064,9 +2045,6 @@ private void createSpecializationClass(CodeTypeElement enclosingType, Specializa DeclaredType annotationType; if (useNode) { annotationType = types.Node_Child; - CodeExecutableElement getNodeCost = new CodeExecutableElement(modifiers(PUBLIC), types.NodeCost, "getCost"); - getNodeCost.createBuilder().startReturn().staticReference(types.NodeCost, "NONE").end(); - specializationClass.add(getNodeCost); } else { annotationType = types.CompilerDirectives_CompilationFinal; } @@ -3886,93 +3864,6 @@ private List filterExecutableTypes(List return filteredTypes; } - private Element createGetCostMethod(boolean uncached) { - TypeMirror returnType = types.NodeCost; - CodeExecutableElement executable = new CodeExecutableElement(modifiers(PUBLIC), returnType, "getCost"); - executable.getAnnotationMirrors().add(new CodeAnnotationMirror(context.getDeclaredType(Override.class))); - CodeTreeBuilder builder = executable.createBuilder(); - - if (uncached) { - builder.startReturn().staticReference(types.NodeCost, "MEGAMORPHIC").end(); - } else { - if (node.needsRewrites(context)) { - FrameState frameState = FrameState.load(this, NodeExecutionMode.UNCACHED, executable); - StateQuery allSpecializationQuery = StateQuery.create(SpecializationActive.class, node.getReachableSpecializations()); - StateQuery noSpecializationQuery = StateQuery.create(SpecializationActive.class); - builder.tree(multiState.createLoad(frameState, allSpecializationQuery)); - - builder.startIf().tree(multiState.createIs(frameState, noSpecializationQuery, allSpecializationQuery)).end(); - builder.startBlock(); - builder.startReturn().staticReference(types.NodeCost, "UNINITIALIZED").end(); - builder.end(); - if (node.getReachableSpecializations().size() == 1 && !node.getReachableSpecializations().iterator().next().hasMultipleInstances()) { - builder.startElseBlock(); - builder.startReturn().staticReference(types.NodeCost, "MONOMORPHIC").end(); - builder.end(); - } else { - builder.startElseBlock(); - - if (multiState.getSets().size() == 1) { - builder.startIf(); - builder.tree(multiState.getSets().get(0).createIsOneBitOf(frameState, allSpecializationQuery)); - builder.end().startBlock(); - } else { - builder.declaration("int", "counter", "0"); - for (BitSet set : multiState.getSets()) { - StateQuery filtered = set.filter(allSpecializationQuery); - if (filtered.isEmpty()) { - continue; - } - builder.startStatement(); - builder.string("counter += "); - builder.startStaticCall(ElementUtils.findMethod(Integer.class, "bitCount")); - builder.tree(set.createMaskedReference(frameState, filtered)); - builder.end(); - builder.end(); - } - builder.startIf(); - builder.string("counter == 1"); - builder.end().startBlock(); - } - - List additionalChecks = new ArrayList<>(); - for (SpecializationData specialization : node.getReachableSpecializations()) { - if (useSpecializationClass(specialization) && specialization.getMaximumNumberOfInstances() > 1) { - String typeName = createSpecializationTypeName(specialization); - String fieldName = createSpecializationFieldName(specialization); - String localName = createSpecializationLocalName(specialization); - builder.declaration(typeName, localName, "this." + fieldName); - CodeTree check = builder.create().startParantheses().string(localName, " == null || ", - localName, ".next_ == null").end().build(); - additionalChecks.add(check); - } - } - if (!additionalChecks.isEmpty()) { - builder.startIf().tree(combineTrees(" && ", additionalChecks.toArray(new CodeTree[0]))).end().startBlock(); - } - builder.startReturn().staticReference(types.NodeCost, "MONOMORPHIC").end(); - if (!additionalChecks.isEmpty()) { - builder.end(); - } - builder.end(); // if - builder.end(); // else block - - builder.startReturn().staticReference(types.NodeCost, "POLYMORPHIC").end(); - } - } else { - builder.startReturn().staticReference(types.NodeCost, "MONOMORPHIC").end(); - } - } - - return executable; - - } - - private static boolean isUndeclaredOrOverrideable(TypeElement sourceType, String methodName) { - List elements = ElementUtils.getDeclaredMethodsInSuperTypes(sourceType, methodName); - return elements.isEmpty() || !elements.iterator().next().getModifiers().contains(Modifier.FINAL); - } - private ExecutableElement createAccessChildMethod(NodeChildData child, boolean uncached) { if (child.getAccessElement() != null && child.getAccessElement().getModifiers().contains(Modifier.ABSTRACT)) { ExecutableElement getter = (ExecutableElement) child.getAccessElement(); @@ -6539,13 +6430,9 @@ private Collection persistCache(FrameState frameState, SpecializationD value = CodeTreeBuilder.singleString(localName); } String message = String.format( - "Specialization '%s' cache '%s' returned a '%s' default value. The cache initializer must never return a default value for this cache. " + - "Use @%s(neverDefault=false) to allow default values for this cached value or make sure the cache initializer never returns '%s'.", - ElementUtils.getReadableSignature(specialization.getMethod()), - cache.getParameter().getLocalName(), - defaultValue, - getSimpleName(types.Cached), - defaultValue); + "A specialization cache returned a default value. The cache initializer must never return a default value for this cache. " + + "Use @%s(neverDefault=false) to allow default values for this cached value or make sure the cache initializer never returns the default value.", + getSimpleName(types.Cached)); if (ElementUtils.isPrimitive(cache.getParameter().getType())) { builder.startIf().tree(value).string(" == ").string(defaultValue).end().startBlock(); @@ -6736,11 +6623,11 @@ private void checkSharedCacheNull(CodeTreeBuilder builder, String refName, Speci return; } builder.startIf().string(refName).string(" == ").string(ElementUtils.defaultValue(cache.getParameter().getType())).end().startBlock(); - String message = String.format("Specialization '%s' contains a shared cache with name '%s' that returned a default value for the cached initializer. " + - "Default values are not supported for shared cached initializers because the default value is reserved for the uninitialized state.", - ElementUtils.getReadableSignature(specialization.getMethod()), - cache.getParameter().getLocalName()); - builder.startThrow().startNew(context.getType(IllegalStateException.class)).doubleQuote(message).end().end(); + builder.startThrow().startNew(context.getType(IllegalStateException.class)); + builder.doubleQuote("A specialization returned a default value for a cached initializer. " + + "Default values are not supported for shared cached initializers because the default value is reserved for the uninitialized state."); + builder.end().end(); // new, throw + builder.end(); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/library/ExportsGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/library/ExportsGenerator.java index 7da719457ee5..db6d0ab0ebca 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/library/ExportsGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/library/ExportsGenerator.java @@ -754,14 +754,14 @@ CodeTypeElement createCached(ExportsLibrary libraryExports, Map create(ProcessorContext context1, AnnotationProcess } } - CodeExecutableElement delegateNodeCost = CodeExecutableElement.clone(ElementUtils.findExecutableElement(types.Node, "getCost")); - delegateNodeCost.createBuilder().startReturn().staticReference(types.NodeCost, "NONE").end(); - delegateClass.add(delegateNodeCost); - CodeExecutableElement delegateIsAdoptable = CodeExecutableElement.clone(ElementUtils.findExecutableElement(types.Node, "isAdoptable")); delegateIsAdoptable.createBuilder().startReturn().string("this.delegateLibrary.isAdoptable()").end(); delegateClass.add(delegateIsAdoptable); @@ -475,8 +470,6 @@ public List create(ProcessorContext context1, AnnotationProcess // CachedToUncachedDispatchNode final CodeTypeElement cachedToUncached = createClass(model, null, modifiers(PRIVATE, STATIC, FINAL), "CachedToUncachedDispatch", libraryTypeMirror); - CodeExecutableElement getCost = cachedToUncached.add(CodeExecutableElement.clone(ElementUtils.findExecutableElement(types.Node, "getCost"))); - getCost.createBuilder().startReturn().staticReference(ElementUtils.findVariableElement(types.NodeCost, "MEGAMORPHIC")).end(); for (MessageObjects message : methods) { CodeExecutableElement execute = cachedToUncached.add(CodeExecutableElement.cloneNoAnnotations(message.model.getExecutable())); @@ -516,8 +509,6 @@ public List create(ProcessorContext context1, AnnotationProcess // UncachedDispatch final CodeTypeElement uncachedDispatch = createClass(model, null, modifiers(PRIVATE, STATIC, FINAL), "UncachedDispatch", libraryTypeMirror); uncachedDispatch.addAnnotationMirror(new CodeAnnotationMirror(types.DenyReplace)); - getCost = uncachedDispatch.add(CodeExecutableElement.clone(ElementUtils.findExecutableElement(types.Node, "getCost"))); - getCost.createBuilder().startReturn().staticReference(ElementUtils.findVariableElement(types.NodeCost, "MEGAMORPHIC")).end(); for (MessageObjects message : methods) { CodeExecutableElement execute = uncachedDispatch.add(CodeExecutableElement.cloneNoAnnotations(message.model.getExecutable())); @@ -540,8 +531,7 @@ public List create(ProcessorContext context1, AnnotationProcess } uncachedDispatch.addOptional(createGenericCastMethod(model)); - CodeExecutableElement isAdoptable = uncachedDispatch.add(CodeExecutableElement.clone(ElementUtils.findExecutableElement(types.Node, "isAdoptable"))); - isAdoptable.createBuilder().returnFalse(); + uncachedDispatch.getImplements().add(types.UnadoptableNode); genClass.add(uncachedDispatch); @@ -627,10 +617,6 @@ public List create(ProcessorContext context1, AnnotationProcess builder.tree(GeneratorUtils.createShouldNotReachHere()); } - DeclaredType nodeCost = types.NodeCost; - getCost = cachedDispatchNext.add(CodeExecutableElement.clone(ElementUtils.findExecutableElement(types.Node, "getCost"))); - getCost.createBuilder().startReturn().staticReference(ElementUtils.findVariableElement(nodeCost, "NONE")).end(); - // specialize CodeExecutableElement execute = cachedDispatch.add(new CodeExecutableElement(modifiers(PRIVATE), context.getType(void.class), "specialize")); @@ -743,21 +729,6 @@ public List create(ProcessorContext context1, AnnotationProcess builder.statement("this.aot_ = true"); } - getCost = cachedDispatchFirst.add(CodeExecutableElement.clone(ElementUtils.findExecutableElement(types.Node, "getCost"))); - builder = getCost.createBuilder(); - builder.startIf().string("this.library").instanceOf(cachedToUncached.asType()).end().startBlock(); - builder.startReturn().staticReference(ElementUtils.findVariableElement(nodeCost, "MEGAMORPHIC")).end(); - builder.end(); - builder.declaration(cachedDispatch.asType(), "current", "this"); - builder.statement("int count = 0"); - builder.startDoBlock(); - builder.startIf().string("current.library != null").end().startBlock(); - builder.statement("count++"); - builder.end(); - builder.statement("current = current.next"); - builder.end().startDoWhile().string("current != null").end().end(); - builder.startReturn().startStaticCall(nodeCost, "fromCount").string("count").end().end(); - genClass.add(cachedDispatch); CodeExecutableElement createCachedDispatch = CodeExecutableElement.clone(ElementUtils.findExecutableElement(types.LibraryFactory, "createDispatchImpl")); diff --git a/truffle/src/com.oracle.truffle.runtime/src/com/oracle/truffle/runtime/AbstractCompilationTask.java b/truffle/src/com.oracle.truffle.runtime/src/com/oracle/truffle/runtime/AbstractCompilationTask.java index c2dbb89505c2..fc938bd78c80 100644 --- a/truffle/src/com.oracle.truffle.runtime/src/com/oracle/truffle/runtime/AbstractCompilationTask.java +++ b/truffle/src/com.oracle.truffle.runtime/src/com/oracle/truffle/runtime/AbstractCompilationTask.java @@ -55,7 +55,6 @@ import com.oracle.truffle.api.dsl.Introspection; import com.oracle.truffle.api.nodes.DirectCallNode; import com.oracle.truffle.api.nodes.Node; -import com.oracle.truffle.api.nodes.NodeCost; import com.oracle.truffle.api.nodes.NodeUtil; import com.oracle.truffle.api.source.SourceSection; import com.oracle.truffle.compiler.TruffleCompilable; @@ -171,10 +170,6 @@ public Map getDebugProperties(JavaConstant node) { } private static void computeNodeProperties(Map properties, com.oracle.truffle.api.nodes.Node node) { - NodeCost nodeCost = node.getCost(); - if (nodeCost != null) { - properties.put("cost", node.getCost()); - } var nodeInfo = node.getClass().getAnnotation(com.oracle.truffle.api.nodes.NodeInfo.class); if (nodeInfo != null) { if (!nodeInfo.shortName().isEmpty()) { diff --git a/truffle/src/com.oracle.truffle.runtime/src/com/oracle/truffle/runtime/OptimizedBlockNode.java b/truffle/src/com.oracle.truffle.runtime/src/com/oracle/truffle/runtime/OptimizedBlockNode.java index 41fa6c312fe3..a91041de0d28 100644 --- a/truffle/src/com.oracle.truffle.runtime/src/com/oracle/truffle/runtime/OptimizedBlockNode.java +++ b/truffle/src/com.oracle.truffle.runtime/src/com/oracle/truffle/runtime/OptimizedBlockNode.java @@ -473,9 +473,7 @@ static final class BlockVisitor implements NodeVisitor { @Override public boolean visit(Node node) { - if (!node.getCost().isTrivial()) { - count++; - } + count++; if (node instanceof BlockNode) { computeBlock((OptimizedBlockNode) node); } else { diff --git a/truffle/src/com.oracle.truffle.runtime/src/com/oracle/truffle/runtime/OptimizedCallTarget.java b/truffle/src/com.oracle.truffle.runtime/src/com/oracle/truffle/runtime/OptimizedCallTarget.java index 75a2b5c44847..85567588c4c8 100644 --- a/truffle/src/com.oracle.truffle.runtime/src/com/oracle/truffle/runtime/OptimizedCallTarget.java +++ b/truffle/src/com.oracle.truffle.runtime/src/com/oracle/truffle/runtime/OptimizedCallTarget.java @@ -1176,7 +1176,7 @@ public final void accept(NodeVisitor visitor) { @Override public final int getNonTrivialNodeCount() { if (cachedNonTrivialNodeCount == -1) { - cachedNonTrivialNodeCount = calculateNonTrivialNodes(getRootNode()); + cachedNonTrivialNodeCount = NodeUtil.countNodes(getRootNode()); } return cachedNonTrivialNodeCount; } @@ -1194,12 +1194,6 @@ public final long getInitializedTimestamp() { return initializedTimestamp; } - public static int calculateNonTrivialNodes(Node node) { - NonTrivialNodeCountVisitor visitor = new NonTrivialNodeCountVisitor(); - node.accept(visitor); - return visitor.nodeCount; - } - public final Map getDebugProperties() { Map properties = new LinkedHashMap<>(); OptimizedTruffleRuntimeListener.addASTSizeProperty(this, properties); @@ -1620,18 +1614,6 @@ final int getUninitializedNodeCount() { return uninitializedNodeCount; } - private static final class NonTrivialNodeCountVisitor implements NodeVisitor { - public int nodeCount; - - @Override - public boolean visit(Node node) { - if (!node.getCost().isTrivial()) { - nodeCount++; - } - return true; - } - } - @Override public final boolean equals(Object obj) { return obj == this; diff --git a/truffle/src/com.oracle.truffle.runtime/src/com/oracle/truffle/runtime/debug/StatisticsListener.java b/truffle/src/com.oracle.truffle.runtime/src/com/oracle/truffle/runtime/debug/StatisticsListener.java index d4b9810143ff..5292e3698803 100644 --- a/truffle/src/com.oracle.truffle.runtime/src/com/oracle/truffle/runtime/debug/StatisticsListener.java +++ b/truffle/src/com.oracle.truffle.runtime/src/com/oracle/truffle/runtime/debug/StatisticsListener.java @@ -60,7 +60,6 @@ import com.oracle.truffle.api.nodes.IndirectCallNode; import com.oracle.truffle.api.nodes.LoopNode; import com.oracle.truffle.api.nodes.Node; -import com.oracle.truffle.api.nodes.NodeCost; import com.oracle.truffle.api.nodes.NodeVisitor; import com.oracle.truffle.compiler.TruffleCompilable; import com.oracle.truffle.compiler.TruffleCompilerListener.CompilationResultInfo; @@ -68,9 +67,9 @@ import com.oracle.truffle.runtime.AbstractCompilationTask; import com.oracle.truffle.runtime.AbstractGraalTruffleRuntimeListener; import com.oracle.truffle.runtime.EngineData; -import com.oracle.truffle.runtime.OptimizedTruffleRuntime; import com.oracle.truffle.runtime.OptimizedCallTarget; import com.oracle.truffle.runtime.OptimizedDirectCallNode; +import com.oracle.truffle.runtime.OptimizedTruffleRuntime; public final class StatisticsListener extends AbstractGraalTruffleRuntimeListener { @@ -98,11 +97,6 @@ public final class StatisticsListener extends AbstractGraalTruffleRuntimeListene private final TargetLongStatistics timeInQueue = new TargetLongStatistics(); private final TargetIntStatistics nodeCount = new TargetIntStatistics(); - private final TargetIntStatistics nodeCountTrivial = new TargetIntStatistics(); - private final TargetIntStatistics nodeCountNonTrivial = new TargetIntStatistics(); - private final TargetIntStatistics nodeCountMonomorphic = new TargetIntStatistics(); - private final TargetIntStatistics nodeCountPolymorphic = new TargetIntStatistics(); - private final TargetIntStatistics nodeCountMegamorphic = new TargetIntStatistics(); private final IdentityStatistics> nodeStatistics = new IdentityStatistics<>(); private final TargetIntStatistics callCount = new TargetIntStatistics(); @@ -215,11 +209,6 @@ public synchronized void onCompilationTruffleTierFinished(OptimizedCallTarget ta CallTargetNodeStatistics callTargetStat = new CallTargetNodeStatistics(task); nodeCount.accept(callTargetStat.getNodeCount(), target); - nodeCountTrivial.accept(callTargetStat.getNodeCountTrivial(), target); - nodeCountNonTrivial.accept(callTargetStat.getNodeCountNonTrivial(), target); - nodeCountMonomorphic.accept(callTargetStat.getNodeCountMonomorphic(), target); - nodeCountPolymorphic.accept(callTargetStat.getNodeCountPolymorphic(), target); - nodeCountMegamorphic.accept(callTargetStat.getNodeCountMegamorphic(), target); callCount.accept(callTargetStat.getCallCount(), target); callCountIndirect.accept(callTargetStat.getCallCountIndirect(), target); @@ -365,11 +354,6 @@ private void printStatistics(EngineData runtimeData) { printStatistic(out, "---------------------------"); printStatistic(out, "AST node statistics "); printStatistic(out, " Truffle node count", nodeCount); - printStatistic(out, " Trivial", nodeCountTrivial); - printStatistic(out, " Non Trivial", nodeCountNonTrivial); - printStatistic(out, " Monomorphic", nodeCountMonomorphic); - printStatistic(out, " Polymorphic", nodeCountPolymorphic); - printStatistic(out, " Megamorphic", nodeCountMegamorphic); printStatistic(out, " Truffle call count", callCount); printStatistic(out, " Indirect", callCountIndirect); printStatistic(out, " Direct", callCountDirect); @@ -564,11 +548,7 @@ public void accept(Collection elements, OptimizedCallTarget target) { private static final class CallTargetNodeStatistics { // nodeCount = truffleNodeCountTrivial + truffleNodeCountNonTrivial - private int nodeCountTrivial; - private int nodeCountNonTrivial; - private int nodeCountMonomorphic; - private int nodeCountPolymorphic; - private int nodeCountMegamorphic; + private int nodeCount; // callCount = truffleCallCountDirect + truffleCallCountIndirect private int callCountIndirect; @@ -592,19 +572,7 @@ private boolean visitNode(Node node) { return true; } - NodeCost cost = node.getCost(); - if (cost.isTrivial()) { - nodeCountTrivial++; - } else { - nodeCountNonTrivial++; - if (cost == NodeCost.MONOMORPHIC) { - nodeCountMonomorphic++; - } else if (cost == NodeCost.POLYMORPHIC) { - nodeCountPolymorphic++; - } else if (cost == NodeCost.MEGAMORPHIC) { - nodeCountMegamorphic++; - } - } + nodeCount++; if (node instanceof DirectCallNode) { OptimizedDirectCallNode optimizedDirectCallNode = node instanceof OptimizedDirectCallNode ? ((OptimizedDirectCallNode) node) : null; @@ -631,7 +599,7 @@ public int getCallCountDirectNotCloned() { } public int getNodeCount() { - return nodeCountTrivial + nodeCountNonTrivial; + return nodeCount; } public int getCallCount() { @@ -642,26 +610,6 @@ public int getCallCountDirect() { return callCountDirectDispatched + callCountDirectInlined; } - public int getNodeCountTrivial() { - return nodeCountTrivial; - } - - public int getNodeCountNonTrivial() { - return nodeCountNonTrivial; - } - - public int getNodeCountMonomorphic() { - return nodeCountMonomorphic; - } - - public int getNodeCountPolymorphic() { - return nodeCountPolymorphic; - } - - public int getNodeCountMegamorphic() { - return nodeCountMegamorphic; - } - public int getCallCountIndirect() { return callCountIndirect; } diff --git a/truffle/src/com.oracle.truffle.runtime/src/com/oracle/truffle/runtime/debug/TraceCompilationPolymorphismListener.java b/truffle/src/com.oracle.truffle.runtime/src/com/oracle/truffle/runtime/debug/TraceCompilationPolymorphismListener.java index c7c3927fa4d2..9126d89dace5 100644 --- a/truffle/src/com.oracle.truffle.runtime/src/com/oracle/truffle/runtime/debug/TraceCompilationPolymorphismListener.java +++ b/truffle/src/com.oracle.truffle.runtime/src/com/oracle/truffle/runtime/debug/TraceCompilationPolymorphismListener.java @@ -44,7 +44,6 @@ import java.util.Map; import com.oracle.truffle.api.nodes.Node; -import com.oracle.truffle.api.nodes.NodeCost; import com.oracle.truffle.api.nodes.NodeUtil; import com.oracle.truffle.api.nodes.NodeVisitor; import com.oracle.truffle.compiler.TruffleCompilerListener.CompilationResultInfo; @@ -70,13 +69,14 @@ public void onCompilationSuccess(OptimizedCallTarget target, AbstractCompilation if (target.getOptionValue(OptimizedRuntimeOptions.TraceCompilationPolymorphism)) { target.accept(new NodeVisitor() { @Override + @SuppressWarnings("deprecation") public boolean visit(Node node) { - if (node != null && (node.getCost() == NodeCost.MEGAMORPHIC || node.getCost() == NodeCost.POLYMORPHIC)) { - NodeCost cost = node.getCost(); + if (node != null && (node.getCost() == com.oracle.truffle.api.nodes.NodeCost.MEGAMORPHIC || node.getCost() == com.oracle.truffle.api.nodes.NodeCost.POLYMORPHIC)) { + com.oracle.truffle.api.nodes.NodeCost cost = node.getCost(); Map props = new LinkedHashMap<>(); props.put("simpleName", node.getClass().getSimpleName()); props.put("subtree", "\n" + NodeUtil.printCompactTreeToString(node)); - String msg = cost == NodeCost.MEGAMORPHIC ? "megamorphic" : "polymorphic"; + String msg = cost == com.oracle.truffle.api.nodes.NodeCost.MEGAMORPHIC ? "megamorphic" : "polymorphic"; runtime.logEvent(target, 0, msg, node.toString(), props, null); } return true; diff --git a/truffle/src/com.oracle.truffle.tck/snapshot.sigtest b/truffle/src/com.oracle.truffle.tck/snapshot.sigtest index 3a779d23270c..bd9d4ad761ea 100644 --- a/truffle/src/com.oracle.truffle.tck/snapshot.sigtest +++ b/truffle/src/com.oracle.truffle.tck/snapshot.sigtest @@ -56,6 +56,7 @@ intf java.lang.annotation.Annotation meth public abstract !hasdefault boolean interactive() meth public abstract !hasdefault boolean internal() meth public abstract !hasdefault boolean needsAllEncodings() + anno 0 java.lang.Deprecated(boolean forRemoval=false, java.lang.String since="24.1") meth public abstract !hasdefault com.oracle.truffle.api.TruffleLanguage$ContextPolicy contextPolicy() meth public abstract !hasdefault java.lang.Class[] internalResources() meth public abstract !hasdefault java.lang.Class[] fileTypeDetectors()