# HG changeset patch # User Benoit Daloze # Date 1440520144 -7200 # Node ID 2cf6e3d9a107509c4cb44df5fd559e41ce4def25 # Parent 80c6d958dbeaa7c984942b33e45f8baea7262742 do not require a DirectCallNode to be adopted for cloneCallTarget() diff -r 80c6d958dbea -r 2cf6e3d9a107 graal/com.oracle.graal.truffle.test/src/com/oracle/graal/truffle/test/TruffleDirectCallNodeTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.truffle.test/src/com/oracle/graal/truffle/test/TruffleDirectCallNodeTest.java Tue Aug 25 18:29:04 2015 +0200 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.truffle.test; + +import static org.junit.Assert.*; + +import org.junit.*; + +import com.oracle.truffle.api.*; +import com.oracle.truffle.api.frame.*; +import com.oracle.truffle.api.nodes.*; + +public class TruffleDirectCallNodeTest { + + @Test + public void testCanBeClonedWithoutParent() { + final RootNode rootNode = new RootNode(MockLanguage.class, null, null) { + @Override + public Object execute(VirtualFrame frame) { + return 42; + } + + @Override + public boolean isCloningAllowed() { + return true; + } + }; + final CallTarget callTarget = Truffle.getRuntime().createCallTarget(rootNode); + final DirectCallNode callNode = Truffle.getRuntime().createDirectCallNode(callTarget); + + assertTrue(callNode.isCallTargetCloningAllowed()); + assertTrue(callNode.cloneCallTarget()); + } +} diff -r 80c6d958dbea -r 2cf6e3d9a107 graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedDirectCallNode.java --- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedDirectCallNode.java Tue Aug 25 15:06:36 2015 +0200 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedDirectCallNode.java Tue Aug 25 18:29:04 2015 +0200 @@ -157,8 +157,10 @@ } newTarget.incrementKnownCallSites(); - // dummy replace to report the split - replace(this, "Split call " + newTarget.toString()); + if (getParent() != null) { + // dummy replace to report the split, irrelevant if this node is not adopted + replace(this, "Split call " + newTarget.toString()); + } if (newTarget.getSourceCallTarget() == null) { splitCallTarget = null; } else {