# HG changeset patch # User Josef Eisl # Date 1394653201 -3600 # Node ID be2be30c653d189d6980d7f120c8ec7d37a51590 # Parent 3518daf2f9bc1f862e724592ab3b49b5d3503194 Introduce AbstractControlFlowGraph. diff -r 3518daf2f9bc -r be2be30c653d graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/LIRGenerator.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/LIRGenerator.java Wed Mar 12 20:32:44 2014 +0100 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/LIRGenerator.java Wed Mar 12 20:40:01 2014 +0100 @@ -341,7 +341,8 @@ } public LabelRef getLIRBlock(FixedNode b) { - Block result = lir.getControlFlowGraph().blockFor(b); + assert lir.getControlFlowGraph() instanceof ControlFlowGraph; + Block result = ((ControlFlowGraph) lir.getControlFlowGraph()).blockFor(b); int suxIndex = currentBlock.getSuccessors().indexOf(result); assert suxIndex != -1 : "Block not in successor list of current block"; diff -r 3518daf2f9bc -r be2be30c653d graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIR.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIR.java Wed Mar 12 20:32:44 2014 +0100 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIR.java Wed Mar 12 20:40:01 2014 +0100 @@ -35,7 +35,7 @@ */ public class LIR { - private final ControlFlowGraph cfg; + private final AbstractControlFlowGraph cfg; /** * The linear-scan ordered list of blocks. @@ -65,14 +65,14 @@ /** * Creates a new LIR instance for the specified compilation. */ - public LIR(ControlFlowGraph cfg, List> linearScanOrder, List> codeEmittingOrder) { + public LIR(AbstractControlFlowGraph cfg, List> linearScanOrder, List> codeEmittingOrder) { this.cfg = cfg; this.codeEmittingOrder = codeEmittingOrder; this.linearScanOrder = linearScanOrder; this.lirInstructions = new BlockMap<>(cfg); } - public ControlFlowGraph getControlFlowGraph() { + public AbstractControlFlowGraph getControlFlowGraph() { return cfg; } diff -r 3518daf2f9bc -r be2be30c653d graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/cfg/AbstractControlFlowGraph.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/cfg/AbstractControlFlowGraph.java Wed Mar 12 20:40:01 2014 +0100 @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2014, 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.nodes.cfg; + +public interface AbstractControlFlowGraph> { + + T[] getBlocks(); + + Loop[] getLoops(); + + Block getStartBlock(); +} diff -r 3518daf2f9bc -r be2be30c653d graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/cfg/BlockMap.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/cfg/BlockMap.java Wed Mar 12 20:32:44 2014 +0100 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/cfg/BlockMap.java Wed Mar 12 20:40:01 2014 +0100 @@ -27,7 +27,7 @@ private final T[] data; @SuppressWarnings("unchecked") - public BlockMap(ControlFlowGraph cfg) { + public BlockMap(AbstractControlFlowGraph cfg) { data = (T[]) new Object[cfg.getBlocks().length]; } diff -r 3518daf2f9bc -r be2be30c653d graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/cfg/ControlFlowGraph.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/cfg/ControlFlowGraph.java Wed Mar 12 20:32:44 2014 +0100 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/cfg/ControlFlowGraph.java Wed Mar 12 20:40:01 2014 +0100 @@ -28,7 +28,7 @@ import com.oracle.graal.graph.*; import com.oracle.graal.nodes.*; -public class ControlFlowGraph { +public class ControlFlowGraph implements AbstractControlFlowGraph { public final StructuredGraph graph; diff -r 3518daf2f9bc -r be2be30c653d graal/com.oracle.graal.printer/src/com/oracle/graal/printer/CFGPrinterObserver.java --- a/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/CFGPrinterObserver.java Wed Mar 12 20:32:44 2014 +0100 +++ b/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/CFGPrinterObserver.java Wed Mar 12 20:40:01 2014 +0100 @@ -141,7 +141,8 @@ cfgPrinter.target = cfgPrinter.lirGenerator.target(); } if (cfgPrinter.lir != null) { - cfgPrinter.cfg = cfgPrinter.lir.getControlFlowGraph(); + assert cfgPrinter.lir.getControlFlowGraph() instanceof ControlFlowGraph; + cfgPrinter.cfg = (ControlFlowGraph) cfgPrinter.lir.getControlFlowGraph(); } CodeCacheProvider codeCache = Debug.contextLookup(CodeCacheProvider.class);