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 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 | 199 |
200 #define DECLARE_HYDROGEN_ACCESSOR(type) \ | 200 #define DECLARE_HYDROGEN_ACCESSOR(type) \ |
201 H##type* hydrogen() const { \ | 201 H##type* hydrogen() const { \ |
202 return H##type::cast(hydrogen_value()); \ | 202 return H##type::cast(hydrogen_value()); \ |
203 } | 203 } |
204 | 204 |
205 | 205 |
206 class LInstruction: public ZoneObject { | 206 class LInstruction: public ZoneObject { |
207 public: | 207 public: |
208 LInstruction() | 208 LInstruction() |
209 : environment_(NULL), | 209 : environment_(NULL), |
210 hydrogen_value_(NULL), | 210 hydrogen_value_(NULL), |
211 is_call_(false) { } | 211 bit_field_(IsCallBits::encode(false)) { |
| 212 set_position(RelocInfo::kNoPosition); |
| 213 } |
212 | 214 |
213 virtual ~LInstruction() { } | 215 virtual ~LInstruction() { } |
214 | 216 |
215 virtual void CompileToNative(LCodeGen* generator) = 0; | 217 virtual void CompileToNative(LCodeGen* generator) = 0; |
216 virtual const char* Mnemonic() const = 0; | 218 virtual const char* Mnemonic() const = 0; |
217 virtual void PrintTo(StringStream* stream); | 219 virtual void PrintTo(StringStream* stream); |
218 virtual void PrintDataTo(StringStream* stream); | 220 virtual void PrintDataTo(StringStream* stream); |
219 virtual void PrintOutputOperandTo(StringStream* stream); | 221 virtual void PrintOutputOperandTo(StringStream* stream); |
220 | 222 |
221 enum Opcode { | 223 enum Opcode { |
(...skipping 19 matching lines...) Expand all Loading... |
241 virtual bool IsControl() const { return false; } | 243 virtual bool IsControl() const { return false; } |
242 | 244 |
243 void set_environment(LEnvironment* env) { environment_ = env; } | 245 void set_environment(LEnvironment* env) { environment_ = env; } |
244 LEnvironment* environment() const { return environment_; } | 246 LEnvironment* environment() const { return environment_; } |
245 bool HasEnvironment() const { return environment_ != NULL; } | 247 bool HasEnvironment() const { return environment_ != NULL; } |
246 | 248 |
247 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); } | 249 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); } |
248 LPointerMap* pointer_map() const { return pointer_map_.get(); } | 250 LPointerMap* pointer_map() const { return pointer_map_.get(); } |
249 bool HasPointerMap() const { return pointer_map_.is_set(); } | 251 bool HasPointerMap() const { return pointer_map_.is_set(); } |
250 | 252 |
| 253 // The 31 bits PositionBits is used to store the int position value. And the |
| 254 // position value may be RelocInfo::kNoPosition (-1). The accessor always |
| 255 // +1/-1 so that the encoded value of position in bit_field_ is always >= 0 |
| 256 // and can fit into the 31 bits PositionBits. |
| 257 void set_position(int pos) { |
| 258 bit_field_ = PositionBits::update(bit_field_, pos + 1); |
| 259 } |
| 260 int position() { return PositionBits::decode(bit_field_) - 1; } |
| 261 |
251 void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; } | 262 void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; } |
252 HValue* hydrogen_value() const { return hydrogen_value_; } | 263 HValue* hydrogen_value() const { return hydrogen_value_; } |
253 | 264 |
254 void MarkAsCall() { is_call_ = true; } | 265 void MarkAsCall() { bit_field_ = IsCallBits::update(bit_field_, true); } |
| 266 bool IsCall() const { return IsCallBits::decode(bit_field_); } |
255 | 267 |
256 // Interface to the register allocator and iterators. | 268 // Interface to the register allocator and iterators. |
257 bool ClobbersTemps() const { return is_call_; } | 269 bool ClobbersTemps() const { return IsCall(); } |
258 bool ClobbersRegisters() const { return is_call_; } | 270 bool ClobbersRegisters() const { return IsCall(); } |
259 bool ClobbersDoubleRegisters() const { return is_call_; } | 271 bool ClobbersDoubleRegisters() const { return IsCall(); } |
260 | 272 |
261 virtual void SetDeferredLazyDeoptimizationEnvironment(LEnvironment* env) { } | 273 virtual void SetDeferredLazyDeoptimizationEnvironment(LEnvironment* env) { } |
262 | 274 |
263 // Interface to the register allocator and iterators. | 275 // Interface to the register allocator and iterators. |
264 bool IsMarkedAsCall() const { return is_call_; } | 276 bool IsMarkedAsCall() const { return IsCall(); } |
265 | 277 |
266 virtual bool HasResult() const = 0; | 278 virtual bool HasResult() const = 0; |
267 virtual LOperand* result() const = 0; | 279 virtual LOperand* result() const = 0; |
268 | 280 |
269 LOperand* FirstInput() { return InputAt(0); } | 281 LOperand* FirstInput() { return InputAt(0); } |
270 LOperand* Output() { return HasResult() ? result() : NULL; } | 282 LOperand* Output() { return HasResult() ? result() : NULL; } |
271 | 283 |
272 virtual bool HasInterestingComment(LCodeGen* gen) const { return true; } | 284 virtual bool HasInterestingComment(LCodeGen* gen) const { return true; } |
273 | 285 |
274 #ifdef DEBUG | 286 #ifdef DEBUG |
275 void VerifyCall(); | 287 void VerifyCall(); |
276 #endif | 288 #endif |
277 | 289 |
278 private: | 290 private: |
279 // Iterator support. | 291 // Iterator support. |
280 friend class InputIterator; | 292 friend class InputIterator; |
281 virtual int InputCount() = 0; | 293 virtual int InputCount() = 0; |
282 virtual LOperand* InputAt(int i) = 0; | 294 virtual LOperand* InputAt(int i) = 0; |
283 | 295 |
284 friend class TempIterator; | 296 friend class TempIterator; |
285 virtual int TempCount() = 0; | 297 virtual int TempCount() = 0; |
286 virtual LOperand* TempAt(int i) = 0; | 298 virtual LOperand* TempAt(int i) = 0; |
287 | 299 |
| 300 class IsCallBits: public BitField<bool, 0, 1> {}; |
| 301 class PositionBits: public BitField<int, 1, 31> {}; |
| 302 |
288 LEnvironment* environment_; | 303 LEnvironment* environment_; |
289 SetOncePointer<LPointerMap> pointer_map_; | 304 SetOncePointer<LPointerMap> pointer_map_; |
290 HValue* hydrogen_value_; | 305 HValue* hydrogen_value_; |
291 bool is_call_; | 306 int bit_field_; |
292 }; | 307 }; |
293 | 308 |
294 | 309 |
295 // R = number of result operands (0 or 1). | 310 // R = number of result operands (0 or 1). |
296 // I = number of input operands. | 311 // I = number of input operands. |
297 // T = number of temporary operands. | 312 // T = number of temporary operands. |
298 template<int R, int I, int T> | 313 template<int R, int I, int T> |
299 class LTemplateInstruction: public LInstruction { | 314 class LTemplateInstruction: public LInstruction { |
300 public: | 315 public: |
301 // Allow 0 or 1 output operands. | 316 // Allow 0 or 1 output operands. |
(...skipping 2365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2667 | 2682 |
2668 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder); | 2683 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder); |
2669 }; | 2684 }; |
2670 | 2685 |
2671 #undef DECLARE_HYDROGEN_ACCESSOR | 2686 #undef DECLARE_HYDROGEN_ACCESSOR |
2672 #undef DECLARE_CONCRETE_INSTRUCTION | 2687 #undef DECLARE_CONCRETE_INSTRUCTION |
2673 | 2688 |
2674 } } // namespace v8::int | 2689 } } // namespace v8::int |
2675 | 2690 |
2676 #endif // V8_X64_LITHIUM_X64_H_ | 2691 #endif // V8_X64_LITHIUM_X64_H_ |
OLD | NEW |