OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 | 198 |
199 #define DECLARE_HYDROGEN_ACCESSOR(type) \ | 199 #define DECLARE_HYDROGEN_ACCESSOR(type) \ |
200 H##type* hydrogen() const { \ | 200 H##type* hydrogen() const { \ |
201 return H##type::cast(hydrogen_value()); \ | 201 return H##type::cast(hydrogen_value()); \ |
202 } | 202 } |
203 | 203 |
204 | 204 |
205 class LInstruction: public ZoneObject { | 205 class LInstruction: public ZoneObject { |
206 public: | 206 public: |
207 LInstruction() | 207 LInstruction() |
208 : environment_(NULL), | 208 : environment_(NULL), |
209 hydrogen_value_(NULL), | 209 hydrogen_value_(NULL), |
210 is_call_(false) { } | 210 bit_field_(IsCallBits::encode(false)) { |
| 211 set_position(RelocInfo::kNoPosition); |
| 212 } |
| 213 |
211 virtual ~LInstruction() { } | 214 virtual ~LInstruction() { } |
212 | 215 |
213 virtual void CompileToNative(LCodeGen* generator) = 0; | 216 virtual void CompileToNative(LCodeGen* generator) = 0; |
214 virtual const char* Mnemonic() const = 0; | 217 virtual const char* Mnemonic() const = 0; |
215 virtual void PrintTo(StringStream* stream); | 218 virtual void PrintTo(StringStream* stream); |
216 virtual void PrintDataTo(StringStream* stream); | 219 virtual void PrintDataTo(StringStream* stream); |
217 virtual void PrintOutputOperandTo(StringStream* stream); | 220 virtual void PrintOutputOperandTo(StringStream* stream); |
218 | 221 |
219 enum Opcode { | 222 enum Opcode { |
220 // Declare a unique enum value for each instruction. | 223 // Declare a unique enum value for each instruction. |
(...skipping 18 matching lines...) Expand all Loading... |
239 virtual bool IsControl() const { return false; } | 242 virtual bool IsControl() const { return false; } |
240 | 243 |
241 void set_environment(LEnvironment* env) { environment_ = env; } | 244 void set_environment(LEnvironment* env) { environment_ = env; } |
242 LEnvironment* environment() const { return environment_; } | 245 LEnvironment* environment() const { return environment_; } |
243 bool HasEnvironment() const { return environment_ != NULL; } | 246 bool HasEnvironment() const { return environment_ != NULL; } |
244 | 247 |
245 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); } | 248 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); } |
246 LPointerMap* pointer_map() const { return pointer_map_.get(); } | 249 LPointerMap* pointer_map() const { return pointer_map_.get(); } |
247 bool HasPointerMap() const { return pointer_map_.is_set(); } | 250 bool HasPointerMap() const { return pointer_map_.is_set(); } |
248 | 251 |
| 252 // The 31 bits PositionBits is used to store the int position value. And the |
| 253 // position value may be RelocInfo::kNoPosition (-1). The accessor always |
| 254 // +1/-1 so that the encoded value of position in bit_field_ is always >= 0 |
| 255 // and can fit into the 31 bits PositionBits. |
| 256 void set_position(int pos) { |
| 257 bit_field_ = PositionBits::update(bit_field_, pos + 1); |
| 258 } |
| 259 int position() { return PositionBits::decode(bit_field_) - 1; } |
| 260 |
249 void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; } | 261 void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; } |
250 HValue* hydrogen_value() const { return hydrogen_value_; } | 262 HValue* hydrogen_value() const { return hydrogen_value_; } |
251 | 263 |
252 virtual void SetDeferredLazyDeoptimizationEnvironment(LEnvironment* env) { } | 264 virtual void SetDeferredLazyDeoptimizationEnvironment(LEnvironment* env) { } |
253 | 265 |
254 void MarkAsCall() { is_call_ = true; } | 266 void MarkAsCall() { bit_field_ = IsCallBits::update(bit_field_, true); } |
| 267 bool IsCall() const { return IsCallBits::decode(bit_field_); } |
255 | 268 |
256 // Interface to the register allocator and iterators. | 269 // Interface to the register allocator and iterators. |
257 bool ClobbersTemps() const { return is_call_; } | 270 bool ClobbersTemps() const { return IsCall(); } |
258 bool ClobbersRegisters() const { return is_call_; } | 271 bool ClobbersRegisters() const { return IsCall(); } |
259 bool ClobbersDoubleRegisters() const { return is_call_; } | 272 bool ClobbersDoubleRegisters() const { return IsCall(); } |
260 | 273 |
261 // Interface to the register allocator and iterators. | 274 // Interface to the register allocator and iterators. |
262 bool IsMarkedAsCall() const { return is_call_; } | 275 bool IsMarkedAsCall() const { return IsCall(); } |
263 | 276 |
264 virtual bool HasResult() const = 0; | 277 virtual bool HasResult() const = 0; |
265 virtual LOperand* result() const = 0; | 278 virtual LOperand* result() const = 0; |
266 | 279 |
267 LOperand* FirstInput() { return InputAt(0); } | 280 LOperand* FirstInput() { return InputAt(0); } |
268 LOperand* Output() { return HasResult() ? result() : NULL; } | 281 LOperand* Output() { return HasResult() ? result() : NULL; } |
269 | 282 |
270 virtual bool HasInterestingComment(LCodeGen* gen) const { return true; } | 283 virtual bool HasInterestingComment(LCodeGen* gen) const { return true; } |
271 | 284 |
272 #ifdef DEBUG | 285 #ifdef DEBUG |
273 void VerifyCall(); | 286 void VerifyCall(); |
274 #endif | 287 #endif |
275 | 288 |
276 private: | 289 private: |
277 // Iterator interface. | 290 // Iterator interface. |
278 friend class InputIterator; | 291 friend class InputIterator; |
279 virtual int InputCount() = 0; | 292 virtual int InputCount() = 0; |
280 virtual LOperand* InputAt(int i) = 0; | 293 virtual LOperand* InputAt(int i) = 0; |
281 | 294 |
282 friend class TempIterator; | 295 friend class TempIterator; |
283 virtual int TempCount() = 0; | 296 virtual int TempCount() = 0; |
284 virtual LOperand* TempAt(int i) = 0; | 297 virtual LOperand* TempAt(int i) = 0; |
285 | 298 |
| 299 class IsCallBits: public BitField<bool, 0, 1> {}; |
| 300 class PositionBits: public BitField<int, 1, 31> {}; |
| 301 |
286 LEnvironment* environment_; | 302 LEnvironment* environment_; |
287 SetOncePointer<LPointerMap> pointer_map_; | 303 SetOncePointer<LPointerMap> pointer_map_; |
288 HValue* hydrogen_value_; | 304 HValue* hydrogen_value_; |
289 bool is_call_; | 305 int bit_field_; |
290 }; | 306 }; |
291 | 307 |
292 | 308 |
293 // R = number of result operands (0 or 1). | 309 // R = number of result operands (0 or 1). |
294 // I = number of input operands. | 310 // I = number of input operands. |
295 // T = number of temporary operands. | 311 // T = number of temporary operands. |
296 template<int R, int I, int T> | 312 template<int R, int I, int T> |
297 class LTemplateInstruction: public LInstruction { | 313 class LTemplateInstruction: public LInstruction { |
298 public: | 314 public: |
299 // Allow 0 or 1 output operands. | 315 // Allow 0 or 1 output operands. |
(...skipping 2419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2719 | 2735 |
2720 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder); | 2736 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder); |
2721 }; | 2737 }; |
2722 | 2738 |
2723 #undef DECLARE_HYDROGEN_ACCESSOR | 2739 #undef DECLARE_HYDROGEN_ACCESSOR |
2724 #undef DECLARE_CONCRETE_INSTRUCTION | 2740 #undef DECLARE_CONCRETE_INSTRUCTION |
2725 | 2741 |
2726 } } // namespace v8::internal | 2742 } } // namespace v8::internal |
2727 | 2743 |
2728 #endif // V8_MIPS_LITHIUM_MIPS_H_ | 2744 #endif // V8_MIPS_LITHIUM_MIPS_H_ |
OLD | NEW |