Changeset 98912 in webkit for trunk/Source/JavaScriptCore/dfg/DFGGPRInfo.h
- Timestamp:
- Oct 31, 2011, 4:50:57 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/dfg/DFGGPRInfo.h
r95902 r98912 37 37 #define InvalidGPRReg ((GPRReg)-1) 38 38 39 #if USE(JSVALUE64) 40 class JSValueRegs { 41 public: 42 JSValueRegs() 43 : m_gpr(InvalidGPRReg) 44 { 45 } 46 47 explicit JSValueRegs(GPRReg gpr) 48 : m_gpr(gpr) 49 { 50 } 51 52 bool operator!() const { return m_gpr == InvalidGPRReg; } 53 54 GPRReg gpr() const { return m_gpr; } 55 56 private: 57 GPRReg m_gpr; 58 }; 59 60 class JSValueSource { 61 public: 62 JSValueSource() 63 : m_offset(notAddress()) 64 , m_base(InvalidGPRReg) 65 { 66 } 67 68 JSValueSource(JSValueRegs regs) 69 : m_offset(notAddress()) 70 , m_base(regs.gpr()) 71 { 72 } 73 74 explicit JSValueSource(GPRReg gpr) 75 : m_offset(notAddress()) 76 , m_base(gpr) 77 { 78 } 79 80 JSValueSource(MacroAssembler::Address address) 81 : m_offset(address.offset) 82 , m_base(address.base) 83 { 84 ASSERT(m_offset != notAddress()); 85 ASSERT(m_base != InvalidGPRReg); 86 } 87 88 static JSValueSource unboxedCell(GPRReg payloadGPR) 89 { 90 return JSValueSource(payloadGPR); 91 } 92 93 bool operator!() const { return m_base == InvalidGPRReg; } 94 95 bool isAddress() const { return m_offset != notAddress(); } 96 97 int32_t offset() const 98 { 99 ASSERT(isAddress()); 100 return m_offset; 101 } 102 103 GPRReg base() const 104 { 105 ASSERT(isAddress()); 106 return m_base; 107 } 108 109 GPRReg gpr() const 110 { 111 ASSERT(!isAddress()); 112 return m_base; 113 } 114 115 MacroAssembler::Address asAddress() const { return MacroAssembler::Address(base(), offset()); } 116 117 private: 118 static inline int32_t notAddress() { return 0x80000000; } 119 120 int32_t m_offset; 121 GPRReg m_base; 122 }; 123 #endif 124 125 #if USE(JSVALUE32_64) 126 class JSValueRegs { 127 public: 128 JSValueRegs() 129 : m_tagGPR(static_cast<int8_t>(InvalidGPRReg)) 130 , m_payloadGPR(static_cast<int8_t>(InvalidGPRReg)) 131 { 132 } 133 134 JSValueRegs(GPRReg tagGPR, GPRReg payloadGPR) 135 : m_tagGPR(tagGPR) 136 , m_payloadGPR(payloadGPR) 137 { 138 ASSERT((static_cast<GPRReg>(m_tagGPR) == InvalidGPRReg) == (static_cast<GPRReg>(payloadGPR) == InvalidGPRReg)); 139 } 140 141 bool operator!() const { return static_cast<GPRReg>(m_tagGPR) == InvalidGPRReg; } 142 143 GPRReg tagGPR() const { return static_cast<GPRReg>(m_tagGPR); } 144 GPRReg payloadGPR() const { return static_cast<GPRReg>(m_payloadGPR); } 145 146 private: 147 int8_t m_tagGPR; 148 int8_t m_payloadGPR; 149 }; 150 151 class JSValueSource { 152 public: 153 JSValueSource() 154 : m_offset(notAddress()) 155 , m_baseOrTag(static_cast<int8_t>(InvalidGPRReg)) 156 , m_payload(static_cast<int8_t>(InvalidGPRReg)) 157 , m_tagType(0) 158 { 159 } 160 161 JSValueSource(JSValueRegs regs) 162 : m_offset(notAddress()) 163 , m_baseOrTag(regs.tagGPR()) 164 , m_payload(regs.payloadGPR()) 165 , m_tagType(0) 166 { 167 } 168 169 JSValueSource(GPRReg tagGPR, GPRReg payloadGPR) 170 : m_offset(notAddress()) 171 , m_baseOrTag(static_cast<int8_t>(tagGPR)) 172 , m_payload(static_cast<int8_t>(payloadGPR)) 173 , m_tagType(0) 174 { 175 } 176 177 JSValueSource(MacroAssembler::Address address) 178 : m_offset(address.offset) 179 , m_baseOrTag(static_cast<int8_t>(address.base)) 180 , m_payload(static_cast<int8_t>(InvalidGPRReg)) 181 , m_tagType(0) 182 { 183 ASSERT(m_offset != notAddress()); 184 ASSERT(static_cast<GPRReg>(m_baseOrTag) != InvalidGPRReg); 185 } 186 187 static JSValueSource unboxedCell(GPRReg payloadGPR) 188 { 189 JSValueSource result; 190 result.m_offset = notAddress(); 191 result.m_baseOrTag = static_cast<int8_t>(InvalidGPRReg); 192 result.m_payload = static_cast<int8_t>(payloadGPR); 193 result.m_tagType = static_cast<int8_t>(JSValue::CellTag); 194 return result; 195 } 196 197 bool operator!() const { return static_cast<GPRReg>(m_baseOrTag) == InvalidGPRReg && static_cast<GPRReg>(m_payload) == InvalidGPRReg; } 198 199 bool isAddress() const 200 { 201 ASSERT(!!*this); 202 return m_offset != notAddress(); 203 } 204 205 int32_t offset() const 206 { 207 ASSERT(isAddress()); 208 return m_offset; 209 } 210 211 GPRReg base() const 212 { 213 ASSERT(isAddress()); 214 return static_cast<GPRReg>(m_baseOrTag); 215 } 216 217 GPRReg tagGPR() const 218 { 219 ASSERT(!isAddress() && m_baseOrTag != InvalidGPRReg); 220 return static_cast<GPRReg>(m_baseOrTag); 221 } 222 223 GPRReg payloadGPR() const 224 { 225 ASSERT(!isAddress()); 226 return static_cast<GPRReg>(m_payload); 227 } 228 229 bool hasKnownTag() const 230 { 231 ASSERT(!!*this); 232 ASSERT(!isAddress()); 233 return static_cast<GPRReg>(m_baseOrTag) == InvalidGPRReg; 234 } 235 236 uint32_t tag() const 237 { 238 return static_cast<int32_t>(m_tagType); 239 } 240 241 MacroAssembler::Address asAddress(unsigned additionalOffset = 0) const { return MacroAssembler::Address(base(), offset() + additionalOffset); } 242 243 private: 244 static inline int32_t notAddress() { return 0x80000000; } 245 246 int32_t m_offset; 247 int8_t m_baseOrTag; 248 int8_t m_payload; 249 int8_t m_tagType; // Contains the low bits of the tag. 250 }; 251 #endif 252 39 253 #if CPU(X86) 40 254
Note:
See TracChangeset
for help on using the changeset viewer.