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 2537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2548 }; | 2548 }; |
2549 | 2549 |
2550 | 2550 |
2551 class HBitNot: public HUnaryOperation { | 2551 class HBitNot: public HUnaryOperation { |
2552 public: | 2552 public: |
2553 explicit HBitNot(HValue* value) : HUnaryOperation(value) { | 2553 explicit HBitNot(HValue* value) : HUnaryOperation(value) { |
2554 set_representation(Representation::Integer32()); | 2554 set_representation(Representation::Integer32()); |
2555 SetFlag(kUseGVN); | 2555 SetFlag(kUseGVN); |
2556 SetFlag(kTruncatingToInt32); | 2556 SetFlag(kTruncatingToInt32); |
2557 SetFlag(kAllowUndefinedAsNaN); | 2557 SetFlag(kAllowUndefinedAsNaN); |
| 2558 set_type(HType::TaggedNumber()); |
2558 } | 2559 } |
2559 | 2560 |
2560 virtual Representation RequiredInputRepresentation(int index) { | 2561 virtual Representation RequiredInputRepresentation(int index) { |
2561 return Representation::Integer32(); | 2562 return Representation::Integer32(); |
2562 } | 2563 } |
2563 virtual Representation observed_input_representation(int index) { | 2564 virtual Representation observed_input_representation(int index) { |
2564 return Representation::Integer32(); | 2565 return Representation::Integer32(); |
2565 } | 2566 } |
2566 virtual HType CalculateInferredType(); | |
2567 | 2567 |
2568 virtual HValue* Canonicalize(); | 2568 virtual HValue* Canonicalize(); |
2569 | 2569 |
2570 DECLARE_CONCRETE_INSTRUCTION(BitNot) | 2570 DECLARE_CONCRETE_INSTRUCTION(BitNot) |
2571 | 2571 |
2572 protected: | 2572 protected: |
2573 virtual bool DataEquals(HValue* other) { return true; } | 2573 virtual bool DataEquals(HValue* other) { return true; } |
2574 | 2574 |
2575 private: | 2575 private: |
2576 virtual bool IsDeletable() const { return true; } | 2576 virtual bool IsDeletable() const { return true; } |
2577 }; | 2577 }; |
2578 | 2578 |
2579 | 2579 |
2580 class HUnaryMathOperation: public HTemplateInstruction<2> { | 2580 class HUnaryMathOperation: public HTemplateInstruction<2> { |
2581 public: | 2581 public: |
2582 static HInstruction* New(Zone* zone, | 2582 static HInstruction* New(Zone* zone, |
2583 HValue* context, | 2583 HValue* context, |
2584 HValue* value, | 2584 HValue* value, |
2585 BuiltinFunctionId op); | 2585 BuiltinFunctionId op); |
2586 | 2586 |
2587 HValue* context() { return OperandAt(0); } | 2587 HValue* context() { return OperandAt(0); } |
2588 HValue* value() { return OperandAt(1); } | 2588 HValue* value() { return OperandAt(1); } |
2589 | 2589 |
2590 virtual void PrintDataTo(StringStream* stream); | 2590 virtual void PrintDataTo(StringStream* stream); |
2591 | 2591 |
2592 virtual HType CalculateInferredType(); | |
2593 | |
2594 virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited); | 2592 virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited); |
2595 | 2593 |
2596 virtual Representation RequiredInputRepresentation(int index) { | 2594 virtual Representation RequiredInputRepresentation(int index) { |
2597 if (index == 0) { | 2595 if (index == 0) { |
2598 return Representation::Tagged(); | 2596 return Representation::Tagged(); |
2599 } else { | 2597 } else { |
2600 switch (op_) { | 2598 switch (op_) { |
2601 case kMathFloor: | 2599 case kMathFloor: |
2602 case kMathRound: | 2600 case kMathRound: |
2603 case kMathSqrt: | 2601 case kMathSqrt: |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2662 case kMathExp: | 2660 case kMathExp: |
2663 case kMathSqrt: | 2661 case kMathSqrt: |
2664 case kMathPowHalf: | 2662 case kMathPowHalf: |
2665 set_representation(Representation::Double()); | 2663 set_representation(Representation::Double()); |
2666 break; | 2664 break; |
2667 default: | 2665 default: |
2668 UNREACHABLE(); | 2666 UNREACHABLE(); |
2669 } | 2667 } |
2670 SetFlag(kUseGVN); | 2668 SetFlag(kUseGVN); |
2671 SetFlag(kAllowUndefinedAsNaN); | 2669 SetFlag(kAllowUndefinedAsNaN); |
| 2670 set_type(HType::TaggedNumber()); |
2672 } | 2671 } |
2673 | 2672 |
2674 virtual bool IsDeletable() const { return true; } | 2673 virtual bool IsDeletable() const { return true; } |
2675 | 2674 |
2676 BuiltinFunctionId op_; | 2675 BuiltinFunctionId op_; |
2677 }; | 2676 }; |
2678 | 2677 |
2679 | 2678 |
2680 class HLoadExternalArrayPointer: public HUnaryOperation { | 2679 class HLoadExternalArrayPointer: public HUnaryOperation { |
2681 public: | 2680 public: |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2722 | 2721 |
2723 bool CanOmitMapChecks() { return omit_; } | 2722 bool CanOmitMapChecks() { return omit_; } |
2724 | 2723 |
2725 virtual bool HasEscapingOperandAt(int index) { return false; } | 2724 virtual bool HasEscapingOperandAt(int index) { return false; } |
2726 virtual Representation RequiredInputRepresentation(int index) { | 2725 virtual Representation RequiredInputRepresentation(int index) { |
2727 return Representation::Tagged(); | 2726 return Representation::Tagged(); |
2728 } | 2727 } |
2729 virtual void HandleSideEffectDominator(GVNFlag side_effect, | 2728 virtual void HandleSideEffectDominator(GVNFlag side_effect, |
2730 HValue* dominator); | 2729 HValue* dominator); |
2731 virtual void PrintDataTo(StringStream* stream); | 2730 virtual void PrintDataTo(StringStream* stream); |
2732 virtual HType CalculateInferredType(); | |
2733 | 2731 |
2734 HValue* value() { return OperandAt(0); } | 2732 HValue* value() { return OperandAt(0); } |
2735 SmallMapList* map_set() { return &map_set_; } | 2733 SmallMapList* map_set() { return &map_set_; } |
2736 | 2734 |
2737 virtual void FinalizeUniqueValueId(); | 2735 virtual void FinalizeUniqueValueId(); |
2738 | 2736 |
2739 DECLARE_CONCRETE_INSTRUCTION(CheckMaps) | 2737 DECLARE_CONCRETE_INSTRUCTION(CheckMaps) |
2740 | 2738 |
2741 protected: | 2739 protected: |
2742 virtual bool DataEquals(HValue* other) { | 2740 virtual bool DataEquals(HValue* other) { |
(...skipping 17 matching lines...) Expand all Loading... |
2760 : omit_(false), map_unique_ids_(0, zone) { | 2758 : omit_(false), map_unique_ids_(0, zone) { |
2761 SetOperandAt(0, value); | 2759 SetOperandAt(0, value); |
2762 // Use the object value for the dependency if NULL is passed. | 2760 // Use the object value for the dependency if NULL is passed. |
2763 // TODO(titzer): do GVN flags already express this dependency? | 2761 // TODO(titzer): do GVN flags already express this dependency? |
2764 SetOperandAt(1, typecheck != NULL ? typecheck : value); | 2762 SetOperandAt(1, typecheck != NULL ? typecheck : value); |
2765 set_representation(Representation::Tagged()); | 2763 set_representation(Representation::Tagged()); |
2766 SetFlag(kUseGVN); | 2764 SetFlag(kUseGVN); |
2767 SetFlag(kTrackSideEffectDominators); | 2765 SetFlag(kTrackSideEffectDominators); |
2768 SetGVNFlag(kDependsOnMaps); | 2766 SetGVNFlag(kDependsOnMaps); |
2769 SetGVNFlag(kDependsOnElementsKind); | 2767 SetGVNFlag(kDependsOnElementsKind); |
| 2768 set_type(value->type()); |
2770 } | 2769 } |
2771 | 2770 |
2772 void omit(CompilationInfo* info) { | 2771 void omit(CompilationInfo* info) { |
2773 omit_ = true; | 2772 omit_ = true; |
2774 for (int i = 0; i < map_set_.length(); i++) { | 2773 for (int i = 0; i < map_set_.length(); i++) { |
2775 Handle<Map> map = map_set_.at(i); | 2774 Handle<Map> map = map_set_.at(i); |
2776 map->AddDependentCompilationInfo(DependentCode::kPrototypeCheckGroup, | 2775 map->AddDependentCompilationInfo(DependentCode::kPrototypeCheckGroup, |
2777 info); | 2776 info); |
2778 } | 2777 } |
2779 } | 2778 } |
2780 | 2779 |
2781 bool omit_; | 2780 bool omit_; |
2782 SmallMapList map_set_; | 2781 SmallMapList map_set_; |
2783 ZoneList<UniqueValueId> map_unique_ids_; | 2782 ZoneList<UniqueValueId> map_unique_ids_; |
2784 }; | 2783 }; |
2785 | 2784 |
2786 | 2785 |
2787 class HCheckFunction: public HUnaryOperation { | 2786 class HCheckFunction: public HUnaryOperation { |
2788 public: | 2787 public: |
2789 HCheckFunction(HValue* value, Handle<JSFunction> function) | 2788 HCheckFunction(HValue* value, Handle<JSFunction> function) |
2790 : HUnaryOperation(value), target_(function), target_unique_id_() { | 2789 : HUnaryOperation(value), target_(function), target_unique_id_() { |
2791 set_representation(Representation::Tagged()); | 2790 set_representation(Representation::Tagged()); |
2792 SetFlag(kUseGVN); | 2791 SetFlag(kUseGVN); |
2793 target_in_new_space_ = Isolate::Current()->heap()->InNewSpace(*function); | 2792 target_in_new_space_ = Isolate::Current()->heap()->InNewSpace(*function); |
| 2793 set_type(value->type()); |
2794 } | 2794 } |
2795 | 2795 |
2796 virtual Representation RequiredInputRepresentation(int index) { | 2796 virtual Representation RequiredInputRepresentation(int index) { |
2797 return Representation::Tagged(); | 2797 return Representation::Tagged(); |
2798 } | 2798 } |
2799 virtual void PrintDataTo(StringStream* stream); | 2799 virtual void PrintDataTo(StringStream* stream); |
2800 virtual HType CalculateInferredType(); | |
2801 | 2800 |
2802 virtual HValue* Canonicalize(); | 2801 virtual HValue* Canonicalize(); |
2803 | 2802 |
2804 #ifdef DEBUG | 2803 #ifdef DEBUG |
2805 virtual void Verify(); | 2804 virtual void Verify(); |
2806 #endif | 2805 #endif |
2807 | 2806 |
2808 virtual void FinalizeUniqueValueId() { | 2807 virtual void FinalizeUniqueValueId() { |
2809 target_unique_id_ = UniqueValueId(target_); | 2808 target_unique_id_ = UniqueValueId(target_); |
2810 } | 2809 } |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2885 | 2884 |
2886 const Check check_; | 2885 const Check check_; |
2887 }; | 2886 }; |
2888 | 2887 |
2889 | 2888 |
2890 class HCheckSmi: public HUnaryOperation { | 2889 class HCheckSmi: public HUnaryOperation { |
2891 public: | 2890 public: |
2892 explicit HCheckSmi(HValue* value) : HUnaryOperation(value) { | 2891 explicit HCheckSmi(HValue* value) : HUnaryOperation(value) { |
2893 set_representation(Representation::Smi()); | 2892 set_representation(Representation::Smi()); |
2894 SetFlag(kUseGVN); | 2893 SetFlag(kUseGVN); |
| 2894 set_type(HType::Smi()); |
2895 } | 2895 } |
2896 | 2896 |
2897 virtual Representation RequiredInputRepresentation(int index) { | 2897 virtual Representation RequiredInputRepresentation(int index) { |
2898 return Representation::Tagged(); | 2898 return Representation::Tagged(); |
2899 } | 2899 } |
2900 | 2900 |
2901 virtual HType CalculateInferredType(); | |
2902 | |
2903 virtual HValue* Canonicalize() { | 2901 virtual HValue* Canonicalize() { |
2904 HType value_type = value()->type(); | 2902 HType value_type = value()->type(); |
2905 if (value_type.IsSmi()) { | 2903 if (value_type.IsSmi()) { |
2906 return NULL; | 2904 return NULL; |
2907 } | 2905 } |
2908 return this; | 2906 return this; |
2909 } | 2907 } |
2910 | 2908 |
2911 DECLARE_CONCRETE_INSTRUCTION(CheckSmi) | 2909 DECLARE_CONCRETE_INSTRUCTION(CheckSmi) |
2912 | 2910 |
(...skipping 15 matching lines...) Expand all Loading... |
2928 | 2926 |
2929 DECLARE_CONCRETE_INSTRUCTION(IsNumberAndBranch) | 2927 DECLARE_CONCRETE_INSTRUCTION(IsNumberAndBranch) |
2930 }; | 2928 }; |
2931 | 2929 |
2932 | 2930 |
2933 class HCheckHeapObject: public HUnaryOperation { | 2931 class HCheckHeapObject: public HUnaryOperation { |
2934 public: | 2932 public: |
2935 explicit HCheckHeapObject(HValue* value) : HUnaryOperation(value) { | 2933 explicit HCheckHeapObject(HValue* value) : HUnaryOperation(value) { |
2936 set_representation(Representation::Tagged()); | 2934 set_representation(Representation::Tagged()); |
2937 SetFlag(kUseGVN); | 2935 SetFlag(kUseGVN); |
| 2936 set_type(HType::NonPrimitive()); |
2938 } | 2937 } |
2939 | 2938 |
2940 virtual Representation RequiredInputRepresentation(int index) { | 2939 virtual Representation RequiredInputRepresentation(int index) { |
2941 return Representation::Tagged(); | 2940 return Representation::Tagged(); |
2942 } | 2941 } |
2943 | 2942 |
2944 virtual HType CalculateInferredType(); | |
2945 | |
2946 #ifdef DEBUG | 2943 #ifdef DEBUG |
2947 virtual void Verify(); | 2944 virtual void Verify(); |
2948 #endif | 2945 #endif |
2949 | 2946 |
2950 virtual HValue* Canonicalize() { | 2947 virtual HValue* Canonicalize() { |
2951 return value()->type().IsHeapObject() ? NULL : this; | 2948 return value()->type().IsHeapObject() ? NULL : this; |
2952 } | 2949 } |
2953 | 2950 |
2954 DECLARE_CONCRETE_INSTRUCTION(CheckHeapObject) | 2951 DECLARE_CONCRETE_INSTRUCTION(CheckHeapObject) |
2955 | 2952 |
(...skipping 1100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4056 Representation r = HBinaryOperation::observed_input_representation(index); | 4053 Representation r = HBinaryOperation::observed_input_representation(index); |
4057 if (r.IsDouble()) return Representation::Integer32(); | 4054 if (r.IsDouble()) return Representation::Integer32(); |
4058 return r; | 4055 return r; |
4059 } | 4056 } |
4060 | 4057 |
4061 virtual void initialize_output_representation(Representation observed) { | 4058 virtual void initialize_output_representation(Representation observed) { |
4062 if (observed.IsDouble()) observed = Representation::Integer32(); | 4059 if (observed.IsDouble()) observed = Representation::Integer32(); |
4063 HBinaryOperation::initialize_output_representation(observed); | 4060 HBinaryOperation::initialize_output_representation(observed); |
4064 } | 4061 } |
4065 | 4062 |
4066 virtual HType CalculateInferredType(); | |
4067 | |
4068 DECLARE_ABSTRACT_INSTRUCTION(BitwiseBinaryOperation) | 4063 DECLARE_ABSTRACT_INSTRUCTION(BitwiseBinaryOperation) |
4069 | 4064 |
4070 private: | 4065 private: |
4071 virtual bool IsDeletable() const { return true; } | 4066 virtual bool IsDeletable() const { return true; } |
4072 }; | 4067 }; |
4073 | 4068 |
4074 | 4069 |
4075 class HMathFloorOfDiv: public HBinaryOperation { | 4070 class HMathFloorOfDiv: public HBinaryOperation { |
4076 public: | 4071 public: |
4077 HMathFloorOfDiv(HValue* context, HValue* left, HValue* right) | 4072 HMathFloorOfDiv(HValue* context, HValue* left, HValue* right) |
(...skipping 23 matching lines...) Expand all Loading... |
4101 }; | 4096 }; |
4102 | 4097 |
4103 | 4098 |
4104 class HArithmeticBinaryOperation: public HBinaryOperation { | 4099 class HArithmeticBinaryOperation: public HBinaryOperation { |
4105 public: | 4100 public: |
4106 HArithmeticBinaryOperation(HValue* context, HValue* left, HValue* right) | 4101 HArithmeticBinaryOperation(HValue* context, HValue* left, HValue* right) |
4107 : HBinaryOperation(context, left, right) { | 4102 : HBinaryOperation(context, left, right) { |
4108 SetAllSideEffects(); | 4103 SetAllSideEffects(); |
4109 SetFlag(kFlexibleRepresentation); | 4104 SetFlag(kFlexibleRepresentation); |
4110 SetFlag(kAllowUndefinedAsNaN); | 4105 SetFlag(kAllowUndefinedAsNaN); |
| 4106 set_type(HType::TaggedNumber()); |
4111 } | 4107 } |
4112 | 4108 |
4113 virtual void RepresentationChanged(Representation to) { | 4109 virtual void RepresentationChanged(Representation to) { |
4114 if (to.IsTagged()) { | 4110 if (to.IsTagged()) { |
4115 SetAllSideEffects(); | 4111 SetAllSideEffects(); |
4116 ClearFlag(kUseGVN); | 4112 ClearFlag(kUseGVN); |
4117 } else { | 4113 } else { |
4118 ClearAllSideEffects(); | 4114 ClearAllSideEffects(); |
4119 SetFlag(kUseGVN); | 4115 SetFlag(kUseGVN); |
4120 } | 4116 } |
4121 } | 4117 } |
4122 | 4118 |
4123 virtual HType CalculateInferredType(); | |
4124 | |
4125 DECLARE_ABSTRACT_INSTRUCTION(ArithmeticBinaryOperation) | 4119 DECLARE_ABSTRACT_INSTRUCTION(ArithmeticBinaryOperation) |
4126 | 4120 |
4127 private: | 4121 private: |
4128 virtual bool IsDeletable() const { return true; } | 4122 virtual bool IsDeletable() const { return true; } |
4129 }; | 4123 }; |
4130 | 4124 |
4131 | 4125 |
4132 class HCompareGeneric: public HBinaryOperation { | 4126 class HCompareGeneric: public HBinaryOperation { |
4133 public: | 4127 public: |
4134 HCompareGeneric(HValue* context, | 4128 HCompareGeneric(HValue* context, |
4135 HValue* left, | 4129 HValue* left, |
4136 HValue* right, | 4130 HValue* right, |
4137 Token::Value token) | 4131 Token::Value token) |
4138 : HBinaryOperation(context, left, right), token_(token) { | 4132 : HBinaryOperation(context, left, right), token_(token) { |
4139 ASSERT(Token::IsCompareOp(token)); | 4133 ASSERT(Token::IsCompareOp(token)); |
4140 set_representation(Representation::Tagged()); | 4134 set_representation(Representation::Tagged()); |
| 4135 set_type(HType::Boolean()); |
4141 SetAllSideEffects(); | 4136 SetAllSideEffects(); |
4142 } | 4137 } |
4143 | 4138 |
4144 virtual Representation RequiredInputRepresentation(int index) { | 4139 virtual Representation RequiredInputRepresentation(int index) { |
4145 return index == 0 | 4140 return index == 0 |
4146 ? Representation::Tagged() | 4141 ? Representation::Tagged() |
4147 : representation(); | 4142 : representation(); |
4148 } | 4143 } |
4149 | 4144 |
4150 Token::Value token() const { return token_; } | 4145 Token::Value token() const { return token_; } |
4151 virtual void PrintDataTo(StringStream* stream); | 4146 virtual void PrintDataTo(StringStream* stream); |
4152 | 4147 |
4153 virtual HType CalculateInferredType(); | |
4154 | |
4155 DECLARE_CONCRETE_INSTRUCTION(CompareGeneric) | 4148 DECLARE_CONCRETE_INSTRUCTION(CompareGeneric) |
4156 | 4149 |
4157 private: | 4150 private: |
4158 Token::Value token_; | 4151 Token::Value token_; |
4159 }; | 4152 }; |
4160 | 4153 |
4161 | 4154 |
4162 class HCompareNumericAndBranch: public HTemplateControlInstruction<2, 2> { | 4155 class HCompareNumericAndBranch: public HTemplateControlInstruction<2, 2> { |
4163 public: | 4156 public: |
4164 HCompareNumericAndBranch(HValue* left, HValue* right, Token::Value token) | 4157 HCompareNumericAndBranch(HValue* left, HValue* right, Token::Value token) |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4422 private: | 4415 private: |
4423 Handle<String> type_literal_; | 4416 Handle<String> type_literal_; |
4424 }; | 4417 }; |
4425 | 4418 |
4426 | 4419 |
4427 class HInstanceOf: public HBinaryOperation { | 4420 class HInstanceOf: public HBinaryOperation { |
4428 public: | 4421 public: |
4429 HInstanceOf(HValue* context, HValue* left, HValue* right) | 4422 HInstanceOf(HValue* context, HValue* left, HValue* right) |
4430 : HBinaryOperation(context, left, right) { | 4423 : HBinaryOperation(context, left, right) { |
4431 set_representation(Representation::Tagged()); | 4424 set_representation(Representation::Tagged()); |
| 4425 set_type(HType::Boolean()); |
4432 SetAllSideEffects(); | 4426 SetAllSideEffects(); |
4433 } | 4427 } |
4434 | 4428 |
4435 virtual Representation RequiredInputRepresentation(int index) { | 4429 virtual Representation RequiredInputRepresentation(int index) { |
4436 return Representation::Tagged(); | 4430 return Representation::Tagged(); |
4437 } | 4431 } |
4438 | 4432 |
4439 virtual HType CalculateInferredType(); | |
4440 | |
4441 virtual void PrintDataTo(StringStream* stream); | 4433 virtual void PrintDataTo(StringStream* stream); |
4442 | 4434 |
4443 DECLARE_CONCRETE_INSTRUCTION(InstanceOf) | 4435 DECLARE_CONCRETE_INSTRUCTION(InstanceOf) |
4444 }; | 4436 }; |
4445 | 4437 |
4446 | 4438 |
4447 class HInstanceOfKnownGlobal: public HTemplateInstruction<2> { | 4439 class HInstanceOfKnownGlobal: public HTemplateInstruction<2> { |
4448 public: | 4440 public: |
4449 HInstanceOfKnownGlobal(HValue* context, | 4441 HInstanceOfKnownGlobal(HValue* context, |
4450 HValue* left, | 4442 HValue* left, |
4451 Handle<JSFunction> right) | 4443 Handle<JSFunction> right) |
4452 : function_(right) { | 4444 : function_(right) { |
4453 SetOperandAt(0, context); | 4445 SetOperandAt(0, context); |
4454 SetOperandAt(1, left); | 4446 SetOperandAt(1, left); |
| 4447 set_type(HType::Boolean()); |
4455 set_representation(Representation::Tagged()); | 4448 set_representation(Representation::Tagged()); |
4456 SetAllSideEffects(); | 4449 SetAllSideEffects(); |
4457 } | 4450 } |
4458 | 4451 |
4459 HValue* context() { return OperandAt(0); } | 4452 HValue* context() { return OperandAt(0); } |
4460 HValue* left() { return OperandAt(1); } | 4453 HValue* left() { return OperandAt(1); } |
4461 Handle<JSFunction> function() { return function_; } | 4454 Handle<JSFunction> function() { return function_; } |
4462 | 4455 |
4463 virtual Representation RequiredInputRepresentation(int index) { | 4456 virtual Representation RequiredInputRepresentation(int index) { |
4464 return Representation::Tagged(); | 4457 return Representation::Tagged(); |
4465 } | 4458 } |
4466 | 4459 |
4467 virtual HType CalculateInferredType(); | |
4468 | |
4469 DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal) | 4460 DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal) |
4470 | 4461 |
4471 private: | 4462 private: |
4472 Handle<JSFunction> function_; | 4463 Handle<JSFunction> function_; |
4473 }; | 4464 }; |
4474 | 4465 |
4475 | 4466 |
4476 // TODO(mstarzinger): This instruction should be modeled as a load of the map | 4467 // TODO(mstarzinger): This instruction should be modeled as a load of the map |
4477 // field followed by a load of the instance size field once HLoadNamedField is | 4468 // field followed by a load of the instance size field once HLoadNamedField is |
4478 // flexible enough to accommodate byte-field loads. | 4469 // flexible enough to accommodate byte-field loads. |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4557 HValue* right); | 4548 HValue* right); |
4558 | 4549 |
4559 // Add is only commutative if two integer values are added and not if two | 4550 // Add is only commutative if two integer values are added and not if two |
4560 // tagged values are added (because it might be a String concatenation). | 4551 // tagged values are added (because it might be a String concatenation). |
4561 virtual bool IsCommutative() const { | 4552 virtual bool IsCommutative() const { |
4562 return !representation().IsTagged(); | 4553 return !representation().IsTagged(); |
4563 } | 4554 } |
4564 | 4555 |
4565 virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited); | 4556 virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited); |
4566 | 4557 |
4567 virtual HType CalculateInferredType(); | |
4568 | |
4569 virtual HValue* Canonicalize(); | 4558 virtual HValue* Canonicalize(); |
4570 | 4559 |
4571 virtual bool TryDecompose(DecompositionResult* decomposition) { | 4560 virtual bool TryDecompose(DecompositionResult* decomposition) { |
4572 if (left()->IsInteger32Constant()) { | 4561 if (left()->IsInteger32Constant()) { |
4573 decomposition->Apply(right(), left()->GetInteger32Constant()); | 4562 decomposition->Apply(right(), left()->GetInteger32Constant()); |
4574 return true; | 4563 return true; |
4575 } else if (right()->IsInteger32Constant()) { | 4564 } else if (right()->IsInteger32Constant()) { |
4576 decomposition->Apply(left(), right()->GetInteger32Constant()); | 4565 decomposition->Apply(left(), right()->GetInteger32Constant()); |
4577 return true; | 4566 return true; |
4578 } else { | 4567 } else { |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4872 // sign-extension of the smi-sign. | 4861 // sign-extension of the smi-sign. |
4873 } else if (op == Token::BIT_OR && | 4862 } else if (op == Token::BIT_OR && |
4874 ((left->IsConstant() && | 4863 ((left->IsConstant() && |
4875 left->representation().IsSmi() && | 4864 left->representation().IsSmi() && |
4876 HConstant::cast(left)->Integer32Value() < 0) || | 4865 HConstant::cast(left)->Integer32Value() < 0) || |
4877 (right->IsConstant() && | 4866 (right->IsConstant() && |
4878 right->representation().IsSmi() && | 4867 right->representation().IsSmi() && |
4879 HConstant::cast(right)->Integer32Value() < 0))) { | 4868 HConstant::cast(right)->Integer32Value() < 0))) { |
4880 SetFlag(kTruncatingToSmi); | 4869 SetFlag(kTruncatingToSmi); |
4881 } | 4870 } |
| 4871 set_type(HType::TaggedNumber()); |
4882 } | 4872 } |
4883 | 4873 |
4884 Token::Value op_; | 4874 Token::Value op_; |
4885 }; | 4875 }; |
4886 | 4876 |
4887 | 4877 |
4888 class HShl: public HBitwiseBinaryOperation { | 4878 class HShl: public HBitwiseBinaryOperation { |
4889 public: | 4879 public: |
4890 static HInstruction* New(Zone* zone, | 4880 static HInstruction* New(Zone* zone, |
4891 HValue* context, | 4881 HValue* context, |
(...skipping 1566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6458 HValue* left, | 6448 HValue* left, |
6459 HValue* right, | 6449 HValue* right, |
6460 StringAddFlags flags = STRING_ADD_CHECK_NONE); | 6450 StringAddFlags flags = STRING_ADD_CHECK_NONE); |
6461 | 6451 |
6462 StringAddFlags flags() const { return flags_; } | 6452 StringAddFlags flags() const { return flags_; } |
6463 | 6453 |
6464 virtual Representation RequiredInputRepresentation(int index) { | 6454 virtual Representation RequiredInputRepresentation(int index) { |
6465 return Representation::Tagged(); | 6455 return Representation::Tagged(); |
6466 } | 6456 } |
6467 | 6457 |
6468 virtual HType CalculateInferredType() { | |
6469 return HType::String(); | |
6470 } | |
6471 | |
6472 DECLARE_CONCRETE_INSTRUCTION(StringAdd) | 6458 DECLARE_CONCRETE_INSTRUCTION(StringAdd) |
6473 | 6459 |
6474 protected: | 6460 protected: |
6475 virtual bool DataEquals(HValue* other) { return true; } | 6461 virtual bool DataEquals(HValue* other) { return true; } |
6476 | 6462 |
6477 private: | 6463 private: |
6478 HStringAdd(HValue* context, HValue* left, HValue* right, StringAddFlags flags) | 6464 HStringAdd(HValue* context, HValue* left, HValue* right, StringAddFlags flags) |
6479 : HBinaryOperation(context, left, right), flags_(flags) { | 6465 : HBinaryOperation(context, left, right), flags_(flags) { |
6480 set_representation(Representation::Tagged()); | 6466 set_representation(Representation::Tagged()); |
6481 SetFlag(kUseGVN); | 6467 SetFlag(kUseGVN); |
6482 SetGVNFlag(kDependsOnMaps); | 6468 SetGVNFlag(kDependsOnMaps); |
6483 SetGVNFlag(kChangesNewSpacePromotion); | 6469 SetGVNFlag(kChangesNewSpacePromotion); |
| 6470 set_type(HType::String()); |
6484 } | 6471 } |
6485 | 6472 |
6486 // No side-effects except possible allocation. | 6473 // No side-effects except possible allocation. |
6487 // NOTE: this instruction _does not_ call ToString() on its inputs. | 6474 // NOTE: this instruction _does not_ call ToString() on its inputs. |
6488 virtual bool IsDeletable() const { return true; } | 6475 virtual bool IsDeletable() const { return true; } |
6489 | 6476 |
6490 const StringAddFlags flags_; | 6477 const StringAddFlags flags_; |
6491 }; | 6478 }; |
6492 | 6479 |
6493 | 6480 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6533 public: | 6520 public: |
6534 static HInstruction* New(Zone* zone, | 6521 static HInstruction* New(Zone* zone, |
6535 HValue* context, | 6522 HValue* context, |
6536 HValue* char_code); | 6523 HValue* char_code); |
6537 | 6524 |
6538 virtual Representation RequiredInputRepresentation(int index) { | 6525 virtual Representation RequiredInputRepresentation(int index) { |
6539 return index == 0 | 6526 return index == 0 |
6540 ? Representation::Tagged() | 6527 ? Representation::Tagged() |
6541 : Representation::Integer32(); | 6528 : Representation::Integer32(); |
6542 } | 6529 } |
6543 virtual HType CalculateInferredType() { return HType::String(); } | |
6544 | 6530 |
6545 HValue* context() const { return OperandAt(0); } | 6531 HValue* context() const { return OperandAt(0); } |
6546 HValue* value() const { return OperandAt(1); } | 6532 HValue* value() const { return OperandAt(1); } |
6547 | 6533 |
6548 virtual bool DataEquals(HValue* other) { return true; } | 6534 virtual bool DataEquals(HValue* other) { return true; } |
6549 | 6535 |
6550 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode) | 6536 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode) |
6551 | 6537 |
6552 private: | 6538 private: |
6553 HStringCharFromCode(HValue* context, HValue* char_code) { | 6539 HStringCharFromCode(HValue* context, HValue* char_code) { |
6554 SetOperandAt(0, context); | 6540 SetOperandAt(0, context); |
6555 SetOperandAt(1, char_code); | 6541 SetOperandAt(1, char_code); |
6556 set_representation(Representation::Tagged()); | 6542 set_representation(Representation::Tagged()); |
6557 SetFlag(kUseGVN); | 6543 SetFlag(kUseGVN); |
6558 SetGVNFlag(kChangesNewSpacePromotion); | 6544 SetGVNFlag(kChangesNewSpacePromotion); |
| 6545 set_type(HType::String()); |
6559 } | 6546 } |
6560 | 6547 |
6561 virtual bool IsDeletable() const { | 6548 virtual bool IsDeletable() const { |
6562 return !value()->ToNumberCanBeObserved(); | 6549 return !value()->ToNumberCanBeObserved(); |
6563 } | 6550 } |
6564 }; | 6551 }; |
6565 | 6552 |
6566 | 6553 |
6567 class HStringLength: public HUnaryOperation { | 6554 class HStringLength: public HUnaryOperation { |
6568 public: | 6555 public: |
6569 static HInstruction* New(Zone* zone, HValue* string); | 6556 static HInstruction* New(Zone* zone, HValue* string); |
6570 | 6557 |
6571 virtual Representation RequiredInputRepresentation(int index) { | 6558 virtual Representation RequiredInputRepresentation(int index) { |
6572 return Representation::Tagged(); | 6559 return Representation::Tagged(); |
6573 } | 6560 } |
6574 | 6561 |
6575 virtual HType CalculateInferredType() { | |
6576 STATIC_ASSERT(String::kMaxLength <= Smi::kMaxValue); | |
6577 return HType::Smi(); | |
6578 } | |
6579 | |
6580 DECLARE_CONCRETE_INSTRUCTION(StringLength) | 6562 DECLARE_CONCRETE_INSTRUCTION(StringLength) |
6581 | 6563 |
6582 protected: | 6564 protected: |
6583 virtual bool DataEquals(HValue* other) { return true; } | 6565 virtual bool DataEquals(HValue* other) { return true; } |
6584 | 6566 |
6585 virtual Range* InferRange(Zone* zone) { | 6567 virtual Range* InferRange(Zone* zone) { |
6586 return new(zone) Range(0, String::kMaxLength); | 6568 return new(zone) Range(0, String::kMaxLength); |
6587 } | 6569 } |
6588 | 6570 |
6589 private: | 6571 private: |
6590 explicit HStringLength(HValue* string) : HUnaryOperation(string) { | 6572 explicit HStringLength(HValue* string) : HUnaryOperation(string) { |
| 6573 STATIC_ASSERT(String::kMaxLength <= Smi::kMaxValue); |
6591 set_representation(Representation::Tagged()); | 6574 set_representation(Representation::Tagged()); |
6592 SetFlag(kUseGVN); | 6575 SetFlag(kUseGVN); |
6593 SetGVNFlag(kDependsOnMaps); | 6576 SetGVNFlag(kDependsOnMaps); |
| 6577 set_type(HType::Smi()); |
6594 } | 6578 } |
6595 | 6579 |
6596 virtual bool IsDeletable() const { return true; } | 6580 virtual bool IsDeletable() const { return true; } |
6597 }; | 6581 }; |
6598 | 6582 |
6599 | 6583 |
6600 template <int V> | 6584 template <int V> |
6601 class HMaterializedLiteral: public HTemplateInstruction<V> { | 6585 class HMaterializedLiteral: public HTemplateInstruction<V> { |
6602 public: | 6586 public: |
6603 HMaterializedLiteral<V>(int index, int depth, AllocationSiteMode mode) | 6587 HMaterializedLiteral<V>(int index, int depth, AllocationSiteMode mode) |
(...skipping 28 matching lines...) Expand all Loading... |
6632 Handle<FixedArray> literals, | 6616 Handle<FixedArray> literals, |
6633 Handle<String> pattern, | 6617 Handle<String> pattern, |
6634 Handle<String> flags, | 6618 Handle<String> flags, |
6635 int literal_index) | 6619 int literal_index) |
6636 : HMaterializedLiteral<1>(literal_index, 0), | 6620 : HMaterializedLiteral<1>(literal_index, 0), |
6637 literals_(literals), | 6621 literals_(literals), |
6638 pattern_(pattern), | 6622 pattern_(pattern), |
6639 flags_(flags) { | 6623 flags_(flags) { |
6640 SetOperandAt(0, context); | 6624 SetOperandAt(0, context); |
6641 SetAllSideEffects(); | 6625 SetAllSideEffects(); |
| 6626 set_type(HType::JSObject()); |
6642 } | 6627 } |
6643 | 6628 |
6644 HValue* context() { return OperandAt(0); } | 6629 HValue* context() { return OperandAt(0); } |
6645 Handle<FixedArray> literals() { return literals_; } | 6630 Handle<FixedArray> literals() { return literals_; } |
6646 Handle<String> pattern() { return pattern_; } | 6631 Handle<String> pattern() { return pattern_; } |
6647 Handle<String> flags() { return flags_; } | 6632 Handle<String> flags() { return flags_; } |
6648 | 6633 |
6649 virtual Representation RequiredInputRepresentation(int index) { | 6634 virtual Representation RequiredInputRepresentation(int index) { |
6650 return Representation::Tagged(); | 6635 return Representation::Tagged(); |
6651 } | 6636 } |
6652 virtual HType CalculateInferredType(); | |
6653 | 6637 |
6654 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral) | 6638 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral) |
6655 | 6639 |
6656 private: | 6640 private: |
6657 Handle<FixedArray> literals_; | 6641 Handle<FixedArray> literals_; |
6658 Handle<String> pattern_; | 6642 Handle<String> pattern_; |
6659 Handle<String> flags_; | 6643 Handle<String> flags_; |
6660 }; | 6644 }; |
6661 | 6645 |
6662 | 6646 |
6663 class HFunctionLiteral: public HTemplateInstruction<1> { | 6647 class HFunctionLiteral: public HTemplateInstruction<1> { |
6664 public: | 6648 public: |
6665 HFunctionLiteral(HValue* context, | 6649 HFunctionLiteral(HValue* context, |
6666 Handle<SharedFunctionInfo> shared, | 6650 Handle<SharedFunctionInfo> shared, |
6667 bool pretenure) | 6651 bool pretenure) |
6668 : shared_info_(shared), | 6652 : shared_info_(shared), |
6669 pretenure_(pretenure), | 6653 pretenure_(pretenure), |
6670 has_no_literals_(shared->num_literals() == 0), | 6654 has_no_literals_(shared->num_literals() == 0), |
6671 is_generator_(shared->is_generator()), | 6655 is_generator_(shared->is_generator()), |
6672 language_mode_(shared->language_mode()) { | 6656 language_mode_(shared->language_mode()) { |
6673 SetOperandAt(0, context); | 6657 SetOperandAt(0, context); |
| 6658 set_type(HType::JSObject()); |
6674 set_representation(Representation::Tagged()); | 6659 set_representation(Representation::Tagged()); |
6675 SetGVNFlag(kChangesNewSpacePromotion); | 6660 SetGVNFlag(kChangesNewSpacePromotion); |
6676 } | 6661 } |
6677 | 6662 |
6678 HValue* context() { return OperandAt(0); } | 6663 HValue* context() { return OperandAt(0); } |
6679 | 6664 |
6680 virtual Representation RequiredInputRepresentation(int index) { | 6665 virtual Representation RequiredInputRepresentation(int index) { |
6681 return Representation::Tagged(); | 6666 return Representation::Tagged(); |
6682 } | 6667 } |
6683 virtual HType CalculateInferredType(); | |
6684 | 6668 |
6685 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral) | 6669 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral) |
6686 | 6670 |
6687 Handle<SharedFunctionInfo> shared_info() const { return shared_info_; } | 6671 Handle<SharedFunctionInfo> shared_info() const { return shared_info_; } |
6688 bool pretenure() const { return pretenure_; } | 6672 bool pretenure() const { return pretenure_; } |
6689 bool has_no_literals() const { return has_no_literals_; } | 6673 bool has_no_literals() const { return has_no_literals_; } |
6690 bool is_generator() const { return is_generator_; } | 6674 bool is_generator() const { return is_generator_; } |
6691 LanguageMode language_mode() const { return language_mode_; } | 6675 LanguageMode language_mode() const { return language_mode_; } |
6692 | 6676 |
6693 private: | 6677 private: |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6962 virtual bool IsDeletable() const { return true; } | 6946 virtual bool IsDeletable() const { return true; } |
6963 }; | 6947 }; |
6964 | 6948 |
6965 | 6949 |
6966 #undef DECLARE_INSTRUCTION | 6950 #undef DECLARE_INSTRUCTION |
6967 #undef DECLARE_CONCRETE_INSTRUCTION | 6951 #undef DECLARE_CONCRETE_INSTRUCTION |
6968 | 6952 |
6969 } } // namespace v8::internal | 6953 } } // namespace v8::internal |
6970 | 6954 |
6971 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ | 6955 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ |
OLD | NEW |