| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 | 45 |
| 46 class LOperand : public ZoneObject { | 46 class LOperand : public ZoneObject { |
| 47 public: | 47 public: |
| 48 enum Kind { | 48 enum Kind { |
| 49 INVALID, | 49 INVALID, |
| 50 UNALLOCATED, | 50 UNALLOCATED, |
| 51 CONSTANT_OPERAND, | 51 CONSTANT_OPERAND, |
| 52 STACK_SLOT, | 52 STACK_SLOT, |
| 53 DOUBLE_STACK_SLOT, | 53 DOUBLE_STACK_SLOT, |
| 54 REGISTER, | 54 REGISTER, |
| 55 DOUBLE_REGISTER, | 55 DOUBLE_REGISTER |
| 56 ARGUMENT | |
| 57 }; | 56 }; |
| 58 | 57 |
| 59 LOperand() : value_(KindField::encode(INVALID)) { } | 58 LOperand() : value_(KindField::encode(INVALID)) { } |
| 60 | 59 |
| 61 Kind kind() const { return KindField::decode(value_); } | 60 Kind kind() const { return KindField::decode(value_); } |
| 62 int index() const { return static_cast<int>(value_) >> kKindFieldWidth; } | 61 int index() const { return static_cast<int>(value_) >> kKindFieldWidth; } |
| 63 #define LITHIUM_OPERAND_PREDICATE(name, type) \ | 62 #define LITHIUM_OPERAND_PREDICATE(name, type) \ |
| 64 bool Is##name() const { return kind() == type; } | 63 bool Is##name() const { return kind() == type; } |
| 65 LITHIUM_OPERAND_LIST(LITHIUM_OPERAND_PREDICATE) | 64 LITHIUM_OPERAND_LIST(LITHIUM_OPERAND_PREDICATE) |
| 66 LITHIUM_OPERAND_PREDICATE(Argument, ARGUMENT) | |
| 67 LITHIUM_OPERAND_PREDICATE(Unallocated, UNALLOCATED) | 65 LITHIUM_OPERAND_PREDICATE(Unallocated, UNALLOCATED) |
| 68 LITHIUM_OPERAND_PREDICATE(Ignored, INVALID) | 66 LITHIUM_OPERAND_PREDICATE(Ignored, INVALID) |
| 69 #undef LITHIUM_OPERAND_PREDICATE | 67 #undef LITHIUM_OPERAND_PREDICATE |
| 70 bool Equals(LOperand* other) const { return value_ == other->value_; } | 68 bool Equals(LOperand* other) const { return value_ == other->value_; } |
| 71 | 69 |
| 72 void PrintTo(StringStream* stream); | 70 void PrintTo(StringStream* stream); |
| 73 void ConvertTo(Kind kind, int index) { | 71 void ConvertTo(Kind kind, int index) { |
| 74 value_ = KindField::encode(kind); | 72 value_ = KindField::encode(kind); |
| 75 value_ |= index << kKindFieldWidth; | 73 value_ |= index << kKindFieldWidth; |
| 76 ASSERT(this->index() == index); | 74 ASSERT(this->index() == index); |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 | 333 |
| 336 private: | 334 private: |
| 337 static const int kNumCachedOperands = 128; | 335 static const int kNumCachedOperands = 128; |
| 338 static LConstantOperand* cache; | 336 static LConstantOperand* cache; |
| 339 | 337 |
| 340 LConstantOperand() : LOperand() { } | 338 LConstantOperand() : LOperand() { } |
| 341 explicit LConstantOperand(int index) : LOperand(CONSTANT_OPERAND, index) { } | 339 explicit LConstantOperand(int index) : LOperand(CONSTANT_OPERAND, index) { } |
| 342 }; | 340 }; |
| 343 | 341 |
| 344 | 342 |
| 345 class LArgument V8_FINAL : public LOperand { | |
| 346 public: | |
| 347 explicit LArgument(int index) : LOperand(ARGUMENT, index) { } | |
| 348 | |
| 349 static LArgument* cast(LOperand* op) { | |
| 350 ASSERT(op->IsArgument()); | |
| 351 return reinterpret_cast<LArgument*>(op); | |
| 352 } | |
| 353 }; | |
| 354 | |
| 355 | |
| 356 class LStackSlot V8_FINAL : public LOperand { | 343 class LStackSlot V8_FINAL : public LOperand { |
| 357 public: | 344 public: |
| 358 static LStackSlot* Create(int index, Zone* zone) { | 345 static LStackSlot* Create(int index, Zone* zone) { |
| 359 ASSERT(index >= 0); | 346 ASSERT(index >= 0); |
| 360 if (index < kNumCachedOperands) return &cache[index]; | 347 if (index < kNumCachedOperands) return &cache[index]; |
| 361 return new(zone) LStackSlot(index); | 348 return new(zone) LStackSlot(index); |
| 362 } | 349 } |
| 363 | 350 |
| 364 static LStackSlot* cast(LOperand* op) { | 351 static LStackSlot* cast(LOperand* op) { |
| 365 ASSERT(op->IsStackSlot()); | 352 ASSERT(op->IsStackSlot()); |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 672 void Advance() { | 659 void Advance() { |
| 673 ASSERT(!Done()); | 660 ASSERT(!Done()); |
| 674 ++current_; | 661 ++current_; |
| 675 SkipUninteresting(); | 662 SkipUninteresting(); |
| 676 } | 663 } |
| 677 | 664 |
| 678 LEnvironment* env() { return env_; } | 665 LEnvironment* env() { return env_; } |
| 679 | 666 |
| 680 private: | 667 private: |
| 681 bool ShouldSkip(LOperand* op) { | 668 bool ShouldSkip(LOperand* op) { |
| 682 return op == NULL || op->IsConstantOperand() || op->IsArgument(); | 669 return op == NULL || op->IsConstantOperand(); |
| 683 } | 670 } |
| 684 | 671 |
| 685 // Skip until something interesting, beginning with and including current_. | 672 // Skip until something interesting, beginning with and including current_. |
| 686 void SkipUninteresting() { | 673 void SkipUninteresting() { |
| 687 while (current_ < limit_ && ShouldSkip(env_->values()->at(current_))) { | 674 while (current_ < limit_ && ShouldSkip(env_->values()->at(current_))) { |
| 688 ++current_; | 675 ++current_; |
| 689 } | 676 } |
| 690 } | 677 } |
| 691 | 678 |
| 692 LEnvironment* env_; | 679 LEnvironment* env_; |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 838 private: | 825 private: |
| 839 LChunk* chunk_; | 826 LChunk* chunk_; |
| 840 | 827 |
| 841 DISALLOW_COPY_AND_ASSIGN(LPhase); | 828 DISALLOW_COPY_AND_ASSIGN(LPhase); |
| 842 }; | 829 }; |
| 843 | 830 |
| 844 | 831 |
| 845 } } // namespace v8::internal | 832 } } // namespace v8::internal |
| 846 | 833 |
| 847 #endif // V8_LITHIUM_H_ | 834 #endif // V8_LITHIUM_H_ |
| OLD | NEW |