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 */
013 package org.jikesrvm.objectmodel;
014
015 import org.jikesrvm.VM;
016 import org.jikesrvm.classloader.SpecializedMethodManager;
017
018 /**
019 * Layout the TIB (Type Information Block).
020 */
021
022 public interface TIBLayoutConstants {
023
024 //--------------------------------------------------------------------------------------------//
025 // Type Information Block (TIB) Layout Constants //
026 //--------------------------------------------------------------------------------------------//
027 //
028 // Object[] (type info block) RVMType (class info)
029 // / /
030 // +--------------------+ +--------------+
031 // | TIB pointer | | TIB pointer |
032 // +--------------------+ +--------------+
033 // | status | | status |
034 // +--------------------+ +--------------+
035 // | length | | field0 |
036 // +--------------------+ +--------------+
037 // TIB: 0:| type +------------> | ... |
038 // +--------------------+ +--------------+
039 // 1:| superclass ids +--> | fieldN-1 |
040 // +--------------------+ +--------------+
041 // 2:| implements trits +-->
042 // +--------------------+
043 // 3:| array element TIB +-->
044 // +--------------------+
045 // 4:| iTABLES/IMT +-->
046 // +--------------------+
047 // 5:| specialized 0 +-->
048 // +--------------------+
049 // | ... +-->
050 // +--------------------+
051 // V0:| virtual method 0 +-----+
052 // +--------------------+ |
053 // | ... | | INSTRUCTION[] (machine code)
054 // +--------------------+ | /
055 // VN-1:| virtual method N-1 | | +--------------+
056 // +--------------------+ | | TIB pointer |
057 // | +--------------+
058 // | | status |
059 // | +--------------+
060 // | | length |
061 // | +--------------+
062 // +------->| code0 |
063 // +--------------+
064 // | ... |
065 // +--------------+
066 // | codeN-1 |
067 // +--------------+
068 //
069
070 // Number of slots reserved for interface method pointers.
071 //
072 int IMT_METHOD_SLOTS = VM.BuildForIMTInterfaceInvocation ? 29 : 0;
073
074 // First slot of tib points to RVMType (slot 0 in above diagram).
075 //
076 int TIB_TYPE_INDEX = 0;
077
078 // A vector of ids for classes that this one extends.
079 // (see vm/classLoader/DynamicTypeCheck.java)
080 //
081 int TIB_SUPERCLASS_IDS_INDEX = TIB_TYPE_INDEX + 1;
082
083 // "Does this class implement the ith interface?"
084 // (see vm/classLoader/DynamicTypeCheck.java)
085 //
086 int TIB_DOES_IMPLEMENT_INDEX = TIB_SUPERCLASS_IDS_INDEX + 1;
087
088 // The TIB of the elements type of an array (may be null in fringe cases
089 // when element type couldn't be resolved during array resolution).
090 // Will be null when not an array.
091 //
092 int TIB_ARRAY_ELEMENT_TIB_INDEX = TIB_DOES_IMPLEMENT_INDEX + 1;
093
094 // A pointer to either an ITable or InterfaceMethodTable (IMT)
095 // depending on which dispatch implementation we are using.
096 int TIB_INTERFACE_DISPATCH_TABLE_INDEX = TIB_ARRAY_ELEMENT_TIB_INDEX + 1;
097
098 // A set of 0 or more specialized methods used in the VM such as for GC scanning
099 int TIB_FIRST_SPECIALIZED_METHOD_INDEX = TIB_INTERFACE_DISPATCH_TABLE_INDEX + 1;
100
101 // Next group of slots point to virtual method code blocks
102 // (slots V1..VN in above diagram).
103 int TIB_FIRST_VIRTUAL_METHOD_INDEX = TIB_FIRST_SPECIALIZED_METHOD_INDEX + SpecializedMethodManager.numSpecializedMethods();
104
105 /**
106 * Special value returned by RVMClassLoader.getFieldOffset() or
107 * RVMClassLoader.getMethodOffset() to indicate fields or methods
108 * that must be accessed via dynamic linking code because their
109 * offset is not yet known or the class's static initializer has not
110 * yet been run.
111 *
112 * We choose a value that will never match a valid jtoc-,
113 * instance-, or virtual method table- offset. Short.MIN_VALUE+1 is
114 * a good value:
115 *
116 * <ul>
117 * <li>the jtoc offsets are aligned and this value should be
118 * too huge to address the table</li>
119 * <li>instance field offsets are always >e; -4</li>
120 * <li>virtual method offsets are always positive w.r.t. TIB pointer</li>
121 * <li>fits into a PowerPC 16bit immediate operand</li>
122 * </ul>
123 */
124 int NEEDS_DYNAMIC_LINK = Short.MIN_VALUE + 1;
125 }
126