# HG changeset patch # User Roland Schatz # Date 1415714590 -3600 # Node ID 2dc0d4dcb7095494ed0ca0d57d34cea45806a378 # Parent 09550eb6ddfbf42814c6587adcf06b77a1e47c93 Separate stamp for metaspace pointers. diff -r 09550eb6ddfb -r 2dc0d4dcb709 graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/PointerType.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/PointerType.java Tue Nov 11 15:03:10 2014 +0100 @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2014, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.api.meta; + +public enum PointerType { + Object, + Type, + Method +} diff -r 09550eb6ddfb -r 2dc0d4dcb709 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 Wed Nov 12 15:33:20 2014 +0100 +++ b/graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64LIRGenerator.java Tue Nov 11 15:03:10 2014 +0100 @@ -37,6 +37,7 @@ import com.oracle.graal.asm.amd64.AMD64Assembler.ConditionFlag; import com.oracle.graal.compiler.common.*; import com.oracle.graal.compiler.common.calc.*; +import com.oracle.graal.compiler.common.spi.*; import com.oracle.graal.lir.*; import com.oracle.graal.lir.StandardOp.JumpOp; import com.oracle.graal.lir.amd64.*; @@ -87,8 +88,8 @@ } } - public AMD64LIRGenerator(Providers providers, CallingConvention cc, LIRGenerationResult lirGenRes) { - super(providers, cc, lirGenRes); + public AMD64LIRGenerator(LIRKindTool lirKindTool, Providers providers, CallingConvention cc, LIRGenerationResult lirGenRes) { + super(lirKindTool, providers, cc, lirGenRes); lirGenRes.getLIR().setSpillMoveFactory(new AMD64SpillMoveFactory()); } diff -r 09550eb6ddfb -r 2dc0d4dcb709 graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/spi/LIRKindTool.java --- a/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/spi/LIRKindTool.java Wed Nov 12 15:33:20 2014 +0100 +++ b/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/spi/LIRKindTool.java Tue Nov 11 15:03:10 2014 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,5 +33,5 @@ LIRKind getFloatingKind(int bits); - LIRKind getObjectKind(); + LIRKind getPointerKind(PointerType type); } diff -r 09550eb6ddfb -r 2dc0d4dcb709 graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/AbstractObjectStamp.java --- a/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/AbstractObjectStamp.java Wed Nov 12 15:33:20 2014 +0100 +++ b/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/AbstractObjectStamp.java Tue Nov 11 15:03:10 2014 +0100 @@ -26,7 +26,10 @@ import com.oracle.graal.api.meta.*; -public abstract class AbstractObjectStamp extends Stamp { +/** + * Type describing all pointers to Java objects. + */ +public abstract class AbstractObjectStamp extends AbstractPointerStamp { private final ResolvedJavaType type; private final boolean exactType; @@ -34,6 +37,7 @@ private final boolean alwaysNull; protected AbstractObjectStamp(ResolvedJavaType type, boolean exactType, boolean nonNull, boolean alwaysNull) { + super(PointerType.Object); this.type = type; this.exactType = exactType; this.nonNull = nonNull; diff -r 09550eb6ddfb -r 2dc0d4dcb709 graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/AbstractPointerStamp.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/AbstractPointerStamp.java Tue Nov 11 15:03:10 2014 +0100 @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2014, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.compiler.common.type; + +import com.oracle.graal.api.meta.*; +import com.oracle.graal.compiler.common.*; +import com.oracle.graal.compiler.common.spi.*; + +/** + * Abstract base class of all pointer types. + */ +public abstract class AbstractPointerStamp extends Stamp { + + private final PointerType type; + + protected AbstractPointerStamp(PointerType type) { + this.type = type; + } + + public PointerType getType() { + return type; + } + + @Override + public boolean isCompatible(Stamp otherStamp) { + if (otherStamp instanceof AbstractPointerStamp) { + AbstractPointerStamp other = (AbstractPointerStamp) otherStamp; + return this.type == other.type; + } + return false; + } + + @Override + public LIRKind getLIRKind(LIRKindTool tool) { + return tool.getPointerKind(getType()); + } + + @Override + public Kind getStackKind() { + return Kind.Illegal; + } + + @Override + public ResolvedJavaType javaType(MetaAccessProvider metaAccess) { + throw GraalInternalError.shouldNotReachHere(type + " pointer has no Java type"); + } + + @Override + public String toString() { + return type + "*"; + } +} diff -r 09550eb6ddfb -r 2dc0d4dcb709 graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/ObjectStamp.java --- a/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/ObjectStamp.java Wed Nov 12 15:33:20 2014 +0100 +++ b/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/ObjectStamp.java Tue Nov 11 15:03:10 2014 +0100 @@ -23,7 +23,6 @@ package com.oracle.graal.compiler.common.type; import com.oracle.graal.api.meta.*; -import com.oracle.graal.compiler.common.spi.*; public class ObjectStamp extends AbstractObjectStamp { @@ -42,11 +41,6 @@ } @Override - public LIRKind getLIRKind(LIRKindTool tool) { - return tool.getObjectKind(); - } - - @Override public String toString() { StringBuilder str = new StringBuilder(); str.append('a'); diff -r 09550eb6ddfb -r 2dc0d4dcb709 graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/PointerStamp.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/PointerStamp.java Tue Nov 11 15:03:10 2014 +0100 @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2014, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.compiler.common.type; + +import com.oracle.graal.api.meta.*; + +/** + * Type of all pointers that point to things other than Java objects. + */ +public class PointerStamp extends AbstractPointerStamp { + + PointerStamp(PointerType type) { + super(type); + assert type != PointerType.Object : "object pointers should use ObjectStamp"; + } + + @Override + public Stamp meet(Stamp other) { + if (!isCompatible(other)) { + return StampFactory.illegal(); + } + return this; + } + + @Override + public Stamp join(Stamp other) { + if (!isCompatible(other)) { + return StampFactory.illegal(); + } + return this; + } + + @Override + public Stamp unrestricted() { + return this; + } + + @Override + public Stamp illegal() { + // there is no illegal pointer stamp + return this; + } + + @Override + public Stamp constant(Constant c, MetaAccessProvider meta) { + return this; + } + + @Override + public boolean isLegal() { + return true; + } +} diff -r 09550eb6ddfb -r 2dc0d4dcb709 graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/StampFactory.java --- a/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/StampFactory.java Wed Nov 12 15:33:20 2014 +0100 +++ b/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/StampFactory.java Tue Nov 11 15:03:10 2014 +0100 @@ -31,6 +31,7 @@ // JaCoCo Exclude private static final Stamp[] stampCache = new Stamp[Kind.values().length]; + private static final Stamp[] pointerStampCache = new Stamp[PointerType.values().length]; private static final Stamp[] illegalStampCache = new Stamp[Kind.values().length]; private static final Stamp objectStamp = new ObjectStamp(null, false, false, false); private static final Stamp objectNonNullStamp = new ObjectStamp(null, false, true, false); @@ -78,6 +79,10 @@ illegalStampCache[k.ordinal()] = IllegalStamp.getInstance(); } } + + pointerStampCache[PointerType.Object.ordinal()] = objectStamp; + pointerStampCache[PointerType.Type.ordinal()] = new PointerStamp(PointerType.Type); + pointerStampCache[PointerType.Method.ordinal()] = new PointerStamp(PointerType.Method); } /** @@ -89,6 +94,14 @@ } /** + * Return a stamp for a pointer. + */ + public static Stamp forPointer(PointerType type) { + assert pointerStampCache[type.ordinal()] != null; + return pointerStampCache[type.ordinal()]; + } + + /** * Return the stamp for the {@code void} type. This will return a singleton instance than can be * compared using {@code ==}. */ diff -r 09550eb6ddfb -r 2dc0d4dcb709 graal/com.oracle.graal.compiler.hsail/src/com/oracle/graal/compiler/hsail/HSAILLIRGenerator.java --- a/graal/com.oracle.graal.compiler.hsail/src/com/oracle/graal/compiler/hsail/HSAILLIRGenerator.java Wed Nov 12 15:33:20 2014 +0100 +++ b/graal/com.oracle.graal.compiler.hsail/src/com/oracle/graal/compiler/hsail/HSAILLIRGenerator.java Tue Nov 11 15:03:10 2014 +0100 @@ -33,14 +33,24 @@ import com.oracle.graal.asm.*; import com.oracle.graal.compiler.common.*; import com.oracle.graal.compiler.common.calc.*; +import com.oracle.graal.compiler.common.spi.*; import com.oracle.graal.lir.*; import com.oracle.graal.lir.StandardOp.JumpOp; import com.oracle.graal.lir.gen.*; import com.oracle.graal.lir.hsail.*; +import com.oracle.graal.lir.hsail.HSAILArithmetic.ConvertOp; import com.oracle.graal.lir.hsail.HSAILArithmetic.Op1Reg; import com.oracle.graal.lir.hsail.HSAILArithmetic.Op2Reg; -import com.oracle.graal.lir.hsail.HSAILControlFlow.*; -import com.oracle.graal.lir.hsail.HSAILMove.*; +import com.oracle.graal.lir.hsail.HSAILArithmetic.ShiftOp; +import com.oracle.graal.lir.hsail.HSAILControlFlow.CompareBranchOp; +import com.oracle.graal.lir.hsail.HSAILControlFlow.CondMoveOp; +import com.oracle.graal.lir.hsail.HSAILControlFlow.FloatCondMoveOp; +import com.oracle.graal.lir.hsail.HSAILControlFlow.ReturnOp; +import com.oracle.graal.lir.hsail.HSAILControlFlow.StrategySwitchOp; +import com.oracle.graal.lir.hsail.HSAILMove.LeaOp; +import com.oracle.graal.lir.hsail.HSAILMove.MembarOp; +import com.oracle.graal.lir.hsail.HSAILMove.MoveFromRegOp; +import com.oracle.graal.lir.hsail.HSAILMove.MoveToRegOp; import com.oracle.graal.phases.util.*; /** @@ -56,8 +66,8 @@ } } - public HSAILLIRGenerator(Providers providers, CallingConvention cc, LIRGenerationResult lirGenRes) { - super(providers, cc, lirGenRes); + public HSAILLIRGenerator(LIRKindTool lirKindTool, Providers providers, CallingConvention cc, LIRGenerationResult lirGenRes) { + super(lirKindTool, providers, cc, lirGenRes); lirGenRes.getLIR().setSpillMoveFactory(new HSAILSpillMoveFactory()); } diff -r 09550eb6ddfb -r 2dc0d4dcb709 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 Wed Nov 12 15:33:20 2014 +0100 +++ b/graal/com.oracle.graal.compiler.ptx/src/com/oracle/graal/compiler/ptx/PTXLIRGenerator.java Tue Nov 11 15:03:10 2014 +0100 @@ -33,6 +33,7 @@ import com.oracle.graal.asm.*; import com.oracle.graal.compiler.common.*; import com.oracle.graal.compiler.common.calc.*; +import com.oracle.graal.compiler.common.spi.*; import com.oracle.graal.lir.*; import com.oracle.graal.lir.StandardOp.JumpOp; import com.oracle.graal.lir.gen.*; @@ -80,8 +81,8 @@ } } - public PTXLIRGenerator(Providers providers, CallingConvention cc, LIRGenerationResult lirGenRes) { - super(providers, cc, lirGenRes); + public PTXLIRGenerator(LIRKindTool lirKindTool, Providers providers, CallingConvention cc, LIRGenerationResult lirGenRes) { + super(lirKindTool, providers, cc, lirGenRes); lirGenRes.getLIR().setSpillMoveFactory(new PTXSpillMoveFactory()); int callVariables = cc.getArgumentCount() + (cc.getReturn().equals(Value.ILLEGAL) ? 0 : 1); lirGenRes.getLIR().setFirstVariableNumber(callVariables); diff -r 09550eb6ddfb -r 2dc0d4dcb709 graal/com.oracle.graal.compiler.sparc/src/com/oracle/graal/compiler/sparc/SPARCLIRGenerator.java --- a/graal/com.oracle.graal.compiler.sparc/src/com/oracle/graal/compiler/sparc/SPARCLIRGenerator.java Wed Nov 12 15:33:20 2014 +0100 +++ b/graal/com.oracle.graal.compiler.sparc/src/com/oracle/graal/compiler/sparc/SPARCLIRGenerator.java Tue Nov 11 15:03:10 2014 +0100 @@ -36,6 +36,7 @@ import com.oracle.graal.asm.sparc.SPARCAssembler.ConditionFlag; import com.oracle.graal.compiler.common.*; import com.oracle.graal.compiler.common.calc.*; +import com.oracle.graal.compiler.common.spi.*; import com.oracle.graal.lir.*; import com.oracle.graal.lir.gen.*; import com.oracle.graal.lir.sparc.*; @@ -60,7 +61,7 @@ import com.oracle.graal.lir.sparc.SPARCMove.StackLoadAddressOp; import com.oracle.graal.phases.util.*; import com.oracle.graal.sparc.*; -import com.oracle.graal.sparc.SPARC.*; +import com.oracle.graal.sparc.SPARC.CPUFeature; /** * This class implements the SPARC specific portion of the LIR generator. @@ -77,8 +78,8 @@ } } - public SPARCLIRGenerator(Providers providers, CallingConvention cc, LIRGenerationResult lirGenRes) { - super(providers, cc, lirGenRes); + public SPARCLIRGenerator(LIRKindTool lirKindTool, Providers providers, CallingConvention cc, LIRGenerationResult lirGenRes) { + super(lirKindTool, providers, cc, lirGenRes); lirGenRes.getLIR().setSpillMoveFactory(new SPARCSpillMoveFactory()); } diff -r 09550eb6ddfb -r 2dc0d4dcb709 graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotLIRGenerator.java --- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotLIRGenerator.java Wed Nov 12 15:33:20 2014 +0100 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotLIRGenerator.java Tue Nov 11 15:03:10 2014 +0100 @@ -39,6 +39,7 @@ import com.oracle.graal.hotspot.HotSpotVMConfig.CompressEncoding; import com.oracle.graal.hotspot.amd64.AMD64HotSpotMove.HotSpotStoreConstantOp; import com.oracle.graal.hotspot.meta.*; +import com.oracle.graal.hotspot.nodes.type.*; import com.oracle.graal.hotspot.stubs.*; import com.oracle.graal.lir.*; import com.oracle.graal.lir.StandardOp.NoOp; @@ -62,7 +63,7 @@ private HotSpotLockStack lockStack; protected AMD64HotSpotLIRGenerator(HotSpotProviders providers, HotSpotVMConfig config, CallingConvention cc, LIRGenerationResult lirGenRes) { - super(providers, cc, lirGenRes); + super(new HotSpotLIRKindTool(providers.getCodeCache().getTarget().wordKind), providers, cc, lirGenRes); assert config.basicLockSize == 8; this.config = config; } diff -r 09550eb6ddfb -r 2dc0d4dcb709 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 Wed Nov 12 15:33:20 2014 +0100 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotNodeLIRBuilder.java Tue Nov 11 15:03:10 2014 +0100 @@ -226,9 +226,8 @@ Stamp compressedStamp = compress.getValue().stamp(); if (compressedStamp instanceof NarrowOopStamp) { return true; - } else if (compressedStamp instanceof IntegerStamp) { - IntegerStamp is = (IntegerStamp) compressedStamp; - return is.getBits() == 32 && config.narrowKlassBase == config.narrowOopBase; + } else if (compressedStamp instanceof NarrowPointerStamp) { + return config.narrowKlassBase == config.narrowOopBase; } } return false; diff -r 09550eb6ddfb -r 2dc0d4dcb709 graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotLIRGenerator.java --- a/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotLIRGenerator.java Wed Nov 12 15:33:20 2014 +0100 +++ b/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotLIRGenerator.java Tue Nov 11 15:03:10 2014 +0100 @@ -33,6 +33,7 @@ import com.oracle.graal.hotspot.*; import com.oracle.graal.hotspot.HotSpotVMConfig.CompressEncoding; import com.oracle.graal.hotspot.meta.*; +import com.oracle.graal.hotspot.nodes.type.*; import com.oracle.graal.lir.*; import com.oracle.graal.lir.StandardOp.SaveRegistersOp; import com.oracle.graal.lir.gen.*; @@ -60,7 +61,7 @@ final HotSpotVMConfig config; public HSAILHotSpotLIRGenerator(Providers providers, HotSpotVMConfig config, CallingConvention cc, LIRGenerationResult lirGenRes) { - super(providers, cc, lirGenRes); + super(new HotSpotLIRKindTool(providers.getCodeCache().getTarget().wordKind), providers, cc, lirGenRes); this.config = config; } diff -r 09550eb6ddfb -r 2dc0d4dcb709 graal/com.oracle.graal.hotspot.ptx/src/com/oracle/graal/hotspot/ptx/PTXHotSpotLIRGenerator.java --- a/graal/com.oracle.graal.hotspot.ptx/src/com/oracle/graal/hotspot/ptx/PTXHotSpotLIRGenerator.java Wed Nov 12 15:33:20 2014 +0100 +++ b/graal/com.oracle.graal.hotspot.ptx/src/com/oracle/graal/hotspot/ptx/PTXHotSpotLIRGenerator.java Tue Nov 11 15:03:10 2014 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,6 +30,7 @@ import com.oracle.graal.hotspot.*; import com.oracle.graal.hotspot.HotSpotVMConfig.CompressEncoding; import com.oracle.graal.hotspot.meta.*; +import com.oracle.graal.hotspot.nodes.type.*; import com.oracle.graal.lir.StandardOp.SaveRegistersOp; import com.oracle.graal.lir.gen.*; @@ -39,7 +40,7 @@ public class PTXHotSpotLIRGenerator extends PTXLIRGenerator implements HotSpotLIRGenerator { protected PTXHotSpotLIRGenerator(HotSpotProviders providers, HotSpotVMConfig config, CallingConvention cc, LIRGenerationResult lirGenRes) { - super(providers, cc, lirGenRes); + super(new HotSpotLIRKindTool(providers.getCodeCache().getTarget().wordKind), providers, cc, lirGenRes); assert config.basicLockSize == 8; } diff -r 09550eb6ddfb -r 2dc0d4dcb709 graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotLIRGenerator.java --- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotLIRGenerator.java Wed Nov 12 15:33:20 2014 +0100 +++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotLIRGenerator.java Tue Nov 11 15:03:10 2014 +0100 @@ -37,12 +37,17 @@ import com.oracle.graal.hotspot.*; import com.oracle.graal.hotspot.HotSpotVMConfig.CompressEncoding; import com.oracle.graal.hotspot.meta.*; +import com.oracle.graal.hotspot.nodes.type.*; import com.oracle.graal.hotspot.stubs.*; import com.oracle.graal.lir.*; import com.oracle.graal.lir.StandardOp.SaveRegistersOp; import com.oracle.graal.lir.gen.*; import com.oracle.graal.lir.sparc.*; -import com.oracle.graal.lir.sparc.SPARCMove.*; +import com.oracle.graal.lir.sparc.SPARCMove.CompareAndSwapOp; +import com.oracle.graal.lir.sparc.SPARCMove.LoadOp; +import com.oracle.graal.lir.sparc.SPARCMove.NullCheckOp; +import com.oracle.graal.lir.sparc.SPARCMove.StoreConstantOp; +import com.oracle.graal.lir.sparc.SPARCMove.StoreOp; public class SPARCHotSpotLIRGenerator extends SPARCLIRGenerator implements HotSpotLIRGenerator { @@ -51,7 +56,7 @@ private LIRFrameState currentRuntimeCallInfo; public SPARCHotSpotLIRGenerator(HotSpotProviders providers, HotSpotVMConfig config, CallingConvention cc, LIRGenerationResult lirGenRes) { - super(providers, cc, lirGenRes); + super(new HotSpotLIRKindTool(providers.getCodeCache().getTarget().wordKind), providers, cc, lirGenRes); this.config = config; } diff -r 09550eb6ddfb -r 2dc0d4dcb709 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/type/HotSpotLIRKindTool.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/type/HotSpotLIRKindTool.java Tue Nov 11 15:03:10 2014 +0100 @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2014, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.hotspot.nodes.type; + +import com.oracle.graal.api.meta.*; +import com.oracle.graal.compiler.common.*; +import com.oracle.graal.lir.gen.*; + +public class HotSpotLIRKindTool extends DefaultLIRKindTool { + + private final Kind pointerKind; + + public HotSpotLIRKindTool(Kind pointerKind) { + this.pointerKind = pointerKind; + } + + public LIRKind getPointerKind(PointerType type) { + /* + * In the Hotspot VM, object pointers are tracked heap references. All other pointers + * (method and klass pointers) are untracked pointers to the metaspace. + */ + switch (type) { + case Object: + return LIRKind.reference(Kind.Object); + case Type: + case Method: + return LIRKind.value(pointerKind); + default: + throw GraalInternalError.shouldNotReachHere(); + } + } +} diff -r 09550eb6ddfb -r 2dc0d4dcb709 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/type/NarrowPointerStamp.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/type/NarrowPointerStamp.java Tue Nov 11 15:03:10 2014 +0100 @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2014, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.hotspot.nodes.type; + +import com.oracle.graal.api.meta.*; +import com.oracle.graal.compiler.common.spi.*; +import com.oracle.graal.compiler.common.type.*; +import com.oracle.graal.hotspot.HotSpotVMConfig.*; + +public class NarrowPointerStamp extends AbstractPointerStamp { + + private final CompressEncoding encoding; + + public NarrowPointerStamp(PointerType type, CompressEncoding encoding) { + super(type); + assert type != PointerType.Object : "object pointers should use NarrowOopStamp"; + this.encoding = encoding; + } + + @Override + public boolean isCompatible(Stamp otherStamp) { + if (this == otherStamp) { + return true; + } + if (otherStamp instanceof NarrowPointerStamp) { + NarrowPointerStamp other = (NarrowPointerStamp) otherStamp; + return encoding.equals(other.encoding) && super.isCompatible(other); + } + return false; + } + + @Override + public LIRKind getLIRKind(LIRKindTool tool) { + return LIRKind.value(Kind.Int); + } + + @Override + public Stamp meet(Stamp other) { + if (!isCompatible(other)) { + return StampFactory.illegal(); + } + return this; + } + + @Override + public Stamp join(Stamp other) { + if (!isCompatible(other)) { + return StampFactory.illegal(); + } + return this; + } + + @Override + public Stamp unrestricted() { + return this; + } + + @Override + public Stamp illegal() { + // there is no illegal pointer stamp + return this; + } + + @Override + public Stamp constant(Constant c, MetaAccessProvider meta) { + return this; + } + + @Override + public boolean isLegal() { + return true; + } +} diff -r 09550eb6ddfb -r 2dc0d4dcb709 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/gen/DefaultLIRKindTool.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/gen/DefaultLIRKindTool.java Tue Nov 11 15:03:10 2014 +0100 @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2014, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.lir.gen; + +import com.oracle.graal.api.meta.*; +import com.oracle.graal.compiler.common.*; +import com.oracle.graal.compiler.common.spi.*; + +/** + * Default implementation of {@link LIRKindTool}. Returns the normal Java kind for primitive types. + * Subclasses still have to implement {@link #getPointerKind}. + */ +public abstract class DefaultLIRKindTool implements LIRKindTool { + + public LIRKind getIntegerKind(int bits) { + if (bits <= 8) { + return LIRKind.value(Kind.Byte); + } else if (bits <= 16) { + return LIRKind.value(Kind.Short); + } else if (bits <= 32) { + return LIRKind.value(Kind.Int); + } else { + assert bits <= 64; + return LIRKind.value(Kind.Long); + } + } + + public LIRKind getFloatingKind(int bits) { + switch (bits) { + case 32: + return LIRKind.value(Kind.Float); + case 64: + return LIRKind.value(Kind.Double); + default: + throw GraalInternalError.shouldNotReachHere(); + } + } +} diff -r 09550eb6ddfb -r 2dc0d4dcb709 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/gen/LIRGenerator.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/gen/LIRGenerator.java Wed Nov 12 15:33:20 2014 +0100 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/gen/LIRGenerator.java Tue Nov 11 15:03:10 2014 +0100 @@ -44,7 +44,7 @@ /** * This class traverses the HIR instructions and generates LIR instructions from them. */ -public abstract class LIRGenerator implements LIRGeneratorTool, LIRKindTool { +public abstract class LIRGenerator implements LIRGeneratorTool { public static class Options { // @formatter:off @@ -55,6 +55,8 @@ // @formatter:on } + private final LIRKindTool lirKindTool; + private final CodeGenProviders providers; private final CallingConvention cc; @@ -62,7 +64,8 @@ private LIRGenerationResult res; - public LIRGenerator(CodeGenProviders providers, CallingConvention cc, LIRGenerationResult res) { + public LIRGenerator(LIRKindTool lirKindTool, CodeGenProviders providers, CallingConvention cc, LIRGenerationResult res) { + this.lirKindTool = lirKindTool; this.res = res; this.providers = providers; this.cc = cc; @@ -361,39 +364,8 @@ } } - /** - * Default implementation: Return the Java stack kind for each stamp. - */ public LIRKind getLIRKind(Stamp stamp) { - return stamp.getLIRKind(this); - } - - public LIRKind getIntegerKind(int bits) { - if (bits <= 8) { - return LIRKind.value(Kind.Byte); - } else if (bits <= 16) { - return LIRKind.value(Kind.Short); - } else if (bits <= 32) { - return LIRKind.value(Kind.Int); - } else { - assert bits <= 64; - return LIRKind.value(Kind.Long); - } - } - - public LIRKind getFloatingKind(int bits) { - switch (bits) { - case 32: - return LIRKind.value(Kind.Float); - case 64: - return LIRKind.value(Kind.Double); - default: - throw GraalInternalError.shouldNotReachHere(); - } - } - - public LIRKind getObjectKind() { - return LIRKind.reference(Kind.Object); + return stamp.getLIRKind(lirKindTool); } protected LIRKind getAddressKind(Value base, long displacement, Value index) {