Mercurial > hg > graal-compiler
changeset 22506:2cf6e3d9a107
do not require a DirectCallNode to be adopted for cloneCallTarget()
author | Benoit Daloze <benoit.daloze@jku.at> |
---|---|
date | Tue, 25 Aug 2015 18:29:04 +0200 |
parents | 80c6d958dbea |
children | d84c5bd1e65c |
files | graal/com.oracle.graal.truffle.test/src/com/oracle/graal/truffle/test/TruffleDirectCallNodeTest.java graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedDirectCallNode.java |
diffstat | 2 files changed, 58 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- /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()); + } +}
--- 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 {