Mercurial > hg > graal-compiler
changeset 14833:6c4b46e4f640
Introduce BytecodeParser interface.
author | Josef Eisl <josef.eisl@jku.at> |
---|---|
date | Mon, 24 Mar 2014 13:15:42 +0100 |
parents | 4e784d4f5aea |
children | dbe762fc0eb1 |
files | graal/com.oracle.graal.baseline/src/com/oracle/graal/baseline/BaselineCompiler.java graal/com.oracle.graal.compiler.ptx/src/com/oracle/graal/compiler/ptx/PTXLIRGenerator.java graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/BytecodeParser.java graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/LIRGenerator.java graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotLIRGenerator.java |
diffstat | 5 files changed, 49 insertions(+), 24 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.baseline/src/com/oracle/graal/baseline/BaselineCompiler.java Mon Mar 24 11:58:59 2014 +0100 +++ b/graal/com.oracle.graal.baseline/src/com/oracle/graal/baseline/BaselineCompiler.java Mon Mar 24 13:15:42 2014 +0100 @@ -57,7 +57,7 @@ * The {@code GraphBuilder} class parses the bytecode of a method and builds the IR graph. */ @SuppressWarnings("all") -public class BaselineCompiler { +public class BaselineCompiler implements BytecodeParser<BciBlock> { public BaselineCompiler(GraphBuilderConfiguration graphBuilderConfig, MetaAccessProvider metaAccess) { this.graphBuilderConfig = graphBuilderConfig; @@ -176,17 +176,11 @@ try (Scope ds = Debug.scope("BackEnd", lir)) { try (Scope s = Debug.scope("LIRGen", lirGen)) { - lirGen.emitPrologue(method); - // possibly add all the arguments to slots in the local variable array for (BciBlock block : blockMap.blocks) { - lirGen.doBlockStart(block); - - processBlock(block); - - lirGen.doBlockEnd(block); + lirGen.doBlock(block, method, this); } // indent.outdent(); @@ -508,7 +502,7 @@ throw GraalInternalError.unimplemented(); } - private void processBlock(BciBlock block) { + public void processBlock(BciBlock block) { Indent indent = Debug.logAndIndent("Parsing block %s firstInstruction: %s loopHeader: %b", block, block.firstInstruction, block.isLoopHeader); currentBlock = block; iterateBytecodesForBlock(block);
--- a/graal/com.oracle.graal.compiler.ptx/src/com/oracle/graal/compiler/ptx/PTXLIRGenerator.java Mon Mar 24 11:58:59 2014 +0100 +++ b/graal/com.oracle.graal.compiler.ptx/src/com/oracle/graal/compiler/ptx/PTXLIRGenerator.java Mon Mar 24 13:15:42 2014 +0100 @@ -172,7 +172,7 @@ } @Override - public void emitPrologue(ResolvedJavaMethod method) { + protected void emitPrologue(ResolvedJavaMethod method) { // Need to emit .param directives based on incoming arguments and return value CallingConvention incomingArguments = getCallingConvention(); Object returnObject = incomingArguments.getReturn();
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/BytecodeParser.java Mon Mar 24 13:15:42 2014 +0100 @@ -0,0 +1,29 @@ +/* + * 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.compiler.gen; + +import com.oracle.graal.nodes.cfg.*; + +public interface BytecodeParser<T extends AbstractBlock<T>> { + void processBlock(T block); +}
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/LIRGenerator.java Mon Mar 24 11:58:59 2014 +0100 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/LIRGenerator.java Mon Mar 24 13:15:42 2014 +0100 @@ -442,18 +442,20 @@ /** * For Baseline compilation */ - /* - * public void doBlock(AbstractBlock<?> block, ResolvedJavaMethod method) { doBlockStart(block); - * - * if (block == res.getLIR().getControlFlowGraph().getStartBlock()) { assert - * block.getPredecessorCount() == 0; emitPrologue(method); } else { assert - * block.getPredecessorCount() > 0; } - * - * // add instruction Value add = emitAdd(Constant.forLong(42), Constant.forLong(73)); - * emitReturn(add); - * - * doBlockEnd(block); } - */ + + public <T extends AbstractBlock<T>> void doBlock(T block, ResolvedJavaMethod method, BytecodeParser<T> parser) { + doBlockStart(block); + + if (block == res.getLIR().getControlFlowGraph().getStartBlock()) { + assert block.getPredecessorCount() == 0; + emitPrologue(method); + } else { + assert block.getPredecessorCount() > 0; + } + parser.processBlock(block); + + doBlockEnd(block); + } public void doBlock(Block block, StructuredGraph graph, BlockMap<List<ScheduledNode>> blockMap) { doBlockStart(block); @@ -570,7 +572,7 @@ } } - public void emitPrologue(ResolvedJavaMethod method) { + protected void emitPrologue(ResolvedJavaMethod method) { CallingConvention incomingArguments = getCallingConvention(); Value[] params = new Value[incomingArguments.getArgumentCount()];
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotLIRGenerator.java Mon Mar 24 11:58:59 2014 +0100 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotLIRGenerator.java Mon Mar 24 13:15:42 2014 +0100 @@ -174,7 +174,7 @@ } @Override - public void emitPrologue(ResolvedJavaMethod method) { + protected void emitPrologue(ResolvedJavaMethod method) { CallingConvention incomingArguments = getCallingConvention();