1 /* 2 * Copyright (c) 2015, 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 package org.graalvm.compiler.nodes.graphbuilderconf; 24 25 import jdk.vm.ci.meta.ResolvedJavaMethod; 26 27 public interface LoopExplosionPlugin extends GraphBuilderPlugin { 28 29 enum LoopExplosionKind { 30 /** 31 * No loop explosion. 32 */ 33 NONE, 34 /** 35 * Fully unroll all loops. The loops must have a known finite number of iterations. If a 36 * loop has multiple loop ends, they are merged so that the subsequent loop iteration is 37 * processed only once. For example, a loop with 4 iterations and 2 loop ends leads to 38 * 1+1+1+1 = 4 copies of the loop body. 39 */ 40 FULL_UNROLL, 41 /** 42 * Fully explode all loops. The loops must have a known finite number of iterations. If a 43 * loop has multiple loop ends, they are not merged so that subsequent loop iterations are 44 * processed multiple times. For example, a loop with 4 iterations and 2 loop ends leads to 45 * 1+2+4+8 = 15 copies of the loop body. 46 */ 47 FULL_EXPLODE, 48 /** 49 * Like {@link #FULL_EXPLODE}, but in addition explosion does not stop at loop exits. Code 50 * after the loop is duplicated for every loop exit of every loop iteration. For example, a 51 * loop with 4 iterations and 2 loop exits leads to 4 * 2 = 8 copies of the code after the 52 * loop. 53 */ 54 FULL_EXPLODE_UNTIL_RETURN, 55 /** 56 * like {@link #FULL_EXPLODE}, but copies of the loop body that have the exact same state 57 * (all local variables have the same value) are merged. This reduces the number of copies 58 * necessary, but can introduce loops again. This kind is useful for bytecode interpreter 59 * loops. 60 */ 61 MERGE_EXPLODE 62 } 63 64 LoopExplosionKind loopExplosionKind(ResolvedJavaMethod method); 65 }