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