1 /* 2 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 /* 24 */ 25 package org.graalvm.compiler.core.test; 26 27 import org.junit.Test; 28 29 import org.graalvm.compiler.code.CompilationResult; 30 import org.graalvm.compiler.core.phases.HighTier; 31 import org.graalvm.compiler.nodes.StructuredGraph; 32 import org.graalvm.compiler.nodes.StructuredGraph.AllowAssumptions; 33 import org.graalvm.compiler.options.OptionValues; 34 import org.graalvm.compiler.phases.tiers.Suites; 35 36 import jdk.vm.ci.meta.ResolvedJavaMethod; 37 38 public final class DontReuseArgumentSpaceTest extends GraalCompilerTest { 39 40 @Override 41 @SuppressWarnings("try") 42 protected Suites createSuites(OptionValues options) { 43 return super.createSuites(new OptionValues(options, HighTier.Options.Inline, false)); 44 } 45 46 @BytecodeParserNeverInline 47 public static int killArguments(int a, int b, int c, int d, int e, int f, int g, int h, int i, int j) { 48 return a + b + c + d + e + f + g + h + i + j; 49 } 50 51 @BytecodeParserNeverInline 52 public static int callTwice(int a, int b, int c, int d, int e, int f, int g, int h, int i, int j) { 53 /* 54 * Call the same method twice so the arguments are in the same place each time and might 55 * appear to be redundant moves. 56 */ 57 killArguments(a, b, c, d, e, f, g, h, i, j); 58 return killArguments(a, b, c, d, e, f, g, h, i, j); 59 } 60 61 @Test 62 public void run0() throws Throwable { 63 /* 64 * Exercise the methods once so everything is resolved 65 */ 66 callTwice(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); 67 68 /* 69 * Create a standalone compile of killArguments. This test assumes that zapping of argument 70 * space is being performed by the backend. 71 */ 72 ResolvedJavaMethod javaMethod = getResolvedJavaMethod("killArguments"); 73 StructuredGraph graph = parseEager(javaMethod, AllowAssumptions.YES); 74 CompilationResult compilationResult = compile(javaMethod, graph); 75 getBackend().createDefaultInstalledCode(javaMethod, compilationResult); 76 77 test("callTwice", 1, 2, 3, 4, 5, 6, 7, 8, 9, 10); 78 } 79 }