# HG changeset patch # User Roland Schatz # Date 1366899151 -7200 # Node ID 899295127bc4d0216646d5e05d93a7a47a1f2a6b # Parent d006c9920e943276e281e8cd153d1f7e367dbe60 Get rid of the distinction between UNUSED and ILLEGAL value. diff -r d006c9920e94 -r 899295127bc4 graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/AllocatableValue.java --- a/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/AllocatableValue.java Thu Apr 25 16:12:06 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,50 +0,0 @@ -/* - * 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; - -import com.oracle.graal.api.meta.*; - -/** - * Common base class for values that can be manipulated by the register allocator. - */ -public abstract class AllocatableValue extends Value { - - private static final long serialVersionUID = 153019506717492133L; - - /** - * Marker to tell the register allocator that no storage location needs to be allocated for this - * value. - */ - @SuppressWarnings("serial") public static final AllocatableValue UNUSED = new AllocatableValue(Kind.Illegal) { - - @Override - public String toString() { - return "-"; - } - }; - - public AllocatableValue(Kind kind) { - super(kind); - } - -} diff -r d006c9920e94 -r 899295127bc4 graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/AllocatableValue.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/AllocatableValue.java Thu Apr 25 16:12:31 2013 +0200 @@ -0,0 +1,37 @@ +/* + * 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.meta; + +/** + * Common base class for values that are stored in some location that's managed by the register + * allocator (e.g. register, stack slot). + */ +public abstract class AllocatableValue extends Value { + + private static final long serialVersionUID = 153019506717492133L; + + public AllocatableValue(Kind kind) { + super(kind); + } + +} diff -r d006c9920e94 -r 899295127bc4 graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/Value.java --- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/Value.java Thu Apr 25 16:12:06 2013 +0200 +++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/Value.java Thu Apr 25 16:12:31 2013 +0200 @@ -34,7 +34,7 @@ public static final Value[] NONE = {}; - @SuppressWarnings("serial") public static final Value ILLEGAL = new Value(Kind.Illegal) { + @SuppressWarnings("serial") public static final AllocatableValue ILLEGAL = new AllocatableValue(Kind.Illegal) { @Override public String toString() { diff -r d006c9920e94 -r 899295127bc4 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 Thu Apr 25 16:12:06 2013 +0200 +++ b/graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64LIRGenerator.java Thu Apr 25 16:12:31 2013 +0200 @@ -161,15 +161,13 @@ long finalDisp = displacement; if (isConstant(base)) { if (asConstant(base).isNull()) { - baseRegister = AllocatableValue.UNUSED; + baseRegister = Value.ILLEGAL; } else if (asConstant(base).getKind() != Kind.Object && !runtime.needsDataPatch(asConstant(base))) { finalDisp += asConstant(base).asLong(); - baseRegister = AllocatableValue.UNUSED; + baseRegister = Value.ILLEGAL; } else { baseRegister = load(base); } - } else if (base == Value.ILLEGAL) { - baseRegister = AllocatableValue.UNUSED; } else { baseRegister = asAllocatable(base); } @@ -180,12 +178,12 @@ scaleEnum = Scale.fromInt(scale); if (isConstant(index)) { finalDisp += asConstant(index).asLong() * scale; - indexRegister = AllocatableValue.UNUSED; + indexRegister = Value.ILLEGAL; } else { indexRegister = asAllocatable(index); } } else { - indexRegister = AllocatableValue.UNUSED; + indexRegister = Value.ILLEGAL; scaleEnum = Scale.Times1; } @@ -195,9 +193,9 @@ } else { displacementInt = 0; AllocatableValue displacementRegister = load(Constant.forLong(finalDisp)); - if (baseRegister == AllocatableValue.UNUSED) { + if (baseRegister == Value.ILLEGAL) { baseRegister = displacementRegister; - } else if (indexRegister == AllocatableValue.UNUSED) { + } else if (indexRegister == Value.ILLEGAL) { indexRegister = displacementRegister; scaleEnum = Scale.Times1; } else { diff -r d006c9920e94 -r 899295127bc4 graal/com.oracle.graal.compiler.ptx/src/com/oracle/graal/compiler/ptx/PTXLIRGenerator.java --- a/graal/com.oracle.graal.compiler.ptx/src/com/oracle/graal/compiler/ptx/PTXLIRGenerator.java Thu Apr 25 16:12:06 2013 +0200 +++ b/graal/com.oracle.graal.compiler.ptx/src/com/oracle/graal/compiler/ptx/PTXLIRGenerator.java Thu Apr 25 16:12:31 2013 +0200 @@ -28,17 +28,13 @@ import static com.oracle.graal.lir.ptx.PTXBitManipulationOp.IntrinsicOpcode.*; import static com.oracle.graal.lir.ptx.PTXCompare.*; -import com.oracle.graal.api.code.AllocatableValue; import com.oracle.graal.api.code.CodeCacheProvider; import com.oracle.graal.api.code.DeoptimizationAction; import com.oracle.graal.api.code.RuntimeCallTarget; import com.oracle.graal.api.code.StackSlot; import com.oracle.graal.api.code.TargetDescription; import com.oracle.graal.api.code.RuntimeCallTarget.Descriptor; -import com.oracle.graal.api.meta.Constant; -import com.oracle.graal.api.meta.Kind; -import com.oracle.graal.api.meta.ResolvedJavaMethod; -import com.oracle.graal.api.meta.Value; +import com.oracle.graal.api.meta.*; import com.oracle.graal.asm.NumUtil; import com.oracle.graal.compiler.gen.LIRGenerator; import com.oracle.graal.compiler.target.LIRGenLowerable; @@ -142,15 +138,13 @@ long finalDisp = displacement; if (isConstant(base)) { if (asConstant(base).isNull()) { - baseRegister = AllocatableValue.UNUSED; + baseRegister = Value.ILLEGAL; } else if (asConstant(base).getKind() != Kind.Object) { finalDisp += asConstant(base).asLong(); - baseRegister = AllocatableValue.UNUSED; + baseRegister = Value.ILLEGAL; } else { baseRegister = load(base); } - } else if (base == Value.ILLEGAL) { - baseRegister = AllocatableValue.UNUSED; } else { baseRegister = asAllocatable(base); } @@ -166,7 +160,7 @@ indexRegister = index; } - if (baseRegister == AllocatableValue.UNUSED) { + if (baseRegister == Value.ILLEGAL) { baseRegister = asAllocatable(indexRegister); } else { Variable newBase = newVariable(Kind.Int); diff -r d006c9920e94 -r 899295127bc4 graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotUnwindOp.java --- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotUnwindOp.java Thu Apr 25 16:12:06 2013 +0200 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotUnwindOp.java Thu Apr 25 16:12:31 2013 +0200 @@ -29,6 +29,7 @@ import com.oracle.graal.amd64.*; import com.oracle.graal.api.code.*; import com.oracle.graal.api.code.RuntimeCallTarget.Descriptor; +import com.oracle.graal.api.meta.*; import com.oracle.graal.asm.amd64.*; import com.oracle.graal.lir.LIRInstruction.Opcode; import com.oracle.graal.lir.amd64.*; diff -r d006c9920e94 -r 899295127bc4 graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64SafepointOp.java --- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64SafepointOp.java Thu Apr 25 16:12:06 2013 +0200 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64SafepointOp.java Thu Apr 25 16:12:31 2013 +0200 @@ -27,6 +27,7 @@ import sun.misc.*; import com.oracle.graal.api.code.*; +import com.oracle.graal.api.meta.*; import com.oracle.graal.asm.amd64.*; import com.oracle.graal.hotspot.*; import com.oracle.graal.hotspot.bridge.*; diff -r d006c9920e94 -r 899295127bc4 graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64AddressValue.java --- a/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64AddressValue.java Thu Apr 25 16:12:06 2013 +0200 +++ b/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64AddressValue.java Thu Apr 25 16:12:31 2013 +0200 @@ -30,18 +30,19 @@ import com.oracle.graal.asm.amd64.*; import com.oracle.graal.asm.amd64.AMD64Address.Scale; import com.oracle.graal.lir.*; +import com.oracle.graal.lir.LIRInstruction.OperandFlag; public class AMD64AddressValue extends CompositeValue { private static final long serialVersionUID = -4444600052487578694L; - @Component({REG, UNUSED}) protected AllocatableValue base; - @Component({REG, UNUSED}) protected AllocatableValue index; + @Component({REG, OperandFlag.ILLEGAL}) protected AllocatableValue base; + @Component({REG, OperandFlag.ILLEGAL}) protected AllocatableValue index; protected final Scale scale; protected final int displacement; public AMD64AddressValue(Kind kind, AllocatableValue base, int displacement) { - this(kind, base, AllocatableValue.UNUSED, Scale.Times1, displacement); + this(kind, base, Value.ILLEGAL, Scale.Times1, displacement); } public AMD64AddressValue(Kind kind, AllocatableValue base, AllocatableValue index, Scale scale, int displacement) { @@ -53,7 +54,7 @@ } private static Register toRegister(AllocatableValue value) { - if (value == AllocatableValue.UNUSED) { + if (value == Value.ILLEGAL) { return Register.None; } else { RegisterValue reg = (RegisterValue) value; diff -r d006c9920e94 -r 899295127bc4 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 Thu Apr 25 16:12:06 2013 +0200 +++ b/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64Arithmetic.java Thu Apr 25 16:12:31 2013 +0200 @@ -26,7 +26,6 @@ import static com.oracle.graal.lir.LIRInstruction.OperandFlag.*; import com.oracle.graal.amd64.*; -import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; import com.oracle.graal.asm.amd64.*; import com.oracle.graal.graph.*; diff -r d006c9920e94 -r 899295127bc4 graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64BitManipulationOp.java --- a/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64BitManipulationOp.java Thu Apr 25 16:12:06 2013 +0200 +++ b/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64BitManipulationOp.java Thu Apr 25 16:12:31 2013 +0200 @@ -23,6 +23,7 @@ package com.oracle.graal.lir.amd64; import com.oracle.graal.api.code.*; +import com.oracle.graal.api.meta.*; import com.oracle.graal.asm.amd64.*; import com.oracle.graal.lir.asm.*; diff -r d006c9920e94 -r 899295127bc4 graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXAddressValue.java --- a/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXAddressValue.java Thu Apr 25 16:12:06 2013 +0200 +++ b/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXAddressValue.java Thu Apr 25 16:12:31 2013 +0200 @@ -29,6 +29,7 @@ import com.oracle.graal.api.meta.*; import com.oracle.graal.asm.ptx.*; import com.oracle.graal.lir.*; +import com.oracle.graal.lir.LIRInstruction.OperandFlag; /** * Represents an address in target machine memory, specified via some combination of a base register @@ -38,7 +39,7 @@ private static final long serialVersionUID = 1802222435353022623L; - @Component({REG, UNUSED}) private AllocatableValue base; + @Component({REG, OperandFlag.ILLEGAL}) private AllocatableValue base; private final long displacement; /** @@ -68,7 +69,7 @@ } public PTXAddress toAddress() { - Register baseReg = base == AllocatableValue.UNUSED ? Register.None : asRegister(base); + Register baseReg = base == Value.ILLEGAL ? Register.None : asRegister(base); return new PTXAddress(baseReg, displacement); } diff -r d006c9920e94 -r 899295127bc4 graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXArithmetic.java --- a/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXArithmetic.java Thu Apr 25 16:12:06 2013 +0200 +++ b/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXArithmetic.java Thu Apr 25 16:12:31 2013 +0200 @@ -25,7 +25,6 @@ import static com.oracle.graal.api.code.ValueUtil.*; import static com.oracle.graal.lir.LIRInstruction.OperandFlag.*; -import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; import com.oracle.graal.asm.ptx.*; import com.oracle.graal.graph.*; diff -r d006c9920e94 -r 899295127bc4 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIRInstruction.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIRInstruction.java Thu Apr 25 16:12:06 2013 +0200 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIRInstruction.java Thu Apr 25 16:12:31 2013 +0200 @@ -181,11 +181,6 @@ ILLEGAL, /** - * The value can be {@link AllocatableValue#UNUSED}. - */ - UNUSED, - - /** * The register allocator should try to assign a certain register to improve code quality. * Use {@link LIRInstruction#forEachRegisterHint} to access the register hints. */ @@ -205,10 +200,10 @@ static { ALLOWED_FLAGS = new EnumMap<>(OperandMode.class); - ALLOWED_FLAGS.put(USE, EnumSet.of(REG, STACK, COMPOSITE, CONST, ILLEGAL, HINT, UNUSED, UNINITIALIZED)); - ALLOWED_FLAGS.put(ALIVE, EnumSet.of(REG, STACK, COMPOSITE, CONST, ILLEGAL, HINT, UNUSED, UNINITIALIZED)); - ALLOWED_FLAGS.put(TEMP, EnumSet.of(REG, COMPOSITE, CONST, ILLEGAL, UNUSED, HINT)); - ALLOWED_FLAGS.put(DEF, EnumSet.of(REG, STACK, COMPOSITE, ILLEGAL, UNUSED, HINT)); + ALLOWED_FLAGS.put(USE, EnumSet.of(REG, STACK, COMPOSITE, CONST, ILLEGAL, HINT, UNINITIALIZED)); + ALLOWED_FLAGS.put(ALIVE, EnumSet.of(REG, STACK, COMPOSITE, CONST, ILLEGAL, HINT, UNINITIALIZED)); + ALLOWED_FLAGS.put(TEMP, EnumSet.of(REG, COMPOSITE, CONST, ILLEGAL, HINT)); + ALLOWED_FLAGS.put(DEF, EnumSet.of(REG, STACK, COMPOSITE, ILLEGAL, HINT)); } /** diff -r d006c9920e94 -r 899295127bc4 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIRVerifier.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIRVerifier.java Thu Apr 25 16:12:06 2013 +0200 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIRVerifier.java Thu Apr 25 16:12:31 2013 +0200 @@ -232,8 +232,7 @@ private static Value allowed(Object op, Value value, OperandMode mode, EnumSet flags) { if ((isVariable(value) && flags.contains(OperandFlag.REG)) || (isRegister(value) && flags.contains(OperandFlag.REG)) || (isStackSlot(value) && flags.contains(OperandFlag.STACK)) || - (isConstant(value) && flags.contains(OperandFlag.CONST) && mode != OperandMode.DEF) || (isIllegal(value) && flags.contains(OperandFlag.ILLEGAL)) || - (value == AllocatableValue.UNUSED && flags.contains(OperandFlag.UNUSED))) { + (isConstant(value) && flags.contains(OperandFlag.CONST) && mode != OperandMode.DEF) || (isIllegal(value) && flags.contains(OperandFlag.ILLEGAL))) { return value; } TTY.println("instruction %s", op); diff -r d006c9920e94 -r 899295127bc4 src/share/vm/graal/graalJavaAccess.hpp --- a/src/share/vm/graal/graalJavaAccess.hpp Thu Apr 25 16:12:06 2013 +0200 +++ b/src/share/vm/graal/graalJavaAccess.hpp Thu Apr 25 16:12:31 2013 +0200 @@ -197,7 +197,7 @@ end_class \ start_class(Value) \ oop_field(Value, kind, "Lcom/oracle/graal/api/meta/Kind;") \ - static_oop_field(Value, ILLEGAL, "Lcom/oracle/graal/api/meta/Value;"); \ + static_oop_field(Value, ILLEGAL, "Lcom/oracle/graal/api/meta/AllocatableValue;"); \ end_class \ start_class(RegisterValue) \ oop_field(RegisterValue, reg, "Lcom/oracle/graal/api/code/Register;") \