# HG changeset patch # User Josef Eisl # Date 1395663342 -3600 # Node ID 6c4b46e4f64043af8e618e9c8349cc0b5eeef582 # Parent 4e784d4f5aeacfc1524a61a35abe05e26843a66e Introduce BytecodeParser interface. diff -r 4e784d4f5aea -r 6c4b46e4f640 graal/com.oracle.graal.baseline/src/com/oracle/graal/baseline/BaselineCompiler.java --- 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 { 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); diff -r 4e784d4f5aea -r 6c4b46e4f640 graal/com.oracle.graal.compiler.ptx/src/com/oracle/graal/compiler/ptx/PTXLIRGenerator.java --- 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(); diff -r 4e784d4f5aea -r 6c4b46e4f640 graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/BytecodeParser.java --- /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> { + void processBlock(T block); +} diff -r 4e784d4f5aea -r 6c4b46e4f640 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 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 > void doBlock(T block, ResolvedJavaMethod method, BytecodeParser 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> 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()]; diff -r 4e784d4f5aea -r 6c4b46e4f640 graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotLIRGenerator.java --- 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();