001/*
002 *  This file is part of the Jikes RVM project (http://jikesrvm.org).
003 *
004 *  This file is licensed to You under the Eclipse Public License (EPL);
005 *  You may not use this file except in compliance with the License. You
006 *  may obtain a copy of the License at
007 *
008 *      http://www.opensource.org/licenses/eclipse-1.0.php
009 *
010 *  See the COPYRIGHT.txt file distributed with this work for information
011 *  regarding copyright ownership.
012 */
013package org.jikesrvm.architecture;
014
015import org.jikesrvm.VM;
016
017import org.vmmagic.unboxed.Address;
018import org.vmmagic.unboxed.Offset;
019
020import org.vmmagic.pragma.Uninterruptible;
021
022@Uninterruptible
023public final class StackFrameLayout {
024
025  public static int getNormalStackSize() {
026    if (VM.BuildForIA32) {
027      return org.jikesrvm.ia32.StackframeLayoutConstants.STACK_SIZE_NORMAL;
028    } else {
029      if (VM.VerifyAssertions) VM._assert(VM.BuildForPowerPC);
030      return org.jikesrvm.ppc.StackframeLayoutConstants.STACK_SIZE_NORMAL;
031    }
032  }
033  public static int getMaxStackSize() {
034    if (VM.BuildForIA32) {
035      return org.jikesrvm.ia32.StackframeLayoutConstants.STACK_SIZE_MAX;
036    } else {
037      if (VM.VerifyAssertions) VM._assert(VM.BuildForPowerPC);
038      return org.jikesrvm.ppc.StackframeLayoutConstants.STACK_SIZE_MAX;
039    }
040  }
041  public static int getBootThreadStackSize() {
042    if (VM.BuildForIA32) {
043      return org.jikesrvm.ia32.StackframeLayoutConstants.STACK_SIZE_BOOT;
044    } else {
045      if (VM.VerifyAssertions) VM._assert(VM.BuildForPowerPC);
046      return org.jikesrvm.ppc.StackframeLayoutConstants.STACK_SIZE_BOOT;
047    }
048  }
049  public static int getStackSizeCollector() {
050    if (VM.BuildForIA32) {
051      return org.jikesrvm.ia32.StackframeLayoutConstants.STACK_SIZE_COLLECTOR;
052    } else {
053      if (VM.VerifyAssertions) VM._assert(VM.BuildForPowerPC);
054      return org.jikesrvm.ppc.StackframeLayoutConstants.STACK_SIZE_COLLECTOR;
055    }
056  }
057  public static int getStackSizeGCDisabled() {
058    if (VM.BuildForIA32) {
059      return org.jikesrvm.ia32.StackframeLayoutConstants.STACK_SIZE_GCDISABLED;
060    } else {
061      if (VM.VerifyAssertions) VM._assert(VM.BuildForPowerPC);
062      return org.jikesrvm.ppc.StackframeLayoutConstants.STACK_SIZE_GCDISABLED;
063    }
064  }
065  public static int getStackSizeDLOpen() {
066    if (VM.BuildForIA32) {
067      return org.jikesrvm.ia32.StackframeLayoutConstants.STACK_SIZE_DLOPEN;
068    } else {
069      if (VM.VerifyAssertions) VM._assert(VM.BuildForPowerPC);
070      return org.jikesrvm.ppc.StackframeLayoutConstants.STACK_SIZE_DLOPEN;
071    }
072  }
073  public static int getStackSizeBoot() {
074    if (VM.BuildForIA32) {
075      return org.jikesrvm.ia32.StackframeLayoutConstants.STACK_SIZE_BOOT;
076    } else {
077      if (VM.VerifyAssertions) VM._assert(VM.BuildForPowerPC);
078      return org.jikesrvm.ppc.StackframeLayoutConstants.STACK_SIZE_BOOT;
079    }
080  }
081  public static int getStackSizeNormal() {
082    if (VM.BuildForIA32) {
083      return org.jikesrvm.ia32.StackframeLayoutConstants.STACK_SIZE_NORMAL;
084    } else {
085      if (VM.VerifyAssertions) VM._assert(VM.BuildForPowerPC);
086      return org.jikesrvm.ppc.StackframeLayoutConstants.STACK_SIZE_NORMAL;
087    }
088  }
089  public static int getJNIStackGrowthSize() {
090        if (VM.BuildForIA32) {
091      return org.jikesrvm.ia32.StackframeLayoutConstants.STACK_SIZE_JNINATIVE_GROW;
092    } else {
093      if (VM.VerifyAssertions) VM._assert(VM.BuildForPowerPC);
094      return org.jikesrvm.ppc.StackframeLayoutConstants.STACK_SIZE_JNINATIVE_GROW;
095    }
096  }
097  public static int getStackGrowthSize() {
098    if (VM.BuildForIA32) {
099      return org.jikesrvm.ia32.StackframeLayoutConstants.STACK_SIZE_GROW;
100    } else {
101      if (VM.VerifyAssertions) VM._assert(VM.BuildForPowerPC);
102      return org.jikesrvm.ppc.StackframeLayoutConstants.STACK_SIZE_GROW;
103    }
104  }
105  public static int getStackSizeGuard() {
106    if (VM.BuildForIA32) {
107      return org.jikesrvm.ia32.StackframeLayoutConstants.STACK_SIZE_GUARD;
108    } else {
109      if (VM.VerifyAssertions) VM._assert(VM.BuildForPowerPC);
110      return org.jikesrvm.ppc.StackframeLayoutConstants.STACK_SIZE_GUARD;
111    }
112  }
113  public static Address getStackFrameSentinelFP() {
114    if (VM.BuildForIA32) {
115      return org.jikesrvm.ia32.StackframeLayoutConstants.STACKFRAME_SENTINEL_FP;
116    } else {
117      if (VM.VerifyAssertions) VM._assert(VM.BuildForPowerPC);
118      return org.jikesrvm.ppc.StackframeLayoutConstants.STACKFRAME_SENTINEL_FP;
119    }
120  }
121  public static int getInvisibleMethodID() {
122    if (VM.BuildForIA32) {
123      return org.jikesrvm.ia32.StackframeLayoutConstants.INVISIBLE_METHOD_ID;
124    } else {
125      if (VM.VerifyAssertions) VM._assert(VM.BuildForPowerPC);
126      return org.jikesrvm.ppc.StackframeLayoutConstants.INVISIBLE_METHOD_ID;
127    }
128  }
129  public static int getStackFrameHeaderSize() {
130    if (VM.BuildForIA32) {
131      return org.jikesrvm.ia32.StackframeLayoutConstants.STACKFRAME_HEADER_SIZE;
132    } else {
133      if (VM.VerifyAssertions) VM._assert(VM.BuildForPowerPC);
134      return org.jikesrvm.ppc.StackframeLayoutConstants.STACKFRAME_HEADER_SIZE;
135    }
136  }
137  public static Offset getStackFrameMethodIDOffset() {
138    if (VM.BuildForIA32) {
139      return org.jikesrvm.ia32.StackframeLayoutConstants.STACKFRAME_METHOD_ID_OFFSET;
140    } else {
141      if (VM.VerifyAssertions) VM._assert(VM.BuildForPowerPC);
142      return org.jikesrvm.ppc.StackframeLayoutConstants.STACKFRAME_METHOD_ID_OFFSET;
143    }
144  }
145  public static Offset getStackFramePointerOffset() {
146    if (VM.BuildForIA32) {
147      return org.jikesrvm.ia32.StackframeLayoutConstants.STACKFRAME_FRAME_POINTER_OFFSET;
148    } else {
149      if (VM.VerifyAssertions) VM._assert(VM.BuildForPowerPC);
150      return org.jikesrvm.ppc.StackframeLayoutConstants.STACKFRAME_FRAME_POINTER_OFFSET;
151    }
152  }
153  public static Offset getStackFrameReturnAddressOffset() {
154    if (VM.BuildForIA32) {
155      return org.jikesrvm.ia32.StackframeLayoutConstants.STACKFRAME_RETURN_ADDRESS_OFFSET;
156    } else {
157      if (VM.VerifyAssertions) VM._assert(VM.BuildForPowerPC);
158      return org.jikesrvm.ppc.StackframeLayoutConstants.STACKFRAME_RETURN_ADDRESS_OFFSET;
159    }
160  }
161
162}