# HG changeset patch # User Roland Schatz # Date 1367316253 -7200 # Node ID 3426008293e72f838d50e59b966a1fc98c867f7b # Parent 149fe42411df52d0ccc4ee618d2585f600f2799c Move getSizeInBytes method to Architecture class. diff -r 149fe42411df -r 3426008293e7 graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/Architecture.java --- a/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/Architecture.java Tue Apr 30 12:00:13 2013 +0200 +++ b/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/Architecture.java Tue Apr 30 12:04:13 2013 +0200 @@ -164,4 +164,36 @@ public int getMaxVectorLength(@SuppressWarnings("unused") Kind kind) { return 1; } + + /** + * Gets the size in bytes of the specified kind for this target. + * + * @param kind the kind for which to get the size + * + * @return the size in bytes of {@code kind} + */ + public int getSizeInBytes(PlatformKind kind) { + switch ((Kind) kind) { + case Boolean: + return 1; + case Byte: + return 1; + case Char: + return 2; + case Short: + return 2; + case Int: + return 4; + case Long: + return 8; + case Float: + return 4; + case Double: + return 8; + case Object: + return wordSize; + default: + return 0; + } + } } diff -r 149fe42411df -r 3426008293e7 graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/TargetDescription.java --- a/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/TargetDescription.java Tue Apr 30 12:00:13 2013 +0200 +++ b/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/TargetDescription.java Tue Apr 30 12:04:13 2013 +0200 @@ -83,39 +83,6 @@ } /** - * Gets the size in bytes of the specified kind for this target. - * - * @param kind the kind for which to get the size - * @return the size in bytes of {@code kind} - */ - public int sizeInBytes(PlatformKind kind) { - // Checkstyle: stop - switch ((Kind) kind) { - case Boolean: - return 1; - case Byte: - return 1; - case Char: - return 2; - case Short: - return 2; - case Int: - return 4; - case Long: - return 8; - case Float: - return 4; - case Double: - return 8; - case Object: - return wordSize; - default: - return 0; - } - // Checkstyle: resume - } - - /** * Aligns the given frame size (without return instruction pointer) to the stack alignment size * and return the aligned size (without return instruction pointer). * diff -r 149fe42411df -r 3426008293e7 graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotRegisterConfig.java --- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotRegisterConfig.java Tue Apr 30 12:00:13 2013 +0200 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotRegisterConfig.java Tue Apr 30 12:04:13 2013 +0200 @@ -178,7 +178,7 @@ if (locations[i] == null) { locations[i] = StackSlot.get(kind.getStackKind(), currentStackOffset, !type.out); - currentStackOffset += Math.max(target.sizeInBytes(kind), target.wordSize); + currentStackOffset += Math.max(target.arch.getSizeInBytes(kind), target.wordSize); } } diff -r 149fe42411df -r 3426008293e7 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java Tue Apr 30 12:00:13 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java Tue Apr 30 12:04:13 2013 +0200 @@ -198,7 +198,7 @@ result[i] = ccRegs[i].asValue(kind); } else { result[i] = StackSlot.get(kind.getStackKind(), currentStackOffset, false); - currentStackOffset += Math.max(target.sizeInBytes(kind), target.wordSize); + currentStackOffset += Math.max(target.arch.getSizeInBytes(kind), target.wordSize); } } return result; @@ -854,7 +854,7 @@ } private IndexedLocationNode createArrayLocation(Graph graph, Kind elementKind, ValueNode index) { - int scale = this.graalRuntime.getTarget().sizeInBytes(elementKind); + int scale = this.graalRuntime.getTarget().arch.getSizeInBytes(elementKind); return IndexedLocationNode.create(LocationNode.getArrayLocation(elementKind), elementKind, getArrayBaseOffset(elementKind), index, graph, scale); } diff -r 149fe42411df -r 3426008293e7 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/NewObjectSnippets.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/NewObjectSnippets.java Tue Apr 30 12:00:13 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/NewObjectSnippets.java Tue Apr 30 12:04:13 2013 +0200 @@ -261,7 +261,7 @@ final int alignment = target.wordSize; final int headerSize = HotSpotRuntime.getArrayBaseOffset(elementKind); final Integer length = lengthNode.isConstant() ? Integer.valueOf(lengthNode.asConstant().asInt()) : null; - int log2ElementSize = CodeUtil.log2(target.sizeInBytes(elementKind)); + int log2ElementSize = CodeUtil.log2(target.arch.getSizeInBytes(elementKind)); if (!useTLAB) { ConstantNode zero = ConstantNode.defaultForKind(target.wordKind, graph); /* diff -r 149fe42411df -r 3426008293e7 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/FrameMap.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/FrameMap.java Tue Apr 30 12:00:13 2013 +0200 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/FrameMap.java Tue Apr 30 12:04:13 2013 +0200 @@ -197,7 +197,7 @@ // Without this, frameNeedsAllocating() would never return true. int total = 0; for (StackSlot s : freedSlots) { - total += target.sizeInBytes(s.getKind()); + total += target.arch.getSizeInBytes(s.getKind()); } int initialSpillSize = returnAddressSize() + calleeSaveAreaSize(); if (total == spillSize - initialSpillSize) { @@ -291,7 +291,7 @@ } } } - int size = target.sizeInBytes(kind); + int size = target.arch.getSizeInBytes(kind); spillSize = NumUtil.roundUp(spillSize + size, size); return getSlot(kind, 0); } diff -r 149fe42411df -r 3426008293e7 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/UnsafeCastNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/UnsafeCastNode.java Tue Apr 30 12:00:13 2013 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/UnsafeCastNode.java Tue Apr 30 12:04:13 2013 +0200 @@ -90,7 +90,7 @@ @Override public void generate(LIRGeneratorTool generator) { if (kind() != object().kind()) { - assert generator.target().sizeInBytes(kind()) == generator.target().sizeInBytes(object().kind()) : "unsafe cast cannot be used to change the size of a value"; + assert generator.target().arch.getSizeInBytes(kind()) == generator.target().arch.getSizeInBytes(object().kind()) : "unsafe cast cannot be used to change the size of a value"; AllocatableValue result = generator.newVariable(kind()); generator.emitMove(result, generator.operand(object())); generator.setResult(this, result);