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

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

Issue 8473002: Propagate and combine constants in Hydrogen (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
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
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 2307 matching lines...) Expand 10 before | Expand all | Expand 10 after
2318 bool HasInteger32Value() const { return has_int32_value_; } 2318 bool HasInteger32Value() const { return has_int32_value_; }
2319 int32_t Integer32Value() const { 2319 int32_t Integer32Value() const {
2320 ASSERT(HasInteger32Value()); 2320 ASSERT(HasInteger32Value());
2321 return int32_value_; 2321 return int32_value_;
2322 } 2322 }
2323 bool HasDoubleValue() const { return has_double_value_; } 2323 bool HasDoubleValue() const { return has_double_value_; }
2324 double DoubleValue() const { 2324 double DoubleValue() const {
2325 ASSERT(HasDoubleValue()); 2325 ASSERT(HasDoubleValue());
2326 return double_value_; 2326 return double_value_;
2327 } 2327 }
2328 bool HasNumberValue() const { return has_int32_value_ || has_double_value_; }
2329 int32_t NumberValueAsInteger32() const {
2330 ASSERT(HasNumberValue());
2331 if (has_int32_value_) return int32_value_;
2332 return DoubleToInt32(double_value_);
2333 }
2328 bool HasStringValue() const { return handle_->IsString(); } 2334 bool HasStringValue() const { return handle_->IsString(); }
2329 2335
2330 bool ToBoolean() const; 2336 bool ToBoolean() const;
2331 2337
2332 virtual intptr_t Hashcode() { 2338 virtual intptr_t Hashcode() {
2333 ASSERT(!HEAP->allow_allocation(false)); 2339 ASSERT(!HEAP->allow_allocation(false));
2334 return reinterpret_cast<intptr_t>(*handle()); 2340 return reinterpret_cast<intptr_t>(*handle());
2335 } 2341 }
2336 2342
2337 #ifdef DEBUG 2343 #ifdef DEBUG
(...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after
2935 } 2941 }
2936 2942
2937 // Add is only commutative if two integer values are added and not if two 2943 // Add is only commutative if two integer values are added and not if two
2938 // tagged values are added (because it might be a String concatenation). 2944 // tagged values are added (because it might be a String concatenation).
2939 virtual bool IsCommutative() const { 2945 virtual bool IsCommutative() const {
2940 return !representation().IsTagged(); 2946 return !representation().IsTagged();
2941 } 2947 }
2942 2948
2943 virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited); 2949 virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited);
2944 2950
2951 static HInstruction* NewHAdd(Zone* zone,
2952 HValue* context,
2953 HValue* left,
2954 HValue* right);
2955
2945 virtual HType CalculateInferredType(); 2956 virtual HType CalculateInferredType();
2946 2957
2947 DECLARE_CONCRETE_INSTRUCTION(Add) 2958 DECLARE_CONCRETE_INSTRUCTION(Add)
2948 2959
2949 protected: 2960 protected:
2950 virtual bool DataEquals(HValue* other) { return true; } 2961 virtual bool DataEquals(HValue* other) { return true; }
2951 2962
2952 virtual Range* InferRange(); 2963 virtual Range* InferRange();
2953 }; 2964 };
2954 2965
2955 2966
2956 class HSub: public HArithmeticBinaryOperation { 2967 class HSub: public HArithmeticBinaryOperation {
2957 public: 2968 public:
2958 HSub(HValue* context, HValue* left, HValue* right) 2969 HSub(HValue* context, HValue* left, HValue* right)
2959 : HArithmeticBinaryOperation(context, left, right) { 2970 : HArithmeticBinaryOperation(context, left, right) {
2960 SetFlag(kCanOverflow); 2971 SetFlag(kCanOverflow);
2961 } 2972 }
2962 2973
2963 virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited); 2974 virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited);
2964 2975
2976 static HInstruction* NewHSub(Zone* zone,
2977 HValue* context,
2978 HValue* left,
2979 HValue* right);
2980
2965 DECLARE_CONCRETE_INSTRUCTION(Sub) 2981 DECLARE_CONCRETE_INSTRUCTION(Sub)
2966 2982
2967 protected: 2983 protected:
2968 virtual bool DataEquals(HValue* other) { return true; } 2984 virtual bool DataEquals(HValue* other) { return true; }
2969 2985
2970 virtual Range* InferRange(); 2986 virtual Range* InferRange();
2971 }; 2987 };
2972 2988
2973 2989
2974 class HMul: public HArithmeticBinaryOperation { 2990 class HMul: public HArithmeticBinaryOperation {
2975 public: 2991 public:
2976 HMul(HValue* context, HValue* left, HValue* right) 2992 HMul(HValue* context, HValue* left, HValue* right)
2977 : HArithmeticBinaryOperation(context, left, right) { 2993 : HArithmeticBinaryOperation(context, left, right) {
2978 SetFlag(kCanOverflow); 2994 SetFlag(kCanOverflow);
2979 } 2995 }
2980 2996
2981 virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited); 2997 virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited);
2982 2998
2983 // Only commutative if it is certain that not two objects are multiplicated. 2999 // Only commutative if it is certain that not two objects are multiplicated.
2984 virtual bool IsCommutative() const { 3000 virtual bool IsCommutative() const {
2985 return !representation().IsTagged(); 3001 return !representation().IsTagged();
2986 } 3002 }
2987 3003
3004 static HInstruction* NewHMul(Zone* zone,
3005 HValue* context,
3006 HValue* left,
3007 HValue* right);
3008
2988 DECLARE_CONCRETE_INSTRUCTION(Mul) 3009 DECLARE_CONCRETE_INSTRUCTION(Mul)
2989 3010
2990 protected: 3011 protected:
2991 virtual bool DataEquals(HValue* other) { return true; } 3012 virtual bool DataEquals(HValue* other) { return true; }
2992 3013
2993 virtual Range* InferRange(); 3014 virtual Range* InferRange();
2994 }; 3015 };
2995 3016
2996 3017
2997 class HMod: public HArithmeticBinaryOperation { 3018 class HMod: public HArithmeticBinaryOperation {
2998 public: 3019 public:
2999 HMod(HValue* context, HValue* left, HValue* right) 3020 HMod(HValue* context, HValue* left, HValue* right)
3000 : HArithmeticBinaryOperation(context, left, right) { 3021 : HArithmeticBinaryOperation(context, left, right) {
3001 SetFlag(kCanBeDivByZero); 3022 SetFlag(kCanBeDivByZero);
3002 } 3023 }
3003 3024
3004 bool HasPowerOf2Divisor() { 3025 bool HasPowerOf2Divisor() {
3005 if (right()->IsConstant() && 3026 if (right()->IsConstant() &&
3006 HConstant::cast(right())->HasInteger32Value()) { 3027 HConstant::cast(right())->HasInteger32Value()) {
3007 int32_t value = HConstant::cast(right())->Integer32Value(); 3028 int32_t value = HConstant::cast(right())->Integer32Value();
3008 return value != 0 && (IsPowerOf2(value) || IsPowerOf2(-value)); 3029 return value != 0 && (IsPowerOf2(value) || IsPowerOf2(-value));
3009 } 3030 }
3010 3031
3011 return false; 3032 return false;
3012 } 3033 }
3013 3034
3014 virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited); 3035 virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited);
3015 3036
3037 static HInstruction* NewHMod(Zone* zone,
3038 HValue* context,
3039 HValue* left,
3040 HValue* right);
3041
3016 DECLARE_CONCRETE_INSTRUCTION(Mod) 3042 DECLARE_CONCRETE_INSTRUCTION(Mod)
3017 3043
3018 protected: 3044 protected:
3019 virtual bool DataEquals(HValue* other) { return true; } 3045 virtual bool DataEquals(HValue* other) { return true; }
3020 3046
3021 virtual Range* InferRange(); 3047 virtual Range* InferRange();
3022 }; 3048 };
3023 3049
3024 3050
3025 class HDiv: public HArithmeticBinaryOperation { 3051 class HDiv: public HArithmeticBinaryOperation {
3026 public: 3052 public:
3027 HDiv(HValue* context, HValue* left, HValue* right) 3053 HDiv(HValue* context, HValue* left, HValue* right)
3028 : HArithmeticBinaryOperation(context, left, right) { 3054 : HArithmeticBinaryOperation(context, left, right) {
3029 SetFlag(kCanBeDivByZero); 3055 SetFlag(kCanBeDivByZero);
3030 SetFlag(kCanOverflow); 3056 SetFlag(kCanOverflow);
3031 } 3057 }
3032 3058
3033 virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited); 3059 virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited);
3034 3060
3061
3062 static HInstruction* NewHDiv(Zone* zone,
3063 HValue* context,
3064 HValue* left,
3065 HValue* right);
3066
3035 DECLARE_CONCRETE_INSTRUCTION(Div) 3067 DECLARE_CONCRETE_INSTRUCTION(Div)
3036 3068
3037 protected: 3069 protected:
3038 virtual bool DataEquals(HValue* other) { return true; } 3070 virtual bool DataEquals(HValue* other) { return true; }
3039 3071
3040 virtual Range* InferRange(); 3072 virtual Range* InferRange();
3041 }; 3073 };
3042 3074
3043 3075
3044 class HBitwise: public HBitwiseBinaryOperation { 3076 class HBitwise: public HBitwiseBinaryOperation {
3045 public: 3077 public:
3046 HBitwise(Token::Value op, HValue* context, HValue* left, HValue* right) 3078 HBitwise(Token::Value op, HValue* context, HValue* left, HValue* right)
3047 : HBitwiseBinaryOperation(context, left, right), op_(op) { 3079 : HBitwiseBinaryOperation(context, left, right), op_(op) {
3048 ASSERT(op == Token::BIT_AND || 3080 ASSERT(op == Token::BIT_AND ||
3049 op == Token::BIT_OR || 3081 op == Token::BIT_OR ||
3050 op == Token::BIT_XOR); 3082 op == Token::BIT_XOR);
3051 } 3083 }
3052 3084
3053 Token::Value op() const { return op_; } 3085 Token::Value op() const { return op_; }
3054 3086
3055 virtual bool IsCommutative() const { return true; } 3087 virtual bool IsCommutative() const { return true; }
3056 3088
3089 static HInstruction* NewHBitwise(Zone* zone,
3090 Token::Value op,
3091 HValue* context,
3092 HValue* left,
3093 HValue* right);
3094
3057 DECLARE_CONCRETE_INSTRUCTION(Bitwise) 3095 DECLARE_CONCRETE_INSTRUCTION(Bitwise)
3058 3096
3059 protected: 3097 protected:
3060 virtual bool DataEquals(HValue* other) { 3098 virtual bool DataEquals(HValue* other) {
3061 return op() == HBitwise::cast(other)->op(); 3099 return op() == HBitwise::cast(other)->op();
3062 } 3100 }
3063 3101
3064 virtual Range* InferRange(); 3102 virtual Range* InferRange();
3065 3103
3066 private: 3104 private:
3067 Token::Value op_; 3105 Token::Value op_;
3068 }; 3106 };
3069 3107
3070 3108
3071 class HShl: public HBitwiseBinaryOperation { 3109 class HShl: public HBitwiseBinaryOperation {
3072 public: 3110 public:
3073 HShl(HValue* context, HValue* left, HValue* right) 3111 HShl(HValue* context, HValue* left, HValue* right)
3074 : HBitwiseBinaryOperation(context, left, right) { } 3112 : HBitwiseBinaryOperation(context, left, right) { }
3075 3113
3076 virtual Range* InferRange(); 3114 virtual Range* InferRange();
3077 3115
3116 static HInstruction* NewHShl(Zone* zone,
3117 HValue* context,
3118 HValue* left,
3119 HValue* right);
3120
3078 DECLARE_CONCRETE_INSTRUCTION(Shl) 3121 DECLARE_CONCRETE_INSTRUCTION(Shl)
3079 3122
3080 protected: 3123 protected:
3081 virtual bool DataEquals(HValue* other) { return true; } 3124 virtual bool DataEquals(HValue* other) { return true; }
3082 }; 3125 };
3083 3126
3084 3127
3085 class HShr: public HBitwiseBinaryOperation { 3128 class HShr: public HBitwiseBinaryOperation {
3086 public: 3129 public:
3087 HShr(HValue* context, HValue* left, HValue* right) 3130 HShr(HValue* context, HValue* left, HValue* right)
3088 : HBitwiseBinaryOperation(context, left, right) { } 3131 : HBitwiseBinaryOperation(context, left, right) { }
3089 3132
3090 virtual Range* InferRange(); 3133 virtual Range* InferRange();
3091 3134
3135 static HInstruction* NewHShr(Zone* zone,
3136 HValue* context,
3137 HValue* left,
3138 HValue* right);
3139
3092 DECLARE_CONCRETE_INSTRUCTION(Shr) 3140 DECLARE_CONCRETE_INSTRUCTION(Shr)
3093 3141
3094 protected: 3142 protected:
3095 virtual bool DataEquals(HValue* other) { return true; } 3143 virtual bool DataEquals(HValue* other) { return true; }
3096 }; 3144 };
3097 3145
3098 3146
3099 class HSar: public HBitwiseBinaryOperation { 3147 class HSar: public HBitwiseBinaryOperation {
3100 public: 3148 public:
3101 HSar(HValue* context, HValue* left, HValue* right) 3149 HSar(HValue* context, HValue* left, HValue* right)
3102 : HBitwiseBinaryOperation(context, left, right) { } 3150 : HBitwiseBinaryOperation(context, left, right) { }
3103 3151
3104 virtual Range* InferRange(); 3152 virtual Range* InferRange();
3105 3153
3154 static HInstruction* NewHSar(Zone* zone,
3155 HValue* context,
3156 HValue* left,
3157 HValue* right);
3158
3106 DECLARE_CONCRETE_INSTRUCTION(Sar) 3159 DECLARE_CONCRETE_INSTRUCTION(Sar)
3107 3160
3108 protected: 3161 protected:
3109 virtual bool DataEquals(HValue* other) { return true; } 3162 virtual bool DataEquals(HValue* other) { return true; }
3110 }; 3163 };
3111 3164
3112 3165
3113 class HOsrEntry: public HTemplateInstruction<0> { 3166 class HOsrEntry: public HTemplateInstruction<0> {
3114 public: 3167 public:
3115 explicit HOsrEntry(int ast_id) : ast_id_(ast_id) { 3168 explicit HOsrEntry(int ast_id) : ast_id_(ast_id) {
(...skipping 1169 matching lines...) Expand 10 before | Expand all | Expand 10 after
4285 4338
4286 DECLARE_CONCRETE_INSTRUCTION(In) 4339 DECLARE_CONCRETE_INSTRUCTION(In)
4287 }; 4340 };
4288 4341
4289 #undef DECLARE_INSTRUCTION 4342 #undef DECLARE_INSTRUCTION
4290 #undef DECLARE_CONCRETE_INSTRUCTION 4343 #undef DECLARE_CONCRETE_INSTRUCTION
4291 4344
4292 } } // namespace v8::internal 4345 } } // namespace v8::internal
4293 4346
4294 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ 4347 #endif // V8_HYDROGEN_INSTRUCTIONS_H_
OLDNEW
« src/flag-definitions.h ('K') | « src/hydrogen.cc ('k') | src/hydrogen-instructions.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698