OLD | NEW |
---|---|
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
284 | 284 |
285 #define DECLARE_HYDROGEN_ACCESSOR(type) \ | 285 #define DECLARE_HYDROGEN_ACCESSOR(type) \ |
286 H##type* hydrogen() const { \ | 286 H##type* hydrogen() const { \ |
287 return H##type::cast(hydrogen_value()); \ | 287 return H##type::cast(hydrogen_value()); \ |
288 } | 288 } |
289 | 289 |
290 | 290 |
291 class LInstruction: public ZoneObject { | 291 class LInstruction: public ZoneObject { |
292 public: | 292 public: |
293 LInstruction() | 293 LInstruction() |
294 : hydrogen_value_(NULL) { } | 294 : hydrogen_value_(NULL), is_call_(false), is_save_doubles_(false) { } |
295 virtual ~LInstruction() { } | 295 virtual ~LInstruction() { } |
296 | 296 |
297 virtual void CompileToNative(LCodeGen* generator) = 0; | 297 virtual void CompileToNative(LCodeGen* generator) = 0; |
298 virtual const char* Mnemonic() const = 0; | 298 virtual const char* Mnemonic() const = 0; |
299 virtual void PrintTo(StringStream* stream); | 299 virtual void PrintTo(StringStream* stream); |
300 virtual void PrintDataTo(StringStream* stream) = 0; | 300 virtual void PrintDataTo(StringStream* stream) = 0; |
301 virtual void PrintOutputOperandTo(StringStream* stream) = 0; | 301 virtual void PrintOutputOperandTo(StringStream* stream) = 0; |
302 | 302 |
303 // Declare virtual type testers. | 303 // Declare virtual type testers. |
304 #define DECLARE_DO(type) virtual bool Is##type() const { return false; } | 304 #define DECLARE_DO(type) virtual bool Is##type() const { return false; } |
305 LITHIUM_ALL_INSTRUCTION_LIST(DECLARE_DO) | 305 LITHIUM_ALL_INSTRUCTION_LIST(DECLARE_DO) |
306 #undef DECLARE_DO | 306 #undef DECLARE_DO |
307 | 307 |
308 virtual bool IsControl() const { return false; } | 308 virtual bool IsControl() const { return false; } |
309 virtual void SetBranchTargets(int true_block_id, int false_block_id) { } | 309 virtual void SetBranchTargets(int true_block_id, int false_block_id) { } |
310 | 310 |
311 void set_environment(LEnvironment* env) { environment_.set(env); } | 311 void set_environment(LEnvironment* env) { environment_.set(env); } |
312 LEnvironment* environment() const { return environment_.get(); } | 312 LEnvironment* environment() const { return environment_.get(); } |
313 bool HasEnvironment() const { return environment_.is_set(); } | 313 bool HasEnvironment() const { return environment_.is_set(); } |
314 | 314 |
315 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); } | 315 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); } |
316 LPointerMap* pointer_map() const { return pointer_map_.get(); } | 316 LPointerMap* pointer_map() const { return pointer_map_.get(); } |
317 bool HasPointerMap() const { return pointer_map_.is_set(); } | 317 bool HasPointerMap() const { return pointer_map_.is_set(); } |
318 | 318 |
319 virtual bool HasResult() const = 0; | |
320 | 319 |
321 void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; } | 320 void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; } |
322 HValue* hydrogen_value() const { return hydrogen_value_; } | 321 HValue* hydrogen_value() const { return hydrogen_value_; } |
323 | 322 |
324 void set_deoptimization_environment(LEnvironment* env) { | 323 void set_deoptimization_environment(LEnvironment* env) { |
325 deoptimization_environment_.set(env); | 324 deoptimization_environment_.set(env); |
326 } | 325 } |
327 LEnvironment* deoptimization_environment() const { | 326 LEnvironment* deoptimization_environment() const { |
328 return deoptimization_environment_.get(); | 327 return deoptimization_environment_.get(); |
329 } | 328 } |
330 bool HasDeoptimizationEnvironment() const { | 329 bool HasDeoptimizationEnvironment() const { |
331 return deoptimization_environment_.is_set(); | 330 return deoptimization_environment_.is_set(); |
332 } | 331 } |
333 | 332 |
333 void MarkAsCall() { is_call_ = true; } | |
334 void MarkAsSaveDoubles() { is_save_doubles_ = true; } | |
335 | |
336 // Interface to the register allocator and iterators. | |
337 bool IsMarkedAsCall() const { return is_call_; } | |
338 bool IsSaveDoubles() const { return is_save_doubles_; } | |
Kevin Millikin (Chromium)
2011/01/20 12:20:30
These two names are not entirely consistent: is_th
fschneider
2011/01/20 17:13:08
IsCall is already taken as the name of the type-te
| |
339 | |
340 virtual bool HasResult() const = 0; | |
Kevin Millikin (Chromium)
2011/01/20 12:20:30
const doesn't care if it has extra spaces around i
fschneider
2011/01/20 17:13:08
Done.
| |
341 virtual LOperand* result() = 0; | |
342 | |
343 virtual int InputCount() = 0; | |
344 virtual LOperand* InputAt(int i) = 0; | |
345 virtual int TempCount() = 0; | |
346 virtual LOperand* TempAt(int i) = 0; | |
347 | |
348 TempIterator GetTempIterator(); | |
349 UseIterator GetUseIterator(); | |
350 LOperand* FirstInput() { return InputAt(0); } | |
351 LOperand* Output() { return HasResult() ? result() : NULL; } | |
352 | |
353 #ifdef DEBUG | |
354 void VerifyCall(); | |
355 #endif | |
356 | |
334 private: | 357 private: |
335 SetOncePointer<LEnvironment> environment_; | 358 SetOncePointer<LEnvironment> environment_; |
336 SetOncePointer<LPointerMap> pointer_map_; | 359 SetOncePointer<LPointerMap> pointer_map_; |
337 HValue* hydrogen_value_; | 360 HValue* hydrogen_value_; |
338 SetOncePointer<LEnvironment> deoptimization_environment_; | 361 SetOncePointer<LEnvironment> deoptimization_environment_; |
362 bool is_call_; | |
363 bool is_save_doubles_; | |
339 }; | 364 }; |
340 | 365 |
341 | 366 |
342 template<typename T, int N> | 367 template<typename T, int N> |
343 class OperandContainer { | 368 class OperandContainer { |
344 public: | 369 public: |
345 OperandContainer() { | 370 OperandContainer() { |
346 for (int i = 0; i < N; i++) elems_[i] = NULL; | 371 for (int i = 0; i < N; i++) elems_[i] = NULL; |
347 } | 372 } |
348 int length() { return N; } | 373 int length() { return N; } |
349 T& operator[](int i) { | 374 T& operator[](int i) { |
350 ASSERT(i < length()); | 375 ASSERT(i < length()); |
351 return elems_[i]; | 376 return elems_[i]; |
352 } | 377 } |
353 void PrintOperandsTo(StringStream* stream); | 378 void PrintOperandsTo(StringStream* stream); |
354 | 379 |
355 private: | 380 private: |
356 T elems_[N]; | 381 T elems_[N]; |
357 }; | 382 }; |
358 | 383 |
359 | 384 |
360 template<typename T> | 385 template<typename T> |
361 class OperandContainer<T, 0> { | 386 class OperandContainer<T, 0> { |
362 public: | 387 public: |
363 int length() { return 0; } | 388 int length() { return 0; } |
364 void PrintOperandsTo(StringStream* stream) { } | 389 void PrintOperandsTo(StringStream* stream) { } |
390 T& operator[](int i) { | |
391 UNREACHABLE(); | |
392 static T t = NULL; | |
Kevin Millikin (Chromium)
2011/01/20 12:20:30
Do we really write NULL and not 0 to initialize a
fschneider
2011/01/20 17:13:08
Done.
| |
393 return t; | |
394 } | |
365 }; | 395 }; |
366 | 396 |
367 | 397 |
368 template<int R, int I, int T = 0> | 398 template<int R, int I, int T = 0> |
369 class LTemplateInstruction: public LInstruction { | 399 class LTemplateInstruction: public LInstruction { |
370 public: | 400 public: |
371 // Allow 0 or 1 output operands. | 401 // Allow 0 or 1 output operands. |
372 STATIC_ASSERT(R == 0 || R == 1); | 402 STATIC_ASSERT(R == 0 || R == 1); |
373 virtual bool HasResult() const { return R != 0; } | 403 virtual bool HasResult() const { return R != 0; } |
374 void set_result(LOperand* operand) { results_[0] = operand; } | 404 void set_result(LOperand* operand) { results_[0] = operand; } |
(...skipping 1643 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2018 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder); | 2048 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder); |
2019 }; | 2049 }; |
2020 | 2050 |
2021 #undef DECLARE_HYDROGEN_ACCESSOR | 2051 #undef DECLARE_HYDROGEN_ACCESSOR |
2022 #undef DECLARE_INSTRUCTION | 2052 #undef DECLARE_INSTRUCTION |
2023 #undef DECLARE_CONCRETE_INSTRUCTION | 2053 #undef DECLARE_CONCRETE_INSTRUCTION |
2024 | 2054 |
2025 } } // namespace v8::internal | 2055 } } // namespace v8::internal |
2026 | 2056 |
2027 #endif // V8_IA32_LITHIUM_IA32_H_ | 2057 #endif // V8_IA32_LITHIUM_IA32_H_ |
OLD | NEW |