changeset 13326:ac5243877cc7

made commoning of loading constants non-configurable (GRAAL-508)
author Doug Simon <doug.simon@oracle.com>
date Fri, 13 Dec 2013 14:10:30 +0100
parents da0851712519
children c258331fdde6
files graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/LIRGenerator.java
diffstat 1 files changed, 21 insertions(+), 53 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/LIRGenerator.java	Fri Dec 13 14:05:48 2013 +0100
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/LIRGenerator.java	Fri Dec 13 14:10:30 2013 +0100
@@ -83,12 +83,6 @@
     private final boolean printIRWithLIR;
 
     /**
-     * Maps constants to variables within the scope of a single block to avoid loading a constant
-     * more than once per block.
-     */
-    private Map<Constant, Variable> constantsLoadedInCurrentBlock;
-
-    /**
      * Handle for an operation that loads a constant into a variable. The operation starts in the
      * first block where the constant is used but will eventually be
      * {@linkplain LIRGenerator#insertConstantLoads() moved} to a block dominating all usages of the
@@ -240,12 +234,6 @@
         return operand;
     }
 
-    /**
-     * Controls whether commoning is performed on {@linkplain #canInlineConstant(Constant)
-     * non-inlinable} constants.
-     */
-    private static final boolean CommonConstantLoads = Boolean.parseBoolean(System.getProperty("graal.commonConstantLoads", "true"));
-
     private Value getConstantOperand(ValueNode node) {
         if (!ConstantNodeRecordsUsages) {
             Constant value = node.asConstant();
@@ -254,42 +242,29 @@
                     return !node.isExternal() ? setResult(node, value) : value;
                 } else {
                     Variable loadedValue;
-                    if (CommonConstantLoads) {
-                        if (constantLoads == null) {
-                            constantLoads = new HashMap<>();
-                        }
-                        LoadConstant load = constantLoads.get(value);
-                        if (load == null) {
-                            int index = lir.lir(currentBlock).size();
-                            // loadedValue = newVariable(value.getPlatformKind());
-                            loadedValue = emitMove(value);
-                            LIRInstruction op = lir.lir(currentBlock).get(index);
-                            constantLoads.put(value, new LoadConstant(loadedValue, currentBlock, index, op));
+                    if (constantLoads == null) {
+                        constantLoads = new HashMap<>();
+                    }
+                    LoadConstant load = constantLoads.get(value);
+                    if (load == null) {
+                        int index = lir.lir(currentBlock).size();
+                        // loadedValue = newVariable(value.getPlatformKind());
+                        loadedValue = emitMove(value);
+                        LIRInstruction op = lir.lir(currentBlock).get(index);
+                        constantLoads.put(value, new LoadConstant(loadedValue, currentBlock, index, op));
+                    } else {
+                        Block dominator = ControlFlowGraph.commonDominator(load.block, currentBlock);
+                        loadedValue = load.variable;
+                        if (dominator != load.block) {
+                            if (load.index >= 0) {
+                                List<LIRInstruction> instructions = lir.lir(load.block);
+                                instructions.set(load.index, new NoOp(null, -1));
+                                load.index = -1;
+                            }
                         } else {
-                            Block dominator = ControlFlowGraph.commonDominator(load.block, currentBlock);
-                            loadedValue = load.variable;
-                            if (dominator != load.block) {
-                                if (load.index >= 0) {
-                                    List<LIRInstruction> instructions = lir.lir(load.block);
-                                    instructions.set(load.index, new NoOp(null, -1));
-                                    load.index = -1;
-                                }
-                            } else {
-                                assert load.block != currentBlock || load.index < lir.lir(currentBlock).size();
-                            }
-                            load.block = dominator;
+                            assert load.block != currentBlock || load.index < lir.lir(currentBlock).size();
                         }
-                    } else {
-                        if (constantsLoadedInCurrentBlock == null) {
-                            constantsLoadedInCurrentBlock = new HashMap<>();
-                            loadedValue = null;
-                        } else {
-                            loadedValue = constantsLoadedInCurrentBlock.get(value);
-                        }
-                        if (loadedValue == null) {
-                            loadedValue = emitMove(value);
-                            constantsLoadedInCurrentBlock.put(value, loadedValue);
-                        }
+                        load.block = dominator;
                     }
                     return loadedValue;
                 }
@@ -442,7 +417,6 @@
         }
 
         currentBlock = block;
-        resetLoadedConstants();
 
         // set up the list of LIR instructions
         assert lir.lir(block) == null : "LIR list already computed for this block";
@@ -506,12 +480,6 @@
         }
     }
 
-    private void resetLoadedConstants() {
-        if (constantsLoadedInCurrentBlock != null && !constantsLoadedInCurrentBlock.isEmpty()) {
-            constantsLoadedInCurrentBlock.clear();
-        }
-    }
-
     protected abstract boolean peephole(ValueNode valueNode);
 
     private boolean hasBlockEnd(Block block) {