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