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 1434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1445 virtual Representation RequiredInputRepresentation(int index) { | 1445 virtual Representation RequiredInputRepresentation(int index) { |
1446 return Representation::None(); | 1446 return Representation::None(); |
1447 } | 1447 } |
1448 | 1448 |
1449 DECLARE_CONCRETE_INSTRUCTION(BlockEntry) | 1449 DECLARE_CONCRETE_INSTRUCTION(BlockEntry) |
1450 }; | 1450 }; |
1451 | 1451 |
1452 | 1452 |
1453 class HDummyUse: public HTemplateInstruction<1> { | 1453 class HDummyUse: public HTemplateInstruction<1> { |
1454 public: | 1454 public: |
1455 explicit HDummyUse(HValue* value) { | 1455 explicit HDummyUse(HValue* value) |
| 1456 : HTemplateInstruction<1>(HType::Smi()) { |
1456 SetOperandAt(0, value); | 1457 SetOperandAt(0, value); |
1457 // Pretend to be a Smi so that the HChange instructions inserted | 1458 // Pretend to be a Smi so that the HChange instructions inserted |
1458 // before any use generate as little code as possible. | 1459 // before any use generate as little code as possible. |
1459 set_representation(Representation::Tagged()); | 1460 set_representation(Representation::Tagged()); |
1460 set_type(HType::Smi()); | |
1461 } | 1461 } |
1462 | 1462 |
1463 HValue* value() { return OperandAt(0); } | 1463 HValue* value() { return OperandAt(0); } |
1464 | 1464 |
1465 virtual bool HasEscapingOperandAt(int index) { return false; } | 1465 virtual bool HasEscapingOperandAt(int index) { return false; } |
1466 virtual Representation RequiredInputRepresentation(int index) { | 1466 virtual Representation RequiredInputRepresentation(int index) { |
1467 return Representation::None(); | 1467 return Representation::None(); |
1468 } | 1468 } |
1469 | 1469 |
1470 virtual void PrintDataTo(StringStream* stream); | 1470 virtual void PrintDataTo(StringStream* stream); |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1659 virtual Representation RequiredInputRepresentation(int index) { | 1659 virtual Representation RequiredInputRepresentation(int index) { |
1660 return Representation::None(); | 1660 return Representation::None(); |
1661 } | 1661 } |
1662 | 1662 |
1663 DECLARE_CONCRETE_INSTRUCTION(AbnormalExit) | 1663 DECLARE_CONCRETE_INSTRUCTION(AbnormalExit) |
1664 }; | 1664 }; |
1665 | 1665 |
1666 | 1666 |
1667 class HUnaryOperation: public HTemplateInstruction<1> { | 1667 class HUnaryOperation: public HTemplateInstruction<1> { |
1668 public: | 1668 public: |
1669 explicit HUnaryOperation(HValue* value) { | 1669 HUnaryOperation(HValue* value, HType type = HType::Tagged()) |
| 1670 : HTemplateInstruction<1>(type) { |
1670 SetOperandAt(0, value); | 1671 SetOperandAt(0, value); |
1671 } | 1672 } |
1672 | 1673 |
1673 static HUnaryOperation* cast(HValue* value) { | 1674 static HUnaryOperation* cast(HValue* value) { |
1674 return reinterpret_cast<HUnaryOperation*>(value); | 1675 return reinterpret_cast<HUnaryOperation*>(value); |
1675 } | 1676 } |
1676 | 1677 |
1677 HValue* value() const { return OperandAt(0); } | 1678 HValue* value() const { return OperandAt(0); } |
1678 virtual void PrintDataTo(StringStream* stream); | 1679 virtual void PrintDataTo(StringStream* stream); |
1679 }; | 1680 }; |
(...skipping 824 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2504 DECLARE_CONCRETE_INSTRUCTION(CallRuntime) | 2505 DECLARE_CONCRETE_INSTRUCTION(CallRuntime) |
2505 | 2506 |
2506 private: | 2507 private: |
2507 const Runtime::Function* c_function_; | 2508 const Runtime::Function* c_function_; |
2508 Handle<String> name_; | 2509 Handle<String> name_; |
2509 }; | 2510 }; |
2510 | 2511 |
2511 | 2512 |
2512 class HMapEnumLength: public HUnaryOperation { | 2513 class HMapEnumLength: public HUnaryOperation { |
2513 public: | 2514 public: |
2514 explicit HMapEnumLength(HValue* value) : HUnaryOperation(value) { | 2515 explicit HMapEnumLength(HValue* value) |
2515 set_type(HType::Smi()); | 2516 : HUnaryOperation(value, HType::Smi()) { |
2516 set_representation(Representation::Smi()); | 2517 set_representation(Representation::Smi()); |
2517 SetFlag(kUseGVN); | 2518 SetFlag(kUseGVN); |
2518 SetGVNFlag(kDependsOnMaps); | 2519 SetGVNFlag(kDependsOnMaps); |
2519 } | 2520 } |
2520 | 2521 |
2521 virtual Representation RequiredInputRepresentation(int index) { | 2522 virtual Representation RequiredInputRepresentation(int index) { |
2522 return Representation::Tagged(); | 2523 return Representation::Tagged(); |
2523 } | 2524 } |
2524 | 2525 |
2525 DECLARE_CONCRETE_INSTRUCTION(MapEnumLength) | 2526 DECLARE_CONCRETE_INSTRUCTION(MapEnumLength) |
(...skipping 23 matching lines...) Expand all Loading... |
2549 protected: | 2550 protected: |
2550 virtual bool DataEquals(HValue* other) { return true; } | 2551 virtual bool DataEquals(HValue* other) { return true; } |
2551 | 2552 |
2552 private: | 2553 private: |
2553 virtual bool IsDeletable() const { return true; } | 2554 virtual bool IsDeletable() const { return true; } |
2554 }; | 2555 }; |
2555 | 2556 |
2556 | 2557 |
2557 class HBitNot: public HUnaryOperation { | 2558 class HBitNot: public HUnaryOperation { |
2558 public: | 2559 public: |
2559 explicit HBitNot(HValue* value) : HUnaryOperation(value) { | 2560 explicit HBitNot(HValue* value) |
| 2561 : HUnaryOperation(value, HType::TaggedNumber()) { |
2560 set_representation(Representation::Integer32()); | 2562 set_representation(Representation::Integer32()); |
2561 SetFlag(kUseGVN); | 2563 SetFlag(kUseGVN); |
2562 SetFlag(kTruncatingToInt32); | 2564 SetFlag(kTruncatingToInt32); |
2563 SetFlag(kAllowUndefinedAsNaN); | 2565 SetFlag(kAllowUndefinedAsNaN); |
2564 set_type(HType::TaggedNumber()); | |
2565 } | 2566 } |
2566 | 2567 |
2567 virtual Representation RequiredInputRepresentation(int index) { | 2568 virtual Representation RequiredInputRepresentation(int index) { |
2568 return Representation::Integer32(); | 2569 return Representation::Integer32(); |
2569 } | 2570 } |
2570 virtual Representation observed_input_representation(int index) { | 2571 virtual Representation observed_input_representation(int index) { |
2571 return Representation::Integer32(); | 2572 return Representation::Integer32(); |
2572 } | 2573 } |
2573 | 2574 |
2574 virtual HValue* Canonicalize(); | 2575 virtual HValue* Canonicalize(); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2632 DECLARE_CONCRETE_INSTRUCTION(UnaryMathOperation) | 2633 DECLARE_CONCRETE_INSTRUCTION(UnaryMathOperation) |
2633 | 2634 |
2634 protected: | 2635 protected: |
2635 virtual bool DataEquals(HValue* other) { | 2636 virtual bool DataEquals(HValue* other) { |
2636 HUnaryMathOperation* b = HUnaryMathOperation::cast(other); | 2637 HUnaryMathOperation* b = HUnaryMathOperation::cast(other); |
2637 return op_ == b->op(); | 2638 return op_ == b->op(); |
2638 } | 2639 } |
2639 | 2640 |
2640 private: | 2641 private: |
2641 HUnaryMathOperation(HValue* context, HValue* value, BuiltinFunctionId op) | 2642 HUnaryMathOperation(HValue* context, HValue* value, BuiltinFunctionId op) |
2642 : op_(op) { | 2643 : HTemplateInstruction<2>(HType::TaggedNumber()), op_(op) { |
2643 SetOperandAt(0, context); | 2644 SetOperandAt(0, context); |
2644 SetOperandAt(1, value); | 2645 SetOperandAt(1, value); |
2645 switch (op) { | 2646 switch (op) { |
2646 case kMathFloor: | 2647 case kMathFloor: |
2647 case kMathRound: | 2648 case kMathRound: |
2648 // TODO(verwaest): Set representation to flexible int starting as smi. | 2649 // TODO(verwaest): Set representation to flexible int starting as smi. |
2649 set_representation(Representation::Integer32()); | 2650 set_representation(Representation::Integer32()); |
2650 break; | 2651 break; |
2651 case kMathAbs: | 2652 case kMathAbs: |
2652 // Not setting representation here: it is None intentionally. | 2653 // Not setting representation here: it is None intentionally. |
(...skipping 13 matching lines...) Expand all Loading... |
2666 case kMathExp: | 2667 case kMathExp: |
2667 case kMathSqrt: | 2668 case kMathSqrt: |
2668 case kMathPowHalf: | 2669 case kMathPowHalf: |
2669 set_representation(Representation::Double()); | 2670 set_representation(Representation::Double()); |
2670 break; | 2671 break; |
2671 default: | 2672 default: |
2672 UNREACHABLE(); | 2673 UNREACHABLE(); |
2673 } | 2674 } |
2674 SetFlag(kUseGVN); | 2675 SetFlag(kUseGVN); |
2675 SetFlag(kAllowUndefinedAsNaN); | 2676 SetFlag(kAllowUndefinedAsNaN); |
2676 set_type(HType::TaggedNumber()); | |
2677 } | 2677 } |
2678 | 2678 |
2679 virtual bool IsDeletable() const { return true; } | 2679 virtual bool IsDeletable() const { return true; } |
2680 | 2680 |
2681 BuiltinFunctionId op_; | 2681 BuiltinFunctionId op_; |
2682 }; | 2682 }; |
2683 | 2683 |
2684 | 2684 |
2685 class HLoadExternalArrayPointer: public HUnaryOperation { | 2685 class HLoadExternalArrayPointer: public HUnaryOperation { |
2686 public: | 2686 public: |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2758 if (map_unique_ids_.at(i) != b->map_unique_ids_.at(i)) { | 2758 if (map_unique_ids_.at(i) != b->map_unique_ids_.at(i)) { |
2759 return false; | 2759 return false; |
2760 } | 2760 } |
2761 } | 2761 } |
2762 return true; | 2762 return true; |
2763 } | 2763 } |
2764 | 2764 |
2765 private: | 2765 private: |
2766 // Clients should use one of the static New* methods above. | 2766 // Clients should use one of the static New* methods above. |
2767 HCheckMaps(HValue* value, Zone *zone, HValue* typecheck) | 2767 HCheckMaps(HValue* value, Zone *zone, HValue* typecheck) |
2768 : omit_(false), map_unique_ids_(0, zone) { | 2768 : HTemplateInstruction<2>(value->type()), |
| 2769 omit_(false), map_unique_ids_(0, zone) { |
2769 SetOperandAt(0, value); | 2770 SetOperandAt(0, value); |
2770 // Use the object value for the dependency if NULL is passed. | 2771 // Use the object value for the dependency if NULL is passed. |
2771 // TODO(titzer): do GVN flags already express this dependency? | 2772 // TODO(titzer): do GVN flags already express this dependency? |
2772 SetOperandAt(1, typecheck != NULL ? typecheck : value); | 2773 SetOperandAt(1, typecheck != NULL ? typecheck : value); |
2773 set_representation(Representation::Tagged()); | 2774 set_representation(Representation::Tagged()); |
2774 SetFlag(kUseGVN); | 2775 SetFlag(kUseGVN); |
2775 SetFlag(kTrackSideEffectDominators); | 2776 SetFlag(kTrackSideEffectDominators); |
2776 SetGVNFlag(kDependsOnMaps); | 2777 SetGVNFlag(kDependsOnMaps); |
2777 SetGVNFlag(kDependsOnElementsKind); | 2778 SetGVNFlag(kDependsOnElementsKind); |
2778 set_type(value->type()); | |
2779 } | 2779 } |
2780 | 2780 |
2781 void omit(CompilationInfo* info) { | 2781 void omit(CompilationInfo* info) { |
2782 omit_ = true; | 2782 omit_ = true; |
2783 for (int i = 0; i < map_set_.length(); i++) { | 2783 for (int i = 0; i < map_set_.length(); i++) { |
2784 Handle<Map> map = map_set_.at(i); | 2784 Handle<Map> map = map_set_.at(i); |
2785 map->AddDependentCompilationInfo(DependentCode::kPrototypeCheckGroup, | 2785 map->AddDependentCompilationInfo(DependentCode::kPrototypeCheckGroup, |
2786 info); | 2786 info); |
2787 } | 2787 } |
2788 } | 2788 } |
2789 | 2789 |
2790 bool omit_; | 2790 bool omit_; |
2791 SmallMapList map_set_; | 2791 SmallMapList map_set_; |
2792 ZoneList<UniqueValueId> map_unique_ids_; | 2792 ZoneList<UniqueValueId> map_unique_ids_; |
2793 }; | 2793 }; |
2794 | 2794 |
2795 | 2795 |
2796 class HCheckFunction: public HUnaryOperation { | 2796 class HCheckFunction: public HUnaryOperation { |
2797 public: | 2797 public: |
2798 HCheckFunction(HValue* value, Handle<JSFunction> function) | 2798 HCheckFunction(HValue* value, Handle<JSFunction> function) |
2799 : HUnaryOperation(value), target_(function), target_unique_id_() { | 2799 : HUnaryOperation(value, value->type()), |
| 2800 target_(function), target_unique_id_() { |
2800 set_representation(Representation::Tagged()); | 2801 set_representation(Representation::Tagged()); |
2801 SetFlag(kUseGVN); | 2802 SetFlag(kUseGVN); |
2802 target_in_new_space_ = Isolate::Current()->heap()->InNewSpace(*function); | 2803 target_in_new_space_ = Isolate::Current()->heap()->InNewSpace(*function); |
2803 set_type(value->type()); | |
2804 } | 2804 } |
2805 | 2805 |
2806 virtual Representation RequiredInputRepresentation(int index) { | 2806 virtual Representation RequiredInputRepresentation(int index) { |
2807 return Representation::Tagged(); | 2807 return Representation::Tagged(); |
2808 } | 2808 } |
2809 virtual void PrintDataTo(StringStream* stream); | 2809 virtual void PrintDataTo(StringStream* stream); |
2810 | 2810 |
2811 virtual HValue* Canonicalize(); | 2811 virtual HValue* Canonicalize(); |
2812 | 2812 |
2813 #ifdef DEBUG | 2813 #ifdef DEBUG |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2891 set_representation(Representation::Tagged()); | 2891 set_representation(Representation::Tagged()); |
2892 SetFlag(kUseGVN); | 2892 SetFlag(kUseGVN); |
2893 } | 2893 } |
2894 | 2894 |
2895 const Check check_; | 2895 const Check check_; |
2896 }; | 2896 }; |
2897 | 2897 |
2898 | 2898 |
2899 class HCheckSmi: public HUnaryOperation { | 2899 class HCheckSmi: public HUnaryOperation { |
2900 public: | 2900 public: |
2901 explicit HCheckSmi(HValue* value) : HUnaryOperation(value) { | 2901 explicit HCheckSmi(HValue* value) : HUnaryOperation(value, HType::Smi()) { |
2902 set_representation(Representation::Smi()); | 2902 set_representation(Representation::Smi()); |
2903 SetFlag(kUseGVN); | 2903 SetFlag(kUseGVN); |
2904 set_type(HType::Smi()); | |
2905 } | 2904 } |
2906 | 2905 |
2907 virtual Representation RequiredInputRepresentation(int index) { | 2906 virtual Representation RequiredInputRepresentation(int index) { |
2908 return Representation::Tagged(); | 2907 return Representation::Tagged(); |
2909 } | 2908 } |
2910 | 2909 |
2911 virtual HValue* Canonicalize() { | 2910 virtual HValue* Canonicalize() { |
2912 HType value_type = value()->type(); | 2911 HType value_type = value()->type(); |
2913 if (value_type.IsSmi()) { | 2912 if (value_type.IsSmi()) { |
2914 return NULL; | 2913 return NULL; |
(...skipping 18 matching lines...) Expand all Loading... |
2933 virtual Representation RequiredInputRepresentation(int index) { | 2932 virtual Representation RequiredInputRepresentation(int index) { |
2934 return Representation::None(); | 2933 return Representation::None(); |
2935 } | 2934 } |
2936 | 2935 |
2937 DECLARE_CONCRETE_INSTRUCTION(IsNumberAndBranch) | 2936 DECLARE_CONCRETE_INSTRUCTION(IsNumberAndBranch) |
2938 }; | 2937 }; |
2939 | 2938 |
2940 | 2939 |
2941 class HCheckHeapObject: public HUnaryOperation { | 2940 class HCheckHeapObject: public HUnaryOperation { |
2942 public: | 2941 public: |
2943 explicit HCheckHeapObject(HValue* value) : HUnaryOperation(value) { | 2942 explicit HCheckHeapObject(HValue* value) |
| 2943 : HUnaryOperation(value, HType::NonPrimitive()) { |
2944 set_representation(Representation::Tagged()); | 2944 set_representation(Representation::Tagged()); |
2945 SetFlag(kUseGVN); | 2945 SetFlag(kUseGVN); |
2946 set_type(HType::NonPrimitive()); | |
2947 } | 2946 } |
2948 | 2947 |
2949 virtual Representation RequiredInputRepresentation(int index) { | 2948 virtual Representation RequiredInputRepresentation(int index) { |
2950 return Representation::Tagged(); | 2949 return Representation::Tagged(); |
2951 } | 2950 } |
2952 | 2951 |
2953 #ifdef DEBUG | 2952 #ifdef DEBUG |
2954 virtual void Verify(); | 2953 virtual void Verify(); |
2955 #endif | 2954 #endif |
2956 | 2955 |
(...skipping 734 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3691 bool is_cell_ : 1; | 3690 bool is_cell_ : 1; |
3692 bool boolean_value_ : 1; | 3691 bool boolean_value_ : 1; |
3693 int32_t int32_value_; | 3692 int32_t int32_value_; |
3694 double double_value_; | 3693 double double_value_; |
3695 ExternalReference external_reference_value_; | 3694 ExternalReference external_reference_value_; |
3696 }; | 3695 }; |
3697 | 3696 |
3698 | 3697 |
3699 class HBinaryOperation: public HTemplateInstruction<3> { | 3698 class HBinaryOperation: public HTemplateInstruction<3> { |
3700 public: | 3699 public: |
3701 HBinaryOperation(HValue* context, HValue* left, HValue* right) | 3700 HBinaryOperation(HValue* context, HValue* left, HValue* right, |
3702 : observed_output_representation_(Representation::None()) { | 3701 HType type = HType::Tagged()) |
| 3702 : HTemplateInstruction<3>(type), |
| 3703 observed_output_representation_(Representation::None()) { |
3703 ASSERT(left != NULL && right != NULL); | 3704 ASSERT(left != NULL && right != NULL); |
3704 SetOperandAt(0, context); | 3705 SetOperandAt(0, context); |
3705 SetOperandAt(1, left); | 3706 SetOperandAt(1, left); |
3706 SetOperandAt(2, right); | 3707 SetOperandAt(2, right); |
3707 observed_input_representation_[0] = Representation::None(); | 3708 observed_input_representation_[0] = Representation::None(); |
3708 observed_input_representation_[1] = Representation::None(); | 3709 observed_input_representation_[1] = Representation::None(); |
3709 } | 3710 } |
3710 | 3711 |
3711 HValue* context() const { return OperandAt(0); } | 3712 HValue* context() const { return OperandAt(0); } |
3712 HValue* left() const { return OperandAt(1); } | 3713 HValue* left() const { return OperandAt(1); } |
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4043 bounds_check()->SetResponsibilityForRange(direction); | 4044 bounds_check()->SetResponsibilityForRange(direction); |
4044 } | 4045 } |
4045 virtual void TryGuaranteeRangeChanging(RangeEvaluationContext* context) { | 4046 virtual void TryGuaranteeRangeChanging(RangeEvaluationContext* context) { |
4046 bounds_check()->TryGuaranteeRangeChanging(context); | 4047 bounds_check()->TryGuaranteeRangeChanging(context); |
4047 } | 4048 } |
4048 }; | 4049 }; |
4049 | 4050 |
4050 | 4051 |
4051 class HBitwiseBinaryOperation: public HBinaryOperation { | 4052 class HBitwiseBinaryOperation: public HBinaryOperation { |
4052 public: | 4053 public: |
4053 HBitwiseBinaryOperation(HValue* context, HValue* left, HValue* right) | 4054 HBitwiseBinaryOperation(HValue* context, HValue* left, HValue* right, |
4054 : HBinaryOperation(context, left, right) { | 4055 HType type = HType::Tagged()) |
| 4056 : HBinaryOperation(context, left, right, type) { |
4055 SetFlag(kFlexibleRepresentation); | 4057 SetFlag(kFlexibleRepresentation); |
4056 SetFlag(kTruncatingToInt32); | 4058 SetFlag(kTruncatingToInt32); |
4057 SetFlag(kAllowUndefinedAsNaN); | 4059 SetFlag(kAllowUndefinedAsNaN); |
4058 SetAllSideEffects(); | 4060 SetAllSideEffects(); |
4059 } | 4061 } |
4060 | 4062 |
4061 virtual void RepresentationChanged(Representation to) { | 4063 virtual void RepresentationChanged(Representation to) { |
4062 if (!to.IsTagged()) { | 4064 if (!to.IsTagged()) { |
4063 ASSERT(to.IsSmiOrInteger32()); | 4065 ASSERT(to.IsSmiOrInteger32()); |
4064 ClearAllSideEffects(); | 4066 ClearAllSideEffects(); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4120 virtual bool DataEquals(HValue* other) { return true; } | 4122 virtual bool DataEquals(HValue* other) { return true; } |
4121 | 4123 |
4122 private: | 4124 private: |
4123 virtual bool IsDeletable() const { return true; } | 4125 virtual bool IsDeletable() const { return true; } |
4124 }; | 4126 }; |
4125 | 4127 |
4126 | 4128 |
4127 class HArithmeticBinaryOperation: public HBinaryOperation { | 4129 class HArithmeticBinaryOperation: public HBinaryOperation { |
4128 public: | 4130 public: |
4129 HArithmeticBinaryOperation(HValue* context, HValue* left, HValue* right) | 4131 HArithmeticBinaryOperation(HValue* context, HValue* left, HValue* right) |
4130 : HBinaryOperation(context, left, right) { | 4132 : HBinaryOperation(context, left, right, HType::TaggedNumber()) { |
4131 SetAllSideEffects(); | 4133 SetAllSideEffects(); |
4132 SetFlag(kFlexibleRepresentation); | 4134 SetFlag(kFlexibleRepresentation); |
4133 SetFlag(kAllowUndefinedAsNaN); | 4135 SetFlag(kAllowUndefinedAsNaN); |
4134 set_type(HType::TaggedNumber()); | |
4135 } | 4136 } |
4136 | 4137 |
4137 virtual void RepresentationChanged(Representation to) { | 4138 virtual void RepresentationChanged(Representation to) { |
4138 if (to.IsTagged()) { | 4139 if (to.IsTagged()) { |
4139 SetAllSideEffects(); | 4140 SetAllSideEffects(); |
4140 ClearFlag(kUseGVN); | 4141 ClearFlag(kUseGVN); |
4141 } else { | 4142 } else { |
4142 ClearAllSideEffects(); | 4143 ClearAllSideEffects(); |
4143 SetFlag(kUseGVN); | 4144 SetFlag(kUseGVN); |
4144 } | 4145 } |
4145 } | 4146 } |
4146 | 4147 |
4147 DECLARE_ABSTRACT_INSTRUCTION(ArithmeticBinaryOperation) | 4148 DECLARE_ABSTRACT_INSTRUCTION(ArithmeticBinaryOperation) |
4148 | 4149 |
4149 private: | 4150 private: |
4150 virtual bool IsDeletable() const { return true; } | 4151 virtual bool IsDeletable() const { return true; } |
4151 }; | 4152 }; |
4152 | 4153 |
4153 | 4154 |
4154 class HCompareGeneric: public HBinaryOperation { | 4155 class HCompareGeneric: public HBinaryOperation { |
4155 public: | 4156 public: |
4156 HCompareGeneric(HValue* context, | 4157 HCompareGeneric(HValue* context, |
4157 HValue* left, | 4158 HValue* left, |
4158 HValue* right, | 4159 HValue* right, |
4159 Token::Value token) | 4160 Token::Value token) |
4160 : HBinaryOperation(context, left, right), token_(token) { | 4161 : HBinaryOperation(context, left, right, HType::Boolean()), |
| 4162 token_(token) { |
4161 ASSERT(Token::IsCompareOp(token)); | 4163 ASSERT(Token::IsCompareOp(token)); |
4162 set_representation(Representation::Tagged()); | 4164 set_representation(Representation::Tagged()); |
4163 set_type(HType::Boolean()); | |
4164 SetAllSideEffects(); | 4165 SetAllSideEffects(); |
4165 } | 4166 } |
4166 | 4167 |
4167 virtual Representation RequiredInputRepresentation(int index) { | 4168 virtual Representation RequiredInputRepresentation(int index) { |
4168 return index == 0 | 4169 return index == 0 |
4169 ? Representation::Tagged() | 4170 ? Representation::Tagged() |
4170 : representation(); | 4171 : representation(); |
4171 } | 4172 } |
4172 | 4173 |
4173 Token::Value token() const { return token_; } | 4174 Token::Value token() const { return token_; } |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4441 } | 4442 } |
4442 | 4443 |
4443 private: | 4444 private: |
4444 Handle<String> type_literal_; | 4445 Handle<String> type_literal_; |
4445 }; | 4446 }; |
4446 | 4447 |
4447 | 4448 |
4448 class HInstanceOf: public HBinaryOperation { | 4449 class HInstanceOf: public HBinaryOperation { |
4449 public: | 4450 public: |
4450 HInstanceOf(HValue* context, HValue* left, HValue* right) | 4451 HInstanceOf(HValue* context, HValue* left, HValue* right) |
4451 : HBinaryOperation(context, left, right) { | 4452 : HBinaryOperation(context, left, right, HType::Boolean()) { |
4452 set_representation(Representation::Tagged()); | 4453 set_representation(Representation::Tagged()); |
4453 set_type(HType::Boolean()); | |
4454 SetAllSideEffects(); | 4454 SetAllSideEffects(); |
4455 } | 4455 } |
4456 | 4456 |
4457 virtual Representation RequiredInputRepresentation(int index) { | 4457 virtual Representation RequiredInputRepresentation(int index) { |
4458 return Representation::Tagged(); | 4458 return Representation::Tagged(); |
4459 } | 4459 } |
4460 | 4460 |
4461 virtual void PrintDataTo(StringStream* stream); | 4461 virtual void PrintDataTo(StringStream* stream); |
4462 | 4462 |
4463 DECLARE_CONCRETE_INSTRUCTION(InstanceOf) | 4463 DECLARE_CONCRETE_INSTRUCTION(InstanceOf) |
4464 }; | 4464 }; |
4465 | 4465 |
4466 | 4466 |
4467 class HInstanceOfKnownGlobal: public HTemplateInstruction<2> { | 4467 class HInstanceOfKnownGlobal: public HTemplateInstruction<2> { |
4468 public: | 4468 public: |
4469 HInstanceOfKnownGlobal(HValue* context, | 4469 HInstanceOfKnownGlobal(HValue* context, |
4470 HValue* left, | 4470 HValue* left, |
4471 Handle<JSFunction> right) | 4471 Handle<JSFunction> right) |
4472 : function_(right) { | 4472 : HTemplateInstruction<2>(HType::Boolean()), function_(right) { |
4473 SetOperandAt(0, context); | 4473 SetOperandAt(0, context); |
4474 SetOperandAt(1, left); | 4474 SetOperandAt(1, left); |
4475 set_type(HType::Boolean()); | |
4476 set_representation(Representation::Tagged()); | 4475 set_representation(Representation::Tagged()); |
4477 SetAllSideEffects(); | 4476 SetAllSideEffects(); |
4478 } | 4477 } |
4479 | 4478 |
4480 HValue* context() { return OperandAt(0); } | 4479 HValue* context() { return OperandAt(0); } |
4481 HValue* left() { return OperandAt(1); } | 4480 HValue* left() { return OperandAt(1); } |
4482 Handle<JSFunction> function() { return function_; } | 4481 Handle<JSFunction> function() { return function_; } |
4483 | 4482 |
4484 virtual Representation RequiredInputRepresentation(int index) { | 4483 virtual Representation RequiredInputRepresentation(int index) { |
4485 return Representation::Tagged(); | 4484 return Representation::Tagged(); |
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4866 | 4865 |
4867 protected: | 4866 protected: |
4868 virtual bool DataEquals(HValue* other) { | 4867 virtual bool DataEquals(HValue* other) { |
4869 return op() == HBitwise::cast(other)->op(); | 4868 return op() == HBitwise::cast(other)->op(); |
4870 } | 4869 } |
4871 | 4870 |
4872 virtual Range* InferRange(Zone* zone); | 4871 virtual Range* InferRange(Zone* zone); |
4873 | 4872 |
4874 private: | 4873 private: |
4875 HBitwise(Token::Value op, HValue* context, HValue* left, HValue* right) | 4874 HBitwise(Token::Value op, HValue* context, HValue* left, HValue* right) |
4876 : HBitwiseBinaryOperation(context, left, right), op_(op) { | 4875 : HBitwiseBinaryOperation(context, left, right, HType::TaggedNumber()), |
| 4876 op_(op) { |
4877 ASSERT(op == Token::BIT_AND || op == Token::BIT_OR || op == Token::BIT_XOR); | 4877 ASSERT(op == Token::BIT_AND || op == Token::BIT_OR || op == Token::BIT_XOR); |
4878 // BIT_AND with a smi-range positive value will always unset the | 4878 // BIT_AND with a smi-range positive value will always unset the |
4879 // entire sign-extension of the smi-sign. | 4879 // entire sign-extension of the smi-sign. |
4880 if (op == Token::BIT_AND && | 4880 if (op == Token::BIT_AND && |
4881 ((left->IsConstant() && | 4881 ((left->IsConstant() && |
4882 left->representation().IsSmi() && | 4882 left->representation().IsSmi() && |
4883 HConstant::cast(left)->Integer32Value() >= 0) || | 4883 HConstant::cast(left)->Integer32Value() >= 0) || |
4884 (right->IsConstant() && | 4884 (right->IsConstant() && |
4885 right->representation().IsSmi() && | 4885 right->representation().IsSmi() && |
4886 HConstant::cast(right)->Integer32Value() >= 0))) { | 4886 HConstant::cast(right)->Integer32Value() >= 0))) { |
4887 SetFlag(kTruncatingToSmi); | 4887 SetFlag(kTruncatingToSmi); |
4888 // BIT_OR with a smi-range negative value will always set the entire | 4888 // BIT_OR with a smi-range negative value will always set the entire |
4889 // sign-extension of the smi-sign. | 4889 // sign-extension of the smi-sign. |
4890 } else if (op == Token::BIT_OR && | 4890 } else if (op == Token::BIT_OR && |
4891 ((left->IsConstant() && | 4891 ((left->IsConstant() && |
4892 left->representation().IsSmi() && | 4892 left->representation().IsSmi() && |
4893 HConstant::cast(left)->Integer32Value() < 0) || | 4893 HConstant::cast(left)->Integer32Value() < 0) || |
4894 (right->IsConstant() && | 4894 (right->IsConstant() && |
4895 right->representation().IsSmi() && | 4895 right->representation().IsSmi() && |
4896 HConstant::cast(right)->Integer32Value() < 0))) { | 4896 HConstant::cast(right)->Integer32Value() < 0))) { |
4897 SetFlag(kTruncatingToSmi); | 4897 SetFlag(kTruncatingToSmi); |
4898 } | 4898 } |
4899 set_type(HType::TaggedNumber()); | |
4900 } | 4899 } |
4901 | 4900 |
4902 Token::Value op_; | 4901 Token::Value op_; |
4903 }; | 4902 }; |
4904 | 4903 |
4905 | 4904 |
4906 class HShl: public HBitwiseBinaryOperation { | 4905 class HShl: public HBitwiseBinaryOperation { |
4907 public: | 4906 public: |
4908 static HInstruction* New(Zone* zone, | 4907 static HInstruction* New(Zone* zone, |
4909 HValue* context, | 4908 HValue* context, |
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5231 bool for_typeof_; | 5230 bool for_typeof_; |
5232 }; | 5231 }; |
5233 | 5232 |
5234 | 5233 |
5235 class HAllocate: public HTemplateInstruction<2> { | 5234 class HAllocate: public HTemplateInstruction<2> { |
5236 public: | 5235 public: |
5237 HAllocate(HValue* context, | 5236 HAllocate(HValue* context, |
5238 HValue* size, | 5237 HValue* size, |
5239 HType type, | 5238 HType type, |
5240 bool pretenure, | 5239 bool pretenure, |
5241 ElementsKind kind = FAST_ELEMENTS) { | 5240 ElementsKind kind = FAST_ELEMENTS) |
| 5241 : HTemplateInstruction<2>(type) { |
5242 SetOperandAt(0, context); | 5242 SetOperandAt(0, context); |
5243 SetOperandAt(1, size); | 5243 SetOperandAt(1, size); |
5244 set_type(type); | |
5245 set_representation(Representation::Tagged()); | 5244 set_representation(Representation::Tagged()); |
5246 SetFlag(kTrackSideEffectDominators); | 5245 SetFlag(kTrackSideEffectDominators); |
5247 SetGVNFlag(kChangesNewSpacePromotion); | 5246 SetGVNFlag(kChangesNewSpacePromotion); |
5248 SetGVNFlag(kDependsOnNewSpacePromotion); | 5247 SetGVNFlag(kDependsOnNewSpacePromotion); |
5249 if (pretenure) { | 5248 if (pretenure) { |
5250 if (IsFastDoubleElementsKind(kind)) { | 5249 if (IsFastDoubleElementsKind(kind)) { |
5251 flags_ = static_cast<HAllocate::Flags>(ALLOCATE_IN_OLD_DATA_SPACE | | 5250 flags_ = static_cast<HAllocate::Flags>(ALLOCATE_IN_OLD_DATA_SPACE | |
5252 ALLOCATE_DOUBLE_ALIGNED); | 5251 ALLOCATE_DOUBLE_ALIGNED); |
5253 } else { | 5252 } else { |
5254 flags_ = ALLOCATE_IN_OLD_POINTER_SPACE; | 5253 flags_ = ALLOCATE_IN_OLD_POINTER_SPACE; |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5333 }; | 5332 }; |
5334 | 5333 |
5335 Flags flags_; | 5334 Flags flags_; |
5336 Handle<Map> known_initial_map_; | 5335 Handle<Map> known_initial_map_; |
5337 }; | 5336 }; |
5338 | 5337 |
5339 | 5338 |
5340 class HInnerAllocatedObject: public HTemplateInstruction<1> { | 5339 class HInnerAllocatedObject: public HTemplateInstruction<1> { |
5341 public: | 5340 public: |
5342 HInnerAllocatedObject(HValue* value, int offset, HType type = HType::Tagged()) | 5341 HInnerAllocatedObject(HValue* value, int offset, HType type = HType::Tagged()) |
5343 : offset_(offset) { | 5342 : HTemplateInstruction<1>(type), offset_(offset) { |
5344 ASSERT(value->IsAllocate()); | 5343 ASSERT(value->IsAllocate()); |
5345 SetOperandAt(0, value); | 5344 SetOperandAt(0, value); |
5346 set_type(type); | |
5347 set_representation(Representation::Tagged()); | 5345 set_representation(Representation::Tagged()); |
5348 } | 5346 } |
5349 | 5347 |
5350 HValue* base_object() { return OperandAt(0); } | 5348 HValue* base_object() { return OperandAt(0); } |
5351 int offset() { return offset_; } | 5349 int offset() { return offset_; } |
5352 | 5350 |
5353 virtual Representation RequiredInputRepresentation(int index) { | 5351 virtual Representation RequiredInputRepresentation(int index) { |
5354 return Representation::Tagged(); | 5352 return Representation::Tagged(); |
5355 } | 5353 } |
5356 | 5354 |
(...skipping 1145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6502 return Representation::Tagged(); | 6500 return Representation::Tagged(); |
6503 } | 6501 } |
6504 | 6502 |
6505 DECLARE_CONCRETE_INSTRUCTION(StringAdd) | 6503 DECLARE_CONCRETE_INSTRUCTION(StringAdd) |
6506 | 6504 |
6507 protected: | 6505 protected: |
6508 virtual bool DataEquals(HValue* other) { return true; } | 6506 virtual bool DataEquals(HValue* other) { return true; } |
6509 | 6507 |
6510 private: | 6508 private: |
6511 HStringAdd(HValue* context, HValue* left, HValue* right, StringAddFlags flags) | 6509 HStringAdd(HValue* context, HValue* left, HValue* right, StringAddFlags flags) |
6512 : HBinaryOperation(context, left, right), flags_(flags) { | 6510 : HBinaryOperation(context, left, right, HType::String()), flags_(flags) { |
6513 set_representation(Representation::Tagged()); | 6511 set_representation(Representation::Tagged()); |
6514 SetFlag(kUseGVN); | 6512 SetFlag(kUseGVN); |
6515 SetGVNFlag(kDependsOnMaps); | 6513 SetGVNFlag(kDependsOnMaps); |
6516 SetGVNFlag(kChangesNewSpacePromotion); | 6514 SetGVNFlag(kChangesNewSpacePromotion); |
6517 set_type(HType::String()); | |
6518 } | 6515 } |
6519 | 6516 |
6520 // No side-effects except possible allocation. | 6517 // No side-effects except possible allocation. |
6521 // NOTE: this instruction _does not_ call ToString() on its inputs. | 6518 // NOTE: this instruction _does not_ call ToString() on its inputs. |
6522 virtual bool IsDeletable() const { return true; } | 6519 virtual bool IsDeletable() const { return true; } |
6523 | 6520 |
6524 const StringAddFlags flags_; | 6521 const StringAddFlags flags_; |
6525 }; | 6522 }; |
6526 | 6523 |
6527 | 6524 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6576 } | 6573 } |
6577 | 6574 |
6578 HValue* context() const { return OperandAt(0); } | 6575 HValue* context() const { return OperandAt(0); } |
6579 HValue* value() const { return OperandAt(1); } | 6576 HValue* value() const { return OperandAt(1); } |
6580 | 6577 |
6581 virtual bool DataEquals(HValue* other) { return true; } | 6578 virtual bool DataEquals(HValue* other) { return true; } |
6582 | 6579 |
6583 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode) | 6580 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode) |
6584 | 6581 |
6585 private: | 6582 private: |
6586 HStringCharFromCode(HValue* context, HValue* char_code) { | 6583 HStringCharFromCode(HValue* context, HValue* char_code) |
| 6584 : HTemplateInstruction<2>(HType::String()) { |
6587 SetOperandAt(0, context); | 6585 SetOperandAt(0, context); |
6588 SetOperandAt(1, char_code); | 6586 SetOperandAt(1, char_code); |
6589 set_representation(Representation::Tagged()); | 6587 set_representation(Representation::Tagged()); |
6590 SetFlag(kUseGVN); | 6588 SetFlag(kUseGVN); |
6591 SetGVNFlag(kChangesNewSpacePromotion); | 6589 SetGVNFlag(kChangesNewSpacePromotion); |
6592 set_type(HType::String()); | |
6593 } | 6590 } |
6594 | 6591 |
6595 virtual bool IsDeletable() const { | 6592 virtual bool IsDeletable() const { |
6596 return !value()->ToNumberCanBeObserved(); | 6593 return !value()->ToNumberCanBeObserved(); |
6597 } | 6594 } |
6598 }; | 6595 }; |
6599 | 6596 |
6600 | 6597 |
6601 class HStringLength: public HUnaryOperation { | 6598 class HStringLength: public HUnaryOperation { |
6602 public: | 6599 public: |
6603 static HInstruction* New(Zone* zone, HValue* string); | 6600 static HInstruction* New(Zone* zone, HValue* string); |
6604 | 6601 |
6605 virtual Representation RequiredInputRepresentation(int index) { | 6602 virtual Representation RequiredInputRepresentation(int index) { |
6606 return Representation::Tagged(); | 6603 return Representation::Tagged(); |
6607 } | 6604 } |
6608 | 6605 |
6609 DECLARE_CONCRETE_INSTRUCTION(StringLength) | 6606 DECLARE_CONCRETE_INSTRUCTION(StringLength) |
6610 | 6607 |
6611 protected: | 6608 protected: |
6612 virtual bool DataEquals(HValue* other) { return true; } | 6609 virtual bool DataEquals(HValue* other) { return true; } |
6613 | 6610 |
6614 virtual Range* InferRange(Zone* zone) { | 6611 virtual Range* InferRange(Zone* zone) { |
6615 return new(zone) Range(0, String::kMaxLength); | 6612 return new(zone) Range(0, String::kMaxLength); |
6616 } | 6613 } |
6617 | 6614 |
6618 private: | 6615 private: |
6619 explicit HStringLength(HValue* string) : HUnaryOperation(string) { | 6616 explicit HStringLength(HValue* string) |
| 6617 : HUnaryOperation(string, HType::Smi()) { |
6620 STATIC_ASSERT(String::kMaxLength <= Smi::kMaxValue); | 6618 STATIC_ASSERT(String::kMaxLength <= Smi::kMaxValue); |
6621 set_representation(Representation::Tagged()); | 6619 set_representation(Representation::Tagged()); |
6622 SetFlag(kUseGVN); | 6620 SetFlag(kUseGVN); |
6623 SetGVNFlag(kDependsOnMaps); | 6621 SetGVNFlag(kDependsOnMaps); |
6624 set_type(HType::Smi()); | |
6625 } | 6622 } |
6626 | 6623 |
6627 virtual bool IsDeletable() const { return true; } | 6624 virtual bool IsDeletable() const { return true; } |
6628 }; | 6625 }; |
6629 | 6626 |
6630 | 6627 |
6631 template <int V> | 6628 template <int V> |
6632 class HMaterializedLiteral: public HTemplateInstruction<V> { | 6629 class HMaterializedLiteral: public HTemplateInstruction<V> { |
6633 public: | 6630 public: |
6634 HMaterializedLiteral<V>(int index, int depth, AllocationSiteMode mode) | 6631 HMaterializedLiteral<V>(int index, int depth, AllocationSiteMode mode) |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6689 Handle<String> pattern_; | 6686 Handle<String> pattern_; |
6690 Handle<String> flags_; | 6687 Handle<String> flags_; |
6691 }; | 6688 }; |
6692 | 6689 |
6693 | 6690 |
6694 class HFunctionLiteral: public HTemplateInstruction<1> { | 6691 class HFunctionLiteral: public HTemplateInstruction<1> { |
6695 public: | 6692 public: |
6696 HFunctionLiteral(HValue* context, | 6693 HFunctionLiteral(HValue* context, |
6697 Handle<SharedFunctionInfo> shared, | 6694 Handle<SharedFunctionInfo> shared, |
6698 bool pretenure) | 6695 bool pretenure) |
6699 : shared_info_(shared), | 6696 : HTemplateInstruction<1>(HType::JSObject()), |
| 6697 shared_info_(shared), |
6700 pretenure_(pretenure), | 6698 pretenure_(pretenure), |
6701 has_no_literals_(shared->num_literals() == 0), | 6699 has_no_literals_(shared->num_literals() == 0), |
6702 is_generator_(shared->is_generator()), | 6700 is_generator_(shared->is_generator()), |
6703 language_mode_(shared->language_mode()) { | 6701 language_mode_(shared->language_mode()) { |
6704 SetOperandAt(0, context); | 6702 SetOperandAt(0, context); |
6705 set_type(HType::JSObject()); | |
6706 set_representation(Representation::Tagged()); | 6703 set_representation(Representation::Tagged()); |
6707 SetGVNFlag(kChangesNewSpacePromotion); | 6704 SetGVNFlag(kChangesNewSpacePromotion); |
6708 } | 6705 } |
6709 | 6706 |
6710 HValue* context() { return OperandAt(0); } | 6707 HValue* context() { return OperandAt(0); } |
6711 | 6708 |
6712 virtual Representation RequiredInputRepresentation(int index) { | 6709 virtual Representation RequiredInputRepresentation(int index) { |
6713 return Representation::Tagged(); | 6710 return Representation::Tagged(); |
6714 } | 6711 } |
6715 | 6712 |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6993 virtual bool IsDeletable() const { return true; } | 6990 virtual bool IsDeletable() const { return true; } |
6994 }; | 6991 }; |
6995 | 6992 |
6996 | 6993 |
6997 #undef DECLARE_INSTRUCTION | 6994 #undef DECLARE_INSTRUCTION |
6998 #undef DECLARE_CONCRETE_INSTRUCTION | 6995 #undef DECLARE_CONCRETE_INSTRUCTION |
6999 | 6996 |
7000 } } // namespace v8::internal | 6997 } } // namespace v8::internal |
7001 | 6998 |
7002 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ | 6999 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ |
OLD | NEW |