| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef V8_COMPILER_INSTRUCTION_H_ | 5 #ifndef V8_COMPILER_INSTRUCTION_H_ |
| 6 #define V8_COMPILER_INSTRUCTION_H_ | 6 #define V8_COMPILER_INSTRUCTION_H_ |
| 7 | 7 |
| 8 #include <deque> | 8 #include <deque> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <set> | 10 #include <set> |
| (...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 651 SourcePosition source_position_; | 651 SourcePosition source_position_; |
| 652 }; | 652 }; |
| 653 | 653 |
| 654 | 654 |
| 655 class Constant FINAL { | 655 class Constant FINAL { |
| 656 public: | 656 public: |
| 657 enum Type { kInt32, kInt64, kFloat64, kExternalReference, kHeapObject }; | 657 enum Type { kInt32, kInt64, kFloat64, kExternalReference, kHeapObject }; |
| 658 | 658 |
| 659 explicit Constant(int32_t v) : type_(kInt32), value_(v) {} | 659 explicit Constant(int32_t v) : type_(kInt32), value_(v) {} |
| 660 explicit Constant(int64_t v) : type_(kInt64), value_(v) {} | 660 explicit Constant(int64_t v) : type_(kInt64), value_(v) {} |
| 661 explicit Constant(double v) : type_(kFloat64), value_(BitCast<int64_t>(v)) {} | 661 explicit Constant(double v) : type_(kFloat64), value_(bit_cast<int64_t>(v)) {} |
| 662 explicit Constant(ExternalReference ref) | 662 explicit Constant(ExternalReference ref) |
| 663 : type_(kExternalReference), value_(BitCast<intptr_t>(ref)) {} | 663 : type_(kExternalReference), value_(bit_cast<intptr_t>(ref)) {} |
| 664 explicit Constant(Handle<HeapObject> obj) | 664 explicit Constant(Handle<HeapObject> obj) |
| 665 : type_(kHeapObject), value_(BitCast<intptr_t>(obj)) {} | 665 : type_(kHeapObject), value_(bit_cast<intptr_t>(obj)) {} |
| 666 | 666 |
| 667 Type type() const { return type_; } | 667 Type type() const { return type_; } |
| 668 | 668 |
| 669 int32_t ToInt32() const { | 669 int32_t ToInt32() const { |
| 670 DCHECK_EQ(kInt32, type()); | 670 DCHECK_EQ(kInt32, type()); |
| 671 return static_cast<int32_t>(value_); | 671 return static_cast<int32_t>(value_); |
| 672 } | 672 } |
| 673 | 673 |
| 674 int64_t ToInt64() const { | 674 int64_t ToInt64() const { |
| 675 if (type() == kInt32) return ToInt32(); | 675 if (type() == kInt32) return ToInt32(); |
| 676 DCHECK_EQ(kInt64, type()); | 676 DCHECK_EQ(kInt64, type()); |
| 677 return value_; | 677 return value_; |
| 678 } | 678 } |
| 679 | 679 |
| 680 double ToFloat64() const { | 680 double ToFloat64() const { |
| 681 if (type() == kInt32) return ToInt32(); | 681 if (type() == kInt32) return ToInt32(); |
| 682 DCHECK_EQ(kFloat64, type()); | 682 DCHECK_EQ(kFloat64, type()); |
| 683 return BitCast<double>(value_); | 683 return bit_cast<double>(value_); |
| 684 } | 684 } |
| 685 | 685 |
| 686 ExternalReference ToExternalReference() const { | 686 ExternalReference ToExternalReference() const { |
| 687 DCHECK_EQ(kExternalReference, type()); | 687 DCHECK_EQ(kExternalReference, type()); |
| 688 return BitCast<ExternalReference>(static_cast<intptr_t>(value_)); | 688 return bit_cast<ExternalReference>(static_cast<intptr_t>(value_)); |
| 689 } | 689 } |
| 690 | 690 |
| 691 Handle<HeapObject> ToHeapObject() const { | 691 Handle<HeapObject> ToHeapObject() const { |
| 692 DCHECK_EQ(kHeapObject, type()); | 692 DCHECK_EQ(kHeapObject, type()); |
| 693 return BitCast<Handle<HeapObject> >(static_cast<intptr_t>(value_)); | 693 return bit_cast<Handle<HeapObject> >(static_cast<intptr_t>(value_)); |
| 694 } | 694 } |
| 695 | 695 |
| 696 private: | 696 private: |
| 697 Type type_; | 697 Type type_; |
| 698 int64_t value_; | 698 int64_t value_; |
| 699 }; | 699 }; |
| 700 | 700 |
| 701 | 701 |
| 702 class FrameStateDescriptor : public ZoneObject { | 702 class FrameStateDescriptor : public ZoneObject { |
| 703 public: | 703 public: |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 902 DeoptimizationVector deoptimization_entries_; | 902 DeoptimizationVector deoptimization_entries_; |
| 903 }; | 903 }; |
| 904 | 904 |
| 905 OStream& operator<<(OStream& os, const InstructionSequence& code); | 905 OStream& operator<<(OStream& os, const InstructionSequence& code); |
| 906 | 906 |
| 907 } // namespace compiler | 907 } // namespace compiler |
| 908 } // namespace internal | 908 } // namespace internal |
| 909 } // namespace v8 | 909 } // namespace v8 |
| 910 | 910 |
| 911 #endif // V8_COMPILER_INSTRUCTION_H_ | 911 #endif // V8_COMPILER_INSTRUCTION_H_ |
| OLD | NEW |