# HG changeset patch # User Thomas Wuerthinger # Date 1376050040 -7200 # Node ID af358daf4f41dcad808967ae2a1f397665011685 # Parent 46843d7581b90cb820d061c9180cc533fd6fa24c# Parent b5e95841d36632edf966c82fa7ac943fb9c3c8d7 Merge. diff -r 46843d7581b9 -r af358daf4f41 graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/Architecture.java --- a/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/Architecture.java Fri Aug 09 11:55:54 2013 +0200 +++ b/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/Architecture.java Fri Aug 09 14:07:20 2013 +0200 @@ -188,11 +188,11 @@ * * @param kind the kind of the individual vector elements * @param maxLength the maximum length that should be returned - * @param arithmetic whether the vector length needs to support arithmetic operations or just - * load and store + * @param arithmetic the arithmetic operation for which the vector size should be determined, or + * null if no arithmetic needs to be performed on the vector * @return a supported vector size, but at most {@code maxLength} */ - public int getSupportedVectorLength(Kind kind, int maxLength, boolean arithmetic) { + public int getSupportedVectorLength(Kind kind, int maxLength, ArithmeticOperation arithmetic) { return 1; } diff -r 46843d7581b9 -r af358daf4f41 graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/ArithmeticOperation.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/ArithmeticOperation.java Fri Aug 09 14:07:20 2013 +0200 @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2013, 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.api.code; + +/** + * An {@code ArithmeticOperation} is an operation that does primitive value arithmetic without side + * effect. + */ +public interface ArithmeticOperation { +} diff -r 46843d7581b9 -r af358daf4f41 graal/com.oracle.graal.asm.amd64/src/com/oracle/graal/asm/amd64/AMD64Assembler.java --- a/graal/com.oracle.graal.asm.amd64/src/com/oracle/graal/asm/amd64/AMD64Assembler.java Fri Aug 09 11:55:54 2013 +0200 +++ b/graal/com.oracle.graal.asm.amd64/src/com/oracle/graal/asm/amd64/AMD64Assembler.java Fri Aug 09 14:07:20 2013 +0200 @@ -1518,6 +1518,15 @@ emitByte(0xE8 | encode); } + public final void sqrtsd(Register dst, AMD64Address src) { + assert dst.getRegisterCategory() == AMD64.XMM; + emitByte(0xF2); + prefix(src, dst); + emitByte(0x0F); + emitByte(0x51); + emitOperandHelper(dst, src); + } + public final void sqrtsd(Register dst, Register src) { assert dst.getRegisterCategory() == AMD64.XMM; assert src.getRegisterCategory() == AMD64.XMM; diff -r 46843d7581b9 -r af358daf4f41 graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64LIRGenerator.java --- a/graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64LIRGenerator.java Fri Aug 09 11:55:54 2013 +0200 +++ b/graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64LIRGenerator.java Fri Aug 09 14:07:20 2013 +0200 @@ -800,7 +800,7 @@ @Override public void emitMathSqrt(Variable result, Variable input) { - append(new AMD64MathIntrinsicOp(SQRT, result, input)); + append(new Unary2Op(SQRT, result, input)); } @Override diff -r 46843d7581b9 -r af358daf4f41 graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java --- a/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java Fri Aug 09 11:55:54 2013 +0200 +++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java Fri Aug 09 14:07:20 2013 +0200 @@ -546,7 +546,7 @@ ValueNode y = frameState.pop(result); ValueNode x = frameState.pop(result); boolean isStrictFP = isStrict(method.getModifiers()); - ArithmeticNode v; + BinaryNode v; switch (opcode) { case IADD: case LADD: diff -r 46843d7581b9 -r af358daf4f41 graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64Arithmetic.java --- a/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64Arithmetic.java Fri Aug 09 11:55:54 2013 +0200 +++ b/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64Arithmetic.java Fri Aug 09 14:07:20 2013 +0200 @@ -43,6 +43,7 @@ FADD, FSUB, FMUL, FDIV, FREM, FAND, FOR, FXOR, DADD, DSUB, DMUL, DDIV, DREM, DAND, DOR, DXOR, INEG, LNEG, + SQRT, I2L, L2I, I2B, I2C, I2S, F2D, D2F, I2F, I2D, @@ -484,6 +485,10 @@ masm.xorpd(asDoubleReg(dst), asDoubleReg(src)); break; + case SQRT: + masm.sqrtsd(asDoubleReg(dst), asDoubleReg(src)); + break; + case I2B: masm.movsxb(asIntReg(dst), asIntReg(src)); break; @@ -740,6 +745,10 @@ masm.divsd(asDoubleReg(dst), (AMD64Address) tasm.asDoubleAddr(src)); break; + case SQRT: + masm.sqrtsd(asDoubleReg(dst), (AMD64Address) tasm.asDoubleAddr(src)); + break; + case I2B: masm.movsxb(asIntReg(dst), (AMD64Address) tasm.asIntAddr(src)); break; diff -r 46843d7581b9 -r af358daf4f41 graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64MathIntrinsicOp.java --- a/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64MathIntrinsicOp.java Fri Aug 09 11:55:54 2013 +0200 +++ b/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64MathIntrinsicOp.java Fri Aug 09 14:07:20 2013 +0200 @@ -33,7 +33,6 @@ // @formatter:off public class AMD64MathIntrinsicOp extends AMD64LIRInstruction { public enum IntrinsicOpcode { - SQRT, SIN, COS, TAN, LOG, LOG10 } @@ -51,7 +50,6 @@ @Override public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { switch (opcode) { - case SQRT: masm.sqrtsd(asDoubleReg(result), asDoubleReg(input)); break; case LOG: masm.flog(asDoubleReg(result), asDoubleReg(input), false); break; case LOG10: masm.flog(asDoubleReg(result), asDoubleReg(input), true); break; case SIN: masm.fsin(asDoubleReg(result), asDoubleReg(input)); break; diff -r 46843d7581b9 -r af358daf4f41 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/ArithmeticNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/ArithmeticNode.java Fri Aug 09 11:55:54 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2009, 2011, 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.calc; - -import com.oracle.graal.api.meta.*; -import com.oracle.graal.nodes.*; - -/** - * The {@code ArithmeticOp} class represents arithmetic operations such as addition, subtraction, - * etc. - */ -public abstract class ArithmeticNode extends BinaryNode { - - private final boolean isStrictFP; - - /** - * Creates a new arithmetic operation. - * - * @param kind the result kind of the operation - * @param x the first input instruction - * @param y the second input instruction - * @param isStrictFP indicates this operation has strict rounding semantics - */ - public ArithmeticNode(Kind kind, ValueNode x, ValueNode y, boolean isStrictFP) { - super(kind, x, y); - this.isStrictFP = isStrictFP; - } - - /** - * Checks whether this instruction has strict fp semantics. - * - * @return {@code true} if this instruction has strict fp semantics - */ - public boolean isStrictFP() { - return isStrictFP; - } -} diff -r 46843d7581b9 -r af358daf4f41 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 Fri Aug 09 11:55:54 2013 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/BitLogicNode.java Fri Aug 09 14:07:20 2013 +0200 @@ -22,6 +22,7 @@ */ package com.oracle.graal.nodes.calc; +import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; import com.oracle.graal.graph.*; import com.oracle.graal.nodes.*; @@ -29,7 +30,7 @@ /** * The {@code LogicNode} class definition. */ -public abstract class BitLogicNode extends BinaryNode { +public abstract class BitLogicNode extends BinaryNode implements ArithmeticOperation { /** * Constructs a new logic operation node. diff -r 46843d7581b9 -r af358daf4f41 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/ConvertNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/ConvertNode.java Fri Aug 09 11:55:54 2013 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/ConvertNode.java Fri Aug 09 14:07:20 2013 +0200 @@ -24,6 +24,7 @@ import static com.oracle.graal.api.meta.Kind.*; +import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; import com.oracle.graal.graph.*; import com.oracle.graal.nodes.*; @@ -33,7 +34,7 @@ /** * The {@code ConvertNode} class represents a conversion between primitive types. */ -public final class ConvertNode extends FloatingNode implements Canonicalizable, LIRLowerable, Lowerable { +public final class ConvertNode extends FloatingNode implements Canonicalizable, LIRLowerable, Lowerable, ArithmeticOperation { public static enum Op { I2L(Int, Long, true), diff -r 46843d7581b9 -r af358daf4f41 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 Fri Aug 09 11:55:54 2013 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/FloatArithmeticNode.java Fri Aug 09 14:07:20 2013 +0200 @@ -22,13 +22,25 @@ */ package com.oracle.graal.nodes.calc; +import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; import com.oracle.graal.nodes.*; -public abstract class FloatArithmeticNode extends ArithmeticNode { +public abstract class FloatArithmeticNode extends BinaryNode implements ArithmeticOperation { + + private final boolean isStrictFP; public FloatArithmeticNode(Kind kind, ValueNode x, ValueNode y, boolean isStrictFP) { - super(kind, x, y, isStrictFP); + super(kind, x, y); + this.isStrictFP = isStrictFP; } + /** + * Checks whether this instruction has strict fp semantics. + * + * @return {@code true} if this instruction has strict fp semantics + */ + public boolean isStrictFP() { + return isStrictFP; + } } diff -r 46843d7581b9 -r af358daf4f41 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 Fri Aug 09 11:55:54 2013 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/IntegerArithmeticNode.java Fri Aug 09 14:07:20 2013 +0200 @@ -22,14 +22,15 @@ */ package com.oracle.graal.nodes.calc; +import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; import com.oracle.graal.graph.*; import com.oracle.graal.nodes.*; -public abstract class IntegerArithmeticNode extends ArithmeticNode { +public abstract class IntegerArithmeticNode extends BinaryNode implements ArithmeticOperation { public IntegerArithmeticNode(Kind kind, ValueNode x, ValueNode y) { - super(kind, x, y, false); + super(kind, x, y); assert kind == Kind.Int || kind == Kind.Long; } diff -r 46843d7581b9 -r af358daf4f41 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/NegateNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/NegateNode.java Fri Aug 09 11:55:54 2013 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/NegateNode.java Fri Aug 09 14:07:20 2013 +0200 @@ -22,6 +22,7 @@ */ package com.oracle.graal.nodes.calc; +import com.oracle.graal.api.code.*; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.spi.*; import com.oracle.graal.nodes.type.*; @@ -29,7 +30,7 @@ /** * The {@code NegateNode} node negates its operand. */ -public final class NegateNode extends FloatingNode implements Canonicalizable, LIRLowerable { +public final class NegateNode extends FloatingNode implements Canonicalizable, LIRLowerable, ArithmeticOperation { @Input private ValueNode x; diff -r 46843d7581b9 -r af358daf4f41 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/ShiftNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/ShiftNode.java Fri Aug 09 11:55:54 2013 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/ShiftNode.java Fri Aug 09 14:07:20 2013 +0200 @@ -22,13 +22,14 @@ */ package com.oracle.graal.nodes.calc; +import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; import com.oracle.graal.nodes.*; /** * The {@code ShiftOp} class represents shift operations. */ -public abstract class ShiftNode extends BinaryNode { +public abstract class ShiftNode extends BinaryNode implements ArithmeticOperation { /** * Creates a new shift operation. diff -r 46843d7581b9 -r af358daf4f41 graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningUtil.java --- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningUtil.java Fri Aug 09 11:55:54 2013 +0200 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningUtil.java Fri Aug 09 14:07:20 2013 +0200 @@ -1446,7 +1446,6 @@ StructuredGraph graph = callTarget.graph(); ValueNode firstParam = callTarget.arguments().get(0); if (firstParam.kind() == Kind.Object && !ObjectStamp.isObjectNonNull(firstParam)) { - assert !ObjectStamp.isObjectAlwaysNull(firstParam); IsNullNode condition = graph.unique(new IsNullNode(firstParam)); Stamp stamp = firstParam.stamp().join(objectNonNull()); GuardingPiNode nonNullReceiver = graph.add(new GuardingPiNode(firstParam, condition, true, NullCheckException, InvalidateReprofile, stamp)); diff -r 46843d7581b9 -r af358daf4f41 graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/MathIntrinsicNode.java --- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/MathIntrinsicNode.java Fri Aug 09 11:55:54 2013 +0200 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/MathIntrinsicNode.java Fri Aug 09 14:07:20 2013 +0200 @@ -22,6 +22,7 @@ */ package com.oracle.graal.replacements.nodes; +import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; import com.oracle.graal.compiler.gen.*; import com.oracle.graal.compiler.target.*; @@ -32,7 +33,7 @@ import com.oracle.graal.nodes.spi.*; import com.oracle.graal.nodes.type.*; -public class MathIntrinsicNode extends FloatingNode implements Canonicalizable, LIRGenLowerable { +public class MathIntrinsicNode extends FloatingNode implements Canonicalizable, LIRGenLowerable, ArithmeticOperation { @Input private ValueNode x; private final Operation operation;