| 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 2620 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2631 if (index == 0) { | 2631 if (index == 0) { |
| 2632 return Representation::Tagged(); | 2632 return Representation::Tagged(); |
| 2633 } else { | 2633 } else { |
| 2634 switch (op_) { | 2634 switch (op_) { |
| 2635 case kMathFloor: | 2635 case kMathFloor: |
| 2636 case kMathRound: | 2636 case kMathRound: |
| 2637 case kMathSqrt: | 2637 case kMathSqrt: |
| 2638 case kMathPowHalf: | 2638 case kMathPowHalf: |
| 2639 case kMathLog: | 2639 case kMathLog: |
| 2640 case kMathExp: | 2640 case kMathExp: |
| 2641 case kMathSin: | |
| 2642 case kMathCos: | |
| 2643 case kMathTan: | |
| 2644 return Representation::Double(); | 2641 return Representation::Double(); |
| 2645 case kMathAbs: | 2642 case kMathAbs: |
| 2646 return representation(); | 2643 return representation(); |
| 2647 default: | 2644 default: |
| 2648 UNREACHABLE(); | 2645 UNREACHABLE(); |
| 2649 return Representation::None(); | 2646 return Representation::None(); |
| 2650 } | 2647 } |
| 2651 } | 2648 } |
| 2652 } | 2649 } |
| 2653 | 2650 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 2678 set_representation(Representation::Integer32()); | 2675 set_representation(Representation::Integer32()); |
| 2679 break; | 2676 break; |
| 2680 case kMathAbs: | 2677 case kMathAbs: |
| 2681 // Not setting representation here: it is None intentionally. | 2678 // Not setting representation here: it is None intentionally. |
| 2682 SetFlag(kFlexibleRepresentation); | 2679 SetFlag(kFlexibleRepresentation); |
| 2683 // TODO(svenpanne) This flag is actually only needed if representation() | 2680 // TODO(svenpanne) This flag is actually only needed if representation() |
| 2684 // is tagged, and not when it is an unboxed double or unboxed integer. | 2681 // is tagged, and not when it is an unboxed double or unboxed integer. |
| 2685 SetGVNFlag(kChangesNewSpacePromotion); | 2682 SetGVNFlag(kChangesNewSpacePromotion); |
| 2686 break; | 2683 break; |
| 2687 case kMathLog: | 2684 case kMathLog: |
| 2688 case kMathSin: | |
| 2689 case kMathCos: | |
| 2690 case kMathTan: | |
| 2691 set_representation(Representation::Double()); | 2685 set_representation(Representation::Double()); |
| 2692 // These operations use the TranscendentalCache, so they may allocate. | 2686 // These operations use the TranscendentalCache, so they may allocate. |
| 2693 SetGVNFlag(kChangesNewSpacePromotion); | 2687 SetGVNFlag(kChangesNewSpacePromotion); |
| 2694 break; | 2688 break; |
| 2695 case kMathExp: | 2689 case kMathExp: |
| 2696 case kMathSqrt: | 2690 case kMathSqrt: |
| 2697 case kMathPowHalf: | 2691 case kMathPowHalf: |
| 2698 set_representation(Representation::Double()); | 2692 set_representation(Representation::Double()); |
| 2699 break; | 2693 break; |
| 2700 default: | 2694 default: |
| (...skipping 2901 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5602 DECLARE_CONCRETE_INSTRUCTION(StoreCodeEntry) | 5596 DECLARE_CONCRETE_INSTRUCTION(StoreCodeEntry) |
| 5603 | 5597 |
| 5604 private: | 5598 private: |
| 5605 HStoreCodeEntry(HValue* function, HValue* code) { | 5599 HStoreCodeEntry(HValue* function, HValue* code) { |
| 5606 SetOperandAt(0, function); | 5600 SetOperandAt(0, function); |
| 5607 SetOperandAt(1, code); | 5601 SetOperandAt(1, code); |
| 5608 } | 5602 } |
| 5609 }; | 5603 }; |
| 5610 | 5604 |
| 5611 | 5605 |
| 5612 class HInnerAllocatedObject V8_FINAL: public HTemplateInstruction<1> { | 5606 class HInnerAllocatedObject V8_FINAL : public HTemplateInstruction<2> { |
| 5613 public: | 5607 public: |
| 5614 static HInnerAllocatedObject* New(Zone* zone, | 5608 static HInnerAllocatedObject* New(Zone* zone, |
| 5615 HValue* context, | 5609 HValue* context, |
| 5616 HValue* value, | 5610 HValue* value, |
| 5617 int offset, | 5611 HValue* offset, |
| 5618 HType type = HType::Tagged()) { | 5612 HType type = HType::Tagged()) { |
| 5619 return new(zone) HInnerAllocatedObject(value, offset, type); | 5613 return new(zone) HInnerAllocatedObject(value, offset, type); |
| 5620 } | 5614 } |
| 5621 | 5615 |
| 5622 HValue* base_object() { return OperandAt(0); } | 5616 HValue* base_object() { return OperandAt(0); } |
| 5623 int offset() { return offset_; } | 5617 HValue* offset() { return OperandAt(1); } |
| 5624 | 5618 |
| 5625 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE { | 5619 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE { |
| 5626 return Representation::Tagged(); | 5620 return index == 0 ? Representation::Tagged() : Representation::Integer32(); |
| 5627 } | 5621 } |
| 5628 | 5622 |
| 5629 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE; | 5623 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE; |
| 5630 | 5624 |
| 5631 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject) | 5625 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject) |
| 5632 | 5626 |
| 5633 private: | 5627 private: |
| 5634 HInnerAllocatedObject(HValue* value, int offset, HType type = HType::Tagged()) | 5628 HInnerAllocatedObject(HValue* value, |
| 5635 : HTemplateInstruction<1>(type), offset_(offset) { | 5629 HValue* offset, |
| 5630 HType type = HType::Tagged()) |
| 5631 : HTemplateInstruction<2>(type) { |
| 5636 ASSERT(value->IsAllocate()); | 5632 ASSERT(value->IsAllocate()); |
| 5637 SetOperandAt(0, value); | 5633 SetOperandAt(0, value); |
| 5634 SetOperandAt(1, offset); |
| 5638 set_type(type); | 5635 set_type(type); |
| 5639 set_representation(Representation::Tagged()); | 5636 set_representation(Representation::Tagged()); |
| 5640 } | 5637 } |
| 5641 | |
| 5642 int offset_; | |
| 5643 }; | 5638 }; |
| 5644 | 5639 |
| 5645 | 5640 |
| 5646 inline bool StoringValueNeedsWriteBarrier(HValue* value) { | 5641 inline bool StoringValueNeedsWriteBarrier(HValue* value) { |
| 5647 return !value->type().IsBoolean() | 5642 return !value->type().IsBoolean() |
| 5648 && !value->type().IsSmi() | 5643 && !value->type().IsSmi() |
| 5649 && !(value->IsConstant() && HConstant::cast(value)->ImmortalImmovable()); | 5644 && !(value->IsConstant() && HConstant::cast(value)->ImmortalImmovable()); |
| 5650 } | 5645 } |
| 5651 | 5646 |
| 5652 | 5647 |
| 5653 inline bool ReceiverObjectNeedsWriteBarrier(HValue* object, | 5648 inline bool ReceiverObjectNeedsWriteBarrier(HValue* object, |
| 5649 HValue* value, |
| 5654 HValue* new_space_dominator) { | 5650 HValue* new_space_dominator) { |
| 5655 if (object->IsInnerAllocatedObject()) { | 5651 while (object->IsInnerAllocatedObject()) { |
| 5656 return ReceiverObjectNeedsWriteBarrier( | 5652 object = HInnerAllocatedObject::cast(object)->base_object(); |
| 5657 HInnerAllocatedObject::cast(object)->base_object(), | |
| 5658 new_space_dominator); | |
| 5659 } | 5653 } |
| 5660 if (object->IsConstant() && HConstant::cast(object)->IsCell()) { | 5654 if (object->IsConstant() && HConstant::cast(object)->IsCell()) { |
| 5661 return false; | 5655 return false; |
| 5662 } | 5656 } |
| 5663 if (object->IsConstant() && | 5657 if (object->IsConstant() && |
| 5664 HConstant::cast(object)->HasExternalReferenceValue()) { | 5658 HConstant::cast(object)->HasExternalReferenceValue()) { |
| 5665 // Stores to external references require no write barriers | 5659 // Stores to external references require no write barriers |
| 5666 return false; | 5660 return false; |
| 5667 } | 5661 } |
| 5668 if (object != new_space_dominator) return true; | 5662 if (object != new_space_dominator) return true; |
| 5669 if (object->IsAllocate()) { | 5663 if (object->IsAllocate()) { |
| 5670 return !HAllocate::cast(object)->IsNewSpaceAllocation(); | 5664 // Stores to new space allocations require no write barriers if the object |
| 5665 // is the new space dominator. |
| 5666 if (HAllocate::cast(object)->IsNewSpaceAllocation()) { |
| 5667 return false; |
| 5668 } |
| 5669 // Likewise we don't need a write barrier if we store a value that |
| 5670 // originates from the same allocation (via allocation folding). |
| 5671 while (value->IsInnerAllocatedObject()) { |
| 5672 value = HInnerAllocatedObject::cast(value)->base_object(); |
| 5673 } |
| 5674 return object != value; |
| 5671 } | 5675 } |
| 5672 return true; | 5676 return true; |
| 5673 } | 5677 } |
| 5674 | 5678 |
| 5675 | 5679 |
| 5676 class HStoreGlobalCell V8_FINAL : public HUnaryOperation { | 5680 class HStoreGlobalCell V8_FINAL : public HUnaryOperation { |
| 5677 public: | 5681 public: |
| 5678 DECLARE_INSTRUCTION_FACTORY_P3(HStoreGlobalCell, HValue*, | 5682 DECLARE_INSTRUCTION_FACTORY_P3(HStoreGlobalCell, HValue*, |
| 5679 Handle<PropertyCell>, PropertyDetails); | 5683 Handle<PropertyCell>, PropertyDetails); |
| 5680 | 5684 |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5944 | 5948 |
| 5945 static HObjectAccess ForArrayLength(ElementsKind elements_kind) { | 5949 static HObjectAccess ForArrayLength(ElementsKind elements_kind) { |
| 5946 return HObjectAccess( | 5950 return HObjectAccess( |
| 5947 kArrayLengths, | 5951 kArrayLengths, |
| 5948 JSArray::kLengthOffset, | 5952 JSArray::kLengthOffset, |
| 5949 IsFastElementsKind(elements_kind) && | 5953 IsFastElementsKind(elements_kind) && |
| 5950 FLAG_track_fields | 5954 FLAG_track_fields |
| 5951 ? Representation::Smi() : Representation::Tagged()); | 5955 ? Representation::Smi() : Representation::Tagged()); |
| 5952 } | 5956 } |
| 5953 | 5957 |
| 5954 static HObjectAccess ForAllocationSiteOffset(int offset) { | 5958 static HObjectAccess ForAllocationSiteOffset(int offset); |
| 5955 ASSERT(offset >= HeapObject::kHeaderSize && offset < AllocationSite::kSize); | |
| 5956 return HObjectAccess(kInobject, offset); | |
| 5957 } | |
| 5958 | 5959 |
| 5959 static HObjectAccess ForAllocationSiteList() { | 5960 static HObjectAccess ForAllocationSiteList() { |
| 5960 return HObjectAccess(kExternalMemory, 0, Representation::Tagged()); | 5961 return HObjectAccess(kExternalMemory, 0, Representation::Tagged()); |
| 5961 } | 5962 } |
| 5962 | 5963 |
| 5963 static HObjectAccess ForFixedArrayLength() { | 5964 static HObjectAccess ForFixedArrayLength() { |
| 5964 return HObjectAccess( | 5965 return HObjectAccess( |
| 5965 kArrayLengths, | 5966 kArrayLengths, |
| 5966 FixedArray::kLengthOffset, | 5967 FixedArray::kLengthOffset, |
| 5967 FLAG_track_fields ? Representation::Smi() : Representation::Tagged()); | 5968 FLAG_track_fields ? Representation::Smi() : Representation::Tagged()); |
| (...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6581 | 6582 |
| 6582 bool NeedsWriteBarrier() { | 6583 bool NeedsWriteBarrier() { |
| 6583 ASSERT(!(FLAG_track_double_fields && field_representation().IsDouble()) || | 6584 ASSERT(!(FLAG_track_double_fields && field_representation().IsDouble()) || |
| 6584 !has_transition()); | 6585 !has_transition()); |
| 6585 if (IsSkipWriteBarrier()) return false; | 6586 if (IsSkipWriteBarrier()) return false; |
| 6586 if (field_representation().IsDouble()) return false; | 6587 if (field_representation().IsDouble()) return false; |
| 6587 if (field_representation().IsSmi()) return false; | 6588 if (field_representation().IsSmi()) return false; |
| 6588 if (field_representation().IsInteger32()) return false; | 6589 if (field_representation().IsInteger32()) return false; |
| 6589 if (field_representation().IsExternal()) return false; | 6590 if (field_representation().IsExternal()) return false; |
| 6590 return StoringValueNeedsWriteBarrier(value()) && | 6591 return StoringValueNeedsWriteBarrier(value()) && |
| 6591 ReceiverObjectNeedsWriteBarrier(object(), new_space_dominator()); | 6592 ReceiverObjectNeedsWriteBarrier(object(), value(), |
| 6593 new_space_dominator()); |
| 6592 } | 6594 } |
| 6593 | 6595 |
| 6594 bool NeedsWriteBarrierForMap() { | 6596 bool NeedsWriteBarrierForMap() { |
| 6595 if (IsSkipWriteBarrier()) return false; | 6597 if (IsSkipWriteBarrier()) return false; |
| 6596 return ReceiverObjectNeedsWriteBarrier(object(), new_space_dominator()); | 6598 return ReceiverObjectNeedsWriteBarrier(object(), transition(), |
| 6599 new_space_dominator()); |
| 6597 } | 6600 } |
| 6598 | 6601 |
| 6599 Representation field_representation() const { | 6602 Representation field_representation() const { |
| 6600 return access_.representation(); | 6603 return access_.representation(); |
| 6601 } | 6604 } |
| 6602 | 6605 |
| 6603 void UpdateValue(HValue* value) { | 6606 void UpdateValue(HValue* value) { |
| 6604 SetOperandAt(1, value); | 6607 SetOperandAt(1, value); |
| 6605 } | 6608 } |
| 6606 | 6609 |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6748 new_space_dominator_ = dominator; | 6751 new_space_dominator_ = dominator; |
| 6749 } | 6752 } |
| 6750 | 6753 |
| 6751 HValue* new_space_dominator() const { return new_space_dominator_; } | 6754 HValue* new_space_dominator() const { return new_space_dominator_; } |
| 6752 | 6755 |
| 6753 bool NeedsWriteBarrier() { | 6756 bool NeedsWriteBarrier() { |
| 6754 if (value_is_smi()) { | 6757 if (value_is_smi()) { |
| 6755 return false; | 6758 return false; |
| 6756 } else { | 6759 } else { |
| 6757 return StoringValueNeedsWriteBarrier(value()) && | 6760 return StoringValueNeedsWriteBarrier(value()) && |
| 6758 ReceiverObjectNeedsWriteBarrier(elements(), new_space_dominator()); | 6761 ReceiverObjectNeedsWriteBarrier(elements(), value(), |
| 6762 new_space_dominator()); |
| 6759 } | 6763 } |
| 6760 } | 6764 } |
| 6761 | 6765 |
| 6762 bool NeedsCanonicalization(); | 6766 bool NeedsCanonicalization(); |
| 6763 | 6767 |
| 6764 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE; | 6768 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE; |
| 6765 | 6769 |
| 6766 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed) | 6770 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed) |
| 6767 | 6771 |
| 6768 private: | 6772 private: |
| (...skipping 716 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7485 virtual bool IsDeletable() const V8_OVERRIDE { return true; } | 7489 virtual bool IsDeletable() const V8_OVERRIDE { return true; } |
| 7486 }; | 7490 }; |
| 7487 | 7491 |
| 7488 | 7492 |
| 7489 #undef DECLARE_INSTRUCTION | 7493 #undef DECLARE_INSTRUCTION |
| 7490 #undef DECLARE_CONCRETE_INSTRUCTION | 7494 #undef DECLARE_CONCRETE_INSTRUCTION |
| 7491 | 7495 |
| 7492 } } // namespace v8::internal | 7496 } } // namespace v8::internal |
| 7493 | 7497 |
| 7494 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ | 7498 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ |
| OLD | NEW |