< prev index next >

src/jdk.vm.ci/share/classes/jdk.vm.ci.code/src/jdk/vm/ci/code/StackSlot.java

Print this page


   1 /*
   2  * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 package jdk.vm.ci.code;
  24 
  25 import jdk.vm.ci.meta.*;

  26 
  27 /**
  28  * Represents a compiler spill slot or an outgoing stack-based argument in a method's frame or an
  29  * incoming stack-based argument in a method's {@linkplain #isInCallerFrame() caller's frame}.
  30  */
  31 public final class StackSlot extends StackSlotValue {
  32 
  33     private final int offset;
  34     private final boolean addFrameSize;
  35 
  36     /**
  37      * Gets a {@link StackSlot} instance representing a stack slot at a given index holding a value
  38      * of a given kind.
  39      *
  40      * @param kind The kind of the value stored in the stack slot.
  41      * @param offset The offset of the stack slot (in bytes)
  42      * @param addFrameSize Specifies if the offset is relative to the stack pointer, or the
  43      *            beginning of the frame (stack pointer + total frame size).
  44      */
  45     public static StackSlot get(LIRKind kind, int offset, boolean addFrameSize) {
  46         assert addFrameSize || offset >= 0;
  47         return new StackSlot(kind, offset, addFrameSize);
  48     }
  49 
  50     /**
  51      * Private constructor to enforce use of {@link #get(LIRKind, int, boolean)} so that a cache can


   1 /*
   2  * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 package jdk.vm.ci.code;
  24 
  25 import jdk.vm.ci.meta.AllocatableValue;
  26 import jdk.vm.ci.meta.LIRKind;
  27 
  28 /**
  29  * Represents a compiler spill slot or an outgoing stack-based argument in a method's frame or an
  30  * incoming stack-based argument in a method's {@linkplain #isInCallerFrame() caller's frame}.
  31  */
  32 public final class StackSlot extends AllocatableValue {
  33 
  34     private final int offset;
  35     private final boolean addFrameSize;
  36 
  37     /**
  38      * Gets a {@link StackSlot} instance representing a stack slot at a given index holding a value
  39      * of a given kind.
  40      *
  41      * @param kind The kind of the value stored in the stack slot.
  42      * @param offset The offset of the stack slot (in bytes)
  43      * @param addFrameSize Specifies if the offset is relative to the stack pointer, or the
  44      *            beginning of the frame (stack pointer + total frame size).
  45      */
  46     public static StackSlot get(LIRKind kind, int offset, boolean addFrameSize) {
  47         assert addFrameSize || offset >= 0;
  48         return new StackSlot(kind, offset, addFrameSize);
  49     }
  50 
  51     /**
  52      * Private constructor to enforce use of {@link #get(LIRKind, int, boolean)} so that a cache can


< prev index next >