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.osr; 014 015 import org.jikesrvm.SizeConstants; 016 import org.jikesrvm.classloader.ClassLoaderConstants; 017 018 /** 019 * OSRConstants defines constants used for on-stack-replacement mapping, 020 * VM scope descriptor, and pseudo bytecodes. 021 */ 022 public interface OSRConstants extends SizeConstants, ClassLoaderConstants { 023 024 //////////////////////////////////////////// 025 // Part I constants used for opt compilation with OSR points 026 /////////////////////////////////////////// 027 028 /* use the similar encoding as GC map. 029 * 030 * An entry (long) containts the following data: 031 * m : a machine code offset ( in bytes ) 032 * o : an index into the OSR maps array 033 * b : the bytecode index of the instruction 034 * i : index into the inline encoding 035 * 036 * (HIGH) iiii iiii iiii iiib bbbb bbbb bbbb bbbo 037 * (LOW) oooo oooo oooo ommm mmmm mmmm mmmm mmmm 038 */ 039 long OFFSET_MASK = 0x000000000007ffffL; 040 long OSRI_MASK = 0x00000001fff80000L; 041 long BCI_MASK = 0x0001fffe00000000L; 042 long IEI_MASK = 0xfffe000000000000L; 043 int OFFSET_SHIFT = 0; 044 int OSRI_SHIFT = 19; 045 int BCI_SHIFT = 33; 046 int IEI_SHIFT = 49; 047 048 /* 049 * signifies there is no map entry for this machine code offset 050 */ 051 int NO_OSR_ENTRY = (int) (OSRI_MASK >>> OSRI_SHIFT); 052 int INVALID_BCI = (int) (BCI_MASK >>> BCI_SHIFT); 053 int INVALID_IEI = (int) (IEI_MASK >>> IEI_SHIFT); 054 055 /* array of OSR maps. 056 * 057 * 1. Each map has one or more ints as following: 058 * REG_REF (WORD1 WORD2) (WORD1 WORD2) 059 * 060 * 2. The first in REG_REF is a bit map of registers that 061 * contain references ( the MSB is used for chaining ). 062 * Use 'getRegBitPosition' to find the position for 063 * a register. 064 * 065 * 3. The following words are tuple of two words: 066 * (WORD 1) Nxxx xxxx xxkt ttnn nnnn nnnn nnnn nnvv 067 * (WORD 2) int bits value 068 * 069 * N : next tuple is valid. 070 * x : unused bits 071 * k : kind of this element ( LOCAL/STACK ) 072 * t : type of this element ( see type code ) 073 * n : the number this element ( e.g, L0, S1 ), which is 16-bit 074 * as required by JVM spec. 075 * v : the type of the next word 076 */ 077 078 /* bit pattern for the "Next" bit in the OSR maps array 079 */ 080 int NEXT_BIT = 0x80000000; 081 /* kind of element */ int KIND_MASK = 0x00400000; 082 int KIND_SHIFT = 22; 083 /* type code */ 084 int TCODE_MASK = 0x00380000; 085 int TCODE_SHIFT = 19; 086 /* number */ 087 int NUM_MASK = 0x0007fff8; 088 int NUM_SHIFT = 3; 089 /* value type */ 090 int VTYPE_MASK = 0x00000007; 091 int VTYPE_SHIFT = 0; 092 093 //////////////////////////////////////////// 094 // Part II constants used when extract VM scope descriptor 095 //////////////////////////////////////////// 096 /** Used to indicate the kind of element is a local variable */ 097 boolean LOCAL = false; 098 /** Used to indicate the kind of element is from the operand stack */ 099 boolean STACK = true; 100 101 /* the type code of the element, used in osr map encoding. */ 102 byte INT = 0; 103 byte HIGH_64BIT = 1; //used to store the high bits of a 64-bit value 104 byte LONG = 2; 105 byte FLOAT = 3; 106 byte DOUBLE = 4; 107 byte RET_ADDR = 5; 108 byte REF = 6; 109 byte WORD = 7; 110 111 /* value type */ 112 byte ICONST = 0; 113 byte ACONST = 3; 114 byte LCONST = 4; 115 byte PHYREG = 1; 116 byte SPILL = 2; 117 118 ///////////////////////////////////////////////// 119 // Part III Pseudo bytecodes 120 //////////////////////////////////////////////// 121 /* We define instruction as follows: JBC_impdep1, 122 * PSEUDO_instruction, values 123 * 124 * LoadConst takes encoded value and push on the top of stack. 125 * Compiler should construct constant values, and use Magic to 126 * convert INT to FLOAT, or LONG to DOUBLE. 127 * 128 * LoadRetAddrConst followed by offset from the PC of this instruction. 129 * 130 * InvokeStatic encoded with index into JTOC. 131 * 132 * All value are signed except LoadRetAddrConst 133 * 134 * LoadIntConst : B, V0, V1, V2, V3 135 * LoadLongConst: B, H0, H1, H2, H3, L0, L1, L2, L3 136 * LoadWordConst: on 32-bit: B, V0, V1, V2, V3 137 * LoadWordConst: on 64-bit: B, H0, H1, H2, H3, L0, L1, L2, L3 138 * LoadFloatConst: B, V0, V1, V2, V3 139 * LoadDoubleConst: B, H0, H1, H2, H3, L0, L1, L2, L3 140 * LoadRetAddrConst: B, V0, V1, V2, V3 141 * 142 * All value are unsigned: 143 * 144 * InvokeStatic : B, L0, L1, L2, L3 145 * 146 * The change of stack is pretty obvious. 147 */ 148 149 int PSEUDO_LoadIntConst = 1; 150 int PSEUDO_LoadLongConst = 2; 151 int PSEUDO_LoadFloatConst = 3; 152 int PSEUDO_LoadDoubleConst = 4; 153 int PSEUDO_LoadRetAddrConst = 5; 154 int PSEUDO_LoadWordConst = 6; 155 156 int PSEUDO_InvokeStatic = 7; 157 int PSEUDO_CheckCast = 8; 158 159 /* followed by compiled method ID */ 160 int PSEUDO_InvokeCompiledMethod = 9; 161 162 /* indicate local initialization ends, for baselike compiler */ 163 int PSEUDO_ParamInitEnd = 10; 164 165 /* special method id for PSEUDO_InvokeStatic, target must be listed here */ 166 int GETREFAT = 0; // ObjectHolder.getRefAt 167 int CLEANREFS = 1; // ObjectHolder.cleanRefAt 168 169 byte ReturnAddressTypeCode = (byte) 'R'; 170 byte WordTypeCode = (byte) 'W'; //'A' 171 }