changeset 22431:0a0c0111ecda

Remove unused class CalleeSaveLayout.
author Roland Schatz <roland.schatz@oracle.com>
date Wed, 19 Aug 2015 13:37:41 +0200
parents 0666b6a8f33b
children e4f0d819fe22
files jvmci/jdk.internal.jvmci.code/src/jdk/internal/jvmci/code/CalleeSaveLayout.java jvmci/jdk.internal.jvmci.code/src/jdk/internal/jvmci/code/RegisterAttributes.java jvmci/jdk.internal.jvmci.code/src/jdk/internal/jvmci/code/RegisterConfig.java jvmci/jdk.internal.jvmci.hotspot.amd64/src/jdk/internal/jvmci/hotspot/amd64/AMD64HotSpotRegisterConfig.java jvmci/jdk.internal.jvmci.hotspot.sparc/src/jdk/internal/jvmci/hotspot/sparc/SPARCHotSpotRegisterConfig.java
diffstat 5 files changed, 13 insertions(+), 204 deletions(-) [+]
line wrap: on
line diff
--- a/jvmci/jdk.internal.jvmci.code/src/jdk/internal/jvmci/code/CalleeSaveLayout.java	Wed Aug 19 10:58:13 2015 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,182 +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 jdk.internal.jvmci.code;
-
-import java.util.*;
-
-import jdk.internal.jvmci.meta.*;
-
-/**
- * The callee save area (CSA) is a contiguous space in a stack frame used to save (and restore) the
- * values of the caller's registers. This class describes the layout of a CSA in terms of its
- * {@linkplain #size size}, {@linkplain #slotSize slot size} and the {@linkplain #registers callee
- * save registers} covered by the CSA.
- */
-public class CalleeSaveLayout {
-
-    /**
-     * The size (in bytes) of the CSA.
-     */
-    public final int size;
-
-    /**
-     * The size (in bytes) of an {@linkplain #registerAt(int) indexable} slot in the CSA.
-     */
-    public final int slotSize;
-
-    /**
-     * Map from {@linkplain Register#number register numbers} to slot indexes in the CSA.
-     */
-    private final int[] regNumToIndex;
-
-    private final Register[] indexToReg;
-
-    /**
-     * The list of registers {@linkplain #contains(int) contained} by this CSA.
-     */
-    public final Register[] registers;
-
-    /**
-     * The offset from the frame pointer to the CSA. If this is not known, then this field will have
-     * the value {@link Integer#MAX_VALUE}.
-     */
-    public final int frameOffsetToCSA;
-
-    /**
-     * Creates a CSA layout.
-     *
-     * @param size size (in bytes) of the CSA. If this is {@code -1}, then the CSA size will be
-     *            computed from {@code registers}.
-     * @param slotSize the size (in bytes) of an {@linkplain #registerAt(int) indexable} slot in the
-     *            CSA
-     * @param registers the registers that can be saved in the CSA
-     */
-    public CalleeSaveLayout(TargetDescription target, int frameOffsetToCSA, int size, int slotSize, Register... registers) {
-        this.frameOffsetToCSA = frameOffsetToCSA;
-        assert slotSize == 0 || CodeUtil.isPowerOf2(slotSize);
-        this.slotSize = slotSize;
-        int maxRegNum = -1;
-        int maxOffset = 0;
-        this.registers = registers;
-        int offset = 0;
-        for (Register reg : registers) {
-            assert offset % slotSize == 0;
-            assert reg.number >= 0;
-            if (reg.number > maxRegNum) {
-                maxRegNum = reg.number;
-            }
-            if (offset > maxOffset) {
-                maxOffset = offset;
-            }
-            PlatformKind kind = target.arch.getLargestStorableKind(reg.getRegisterCategory());
-            offset += target.getSizeInBytes(kind);
-        }
-        if (size == -1) {
-            this.size = offset;
-        } else {
-            assert offset <= size;
-            this.size = size;
-        }
-
-        this.regNumToIndex = new int[maxRegNum + 1];
-        this.indexToReg = offset == 0 ? new Register[0] : new Register[offset / slotSize];
-        Arrays.fill(regNumToIndex, -1);
-        offset = 0;
-        for (Register reg : registers) {
-            int index = offset / slotSize;
-            regNumToIndex[reg.number] = index;
-            indexToReg[index] = reg;
-            PlatformKind kind = target.arch.getLargestStorableKind(reg.getRegisterCategory());
-            offset += target.getSizeInBytes(kind);
-        }
-    }
-
-    /**
-     * Gets the offset of a given register in the CSA.
-     *
-     * @return the offset (in bytes) of {@code reg} in the CSA
-     * @throws IllegalArgumentException if {@code reg} does not have a slot in the CSA
-     */
-    public int offsetOf(int reg) {
-        return indexOf(reg) * slotSize;
-    }
-
-    /**
-     * Gets the index of a given register in the CSA.
-     *
-     * @return the index of {@code reg} in the CSA
-     * @throws IllegalArgumentException if {@code reg} does not have a slot in the CSA
-     */
-    public int indexOf(int reg) {
-        if (!contains(reg)) {
-            throw new IllegalArgumentException(String.valueOf(reg));
-        }
-        return regNumToIndex[reg];
-    }
-
-    /**
-     * Gets the offset of a given register in the CSA.
-     *
-     * @return the offset (in bytes) of {@code reg} in the CSA
-     * @throws IllegalArgumentException if {@code reg} does not have a slot in the CSA
-     */
-    public int offsetOf(Register reg) {
-        return offsetOf(reg.number);
-    }
-
-    /**
-     * Determines if the CSA includes a slot for a given register.
-     *
-     * @param reg the register to test
-     * @return true if the CSA contains a slot for {@code reg}
-     */
-    public boolean contains(int reg) {
-        return reg >= 0 && reg < regNumToIndex.length && regNumToIndex[reg] != -1;
-    }
-
-    /**
-     * Gets the register whose slot in the CSA is at a given index.
-     *
-     * @param index an index of a slot in the CSA
-     * @return the register whose slot in the CSA is at {@code index} or {@code null} if
-     *         {@code index} does not denote a slot in the CSA aligned with a register
-     */
-    public Register registerAt(int index) {
-        if (index < 0 || index >= indexToReg.length) {
-            return null;
-        }
-        return indexToReg[index];
-    }
-
-    @Override
-    public String toString() {
-        StringBuilder sb = new StringBuilder("[");
-        for (Register reg : registers) {
-            if (sb.length() != 1) {
-                sb.append(", ");
-            }
-            sb.append(reg).append("{+").append(offsetOf(reg)).append('}');
-        }
-        return sb.append("] size=").append(size).toString();
-    }
-}
--- a/jvmci/jdk.internal.jvmci.code/src/jdk/internal/jvmci/code/RegisterAttributes.java	Wed Aug 19 10:58:13 2015 +0200
+++ b/jvmci/jdk.internal.jvmci.code/src/jdk/internal/jvmci/code/RegisterAttributes.java	Wed Aug 19 13:37:41 2015 +0200
@@ -57,9 +57,9 @@
         RegisterAttributes[] map = new RegisterAttributes[registers.length];
         for (Register reg : registers) {
             if (reg != null) {
-                CalleeSaveLayout csl = registerConfig.getCalleeSaveLayout();
-                RegisterAttributes attr = new RegisterAttributes(Arrays.asList(registerConfig.getCallerSaveRegisters()).contains(reg),
-                                csl == null ? false : Arrays.asList(csl.registers).contains(reg), Arrays.asList(registerConfig.getAllocatableRegisters()).contains(reg));
+                Register[] csr = registerConfig.getCalleeSaveRegisters();
+                RegisterAttributes attr = new RegisterAttributes(Arrays.asList(registerConfig.getCallerSaveRegisters()).contains(reg), csr == null ? false : Arrays.asList(csr).contains(reg),
+                                Arrays.asList(registerConfig.getAllocatableRegisters()).contains(reg));
                 if (map.length <= reg.number) {
                     map = Arrays.copyOf(map, reg.number + 1);
                 }
--- a/jvmci/jdk.internal.jvmci.code/src/jdk/internal/jvmci/code/RegisterConfig.java	Wed Aug 19 10:58:13 2015 +0200
+++ b/jvmci/jdk.internal.jvmci.code/src/jdk/internal/jvmci/code/RegisterConfig.java	Wed Aug 19 13:37:41 2015 +0200
@@ -91,11 +91,9 @@
     Register[] getCallerSaveRegisters();
 
     /**
-     * Gets the layout of the callee save area of this register configuration.
-     *
-     * @return {@code null} if there is no callee save area
+     * Gets the registers whose values must be preserved by the callee.
      */
-    CalleeSaveLayout getCalleeSaveLayout();
+    Register[] getCalleeSaveRegisters();
 
     /**
      * Gets a map from register {@linkplain Register#number numbers} to register
--- a/jvmci/jdk.internal.jvmci.hotspot.amd64/src/jdk/internal/jvmci/hotspot/amd64/AMD64HotSpotRegisterConfig.java	Wed Aug 19 10:58:13 2015 +0200
+++ b/jvmci/jdk.internal.jvmci.hotspot.amd64/src/jdk/internal/jvmci/hotspot/amd64/AMD64HotSpotRegisterConfig.java	Wed Aug 19 13:37:41 2015 +0200
@@ -86,8 +86,6 @@
      */
     private final boolean needsNativeStackHomeSpace;
 
-    private final CalleeSaveLayout csl;
-
     private static Register[] initAllocatable(boolean reserveForHeapBase) {
         Register[] registers = null;
         // @formatter:off
@@ -127,7 +125,6 @@
             this.needsNativeStackHomeSpace = false;
         }
 
-        csl = null;
         this.allocatable = allocatable.clone();
         Set<Register> callerSaveSet = new HashSet<>();
         Collections.addAll(callerSaveSet, allocatable);
@@ -145,6 +142,10 @@
         return callerSaved;
     }
 
+    public Register[] getCalleeSaveRegisters() {
+        return null;
+    }
+
     @Override
     public boolean areAllAllocatableRegistersCallerSaved() {
         return allAllocatableAreCallerSaved;
@@ -245,10 +246,6 @@
         return rsp;
     }
 
-    public CalleeSaveLayout getCalleeSaveLayout() {
-        return csl;
-    }
-
     @Override
     public String toString() {
         return String.format("Allocatable: " + Arrays.toString(getAllocatableRegisters()) + "%n" + "CallerSave:  " + Arrays.toString(getCallerSaveRegisters()) + "%n");
--- a/jvmci/jdk.internal.jvmci.hotspot.sparc/src/jdk/internal/jvmci/hotspot/sparc/SPARCHotSpotRegisterConfig.java	Wed Aug 19 10:58:13 2015 +0200
+++ b/jvmci/jdk.internal.jvmci.hotspot.sparc/src/jdk/internal/jvmci/hotspot/sparc/SPARCHotSpotRegisterConfig.java	Wed Aug 19 13:37:41 2015 +0200
@@ -98,8 +98,6 @@
      */
     private final Register[] calleeSaveRegisters = {l0, l1, l2, l3, l4, l5, l6, l7, i0, i1, i2, i3, i4, i5, i6, i7};
 
-    private final CalleeSaveLayout csl;
-
     private static Register[] initAllocatable(boolean reserveForHeapBase) {
         Register[] registers = null;
         if (reserveForHeapBase) {
@@ -149,8 +147,6 @@
 
     public SPARCHotSpotRegisterConfig(TargetDescription target, Register[] allocatable) {
         this.architecture = target.arch;
-
-        csl = new CalleeSaveLayout(target, -1, -1, target.arch.getWordSize(), calleeSaveRegisters);
         this.allocatable = allocatable.clone();
         attributesMap = RegisterAttributes.createMap(this, SPARC.allRegisters);
     }
@@ -160,6 +156,10 @@
         return callerSaveRegisters;
     }
 
+    public Register[] getCalleeSaveRegisters() {
+        return calleeSaveRegisters;
+    }
+
     @Override
     public boolean areAllAllocatableRegistersCallerSaved() {
         return false;
@@ -284,10 +284,6 @@
         return sp;
     }
 
-    public CalleeSaveLayout getCalleeSaveLayout() {
-        return csl;
-    }
-
     @Override
     public String toString() {
         return String.format("Allocatable: " + Arrays.toString(getAllocatableRegisters()) + "%n" + "CallerSave:  " + Arrays.toString(getCallerSaveRegisters()) + "%n");