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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 V(CheckMap) \ | 87 V(CheckMap) \ |
88 V(CheckNonSmi) \ | 88 V(CheckNonSmi) \ |
89 V(CheckPrototypeMaps) \ | 89 V(CheckPrototypeMaps) \ |
90 V(CheckSmi) \ | 90 V(CheckSmi) \ |
91 V(ClampToUint8) \ | 91 V(ClampToUint8) \ |
92 V(ClassOfTest) \ | 92 V(ClassOfTest) \ |
93 V(Compare) \ | 93 V(Compare) \ |
94 V(CompareJSObjectEq) \ | 94 V(CompareJSObjectEq) \ |
95 V(CompareMap) \ | 95 V(CompareMap) \ |
96 V(CompareSymbolEq) \ | 96 V(CompareSymbolEq) \ |
| 97 V(CompareConstantEq) \ |
97 V(Constant) \ | 98 V(Constant) \ |
98 V(Context) \ | 99 V(Context) \ |
99 V(DeleteProperty) \ | 100 V(DeleteProperty) \ |
100 V(Deoptimize) \ | 101 V(Deoptimize) \ |
101 V(Div) \ | 102 V(Div) \ |
| 103 V(ElementsKind) \ |
102 V(EnterInlined) \ | 104 V(EnterInlined) \ |
103 V(ExternalArrayLength) \ | 105 V(ExternalArrayLength) \ |
104 V(FixedArrayLength) \ | 106 V(FixedArrayLength) \ |
105 V(ForceRepresentation) \ | 107 V(ForceRepresentation) \ |
106 V(FunctionLiteral) \ | 108 V(FunctionLiteral) \ |
107 V(GetCachedArrayIndex) \ | 109 V(GetCachedArrayIndex) \ |
108 V(GlobalObject) \ | 110 V(GlobalObject) \ |
109 V(GlobalReceiver) \ | 111 V(GlobalReceiver) \ |
110 V(Goto) \ | 112 V(Goto) \ |
111 V(HasCachedArrayIndex) \ | 113 V(HasCachedArrayIndex) \ |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 enum Type { | 397 enum Type { |
396 kTagged = 0x1, // 0000 0000 0000 0001 | 398 kTagged = 0x1, // 0000 0000 0000 0001 |
397 kTaggedPrimitive = 0x5, // 0000 0000 0000 0101 | 399 kTaggedPrimitive = 0x5, // 0000 0000 0000 0101 |
398 kTaggedNumber = 0xd, // 0000 0000 0000 1101 | 400 kTaggedNumber = 0xd, // 0000 0000 0000 1101 |
399 kSmi = 0x1d, // 0000 0000 0001 1101 | 401 kSmi = 0x1d, // 0000 0000 0001 1101 |
400 kHeapNumber = 0x2d, // 0000 0000 0010 1101 | 402 kHeapNumber = 0x2d, // 0000 0000 0010 1101 |
401 kString = 0x45, // 0000 0000 0100 0101 | 403 kString = 0x45, // 0000 0000 0100 0101 |
402 kBoolean = 0x85, // 0000 0000 1000 0101 | 404 kBoolean = 0x85, // 0000 0000 1000 0101 |
403 kNonPrimitive = 0x101, // 0000 0001 0000 0001 | 405 kNonPrimitive = 0x101, // 0000 0001 0000 0001 |
404 kJSObject = 0x301, // 0000 0011 0000 0001 | 406 kJSObject = 0x301, // 0000 0011 0000 0001 |
405 kJSArray = 0x701, // 0000 0111 1000 0001 | 407 kJSArray = 0x701, // 0000 0111 0000 0001 |
406 kUninitialized = 0x1fff // 0001 1111 1111 1111 | 408 kUninitialized = 0x1fff // 0001 1111 1111 1111 |
407 }; | 409 }; |
408 | 410 |
409 // Make sure type fits in int16. | 411 // Make sure type fits in int16. |
410 STATIC_ASSERT(kUninitialized < (1 << (2 * kBitsPerByte))); | 412 STATIC_ASSERT(kUninitialized < (1 << (2 * kBitsPerByte))); |
411 | 413 |
412 explicit HType(Type t) : type_(t) { } | 414 explicit HType(Type t) : type_(t) { } |
413 | 415 |
414 int16_t type_; | 416 int16_t type_; |
415 }; | 417 }; |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
477 | 479 |
478 // There must be one corresponding kDepends flag for every kChanges flag and | 480 // There must be one corresponding kDepends flag for every kChanges flag and |
479 // the order of the kChanges flags must be exactly the same as of the kDepends | 481 // the order of the kChanges flags must be exactly the same as of the kDepends |
480 // flags. | 482 // flags. |
481 enum Flag { | 483 enum Flag { |
482 // Declare global value numbering flags. | 484 // Declare global value numbering flags. |
483 #define DECLARE_DO(type) kChanges##type, kDependsOn##type, | 485 #define DECLARE_DO(type) kChanges##type, kDependsOn##type, |
484 GVN_FLAG_LIST(DECLARE_DO) | 486 GVN_FLAG_LIST(DECLARE_DO) |
485 #undef DECLARE_DO | 487 #undef DECLARE_DO |
486 kFlexibleRepresentation, | 488 kFlexibleRepresentation, |
| 489 // Participate in Global Value Numbering, i.e. elimination of |
| 490 // unnecessary recomputations. If an instruction sets this flag, it must |
| 491 // implement DataEquals(), which will be used to determine if other |
| 492 // occurrences of the instruction are indeed the same. |
487 kUseGVN, | 493 kUseGVN, |
488 kCanOverflow, | 494 kCanOverflow, |
489 kBailoutOnMinusZero, | 495 kBailoutOnMinusZero, |
490 kCanBeDivByZero, | 496 kCanBeDivByZero, |
491 kDeoptimizeOnUndefined, | 497 kDeoptimizeOnUndefined, |
492 kIsArguments, | 498 kIsArguments, |
493 kTruncatingToInt32, | 499 kTruncatingToInt32, |
494 kLastFlag = kTruncatingToInt32 | 500 kLastFlag = kTruncatingToInt32 |
495 }; | 501 }; |
496 | 502 |
(...skipping 1203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1700 return Representation::Tagged(); | 1706 return Representation::Tagged(); |
1701 } | 1707 } |
1702 | 1708 |
1703 DECLARE_CONCRETE_INSTRUCTION(ExternalArrayLength) | 1709 DECLARE_CONCRETE_INSTRUCTION(ExternalArrayLength) |
1704 | 1710 |
1705 protected: | 1711 protected: |
1706 virtual bool DataEquals(HValue* other) { return true; } | 1712 virtual bool DataEquals(HValue* other) { return true; } |
1707 }; | 1713 }; |
1708 | 1714 |
1709 | 1715 |
| 1716 class HElementsKind: public HUnaryOperation { |
| 1717 public: |
| 1718 explicit HElementsKind(HValue* value) : HUnaryOperation(value) { |
| 1719 set_representation(Representation::Integer32()); |
| 1720 SetFlag(kUseGVN); |
| 1721 SetFlag(kDependsOnMaps); |
| 1722 } |
| 1723 |
| 1724 virtual Representation RequiredInputRepresentation(int index) const { |
| 1725 return Representation::Tagged(); |
| 1726 } |
| 1727 |
| 1728 DECLARE_CONCRETE_INSTRUCTION(ElementsKind) |
| 1729 |
| 1730 protected: |
| 1731 virtual bool DataEquals(HValue* other) { return true; } |
| 1732 }; |
| 1733 |
| 1734 |
1710 class HBitNot: public HUnaryOperation { | 1735 class HBitNot: public HUnaryOperation { |
1711 public: | 1736 public: |
1712 explicit HBitNot(HValue* value) : HUnaryOperation(value) { | 1737 explicit HBitNot(HValue* value) : HUnaryOperation(value) { |
1713 set_representation(Representation::Integer32()); | 1738 set_representation(Representation::Integer32()); |
1714 SetFlag(kUseGVN); | 1739 SetFlag(kUseGVN); |
1715 SetFlag(kTruncatingToInt32); | 1740 SetFlag(kTruncatingToInt32); |
1716 } | 1741 } |
1717 | 1742 |
1718 virtual Representation RequiredInputRepresentation(int index) const { | 1743 virtual Representation RequiredInputRepresentation(int index) const { |
1719 return Representation::Integer32(); | 1744 return Representation::Integer32(); |
(...skipping 862 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2582 protected: | 2607 protected: |
2583 virtual bool DataEquals(HValue* other) { | 2608 virtual bool DataEquals(HValue* other) { |
2584 return op_ == HCompareSymbolEq::cast(other)->op_; | 2609 return op_ == HCompareSymbolEq::cast(other)->op_; |
2585 } | 2610 } |
2586 | 2611 |
2587 private: | 2612 private: |
2588 const Token::Value op_; | 2613 const Token::Value op_; |
2589 }; | 2614 }; |
2590 | 2615 |
2591 | 2616 |
| 2617 class HCompareConstantEq: public HUnaryOperation { |
| 2618 public: |
| 2619 HCompareConstantEq(HValue* left, int right, Token::Value op) |
| 2620 : HUnaryOperation(left), op_(op), right_(right) { |
| 2621 ASSERT(op == Token::EQ_STRICT); |
| 2622 set_representation(Representation::Tagged()); |
| 2623 SetFlag(kUseGVN); |
| 2624 } |
| 2625 |
| 2626 Token::Value op() const { return op_; } |
| 2627 int right() const { return right_; } |
| 2628 |
| 2629 virtual bool EmitAtUses() { |
| 2630 return !HasSideEffects() && !HasMultipleUses(); |
| 2631 } |
| 2632 |
| 2633 virtual Representation RequiredInputRepresentation(int index) const { |
| 2634 return Representation::Integer32(); |
| 2635 } |
| 2636 |
| 2637 virtual HType CalculateInferredType() { return HType::Boolean(); } |
| 2638 |
| 2639 DECLARE_CONCRETE_INSTRUCTION(CompareConstantEq); |
| 2640 |
| 2641 protected: |
| 2642 virtual bool DataEquals(HValue* other) { |
| 2643 HCompareConstantEq* other_instr = HCompareConstantEq::cast(other); |
| 2644 return (op_ == other_instr->op_ && |
| 2645 right_ == other_instr->right_); |
| 2646 } |
| 2647 |
| 2648 private: |
| 2649 const Token::Value op_; |
| 2650 const int right_; |
| 2651 }; |
| 2652 |
| 2653 |
2592 class HUnaryPredicate: public HUnaryOperation { | 2654 class HUnaryPredicate: public HUnaryOperation { |
2593 public: | 2655 public: |
2594 explicit HUnaryPredicate(HValue* value) : HUnaryOperation(value) { | 2656 explicit HUnaryPredicate(HValue* value) : HUnaryOperation(value) { |
2595 set_representation(Representation::Tagged()); | 2657 set_representation(Representation::Tagged()); |
2596 SetFlag(kUseGVN); | 2658 SetFlag(kUseGVN); |
2597 } | 2659 } |
2598 | 2660 |
2599 virtual bool EmitAtUses() { | 2661 virtual bool EmitAtUses() { |
2600 return !HasSideEffects() && !HasMultipleUses(); | 2662 return !HasSideEffects() && !HasMultipleUses(); |
2601 } | 2663 } |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2687 HHasInstanceType(HValue* value, InstanceType type) | 2749 HHasInstanceType(HValue* value, InstanceType type) |
2688 : HUnaryPredicate(value), from_(type), to_(type) { } | 2750 : HUnaryPredicate(value), from_(type), to_(type) { } |
2689 HHasInstanceType(HValue* value, InstanceType from, InstanceType to) | 2751 HHasInstanceType(HValue* value, InstanceType from, InstanceType to) |
2690 : HUnaryPredicate(value), from_(from), to_(to) { | 2752 : HUnaryPredicate(value), from_(from), to_(to) { |
2691 ASSERT(to == LAST_TYPE); // Others not implemented yet in backend. | 2753 ASSERT(to == LAST_TYPE); // Others not implemented yet in backend. |
2692 } | 2754 } |
2693 | 2755 |
2694 InstanceType from() { return from_; } | 2756 InstanceType from() { return from_; } |
2695 InstanceType to() { return to_; } | 2757 InstanceType to() { return to_; } |
2696 | 2758 |
| 2759 virtual bool EmitAtUses() { |
| 2760 return !HasSideEffects() && !HasMultipleUses(); |
| 2761 } |
| 2762 |
2697 virtual void PrintDataTo(StringStream* stream); | 2763 virtual void PrintDataTo(StringStream* stream); |
2698 | 2764 |
2699 DECLARE_CONCRETE_INSTRUCTION(HasInstanceType) | 2765 DECLARE_CONCRETE_INSTRUCTION(HasInstanceType) |
2700 | 2766 |
2701 protected: | 2767 protected: |
2702 virtual bool DataEquals(HValue* other) { | 2768 virtual bool DataEquals(HValue* other) { |
2703 HHasInstanceType* b = HHasInstanceType::cast(other); | 2769 HHasInstanceType* b = HHasInstanceType::cast(other); |
2704 return (from_ == b->from()) && (to_ == b->to()); | 2770 return (from_ == b->from()) && (to_ == b->to()); |
2705 } | 2771 } |
2706 | 2772 |
(...skipping 1329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4036 | 4102 |
4037 DECLARE_CONCRETE_INSTRUCTION(In) | 4103 DECLARE_CONCRETE_INSTRUCTION(In) |
4038 }; | 4104 }; |
4039 | 4105 |
4040 #undef DECLARE_INSTRUCTION | 4106 #undef DECLARE_INSTRUCTION |
4041 #undef DECLARE_CONCRETE_INSTRUCTION | 4107 #undef DECLARE_CONCRETE_INSTRUCTION |
4042 | 4108 |
4043 } } // namespace v8::internal | 4109 } } // namespace v8::internal |
4044 | 4110 |
4045 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ | 4111 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ |
OLD | NEW |