changeset 14816:836d558c3a5f

Create Baseline version of doBlock in LIRGenerator.
author Josef Eisl <josef.eisl@jku.at>
date Wed, 19 Mar 2014 15:14:37 +0100
parents 61821c3e9235
children 2ff2a660c4d8
files graal/com.oracle.graal.baseline/src/com/oracle/graal/baseline/BaselineCompiler.java graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraalCompilerTest.java graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/LIRGenerator.java graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/LIRGeneratorCommon.java
diffstat 4 files changed, 60 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.baseline/src/com/oracle/graal/baseline/BaselineCompiler.java	Wed Mar 19 15:13:13 2014 +0100
+++ b/graal/com.oracle.graal.baseline/src/com/oracle/graal/baseline/BaselineCompiler.java	Wed Mar 19 15:14:37 2014 +0100
@@ -35,9 +35,11 @@
 import com.oracle.graal.api.meta.ResolvedJavaType.Representation;
 import com.oracle.graal.bytecode.*;
 import com.oracle.graal.compiler.*;
+import com.oracle.graal.compiler.alloc.*;
 import com.oracle.graal.compiler.gen.*;
 import com.oracle.graal.compiler.target.*;
 import com.oracle.graal.debug.*;
+import com.oracle.graal.debug.Debug.Scope;
 import com.oracle.graal.graph.*;
 import com.oracle.graal.java.*;
 import com.oracle.graal.java.BciBlockMapping.Block;
@@ -116,18 +118,33 @@
         List<? extends AbstractBlock<?>> linearScanOrder = ComputeBlockOrder.computeLinearScanOrder(blocks.length, b, blockProbabilities);
         List<? extends AbstractBlock<?>> codeEmittingOrder = ComputeBlockOrder.computeCodeEmittingOrder(blocks.length, b, blockProbabilities);
         LIR lir = new LIR(cfg, linearScanOrder, codeEmittingOrder);
-        CallingConvention cc = CodeUtil.getCallingConvention(backend.getProviders().getCodeCache(), CallingConvention.Type.JavaCallee, method, false);
-        LIRGenerationResult lirGenRes = backend.newLIRGenerationResult(lir, backend.newFrameMap(), null);
-        LIRGenerator lirGen = backend.newLIRGenerator(null, cc, lirGenRes);
+        LIRGenerationResult lirGenRes = null;
+        try (Scope ds = Debug.scope("BackEnd", lir)) {
+            FrameMap frameMap = backend.newFrameMap();
+            TargetDescription target = backend.getTarget();
+            CallingConvention cc = CodeUtil.getCallingConvention(backend.getProviders().getCodeCache(), CallingConvention.Type.JavaCallee, method, false);
+            lirGenRes = backend.newLIRGenerationResult(lir, frameMap, null);
+            LIRGenerator lirGen = backend.newLIRGenerator(null, cc, lirGenRes);
+
+            try (Scope s = Debug.scope("LIRGen", lirGen)) {
+                lirGen.doBlock(b);
+                // lirGen.beforeRegisterAllocation();
 
-        // add instruction
-        lirGen.emitAdd(Constant.forLong(42), Constant.forLong(73));
+                Debug.dump(lir, "After LIR generation");
+            } catch (Throwable e) {
+                throw Debug.handle(e);
+            }
 
-        List<LIRInstruction> lirList = null;
-        lir.setLIRforBlock(b, lirList);
-
-        // register allocation
-        lirGenRes.getFrameMap().finish();
+            try (Scope s = Debug.scope("Allocator", lirGen)) {
+                if (backend.shouldAllocateRegisters()) {
+                    new LinearScan(target, lir, frameMap).allocate();
+                }
+            } catch (Throwable e) {
+                throw Debug.handle(e);
+            }
+        } catch (Throwable e) {
+            throw Debug.handle(e);
+        }
 
         // emitCode
         Assumptions assumptions = new Assumptions(OptAssumptions.getValue());
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraalCompilerTest.java	Wed Mar 19 15:13:13 2014 +0100
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraalCompilerTest.java	Wed Mar 19 15:14:37 2014 +0100
@@ -498,7 +498,7 @@
     }
 
     private CompilationResult compileBaseline(ResolvedJavaMethod javaMethod) {
-        try (Scope bds = Debug.scope("compileBaseline")) {
+        try (Scope bds = Debug.scope("compileBaseline", javaMethod)) {
             BaselineCompiler baselineCompiler = new BaselineCompiler(GraphBuilderConfiguration.getDefault(), providers.getMetaAccess());
             return baselineCompiler.generate(javaMethod, -1, getBackend(), new CompilationResult(), javaMethod, CompilationResultBuilderFactory.Default);
         } catch (Throwable e) {
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/LIRGenerator.java	Wed Mar 19 15:13:13 2014 +0100
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/LIRGenerator.java	Wed Mar 19 15:14:37 2014 +0100
@@ -407,7 +407,7 @@
         res.getLIR().getLIRforBlock(currentBlock).add(op);
     }
 
-    public void doBlock(Block block, StructuredGraph graph, BlockMap<List<ScheduledNode>> blockMap) {
+    private final void doBlockStart(AbstractBlock<?> block) {
         if (printIRWithLIR) {
             TTY.print(block.toString());
         }
@@ -423,6 +423,33 @@
         if (traceLevel >= 1) {
             TTY.println("BEGIN Generating LIR for block B" + block.getId());
         }
+    }
+
+    private final void doBlockEnd(AbstractBlock<?> block) {
+
+        if (traceLevel >= 1) {
+            TTY.println("END Generating LIR for block B" + block.getId());
+        }
+
+        currentBlock = null;
+
+        if (printIRWithLIR) {
+            TTY.println();
+        }
+    }
+
+    /**
+     * For Baseline compilation
+     */
+    public void doBlock(AbstractBlock<?> block) {
+        doBlockStart(block);
+        // add instruction
+        emitAdd(Constant.forLong(42), Constant.forLong(73));
+        doBlockEnd(block);
+    }
+
+    public void doBlock(Block block, StructuredGraph graph, BlockMap<List<ScheduledNode>> blockMap) {
+        doBlockStart(block);
 
         if (block == res.getLIR().getControlFlowGraph().getStartBlock()) {
             assert block.getPredecessorCount() == 0;
@@ -472,16 +499,7 @@
         }
 
         assert verifyBlock(res.getLIR(), block);
-
-        if (traceLevel >= 1) {
-            TTY.println("END Generating LIR for block B" + block.getId());
-        }
-
-        currentBlock = null;
-
-        if (printIRWithLIR) {
-            TTY.println();
-        }
+        doBlockEnd(block);
     }
 
     protected abstract boolean peephole(ValueNode valueNode);
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/LIRGeneratorCommon.java	Wed Mar 19 15:13:13 2014 +0100
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/LIRGeneratorCommon.java	Wed Mar 19 15:14:37 2014 +0100
@@ -4,6 +4,7 @@
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.lir.*;
 import com.oracle.graal.nodes.calc.*;
+import com.oracle.graal.nodes.cfg.*;
 import com.oracle.graal.nodes.type.*;
 
 public interface LIRGeneratorCommon {
@@ -50,6 +51,8 @@
 
     Value loadNonConst(Value value);
 
+    void doBlock(AbstractBlock<?> block);
+
     /**
      * Gets the ABI specific operand used to return a value of a given kind from a method.
      *