OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 2310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2321 bool HasInteger32Value() const { return has_int32_value_; } | 2321 bool HasInteger32Value() const { return has_int32_value_; } |
2322 int32_t Integer32Value() const { | 2322 int32_t Integer32Value() const { |
2323 ASSERT(HasInteger32Value()); | 2323 ASSERT(HasInteger32Value()); |
2324 return int32_value_; | 2324 return int32_value_; |
2325 } | 2325 } |
2326 bool HasDoubleValue() const { return has_double_value_; } | 2326 bool HasDoubleValue() const { return has_double_value_; } |
2327 double DoubleValue() const { | 2327 double DoubleValue() const { |
2328 ASSERT(HasDoubleValue()); | 2328 ASSERT(HasDoubleValue()); |
2329 return double_value_; | 2329 return double_value_; |
2330 } | 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 } |
2331 bool HasStringValue() const { return handle_->IsString(); } | 2337 bool HasStringValue() const { return handle_->IsString(); } |
2332 | 2338 |
2333 bool ToBoolean() const; | 2339 bool ToBoolean() const; |
2334 | 2340 |
2335 virtual intptr_t Hashcode() { | 2341 virtual intptr_t Hashcode() { |
2336 ASSERT(!HEAP->allow_allocation(false)); | 2342 ASSERT(!HEAP->allow_allocation(false)); |
2337 return reinterpret_cast<intptr_t>(*handle()); | 2343 return reinterpret_cast<intptr_t>(*handle()); |
2338 } | 2344 } |
2339 | 2345 |
2340 #ifdef DEBUG | 2346 #ifdef DEBUG |
(...skipping 645 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2986 } | 2992 } |
2987 | 2993 |
2988 // 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 |
2989 // tagged values are added (because it might be a String concatenation). | 2995 // tagged values are added (because it might be a String concatenation). |
2990 virtual bool IsCommutative() const { | 2996 virtual bool IsCommutative() const { |
2991 return !representation().IsTagged(); | 2997 return !representation().IsTagged(); |
2992 } | 2998 } |
2993 | 2999 |
2994 virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited); | 3000 virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited); |
2995 | 3001 |
| 3002 static HInstruction* NewHAdd(Zone* zone, |
| 3003 HValue* context, |
| 3004 HValue* left, |
| 3005 HValue* right); |
| 3006 |
2996 virtual HType CalculateInferredType(); | 3007 virtual HType CalculateInferredType(); |
2997 | 3008 |
2998 DECLARE_CONCRETE_INSTRUCTION(Add) | 3009 DECLARE_CONCRETE_INSTRUCTION(Add) |
2999 | 3010 |
3000 protected: | 3011 protected: |
3001 virtual bool DataEquals(HValue* other) { return true; } | 3012 virtual bool DataEquals(HValue* other) { return true; } |
3002 | 3013 |
3003 virtual Range* InferRange(); | 3014 virtual Range* InferRange(); |
3004 }; | 3015 }; |
3005 | 3016 |
3006 | 3017 |
3007 class HSub: public HArithmeticBinaryOperation { | 3018 class HSub: public HArithmeticBinaryOperation { |
3008 public: | 3019 public: |
3009 HSub(HValue* context, HValue* left, HValue* right) | 3020 HSub(HValue* context, HValue* left, HValue* right) |
3010 : HArithmeticBinaryOperation(context, left, right) { | 3021 : HArithmeticBinaryOperation(context, left, right) { |
3011 SetFlag(kCanOverflow); | 3022 SetFlag(kCanOverflow); |
3012 } | 3023 } |
3013 | 3024 |
3014 virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited); | 3025 virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited); |
3015 | 3026 |
| 3027 static HInstruction* NewHSub(Zone* zone, |
| 3028 HValue* context, |
| 3029 HValue* left, |
| 3030 HValue* right); |
| 3031 |
3016 DECLARE_CONCRETE_INSTRUCTION(Sub) | 3032 DECLARE_CONCRETE_INSTRUCTION(Sub) |
3017 | 3033 |
3018 protected: | 3034 protected: |
3019 virtual bool DataEquals(HValue* other) { return true; } | 3035 virtual bool DataEquals(HValue* other) { return true; } |
3020 | 3036 |
3021 virtual Range* InferRange(); | 3037 virtual Range* InferRange(); |
3022 }; | 3038 }; |
3023 | 3039 |
3024 | 3040 |
3025 class HMul: public HArithmeticBinaryOperation { | 3041 class HMul: public HArithmeticBinaryOperation { |
3026 public: | 3042 public: |
3027 HMul(HValue* context, HValue* left, HValue* right) | 3043 HMul(HValue* context, HValue* left, HValue* right) |
3028 : HArithmeticBinaryOperation(context, left, right) { | 3044 : HArithmeticBinaryOperation(context, left, right) { |
3029 SetFlag(kCanOverflow); | 3045 SetFlag(kCanOverflow); |
3030 } | 3046 } |
3031 | 3047 |
3032 virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited); | 3048 virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited); |
3033 | 3049 |
3034 // 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. |
3035 virtual bool IsCommutative() const { | 3051 virtual bool IsCommutative() const { |
3036 return !representation().IsTagged(); | 3052 return !representation().IsTagged(); |
3037 } | 3053 } |
3038 | 3054 |
| 3055 static HInstruction* NewHMul(Zone* zone, |
| 3056 HValue* context, |
| 3057 HValue* left, |
| 3058 HValue* right); |
| 3059 |
3039 DECLARE_CONCRETE_INSTRUCTION(Mul) | 3060 DECLARE_CONCRETE_INSTRUCTION(Mul) |
3040 | 3061 |
3041 protected: | 3062 protected: |
3042 virtual bool DataEquals(HValue* other) { return true; } | 3063 virtual bool DataEquals(HValue* other) { return true; } |
3043 | 3064 |
3044 virtual Range* InferRange(); | 3065 virtual Range* InferRange(); |
3045 }; | 3066 }; |
3046 | 3067 |
3047 | 3068 |
3048 class HMod: public HArithmeticBinaryOperation { | 3069 class HMod: public HArithmeticBinaryOperation { |
3049 public: | 3070 public: |
3050 HMod(HValue* context, HValue* left, HValue* right) | 3071 HMod(HValue* context, HValue* left, HValue* right) |
3051 : HArithmeticBinaryOperation(context, left, right) { | 3072 : HArithmeticBinaryOperation(context, left, right) { |
3052 SetFlag(kCanBeDivByZero); | 3073 SetFlag(kCanBeDivByZero); |
3053 } | 3074 } |
3054 | 3075 |
3055 bool HasPowerOf2Divisor() { | 3076 bool HasPowerOf2Divisor() { |
3056 if (right()->IsConstant() && | 3077 if (right()->IsConstant() && |
3057 HConstant::cast(right())->HasInteger32Value()) { | 3078 HConstant::cast(right())->HasInteger32Value()) { |
3058 int32_t value = HConstant::cast(right())->Integer32Value(); | 3079 int32_t value = HConstant::cast(right())->Integer32Value(); |
3059 return value != 0 && (IsPowerOf2(value) || IsPowerOf2(-value)); | 3080 return value != 0 && (IsPowerOf2(value) || IsPowerOf2(-value)); |
3060 } | 3081 } |
3061 | 3082 |
3062 return false; | 3083 return false; |
3063 } | 3084 } |
3064 | 3085 |
3065 virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited); | 3086 virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited); |
3066 | 3087 |
| 3088 static HInstruction* NewHMod(Zone* zone, |
| 3089 HValue* context, |
| 3090 HValue* left, |
| 3091 HValue* right); |
| 3092 |
3067 DECLARE_CONCRETE_INSTRUCTION(Mod) | 3093 DECLARE_CONCRETE_INSTRUCTION(Mod) |
3068 | 3094 |
3069 protected: | 3095 protected: |
3070 virtual bool DataEquals(HValue* other) { return true; } | 3096 virtual bool DataEquals(HValue* other) { return true; } |
3071 | 3097 |
3072 virtual Range* InferRange(); | 3098 virtual Range* InferRange(); |
3073 }; | 3099 }; |
3074 | 3100 |
3075 | 3101 |
3076 class HDiv: public HArithmeticBinaryOperation { | 3102 class HDiv: public HArithmeticBinaryOperation { |
3077 public: | 3103 public: |
3078 HDiv(HValue* context, HValue* left, HValue* right) | 3104 HDiv(HValue* context, HValue* left, HValue* right) |
3079 : HArithmeticBinaryOperation(context, left, right) { | 3105 : HArithmeticBinaryOperation(context, left, right) { |
3080 SetFlag(kCanBeDivByZero); | 3106 SetFlag(kCanBeDivByZero); |
3081 SetFlag(kCanOverflow); | 3107 SetFlag(kCanOverflow); |
3082 } | 3108 } |
3083 | 3109 |
3084 virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited); | 3110 virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited); |
3085 | 3111 |
| 3112 |
| 3113 static HInstruction* NewHDiv(Zone* zone, |
| 3114 HValue* context, |
| 3115 HValue* left, |
| 3116 HValue* right); |
| 3117 |
3086 DECLARE_CONCRETE_INSTRUCTION(Div) | 3118 DECLARE_CONCRETE_INSTRUCTION(Div) |
3087 | 3119 |
3088 protected: | 3120 protected: |
3089 virtual bool DataEquals(HValue* other) { return true; } | 3121 virtual bool DataEquals(HValue* other) { return true; } |
3090 | 3122 |
3091 virtual Range* InferRange(); | 3123 virtual Range* InferRange(); |
3092 }; | 3124 }; |
3093 | 3125 |
3094 | 3126 |
3095 class HBitwise: public HBitwiseBinaryOperation { | 3127 class HBitwise: public HBitwiseBinaryOperation { |
3096 public: | 3128 public: |
3097 HBitwise(Token::Value op, HValue* context, HValue* left, HValue* right) | 3129 HBitwise(Token::Value op, HValue* context, HValue* left, HValue* right) |
3098 : HBitwiseBinaryOperation(context, left, right), op_(op) { | 3130 : HBitwiseBinaryOperation(context, left, right), op_(op) { |
3099 ASSERT(op == Token::BIT_AND || | 3131 ASSERT(op == Token::BIT_AND || |
3100 op == Token::BIT_OR || | 3132 op == Token::BIT_OR || |
3101 op == Token::BIT_XOR); | 3133 op == Token::BIT_XOR); |
3102 } | 3134 } |
3103 | 3135 |
3104 Token::Value op() const { return op_; } | 3136 Token::Value op() const { return op_; } |
3105 | 3137 |
3106 virtual bool IsCommutative() const { return true; } | 3138 virtual bool IsCommutative() const { return true; } |
3107 | 3139 |
| 3140 static HInstruction* NewHBitwise(Zone* zone, |
| 3141 Token::Value op, |
| 3142 HValue* context, |
| 3143 HValue* left, |
| 3144 HValue* right); |
| 3145 |
3108 DECLARE_CONCRETE_INSTRUCTION(Bitwise) | 3146 DECLARE_CONCRETE_INSTRUCTION(Bitwise) |
3109 | 3147 |
3110 protected: | 3148 protected: |
3111 virtual bool DataEquals(HValue* other) { | 3149 virtual bool DataEquals(HValue* other) { |
3112 return op() == HBitwise::cast(other)->op(); | 3150 return op() == HBitwise::cast(other)->op(); |
3113 } | 3151 } |
3114 | 3152 |
3115 virtual Range* InferRange(); | 3153 virtual Range* InferRange(); |
3116 | 3154 |
3117 private: | 3155 private: |
3118 Token::Value op_; | 3156 Token::Value op_; |
3119 }; | 3157 }; |
3120 | 3158 |
3121 | 3159 |
3122 class HShl: public HBitwiseBinaryOperation { | 3160 class HShl: public HBitwiseBinaryOperation { |
3123 public: | 3161 public: |
3124 HShl(HValue* context, HValue* left, HValue* right) | 3162 HShl(HValue* context, HValue* left, HValue* right) |
3125 : HBitwiseBinaryOperation(context, left, right) { } | 3163 : HBitwiseBinaryOperation(context, left, right) { } |
3126 | 3164 |
3127 virtual Range* InferRange(); | 3165 virtual Range* InferRange(); |
3128 | 3166 |
| 3167 static HInstruction* NewHShl(Zone* zone, |
| 3168 HValue* context, |
| 3169 HValue* left, |
| 3170 HValue* right); |
| 3171 |
3129 DECLARE_CONCRETE_INSTRUCTION(Shl) | 3172 DECLARE_CONCRETE_INSTRUCTION(Shl) |
3130 | 3173 |
3131 protected: | 3174 protected: |
3132 virtual bool DataEquals(HValue* other) { return true; } | 3175 virtual bool DataEquals(HValue* other) { return true; } |
3133 }; | 3176 }; |
3134 | 3177 |
3135 | 3178 |
3136 class HShr: public HBitwiseBinaryOperation { | 3179 class HShr: public HBitwiseBinaryOperation { |
3137 public: | 3180 public: |
3138 HShr(HValue* context, HValue* left, HValue* right) | 3181 HShr(HValue* context, HValue* left, HValue* right) |
3139 : HBitwiseBinaryOperation(context, left, right) { } | 3182 : HBitwiseBinaryOperation(context, left, right) { } |
3140 | 3183 |
3141 virtual Range* InferRange(); | 3184 virtual Range* InferRange(); |
3142 | 3185 |
| 3186 static HInstruction* NewHShr(Zone* zone, |
| 3187 HValue* context, |
| 3188 HValue* left, |
| 3189 HValue* right); |
| 3190 |
3143 DECLARE_CONCRETE_INSTRUCTION(Shr) | 3191 DECLARE_CONCRETE_INSTRUCTION(Shr) |
3144 | 3192 |
3145 protected: | 3193 protected: |
3146 virtual bool DataEquals(HValue* other) { return true; } | 3194 virtual bool DataEquals(HValue* other) { return true; } |
3147 }; | 3195 }; |
3148 | 3196 |
3149 | 3197 |
3150 class HSar: public HBitwiseBinaryOperation { | 3198 class HSar: public HBitwiseBinaryOperation { |
3151 public: | 3199 public: |
3152 HSar(HValue* context, HValue* left, HValue* right) | 3200 HSar(HValue* context, HValue* left, HValue* right) |
3153 : HBitwiseBinaryOperation(context, left, right) { } | 3201 : HBitwiseBinaryOperation(context, left, right) { } |
3154 | 3202 |
3155 virtual Range* InferRange(); | 3203 virtual Range* InferRange(); |
3156 | 3204 |
| 3205 static HInstruction* NewHSar(Zone* zone, |
| 3206 HValue* context, |
| 3207 HValue* left, |
| 3208 HValue* right); |
| 3209 |
3157 DECLARE_CONCRETE_INSTRUCTION(Sar) | 3210 DECLARE_CONCRETE_INSTRUCTION(Sar) |
3158 | 3211 |
3159 protected: | 3212 protected: |
3160 virtual bool DataEquals(HValue* other) { return true; } | 3213 virtual bool DataEquals(HValue* other) { return true; } |
3161 }; | 3214 }; |
3162 | 3215 |
3163 | 3216 |
3164 class HOsrEntry: public HTemplateInstruction<0> { | 3217 class HOsrEntry: public HTemplateInstruction<0> { |
3165 public: | 3218 public: |
3166 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 Loading... |
4337 | 4390 |
4338 DECLARE_CONCRETE_INSTRUCTION(In) | 4391 DECLARE_CONCRETE_INSTRUCTION(In) |
4339 }; | 4392 }; |
4340 | 4393 |
4341 #undef DECLARE_INSTRUCTION | 4394 #undef DECLARE_INSTRUCTION |
4342 #undef DECLARE_CONCRETE_INSTRUCTION | 4395 #undef DECLARE_CONCRETE_INSTRUCTION |
4343 | 4396 |
4344 } } // namespace v8::internal | 4397 } } // namespace v8::internal |
4345 | 4398 |
4346 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ | 4399 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ |
OLD | NEW |