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 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
203 | 203 |
204 | 204 |
205 #define DECLARE_HYDROGEN_ACCESSOR(type) \ | 205 #define DECLARE_HYDROGEN_ACCESSOR(type) \ |
206 H##type* hydrogen() const { \ | 206 H##type* hydrogen() const { \ |
207 return H##type::cast(hydrogen_value()); \ | 207 return H##type::cast(hydrogen_value()); \ |
208 } | 208 } |
209 | 209 |
210 | 210 |
211 class LInstruction: public ZoneObject { | 211 class LInstruction: public ZoneObject { |
212 public: | 212 public: |
213 LInstruction() | 213 LInstruction() : environment_(NULL), hydrogen_value_(NULL) { |
214 : environment_(NULL), | 214 bit_field_ = IsCallBits::encode(false) | |
215 hydrogen_value_(NULL), | 215 PositionBits::encode(RelocInfo::kNoPosition + 1); |
216 is_call_(false) { } | 216 } |
danno
2013/08/02 10:53:16
Build the constructor like this instead:
LInstruc
| |
217 | |
217 virtual ~LInstruction() { } | 218 virtual ~LInstruction() { } |
218 | 219 |
219 virtual void CompileToNative(LCodeGen* generator) = 0; | 220 virtual void CompileToNative(LCodeGen* generator) = 0; |
220 virtual const char* Mnemonic() const = 0; | 221 virtual const char* Mnemonic() const = 0; |
221 virtual void PrintTo(StringStream* stream); | 222 virtual void PrintTo(StringStream* stream); |
222 virtual void PrintDataTo(StringStream* stream); | 223 virtual void PrintDataTo(StringStream* stream); |
223 virtual void PrintOutputOperandTo(StringStream* stream); | 224 virtual void PrintOutputOperandTo(StringStream* stream); |
224 | 225 |
225 enum Opcode { | 226 enum Opcode { |
226 // Declare a unique enum value for each instruction. | 227 // Declare a unique enum value for each instruction. |
(...skipping 18 matching lines...) Expand all Loading... | |
245 virtual bool IsControl() const { return false; } | 246 virtual bool IsControl() const { return false; } |
246 | 247 |
247 void set_environment(LEnvironment* env) { environment_ = env; } | 248 void set_environment(LEnvironment* env) { environment_ = env; } |
248 LEnvironment* environment() const { return environment_; } | 249 LEnvironment* environment() const { return environment_; } |
249 bool HasEnvironment() const { return environment_ != NULL; } | 250 bool HasEnvironment() const { return environment_ != NULL; } |
250 | 251 |
251 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); } | 252 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); } |
252 LPointerMap* pointer_map() const { return pointer_map_.get(); } | 253 LPointerMap* pointer_map() const { return pointer_map_.get(); } |
253 bool HasPointerMap() const { return pointer_map_.is_set(); } | 254 bool HasPointerMap() const { return pointer_map_.is_set(); } |
254 | 255 |
256 // The 31 bits PositionBits is used to store the int position value. And the | |
257 // position value may be RelocInfo::kNoPosition (-1). The accessor always | |
258 // +1/-1 so that the encoded value of position in bit_field_ is always >= 0 | |
259 // and can fit into the 31 bits PositionBits. | |
260 void set_position(int pos) { | |
261 bit_field_ = PositionBits::update(bit_field_, pos + 1); | |
262 } | |
263 int position() { return PositionBits::decode(bit_field_) - 1; } | |
264 | |
255 void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; } | 265 void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; } |
256 HValue* hydrogen_value() const { return hydrogen_value_; } | 266 HValue* hydrogen_value() const { return hydrogen_value_; } |
257 | 267 |
258 virtual void SetDeferredLazyDeoptimizationEnvironment(LEnvironment* env) { } | 268 virtual void SetDeferredLazyDeoptimizationEnvironment(LEnvironment* env) { } |
259 | 269 |
260 void MarkAsCall() { is_call_ = true; } | 270 void MarkAsCall() { bit_field_ = IsCallBits::update(bit_field_, true); } |
261 | 271 |
262 // Interface to the register allocator and iterators. | 272 // Interface to the register allocator and iterators. |
263 bool ClobbersTemps() const { return is_call_; } | 273 bool ClobbersTemps() const { return IsCallBits::decode(bit_field_); } |
danno
2013/08/02 10:53:16
There should only be a single function that explic
| |
264 bool ClobbersRegisters() const { return is_call_; } | 274 bool ClobbersRegisters() const { return IsCallBits::decode(bit_field_); } |
265 bool ClobbersDoubleRegisters() const { return is_call_; } | 275 bool ClobbersDoubleRegisters() const { |
276 return IsCallBits::decode(bit_field_); | |
277 } | |
266 | 278 |
267 // Interface to the register allocator and iterators. | 279 // Interface to the register allocator and iterators. |
268 bool IsMarkedAsCall() const { return is_call_; } | 280 bool IsMarkedAsCall() const { return IsCallBits::decode(bit_field_); } |
269 | 281 |
270 virtual bool HasResult() const = 0; | 282 virtual bool HasResult() const = 0; |
271 virtual LOperand* result() const = 0; | 283 virtual LOperand* result() const = 0; |
272 | 284 |
273 LOperand* FirstInput() { return InputAt(0); } | 285 LOperand* FirstInput() { return InputAt(0); } |
274 LOperand* Output() { return HasResult() ? result() : NULL; } | 286 LOperand* Output() { return HasResult() ? result() : NULL; } |
275 | 287 |
276 virtual bool HasInterestingComment(LCodeGen* gen) const { return true; } | 288 virtual bool HasInterestingComment(LCodeGen* gen) const { return true; } |
277 | 289 |
278 #ifdef DEBUG | 290 #ifdef DEBUG |
279 void VerifyCall(); | 291 void VerifyCall(); |
280 #endif | 292 #endif |
281 | 293 |
282 private: | 294 private: |
283 // Iterator support. | 295 // Iterator support. |
284 friend class InputIterator; | 296 friend class InputIterator; |
285 virtual int InputCount() = 0; | 297 virtual int InputCount() = 0; |
286 virtual LOperand* InputAt(int i) = 0; | 298 virtual LOperand* InputAt(int i) = 0; |
287 | 299 |
288 friend class TempIterator; | 300 friend class TempIterator; |
289 virtual int TempCount() = 0; | 301 virtual int TempCount() = 0; |
290 virtual LOperand* TempAt(int i) = 0; | 302 virtual LOperand* TempAt(int i) = 0; |
291 | 303 |
danno
2013/08/02 10:53:16
coding standard nit: Please put the class definiti
| |
292 LEnvironment* environment_; | 304 LEnvironment* environment_; |
293 SetOncePointer<LPointerMap> pointer_map_; | 305 SetOncePointer<LPointerMap> pointer_map_; |
294 HValue* hydrogen_value_; | 306 HValue* hydrogen_value_; |
295 bool is_call_; | 307 int bit_field_; |
308 class IsCallBits: public BitField<bool, 0, 1> {}; | |
309 class PositionBits: public BitField<int, 1, 31> {}; | |
296 }; | 310 }; |
297 | 311 |
298 | 312 |
299 // R = number of result operands (0 or 1). | 313 // R = number of result operands (0 or 1). |
300 // I = number of input operands. | 314 // I = number of input operands. |
301 // T = number of temporary operands. | 315 // T = number of temporary operands. |
302 template<int R, int I, int T> | 316 template<int R, int I, int T> |
303 class LTemplateInstruction: public LInstruction { | 317 class LTemplateInstruction: public LInstruction { |
304 public: | 318 public: |
305 // Allow 0 or 1 output operands. | 319 // Allow 0 or 1 output operands. |
(...skipping 2487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2793 | 2807 |
2794 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder); | 2808 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder); |
2795 }; | 2809 }; |
2796 | 2810 |
2797 #undef DECLARE_HYDROGEN_ACCESSOR | 2811 #undef DECLARE_HYDROGEN_ACCESSOR |
2798 #undef DECLARE_CONCRETE_INSTRUCTION | 2812 #undef DECLARE_CONCRETE_INSTRUCTION |
2799 | 2813 |
2800 } } // namespace v8::internal | 2814 } } // namespace v8::internal |
2801 | 2815 |
2802 #endif // V8_ARM_LITHIUM_ARM_H_ | 2816 #endif // V8_ARM_LITHIUM_ARM_H_ |
OLD | NEW |