< prev index next >

src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.lir/src/org/graalvm/compiler/lir/alloc/trace/lsra/TraceLinearScanResolveDataFlowPhase.java

Print this page




   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.lir.alloc.trace.lsra;
  24 
  25 import static jdk.vm.ci.code.ValueUtil.isRegister;
  26 import static org.graalvm.compiler.core.common.GraalOptions.DetailedAsserts;
  27 import static org.graalvm.compiler.lir.LIRValueUtil.asConstant;
  28 import static org.graalvm.compiler.lir.LIRValueUtil.asVariable;
  29 import static org.graalvm.compiler.lir.LIRValueUtil.isConstantValue;
  30 import static org.graalvm.compiler.lir.LIRValueUtil.isStackSlotValue;
  31 import static org.graalvm.compiler.lir.LIRValueUtil.isVirtualStackSlot;
  32 
  33 import java.util.ArrayList;
  34 
  35 import org.graalvm.compiler.core.common.alloc.RegisterAllocationConfig;
  36 import org.graalvm.compiler.core.common.alloc.Trace;
  37 import org.graalvm.compiler.core.common.alloc.TraceBuilderResult;
  38 import org.graalvm.compiler.core.common.cfg.AbstractBlockBase;

  39 import org.graalvm.compiler.debug.CounterKey;
  40 import org.graalvm.compiler.debug.DebugContext;
  41 import org.graalvm.compiler.debug.Indent;
  42 import org.graalvm.compiler.lir.LIR;
  43 import org.graalvm.compiler.lir.LIRInstruction;
  44 import org.graalvm.compiler.lir.StandardOp;
  45 import org.graalvm.compiler.lir.StandardOp.JumpOp;
  46 import org.graalvm.compiler.lir.StandardOp.LabelOp;
  47 import org.graalvm.compiler.lir.alloc.trace.GlobalLivenessInfo;
  48 import org.graalvm.compiler.lir.alloc.trace.lsra.TraceLinearScanPhase.TraceLinearScan;
  49 import org.graalvm.compiler.lir.gen.LIRGenerationResult;
  50 import org.graalvm.compiler.lir.gen.LIRGeneratorTool.MoveFactory;
  51 import org.graalvm.compiler.lir.ssa.SSAUtil;
  52 
  53 import jdk.vm.ci.code.TargetDescription;
  54 import jdk.vm.ci.meta.Value;
  55 
  56 /**
  57  * Phase 6: resolve data flow
  58  *


  80         private void resolveFindInsertPos(AbstractBlockBase<?> fromBlock, AbstractBlockBase<?> toBlock, TraceLocalMoveResolver moveResolver) {
  81             if (fromBlock.getSuccessorCount() <= 1) {
  82                 if (debug.isLogEnabled()) {
  83                     debug.log("inserting moves at end of fromBlock B%d", fromBlock.getId());
  84                 }
  85 
  86                 ArrayList<LIRInstruction> instructions = allocator.getLIR().getLIRforBlock(fromBlock);
  87                 LIRInstruction instr = instructions.get(instructions.size() - 1);
  88                 if (instr instanceof StandardOp.JumpOp) {
  89                     // insert moves before branch
  90                     moveResolver.setInsertPosition(instructions, instructions.size() - 1);
  91                 } else {
  92                     moveResolver.setInsertPosition(instructions, instructions.size());
  93                 }
  94 
  95             } else {
  96                 if (debug.isLogEnabled()) {
  97                     debug.log("inserting moves at beginning of toBlock B%d", toBlock.getId());
  98                 }
  99 
 100                 if (DetailedAsserts.getValue(allocator.getOptions())) {
 101                     assert allocator.getLIR().getLIRforBlock(fromBlock).get(0) instanceof StandardOp.LabelOp : "block does not start with a label";
 102 
 103                     /*
 104                      * Because the number of predecessor edges matches the number of successor
 105                      * edges, blocks which are reached by switch statements may have be more than
 106                      * one predecessor but it will be guaranteed that all predecessors will be the
 107                      * same.
 108                      */
 109                     for (AbstractBlockBase<?> predecessor : toBlock.getPredecessors()) {
 110                         assert fromBlock == predecessor : "all critical edges must be broken";
 111                     }
 112                 }
 113 
 114                 moveResolver.setInsertPosition(allocator.getLIR().getLIRforBlock(toBlock), 1);
 115             }
 116         }
 117 
 118         /**
 119          * Inserts necessary moves (spilling or reloading) at edges between blocks for intervals
 120          * that have been split.




   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.lir.alloc.trace.lsra;
  24 
  25 import static jdk.vm.ci.code.ValueUtil.isRegister;

  26 import static org.graalvm.compiler.lir.LIRValueUtil.asConstant;
  27 import static org.graalvm.compiler.lir.LIRValueUtil.asVariable;
  28 import static org.graalvm.compiler.lir.LIRValueUtil.isConstantValue;
  29 import static org.graalvm.compiler.lir.LIRValueUtil.isStackSlotValue;
  30 import static org.graalvm.compiler.lir.LIRValueUtil.isVirtualStackSlot;
  31 
  32 import java.util.ArrayList;
  33 
  34 import org.graalvm.compiler.core.common.alloc.RegisterAllocationConfig;
  35 import org.graalvm.compiler.core.common.alloc.Trace;
  36 import org.graalvm.compiler.core.common.alloc.TraceBuilderResult;
  37 import org.graalvm.compiler.core.common.cfg.AbstractBlockBase;
  38 import org.graalvm.compiler.debug.Assertions;
  39 import org.graalvm.compiler.debug.CounterKey;
  40 import org.graalvm.compiler.debug.DebugContext;
  41 import org.graalvm.compiler.debug.Indent;
  42 import org.graalvm.compiler.lir.LIR;
  43 import org.graalvm.compiler.lir.LIRInstruction;
  44 import org.graalvm.compiler.lir.StandardOp;
  45 import org.graalvm.compiler.lir.StandardOp.JumpOp;
  46 import org.graalvm.compiler.lir.StandardOp.LabelOp;
  47 import org.graalvm.compiler.lir.alloc.trace.GlobalLivenessInfo;
  48 import org.graalvm.compiler.lir.alloc.trace.lsra.TraceLinearScanPhase.TraceLinearScan;
  49 import org.graalvm.compiler.lir.gen.LIRGenerationResult;
  50 import org.graalvm.compiler.lir.gen.LIRGeneratorTool.MoveFactory;
  51 import org.graalvm.compiler.lir.ssa.SSAUtil;
  52 
  53 import jdk.vm.ci.code.TargetDescription;
  54 import jdk.vm.ci.meta.Value;
  55 
  56 /**
  57  * Phase 6: resolve data flow
  58  *


  80         private void resolveFindInsertPos(AbstractBlockBase<?> fromBlock, AbstractBlockBase<?> toBlock, TraceLocalMoveResolver moveResolver) {
  81             if (fromBlock.getSuccessorCount() <= 1) {
  82                 if (debug.isLogEnabled()) {
  83                     debug.log("inserting moves at end of fromBlock B%d", fromBlock.getId());
  84                 }
  85 
  86                 ArrayList<LIRInstruction> instructions = allocator.getLIR().getLIRforBlock(fromBlock);
  87                 LIRInstruction instr = instructions.get(instructions.size() - 1);
  88                 if (instr instanceof StandardOp.JumpOp) {
  89                     // insert moves before branch
  90                     moveResolver.setInsertPosition(instructions, instructions.size() - 1);
  91                 } else {
  92                     moveResolver.setInsertPosition(instructions, instructions.size());
  93                 }
  94 
  95             } else {
  96                 if (debug.isLogEnabled()) {
  97                     debug.log("inserting moves at beginning of toBlock B%d", toBlock.getId());
  98                 }
  99 
 100                 if (Assertions.detailedAssertionsEnabled(allocator.getOptions())) {
 101                     assert allocator.getLIR().getLIRforBlock(fromBlock).get(0) instanceof StandardOp.LabelOp : "block does not start with a label";
 102 
 103                     /*
 104                      * Because the number of predecessor edges matches the number of successor
 105                      * edges, blocks which are reached by switch statements may have be more than
 106                      * one predecessor but it will be guaranteed that all predecessors will be the
 107                      * same.
 108                      */
 109                     for (AbstractBlockBase<?> predecessor : toBlock.getPredecessors()) {
 110                         assert fromBlock == predecessor : "all critical edges must be broken";
 111                     }
 112                 }
 113 
 114                 moveResolver.setInsertPosition(allocator.getLIR().getLIRforBlock(toBlock), 1);
 115             }
 116         }
 117 
 118         /**
 119          * Inserts necessary moves (spilling or reloading) at edges between blocks for intervals
 120          * that have been split.


< prev index next >