1 /* 2 * Copyright (c) 2016, 2018, 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 26 27 package org.graalvm.compiler.core.test; 28 29 import org.junit.Test; 30 31 import org.graalvm.compiler.code.CompilationResult; 32 import org.graalvm.compiler.core.phases.HighTier; 33 import org.graalvm.compiler.debug.DebugContext; 34 import org.graalvm.compiler.nodes.StructuredGraph; 35 import org.graalvm.compiler.nodes.StructuredGraph.AllowAssumptions; 36 import org.graalvm.compiler.options.OptionValues; 37 import org.graalvm.compiler.phases.tiers.Suites; 38 39 import jdk.vm.ci.meta.ResolvedJavaMethod; 40 41 public final class DontReuseArgumentSpaceTest extends GraalCompilerTest { 42 43 @Override 44 @SuppressWarnings("try") 45 protected Suites createSuites(OptionValues options) { 46 return super.createSuites(new OptionValues(options, HighTier.Options.Inline, false)); 47 } 48 49 @BytecodeParserNeverInline 50 public static int killArguments(int a, int b, int c, int d, int e, int f, int g, int h, int i, int j) { 51 return a + b + c + d + e + f + g + h + i + j; 52 } 53 54 @BytecodeParserNeverInline 55 public static int callTwice(int a, int b, int c, int d, int e, int f, int g, int h, int i, int j) { 56 /* 57 * Call the same method twice so the arguments are in the same place each time and might 58 * appear to be redundant moves. 59 */ 60 killArguments(a, b, c, d, e, f, g, h, i, j); 61 return killArguments(a, b, c, d, e, f, g, h, i, j); 62 } 63 64 @Test 65 public void run0() throws Throwable { 66 /* 67 * Exercise the methods once so everything is resolved 68 */ 69 callTwice(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); 70 71 /* 72 * Create a standalone compile of killArguments. This test assumes that zapping of argument 73 * space is being performed by the backend. 74 */ 75 ResolvedJavaMethod javaMethod = getResolvedJavaMethod("killArguments"); 76 StructuredGraph graph = parseEager(javaMethod, AllowAssumptions.YES); 77 CompilationResult compilationResult = compile(javaMethod, graph); 78 DebugContext debug = getDebugContext(); 79 getBackend().createDefaultInstalledCode(debug, javaMethod, compilationResult); 80 81 test("callTwice", 1, 2, 3, 4, 5, 6, 7, 8, 9, 10); 82 } 83 }