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 5203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5214 virtual void PrintDataTo(StringStream* stream); | 5214 virtual void PrintDataTo(StringStream* stream); |
5215 | 5215 |
5216 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot) | 5216 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot) |
5217 | 5217 |
5218 private: | 5218 private: |
5219 int slot_index_; | 5219 int slot_index_; |
5220 Mode mode_; | 5220 Mode mode_; |
5221 }; | 5221 }; |
5222 | 5222 |
5223 | 5223 |
| 5224 // Represents an access to a portion of an object, such as the map pointer, |
| 5225 // array elements pointer, etc, but not accesses to array elements themselves. |
| 5226 class HObjectAccess: public ZoneObject { |
| 5227 public: |
| 5228 enum Portion { |
| 5229 kArrayLengths, |
| 5230 kInobject, |
| 5231 kBackingStore, |
| 5232 kElementsPointer, |
| 5233 kMaps |
| 5234 }; |
| 5235 |
| 5236 HObjectAccess(Portion portion, int offset, |
| 5237 Handle<String> name = Handle<String>::null()) |
| 5238 : portion_(portion), offset_(offset) { } |
| 5239 |
| 5240 inline bool IsInobject() { |
| 5241 return portion_ != kBackingStore; |
| 5242 } |
| 5243 |
| 5244 inline int offset() { |
| 5245 return offset_; |
| 5246 } |
| 5247 |
| 5248 inline Handle<String> name() { |
| 5249 return name_; |
| 5250 } |
| 5251 |
| 5252 protected: |
| 5253 void SetGVNFlags(HValue *instr, bool is_store); |
| 5254 |
| 5255 private: |
| 5256 Portion portion_; |
| 5257 int offset_; |
| 5258 Handle<String> name_; |
| 5259 |
| 5260 friend class HLoadNamedField; |
| 5261 friend class HStoreNamedField; |
| 5262 }; |
| 5263 |
| 5264 |
5224 class HLoadNamedField: public HTemplateInstruction<2> { | 5265 class HLoadNamedField: public HTemplateInstruction<2> { |
5225 public: | 5266 public: |
5226 HLoadNamedField(HValue* object, bool is_in_object, | 5267 HLoadNamedField(HValue* object, HObjectAccess *access, |
5227 Representation field_representation, | 5268 HValue* typecheck = NULL) |
5228 int offset, HValue* typecheck = NULL) | 5269 : access_(access), |
5229 : is_in_object_(is_in_object), | 5270 field_representation_(Representation::Tagged()) { |
5230 field_representation_(field_representation), | |
5231 offset_(offset) { | |
5232 ASSERT(object != NULL); | 5271 ASSERT(object != NULL); |
5233 SetOperandAt(0, object); | 5272 SetOperandAt(0, object); |
5234 SetOperandAt(1, typecheck != NULL ? typecheck : object); | 5273 SetOperandAt(1, typecheck != NULL ? typecheck : object); |
5235 | 5274 |
5236 if (FLAG_track_fields && field_representation.IsSmi()) { | 5275 set_representation(Representation::Tagged()); |
5237 set_type(HType::Smi()); | 5276 access->SetGVNFlags(this, false); |
5238 set_representation(Representation::Tagged()); | |
5239 } else if (FLAG_track_double_fields && field_representation.IsDouble()) { | |
5240 set_representation(field_representation); | |
5241 } else { | |
5242 set_representation(Representation::Tagged()); | |
5243 } | |
5244 SetFlag(kUseGVN); | |
5245 SetGVNFlag(kDependsOnMaps); | |
5246 if (is_in_object) { | |
5247 SetGVNFlag(kDependsOnInobjectFields); | |
5248 } else { | |
5249 SetGVNFlag(kDependsOnBackingStoreFields); | |
5250 } | |
5251 } | |
5252 | |
5253 static HLoadNamedField* NewArrayLength(Zone* zone, HValue* object, | |
5254 HValue* typecheck, | |
5255 HType type = HType::Tagged()) { | |
5256 Representation representation = | |
5257 type.IsSmi() ? Representation::Smi() : Representation::Tagged(); | |
5258 HLoadNamedField* result = new(zone) HLoadNamedField( | |
5259 object, true, representation, JSArray::kLengthOffset, typecheck); | |
5260 result->set_type(type); | |
5261 result->SetGVNFlag(kDependsOnArrayLengths); | |
5262 result->ClearGVNFlag(kDependsOnInobjectFields); | |
5263 return result; | |
5264 } | 5277 } |
5265 | 5278 |
5266 HValue* object() { return OperandAt(0); } | 5279 HValue* object() { return OperandAt(0); } |
5267 HValue* typecheck() { | 5280 HValue* typecheck() { |
5268 ASSERT(HasTypeCheck()); | 5281 ASSERT(HasTypeCheck()); |
5269 return OperandAt(1); | 5282 return OperandAt(1); |
5270 } | 5283 } |
5271 | 5284 |
5272 bool HasTypeCheck() const { return OperandAt(0) != OperandAt(1); } | 5285 bool HasTypeCheck() const { return OperandAt(0) != OperandAt(1); } |
5273 bool is_in_object() const { return is_in_object_; } | 5286 bool is_in_object() const { return access_->IsInobject(); } |
5274 Representation field_representation() const { return representation_; } | 5287 Representation field_representation() const { return representation_; } |
5275 int offset() const { return offset_; } | 5288 int offset() const { return access_->offset(); } |
| 5289 |
| 5290 void set_field_representation(Representation representation) { |
| 5291 field_representation_ = representation; |
| 5292 } |
5276 | 5293 |
5277 virtual Representation RequiredInputRepresentation(int index) { | 5294 virtual Representation RequiredInputRepresentation(int index) { |
5278 return Representation::Tagged(); | 5295 return Representation::Tagged(); |
5279 } | 5296 } |
5280 virtual void PrintDataTo(StringStream* stream); | 5297 virtual void PrintDataTo(StringStream* stream); |
5281 | 5298 |
5282 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField) | 5299 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField) |
5283 | 5300 |
5284 protected: | 5301 protected: |
5285 virtual bool DataEquals(HValue* other) { | 5302 virtual bool DataEquals(HValue* other) { |
5286 HLoadNamedField* b = HLoadNamedField::cast(other); | 5303 HLoadNamedField* b = HLoadNamedField::cast(other); |
5287 return is_in_object_ == b->is_in_object_ && offset_ == b->offset_; | 5304 return is_in_object() == b->is_in_object() && offset() == b->offset(); |
5288 } | 5305 } |
5289 | 5306 |
5290 private: | 5307 private: |
5291 virtual bool IsDeletable() const { return true; } | 5308 virtual bool IsDeletable() const { return true; } |
5292 | 5309 |
5293 bool is_in_object_; | 5310 HObjectAccess* access_; |
5294 Representation field_representation_; | 5311 Representation field_representation_; |
5295 int offset_; | |
5296 }; | 5312 }; |
5297 | 5313 |
5298 | 5314 |
5299 class HLoadNamedFieldPolymorphic: public HTemplateInstruction<2> { | 5315 class HLoadNamedFieldPolymorphic: public HTemplateInstruction<2> { |
5300 public: | 5316 public: |
5301 HLoadNamedFieldPolymorphic(HValue* context, | 5317 HLoadNamedFieldPolymorphic(HValue* context, |
5302 HValue* object, | 5318 HValue* object, |
5303 SmallMapList* types, | 5319 SmallMapList* types, |
5304 Handle<String> name, | 5320 Handle<String> name, |
5305 Zone* zone); | 5321 Zone* zone); |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5579 | 5595 |
5580 virtual HValue* Canonicalize(); | 5596 virtual HValue* Canonicalize(); |
5581 | 5597 |
5582 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric) | 5598 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric) |
5583 }; | 5599 }; |
5584 | 5600 |
5585 | 5601 |
5586 class HStoreNamedField: public HTemplateInstruction<2> { | 5602 class HStoreNamedField: public HTemplateInstruction<2> { |
5587 public: | 5603 public: |
5588 HStoreNamedField(HValue* obj, | 5604 HStoreNamedField(HValue* obj, |
5589 Handle<String> name, | 5605 HObjectAccess* access, |
5590 HValue* val, | 5606 HValue* val) |
5591 bool in_object, | 5607 : access_(access), |
5592 Representation field_representation, | 5608 field_representation_(Representation::Tagged()), |
5593 int offset) | |
5594 : name_(name), | |
5595 is_in_object_(in_object), | |
5596 field_representation_(field_representation), | |
5597 offset_(offset), | |
5598 transition_unique_id_(), | 5609 transition_unique_id_(), |
5599 new_space_dominator_(NULL) { | 5610 new_space_dominator_(NULL) { |
5600 SetOperandAt(0, obj); | 5611 SetOperandAt(0, obj); |
5601 SetOperandAt(1, val); | 5612 SetOperandAt(1, val); |
5602 SetFlag(kTrackSideEffectDominators); | 5613 access->SetGVNFlags(this, true); |
5603 SetGVNFlag(kDependsOnNewSpacePromotion); | |
5604 if (is_in_object_) { | |
5605 SetGVNFlag(kChangesInobjectFields); | |
5606 } else { | |
5607 SetGVNFlag(kChangesBackingStoreFields); | |
5608 } | |
5609 } | 5614 } |
5610 | 5615 |
5611 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField) | 5616 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField) |
5612 | 5617 |
5613 virtual Representation RequiredInputRepresentation(int index) { | 5618 virtual Representation RequiredInputRepresentation(int index) { |
5614 if (FLAG_track_fields && index == 1 && field_representation_.IsSmi()) { | 5619 if (FLAG_track_fields && index == 1 && field_representation_.IsSmi()) { |
5615 return Representation::Integer32(); | 5620 return Representation::Integer32(); |
5616 } | 5621 } |
5617 return Representation::Tagged(); | 5622 return Representation::Tagged(); |
5618 } | 5623 } |
5619 virtual void SetSideEffectDominator(GVNFlag side_effect, HValue* dominator) { | 5624 virtual void SetSideEffectDominator(GVNFlag side_effect, HValue* dominator) { |
5620 ASSERT(side_effect == kChangesNewSpacePromotion); | 5625 ASSERT(side_effect == kChangesNewSpacePromotion); |
5621 new_space_dominator_ = dominator; | 5626 new_space_dominator_ = dominator; |
5622 } | 5627 } |
5623 virtual void PrintDataTo(StringStream* stream); | 5628 virtual void PrintDataTo(StringStream* stream); |
5624 | 5629 |
5625 HValue* object() { return OperandAt(0); } | 5630 HValue* object() { return OperandAt(0); } |
5626 HValue* value() { return OperandAt(1); } | 5631 HValue* value() { return OperandAt(1); } |
5627 | 5632 |
5628 Handle<String> name() const { return name_; } | 5633 Handle<String> name() const { return access_->name(); } |
5629 bool is_in_object() const { return is_in_object_; } | 5634 bool is_in_object() const { return access_->IsInobject(); } |
5630 int offset() const { return offset_; } | 5635 int offset() const { return access_->offset(); } |
5631 Handle<Map> transition() const { return transition_; } | 5636 Handle<Map> transition() const { return transition_; } |
5632 UniqueValueId transition_unique_id() const { return transition_unique_id_; } | 5637 UniqueValueId transition_unique_id() const { return transition_unique_id_; } |
5633 void set_transition(Handle<Map> map) { transition_ = map; } | 5638 void set_transition(Handle<Map> map) { transition_ = map; } |
5634 HValue* new_space_dominator() const { return new_space_dominator_; } | 5639 HValue* new_space_dominator() const { return new_space_dominator_; } |
5635 | 5640 |
5636 bool NeedsWriteBarrier() { | 5641 bool NeedsWriteBarrier() { |
5637 return (!FLAG_track_fields || !field_representation_.IsSmi()) && | 5642 return (!FLAG_track_fields || !field_representation_.IsSmi()) && |
5638 StoringValueNeedsWriteBarrier(value()) && | 5643 StoringValueNeedsWriteBarrier(value()) && |
5639 ReceiverObjectNeedsWriteBarrier(object(), new_space_dominator()); | 5644 ReceiverObjectNeedsWriteBarrier(object(), new_space_dominator()); |
5640 } | 5645 } |
5641 | 5646 |
5642 bool NeedsWriteBarrierForMap() { | 5647 bool NeedsWriteBarrierForMap() { |
5643 return ReceiverObjectNeedsWriteBarrier(object(), new_space_dominator()); | 5648 return ReceiverObjectNeedsWriteBarrier(object(), new_space_dominator()); |
5644 } | 5649 } |
5645 | 5650 |
5646 virtual void FinalizeUniqueValueId() { | 5651 virtual void FinalizeUniqueValueId() { |
5647 transition_unique_id_ = UniqueValueId(transition_); | 5652 transition_unique_id_ = UniqueValueId(transition_); |
5648 } | 5653 } |
5649 | 5654 |
| 5655 void set_field_representation(Representation representation) { |
| 5656 field_representation_ = representation; |
| 5657 } |
| 5658 |
5650 Representation field_representation() const { | 5659 Representation field_representation() const { |
5651 return field_representation_; | 5660 return field_representation_; |
5652 } | 5661 } |
5653 | 5662 |
5654 private: | 5663 private: |
5655 Handle<String> name_; | 5664 HObjectAccess* access_; |
5656 bool is_in_object_; | |
5657 Representation field_representation_; | 5665 Representation field_representation_; |
5658 int offset_; | |
5659 Handle<Map> transition_; | 5666 Handle<Map> transition_; |
5660 UniqueValueId transition_unique_id_; | 5667 UniqueValueId transition_unique_id_; |
5661 HValue* new_space_dominator_; | 5668 HValue* new_space_dominator_; |
5662 }; | 5669 }; |
5663 | 5670 |
5664 | 5671 |
5665 class HStoreNamedGeneric: public HTemplateInstruction<3> { | 5672 class HStoreNamedGeneric: public HTemplateInstruction<3> { |
5666 public: | 5673 public: |
5667 HStoreNamedGeneric(HValue* context, | 5674 HStoreNamedGeneric(HValue* context, |
5668 HValue* object, | 5675 HValue* object, |
(...skipping 888 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6557 virtual bool IsDeletable() const { return true; } | 6564 virtual bool IsDeletable() const { return true; } |
6558 }; | 6565 }; |
6559 | 6566 |
6560 | 6567 |
6561 #undef DECLARE_INSTRUCTION | 6568 #undef DECLARE_INSTRUCTION |
6562 #undef DECLARE_CONCRETE_INSTRUCTION | 6569 #undef DECLARE_CONCRETE_INSTRUCTION |
6563 | 6570 |
6564 } } // namespace v8::internal | 6571 } } // namespace v8::internal |
6565 | 6572 |
6566 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ | 6573 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ |
OLD | NEW |