Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(65)

Side by Side Diff: src/hydrogen-instructions.h

Issue 8551006: Version 3.7.9. (Closed) Base URL: http://v8.googlecode.com/svn/trunk/
Patch Set: Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/hydrogen.cc ('k') | src/hydrogen-instructions.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 V(Goto) \ 111 V(Goto) \
112 V(HasCachedArrayIndexAndBranch) \ 112 V(HasCachedArrayIndexAndBranch) \
113 V(HasInstanceTypeAndBranch) \ 113 V(HasInstanceTypeAndBranch) \
114 V(In) \ 114 V(In) \
115 V(InstanceOf) \ 115 V(InstanceOf) \
116 V(InstanceOfKnownGlobal) \ 116 V(InstanceOfKnownGlobal) \
117 V(InvokeFunction) \ 117 V(InvokeFunction) \
118 V(IsConstructCallAndBranch) \ 118 V(IsConstructCallAndBranch) \
119 V(IsNilAndBranch) \ 119 V(IsNilAndBranch) \
120 V(IsObjectAndBranch) \ 120 V(IsObjectAndBranch) \
121 V(IsStringAndBranch) \
121 V(IsSmiAndBranch) \ 122 V(IsSmiAndBranch) \
122 V(IsUndetectableAndBranch) \ 123 V(IsUndetectableAndBranch) \
124 V(StringCompareAndBranch) \
123 V(JSArrayLength) \ 125 V(JSArrayLength) \
124 V(LeaveInlined) \ 126 V(LeaveInlined) \
125 V(LoadContextSlot) \ 127 V(LoadContextSlot) \
126 V(LoadElements) \ 128 V(LoadElements) \
127 V(LoadExternalArrayPointer) \ 129 V(LoadExternalArrayPointer) \
128 V(LoadFunctionPrototype) \ 130 V(LoadFunctionPrototype) \
129 V(LoadGlobalCell) \ 131 V(LoadGlobalCell) \
130 V(LoadGlobalGeneric) \ 132 V(LoadGlobalGeneric) \
131 V(LoadKeyedFastDoubleElement) \ 133 V(LoadKeyedFastDoubleElement) \
132 V(LoadKeyedFastElement) \ 134 V(LoadKeyedFastElement) \
(...skipping 2186 matching lines...) Expand 10 before | Expand all | Expand 10 after
2319 bool HasInteger32Value() const { return has_int32_value_; } 2321 bool HasInteger32Value() const { return has_int32_value_; }
2320 int32_t Integer32Value() const { 2322 int32_t Integer32Value() const {
2321 ASSERT(HasInteger32Value()); 2323 ASSERT(HasInteger32Value());
2322 return int32_value_; 2324 return int32_value_;
2323 } 2325 }
2324 bool HasDoubleValue() const { return has_double_value_; } 2326 bool HasDoubleValue() const { return has_double_value_; }
2325 double DoubleValue() const { 2327 double DoubleValue() const {
2326 ASSERT(HasDoubleValue()); 2328 ASSERT(HasDoubleValue());
2327 return double_value_; 2329 return double_value_;
2328 } 2330 }
2331 bool HasNumberValue() const { return has_int32_value_ || has_double_value_; }
2332 int32_t NumberValueAsInteger32() const {
2333 ASSERT(HasNumberValue());
2334 if (has_int32_value_) return int32_value_;
2335 return DoubleToInt32(double_value_);
2336 }
2329 bool HasStringValue() const { return handle_->IsString(); } 2337 bool HasStringValue() const { return handle_->IsString(); }
2330 2338
2331 bool ToBoolean() const; 2339 bool ToBoolean() const;
2332 2340
2333 virtual intptr_t Hashcode() { 2341 virtual intptr_t Hashcode() {
2334 ASSERT(!HEAP->allow_allocation(false)); 2342 ASSERT(!HEAP->allow_allocation(false));
2335 return reinterpret_cast<intptr_t>(*handle()); 2343 return reinterpret_cast<intptr_t>(*handle());
2336 } 2344 }
2337 2345
2338 #ifdef DEBUG 2346 #ifdef DEBUG
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
2709 explicit HIsObjectAndBranch(HValue* value) 2717 explicit HIsObjectAndBranch(HValue* value)
2710 : HUnaryControlInstruction(value, NULL, NULL) { } 2718 : HUnaryControlInstruction(value, NULL, NULL) { }
2711 2719
2712 virtual Representation RequiredInputRepresentation(int index) { 2720 virtual Representation RequiredInputRepresentation(int index) {
2713 return Representation::Tagged(); 2721 return Representation::Tagged();
2714 } 2722 }
2715 2723
2716 DECLARE_CONCRETE_INSTRUCTION(IsObjectAndBranch) 2724 DECLARE_CONCRETE_INSTRUCTION(IsObjectAndBranch)
2717 }; 2725 };
2718 2726
2727 class HIsStringAndBranch: public HUnaryControlInstruction {
2728 public:
2729 explicit HIsStringAndBranch(HValue* value)
2730 : HUnaryControlInstruction(value, NULL, NULL) { }
2731
2732 virtual Representation RequiredInputRepresentation(int index) {
2733 return Representation::Tagged();
2734 }
2735
2736 DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch)
2737 };
2738
2719 2739
2720 class HIsSmiAndBranch: public HUnaryControlInstruction { 2740 class HIsSmiAndBranch: public HUnaryControlInstruction {
2721 public: 2741 public:
2722 explicit HIsSmiAndBranch(HValue* value) 2742 explicit HIsSmiAndBranch(HValue* value)
2723 : HUnaryControlInstruction(value, NULL, NULL) { } 2743 : HUnaryControlInstruction(value, NULL, NULL) { }
2724 2744
2725 DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch) 2745 DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch)
2726 2746
2727 virtual Representation RequiredInputRepresentation(int index) { 2747 virtual Representation RequiredInputRepresentation(int index) {
2728 return Representation::Tagged(); 2748 return Representation::Tagged();
(...skipping 10 matching lines...) Expand all
2739 : HUnaryControlInstruction(value, NULL, NULL) { } 2759 : HUnaryControlInstruction(value, NULL, NULL) { }
2740 2760
2741 virtual Representation RequiredInputRepresentation(int index) { 2761 virtual Representation RequiredInputRepresentation(int index) {
2742 return Representation::Tagged(); 2762 return Representation::Tagged();
2743 } 2763 }
2744 2764
2745 DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch) 2765 DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch)
2746 }; 2766 };
2747 2767
2748 2768
2769 class HStringCompareAndBranch: public HTemplateControlInstruction<2, 3> {
2770 public:
2771 HStringCompareAndBranch(HValue* context,
2772 HValue* left,
2773 HValue* right,
2774 Token::Value token)
2775 : token_(token) {
2776 ASSERT(Token::IsCompareOp(token));
2777 SetOperandAt(0, context);
2778 SetOperandAt(1, left);
2779 SetOperandAt(2, right);
2780 set_representation(Representation::Tagged());
2781 }
2782
2783 HValue* context() { return OperandAt(0); }
2784 HValue* left() { return OperandAt(1); }
2785 HValue* right() { return OperandAt(2); }
2786 Token::Value token() const { return token_; }
2787
2788 virtual void PrintDataTo(StringStream* stream);
2789
2790 virtual Representation RequiredInputRepresentation(int index) {
2791 return Representation::Tagged();
2792 }
2793
2794 Representation GetInputRepresentation() const {
2795 return Representation::Tagged();
2796 }
2797
2798 DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch)
2799
2800 private:
2801 Token::Value token_;
2802 };
2803
2804
2749 class HIsConstructCallAndBranch: public HTemplateControlInstruction<2, 0> { 2805 class HIsConstructCallAndBranch: public HTemplateControlInstruction<2, 0> {
2750 public: 2806 public:
2751 virtual Representation RequiredInputRepresentation(int index) { 2807 virtual Representation RequiredInputRepresentation(int index) {
2752 return Representation::None(); 2808 return Representation::None();
2753 } 2809 }
2754 2810
2755 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch) 2811 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch)
2756 }; 2812 };
2757 2813
2758 2814
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
2936 } 2992 }
2937 2993
2938 // Add is only commutative if two integer values are added and not if two 2994 // Add is only commutative if two integer values are added and not if two
2939 // tagged values are added (because it might be a String concatenation). 2995 // tagged values are added (because it might be a String concatenation).
2940 virtual bool IsCommutative() const { 2996 virtual bool IsCommutative() const {
2941 return !representation().IsTagged(); 2997 return !representation().IsTagged();
2942 } 2998 }
2943 2999
2944 virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited); 3000 virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited);
2945 3001
3002 static HInstruction* NewHAdd(Zone* zone,
3003 HValue* context,
3004 HValue* left,
3005 HValue* right);
3006
2946 virtual HType CalculateInferredType(); 3007 virtual HType CalculateInferredType();
2947 3008
2948 DECLARE_CONCRETE_INSTRUCTION(Add) 3009 DECLARE_CONCRETE_INSTRUCTION(Add)
2949 3010
2950 protected: 3011 protected:
2951 virtual bool DataEquals(HValue* other) { return true; } 3012 virtual bool DataEquals(HValue* other) { return true; }
2952 3013
2953 virtual Range* InferRange(); 3014 virtual Range* InferRange();
2954 }; 3015 };
2955 3016
2956 3017
2957 class HSub: public HArithmeticBinaryOperation { 3018 class HSub: public HArithmeticBinaryOperation {
2958 public: 3019 public:
2959 HSub(HValue* context, HValue* left, HValue* right) 3020 HSub(HValue* context, HValue* left, HValue* right)
2960 : HArithmeticBinaryOperation(context, left, right) { 3021 : HArithmeticBinaryOperation(context, left, right) {
2961 SetFlag(kCanOverflow); 3022 SetFlag(kCanOverflow);
2962 } 3023 }
2963 3024
2964 virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited); 3025 virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited);
2965 3026
3027 static HInstruction* NewHSub(Zone* zone,
3028 HValue* context,
3029 HValue* left,
3030 HValue* right);
3031
2966 DECLARE_CONCRETE_INSTRUCTION(Sub) 3032 DECLARE_CONCRETE_INSTRUCTION(Sub)
2967 3033
2968 protected: 3034 protected:
2969 virtual bool DataEquals(HValue* other) { return true; } 3035 virtual bool DataEquals(HValue* other) { return true; }
2970 3036
2971 virtual Range* InferRange(); 3037 virtual Range* InferRange();
2972 }; 3038 };
2973 3039
2974 3040
2975 class HMul: public HArithmeticBinaryOperation { 3041 class HMul: public HArithmeticBinaryOperation {
2976 public: 3042 public:
2977 HMul(HValue* context, HValue* left, HValue* right) 3043 HMul(HValue* context, HValue* left, HValue* right)
2978 : HArithmeticBinaryOperation(context, left, right) { 3044 : HArithmeticBinaryOperation(context, left, right) {
2979 SetFlag(kCanOverflow); 3045 SetFlag(kCanOverflow);
2980 } 3046 }
2981 3047
2982 virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited); 3048 virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited);
2983 3049
2984 // Only commutative if it is certain that not two objects are multiplicated. 3050 // Only commutative if it is certain that not two objects are multiplicated.
2985 virtual bool IsCommutative() const { 3051 virtual bool IsCommutative() const {
2986 return !representation().IsTagged(); 3052 return !representation().IsTagged();
2987 } 3053 }
2988 3054
3055 static HInstruction* NewHMul(Zone* zone,
3056 HValue* context,
3057 HValue* left,
3058 HValue* right);
3059
2989 DECLARE_CONCRETE_INSTRUCTION(Mul) 3060 DECLARE_CONCRETE_INSTRUCTION(Mul)
2990 3061
2991 protected: 3062 protected:
2992 virtual bool DataEquals(HValue* other) { return true; } 3063 virtual bool DataEquals(HValue* other) { return true; }
2993 3064
2994 virtual Range* InferRange(); 3065 virtual Range* InferRange();
2995 }; 3066 };
2996 3067
2997 3068
2998 class HMod: public HArithmeticBinaryOperation { 3069 class HMod: public HArithmeticBinaryOperation {
2999 public: 3070 public:
3000 HMod(HValue* context, HValue* left, HValue* right) 3071 HMod(HValue* context, HValue* left, HValue* right)
3001 : HArithmeticBinaryOperation(context, left, right) { 3072 : HArithmeticBinaryOperation(context, left, right) {
3002 SetFlag(kCanBeDivByZero); 3073 SetFlag(kCanBeDivByZero);
3003 } 3074 }
3004 3075
3005 bool HasPowerOf2Divisor() { 3076 bool HasPowerOf2Divisor() {
3006 if (right()->IsConstant() && 3077 if (right()->IsConstant() &&
3007 HConstant::cast(right())->HasInteger32Value()) { 3078 HConstant::cast(right())->HasInteger32Value()) {
3008 int32_t value = HConstant::cast(right())->Integer32Value(); 3079 int32_t value = HConstant::cast(right())->Integer32Value();
3009 return value != 0 && (IsPowerOf2(value) || IsPowerOf2(-value)); 3080 return value != 0 && (IsPowerOf2(value) || IsPowerOf2(-value));
3010 } 3081 }
3011 3082
3012 return false; 3083 return false;
3013 } 3084 }
3014 3085
3015 virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited); 3086 virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited);
3016 3087
3088 static HInstruction* NewHMod(Zone* zone,
3089 HValue* context,
3090 HValue* left,
3091 HValue* right);
3092
3017 DECLARE_CONCRETE_INSTRUCTION(Mod) 3093 DECLARE_CONCRETE_INSTRUCTION(Mod)
3018 3094
3019 protected: 3095 protected:
3020 virtual bool DataEquals(HValue* other) { return true; } 3096 virtual bool DataEquals(HValue* other) { return true; }
3021 3097
3022 virtual Range* InferRange(); 3098 virtual Range* InferRange();
3023 }; 3099 };
3024 3100
3025 3101
3026 class HDiv: public HArithmeticBinaryOperation { 3102 class HDiv: public HArithmeticBinaryOperation {
3027 public: 3103 public:
3028 HDiv(HValue* context, HValue* left, HValue* right) 3104 HDiv(HValue* context, HValue* left, HValue* right)
3029 : HArithmeticBinaryOperation(context, left, right) { 3105 : HArithmeticBinaryOperation(context, left, right) {
3030 SetFlag(kCanBeDivByZero); 3106 SetFlag(kCanBeDivByZero);
3031 SetFlag(kCanOverflow); 3107 SetFlag(kCanOverflow);
3032 } 3108 }
3033 3109
3034 virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited); 3110 virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited);
3035 3111
3112
3113 static HInstruction* NewHDiv(Zone* zone,
3114 HValue* context,
3115 HValue* left,
3116 HValue* right);
3117
3036 DECLARE_CONCRETE_INSTRUCTION(Div) 3118 DECLARE_CONCRETE_INSTRUCTION(Div)
3037 3119
3038 protected: 3120 protected:
3039 virtual bool DataEquals(HValue* other) { return true; } 3121 virtual bool DataEquals(HValue* other) { return true; }
3040 3122
3041 virtual Range* InferRange(); 3123 virtual Range* InferRange();
3042 }; 3124 };
3043 3125
3044 3126
3045 class HBitwise: public HBitwiseBinaryOperation { 3127 class HBitwise: public HBitwiseBinaryOperation {
3046 public: 3128 public:
3047 HBitwise(Token::Value op, HValue* context, HValue* left, HValue* right) 3129 HBitwise(Token::Value op, HValue* context, HValue* left, HValue* right)
3048 : HBitwiseBinaryOperation(context, left, right), op_(op) { 3130 : HBitwiseBinaryOperation(context, left, right), op_(op) {
3049 ASSERT(op == Token::BIT_AND || 3131 ASSERT(op == Token::BIT_AND ||
3050 op == Token::BIT_OR || 3132 op == Token::BIT_OR ||
3051 op == Token::BIT_XOR); 3133 op == Token::BIT_XOR);
3052 } 3134 }
3053 3135
3054 Token::Value op() const { return op_; } 3136 Token::Value op() const { return op_; }
3055 3137
3056 virtual bool IsCommutative() const { return true; } 3138 virtual bool IsCommutative() const { return true; }
3057 3139
3140 static HInstruction* NewHBitwise(Zone* zone,
3141 Token::Value op,
3142 HValue* context,
3143 HValue* left,
3144 HValue* right);
3145
3058 DECLARE_CONCRETE_INSTRUCTION(Bitwise) 3146 DECLARE_CONCRETE_INSTRUCTION(Bitwise)
3059 3147
3060 protected: 3148 protected:
3061 virtual bool DataEquals(HValue* other) { 3149 virtual bool DataEquals(HValue* other) {
3062 return op() == HBitwise::cast(other)->op(); 3150 return op() == HBitwise::cast(other)->op();
3063 } 3151 }
3064 3152
3065 virtual Range* InferRange(); 3153 virtual Range* InferRange();
3066 3154
3067 private: 3155 private:
3068 Token::Value op_; 3156 Token::Value op_;
3069 }; 3157 };
3070 3158
3071 3159
3072 class HShl: public HBitwiseBinaryOperation { 3160 class HShl: public HBitwiseBinaryOperation {
3073 public: 3161 public:
3074 HShl(HValue* context, HValue* left, HValue* right) 3162 HShl(HValue* context, HValue* left, HValue* right)
3075 : HBitwiseBinaryOperation(context, left, right) { } 3163 : HBitwiseBinaryOperation(context, left, right) { }
3076 3164
3077 virtual Range* InferRange(); 3165 virtual Range* InferRange();
3078 3166
3167 static HInstruction* NewHShl(Zone* zone,
3168 HValue* context,
3169 HValue* left,
3170 HValue* right);
3171
3079 DECLARE_CONCRETE_INSTRUCTION(Shl) 3172 DECLARE_CONCRETE_INSTRUCTION(Shl)
3080 3173
3081 protected: 3174 protected:
3082 virtual bool DataEquals(HValue* other) { return true; } 3175 virtual bool DataEquals(HValue* other) { return true; }
3083 }; 3176 };
3084 3177
3085 3178
3086 class HShr: public HBitwiseBinaryOperation { 3179 class HShr: public HBitwiseBinaryOperation {
3087 public: 3180 public:
3088 HShr(HValue* context, HValue* left, HValue* right) 3181 HShr(HValue* context, HValue* left, HValue* right)
3089 : HBitwiseBinaryOperation(context, left, right) { } 3182 : HBitwiseBinaryOperation(context, left, right) { }
3090 3183
3091 virtual Range* InferRange(); 3184 virtual Range* InferRange();
3092 3185
3186 static HInstruction* NewHShr(Zone* zone,
3187 HValue* context,
3188 HValue* left,
3189 HValue* right);
3190
3093 DECLARE_CONCRETE_INSTRUCTION(Shr) 3191 DECLARE_CONCRETE_INSTRUCTION(Shr)
3094 3192
3095 protected: 3193 protected:
3096 virtual bool DataEquals(HValue* other) { return true; } 3194 virtual bool DataEquals(HValue* other) { return true; }
3097 }; 3195 };
3098 3196
3099 3197
3100 class HSar: public HBitwiseBinaryOperation { 3198 class HSar: public HBitwiseBinaryOperation {
3101 public: 3199 public:
3102 HSar(HValue* context, HValue* left, HValue* right) 3200 HSar(HValue* context, HValue* left, HValue* right)
3103 : HBitwiseBinaryOperation(context, left, right) { } 3201 : HBitwiseBinaryOperation(context, left, right) { }
3104 3202
3105 virtual Range* InferRange(); 3203 virtual Range* InferRange();
3106 3204
3205 static HInstruction* NewHSar(Zone* zone,
3206 HValue* context,
3207 HValue* left,
3208 HValue* right);
3209
3107 DECLARE_CONCRETE_INSTRUCTION(Sar) 3210 DECLARE_CONCRETE_INSTRUCTION(Sar)
3108 3211
3109 protected: 3212 protected:
3110 virtual bool DataEquals(HValue* other) { return true; } 3213 virtual bool DataEquals(HValue* other) { return true; }
3111 }; 3214 };
3112 3215
3113 3216
3114 class HOsrEntry: public HTemplateInstruction<0> { 3217 class HOsrEntry: public HTemplateInstruction<0> {
3115 public: 3218 public:
3116 explicit HOsrEntry(int ast_id) : ast_id_(ast_id) { 3219 explicit HOsrEntry(int ast_id) : ast_id_(ast_id) {
(...skipping 1170 matching lines...) Expand 10 before | Expand all | Expand 10 after
4287 4390
4288 DECLARE_CONCRETE_INSTRUCTION(In) 4391 DECLARE_CONCRETE_INSTRUCTION(In)
4289 }; 4392 };
4290 4393
4291 #undef DECLARE_INSTRUCTION 4394 #undef DECLARE_INSTRUCTION
4292 #undef DECLARE_CONCRETE_INSTRUCTION 4395 #undef DECLARE_CONCRETE_INSTRUCTION
4293 4396
4294 } } // namespace v8::internal 4397 } } // namespace v8::internal
4295 4398
4296 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ 4399 #endif // V8_HYDROGEN_INSTRUCTIONS_H_
OLDNEW
« no previous file with comments | « src/hydrogen.cc ('k') | src/hydrogen-instructions.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698