# HG changeset patch # User Thomas Wuerthinger # Date 1303915209 -7200 # Node ID 2f271a85d1043f28ce5cf605861e3ce534c700a5 # Parent 99307021e3f508744019d3cdbc6ae732e3c07d65 Removed intrinsic-related instructions diff -r 99307021e3f5 -r 2f271a85d104 graal/GraalCompiler/src/com/sun/c1x/C1XOptions.java --- a/graal/GraalCompiler/src/com/sun/c1x/C1XOptions.java Wed Apr 27 16:25:54 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/C1XOptions.java Wed Apr 27 16:40:09 2011 +0200 @@ -85,14 +85,12 @@ public static boolean TraceAssembler = ____; public static int TraceBytecodeParserLevel = 0; public static boolean PrintAssumptions = ____; - public static boolean PrintInlinedIntrinsics = ____; // IR checking public static boolean InterpretInvokedMethods = ____; public static boolean PrintStateInInterpreter = ____; // canonicalizer settings - public static boolean CanonicalizeIntrinsics = true; public static boolean CanonicalizeFloatingPoint = true; public static boolean CanonicalizeNarrowingInStores = true; public static boolean CanonicalizeConstantFields = true; diff -r 99307021e3f5 -r 2f271a85d104 graal/GraalCompiler/src/com/sun/c1x/gen/LIRGenerator.java --- a/graal/GraalCompiler/src/com/sun/c1x/gen/LIRGenerator.java Wed Apr 27 16:25:54 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/gen/LIRGenerator.java Wed Apr 27 16:40:09 2011 +0200 @@ -38,7 +38,6 @@ import com.sun.c1x.globalstub.*; import com.sun.c1x.graph.*; import com.sun.c1x.ir.*; -import com.sun.c1x.ir.Value.Flag; import com.sun.c1x.lir.*; import com.sun.c1x.opt.*; import com.sun.c1x.util.*; @@ -223,22 +222,6 @@ } } - public final void emitGuard(Guard x) { - FrameState state = x.stateBefore(); - assert state != null : "deoptimize instruction always needs a state"; - - if (deoptimizationStubs == null) { - deoptimizationStubs = new ArrayList(); - } - - // (tw) TODO: Try to reuse an existing stub if possible. - // It is only allowed if there are no LIR instructions in between that can modify registers. - - DeoptimizationStub stub = new DeoptimizationStub(state); - deoptimizationStubs.add(stub); - lir.branch(x.condition.negate(), stub.label, stub.info); - } - public void doBlock(BlockBegin block) { blockDoProlog(block); this.currentBlock = block; @@ -431,13 +414,6 @@ public void visitGoto(Goto x) { setNoResult(x); - if (currentBlock.next() instanceof OsrEntry) { - // need to free up storage used for OSR entry point - CiValue osrBuffer = currentBlock.next().operand(); - callRuntime(CiRuntimeCall.OSRMigrationEnd, null, osrBuffer); - emitXir(xir.genSafepoint(site(x)), x, stateFor(x, x.stateAfter()), null, false); - } - // emit phi-instruction moves after safepoint since this simplifies // describing the state at the safepoint. moveToPhi(x.stateAfter()); @@ -651,15 +627,6 @@ } @Override - public void visitOsrEntry(OsrEntry x) { - // construct our frame and model the production of incoming pointer - // to the OSR buffer. - lir.osrEntry(osrBufferPointer()); - CiValue result = createResultVariable(x); - lir.move(osrBufferPointer(), result); - } - - @Override public void visitPhi(Phi i) { Util.shouldNotReachHere(); } @@ -959,142 +926,6 @@ } } - @Override - public void visitUnsafeGetObject(UnsafeGetObject x) { - CiKind kind = x.unsafeOpKind; - - CiValue off = load(x.offset()); - CiValue src = load(x.object()); - - CiValue reg = createResultVariable(x); - - if (x.isVolatile()) { - vma.preVolatileRead(); - } - genGetObjectUnsafe(reg, src, off, kind, x.isVolatile()); - if (x.isVolatile()) { - vma.postVolatileRead(); - } - } - - @Override - public void visitUnsafeGetRaw(UnsafeGetRaw x) { - LIRItem idx = new LIRItem(this); - CiValue base = load(x.base()); - if (x.hasIndex()) { - idx.setInstruction(x.index()); - idx.loadNonconstant(); - } - - CiValue reg = createResultVariable(x); - - int log2scale = 0; - if (x.hasIndex()) { - assert x.index().kind.isInt() : "should not find non-int index"; - log2scale = x.log2Scale(); - } - - assert !x.hasIndex() || idx.instruction == x.index() : "should match"; - - CiKind dstKind = x.unsafeOpKind; - CiValue indexOp = idx.result(); - - CiAddress addr = null; - if (indexOp.isConstant()) { - assert log2scale == 0 : "must not have a scale"; - CiConstant constantIndexOp = (CiConstant) indexOp; - addr = new CiAddress(dstKind, base, constantIndexOp.asInt()); - } else { - - if (compilation.target.arch.isX86()) { - addr = new CiAddress(dstKind, base, indexOp, CiAddress.Scale.fromInt(2 ^ log2scale), 0); - - } else if (compilation.target.arch.isSPARC()) { - if (indexOp.isIllegal() || log2scale == 0) { - addr = new CiAddress(dstKind, base, indexOp); - } else { - CiValue tmp = newVariable(CiKind.Int); - lir.shiftLeft(indexOp, log2scale, tmp); - addr = new CiAddress(dstKind, base, tmp); - } - - } else { - Util.shouldNotReachHere(); - } - } - - if (x.mayBeUnaligned() && (dstKind == CiKind.Long || dstKind == CiKind.Double)) { - lir.unalignedMove(addr, reg); - } else { - lir.move(addr, reg); - } - } - - @Override - public void visitUnsafePrefetchRead(UnsafePrefetchRead x) { - visitUnsafePrefetch(x, false); - } - - @Override - public void visitUnsafePrefetchWrite(UnsafePrefetchWrite x) { - visitUnsafePrefetch(x, true); - } - - @Override - public void visitUnsafePutObject(UnsafePutObject x) { - CiKind kind = x.unsafeOpKind; - LIRItem data = new LIRItem(x.value(), this); - - CiValue src = load(x.object()); - data.loadItem(kind); - CiValue off = load(x.offset()); - - setNoResult(x); - - if (x.isVolatile()) { - vma.preVolatileWrite(); - } - genPutObjectUnsafe(src, off, data.result(), kind, x.isVolatile()); - if (x.isVolatile()) { - vma.postVolatileWrite(); - } - } - - @Override - public void visitUnsafePutRaw(UnsafePutRaw x) { - int log2scale = 0; - CiKind kind = x.unsafeOpKind; - - if (x.hasIndex()) { - assert x.index().kind.isInt() : "should not find non-int index"; - log2scale = x.log2scale(); - } - - LIRItem value = new LIRItem(x.value(), this); - LIRItem idx = new LIRItem(this); - - CiValue base = load(x.base()); - if (x.hasIndex()) { - idx.setInstruction(x.index()); - idx.loadItem(); - } - - value.loadItem(kind); - - setNoResult(x); - - CiValue indexOp = idx.result(); - if (log2scale != 0) { - // temporary fix (platform dependent code without shift on Intel would be better) - indexOp = newVariable(CiKind.Int); - lir.move(idx.result(), indexOp); - lir.shiftLeft(indexOp, log2scale, indexOp); - } - - CiValue addr = new CiAddress(x.unsafeOpKind, base, indexOp); - lir.move(value.result(), addr); - } - private void blockDoEpilog(BlockBegin block) { if (C1XOptions.PrintIRWithLIR) { TTY.println(); @@ -1217,21 +1048,6 @@ lir.jump(defaultSux); } - private void visitUnsafePrefetch(UnsafePrefetch x, boolean isStore) { - LIRItem src = new LIRItem(x.object(), this); - LIRItem off = new LIRItem(x.offset(), this); - - src.loadItem(); - if (!(off.result().isConstant() && canInlineAsConstant(x.offset()))) { - off.loadItem(); - } - - setNoResult(x); - - CiAddress addr = genAddress(src.result(), off.result(), 0, 0, CiKind.Byte); - lir.prefetch(addr, isStore); - } - protected void arithmeticOpFpu(int code, CiValue result, CiValue left, CiValue right, CiValue tmp) { CiValue leftOp = left; @@ -1850,57 +1666,10 @@ } - public void arrayCopy(RiType type, ArrayCopy arrayCopy, XirSnippet snippet) { - emitXir(snippet, arrayCopy, stateFor(arrayCopy), null, false); - } - - @Override - public void visitArrayCopy(ArrayCopy arrayCopy) { - Value src = arrayCopy.src(); - Value dest = arrayCopy.dest(); - Value srcPos = arrayCopy.srcPos(); - Value destPos = arrayCopy.destPos(); - Value length = arrayCopy.length(); - RiType srcType = src.declaredType(); - RiType destType = dest.declaredType(); - if ((srcType != null && srcType.isArrayClass()) || (destType != null && destType.isArrayClass())) { - RiType type = (srcType == null) ? destType : srcType; - if ((srcType == null || destType == null || srcType.kind() != destType.kind()) && type.kind() != CiKind.Object) { - TypeEqualityCheck typeCheck = new TypeEqualityCheck(src, dest, arrayCopy.stateBefore(), Condition.EQ); - visitTypeEqualityCheck(typeCheck); - } - boolean inputsSame = (src == dest); - boolean inputsDifferent = !inputsSame && (src.checkFlag(Flag.ResultIsUnique) || dest.checkFlag(Flag.ResultIsUnique)); - boolean needsStoreCheck = type.componentType().kind() == CiKind.Object && destType != srcType; - if (!needsStoreCheck) { - arrayCopy.setFlag(Flag.NoStoreCheck); - } - XirSnippet snippet = xir.genArrayCopy(site(arrayCopy), toXirArgument(src), toXirArgument(srcPos), toXirArgument(dest), toXirArgument(destPos), toXirArgument(length), type.componentType(), inputsSame, inputsDifferent); - arrayCopy(type, arrayCopy, snippet); - return; - } - arrayCopySlow(arrayCopy); - } - - private void arrayCopySlow(ArrayCopy arrayCopy) { - emitInvokeKnown(arrayCopy.arrayCopyMethod, arrayCopy.stateBefore(), arrayCopy.src(), arrayCopy.srcPos(), arrayCopy.dest(), arrayCopy.destPos(), arrayCopy.length()); - } - private CiValue emitInvokeKnown(RiMethod method, FrameState stateBefore, Value... args) { boolean isStatic = Modifier.isStatic(method.accessFlags()); Invoke invoke = new Invoke(isStatic ? Bytecodes.INVOKESTATIC : Bytecodes.INVOKESPECIAL, method.signature().returnKind(), args, isStatic, method, null, stateBefore); visitInvoke(invoke); return invoke.operand(); } - - @Override - public void visitTypeEqualityCheck(TypeEqualityCheck typeEqualityCheck) { - Value x = typeEqualityCheck.left(); - Value y = typeEqualityCheck.right(); - - CiValue leftValue = emitXir(xir.genGetClass(site(typeEqualityCheck), toXirArgument(x)), typeEqualityCheck, stateFor(typeEqualityCheck), null, false); - CiValue rightValue = emitXir(xir.genGetClass(site(typeEqualityCheck), toXirArgument(y)), typeEqualityCheck, stateFor(typeEqualityCheck), null, false); - lir.cmp(typeEqualityCheck.condition.negate(), leftValue, rightValue); - emitGuard(typeEqualityCheck); - } } diff -r 99307021e3f5 -r 2f271a85d104 graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java --- a/graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java Wed Apr 27 16:25:54 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java Wed Apr 27 16:40:09 2011 +0200 @@ -1436,58 +1436,6 @@ return false; } - private Instruction genArrayClone(RiMethod target, Value[] args) { - FrameState state = curState.immutableCopy(bci()); - Value array = args[0]; - RiType type = array.declaredType(); - assert type != null && type.isResolved() && type.isArrayClass(); - Value newLength = args[1]; - - Value oldLength = append(new ArrayLength(array, state)); - Value newArray = append(new NewObjectArrayClone(newLength, array, state)); - Value copyLength = append(new IfOp(newLength, Condition.LT, oldLength, newLength, oldLength)); - append(new ArrayCopy(array, Constant.forInt(0), newArray, Constant.forInt(0), copyLength, null, null)); - return (Instruction) newArray; - } - - private Instruction genArrayCopy(RiMethod target, Value[] args) { - FrameState state = curState.immutableCopy(bci()); - Instruction result; - Value src = args[0]; - Value srcPos = args[1]; - Value dest = args[2]; - Value destPos = args[3]; - Value length = args[4]; - - // Check src start pos. - Value srcLength = append(new ArrayLength(src, state)); - - // Check dest start pos. - Value destLength = srcLength; - if (src != dest) { - destLength = append(new ArrayLength(dest, state)); - } - - // Check src end pos. - Value srcEndPos = append(new ArithmeticOp(IADD, CiKind.Int, srcPos, length, false, null)); - append(new BoundsCheck(srcEndPos, srcLength, state, Condition.LE)); - - // Check dest end pos. - Value destEndPos = srcEndPos; - if (destPos != srcPos) { - destEndPos = append(new ArithmeticOp(IADD, CiKind.Int, destPos, length, false, null)); - } - append(new BoundsCheck(destEndPos, destLength, state, Condition.LE)); - - Value zero = append(Constant.forInt(0)); - append(new BoundsCheck(length, zero, state, Condition.GE)); - append(new BoundsCheck(srcPos, zero, state, Condition.GE)); - append(new BoundsCheck(destPos, zero, state, Condition.GE)); - - result = new ArrayCopy(src, srcPos, dest, destPos, length, target, state); - return result; - } - private boolean tryFoldable(RiMethod target, Value[] args) { CiConstant result = Canonicalizer.foldInvocation(compilation.runtime, target, args); if (result != null) { diff -r 99307021e3f5 -r 2f271a85d104 graal/GraalCompiler/src/com/sun/c1x/ir/ArrayCopy.java --- a/graal/GraalCompiler/src/com/sun/c1x/ir/ArrayCopy.java Wed Apr 27 16:25:54 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,94 +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.sun.c1x.ir; - -import com.sun.c1x.debug.*; -import com.sun.c1x.value.*; -import com.sun.cri.ci.*; -import com.sun.cri.ri.*; - -/** - * Copies a sequence of elements from a source into a destination array. - * - * @author Thomas Wuerthinger - * - */ -public class ArrayCopy extends StateSplit { - - private Value src; - private Value srcPos; - private Value dest; - private Value destPos; - private Value length; - public final RiMethod arrayCopyMethod; - - public ArrayCopy(Value src, Value srcPos, Value dest, Value destPos, Value length, RiMethod arrayCopyMethod, FrameState stateBefore) { - super(CiKind.Void, stateBefore); - this.arrayCopyMethod = arrayCopyMethod; - this.src = src; - this.srcPos = srcPos; - this.dest = dest; - this.destPos = destPos; - this.length = length; - } - - public Value src() { - return src; - } - - public Value srcPos() { - return srcPos; - } - - public Value dest() { - return dest; - } - - public Value destPos() { - return destPos; - } - - public Value length() { - return length; - } - - @Override - public void inputValuesDo(ValueClosure closure) { - src = closure.apply(src); - srcPos = closure.apply(srcPos); - dest = closure.apply(dest); - destPos = closure.apply(destPos); - length = closure.apply(length); - } - - @Override - public void accept(ValueVisitor v) { - v.visitArrayCopy(this); - } - - @Override - public void print(LogStream out) { - out.print("arrayCopy ").print(src).print(" ").print(srcPos).print(" "); - out.print(dest).print(" ").print(destPos).print(" ").print(length); - } -} diff -r 99307021e3f5 -r 2f271a85d104 graal/GraalCompiler/src/com/sun/c1x/ir/BoundsCheck.java --- a/graal/GraalCompiler/src/com/sun/c1x/ir/BoundsCheck.java Wed Apr 27 16:25:54 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,71 +0,0 @@ -/* - * Copyright (c) 2010, 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.sun.c1x.ir; - -import com.sun.c1x.debug.*; -import com.sun.c1x.value.*; -import com.sun.cri.ci.*; - -/** - * Performs a bounds check on the index variable given a length. Deoptimizes on index < 0 || index >= length. - * - * @author Thomas Wuerthinger - * - */ -public final class BoundsCheck extends Guard { - - Value index; - Value length; - - public BoundsCheck(Value index, Value length, FrameState stateBefore, Condition condition) { - super(condition, stateBefore); - this.index = index; - this.length = length; - assert index.kind == CiKind.Int; - assert length.kind == CiKind.Int; - } - - public Value index() { - return index; - } - - public Value length() { - return length; - } - - @Override - public void inputValuesDo(ValueClosure closure) { - index = closure.apply(index); - length = closure.apply(length); - } - - @Override - public void accept(ValueVisitor v) { - v.visitBoundsCheck(this); - } - - @Override - public void print(LogStream out) { - out.print("boundsCheck ").print(index).print(" ").print(length); - } -} diff -r 99307021e3f5 -r 2f271a85d104 graal/GraalCompiler/src/com/sun/c1x/ir/DefaultValueVisitor.java --- a/graal/GraalCompiler/src/com/sun/c1x/ir/DefaultValueVisitor.java Wed Apr 27 16:25:54 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/ir/DefaultValueVisitor.java Wed Apr 27 16:40:09 2011 +0200 @@ -42,11 +42,9 @@ // Checkstyle: stop @Override public void visitArithmeticOp(ArithmeticOp i) { visit(i); } - @Override public void visitArrayCopy(ArrayCopy i) { visit(i); } @Override public void visitArrayLength(ArrayLength i) { visit(i); } @Override public void visitBase(Base i) { visit(i); } @Override public void visitBlockBegin(BlockBegin i) { visit(i); } - @Override public void visitBoundsCheck(BoundsCheck i) { visit(i); } @Override public void visitCheckCast(CheckCast i) { visit(i); } @Override public void visitCompareOp(CompareOp i) { visit(i); } @Override public void visitConstant(Constant i) { visit(i); } @@ -72,7 +70,6 @@ @Override public void visitNewObjectArrayClone(NewObjectArrayClone i) { visit(i); } @Override public void visitNewTypeArray(NewTypeArray i) { visit(i); } @Override public void visitNullCheck(NullCheck i) { visit(i); } - @Override public void visitOsrEntry(OsrEntry i) { visit(i); } @Override public void visitPhi(Phi i) { visit(i); } @Override public void visitRegisterFinalizer(RegisterFinalizer i) { visit(i); } @Override public void visitResolveClass(ResolveClass i) { visit(i); } @@ -82,12 +79,5 @@ @Override public void visitStoreIndexed(StoreIndexed i) { visit(i); } @Override public void visitTableSwitch(TableSwitch i) { visit(i); } @Override public void visitTemplateCall(TemplateCall i) { visit(i); } - @Override public void visitTypeEqualityCheck(TypeEqualityCheck i) { visit(i); } @Override public void visitThrow(Throw i) { visit(i); } - @Override public void visitUnsafeGetObject(UnsafeGetObject i) { visit(i); } - @Override public void visitUnsafeGetRaw(UnsafeGetRaw i) { visit(i); } - @Override public void visitUnsafePrefetchRead(UnsafePrefetchRead i) { visit(i); } - @Override public void visitUnsafePrefetchWrite(UnsafePrefetchWrite i) { visit(i); } - @Override public void visitUnsafePutObject(UnsafePutObject i) { visit(i); } - @Override public void visitUnsafePutRaw(UnsafePutRaw i) { visit(i); } } diff -r 99307021e3f5 -r 2f271a85d104 graal/GraalCompiler/src/com/sun/c1x/ir/Guard.java --- a/graal/GraalCompiler/src/com/sun/c1x/ir/Guard.java Wed Apr 27 16:25:54 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2010, 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.sun.c1x.ir; - -import com.sun.c1x.value.*; -import com.sun.cri.ci.*; - -/** - * Calls the deoptimization runtime method if the condition is met. - * - * @author Thomas Wuerthinger - * - */ -public abstract class Guard extends StateSplit { - - public final Condition condition; - - public Guard(Condition condition, FrameState stateBefore) { - super(CiKind.Illegal, stateBefore); - - this.condition = condition; - } -} diff -r 99307021e3f5 -r 2f271a85d104 graal/GraalCompiler/src/com/sun/c1x/ir/OsrEntry.java --- a/graal/GraalCompiler/src/com/sun/c1x/ir/OsrEntry.java Wed Apr 27 16:25:54 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,52 +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.sun.c1x.ir; - -import com.sun.c1x.debug.*; -import com.sun.cri.ci.*; - -/** - * The {@code OsrEntry} instruction represents the buffer for an OSR. - * - * @author Ben L. Titzer - */ -public final class OsrEntry extends Instruction { - - /** - * Constructs a new OsrEntry instruction. - */ - public OsrEntry() { - // TODO: this should be a CiKind.Word - super(CiKind.Jsr); - } - - @Override - public void accept(ValueVisitor v) { - v.visitOsrEntry(this); - } - - @Override - public void print(LogStream out) { - out.print("osr entry"); - } -} diff -r 99307021e3f5 -r 2f271a85d104 graal/GraalCompiler/src/com/sun/c1x/ir/TypeEqualityCheck.java --- a/graal/GraalCompiler/src/com/sun/c1x/ir/TypeEqualityCheck.java Wed Apr 27 16:25:54 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,71 +0,0 @@ -/* - * Copyright (c) 2010, 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.sun.c1x.ir; - -import com.sun.c1x.debug.*; -import com.sun.c1x.value.*; -import com.sun.cri.ci.*; - -/** - * Checks the types of the two input values and deoptimizes if the condition does not hold. - * - * @author Thomas Wuerthinger - * - */ -public final class TypeEqualityCheck extends Guard { - - Value left; - Value right; - - public TypeEqualityCheck(Value left, Value right, FrameState stateBefore, Condition condition) { - super(condition, stateBefore); - this.left = left; - this.right = right; - assert left.kind == CiKind.Object; - assert right.kind == CiKind.Object; - } - - public Value left() { - return left; - } - - public Value right() { - return right; - } - - @Override - public void inputValuesDo(ValueClosure closure) { - left = closure.apply(left); - right = closure.apply(right); - } - - @Override - public void accept(ValueVisitor v) { - v.visitTypeEqualityCheck(this); - } - - @Override - public void print(LogStream out) { - out.print("typeEqualityCheck ").print(left).print(" ").print(right); - } -} diff -r 99307021e3f5 -r 2f271a85d104 graal/GraalCompiler/src/com/sun/c1x/ir/UnsafeGetObject.java --- a/graal/GraalCompiler/src/com/sun/c1x/ir/UnsafeGetObject.java Wed Apr 27 16:25:54 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,55 +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.sun.c1x.ir; - -import com.sun.c1x.debug.*; -import com.sun.cri.ci.*; - -/** - * The {@code UnsafeGetObject} instruction represents an unsafe read. - * - * @author Ben L. Titzer - */ -public final class UnsafeGetObject extends UnsafeObjectOp { - - /** - * Constructs a new UnsafeGetObject operation. - * @param opKind the kind of the operation - * @param object the instruction generating the object - * @param offset the instruction generating the offset - * @param isVolatile {@code true} if this operation is volatile - */ - public UnsafeGetObject(CiKind opKind, Value object, Value offset, boolean isVolatile) { - super(opKind, object, offset, false, isVolatile); - } - - @Override - public void accept(ValueVisitor v) { - v.visitUnsafeGetObject(this); - } - - @Override - public void print(LogStream out) { - out.print("UnsafeGetObject.(").print(object()).print(", ").print(offset()).print(')'); - } -} diff -r 99307021e3f5 -r 2f271a85d104 graal/GraalCompiler/src/com/sun/c1x/ir/UnsafeGetRaw.java --- a/graal/GraalCompiler/src/com/sun/c1x/ir/UnsafeGetRaw.java Wed Apr 27 16:25:54 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,83 +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.sun.c1x.ir; - -import com.sun.c1x.debug.*; -import com.sun.cri.ci.*; - -/** - * The {@code UnsafeGetRaw} instruction represents an unsafe access of raw memory where - * the type is not an object reference. - * - * @author Ben L. Titzer - */ -public final class UnsafeGetRaw extends UnsafeRawOp { - - final boolean mayBeUnaligned; - - /** - * Constructs a new UnsafeGetRaw instruction. - * @param opKind the kind of the operation - * @param addr the instruction generating the base address - * @param mayBeUnaligned {@code true} if this operation may be unaligned - */ - public UnsafeGetRaw(CiKind opKind, Value addr, boolean mayBeUnaligned) { - super(opKind, addr, false); - this.mayBeUnaligned = mayBeUnaligned; - } - - /** - * Constructs a new UnsafeGetRaw instruction. - * @param opKind the kind of the operation - * @param addr the instruction generating the base address - * @param index the instruction generating the index - * @param log2scale the log base 2 of the scaling factor - * @param mayBeUnaligned {@code true} if this operation may be unaligned - */ - public UnsafeGetRaw(CiKind opKind, Value addr, Value index, int log2scale, boolean mayBeUnaligned) { - super(opKind, addr, index, log2scale, false); - this.mayBeUnaligned = mayBeUnaligned; - } - - /** - * Checks whether this operation may be unaligned. - * @return {@code true} if this operation may be unaligned - */ - public boolean mayBeUnaligned() { - return mayBeUnaligned; - } - - @Override - public void accept(ValueVisitor v) { - v.visitUnsafeGetRaw(this); - } - - @Override - public void print(LogStream out) { - out.print("UnsafeGetRaw.(base ").print(base()); - if (hasIndex()) { - out.print(", index ").print(index()).print(", log2_scale ").print(log2Scale()); - } - out.print(')'); - } -} diff -r 99307021e3f5 -r 2f271a85d104 graal/GraalCompiler/src/com/sun/c1x/ir/UnsafeObjectOp.java --- a/graal/GraalCompiler/src/com/sun/c1x/ir/UnsafeObjectOp.java Wed Apr 27 16:25:54 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,87 +0,0 @@ -/* - * Copyright (c) 2009, 2010, 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.sun.c1x.ir; - -import com.sun.cri.ci.*; - -/** - * The {@code UnsafeObjectOp} class is the base of all unsafe object instructions. - * - * @author Ben L. Titzer - */ -public abstract class UnsafeObjectOp extends UnsafeOp { - - Value object; - Value offset; - final boolean isVolatile; - - /** - * Creates a new UnsafeObjectOp instruction. - * @param opKind the kind of the operation - * @param object the instruction generating the object - * @param offset the instruction generating the index - * @param isStore {@code true} if this is a store operation - * @param isVolatile {@code true} if the operation is volatile - */ - public UnsafeObjectOp(CiKind opKind, Value object, Value offset, boolean isStore, boolean isVolatile) { - super(opKind, isStore); - this.object = object; - this.offset = offset; - this.isVolatile = isVolatile; - } - - /** - * Gets the instruction that generates the object. - * @return the instruction that produces the object - */ - public Value object() { - return object; - } - - /** - * Gets the instruction that generates the offset. - * @return the instruction generating the offset - */ - public Value offset() { - return offset; - } - - /** - * Checks whether this is a volatile operation. - * @return {@code true} if this operation is volatile - */ - public boolean isVolatile() { - return isVolatile; - } - - /** - * Iterates over the input values of this instruction. - * @param closure the closure to apply - */ - @Override - public void inputValuesDo(ValueClosure closure) { - super.inputValuesDo(closure); - object = closure.apply(object); - offset = closure.apply(offset); - } -} diff -r 99307021e3f5 -r 2f271a85d104 graal/GraalCompiler/src/com/sun/c1x/ir/UnsafeOp.java --- a/graal/GraalCompiler/src/com/sun/c1x/ir/UnsafeOp.java Wed Apr 27 16:25:54 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2009, 2010, 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.sun.c1x.ir; - -import com.sun.cri.ci.*; - -/** - * The {@code UnsafeOp} class is the base of all unsafe operations. - * - * @author Ben L. Titzer - */ -public abstract class UnsafeOp extends Instruction { - public final CiKind unsafeOpKind; - - /** - * Creates a new UnsafeOp instruction. - * @param unsafeOpKind the kind of the operation - * @param isStore {@code true} if this is a store operation - */ - public UnsafeOp(CiKind unsafeOpKind, boolean isStore) { - super(isStore ? CiKind.Void : unsafeOpKind.stackKind()); - this.unsafeOpKind = unsafeOpKind; - } - -} diff -r 99307021e3f5 -r 2f271a85d104 graal/GraalCompiler/src/com/sun/c1x/ir/UnsafePrefetch.java --- a/graal/GraalCompiler/src/com/sun/c1x/ir/UnsafePrefetch.java Wed Apr 27 16:25:54 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2009, 2010, 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.sun.c1x.ir; - -import com.sun.cri.ci.*; - -/** - * The {@code UnsafePrefetch} class is the base of prefetch reads and prefetch writes. - * - * @author Ben L. Titzer - */ -public abstract class UnsafePrefetch extends UnsafeObjectOp { - - /** - * Creates a new UnsafePrefetch instruction. - * @param object the instruction generating the object - * @param offset the instruction generating the offset - */ - public UnsafePrefetch(Value object, Value offset) { - super(CiKind.Void, object, offset, false, false); - } -} diff -r 99307021e3f5 -r 2f271a85d104 graal/GraalCompiler/src/com/sun/c1x/ir/UnsafePrefetchRead.java --- a/graal/GraalCompiler/src/com/sun/c1x/ir/UnsafePrefetchRead.java Wed Apr 27 16:25:54 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,52 +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.sun.c1x.ir; - -import com.sun.c1x.debug.*; - -/** - * The {@code UnsafePrefetchRead} instruction represents a prefetch operation on an object field. - * - * @author Ben L. Titzer - */ -public final class UnsafePrefetchRead extends UnsafePrefetch { - - /** - * Creates a new UnsafePrefetchRead instruction. - * @param object the instruction generating the object - * @param offset the instruction generating the offset - */ - public UnsafePrefetchRead(Value object, Value offset) { - super(object, offset); - } - - @Override - public void accept(ValueVisitor v) { - v.visitUnsafePrefetchRead(this); - } - - @Override - public void print(LogStream out) { - out.print("UnsafePrefetchRead.(").print(object()).print(", ").print(offset()).print(')'); - } -} diff -r 99307021e3f5 -r 2f271a85d104 graal/GraalCompiler/src/com/sun/c1x/ir/UnsafePrefetchWrite.java --- a/graal/GraalCompiler/src/com/sun/c1x/ir/UnsafePrefetchWrite.java Wed Apr 27 16:25:54 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,52 +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.sun.c1x.ir; - -import com.sun.c1x.debug.*; - -/** - * The {@code UnsafePrefetchWrite} instruction represents a prefetch write. - * - * @author Ben L. Titzer - */ -public final class UnsafePrefetchWrite extends UnsafePrefetch { - - /** - * Creates a new UnsafePrefetchWrite instruction. - * @param object the instruction generating the object - * @param offset the instruction generating the offset - */ - public UnsafePrefetchWrite(Value object, Value offset) { - super(object, offset); - } - - @Override - public void accept(ValueVisitor v) { - v.visitUnsafePrefetchWrite(this); - } - - @Override - public void print(LogStream out) { - out.print("UnsafePrefetchWrite.(").print(object()).print(", ").print(offset()).print(')'); - } -} diff -r 99307021e3f5 -r 2f271a85d104 graal/GraalCompiler/src/com/sun/c1x/ir/UnsafePutObject.java --- a/graal/GraalCompiler/src/com/sun/c1x/ir/UnsafePutObject.java Wed Apr 27 16:25:54 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,74 +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.sun.c1x.ir; - -import com.sun.c1x.debug.*; -import com.sun.cri.ci.*; - -/** - * The {@code UnsafePutObject} instruction represents a unsafe write operation. - * - * @author Ben L. Titzer - */ -public final class UnsafePutObject extends UnsafeObjectOp { - - Value value; - - /** - * Creates a new UnsafePutObject instruction. - * @param opKind the kind of the operation - * @param object the instruction generating the object - * @param offset the instruction generating the offset - * @param value the instruction generating the value - * @param isVolatile {@code true} if the operation is volatile - */ - public UnsafePutObject(CiKind opKind, Value object, Value offset, Value value, boolean isVolatile) { - super(opKind, object, offset, true, isVolatile); - this.value = value; - } - - /** - * Gets the instruction that generates the value to store. - * @return the instruction generating the value - */ - public Value value() { - return value; - } - - @Override - public void inputValuesDo(ValueClosure closure) { - super.inputValuesDo(closure); - value = closure.apply(value); - } - - @Override - public void accept(ValueVisitor v) { - v.visitUnsafePutObject(this); - } - - @Override - public void print(LogStream out) { - out.print("UnsafePutObject.(").print(object()).print(", ").print(offset() + - ", value ").print(value()).print(')'); - } -} diff -r 99307021e3f5 -r 2f271a85d104 graal/GraalCompiler/src/com/sun/c1x/ir/UnsafePutRaw.java --- a/graal/GraalCompiler/src/com/sun/c1x/ir/UnsafePutRaw.java Wed Apr 27 16:25:54 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,79 +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.sun.c1x.ir; - -import com.sun.c1x.debug.*; -import com.sun.cri.ci.*; - -/** - * The {@code UnsafePutRaw} instruction represents an unsafe store operation. - * - * @author Ben L. Titzer - */ -public final class UnsafePutRaw extends UnsafeRawOp { - - Value value; - - /** - * Constructs a new UnsafeGetRaw instruction. - * @param opKind the kind of the operation - * @param addr the instruction generating the base address - * @param value the instruction generating the value to store - */ - public UnsafePutRaw(CiKind opKind, Value addr, Value value) { - super(opKind, addr, false); - this.value = value; - } - - /** - * Gets the instruction generating the value that will be stored. - * @return the instruction generating the value - */ - public Value value() { - return value; - } - - @Override - public void inputValuesDo(ValueClosure closure) { - super.inputValuesDo(closure); - value = closure.apply(value); - } - - @Override - public void accept(ValueVisitor v) { - v.visitUnsafePutRaw(this); - } - - public int log2scale() { - return log2Scale; - } - - @Override - public void print(LogStream out) { - out.print("UnsafePutRaw.(base ").print(base()); - if (hasIndex()) { - out.print(", index ").print(index()).print(", log2_scale ").print(log2Scale()); - } - out.print(", value ").print(value()).print(')'); - } -} diff -r 99307021e3f5 -r 2f271a85d104 graal/GraalCompiler/src/com/sun/c1x/ir/UnsafeRawOp.java --- a/graal/GraalCompiler/src/com/sun/c1x/ir/UnsafeRawOp.java Wed Apr 27 16:25:54 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,133 +0,0 @@ -/* - * Copyright (c) 2009, 2010, 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.sun.c1x.ir; - -import com.sun.cri.ci.*; - -/** - * The {@code UnsafeRawOp} class is the base class of all unsafe raw operations. - * - * @author Ben L. Titzer - */ -public abstract class UnsafeRawOp extends UnsafeOp { - - Value base; - Value index; - int log2Scale; - - /** - * Creates a new UnsafeRawOp instruction. - * @param opKind the kind of the operation - * @param addr the instruction generating the base address (a long) - * @param isStore {@code true} if this operation is a store - */ - public UnsafeRawOp(CiKind opKind, Value addr, boolean isStore) { - super(opKind, isStore); - assert addr == null || addr.kind == CiKind.Long; - base = addr; - } - - /** - * Creates a new UnsafeRawOp instruction. - * @param opKind the kind of the operation - * @param addr the instruction generating the base address (a long) - * @param index the instruction generating the index - * @param log2scale the log base 2 of the scaling factor - * @param isStore {@code true} if this operation is a store - */ - public UnsafeRawOp(CiKind opKind, Value addr, Value index, int log2scale, boolean isStore) { - this(opKind, addr, isStore); - this.base = addr; - this.index = index; - this.log2Scale = log2scale; - } - - /** - * Gets the instruction generating the base address for this operation. - * @return the instruction generating the base - */ - public Value base() { - return base; - } - - /** - * Gets the instruction generating the index for this operation. - * @return the instruction generating the index - */ - public Value index() { - return index; - } - - /** - * Checks whether this instruction has an index. - * @return {@code true} if this instruction has an index - */ - public boolean hasIndex() { - return index != null; - } - - /** - * Gets the log base 2 of the scaling factor for the index of this instruction. - * @return the log base 2 of the scaling factor - */ - public int log2Scale() { - return log2Scale; - } - - /** - * Sets the instruction that generates the base address for this instruction. - * @param base the instruction generating the base address - */ - public void setBase(Value base) { - this.base = base; - } - - /** - * Sets the instruction generating the base address for this instruction. - * @param index the instruction generating the index - */ - public void setIndex(Value index) { - this.index = index; - } - - /** - * Sets the scaling factor for the index of this instruction. - * @param log2scale the log base 2 of the scaling factor for this instruction - */ - public void setLog2Scale(int log2scale) { - this.log2Scale = log2scale; - } - - /** - * Iterates over the input values to this instruction. - * @param closure the closure to apply - */ - @Override - public void inputValuesDo(ValueClosure closure) { - super.inputValuesDo(closure); - base = closure.apply(base); - if (index != null) { - index = closure.apply(index); - } - } -} diff -r 99307021e3f5 -r 2f271a85d104 graal/GraalCompiler/src/com/sun/c1x/ir/ValueVisitor.java --- a/graal/GraalCompiler/src/com/sun/c1x/ir/ValueVisitor.java Wed Apr 27 16:25:54 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/ir/ValueVisitor.java Wed Apr 27 16:40:09 2011 +0200 @@ -32,10 +32,8 @@ public abstract class ValueVisitor { // Checkstyle: stop public abstract void visitArithmeticOp(ArithmeticOp i); - public abstract void visitArrayCopy(ArrayCopy arrayCopy); public abstract void visitArrayLength(ArrayLength i); public abstract void visitBase(Base i); - public abstract void visitBoundsCheck(BoundsCheck boundsCheck); public abstract void visitBlockBegin(BlockBegin i); public abstract void visitCheckCast(CheckCast i); public abstract void visitCompareOp(CompareOp i); @@ -62,7 +60,6 @@ public abstract void visitNewObjectArrayClone(NewObjectArrayClone newObjectArrayClone); public abstract void visitNewTypeArray(NewTypeArray i); public abstract void visitNullCheck(NullCheck i); - public abstract void visitOsrEntry(OsrEntry i); public abstract void visitPhi(Phi i); public abstract void visitRegisterFinalizer(RegisterFinalizer i); public abstract void visitResolveClass(ResolveClass i); @@ -73,11 +70,4 @@ public abstract void visitTableSwitch(TableSwitch i); public abstract void visitTemplateCall(TemplateCall templateCall); public abstract void visitThrow(Throw i); - public abstract void visitTypeEqualityCheck(TypeEqualityCheck typeEqualityCheck); - public abstract void visitUnsafeGetObject(UnsafeGetObject i); - public abstract void visitUnsafeGetRaw(UnsafeGetRaw i); - public abstract void visitUnsafePrefetchRead(UnsafePrefetchRead i); - public abstract void visitUnsafePrefetchWrite(UnsafePrefetchWrite i); - public abstract void visitUnsafePutObject(UnsafePutObject i); - public abstract void visitUnsafePutRaw(UnsafePutRaw i); } diff -r 99307021e3f5 -r 2f271a85d104 graal/GraalCompiler/src/com/sun/c1x/opt/Canonicalizer.java --- a/graal/GraalCompiler/src/com/sun/c1x/opt/Canonicalizer.java Wed Apr 27 16:25:54 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/opt/Canonicalizer.java Wed Apr 27 16:40:09 2011 +0200 @@ -1022,90 +1022,6 @@ } } - private void visitUnsafeRawOp(UnsafeRawOp i) { - if (i.base() instanceof ArithmeticOp) { - // if the base is an arithmetic op, try reducing - ArithmeticOp root = (ArithmeticOp) i.base(); - if (!root.isLive() && root.opcode == LADD) { - // match unsafe(x + y) if the x + y is not pinned - // try reducing (x + y) and (y + x) - Value y = root.y(); - Value x = root.x(); - if (reduceRawOp(i, x, y) || reduceRawOp(i, y, x)) { - // the operation was reduced - return; - } - if (y instanceof Convert) { - // match unsafe(x + (long) y) - Convert convert = (Convert) y; - if (convert.opcode == I2L && convert.value().kind.isInt()) { - // the conversion is redundant - setUnsafeRawOp(i, x, convert.value(), 0); - } - } - } - } - } - - private boolean reduceRawOp(UnsafeRawOp i, Value base, Value index) { - if (index instanceof Convert) { - // skip any conversion operations - index = ((Convert) index).value(); - } - if (index instanceof ShiftOp) { - // try to match the index as a shift by a constant - ShiftOp shift = (ShiftOp) index; - CiKind st = shift.y().kind; - if (shift.y().isConstant() && st.isInt()) { - int val = shift.y().asConstant().asInt(); - switch (val) { - case 0: // fall through - case 1: // fall through - case 2: // fall through - case 3: return setUnsafeRawOp(i, base, shift.x(), val); - } - } - } - if (index instanceof ArithmeticOp) { - // try to match the index as a multiply by a constant - // note that this case will not happen if C1XOptions.CanonicalizeMultipliesToShifts is true - ArithmeticOp arith = (ArithmeticOp) index; - CiKind st = arith.y().kind; - if (arith.opcode == IMUL && arith.y().isConstant() && st.isInt()) { - int val = arith.y().asConstant().asInt(); - switch (val) { - case 1: return setUnsafeRawOp(i, base, arith.x(), 0); - case 2: return setUnsafeRawOp(i, base, arith.x(), 1); - case 4: return setUnsafeRawOp(i, base, arith.x(), 2); - case 8: return setUnsafeRawOp(i, base, arith.x(), 3); - } - } - } - - return false; - } - - private boolean setUnsafeRawOp(UnsafeRawOp i, Value base, Value index, int log2scale) { - i.setBase(base); - i.setIndex(index); - i.setLog2Scale(log2scale); - return true; - } - - @Override - public void visitUnsafeGetRaw(UnsafeGetRaw i) { - if (C1XOptions.CanonicalizeUnsafes) { - visitUnsafeRawOp(i); - } - } - - @Override - public void visitUnsafePutRaw(UnsafePutRaw i) { - if (C1XOptions.CanonicalizeUnsafes) { - visitUnsafeRawOp(i); - } - } - private Object argAsObject(Value[] args, int index) { CiConstant c = args[index].asConstant(); if (c != null) { @@ -1163,28 +1079,6 @@ return result; } - @Override - public void visitTypeEqualityCheck(TypeEqualityCheck i) { - if (i.condition == Condition.EQ && i.left() == i.right()) { - setCanonical(null); - } - } - - @Override - public void visitBoundsCheck(BoundsCheck b) { - Value index = b.index(); - Value length = b.length(); - - if (index.isConstant() && length.isConstant()) { - int i = index.asConstant().asInt(); - int l = index.asConstant().asInt(); - Condition c = b.condition; - if (c.check(i, l)) { - setCanonical(null); - } - } - } - private RiType getTypeOf(Value x) { if (x.isConstant()) { return runtime.getTypeOf(x.asConstant()); diff -r 99307021e3f5 -r 2f271a85d104 graal/GraalCompiler/src/com/sun/c1x/target/amd64/AMD64LIRGenerator.java --- a/graal/GraalCompiler/src/com/sun/c1x/target/amd64/AMD64LIRGenerator.java Wed Apr 27 16:25:54 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/target/amd64/AMD64LIRGenerator.java Wed Apr 27 16:40:09 2011 +0200 @@ -568,19 +568,4 @@ protected CiValue osrBufferPointer() { return Util.nonFatalUnimplemented(null); } - - @Override - public void visitBoundsCheck(BoundsCheck boundsCheck) { - Value x = boundsCheck.index(); - Value y = boundsCheck.length(); - CiValue left = load(x); - CiValue right = null; - if (y.isConstant()) { - right = makeOperand(y); - } else { - right = load(y); - } - lir.cmp(boundsCheck.condition.negate(), left, right); - emitGuard(boundsCheck); - } }