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 5193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5204 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot) | 5204 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot) |
5205 | 5205 |
5206 private: | 5206 private: |
5207 int slot_index_; | 5207 int slot_index_; |
5208 Mode mode_; | 5208 Mode mode_; |
5209 }; | 5209 }; |
5210 | 5210 |
5211 | 5211 |
5212 class HLoadNamedField: public HTemplateInstruction<2> { | 5212 class HLoadNamedField: public HTemplateInstruction<2> { |
5213 public: | 5213 public: |
5214 HLoadNamedField(HValue* object, bool is_in_object, int offset, | 5214 HLoadNamedField(HValue* object, bool is_in_object, StorageType storage_type, |
5215 HValue* typecheck = NULL) | 5215 int offset, HValue* typecheck = NULL) |
5216 : is_in_object_(is_in_object), | 5216 : is_in_object_(is_in_object), |
| 5217 storage_type_(storage_type), |
5217 offset_(offset) { | 5218 offset_(offset) { |
5218 ASSERT(object != NULL); | 5219 ASSERT(object != NULL); |
5219 SetOperandAt(0, object); | 5220 SetOperandAt(0, object); |
5220 SetOperandAt(1, typecheck != NULL ? typecheck : object); | 5221 SetOperandAt(1, typecheck != NULL ? typecheck : object); |
5221 | 5222 |
5222 set_representation(Representation::Tagged()); | 5223 if (FLAG_track_fields && storage_type == SMI) { |
| 5224 set_type(HType::Smi()); |
| 5225 set_representation(Representation::Tagged()); |
| 5226 } else if (FLAG_track_double_fields && storage_type == DOUBLE) { |
| 5227 set_representation(Representation::Double()); |
| 5228 } else { |
| 5229 set_representation(Representation::Tagged()); |
| 5230 } |
5223 SetFlag(kUseGVN); | 5231 SetFlag(kUseGVN); |
5224 SetGVNFlag(kDependsOnMaps); | 5232 SetGVNFlag(kDependsOnMaps); |
5225 if (is_in_object) { | 5233 if (is_in_object) { |
5226 SetGVNFlag(kDependsOnInobjectFields); | 5234 SetGVNFlag(kDependsOnInobjectFields); |
5227 } else { | 5235 } else { |
5228 SetGVNFlag(kDependsOnBackingStoreFields); | 5236 SetGVNFlag(kDependsOnBackingStoreFields); |
5229 } | 5237 } |
5230 } | 5238 } |
5231 | 5239 |
5232 static HLoadNamedField* NewArrayLength(Zone* zone, HValue* object, | 5240 static HLoadNamedField* NewArrayLength(Zone* zone, HValue* object, |
5233 HValue* typecheck, | 5241 HValue* typecheck, |
5234 HType type = HType::Tagged()) { | 5242 HType type = HType::Tagged()) { |
| 5243 StorageType storage = type.IsSmi() ? SMI : TAGGED; |
5235 HLoadNamedField* result = new(zone) HLoadNamedField( | 5244 HLoadNamedField* result = new(zone) HLoadNamedField( |
5236 object, true, JSArray::kLengthOffset, typecheck); | 5245 object, true, storage, JSArray::kLengthOffset, typecheck); |
5237 result->set_type(type); | 5246 result->set_type(type); |
5238 result->SetGVNFlag(kDependsOnArrayLengths); | 5247 result->SetGVNFlag(kDependsOnArrayLengths); |
5239 result->ClearGVNFlag(kDependsOnInobjectFields); | 5248 result->ClearGVNFlag(kDependsOnInobjectFields); |
5240 return result; | 5249 return result; |
5241 } | 5250 } |
5242 | 5251 |
5243 HValue* object() { return OperandAt(0); } | 5252 HValue* object() { return OperandAt(0); } |
5244 HValue* typecheck() { | 5253 HValue* typecheck() { |
5245 ASSERT(HasTypeCheck()); | 5254 ASSERT(HasTypeCheck()); |
5246 return OperandAt(1); | 5255 return OperandAt(1); |
5247 } | 5256 } |
5248 | 5257 |
5249 bool HasTypeCheck() const { return OperandAt(0) != OperandAt(1); } | 5258 bool HasTypeCheck() const { return OperandAt(0) != OperandAt(1); } |
5250 bool is_in_object() const { return is_in_object_; } | 5259 bool is_in_object() const { return is_in_object_; } |
| 5260 StorageType storage_type() const { return storage_type_; } |
5251 int offset() const { return offset_; } | 5261 int offset() const { return offset_; } |
5252 | 5262 |
5253 virtual Representation RequiredInputRepresentation(int index) { | 5263 virtual Representation RequiredInputRepresentation(int index) { |
5254 return Representation::Tagged(); | 5264 return Representation::Tagged(); |
5255 } | 5265 } |
5256 virtual void PrintDataTo(StringStream* stream); | 5266 virtual void PrintDataTo(StringStream* stream); |
5257 | 5267 |
5258 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField) | 5268 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField) |
5259 | 5269 |
5260 protected: | 5270 protected: |
5261 virtual bool DataEquals(HValue* other) { | 5271 virtual bool DataEquals(HValue* other) { |
5262 HLoadNamedField* b = HLoadNamedField::cast(other); | 5272 HLoadNamedField* b = HLoadNamedField::cast(other); |
5263 return is_in_object_ == b->is_in_object_ && offset_ == b->offset_; | 5273 return is_in_object_ == b->is_in_object_ && offset_ == b->offset_; |
5264 } | 5274 } |
5265 | 5275 |
5266 private: | 5276 private: |
5267 virtual bool IsDeletable() const { return true; } | 5277 virtual bool IsDeletable() const { return true; } |
5268 | 5278 |
5269 bool is_in_object_; | 5279 bool is_in_object_; |
| 5280 StorageType storage_type_; |
5270 int offset_; | 5281 int offset_; |
5271 }; | 5282 }; |
5272 | 5283 |
5273 | 5284 |
5274 class HLoadNamedFieldPolymorphic: public HTemplateInstruction<2> { | 5285 class HLoadNamedFieldPolymorphic: public HTemplateInstruction<2> { |
5275 public: | 5286 public: |
5276 HLoadNamedFieldPolymorphic(HValue* context, | 5287 HLoadNamedFieldPolymorphic(HValue* context, |
5277 HValue* object, | 5288 HValue* object, |
5278 SmallMapList* types, | 5289 SmallMapList* types, |
5279 Handle<String> name, | 5290 Handle<String> name, |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5557 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric) | 5568 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric) |
5558 }; | 5569 }; |
5559 | 5570 |
5560 | 5571 |
5561 class HStoreNamedField: public HTemplateInstruction<2> { | 5572 class HStoreNamedField: public HTemplateInstruction<2> { |
5562 public: | 5573 public: |
5563 HStoreNamedField(HValue* obj, | 5574 HStoreNamedField(HValue* obj, |
5564 Handle<String> name, | 5575 Handle<String> name, |
5565 HValue* val, | 5576 HValue* val, |
5566 bool in_object, | 5577 bool in_object, |
| 5578 StorageType storage, |
5567 int offset) | 5579 int offset) |
5568 : name_(name), | 5580 : name_(name), |
5569 is_in_object_(in_object), | 5581 is_in_object_(in_object), |
| 5582 storage_(storage), |
5570 offset_(offset), | 5583 offset_(offset), |
5571 transition_unique_id_(), | 5584 transition_unique_id_(), |
5572 new_space_dominator_(NULL) { | 5585 new_space_dominator_(NULL) { |
5573 SetOperandAt(0, obj); | 5586 SetOperandAt(0, obj); |
5574 SetOperandAt(1, val); | 5587 SetOperandAt(1, val); |
5575 SetFlag(kTrackSideEffectDominators); | 5588 SetFlag(kTrackSideEffectDominators); |
5576 SetGVNFlag(kDependsOnNewSpacePromotion); | 5589 SetGVNFlag(kDependsOnNewSpacePromotion); |
5577 if (is_in_object_) { | 5590 if (is_in_object_) { |
5578 SetGVNFlag(kChangesInobjectFields); | 5591 SetGVNFlag(kChangesInobjectFields); |
5579 } else { | 5592 } else { |
5580 SetGVNFlag(kChangesBackingStoreFields); | 5593 SetGVNFlag(kChangesBackingStoreFields); |
5581 } | 5594 } |
5582 } | 5595 } |
5583 | 5596 |
5584 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField) | 5597 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField) |
5585 | 5598 |
5586 virtual Representation RequiredInputRepresentation(int index) { | 5599 virtual Representation RequiredInputRepresentation(int index) { |
| 5600 // if (FLAG_track_double_fields && index == 1 && storage_ == DOUBLE) { |
| 5601 // return Representation::Double(); |
| 5602 // } else |
| 5603 if (FLAG_track_fields && index == 1 && storage_ == SMI) { |
| 5604 return Representation::Integer32(); |
| 5605 } |
5587 return Representation::Tagged(); | 5606 return Representation::Tagged(); |
5588 } | 5607 } |
5589 virtual void SetSideEffectDominator(GVNFlag side_effect, HValue* dominator) { | 5608 virtual void SetSideEffectDominator(GVNFlag side_effect, HValue* dominator) { |
5590 ASSERT(side_effect == kChangesNewSpacePromotion); | 5609 ASSERT(side_effect == kChangesNewSpacePromotion); |
5591 new_space_dominator_ = dominator; | 5610 new_space_dominator_ = dominator; |
5592 } | 5611 } |
5593 virtual void PrintDataTo(StringStream* stream); | 5612 virtual void PrintDataTo(StringStream* stream); |
5594 | 5613 |
5595 HValue* object() { return OperandAt(0); } | 5614 HValue* object() { return OperandAt(0); } |
5596 HValue* value() { return OperandAt(1); } | 5615 HValue* value() { return OperandAt(1); } |
5597 | 5616 |
5598 Handle<String> name() const { return name_; } | 5617 Handle<String> name() const { return name_; } |
5599 bool is_in_object() const { return is_in_object_; } | 5618 bool is_in_object() const { return is_in_object_; } |
5600 int offset() const { return offset_; } | 5619 int offset() const { return offset_; } |
5601 Handle<Map> transition() const { return transition_; } | 5620 Handle<Map> transition() const { return transition_; } |
5602 UniqueValueId transition_unique_id() const { return transition_unique_id_; } | 5621 UniqueValueId transition_unique_id() const { return transition_unique_id_; } |
5603 void set_transition(Handle<Map> map) { transition_ = map; } | 5622 void set_transition(Handle<Map> map) { transition_ = map; } |
5604 HValue* new_space_dominator() const { return new_space_dominator_; } | 5623 HValue* new_space_dominator() const { return new_space_dominator_; } |
5605 | 5624 |
5606 bool NeedsWriteBarrier() { | 5625 bool NeedsWriteBarrier() { |
5607 return StoringValueNeedsWriteBarrier(value()) && | 5626 return (storage_ != SMI || !FLAG_track_fields) && |
| 5627 // (storage_ != DOUBLE || !FLAG_track_double_fields) && |
| 5628 StoringValueNeedsWriteBarrier(value()) && |
5608 ReceiverObjectNeedsWriteBarrier(object(), new_space_dominator()); | 5629 ReceiverObjectNeedsWriteBarrier(object(), new_space_dominator()); |
5609 } | 5630 } |
5610 | 5631 |
5611 bool NeedsWriteBarrierForMap() { | 5632 bool NeedsWriteBarrierForMap() { |
5612 return ReceiverObjectNeedsWriteBarrier(object(), new_space_dominator()); | 5633 return ReceiverObjectNeedsWriteBarrier(object(), new_space_dominator()); |
5613 } | 5634 } |
5614 | 5635 |
5615 virtual void FinalizeUniqueValueId() { | 5636 virtual void FinalizeUniqueValueId() { |
5616 transition_unique_id_ = UniqueValueId(transition_); | 5637 transition_unique_id_ = UniqueValueId(transition_); |
5617 } | 5638 } |
5618 | 5639 |
| 5640 StorageType storage_type() const { |
| 5641 return storage_; |
| 5642 } |
| 5643 |
5619 private: | 5644 private: |
5620 Handle<String> name_; | 5645 Handle<String> name_; |
5621 bool is_in_object_; | 5646 bool is_in_object_; |
| 5647 StorageType storage_; |
5622 int offset_; | 5648 int offset_; |
5623 Handle<Map> transition_; | 5649 Handle<Map> transition_; |
5624 UniqueValueId transition_unique_id_; | 5650 UniqueValueId transition_unique_id_; |
5625 HValue* new_space_dominator_; | 5651 HValue* new_space_dominator_; |
5626 }; | 5652 }; |
5627 | 5653 |
5628 | 5654 |
5629 class HStoreNamedGeneric: public HTemplateInstruction<3> { | 5655 class HStoreNamedGeneric: public HTemplateInstruction<3> { |
5630 public: | 5656 public: |
5631 HStoreNamedGeneric(HValue* context, | 5657 HStoreNamedGeneric(HValue* context, |
(...skipping 859 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6491 virtual bool IsDeletable() const { return true; } | 6517 virtual bool IsDeletable() const { return true; } |
6492 }; | 6518 }; |
6493 | 6519 |
6494 | 6520 |
6495 #undef DECLARE_INSTRUCTION | 6521 #undef DECLARE_INSTRUCTION |
6496 #undef DECLARE_CONCRETE_INSTRUCTION | 6522 #undef DECLARE_CONCRETE_INSTRUCTION |
6497 | 6523 |
6498 } } // namespace v8::internal | 6524 } } // namespace v8::internal |
6499 | 6525 |
6500 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ | 6526 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ |
OLD | NEW |