# HG changeset patch # User Tom Rodriguez # Date 1398712280 25200 # Node ID 3a6dffce51585208d1038e91b870414fad272ae1 # Parent bd2d8a93cfbedadcf604189a28f40a29ef875699 delete memory peephole machinery diff -r bd2d8a93cfbe -r 3a6dffce5158 graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64MemoryPeephole.java --- a/graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64MemoryPeephole.java Mon Apr 28 10:14:36 2014 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,495 +0,0 @@ -/* - * Copyright (c) 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.amd64; - -import static com.oracle.graal.compiler.common.GraalOptions.*; -import static com.oracle.graal.lir.amd64.AMD64Arithmetic.*; -import static com.oracle.graal.nodes.ConstantNode.*; - -import java.util.*; - -import com.oracle.graal.api.meta.*; -import com.oracle.graal.asm.*; -import com.oracle.graal.compiler.common.*; -import com.oracle.graal.compiler.common.calc.*; -import com.oracle.graal.compiler.common.type.*; -import com.oracle.graal.debug.*; -import com.oracle.graal.lir.*; -import com.oracle.graal.lir.amd64.*; -import com.oracle.graal.lir.amd64.AMD64ControlFlow.BranchOp; -import com.oracle.graal.lir.amd64.AMD64ControlFlow.FloatBranchOp; -import com.oracle.graal.nodes.*; -import com.oracle.graal.nodes.calc.*; -import com.oracle.graal.nodes.extended.*; -import com.oracle.graal.nodes.spi.*; - -public class AMD64MemoryPeephole implements MemoryArithmeticLIRLowerer { - protected final AMD64NodeLIRBuilder gen; - protected List deferredNodes; - - protected AMD64MemoryPeephole(AMD64NodeLIRBuilder gen) { - this.gen = gen; - } - - public Value setResult(ValueNode x, Value operand) { - return gen.setResult(x, operand); - } - - @Override - public boolean memoryPeephole(Access access, MemoryArithmeticLIRLowerable operation, List deferred) { - this.deferredNodes = deferred; - boolean result = operation.generate(this, access); - if (result) { - Debug.log("merge %s %s with %1s %s %s", access, access.asNode().stamp(), operation, result, access.asNode().graph().method()); - } else { - Debug.log("can't merge %s %s with %1s", access, access.asNode().stamp(), operation); - } - this.deferredNodes = null; - return result; - } - - protected LIRFrameState getState(Access access) { - if (access instanceof DeoptimizingNode) { - return gen.state((DeoptimizingNode) access); - } - return null; - } - - protected Kind getMemoryKind(Access access) { - return (Kind) gen.getLIRGeneratorTool().getPlatformKind(access.asNode().stamp()); - } - - protected AMD64AddressValue makeAddress(Access access) { - return (AMD64AddressValue) access.accessLocation().generateAddress(gen, gen.getLIRGeneratorTool(), gen.operand(access.object())); - } - - protected Value emitBinaryMemory(AMD64Arithmetic op, boolean commutative, ValueNode x, ValueNode y, Access access) { - ValueNode other = x; - if (uncast(other) == access) { - if (commutative) { - other = y; - } else { - return null; - } - } - ensureEvaluated(other); - return gen.getLIRGeneratorTool().emitBinaryMemory(op, getMemoryKind(access), gen.getLIRGeneratorTool().asAllocatable(gen.operand(other)), makeAddress(access), getState(access)); - } - - /** - * Constants with multiple users need to be evaluated in the right location so that later users - * can pick up the operand. Make sure that happens when it needs to. - */ - protected void ensureEvaluated(ValueNode node) { - evaluateDeferred(node); - evaluateDeferred(); - } - - protected void evaluateDeferred(ValueNode node) { - // Ensure the other input value has a generated value. - if (ConstantNodeRecordsUsages) { - if (!gen.hasOperand(node)) { - assert node instanceof ConstantNode : node; - ((ConstantNode) node).generate(gen); - } - } - } - - protected void evaluateDeferred() { - if (deferredNodes != null) { - for (ValueNode node : deferredNodes) { - evaluateDeferred(node); - } - } - } - - protected Value emitConvert2MemoryOp(PlatformKind kind, AMD64Arithmetic op, Access access) { - AMD64AddressValue address = makeAddress(access); - LIRFrameState state = getState(access); - evaluateDeferred(); - return gen.getLIRGeneratorTool().emitConvert2MemoryOp(kind, op, address, state); - } - - @Override - public Value emitAddMemory(ValueNode x, ValueNode y, Access access) { - switch (getMemoryKind(access)) { - case Int: - return emitBinaryMemory(IADD, true, x, y, access); - case Long: - return emitBinaryMemory(LADD, true, x, y, access); - case Float: - return emitBinaryMemory(FADD, true, x, y, access); - case Double: - return emitBinaryMemory(DADD, true, x, y, access); - default: - return null; - } - } - - @Override - public Value emitSubMemory(ValueNode x, ValueNode y, Access access) { - switch (getMemoryKind(access)) { - case Int: - return emitBinaryMemory(ISUB, false, x, y, access); - case Long: - return emitBinaryMemory(LSUB, false, x, y, access); - case Float: - return emitBinaryMemory(FSUB, false, x, y, access); - case Double: - return emitBinaryMemory(DSUB, false, x, y, access); - default: - return null; - } - } - - @Override - public Value emitMulMemory(ValueNode x, ValueNode y, Access access) { - switch (getMemoryKind(access)) { - case Int: - return emitBinaryMemory(IMUL, true, x, y, access); - case Long: - return emitBinaryMemory(LMUL, true, x, y, access); - case Float: - return emitBinaryMemory(FMUL, true, x, y, access); - case Double: - return emitBinaryMemory(DMUL, true, x, y, access); - default: - return null; - } - } - - @Override - public Value emitDivMemory(ValueNode x, ValueNode y, Access access) { - return null; - } - - @Override - public Value emitRemMemory(ValueNode x, ValueNode y, Access access) { - return null; - } - - @Override - public Value emitAndMemory(ValueNode x, ValueNode y, Access access) { - Kind kind = getMemoryKind(access); - switch (kind) { - case Int: - return emitBinaryMemory(IAND, true, x, y, access); - case Long: - return emitBinaryMemory(LAND, true, x, y, access); - case Short: { - ValueNode other = selectOtherInput(x, y, access); - Constant constant = other instanceof ConstantNode ? ((ConstantNode) other).asConstant() : null; - if (constant != null && constant.asInt() == IntegerStamp.defaultMask(kind.getBitCount())) { - // Convert to unsigned load - ensureEvaluated(other); - return emitZeroExtendMemory(16, 32, access); - } - return null; - } - case Byte: { - if (OptFoldMemory.getValue()) { - return null; - } - ValueNode other = selectOtherInput(x, y, access); - Constant constant = other instanceof ConstantNode ? ((ConstantNode) other).asConstant() : null; - if (constant != null && constant.asInt() == IntegerStamp.defaultMask(kind.getBitCount())) { - // Convert to unsigned load - ensureEvaluated(other); - return emitConvert2MemoryOp(Kind.Int, MOV_B2UI, access); - } - return null; - } - - default: - return null; - } - } - - @Override - public Value emitOrMemory(ValueNode x, ValueNode y, Access access) { - switch (getMemoryKind(access)) { - case Int: - return emitBinaryMemory(IOR, true, x, y, access); - case Long: - return emitBinaryMemory(LOR, true, x, y, access); - default: - return null; - } - } - - @Override - public Value emitXorMemory(ValueNode x, ValueNode y, Access access) { - switch (getMemoryKind(access)) { - case Int: - return emitBinaryMemory(IXOR, true, x, y, access); - case Long: - return emitBinaryMemory(LXOR, true, x, y, access); - default: - return null; - } - } - - @Override - public Value emitReinterpretMemory(Stamp stamp, Access access) { - PlatformKind to = gen.getLIRGeneratorTool().getPlatformKind(stamp); - Kind from = getMemoryKind(access); - assert to != from : "should have been eliminated"; - - /* - * Conversions between integer to floating point types require moves between CPU and FPU - * registers. - */ - switch ((Kind) to) { - case Int: - switch (from) { - case Float: - return emitConvert2MemoryOp(to, MOV_F2I, access); - } - break; - case Long: - switch (from) { - case Double: - return emitConvert2MemoryOp(to, MOV_D2L, access); - } - break; - case Float: - switch (from) { - case Int: - return emitConvert2MemoryOp(to, MOV_I2F, access); - } - break; - case Double: - switch (from) { - case Long: - return emitConvert2MemoryOp(to, MOV_L2D, access); - } - break; - } - throw GraalInternalError.shouldNotReachHere(); - } - - @Override - public Value emitFloatConvertMemory(FloatConvert op, Access access) { - switch (op) { - case D2F: - return emitConvert2MemoryOp(Kind.Float, D2F, access); - case D2I: - return emitConvert2MemoryOp(Kind.Int, D2I, access); - case D2L: - return emitConvert2MemoryOp(Kind.Long, D2L, access); - case F2D: - return emitConvert2MemoryOp(Kind.Double, F2D, access); - case F2I: - return emitConvert2MemoryOp(Kind.Int, F2I, access); - case F2L: - return emitConvert2MemoryOp(Kind.Long, F2L, access); - case I2D: - return emitConvert2MemoryOp(Kind.Double, I2D, access); - case I2F: - return emitConvert2MemoryOp(Kind.Float, I2F, access); - case L2D: - return emitConvert2MemoryOp(Kind.Double, L2D, access); - case L2F: - return emitConvert2MemoryOp(Kind.Float, L2F, access); - default: - throw GraalInternalError.shouldNotReachHere(); - } - } - - @Override - public Value emitSignExtendMemory(Access access, int fromBits, int toBits) { - assert fromBits <= toBits && toBits <= 64; - if (fromBits == toBits) { - return null; - } else if (toBits > 32) { - // sign extend to 64 bits - switch (fromBits) { - case 8: - return emitConvert2MemoryOp(Kind.Long, B2L, access); - case 16: - return emitConvert2MemoryOp(Kind.Long, S2L, access); - case 32: - return emitConvert2MemoryOp(Kind.Long, I2L, access); - default: - throw GraalInternalError.unimplemented("unsupported sign extension (" + fromBits + " bit -> " + toBits + " bit)"); - } - } else { - - // sign extend to 32 bits (smaller values are internally represented as 32 bit values) - switch (fromBits) { - case 8: - return emitConvert2MemoryOp(Kind.Int, B2I, access); - case 16: - return emitConvert2MemoryOp(Kind.Int, S2I, access); - case 32: - return null; - default: - throw GraalInternalError.unimplemented("unsupported sign extension (" + fromBits + " bit -> " + toBits + " bit)"); - } - } - } - - @Override - public Value emitNarrowMemory(int resultBits, Access access) { - // TODO - return null; - } - - @Override - public Value emitZeroExtendMemory(int fromBits, int toBits, Access access) { - assert fromBits != toBits; - Kind memoryKind = getMemoryKind(access); - if (memoryKind.getBitCount() != fromBits && !memoryKind.isUnsigned()) { - // The memory being read from is signed and smaller than the result size so - // this is a sign extension to inputBits followed by a zero extension to resultBits - // which can't be expressed in a memory operation. - return null; - } - if (memoryKind == Kind.Short) { - memoryKind = Kind.Char; - } - evaluateDeferred(); - return gen.getLIRGeneratorTool().emitZeroExtendMemory(memoryKind, toBits, makeAddress(access), getState(access)); - } - - public boolean emitIfMemory(IfNode x, Access access) { - return emitBranchMemory(x.condition(), access, gen.getLIRBlock(x.trueSuccessor()), gen.getLIRBlock(x.falseSuccessor()), x.probability(x.trueSuccessor())); - } - - private boolean emitBranchMemory(LogicNode node, Access access, LabelRef trueSuccessor, LabelRef falseSuccessor, double trueSuccessorProbability) { - if (node instanceof IsNullNode) { - // can't do anything interesting. - return false; - } else if (node instanceof CompareNode) { - CompareNode compare = (CompareNode) node; - return emitCompareBranchMemory(compare, access, trueSuccessor, falseSuccessor, trueSuccessorProbability); - } else if (node instanceof LogicConstantNode) { - return false; - } else if (node instanceof IntegerTestNode) { - return emitIntegerTestBranchMemory((IntegerTestNode) node, access, trueSuccessor, falseSuccessor, trueSuccessorProbability); - } else { - throw GraalInternalError.unimplemented(node.toString()); - } - } - - public boolean emitCompareBranchMemory(CompareNode compare, Access access, LabelRef trueSuccessor, LabelRef falseSuccessor, double trueSuccessorProbability) { - return emitCompareBranchMemory(compare.x(), compare.y(), access, compare.condition(), compare.unorderedIsTrue(), trueSuccessor, falseSuccessor, trueSuccessorProbability); - } - - public boolean emitIntegerTestBranchMemory(IntegerTestNode test, Access access, LabelRef trueSuccessor, LabelRef falseSuccessor, double trueSuccessorProbability) { - return emitIntegerTestBranchMemory(test.x(), test.y(), access, trueSuccessor, falseSuccessor, trueSuccessorProbability); - } - - private boolean emitIntegerTestBranchMemory(ValueNode left, ValueNode right, Access access, LabelRef trueLabel, LabelRef falseLabel, double trueLabelProbability) { - ValueNode other = selectOtherInput(left, right, access); - Kind kind = getMemoryKind(access); - if (other.isConstant()) { - if (kind != kind.getStackKind()) { - return false; - } - Constant constant = other.asConstant(); - if (kind == Kind.Long && !NumUtil.isInt(constant.asLong())) { - // Only imm32 as long - return false; - } - ensureEvaluated(other); - gen.append(new AMD64TestMemoryOp(kind, makeAddress(access), constant, getState(access))); - } else { - evaluateDeferred(); - gen.append(new AMD64TestMemoryOp(kind, makeAddress(access), gen.operand(other), getState(access))); - } - - gen.append(new BranchOp(Condition.EQ, trueLabel, falseLabel, trueLabelProbability)); - return true; - } - - /** - * @return the input which is not equal to access, accounting for possible UnsafeCastNodes. - */ - protected ValueNode selectOtherInput(ValueNode left, ValueNode right, Access access) { - assert uncast(left) == access || uncast(right) == access; - return uncast(left) == access ? right : left; - } - - protected ValueNode uncast(ValueNode value) { - if (value instanceof UnsafeCastNode) { - UnsafeCastNode cast = (UnsafeCastNode) value; - return cast.getOriginalNode(); - } - return value; - } - - protected boolean emitCompareBranchMemory(ValueNode left, ValueNode right, Access access, Condition cond, boolean unorderedIsTrue, LabelRef trueLabel, LabelRef falseLabel, - double trueLabelProbability) { - ValueNode other = selectOtherInput(left, right, access); - Kind kind = getMemoryKind(access); - boolean mirrored = false; - - if (other.isConstant()) { - Constant constant = other.asConstant(); - if (kind == Kind.Long && !NumUtil.isInt(constant.asLong())) { - // Only imm32 as long - return false; - } - if (kind.isNumericFloat()) { - Debug.log("Skipping constant compares for float kinds"); - return false; - } - if (kind == Kind.Object) { - if (!constant.isNull()) { - Debug.log("Skipping constant compares for Object kinds"); - return false; - } - } - ensureEvaluated(other); - gen.getLIRGeneratorTool().emitCompareMemoryConOp(kind, makeAddress(access), constant, getState(access)); - mirrored = uncast(right) == access; - } else { - if (kind == Kind.Object) { - // Can't compare against objects since they require encode/decode - Debug.log("Skipping compares for Object kinds"); - return false; - } - - evaluateDeferred(); - gen.getLIRGeneratorTool().emitCompareRegMemoryOp(kind, gen.operand(other), makeAddress(access), getState(access)); - mirrored = uncast(left) == access; - } - - Condition finalCondition = mirrored ? cond.mirror() : cond; - switch (kind.getStackKind()) { - case Long: - case Int: - case Object: - gen.append(new BranchOp(finalCondition, trueLabel, falseLabel, trueLabelProbability)); - return true; - case Float: - case Double: - gen.append(new FloatBranchOp(finalCondition, unorderedIsTrue, trueLabel, falseLabel, trueLabelProbability)); - return true; - default: - throw GraalInternalError.shouldNotReachHere("" + kind.getStackKind()); - } - } -} diff -r bd2d8a93cfbe -r 3a6dffce5158 graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64NodeLIRBuilder.java --- a/graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64NodeLIRBuilder.java Mon Apr 28 10:14:36 2014 -0700 +++ b/graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64NodeLIRBuilder.java Mon Apr 28 12:11:20 2014 -0700 @@ -41,7 +41,6 @@ import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.calc.*; import com.oracle.graal.nodes.extended.*; -import com.oracle.graal.nodes.spi.*; public abstract class AMD64NodeLIRBuilder extends NodeLIRBuilder { @@ -49,17 +48,6 @@ super(graph, gen); } - protected MemoryArithmeticLIRLowerer memoryPeephole; - - @Override - public MemoryArithmeticLIRLowerer getMemoryLowerer() { - if (memoryPeephole == null) { - // Use the generic one - memoryPeephole = new AMD64MemoryPeephole(this); - } - return memoryPeephole; - } - @Override protected void emitIndirectCall(IndirectCallTargetNode callTarget, Value result, Value[] parameters, Value[] temps, LIRFrameState callState) { AllocatableValue targetAddress = AMD64.rax.asValue(); diff -r bd2d8a93cfbe -r 3a6dffce5158 graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/NodeLIRBuilder.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/NodeLIRBuilder.java Mon Apr 28 10:14:36 2014 -0700 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/NodeLIRBuilder.java Mon Apr 28 12:11:20 2014 -0700 @@ -216,16 +216,11 @@ matchComplexExpressions(nodes); } - int instructionsFolded = 0; for (int i = 0; i < nodes.size(); i++) { Node instr = nodes.get(i); if (Options.TraceLIRGeneratorLevel.getValue() >= 3) { TTY.println("LIRGen for " + instr); } - if (instructionsFolded > 0) { - instructionsFolded--; - continue; - } if (!ConstantNodeRecordsUsages && instr instanceof ConstantNode) { // Loading of constants is done lazily by operand() @@ -234,15 +229,12 @@ Value operand = getOperand(valueNode); if (operand == null) { if (!peephole(valueNode)) { - instructionsFolded = maybeFoldMemory(nodes, i, valueNode); - if (instructionsFolded == 0) { - try { - doRoot((ValueNode) instr); - } catch (GraalInternalError e) { - throw GraalGraphInternalError.transformAndAddContext(e, instr); - } catch (Throwable e) { - throw new GraalGraphInternalError(e).addContext(instr); - } + try { + doRoot((ValueNode) instr); + } catch (GraalInternalError e) { + throw GraalGraphInternalError.transformAndAddContext(e, instr); + } catch (Throwable e) { + throw new GraalGraphInternalError(e).addContext(instr); } } } else if (Value.INTERIOR_MATCH.equals(operand)) { @@ -304,152 +296,6 @@ } } - private static final DebugMetric MemoryFoldSuccess = Debug.metric("MemoryFoldSuccess"); - private static final DebugMetric MemoryFoldFailed = Debug.metric("MemoryFoldFailed"); - private static final DebugMetric MemoryFoldFailedNonAdjacent = Debug.metric("MemoryFoldedFailedNonAdjacent"); - private static final DebugMetric MemoryFoldFailedDifferentBlock = Debug.metric("MemoryFoldedFailedDifferentBlock"); - - /** - * Subclass can provide helper to fold memory operations into other operations. - */ - public MemoryArithmeticLIRLowerer getMemoryLowerer() { - return null; - } - - private static final Object LOG_OUTPUT_LOCK = new Object(); - - /** - * Try to find a sequence of Nodes which can be passed to the backend to look for optimized - * instruction sequences using memory. Currently this basically is a read with a single - * arithmetic user followed by an possible if use. This should generalized to more generic - * pattern matching so that it can be more flexibly used. - */ - private int maybeFoldMemory(List nodes, int i, ValueNode access) { - MemoryArithmeticLIRLowerer lowerer = getMemoryLowerer(); - if (lowerer != null && GraalOptions.OptFoldMemory.getValue() && (access instanceof ReadNode || access instanceof FloatingReadNode) && access.usages().count() == 1 && i + 1 < nodes.size()) { - try (Scope s = Debug.scope("MaybeFoldMemory", access)) { - // This is all bit hacky since it's happening on the linearized schedule. This needs - // to be revisited at some point. - - // Uncast the memory operation. - Node use = access.usages().first(); - if (use instanceof UnsafeCastNode && use.usages().count() == 1) { - use = use.usages().first(); - } - - // Find a memory lowerable usage of this operation - if (use instanceof MemoryArithmeticLIRLowerable) { - ValueNode operation = (ValueNode) use; - if (!nodes.contains(operation)) { - Debug.log("node %1s in different block from %1s", access, operation); - MemoryFoldFailedDifferentBlock.increment(); - return 0; - } - ValueNode firstOperation = operation; - if (operation instanceof LogicNode) { - if (operation.usages().count() == 1 && operation.usages().first() instanceof IfNode) { - ValueNode ifNode = (ValueNode) operation.usages().first(); - if (!nodes.contains(ifNode)) { - MemoryFoldFailedDifferentBlock.increment(); - Debug.log("if node %1s in different block from %1s", ifNode, operation); - try (Indent indent = Debug.logAndIndent("checking operations")) { - int start = nodes.indexOf(access); - int end = nodes.indexOf(operation); - for (int i1 = Math.min(start, end); i1 <= Math.max(start, end); i1++) { - Debug.log("%d: (%d) %1s", i1, nodes.get(i1).usages().count(), nodes.get(i1)); - } - } - return 0; - } else { - operation = ifNode; - } - } - } - if (Debug.isLogEnabled()) { - synchronized (LOG_OUTPUT_LOCK) { // Hack to ensure the output is grouped. - try (Indent indent = Debug.logAndIndent("checking operations")) { - int start = nodes.indexOf(access); - int end = nodes.indexOf(operation); - for (int i1 = Math.min(start, end); i1 <= Math.max(start, end); i1++) { - Debug.log("%d: (%d) %1s", i1, nodes.get(i1).usages().count(), nodes.get(i1)); - } - } - } - } - // Possible lowerable operation in the same block. Check out the dependencies. - int opIndex = nodes.indexOf(operation); - int current = i + 1; - ArrayList deferred = null; - for (; current < opIndex; current++) { - ScheduledNode node = nodes.get(current); - if (node != firstOperation) { - if (node instanceof LocationNode || node instanceof VirtualObjectNode) { - // nothing to do - continue; - } else if (node instanceof ConstantNode) { - if (deferred == null) { - deferred = new ArrayList<>(2); - } - // These nodes are collected and the backend is expended to - // evaluate them before generating the lowered form. This - // basically works around unfriendly scheduling of values which - // are defined in a block but not used there. - deferred.add((ValueNode) node); - continue; - } else if (node instanceof UnsafeCastNode) { - UnsafeCastNode cast = (UnsafeCastNode) node; - if (cast.getOriginalNode() == access) { - continue; - } - } - - // Unexpected inline node - // Debug.log("unexpected node %1s", node); - break; - } - } - - if (current == opIndex) { - if (lowerer.memoryPeephole((Access) access, (MemoryArithmeticLIRLowerable) operation, deferred)) { - MemoryFoldSuccess.increment(); - // if this operation had multiple access inputs, then previous attempts - // would be marked as failures which is wrong. Try to adjust the - // counters to account for this. - for (Node input : operation.inputs()) { - if (input == access) { - continue; - } - if (input instanceof Access && nodes.contains(input)) { - MemoryFoldFailedNonAdjacent.add(-1); - } - } - if (deferred != null) { - // Ensure deferred nodes were evaluated - for (ValueNode node : deferred) { - assert hasOperand(node); - } - } - return opIndex - i; - } else { - // This isn't true failure, it just means there wasn't match for the - // pattern. Usually that means it's just not supported by the backend. - MemoryFoldFailed.increment(); - return 0; - } - } else { - MemoryFoldFailedNonAdjacent.increment(); - } - } else if (!(use instanceof Access) && !(use instanceof PhiNode) && use.usages().count() == 1) { - // memory usage which isn't considered lowerable. Mostly these are - // uninteresting but it might be worth looking at to ensure that interesting - // nodes are being properly handled. - // Debug.log("usage isn't lowerable %1s", access.usages().first()); - } - } - } - return 0; - } - protected abstract boolean peephole(ValueNode valueNode); private void doRoot(ValueNode instr) { diff -r bd2d8a93cfbe -r 3a6dffce5158 graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotMemoryPeephole.java --- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotMemoryPeephole.java Mon Apr 28 10:14:36 2014 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,74 +0,0 @@ -/* - * Copyright (c) 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.hotspot.amd64; - -import com.oracle.graal.api.meta.*; -import com.oracle.graal.compiler.amd64.*; -import com.oracle.graal.compiler.common.calc.*; -import com.oracle.graal.hotspot.*; -import com.oracle.graal.hotspot.amd64.AMD64HotSpotLIRGenerator.CompareMemoryCompressedOp; -import com.oracle.graal.hotspot.nodes.type.*; -import com.oracle.graal.lir.*; -import com.oracle.graal.lir.amd64.AMD64ControlFlow.BranchOp; -import com.oracle.graal.nodes.*; -import com.oracle.graal.nodes.extended.*; - -/** - * Specialized code gen for comparison with compressed memory. - */ - -public class AMD64HotSpotMemoryPeephole extends AMD64MemoryPeephole { - AMD64HotSpotMemoryPeephole(AMD64NodeLIRBuilder gen) { - super(gen); - } - - @Override - protected Kind getMemoryKind(Access access) { - PlatformKind kind = gen.getLIRGeneratorTool().getPlatformKind(access.asNode().stamp()); - if (kind == NarrowOopStamp.NarrowOop) { - return Kind.Int; - } else { - return (Kind) kind; - } - } - - @Override - protected boolean emitCompareBranchMemory(ValueNode left, ValueNode right, Access access, Condition cond, boolean unorderedIsTrue, LabelRef trueLabel, LabelRef falseLabel, - double trueLabelProbability) { - if (HotSpotGraalRuntime.runtime().getConfig().useCompressedOops) { - ValueNode other = selectOtherInput(left, right, access); - Kind kind = getMemoryKind(access); - - if (other.isConstant() && kind == Kind.Object && access.isCompressible()) { - ensureEvaluated(other); - gen.append(new CompareMemoryCompressedOp(makeAddress(access), other.asConstant(), getState(access))); - Condition finalCondition = right == access ? cond.mirror() : cond; - gen.append(new BranchOp(finalCondition, trueLabel, falseLabel, trueLabelProbability)); - return true; - } - } - - return super.emitCompareBranchMemory(left, right, access, cond, unorderedIsTrue, trueLabel, falseLabel, trueLabelProbability); - } -} diff -r bd2d8a93cfbe -r 3a6dffce5158 graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotNodeLIRBuilder.java --- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotNodeLIRBuilder.java Mon Apr 28 10:14:36 2014 -0700 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotNodeLIRBuilder.java Mon Apr 28 12:11:20 2014 -0700 @@ -97,7 +97,6 @@ public AMD64HotSpotNodeLIRBuilder(StructuredGraph graph, LIRGeneratorTool gen) { super(graph, gen); - memoryPeephole = new AMD64HotSpotMemoryPeephole(this); assert gen instanceof AMD64HotSpotLIRGenerator; assert getDebugInfoBuilder() instanceof HotSpotDebugInfoBuilder; ((AMD64HotSpotLIRGenerator) gen).setLockStack(((HotSpotDebugInfoBuilder) getDebugInfoBuilder()).lockStack()); diff -r bd2d8a93cfbe -r 3a6dffce5158 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/BinaryOpLogicNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/BinaryOpLogicNode.java Mon Apr 28 10:14:36 2014 -0700 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/BinaryOpLogicNode.java Mon Apr 28 12:11:20 2014 -0700 @@ -23,13 +23,12 @@ package com.oracle.graal.nodes; import com.oracle.graal.api.meta.*; -import com.oracle.graal.api.meta.ProfilingInfo.*; +import com.oracle.graal.api.meta.ProfilingInfo.TriState; import com.oracle.graal.graph.*; import com.oracle.graal.graph.spi.*; -import com.oracle.graal.nodes.extended.*; import com.oracle.graal.nodes.spi.*; -public abstract class BinaryOpLogicNode extends LogicNode implements LIRLowerable, MemoryArithmeticLIRLowerable, Canonicalizable { +public abstract class BinaryOpLogicNode extends LogicNode implements LIRLowerable, Canonicalizable { @Input private ValueNode x; @Input private ValueNode y; @@ -80,9 +79,4 @@ @Override public void generate(NodeLIRBuilderTool gen) { } - - @Override - public boolean generate(MemoryArithmeticLIRLowerer gen, Access access) { - return false; - } } diff -r bd2d8a93cfbe -r 3a6dffce5158 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/IfNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/IfNode.java Mon Apr 28 10:14:36 2014 -0700 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/IfNode.java Mon Apr 28 12:11:20 2014 -0700 @@ -34,7 +34,6 @@ import com.oracle.graal.graph.iterators.*; import com.oracle.graal.graph.spi.*; import com.oracle.graal.nodes.calc.*; -import com.oracle.graal.nodes.extended.*; import com.oracle.graal.nodes.java.*; import com.oracle.graal.nodes.spi.*; import com.oracle.graal.nodes.util.*; @@ -43,7 +42,7 @@ * The {@code IfNode} represents a branch that can go one of two directions depending on the outcome * of a comparison. */ -public final class IfNode extends ControlSplitNode implements Simplifiable, LIRLowerable, MemoryArithmeticLIRLowerable { +public final class IfNode extends ControlSplitNode implements Simplifiable, LIRLowerable { @Successor private BeginNode trueSuccessor; @Successor private BeginNode falseSuccessor; @@ -132,11 +131,6 @@ } @Override - public boolean generate(MemoryArithmeticLIRLowerer gen, Access access) { - return gen.emitIfMemory(this, access); - } - - @Override public boolean verify() { assertTrue(condition() != null, "missing condition"); assertTrue(trueSuccessor() != null, "missing trueSuccessor"); diff -r bd2d8a93cfbe -r 3a6dffce5158 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/UnaryOpLogicNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/UnaryOpLogicNode.java Mon Apr 28 10:14:36 2014 -0700 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/UnaryOpLogicNode.java Mon Apr 28 12:11:20 2014 -0700 @@ -22,11 +22,10 @@ */ package com.oracle.graal.nodes; -import com.oracle.graal.api.meta.ProfilingInfo.*; -import com.oracle.graal.nodes.extended.*; +import com.oracle.graal.api.meta.ProfilingInfo.TriState; import com.oracle.graal.nodes.spi.*; -public abstract class UnaryOpLogicNode extends LogicNode implements LIRLowerable, MemoryArithmeticLIRLowerable { +public abstract class UnaryOpLogicNode extends LogicNode implements LIRLowerable { @Input private ValueNode object; @@ -49,9 +48,4 @@ @Override public void generate(NodeLIRBuilderTool gen) { } - - @Override - public boolean generate(MemoryArithmeticLIRLowerer gen, Access access) { - return false; - } } diff -r bd2d8a93cfbe -r 3a6dffce5158 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/AndNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/AndNode.java Mon Apr 28 10:14:36 2014 -0700 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/AndNode.java Mon Apr 28 12:11:20 2014 -0700 @@ -28,7 +28,6 @@ import com.oracle.graal.graph.spi.*; import com.oracle.graal.lir.gen.*; import com.oracle.graal.nodes.*; -import com.oracle.graal.nodes.extended.*; import com.oracle.graal.nodes.spi.*; import com.oracle.graal.nodes.type.*; @@ -93,13 +92,4 @@ public void generate(NodeMappableLIRBuilder builder, ArithmeticLIRGenerator gen) { builder.setResult(this, gen.emitAnd(builder.operand(x()), builder.operand(y()))); } - - @Override - public boolean generate(MemoryArithmeticLIRLowerer gen, Access access) { - Value result = gen.emitAndMemory(x(), y(), access); - if (result != null) { - gen.setResult(this, result); - } - return result != null; - } } diff -r bd2d8a93cfbe -r 3a6dffce5158 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/BitLogicNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/BitLogicNode.java Mon Apr 28 10:14:36 2014 -0700 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/BitLogicNode.java Mon Apr 28 12:11:20 2014 -0700 @@ -30,7 +30,7 @@ /** * The {@code LogicNode} class definition. */ -public abstract class BitLogicNode extends BinaryNode implements ArithmeticLIRLowerable, MemoryArithmeticLIRLowerable, NarrowableArithmeticNode { +public abstract class BitLogicNode extends BinaryNode implements ArithmeticLIRLowerable, NarrowableArithmeticNode { /** * Constructs a new logic operation node. diff -r bd2d8a93cfbe -r 3a6dffce5158 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/FloatAddNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/FloatAddNode.java Mon Apr 28 10:14:36 2014 -0700 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/FloatAddNode.java Mon Apr 28 12:11:20 2014 -0700 @@ -28,7 +28,6 @@ import com.oracle.graal.graph.spi.*; import com.oracle.graal.lir.gen.*; import com.oracle.graal.nodes.*; -import com.oracle.graal.nodes.extended.*; import com.oracle.graal.nodes.spi.*; @NodeInfo(shortName = "+") @@ -85,13 +84,4 @@ } return false; } - - @Override - public boolean generate(MemoryArithmeticLIRLowerer gen, Access access) { - Value result = gen.emitAddMemory(x(), y(), access); - if (result != null) { - gen.setResult(this, result); - } - return result != null; - } } diff -r bd2d8a93cfbe -r 3a6dffce5158 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/FloatArithmeticNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/FloatArithmeticNode.java Mon Apr 28 10:14:36 2014 -0700 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/FloatArithmeticNode.java Mon Apr 28 12:11:20 2014 -0700 @@ -26,7 +26,7 @@ import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.spi.*; -public abstract class FloatArithmeticNode extends BinaryNode implements ArithmeticLIRLowerable, MemoryArithmeticLIRLowerable { +public abstract class FloatArithmeticNode extends BinaryNode implements ArithmeticLIRLowerable { private final boolean isStrictFP; diff -r bd2d8a93cfbe -r 3a6dffce5158 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/FloatConvertNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/FloatConvertNode.java Mon Apr 28 10:14:36 2014 -0700 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/FloatConvertNode.java Mon Apr 28 12:11:20 2014 -0700 @@ -30,14 +30,13 @@ import com.oracle.graal.graph.spi.*; import com.oracle.graal.lir.gen.*; import com.oracle.graal.nodes.*; -import com.oracle.graal.nodes.extended.*; import com.oracle.graal.nodes.spi.*; /** * A {@code FloatConvert} converts between integers and floating point numbers according to Java * semantics. */ -public class FloatConvertNode extends ConvertNode implements Canonicalizable, Lowerable, ArithmeticLIRLowerable, MemoryArithmeticLIRLowerable { +public class FloatConvertNode extends ConvertNode implements Canonicalizable, Lowerable, ArithmeticLIRLowerable { private final FloatConvert op; @@ -167,12 +166,4 @@ public void generate(NodeMappableLIRBuilder builder, ArithmeticLIRGenerator gen) { builder.setResult(this, gen.emitFloatConvert(op, builder.operand(getInput()))); } - - public boolean generate(MemoryArithmeticLIRLowerer gen, Access access) { - Value result = gen.emitFloatConvertMemory(getOp(), access); - if (result != null) { - gen.setResult(this, result); - } - return result != null; - } } diff -r bd2d8a93cfbe -r 3a6dffce5158 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/FloatDivNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/FloatDivNode.java Mon Apr 28 10:14:36 2014 -0700 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/FloatDivNode.java Mon Apr 28 12:11:20 2014 -0700 @@ -28,7 +28,6 @@ import com.oracle.graal.graph.spi.*; import com.oracle.graal.lir.gen.*; import com.oracle.graal.nodes.*; -import com.oracle.graal.nodes.extended.*; import com.oracle.graal.nodes.spi.*; @NodeInfo(shortName = "/") @@ -61,13 +60,4 @@ public void generate(NodeMappableLIRBuilder builder, ArithmeticLIRGenerator gen) { builder.setResult(this, gen.emitDiv(builder.operand(x()), builder.operand(y()), null)); } - - @Override - public boolean generate(MemoryArithmeticLIRLowerer gen, Access access) { - Value result = gen.emitDivMemory(x(), y(), access); - if (result != null) { - gen.setResult(this, result); - } - return result != null; - } } diff -r bd2d8a93cfbe -r 3a6dffce5158 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/FloatMulNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/FloatMulNode.java Mon Apr 28 10:14:36 2014 -0700 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/FloatMulNode.java Mon Apr 28 12:11:20 2014 -0700 @@ -28,7 +28,6 @@ import com.oracle.graal.graph.spi.*; import com.oracle.graal.lir.gen.*; import com.oracle.graal.nodes.*; -import com.oracle.graal.nodes.extended.*; import com.oracle.graal.nodes.spi.*; @NodeInfo(shortName = "*") @@ -71,13 +70,4 @@ } builder.setResult(this, gen.emitMul(op1, op2)); } - - @Override - public boolean generate(MemoryArithmeticLIRLowerer gen, Access access) { - Value result = gen.emitMulMemory(x(), y(), access); - if (result != null) { - gen.setResult(this, result); - } - return result != null; - } } diff -r bd2d8a93cfbe -r 3a6dffce5158 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/FloatRemNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/FloatRemNode.java Mon Apr 28 10:14:36 2014 -0700 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/FloatRemNode.java Mon Apr 28 12:11:20 2014 -0700 @@ -28,7 +28,6 @@ import com.oracle.graal.graph.spi.*; import com.oracle.graal.lir.gen.*; import com.oracle.graal.nodes.*; -import com.oracle.graal.nodes.extended.*; import com.oracle.graal.nodes.spi.*; @NodeInfo(shortName = "%") @@ -61,13 +60,4 @@ public void generate(NodeMappableLIRBuilder builder, ArithmeticLIRGenerator gen) { builder.setResult(this, gen.emitRem(builder.operand(x()), builder.operand(y()), null)); } - - @Override - public boolean generate(MemoryArithmeticLIRLowerer gen, Access access) { - Value result = gen.emitRemMemory(x(), y(), access); - if (result != null) { - gen.setResult(this, result); - } - return result != null; - } } diff -r bd2d8a93cfbe -r 3a6dffce5158 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/FloatSubNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/FloatSubNode.java Mon Apr 28 10:14:36 2014 -0700 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/FloatSubNode.java Mon Apr 28 12:11:20 2014 -0700 @@ -28,7 +28,6 @@ import com.oracle.graal.graph.spi.*; import com.oracle.graal.lir.gen.*; import com.oracle.graal.nodes.*; -import com.oracle.graal.nodes.extended.*; import com.oracle.graal.nodes.spi.*; @NodeInfo(shortName = "-") @@ -80,13 +79,4 @@ public void generate(NodeMappableLIRBuilder builder, ArithmeticLIRGenerator gen) { builder.setResult(this, gen.emitSub(builder.operand(x()), builder.operand(y()))); } - - @Override - public boolean generate(MemoryArithmeticLIRLowerer gen, Access access) { - Value result = gen.emitSubMemory(x(), y(), access); - if (result != null) { - gen.setResult(this, result); - } - return result != null; - } } diff -r bd2d8a93cfbe -r 3a6dffce5158 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/IntegerAddNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/IntegerAddNode.java Mon Apr 28 10:14:36 2014 -0700 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/IntegerAddNode.java Mon Apr 28 12:11:20 2014 -0700 @@ -28,7 +28,6 @@ import com.oracle.graal.graph.spi.*; import com.oracle.graal.lir.gen.*; import com.oracle.graal.nodes.*; -import com.oracle.graal.nodes.extended.*; import com.oracle.graal.nodes.spi.*; import com.oracle.graal.nodes.type.*; @@ -102,13 +101,4 @@ } builder.setResult(this, gen.emitAdd(op1, op2)); } - - @Override - public boolean generate(MemoryArithmeticLIRLowerer gen, Access access) { - Value result = gen.emitAddMemory(x(), y(), access); - if (result != null) { - gen.setResult(this, result); - } - return result != null; - } } diff -r bd2d8a93cfbe -r 3a6dffce5158 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/IntegerArithmeticNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/IntegerArithmeticNode.java Mon Apr 28 10:14:36 2014 -0700 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/IntegerArithmeticNode.java Mon Apr 28 12:11:20 2014 -0700 @@ -27,7 +27,7 @@ import com.oracle.graal.nodes.spi.*; import com.oracle.graal.nodes.type.*; -public abstract class IntegerArithmeticNode extends BinaryNode implements ArithmeticLIRLowerable, MemoryArithmeticLIRLowerable { +public abstract class IntegerArithmeticNode extends BinaryNode implements ArithmeticLIRLowerable { public IntegerArithmeticNode(Stamp stamp, ValueNode x, ValueNode y) { super(stamp, x, y); diff -r bd2d8a93cfbe -r 3a6dffce5158 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/IntegerConvertNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/IntegerConvertNode.java Mon Apr 28 10:14:36 2014 -0700 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/IntegerConvertNode.java Mon Apr 28 12:11:20 2014 -0700 @@ -31,7 +31,7 @@ /** * An {@code IntegerConvert} converts an integer to an integer of different width. */ -public abstract class IntegerConvertNode extends ConvertNode implements ArithmeticLIRLowerable, Canonicalizable, MemoryArithmeticLIRLowerable { +public abstract class IntegerConvertNode extends ConvertNode implements ArithmeticLIRLowerable, Canonicalizable { private final int resultBits; diff -r bd2d8a93cfbe -r 3a6dffce5158 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/IntegerMulNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/IntegerMulNode.java Mon Apr 28 10:14:36 2014 -0700 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/IntegerMulNode.java Mon Apr 28 12:11:20 2014 -0700 @@ -29,7 +29,6 @@ import com.oracle.graal.graph.spi.*; import com.oracle.graal.lir.gen.*; import com.oracle.graal.nodes.*; -import com.oracle.graal.nodes.extended.*; import com.oracle.graal.nodes.spi.*; @NodeInfo(shortName = "*") @@ -86,13 +85,4 @@ } builder.setResult(this, gen.emitMul(op1, op2)); } - - @Override - public boolean generate(MemoryArithmeticLIRLowerer gen, Access access) { - Value result = gen.emitMulMemory(x(), y(), access); - if (result != null) { - gen.setResult(this, result); - } - return result != null; - } } diff -r bd2d8a93cfbe -r 3a6dffce5158 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/IntegerSubNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/IntegerSubNode.java Mon Apr 28 10:14:36 2014 -0700 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/IntegerSubNode.java Mon Apr 28 12:11:20 2014 -0700 @@ -28,7 +28,6 @@ import com.oracle.graal.graph.spi.*; import com.oracle.graal.lir.gen.*; import com.oracle.graal.nodes.*; -import com.oracle.graal.nodes.extended.*; import com.oracle.graal.nodes.spi.*; import com.oracle.graal.nodes.type.*; @@ -122,13 +121,4 @@ public void generate(NodeMappableLIRBuilder builder, ArithmeticLIRGenerator gen) { builder.setResult(this, gen.emitSub(builder.operand(x()), builder.operand(y()))); } - - @Override - public boolean generate(MemoryArithmeticLIRLowerer gen, Access access) { - Value result = gen.emitSubMemory(x(), y(), access); - if (result != null) { - gen.setResult(this, result); - } - return result != null; - } } diff -r bd2d8a93cfbe -r 3a6dffce5158 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/NarrowNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/NarrowNode.java Mon Apr 28 10:14:36 2014 -0700 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/NarrowNode.java Mon Apr 28 12:11:20 2014 -0700 @@ -28,7 +28,6 @@ import com.oracle.graal.graph.spi.*; import com.oracle.graal.lir.gen.*; import com.oracle.graal.nodes.*; -import com.oracle.graal.nodes.extended.*; import com.oracle.graal.nodes.spi.*; import com.oracle.graal.nodes.type.*; @@ -109,13 +108,4 @@ public void generate(NodeMappableLIRBuilder builder, ArithmeticLIRGenerator gen) { builder.setResult(this, gen.emitNarrow(builder.operand(getInput()), getResultBits())); } - - @Override - public boolean generate(MemoryArithmeticLIRLowerer gen, Access access) { - Value result = gen.emitNarrowMemory(getResultBits(), access); - if (result != null) { - gen.setResult(this, result); - } - return result != null; - } } diff -r bd2d8a93cfbe -r 3a6dffce5158 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/OrNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/OrNode.java Mon Apr 28 10:14:36 2014 -0700 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/OrNode.java Mon Apr 28 12:11:20 2014 -0700 @@ -28,7 +28,6 @@ import com.oracle.graal.graph.spi.*; import com.oracle.graal.lir.gen.*; import com.oracle.graal.nodes.*; -import com.oracle.graal.nodes.extended.*; import com.oracle.graal.nodes.spi.*; import com.oracle.graal.nodes.type.*; @@ -78,13 +77,4 @@ public void generate(NodeMappableLIRBuilder builder, ArithmeticLIRGenerator gen) { builder.setResult(this, gen.emitOr(builder.operand(x()), builder.operand(y()))); } - - @Override - public boolean generate(MemoryArithmeticLIRLowerer gen, Access access) { - Value result = gen.emitOrMemory(x(), y(), access); - if (result != null) { - gen.setResult(this, result); - } - return result != null; - } } diff -r bd2d8a93cfbe -r 3a6dffce5158 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/ReinterpretNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/ReinterpretNode.java Mon Apr 28 10:14:36 2014 -0700 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/ReinterpretNode.java Mon Apr 28 12:11:20 2014 -0700 @@ -29,7 +29,6 @@ import com.oracle.graal.graph.spi.*; import com.oracle.graal.lir.gen.*; import com.oracle.graal.nodes.*; -import com.oracle.graal.nodes.extended.*; import com.oracle.graal.nodes.spi.*; /** @@ -37,7 +36,7 @@ * of a primitive value to some other incompatible stamp. The new stamp must have the same width as * the old stamp. */ -public class ReinterpretNode extends FloatingNode implements Canonicalizable, ArithmeticLIRLowerable, MemoryArithmeticLIRLowerable { +public class ReinterpretNode extends FloatingNode implements Canonicalizable, ArithmeticLIRLowerable { @Input private ValueNode value; @@ -109,15 +108,6 @@ builder.setResult(this, gen.emitReinterpret(kind, builder.operand(value()))); } - @Override - public boolean generate(MemoryArithmeticLIRLowerer gen, Access access) { - Value result = gen.emitReinterpretMemory(stamp(), access); - if (result != null) { - gen.setResult(this, result); - } - return result != null; - } - public static ValueNode reinterpret(Kind toKind, ValueNode value) { return value.graph().unique(new ReinterpretNode(toKind, value)); } diff -r bd2d8a93cfbe -r 3a6dffce5158 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/SignExtendNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/SignExtendNode.java Mon Apr 28 10:14:36 2014 -0700 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/SignExtendNode.java Mon Apr 28 12:11:20 2014 -0700 @@ -28,7 +28,6 @@ import com.oracle.graal.graph.spi.*; import com.oracle.graal.lir.gen.*; import com.oracle.graal.nodes.*; -import com.oracle.graal.nodes.extended.*; import com.oracle.graal.nodes.spi.*; import com.oracle.graal.nodes.type.*; @@ -110,13 +109,4 @@ public void generate(NodeMappableLIRBuilder builder, ArithmeticLIRGenerator gen) { builder.setResult(this, gen.emitSignExtend(builder.operand(getInput()), getInputBits(), getResultBits())); } - - @Override - public boolean generate(MemoryArithmeticLIRLowerer gen, Access access) { - Value result = gen.emitSignExtendMemory(access, getInputBits(), getResultBits()); - if (result != null) { - gen.setResult(this, result); - } - return result != null; - } } diff -r bd2d8a93cfbe -r 3a6dffce5158 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/XorNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/XorNode.java Mon Apr 28 10:14:36 2014 -0700 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/XorNode.java Mon Apr 28 12:11:20 2014 -0700 @@ -28,7 +28,6 @@ import com.oracle.graal.graph.spi.*; import com.oracle.graal.lir.gen.*; import com.oracle.graal.nodes.*; -import com.oracle.graal.nodes.extended.*; import com.oracle.graal.nodes.spi.*; import com.oracle.graal.nodes.type.*; @@ -77,13 +76,4 @@ public void generate(NodeMappableLIRBuilder builder, ArithmeticLIRGenerator gen) { builder.setResult(this, gen.emitXor(builder.operand(x()), builder.operand(y()))); } - - @Override - public boolean generate(MemoryArithmeticLIRLowerer gen, Access access) { - Value result = gen.emitXorMemory(x(), y(), access); - if (result != null) { - gen.setResult(this, result); - } - return result != null; - } } diff -r bd2d8a93cfbe -r 3a6dffce5158 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/ZeroExtendNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/ZeroExtendNode.java Mon Apr 28 10:14:36 2014 -0700 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/ZeroExtendNode.java Mon Apr 28 12:11:20 2014 -0700 @@ -28,7 +28,6 @@ import com.oracle.graal.graph.spi.*; import com.oracle.graal.lir.gen.*; import com.oracle.graal.nodes.*; -import com.oracle.graal.nodes.extended.*; import com.oracle.graal.nodes.spi.*; import com.oracle.graal.nodes.type.*; @@ -103,13 +102,4 @@ public void generate(NodeMappableLIRBuilder builder, ArithmeticLIRGenerator gen) { builder.setResult(this, gen.emitZeroExtend(builder.operand(getInput()), getInputBits(), getResultBits())); } - - @Override - public boolean generate(MemoryArithmeticLIRLowerer gen, Access access) { - Value result = gen.emitZeroExtendMemory(getInputBits(), getResultBits(), access); - if (result != null) { - gen.setResult(this, result); - } - return result != null; - } } diff -r bd2d8a93cfbe -r 3a6dffce5158 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/MemoryArithmeticLIRLowerable.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/MemoryArithmeticLIRLowerable.java Mon Apr 28 10:14:36 2014 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,42 +0,0 @@ -/* - * Copyright (c) 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.spi; - -import com.oracle.graal.nodes.extended.*; - -/** - * Marks nodes which may be lowered in combination with a memory operation. - */ -public interface MemoryArithmeticLIRLowerable { - - /** - * Attempt to generate a memory form of a node operation. On platforms that support it this will - * be called when the merging is safe. - * - * @param gen - * @param access the memory input which can potentially merge into this operation. - * @return null if it's not possible to emit a memory form of this operation. A non-null value - * will be set as the operand of this node. - */ - boolean generate(MemoryArithmeticLIRLowerer gen, Access access); -} diff -r bd2d8a93cfbe -r 3a6dffce5158 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/MemoryArithmeticLIRLowerer.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/MemoryArithmeticLIRLowerer.java Mon Apr 28 10:14:36 2014 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,71 +0,0 @@ -/* - * Copyright (c) 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.spi; - -import java.util.*; - -import com.oracle.graal.api.meta.*; -import com.oracle.graal.compiler.common.calc.*; -import com.oracle.graal.compiler.common.type.*; -import com.oracle.graal.nodes.*; -import com.oracle.graal.nodes.extended.*; - -/** - * This interface can be used to generate LIR for arithmetic operations where one of the operations - * is load (@see ArithmeticLIRLowerable). - */ -public interface MemoryArithmeticLIRLowerer { - - Value setResult(ValueNode x, Value operand); - - Value emitAddMemory(ValueNode x, ValueNode y, Access access); - - Value emitMulMemory(ValueNode x, ValueNode y, Access access); - - Value emitSubMemory(ValueNode x, ValueNode y, Access access); - - Value emitDivMemory(ValueNode x, ValueNode y, Access access); - - Value emitRemMemory(ValueNode x, ValueNode y, Access access); - - Value emitXorMemory(ValueNode x, ValueNode y, Access access); - - Value emitOrMemory(ValueNode x, ValueNode y, Access access); - - Value emitAndMemory(ValueNode x, ValueNode y, Access access); - - Value emitReinterpretMemory(Stamp stamp, Access access); - - Value emitSignExtendMemory(Access access, int fromBits, int toBits); - - Value emitNarrowMemory(int resultBits, Access access); - - Value emitZeroExtendMemory(int inputBits, int resultBits, Access access); - - Value emitFloatConvertMemory(FloatConvert op, Access access); - - boolean memoryPeephole(Access valueNode, MemoryArithmeticLIRLowerable operation, List deferred); - - boolean emitIfMemory(IfNode ifNode, Access access); - -} diff -r bd2d8a93cfbe -r 3a6dffce5158 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/NodeLIRBuilderTool.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/NodeLIRBuilderTool.java Mon Apr 28 10:14:36 2014 -0700 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/NodeLIRBuilderTool.java Mon Apr 28 12:11:20 2014 -0700 @@ -70,8 +70,6 @@ Value[] visitInvokeArguments(CallingConvention cc, Collection arguments); - MemoryArithmeticLIRLowerer getMemoryLowerer(); - Variable newVariable(Kind kind); void emitArrayEquals(Kind kind, Variable result, Value array1, Value array2, Value length);