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 2351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2362 protected: | 2362 protected: |
2363 virtual bool DataEquals(HValue* other) { return true; } | 2363 virtual bool DataEquals(HValue* other) { return true; } |
2364 | 2364 |
2365 private: | 2365 private: |
2366 virtual bool IsDeletable() const { return true; } | 2366 virtual bool IsDeletable() const { return true; } |
2367 }; | 2367 }; |
2368 | 2368 |
2369 | 2369 |
2370 class HUnaryMathOperation: public HTemplateInstruction<2> { | 2370 class HUnaryMathOperation: public HTemplateInstruction<2> { |
2371 public: | 2371 public: |
2372 HUnaryMathOperation(HValue* context, HValue* value, BuiltinFunctionId op) | 2372 HUnaryMathOperation(HValue* context, HValue* value, BuiltinFunctionId op) |
Jakob Kummerow
2013/02/20 15:31:04
Since you're introducing a factory method below, y
| |
2373 : op_(op) { | 2373 : op_(op) { |
2374 SetOperandAt(0, context); | 2374 SetOperandAt(0, context); |
2375 SetOperandAt(1, value); | 2375 SetOperandAt(1, value); |
2376 switch (op) { | 2376 switch (op) { |
2377 case kMathFloor: | 2377 case kMathFloor: |
2378 case kMathRound: | 2378 case kMathRound: |
2379 case kMathCeil: | 2379 case kMathCeil: |
2380 set_representation(Representation::Integer32()); | 2380 set_representation(Representation::Integer32()); |
2381 break; | 2381 break; |
2382 case kMathAbs: | 2382 case kMathAbs: |
(...skipping 12 matching lines...) Expand all Loading... | |
2395 break; | 2395 break; |
2396 case kMathExp: | 2396 case kMathExp: |
2397 set_representation(Representation::Double()); | 2397 set_representation(Representation::Double()); |
2398 break; | 2398 break; |
2399 default: | 2399 default: |
2400 UNREACHABLE(); | 2400 UNREACHABLE(); |
2401 } | 2401 } |
2402 SetFlag(kUseGVN); | 2402 SetFlag(kUseGVN); |
2403 } | 2403 } |
2404 | 2404 |
2405 static HInstruction* NewHUnaryMathOperation( | |
Jakob Kummerow
2013/02/20 15:31:04
idea: You could shorten this to just "New", as it'
| |
2406 Zone* zone, HValue* context, HValue* value, BuiltinFunctionId op); | |
2407 | |
2405 HValue* context() { return OperandAt(0); } | 2408 HValue* context() { return OperandAt(0); } |
2406 HValue* value() { return OperandAt(1); } | 2409 HValue* value() { return OperandAt(1); } |
2407 | 2410 |
2408 virtual void PrintDataTo(StringStream* stream); | 2411 virtual void PrintDataTo(StringStream* stream); |
2409 | 2412 |
2410 virtual HType CalculateInferredType(); | 2413 virtual HType CalculateInferredType(); |
2411 | 2414 |
2412 virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited); | 2415 virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited); |
2413 | 2416 |
2414 virtual Representation RequiredInputRepresentation(int index) { | 2417 virtual Representation RequiredInputRepresentation(int index) { |
2415 if (index == 0) { | 2418 if (index == 0) { |
2416 return Representation::Tagged(); | 2419 return Representation::Tagged(); |
2417 } else { | 2420 } else { |
2418 switch (op_) { | 2421 switch (op_) { |
2419 case kMathFloor: | 2422 case kMathFloor: |
2420 case kMathRound: | 2423 case kMathRound: |
2421 case kMathCeil: | |
2422 case kMathSqrt: | 2424 case kMathSqrt: |
2423 case kMathPowHalf: | 2425 case kMathPowHalf: |
2424 case kMathLog: | 2426 case kMathLog: |
2425 case kMathExp: | 2427 case kMathExp: |
2426 case kMathSin: | 2428 case kMathSin: |
2427 case kMathCos: | 2429 case kMathCos: |
2428 case kMathTan: | 2430 case kMathTan: |
2429 return Representation::Double(); | 2431 return Representation::Double(); |
2430 case kMathAbs: | 2432 case kMathAbs: |
2431 return representation(); | 2433 return representation(); |
(...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3057 return double_value_; | 3059 return double_value_; |
3058 } | 3060 } |
3059 bool HasNumberValue() const { return has_double_value_; } | 3061 bool HasNumberValue() const { return has_double_value_; } |
3060 int32_t NumberValueAsInteger32() const { | 3062 int32_t NumberValueAsInteger32() const { |
3061 ASSERT(HasNumberValue()); | 3063 ASSERT(HasNumberValue()); |
3062 // Irrespective of whether a numeric HConstant can be safely | 3064 // Irrespective of whether a numeric HConstant can be safely |
3063 // represented as an int32, we store the (in some cases lossy) | 3065 // represented as an int32, we store the (in some cases lossy) |
3064 // representation of the number in int32_value_. | 3066 // representation of the number in int32_value_. |
3065 return int32_value_; | 3067 return int32_value_; |
3066 } | 3068 } |
3069 bool HasStringValue() const { | |
3070 if (has_double_value_ || has_int32_value_) return false; | |
3071 ASSERT(!handle_.is_null()); | |
3072 return handle_->IsString(); | |
3073 } | |
3074 Handle<String> StringValue() const { | |
3075 ASSERT(HasStringValue()); | |
3076 return Handle<String>::cast(handle_); | |
3077 } | |
3067 | 3078 |
3068 bool ToBoolean(); | 3079 bool ToBoolean(); |
3069 | 3080 |
3070 bool IsUint32() { | 3081 bool IsUint32() { |
3071 return HasInteger32Value() && (Integer32Value() >= 0); | 3082 return HasInteger32Value() && (Integer32Value() >= 0); |
3072 } | 3083 } |
3073 | 3084 |
3074 virtual intptr_t Hashcode() { | 3085 virtual intptr_t Hashcode() { |
3075 ASSERT_ALLOCATION_DISABLED; | 3086 ASSERT_ALLOCATION_DISABLED; |
3076 intptr_t hash; | 3087 intptr_t hash; |
(...skipping 808 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3885 class HPower: public HTemplateInstruction<2> { | 3896 class HPower: public HTemplateInstruction<2> { |
3886 public: | 3897 public: |
3887 HPower(HValue* left, HValue* right) { | 3898 HPower(HValue* left, HValue* right) { |
3888 SetOperandAt(0, left); | 3899 SetOperandAt(0, left); |
3889 SetOperandAt(1, right); | 3900 SetOperandAt(1, right); |
3890 set_representation(Representation::Double()); | 3901 set_representation(Representation::Double()); |
3891 SetFlag(kUseGVN); | 3902 SetFlag(kUseGVN); |
3892 SetGVNFlag(kChangesNewSpacePromotion); | 3903 SetGVNFlag(kChangesNewSpacePromotion); |
3893 } | 3904 } |
3894 | 3905 |
3906 static HInstruction* NewHPower( | |
3907 Zone* zone, HValue* left, HValue* right); | |
3908 | |
3895 HValue* left() { return OperandAt(0); } | 3909 HValue* left() { return OperandAt(0); } |
3896 HValue* right() const { return OperandAt(1); } | 3910 HValue* right() const { return OperandAt(1); } |
3897 | 3911 |
3898 virtual Representation RequiredInputRepresentation(int index) { | 3912 virtual Representation RequiredInputRepresentation(int index) { |
3899 return index == 0 | 3913 return index == 0 |
3900 ? Representation::Double() | 3914 ? Representation::Double() |
3901 : Representation::None(); | 3915 : Representation::None(); |
3902 } | 3916 } |
3903 virtual Representation observed_input_representation(int index) { | 3917 virtual Representation observed_input_representation(int index) { |
3904 return RequiredInputRepresentation(index); | 3918 return RequiredInputRepresentation(index); |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4118 | 4132 |
4119 | 4133 |
4120 class HMathMinMax: public HArithmeticBinaryOperation { | 4134 class HMathMinMax: public HArithmeticBinaryOperation { |
4121 public: | 4135 public: |
4122 enum Operation { kMathMin, kMathMax }; | 4136 enum Operation { kMathMin, kMathMax }; |
4123 | 4137 |
4124 HMathMinMax(HValue* context, HValue* left, HValue* right, Operation op) | 4138 HMathMinMax(HValue* context, HValue* left, HValue* right, Operation op) |
4125 : HArithmeticBinaryOperation(context, left, right), | 4139 : HArithmeticBinaryOperation(context, left, right), |
4126 operation_(op) { } | 4140 operation_(op) { } |
4127 | 4141 |
4142 static HInstruction* NewHMathMinMax( | |
4143 Zone* zone, HValue* context, HValue* left, HValue* right, Operation op); | |
4144 | |
4128 virtual Representation RequiredInputRepresentation(int index) { | 4145 virtual Representation RequiredInputRepresentation(int index) { |
4129 return index == 0 ? Representation::Tagged() | 4146 return index == 0 ? Representation::Tagged() |
4130 : representation(); | 4147 : representation(); |
4131 } | 4148 } |
4132 | 4149 |
4133 virtual Representation observed_input_representation(int index) { | 4150 virtual Representation observed_input_representation(int index) { |
4134 return RequiredInputRepresentation(index); | 4151 return RequiredInputRepresentation(index); |
4135 } | 4152 } |
4136 | 4153 |
4137 virtual void InferRepresentation(HInferRepresentation* h_infer); | 4154 virtual void InferRepresentation(HInferRepresentation* h_infer); |
(...skipping 1257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5395 class HStringAdd: public HBinaryOperation { | 5412 class HStringAdd: public HBinaryOperation { |
5396 public: | 5413 public: |
5397 HStringAdd(HValue* context, HValue* left, HValue* right) | 5414 HStringAdd(HValue* context, HValue* left, HValue* right) |
5398 : HBinaryOperation(context, left, right) { | 5415 : HBinaryOperation(context, left, right) { |
5399 set_representation(Representation::Tagged()); | 5416 set_representation(Representation::Tagged()); |
5400 SetFlag(kUseGVN); | 5417 SetFlag(kUseGVN); |
5401 SetGVNFlag(kDependsOnMaps); | 5418 SetGVNFlag(kDependsOnMaps); |
5402 SetGVNFlag(kChangesNewSpacePromotion); | 5419 SetGVNFlag(kChangesNewSpacePromotion); |
5403 } | 5420 } |
5404 | 5421 |
5422 static HInstruction* NewHStringAdd(Zone* zone, | |
5423 HValue* context, | |
5424 HValue* left, | |
5425 HValue* right); | |
5426 | |
5405 virtual Representation RequiredInputRepresentation(int index) { | 5427 virtual Representation RequiredInputRepresentation(int index) { |
5406 return Representation::Tagged(); | 5428 return Representation::Tagged(); |
5407 } | 5429 } |
5408 | 5430 |
5409 virtual HType CalculateInferredType() { | 5431 virtual HType CalculateInferredType() { |
5410 return HType::String(); | 5432 return HType::String(); |
5411 } | 5433 } |
5412 | 5434 |
5413 DECLARE_CONCRETE_INSTRUCTION(StringAdd) | 5435 DECLARE_CONCRETE_INSTRUCTION(StringAdd) |
5414 | 5436 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5462 class HStringCharFromCode: public HTemplateInstruction<2> { | 5484 class HStringCharFromCode: public HTemplateInstruction<2> { |
5463 public: | 5485 public: |
5464 HStringCharFromCode(HValue* context, HValue* char_code) { | 5486 HStringCharFromCode(HValue* context, HValue* char_code) { |
5465 SetOperandAt(0, context); | 5487 SetOperandAt(0, context); |
5466 SetOperandAt(1, char_code); | 5488 SetOperandAt(1, char_code); |
5467 set_representation(Representation::Tagged()); | 5489 set_representation(Representation::Tagged()); |
5468 SetFlag(kUseGVN); | 5490 SetFlag(kUseGVN); |
5469 SetGVNFlag(kChangesNewSpacePromotion); | 5491 SetGVNFlag(kChangesNewSpacePromotion); |
5470 } | 5492 } |
5471 | 5493 |
5494 static HInstruction* NewHStringCharFromCode( | |
5495 Zone* zone, HValue* context, HValue* char_code); | |
5496 | |
5472 virtual Representation RequiredInputRepresentation(int index) { | 5497 virtual Representation RequiredInputRepresentation(int index) { |
5473 return index == 0 | 5498 return index == 0 |
5474 ? Representation::Tagged() | 5499 ? Representation::Tagged() |
5475 : Representation::Integer32(); | 5500 : Representation::Integer32(); |
5476 } | 5501 } |
5477 virtual HType CalculateInferredType(); | 5502 virtual HType CalculateInferredType(); |
5478 | 5503 |
5479 HValue* context() { return OperandAt(0); } | 5504 HValue* context() { return OperandAt(0); } |
5480 HValue* value() { return OperandAt(1); } | 5505 HValue* value() { return OperandAt(1); } |
5481 | 5506 |
5482 virtual bool DataEquals(HValue* other) { return true; } | 5507 virtual bool DataEquals(HValue* other) { return true; } |
5483 | 5508 |
5484 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode) | 5509 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode) |
5485 | 5510 |
5486 // TODO(svenpanne) Might be safe, but leave it out until we know for sure. | 5511 // TODO(svenpanne) Might be safe, but leave it out until we know for sure. |
5487 // private: | 5512 // private: |
5488 // virtual bool IsDeletable() const { return true; } | 5513 // virtual bool IsDeletable() const { return true; } |
5489 }; | 5514 }; |
5490 | 5515 |
5491 | 5516 |
5492 class HStringLength: public HUnaryOperation { | 5517 class HStringLength: public HUnaryOperation { |
5493 public: | 5518 public: |
5494 explicit HStringLength(HValue* string) : HUnaryOperation(string) { | 5519 explicit HStringLength(HValue* string) : HUnaryOperation(string) { |
5495 set_representation(Representation::Tagged()); | 5520 set_representation(Representation::Tagged()); |
5496 SetFlag(kUseGVN); | 5521 SetFlag(kUseGVN); |
5497 SetGVNFlag(kDependsOnMaps); | 5522 SetGVNFlag(kDependsOnMaps); |
5498 } | 5523 } |
5499 | 5524 |
5525 static HInstruction* NewHStringLength(Zone* zone, HValue* string); | |
5526 | |
5500 virtual Representation RequiredInputRepresentation(int index) { | 5527 virtual Representation RequiredInputRepresentation(int index) { |
5501 return Representation::Tagged(); | 5528 return Representation::Tagged(); |
5502 } | 5529 } |
5503 | 5530 |
5504 virtual HType CalculateInferredType() { | 5531 virtual HType CalculateInferredType() { |
5505 STATIC_ASSERT(String::kMaxLength <= Smi::kMaxValue); | 5532 STATIC_ASSERT(String::kMaxLength <= Smi::kMaxValue); |
5506 return HType::Smi(); | 5533 return HType::Smi(); |
5507 } | 5534 } |
5508 | 5535 |
5509 DECLARE_CONCRETE_INSTRUCTION(StringLength) | 5536 DECLARE_CONCRETE_INSTRUCTION(StringLength) |
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6032 virtual bool IsDeletable() const { return true; } | 6059 virtual bool IsDeletable() const { return true; } |
6033 }; | 6060 }; |
6034 | 6061 |
6035 | 6062 |
6036 #undef DECLARE_INSTRUCTION | 6063 #undef DECLARE_INSTRUCTION |
6037 #undef DECLARE_CONCRETE_INSTRUCTION | 6064 #undef DECLARE_CONCRETE_INSTRUCTION |
6038 | 6065 |
6039 } } // namespace v8::internal | 6066 } } // namespace v8::internal |
6040 | 6067 |
6041 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ | 6068 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ |
OLD | NEW |