Mercurial > hg > truffle
changeset 17250:9f001294893d
Truffle: Added test case that compiler intrinsics are not intrinsified if hidden behind a @SlowPath.
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Mon, 29 Sep 2014 18:37:24 +0200 |
parents | c13f423bd4ed |
children | 6ee7afea175a |
files | graal/com.oracle.graal.truffle.test/sl/TestSlowPath01.sl graal/com.oracle.graal.truffle.test/src/com/oracle/graal/truffle/test/SLTruffleGraalTestSuite.java graal/com.oracle.graal.truffle.test/src/com/oracle/graal/truffle/test/builtins/SLTestSlowPath01Builtin.java |
diffstat | 3 files changed, 86 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.truffle.test/sl/TestSlowPath01.sl Mon Sep 29 18:37:24 2014 +0200 @@ -0,0 +1,11 @@ +/* + * This test verifies that CallTargets cannot exceed the TruffleInliningMaxCallerSize limit when inlining. + */ + +function test1() { + testSlowPath01(); +} +function main() { + waitForOptimization(callUntilOptimized(test1)); + assertTrue(isOptimized(test1), "inlinableFunction must be compiled properly"); +}
--- a/graal/com.oracle.graal.truffle.test/src/com/oracle/graal/truffle/test/SLTruffleGraalTestSuite.java Mon Sep 29 16:22:07 2014 +0200 +++ b/graal/com.oracle.graal.truffle.test/src/com/oracle/graal/truffle/test/SLTruffleGraalTestSuite.java Mon Sep 29 18:37:24 2014 +0200 @@ -47,6 +47,9 @@ SLTestRunner.installBuiltin(SLCallUntilOptimizedBuiltinFactory.getInstance()); SLTestRunner.installBuiltin(SLIsInlinedBuiltinFactory.getInstance()); SLTestRunner.installBuiltin(SLGenerateDummyNodesBuiltinFactory.getInstance()); + + /* test specific builtins */ + SLTestRunner.installBuiltin(SLTestSlowPath01BuiltinFactory.getInstance()); } /*
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.truffle.test/src/com/oracle/graal/truffle/test/builtins/SLTestSlowPath01Builtin.java Mon Sep 29 18:37:24 2014 +0200 @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2014, 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.builtins; + +import java.util.concurrent.*; + +import com.oracle.truffle.api.*; +import com.oracle.truffle.api.CompilerDirectives.SlowPath; +import com.oracle.truffle.api.dsl.*; +import com.oracle.truffle.api.nodes.*; +import com.oracle.truffle.sl.runtime.*; + +/** + * Just used in TestSlowPath01.sl. Verifies that all intrinsics have no effect inside of a @SlowPath + * annotated method. + */ +@NodeInfo(shortName = "testSlowPath01") +public abstract class SLTestSlowPath01Builtin extends SLGraalRuntimeBuiltin { + + private static Object nonConstantValue = new Object(); + + @Specialization + @SlowPath + public Object testSlowPath() { + CompilerAsserts.neverPartOfCompilation(); + CompilerAsserts.neverPartOfCompilation("Should never throw an exception when compiling."); + CompilerAsserts.compilationConstant(nonConstantValue); + CompilerDirectives.transferToInterpreter(); + CompilerDirectives.transferToInterpreterAndInvalidate(); + CompilerDirectives.bailout("Should not fail"); + if (CompilerDirectives.inCompiledCode()) { + throw new AssertionError(); + } + if (!CompilerDirectives.inInterpreter()) { + throw new AssertionError(); + } + try { + int result = (int) CompilerDirectives.interpreterOnly(new Callable<Object>() { + public Object call() throws Exception { + return 1; + } + }); + if (result != 1) { + throw new AssertionError(); + } + } catch (Exception e) { + throw new AssertionError(); + } + + return SLNull.SINGLETON; + } +}