# HG changeset patch # User Roland Schatz # Date 1441714418 -7200 # Node ID df053711614bbad30c2b885f7a49ee1d7f0c180d # Parent 952d4d634a4251e2c873bda403446ae051d50ad9 Remove Value.getKind(). diff -r 952d4d634a42 -r df053711614b jvmci/jdk.internal.jvmci.amd64/src/jdk/internal/jvmci/amd64/AMD64.java --- a/jvmci/jdk.internal.jvmci.amd64/src/jdk/internal/jvmci/amd64/AMD64.java Tue Sep 08 11:55:51 2015 +0200 +++ b/jvmci/jdk.internal.jvmci.amd64/src/jdk/internal/jvmci/amd64/AMD64.java Tue Sep 08 14:13:38 2015 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2015, 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 @@ -149,7 +149,7 @@ private final EnumSet flags; public AMD64(EnumSet features, EnumSet flags) { - super("AMD64", 8, ByteOrder.LITTLE_ENDIAN, true, allRegisters, LOAD_STORE | STORE_STORE, 1, cpuRegisters.length + (xmmRegisters.length << XMM_REFERENCE_MAP_SHIFT), 8); + super("AMD64", Kind.Long, ByteOrder.LITTLE_ENDIAN, true, allRegisters, LOAD_STORE | STORE_STORE, 1, cpuRegisters.length + (xmmRegisters.length << XMM_REFERENCE_MAP_SHIFT), 8); this.features = features; this.flags = flags; assert features.contains(CPUFeature.SSE2) : "minimum config for x64"; @@ -164,6 +164,11 @@ } @Override + public PlatformKind getPlatformKind(Kind javaKind) { + return javaKind; + } + + @Override public boolean canStoreValue(RegisterCategory category, PlatformKind platformKind) { if (!(platformKind instanceof Kind)) { return false; diff -r 952d4d634a42 -r df053711614b jvmci/jdk.internal.jvmci.code/src/jdk/internal/jvmci/code/Architecture.java --- a/jvmci/jdk.internal.jvmci.code/src/jdk/internal/jvmci/code/Architecture.java Tue Sep 08 11:55:51 2015 +0200 +++ b/jvmci/jdk.internal.jvmci.code/src/jdk/internal/jvmci/code/Architecture.java Tue Sep 08 14:13:38 2015 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2015, 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 @@ -25,7 +25,7 @@ import java.nio.*; import java.util.*; -import jdk.internal.jvmci.code.Register.*; +import jdk.internal.jvmci.code.Register.RegisterCategory; import jdk.internal.jvmci.meta.*; /** @@ -42,10 +42,9 @@ private final int registerReferenceMapSize; /** - * Represents the natural size of words (typically registers and pointers) of this architecture, - * in bytes. + * The architecture specific type of a native word. */ - private final int wordSize; + private final PlatformKind wordKind; /** * The name of this architecture (e.g. "AMD64", "SPARCv9"). @@ -85,11 +84,11 @@ */ private final int returnAddressSize; - protected Architecture(String name, int wordSize, ByteOrder byteOrder, boolean unalignedMemoryAccess, Register[] registers, int implicitMemoryBarriers, int nativeCallDisplacementOffset, + protected Architecture(String name, PlatformKind wordKind, ByteOrder byteOrder, boolean unalignedMemoryAccess, Register[] registers, int implicitMemoryBarriers, int nativeCallDisplacementOffset, int registerReferenceMapSize, int returnAddressSize) { this.name = name; this.registers = registers; - this.wordSize = wordSize; + this.wordKind = wordKind; this.byteOrder = byteOrder; this.unalignedMemoryAccess = unalignedMemoryAccess; this.implicitMemoryBarriers = implicitMemoryBarriers; @@ -117,7 +116,11 @@ * bytes. */ public int getWordSize() { - return wordSize; + return getSizeInBytes(wordKind); + } + + public PlatformKind getWordKind() { + return wordKind; } /** @@ -198,7 +201,7 @@ case Double: return 8; case Object: - return wordSize; + return getWordSize(); default: return 0; } @@ -220,6 +223,11 @@ */ public abstract PlatformKind getLargestStorableKind(RegisterCategory category); + /** + * Return the {@link PlatformKind} that is used to store Java values of a given {@link Kind}. + */ + public abstract PlatformKind getPlatformKind(Kind javaKind); + @Override public final boolean equals(Object obj) { if (obj == this) { @@ -235,7 +243,7 @@ assert Arrays.equals(this.registers, that.registers); assert this.returnAddressSize == that.returnAddressSize; assert this.unalignedMemoryAccess == that.unalignedMemoryAccess; - assert this.wordSize == that.wordSize; + assert this.wordKind == that.wordKind; return true; } } diff -r 952d4d634a42 -r df053711614b jvmci/jdk.internal.jvmci.code/src/jdk/internal/jvmci/code/TargetDescription.java --- a/jvmci/jdk.internal.jvmci.code/src/jdk/internal/jvmci/code/TargetDescription.java Tue Sep 08 11:55:51 2015 +0200 +++ b/jvmci/jdk.internal.jvmci.code/src/jdk/internal/jvmci/code/TargetDescription.java Tue Sep 08 14:13:38 2015 +0200 @@ -120,20 +120,11 @@ } public LIRKind getLIRKind(Kind javaKind) { - switch (javaKind) { - case Boolean: - case Byte: - case Short: - case Char: - case Int: - case Long: - case Float: - case Double: - return LIRKind.value(javaKind); - case Object: - return LIRKind.reference(javaKind); - default: - return LIRKind.Illegal; + PlatformKind platformKind = arch.getPlatformKind(javaKind); + if (javaKind.isObject()) { + return LIRKind.reference(platformKind); + } else { + return LIRKind.value(platformKind); } } } diff -r 952d4d634a42 -r df053711614b jvmci/jdk.internal.jvmci.code/src/jdk/internal/jvmci/code/ValueUtil.java --- a/jvmci/jdk.internal.jvmci.code/src/jdk/internal/jvmci/code/ValueUtil.java Tue Sep 08 11:55:51 2015 +0200 +++ b/jvmci/jdk.internal.jvmci.code/src/jdk/internal/jvmci/code/ValueUtil.java Tue Sep 08 14:13:38 2015 +0200 @@ -114,37 +114,14 @@ return (RegisterValue) value; } - public static Register asIntReg(Value value) { - if (value.getKind().getStackKind() != Kind.Int) { - throw new InternalError("needed Int got: " + value.getKind()); - } else { - return asRegister(value); - } - } - - public static Register asLongReg(Value value) { - if (value.getKind() != Kind.Long) { - throw new InternalError("needed Long got: " + value.getKind()); + public static Register asRegister(Value value, PlatformKind kind) { + if (value.getPlatformKind() != kind) { + throw new InternalError("needed: " + kind + " got: " + value.getPlatformKind()); } else { return asRegister(value); } } - public static Register asObjectReg(Value value) { - assert value.getKind() == Kind.Object : value.getKind(); - return asRegister(value); - } - - public static Register asFloatReg(Value value) { - assert value.getKind() == Kind.Float : value.getKind(); - return asRegister(value); - } - - public static Register asDoubleReg(Value value) { - assert value.getKind() == Kind.Double : value.getKind(); - return asRegister(value); - } - public static boolean sameRegister(Value v1, Value v2) { return isRegister(v1) && isRegister(v2) && asRegister(v1).equals(asRegister(v2)); } diff -r 952d4d634a42 -r df053711614b jvmci/jdk.internal.jvmci.hotspot.amd64/src/jdk/internal/jvmci/hotspot/amd64/AMD64HotSpotRegisterConfig.java --- a/jvmci/jdk.internal.jvmci.hotspot.amd64/src/jdk/internal/jvmci/hotspot/amd64/AMD64HotSpotRegisterConfig.java Tue Sep 08 11:55:51 2015 +0200 +++ b/jvmci/jdk.internal.jvmci.hotspot.amd64/src/jdk/internal/jvmci/hotspot/amd64/AMD64HotSpotRegisterConfig.java Tue Sep 08 14:13:38 2015 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2015, 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 @@ -167,11 +167,42 @@ } public Register[] getCallingConventionRegisters(Type type, Kind kind) { - if (architecture.canStoreValue(XMM, kind)) { - return xmmParameterRegisters; + switch (kind) { + case Boolean: + case Byte: + case Short: + case Char: + case Int: + case Long: + case Object: + return type == Type.NativeCall ? nativeGeneralParameterRegisters : javaGeneralParameterRegisters; + case Float: + case Double: + return xmmParameterRegisters; + default: + throw JVMCIError.shouldNotReachHere(); } - assert architecture.canStoreValue(CPU, kind); - return type == Type.NativeCall ? nativeGeneralParameterRegisters : javaGeneralParameterRegisters; + } + + private static LIRKind argumentKind(Kind kind) { + switch (kind) { + case Byte: + case Boolean: + case Short: + case Char: + case Int: + return LIRKind.value(Kind.Int); + case Long: + return LIRKind.value(Kind.Long); + case Float: + return LIRKind.value(Kind.Float); + case Double: + return LIRKind.value(Kind.Double); + case Object: + return LIRKind.reference(Kind.Object); + default: + throw JVMCIError.shouldNotReachHere("invalid argument kind " + kind); + } } private CallingConvention callingConvention(Register[] generalParameterRegisters, JavaType returnType, JavaType[] parameterTypes, Type type, TargetDescription target, boolean stackOnly) { @@ -194,14 +225,14 @@ case Object: if (!stackOnly && currentGeneral < generalParameterRegisters.length) { Register register = generalParameterRegisters[currentGeneral++]; - locations[i] = register.asValue(target.getLIRKind(kind)); + locations[i] = register.asValue(argumentKind(kind)); } break; case Float: case Double: if (!stackOnly && currentXMM < xmmParameterRegisters.length) { Register register = xmmParameterRegisters[currentXMM++]; - locations[i] = register.asValue(target.getLIRKind(kind)); + locations[i] = register.asValue(argumentKind(kind)); } break; default: @@ -209,13 +240,14 @@ } if (locations[i] == null) { - locations[i] = StackSlot.get(target.getLIRKind(kind.getStackKind()), currentStackOffset, !type.out); - currentStackOffset += Math.max(target.getSizeInBytes(kind), target.wordSize); + LIRKind lirKind = target.getLIRKind(kind.getStackKind()); + locations[i] = StackSlot.get(lirKind, currentStackOffset, !type.out); + currentStackOffset += Math.max(target.getSizeInBytes(lirKind.getPlatformKind()), target.wordSize); } } Kind returnKind = returnType == null ? Kind.Void : returnType.getKind(); - AllocatableValue returnLocation = returnKind == Kind.Void ? Value.ILLEGAL : getReturnRegister(returnKind).asValue(target.getLIRKind(returnKind.getStackKind())); + AllocatableValue returnLocation = returnKind == Kind.Void ? Value.ILLEGAL : getReturnRegister(returnKind).asValue(argumentKind(returnKind)); return new CallingConvention(currentStackOffset, returnLocation, locations); } diff -r 952d4d634a42 -r df053711614b jvmci/jdk.internal.jvmci.meta/src/jdk/internal/jvmci/meta/Kind.java --- a/jvmci/jdk.internal.jvmci.meta/src/jdk/internal/jvmci/meta/Kind.java Tue Sep 08 11:55:51 2015 +0200 +++ b/jvmci/jdk.internal.jvmci.meta/src/jdk/internal/jvmci/meta/Kind.java Tue Sep 08 14:13:38 2015 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2015, 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 @@ -483,4 +483,14 @@ throw new IllegalArgumentException("illegal call to getDefaultValue on " + this); } } + + @Override + public int getSizeInBytes() { + return getByteCount(); + } + + @Override + public int getVectorLength() { + return 1; + } } diff -r 952d4d634a42 -r df053711614b jvmci/jdk.internal.jvmci.meta/src/jdk/internal/jvmci/meta/PlatformKind.java --- a/jvmci/jdk.internal.jvmci.meta/src/jdk/internal/jvmci/meta/PlatformKind.java Tue Sep 08 11:55:51 2015 +0200 +++ b/jvmci/jdk.internal.jvmci.meta/src/jdk/internal/jvmci/meta/PlatformKind.java Tue Sep 08 14:13:38 2015 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2015, 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 @@ -67,7 +67,19 @@ */ Key getKey(); - default int getVectorLength() { - return 1; - } + /** + * Get the size in bytes of this {@link PlatformKind}. + */ + int getSizeInBytes(); + + /** + * Returns how many primitive values fit in this {@link PlatformKind}. For scalar types this is + * one, for SIMD types it may be higher. + */ + int getVectorLength(); + + /** + * Gets a single type char that identifies this type for use in debug output. + */ + char getTypeChar(); } diff -r 952d4d634a42 -r df053711614b jvmci/jdk.internal.jvmci.meta/src/jdk/internal/jvmci/meta/Value.java --- a/jvmci/jdk.internal.jvmci.meta/src/jdk/internal/jvmci/meta/Value.java Tue Sep 08 11:55:51 2015 +0200 +++ b/jvmci/jdk.internal.jvmci.meta/src/jdk/internal/jvmci/meta/Value.java Tue Sep 08 14:13:38 2015 +0200 @@ -49,7 +49,6 @@ } } - private final Kind kind; private final LIRKind lirKind; /** @@ -59,11 +58,6 @@ */ protected Value(LIRKind lirKind) { this.lirKind = lirKind; - if (getPlatformKind() instanceof Kind) { - this.kind = (Kind) getPlatformKind(); - } else { - this.kind = Kind.Illegal; - } } /** @@ -71,14 +65,7 @@ * {@link #toString()} implementation of subclasses. */ protected final String getKindSuffix() { - return "|" + getKind().getTypeChar(); - } - - /** - * Returns the kind of this value. - */ - public final Kind getKind() { - return kind; + return "|" + getPlatformKind().getTypeChar(); } public final LIRKind getLIRKind() { @@ -101,7 +88,7 @@ public boolean equals(Object obj) { if (obj instanceof Value) { Value that = (Value) obj; - return kind.equals(that.kind) && lirKind.equals(that.lirKind); + return lirKind.equals(that.lirKind); } return false; } diff -r 952d4d634a42 -r df053711614b jvmci/jdk.internal.jvmci.sparc/src/jdk/internal/jvmci/sparc/SPARC.java --- a/jvmci/jdk.internal.jvmci.sparc/src/jdk/internal/jvmci/sparc/SPARC.java Tue Sep 08 11:55:51 2015 +0200 +++ b/jvmci/jdk.internal.jvmci.sparc/src/jdk/internal/jvmci/sparc/SPARC.java Tue Sep 08 14:13:38 2015 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2015, 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 @@ -252,7 +252,7 @@ public final Set features; public SPARC(Set features) { - super("SPARC", 8, BIG_ENDIAN, false, allRegisters, LOAD_LOAD | LOAD_STORE | STORE_STORE, 1, r31.encoding + FLOAT_REGISTER_COUNT + 1, 8); + super("SPARC", Kind.Long, BIG_ENDIAN, false, allRegisters, LOAD_LOAD | LOAD_STORE | STORE_STORE, 1, r31.encoding + FLOAT_REGISTER_COUNT + 1, 8); this.features = features; } @@ -295,6 +295,11 @@ } } + @Override + public PlatformKind getPlatformKind(Kind javaKind) { + return javaKind; + } + public static int spillSlotSize(TargetDescription td, PlatformKind kind) { return Math.max(td.getSizeInBytes(kind), MEMORY_ACCESS_ALIGN); } diff -r 952d4d634a42 -r df053711614b src/share/vm/jvmci/jvmciCodeInstaller.cpp --- a/src/share/vm/jvmci/jvmciCodeInstaller.cpp Tue Sep 08 11:55:51 2015 +0200 +++ b/src/share/vm/jvmci/jvmciCodeInstaller.cpp Tue Sep 08 14:13:38 2015 +0200 @@ -166,7 +166,6 @@ if (constant->is_a(HotSpotMetaspaceConstantImpl::klass())) { oop obj = HotSpotMetaspaceConstantImpl::metaspaceObject(constant); jlong prim = HotSpotMetaspaceConstantImpl::primitive(constant); - assert(Kind::typeChar(Value::kind(constant)) == 'j', "must have word kind"); assert(obj != NULL, "must have an object"); assert(prim != 0, "must have a primitive value"); diff -r 952d4d634a42 -r df053711614b src/share/vm/jvmci/jvmciJavaAccess.hpp --- a/src/share/vm/jvmci/jvmciJavaAccess.hpp Tue Sep 08 11:55:51 2015 +0200 +++ b/src/share/vm/jvmci/jvmciJavaAccess.hpp Tue Sep 08 14:13:38 2015 +0200 @@ -228,7 +228,6 @@ int_field(LIRKind, referenceMask) \ end_class \ start_class(Value) \ - oop_field(Value, kind, "Ljdk/internal/jvmci/meta/Kind;") \ oop_field(Value, lirKind, "Ljdk/internal/jvmci/meta/LIRKind;") \ static_oop_field(Value, ILLEGAL, "Ljdk/internal/jvmci/meta/AllocatableValue;"); \ end_class \