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 2757 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2768 return Representation::Double(); | 2768 return Representation::Double(); |
2769 case kMathAbs: | 2769 case kMathAbs: |
2770 return representation(); | 2770 return representation(); |
2771 default: | 2771 default: |
2772 UNREACHABLE(); | 2772 UNREACHABLE(); |
2773 return Representation::None(); | 2773 return Representation::None(); |
2774 } | 2774 } |
2775 } | 2775 } |
2776 } | 2776 } |
2777 | 2777 |
| 2778 virtual void UpdateRepresentation(Representation new_rep, |
| 2779 HInferRepresentationPhase* h_infer, |
| 2780 const char* reason) { |
| 2781 if (flexible_int() && !new_rep.IsSmi()) { |
| 2782 new_rep = Representation::Integer32(); |
| 2783 } |
| 2784 HValue::UpdateRepresentation(new_rep, h_infer, reason); |
| 2785 } |
| 2786 |
| 2787 virtual void RepresentationChanged(Representation new_rep) { |
| 2788 if (flexible_int() && new_rep.IsInteger32()) { |
| 2789 ClearFlag(kFlexibleRepresentation); |
| 2790 } |
| 2791 } |
| 2792 |
2778 virtual Range* InferRange(Zone* zone); | 2793 virtual Range* InferRange(Zone* zone); |
2779 | 2794 |
2780 virtual HValue* Canonicalize(); | 2795 virtual HValue* Canonicalize(); |
2781 virtual Representation RepresentationFromInputs(); | 2796 virtual Representation RepresentationFromInputs(); |
2782 | 2797 |
2783 BuiltinFunctionId op() const { return op_; } | 2798 BuiltinFunctionId op() const { return op_; } |
2784 const char* OpName() const; | 2799 const char* OpName() const; |
2785 | 2800 |
2786 DECLARE_CONCRETE_INSTRUCTION(UnaryMathOperation) | 2801 DECLARE_CONCRETE_INSTRUCTION(UnaryMathOperation) |
2787 | 2802 |
2788 protected: | 2803 protected: |
2789 virtual bool DataEquals(HValue* other) { | 2804 virtual bool DataEquals(HValue* other) { |
2790 HUnaryMathOperation* b = HUnaryMathOperation::cast(other); | 2805 HUnaryMathOperation* b = HUnaryMathOperation::cast(other); |
2791 return op_ == b->op(); | 2806 return op_ == b->op(); |
2792 } | 2807 } |
2793 | 2808 |
2794 private: | 2809 private: |
| 2810 bool flexible_int() { |
| 2811 return op_ == kMathFloor || op_ == kMathRound; |
| 2812 } |
| 2813 |
2795 HUnaryMathOperation(HValue* context, HValue* value, BuiltinFunctionId op) | 2814 HUnaryMathOperation(HValue* context, HValue* value, BuiltinFunctionId op) |
2796 : HTemplateInstruction<2>(HType::TaggedNumber()), op_(op) { | 2815 : HTemplateInstruction<2>(HType::TaggedNumber()), op_(op) { |
2797 SetOperandAt(0, context); | 2816 SetOperandAt(0, context); |
2798 SetOperandAt(1, value); | 2817 SetOperandAt(1, value); |
2799 switch (op) { | 2818 switch (op) { |
2800 case kMathFloor: | 2819 case kMathFloor: |
2801 case kMathRound: | 2820 case kMathRound: |
2802 // TODO(verwaest): Set representation to flexible int starting as smi. | 2821 set_representation(Representation::Smi()); |
2803 set_representation(Representation::Integer32()); | 2822 SetFlag(kFlexibleRepresentation); |
2804 break; | 2823 break; |
2805 case kMathAbs: | 2824 case kMathAbs: |
2806 // Not setting representation here: it is None intentionally. | 2825 // Not setting representation here: it is None intentionally. |
2807 SetFlag(kFlexibleRepresentation); | 2826 SetFlag(kFlexibleRepresentation); |
2808 // TODO(svenpanne) This flag is actually only needed if representation() | 2827 // TODO(svenpanne) This flag is actually only needed if representation() |
2809 // is tagged, and not when it is an unboxed double or unboxed integer. | 2828 // is tagged, and not when it is an unboxed double or unboxed integer. |
2810 SetGVNFlag(kChangesNewSpacePromotion); | 2829 SetGVNFlag(kChangesNewSpacePromotion); |
2811 break; | 2830 break; |
2812 case kMathLog: | 2831 case kMathLog: |
2813 case kMathSin: | 2832 case kMathSin: |
(...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3432 public: | 3451 public: |
3433 HPhi(int merged_index, Zone* zone) | 3452 HPhi(int merged_index, Zone* zone) |
3434 : inputs_(2, zone), | 3453 : inputs_(2, zone), |
3435 merged_index_(merged_index), | 3454 merged_index_(merged_index), |
3436 phi_id_(-1), | 3455 phi_id_(-1), |
3437 induction_variable_data_(NULL) { | 3456 induction_variable_data_(NULL) { |
3438 for (int i = 0; i < Representation::kNumRepresentations; i++) { | 3457 for (int i = 0; i < Representation::kNumRepresentations; i++) { |
3439 non_phi_uses_[i] = 0; | 3458 non_phi_uses_[i] = 0; |
3440 indirect_uses_[i] = 0; | 3459 indirect_uses_[i] = 0; |
3441 } | 3460 } |
3442 ASSERT(merged_index >= 0); | 3461 ASSERT(merged_index >= 0 || merged_index == kInvalidMergedIndex); |
3443 SetFlag(kFlexibleRepresentation); | 3462 SetFlag(kFlexibleRepresentation); |
3444 SetFlag(kAllowUndefinedAsNaN); | 3463 SetFlag(kAllowUndefinedAsNaN); |
3445 } | 3464 } |
3446 | 3465 |
3447 virtual Representation RepresentationFromInputs(); | 3466 virtual Representation RepresentationFromInputs(); |
3448 | 3467 |
3449 virtual Range* InferRange(Zone* zone); | 3468 virtual Range* InferRange(Zone* zone); |
3450 virtual void InferRepresentation(HInferRepresentationPhase* h_infer); | 3469 virtual void InferRepresentation(HInferRepresentationPhase* h_infer); |
3451 virtual Representation RequiredInputRepresentation(int index) { | 3470 virtual Representation RequiredInputRepresentation(int index) { |
3452 return representation(); | 3471 return representation(); |
3453 } | 3472 } |
3454 virtual Representation KnownOptimalRepresentation() { | 3473 virtual Representation KnownOptimalRepresentation() { |
3455 return representation(); | 3474 return representation(); |
3456 } | 3475 } |
3457 virtual HType CalculateInferredType(); | 3476 virtual HType CalculateInferredType(); |
3458 virtual int OperandCount() { return inputs_.length(); } | 3477 virtual int OperandCount() { return inputs_.length(); } |
3459 virtual HValue* OperandAt(int index) const { return inputs_[index]; } | 3478 virtual HValue* OperandAt(int index) const { return inputs_[index]; } |
3460 HValue* GetRedundantReplacement(); | 3479 HValue* GetRedundantReplacement(); |
3461 void AddInput(HValue* value); | 3480 void AddInput(HValue* value); |
3462 bool HasRealUses(); | 3481 bool HasRealUses(); |
3463 | 3482 |
3464 bool IsReceiver() const { return merged_index_ == 0; } | 3483 bool IsReceiver() const { return merged_index_ == 0; } |
| 3484 bool HasMergedIndex() const { return merged_index_ != kInvalidMergedIndex; } |
3465 | 3485 |
3466 int merged_index() const { return merged_index_; } | 3486 int merged_index() const { return merged_index_; } |
3467 | 3487 |
3468 InductionVariableData* induction_variable_data() { | 3488 InductionVariableData* induction_variable_data() { |
3469 return induction_variable_data_; | 3489 return induction_variable_data_; |
3470 } | 3490 } |
3471 bool IsInductionVariable() { | 3491 bool IsInductionVariable() { |
3472 return induction_variable_data_ != NULL; | 3492 return induction_variable_data_ != NULL; |
3473 } | 3493 } |
3474 bool IsLimitedInductionVariable() { | 3494 bool IsLimitedInductionVariable() { |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3519 int phi_id() { return phi_id_; } | 3539 int phi_id() { return phi_id_; } |
3520 | 3540 |
3521 static HPhi* cast(HValue* value) { | 3541 static HPhi* cast(HValue* value) { |
3522 ASSERT(value->IsPhi()); | 3542 ASSERT(value->IsPhi()); |
3523 return reinterpret_cast<HPhi*>(value); | 3543 return reinterpret_cast<HPhi*>(value); |
3524 } | 3544 } |
3525 virtual Opcode opcode() const { return HValue::kPhi; } | 3545 virtual Opcode opcode() const { return HValue::kPhi; } |
3526 | 3546 |
3527 void SimplifyConstantInputs(); | 3547 void SimplifyConstantInputs(); |
3528 | 3548 |
| 3549 // Marker value representing an invalid merge index. |
| 3550 static const int kInvalidMergedIndex = -1; |
| 3551 |
3529 protected: | 3552 protected: |
3530 virtual void DeleteFromGraph(); | 3553 virtual void DeleteFromGraph(); |
3531 virtual void InternalSetOperandAt(int index, HValue* value) { | 3554 virtual void InternalSetOperandAt(int index, HValue* value) { |
3532 inputs_[index] = value; | 3555 inputs_[index] = value; |
3533 } | 3556 } |
3534 | 3557 |
3535 virtual bool IsRelationTrueInternal(NumericRelation relation, | 3558 virtual bool IsRelationTrueInternal(NumericRelation relation, |
3536 HValue* other, | 3559 HValue* other, |
3537 int offset = 0, | 3560 int offset = 0, |
3538 int scale = 0); | 3561 int scale = 0); |
(...skipping 3710 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7249 virtual bool IsDeletable() const { return true; } | 7272 virtual bool IsDeletable() const { return true; } |
7250 }; | 7273 }; |
7251 | 7274 |
7252 | 7275 |
7253 #undef DECLARE_INSTRUCTION | 7276 #undef DECLARE_INSTRUCTION |
7254 #undef DECLARE_CONCRETE_INSTRUCTION | 7277 #undef DECLARE_CONCRETE_INSTRUCTION |
7255 | 7278 |
7256 } } // namespace v8::internal | 7279 } } // namespace v8::internal |
7257 | 7280 |
7258 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ | 7281 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ |
OLD | NEW |