Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(307)

Side by Side Diff: src/hydrogen-instructions.h

Issue 14284010: Introduce HObjectAccess, which is used by LoadNamedField and StoreNamedField to denote what parts (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Add HObjectAccess::ForBackingStoreOffset and HObjectAccess::ForAllocationSitePayload. Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 5168 matching lines...) Expand 10 before | Expand all | Expand 10 after
5179 virtual void PrintDataTo(StringStream* stream); 5179 virtual void PrintDataTo(StringStream* stream);
5180 5180
5181 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot) 5181 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot)
5182 5182
5183 private: 5183 private:
5184 int slot_index_; 5184 int slot_index_;
5185 Mode mode_; 5185 Mode mode_;
5186 }; 5186 };
5187 5187
5188 5188
5189 // Represents an access to a portion of an object, such as the map pointer,
5190 // array elements pointer, etc, but not accesses to array elements themselves.
5191 class HObjectAccess {
5192 public:
5193 inline bool IsInobject() const {
5194 return portion_ != kBackingStore;
5195 }
5196
5197 inline int offset() const {
5198 return offset_;
5199 }
5200
5201 inline Handle<String> name() const {
5202 return name_;
5203 }
5204
5205 static HObjectAccess ForElementsPointer() {
5206 return HObjectAccess(kElementsPointer, JSObject::kElementsOffset);
5207 }
5208
5209 static HObjectAccess ForArrayLength() {
5210 return HObjectAccess(kArrayLengths, JSArray::kLengthOffset);
5211 }
5212
5213 static HObjectAccess ForFixedArrayLength() {
5214 return HObjectAccess(kArrayLengths, FixedArray::kLengthOffset);
5215 }
5216
5217 static HObjectAccess ForPropertiesPointer() {
5218 return HObjectAccess(kInobject, JSObject::kPropertiesOffset);
5219 }
5220
5221 static HObjectAccess ForMap() {
5222 return HObjectAccess(kMaps, JSObject::kMapOffset);
5223 }
5224
5225 static HObjectAccess ForAllocationSitePayload() {
5226 return HObjectAccess(kInobject, AllocationSiteInfo::kPayloadOffset);
5227 }
5228
5229 // Create an access to an offset in a fixed array.
5230 static HObjectAccess ForFixedArrayOffset(int offset);
5231
5232 // Create an access to an in-object property in a JSObject.
5233 static HObjectAccess ForJSObjectOffset(int offset,
5234 Handle<String> name = Handle<String>::null());
danno 2013/05/10 15:59:19 Why do you pass names in here and to the other var
titzer 2013/05/13 11:23:19 I was thinking that I would pass in the name of th
danno 2013/05/13 15:44:32 It seems, however, that there is a regression. In
titzer 2013/05/14 09:26:19 I've changed lithium to ask the hydrogen's HObject
5235
5236 // Create an access to an in-object property in a JSArray.
5237 static HObjectAccess ForJSArrayOffset(int offset,
5238 Handle<String> name = Handle<String>::null());
5239
5240 // Create an access to the backing store of an object.
5241 static HObjectAccess ForBackingStoreOffset(int offset,
5242 Handle<String> name = Handle<String>::null());
5243
5244 // Create an access to a resolved field (in-object or backing store).
5245 static HObjectAccess ForField(Handle<Map> map,
5246 LookupResult *lookup, Handle<String> name = Handle<String>::null());
5247
5248 void PrintTo(StringStream* stream);
5249
5250 protected:
5251 void SetGVNFlags(HValue *instr, bool is_store);
5252
5253 private:
5254 // internal use only; different parts of an object or array
5255 enum Portion {
5256 kMaps, // map of an object
5257 kArrayLengths, // the length of an array
5258 kElementsPointer, // elements pointer
5259 kBackingStore, // some field in the backing store
5260 kInobject // some other in-object field
5261 };
5262
5263 HObjectAccess(Portion portion, int offset,
5264 Handle<String> name = Handle<String>::null())
5265 : portion_(portion), offset_(offset), name_(name) {
5266 ASSERT(offset_ == offset); // offset must fit
5267 ASSERT(portion_ == portion); // portion must fit
5268 }
5269
5270 unsigned portion_ : 3;
5271 unsigned offset_ : 29;
5272 Handle<String> name_;
5273
5274 friend class HLoadNamedField;
5275 friend class HStoreNamedField;
5276 };
5277
5278
5189 class HLoadNamedField: public HTemplateInstruction<2> { 5279 class HLoadNamedField: public HTemplateInstruction<2> {
5190 public: 5280 public:
5191 HLoadNamedField(HValue* object, bool is_in_object, 5281 HLoadNamedField(HValue* object,
5192 Representation field_representation, 5282 HObjectAccess access,
5193 int offset, HValue* typecheck = NULL) 5283 HValue* typecheck = NULL,
5194 : is_in_object_(is_in_object), 5284 Representation representation = Representation::Tagged())
5195 field_representation_(field_representation), 5285 : access_(access),
5196 offset_(offset) { 5286 field_representation_(representation) {
5197 ASSERT(object != NULL); 5287 ASSERT(object != NULL);
5198 SetOperandAt(0, object); 5288 SetOperandAt(0, object);
5199 SetOperandAt(1, typecheck != NULL ? typecheck : object); 5289 SetOperandAt(1, typecheck != NULL ? typecheck : object);
5200 5290
5201 if (FLAG_track_fields && field_representation.IsSmi()) { 5291 set_representation(Representation::Tagged());
5202 set_type(HType::Smi()); 5292 access.SetGVNFlags(this, false);
5203 set_representation(Representation::Tagged());
5204 } else if (FLAG_track_double_fields && field_representation.IsDouble()) {
5205 set_representation(field_representation);
5206 } else {
5207 set_representation(Representation::Tagged());
5208 }
5209 SetFlag(kUseGVN);
5210 SetGVNFlag(kDependsOnMaps);
5211 if (is_in_object) {
5212 SetGVNFlag(kDependsOnInobjectFields);
5213 } else {
5214 SetGVNFlag(kDependsOnBackingStoreFields);
5215 }
5216 }
5217
5218 static HLoadNamedField* NewArrayLength(Zone* zone, HValue* object,
5219 HValue* typecheck,
5220 HType type = HType::Tagged()) {
5221 Representation representation =
5222 type.IsSmi() ? Representation::Smi() : Representation::Tagged();
5223 HLoadNamedField* result = new(zone) HLoadNamedField(
5224 object, true, representation, JSArray::kLengthOffset, typecheck);
5225 result->set_type(type);
5226 result->SetGVNFlag(kDependsOnArrayLengths);
5227 result->ClearGVNFlag(kDependsOnInobjectFields);
5228 return result;
5229 } 5293 }
5230 5294
5231 HValue* object() { return OperandAt(0); } 5295 HValue* object() { return OperandAt(0); }
5232 HValue* typecheck() { 5296 HValue* typecheck() {
5233 ASSERT(HasTypeCheck()); 5297 ASSERT(HasTypeCheck());
5234 return OperandAt(1); 5298 return OperandAt(1);
5235 } 5299 }
5236 5300
5237 bool HasTypeCheck() const { return OperandAt(0) != OperandAt(1); } 5301 bool HasTypeCheck() const { return OperandAt(0) != OperandAt(1); }
5238 bool is_in_object() const { return is_in_object_; } 5302 bool is_in_object() const { return access_.IsInobject(); }
5239 Representation field_representation() const { return representation_; } 5303 Representation field_representation() const { return representation_; }
5240 int offset() const { return offset_; } 5304 int offset() const { return access_.offset(); }
5241 5305
5242 virtual Representation RequiredInputRepresentation(int index) { 5306 virtual Representation RequiredInputRepresentation(int index) {
5243 return Representation::Tagged(); 5307 return Representation::Tagged();
5244 } 5308 }
5245 virtual void PrintDataTo(StringStream* stream); 5309 virtual void PrintDataTo(StringStream* stream);
5246 5310
5247 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField) 5311 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField)
5248 5312
5249 protected: 5313 protected:
5250 virtual bool DataEquals(HValue* other) { 5314 virtual bool DataEquals(HValue* other) {
5251 HLoadNamedField* b = HLoadNamedField::cast(other); 5315 HLoadNamedField* b = HLoadNamedField::cast(other);
5252 return is_in_object_ == b->is_in_object_ && offset_ == b->offset_; 5316 return is_in_object() == b->is_in_object() && offset() == b->offset();
5253 } 5317 }
5254 5318
5255 private: 5319 private:
5256 virtual bool IsDeletable() const { return true; } 5320 virtual bool IsDeletable() const { return true; }
5257 5321
5258 bool is_in_object_; 5322 HObjectAccess access_;
5259 Representation field_representation_; 5323 Representation field_representation_;
5260 int offset_;
5261 }; 5324 };
5262 5325
5263 5326
5264 class HLoadNamedFieldPolymorphic: public HTemplateInstruction<2> { 5327 class HLoadNamedFieldPolymorphic: public HTemplateInstruction<2> {
5265 public: 5328 public:
5266 HLoadNamedFieldPolymorphic(HValue* context, 5329 HLoadNamedFieldPolymorphic(HValue* context,
5267 HValue* object, 5330 HValue* object,
5268 SmallMapList* types, 5331 SmallMapList* types,
5269 Handle<String> name, 5332 Handle<String> name,
5270 Zone* zone); 5333 Zone* zone);
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
5544 5607
5545 virtual HValue* Canonicalize(); 5608 virtual HValue* Canonicalize();
5546 5609
5547 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric) 5610 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric)
5548 }; 5611 };
5549 5612
5550 5613
5551 class HStoreNamedField: public HTemplateInstruction<2> { 5614 class HStoreNamedField: public HTemplateInstruction<2> {
5552 public: 5615 public:
5553 HStoreNamedField(HValue* obj, 5616 HStoreNamedField(HValue* obj,
5554 Handle<String> name, 5617 HObjectAccess access,
5555 HValue* val, 5618 HValue* val,
5556 bool in_object, 5619 Representation representation = Representation::Tagged())
5557 Representation field_representation, 5620 : access_(access),
5558 int offset) 5621 field_representation_(representation),
5559 : name_(name),
5560 is_in_object_(in_object),
5561 field_representation_(field_representation),
5562 offset_(offset),
5563 transition_unique_id_(), 5622 transition_unique_id_(),
5564 new_space_dominator_(NULL) { 5623 new_space_dominator_(NULL) {
5565 SetOperandAt(0, obj); 5624 SetOperandAt(0, obj);
5566 SetOperandAt(1, val); 5625 SetOperandAt(1, val);
5567 SetFlag(kTrackSideEffectDominators); 5626 access.SetGVNFlags(this, true);
5568 SetGVNFlag(kDependsOnNewSpacePromotion);
5569 if (is_in_object_) {
5570 SetGVNFlag(kChangesInobjectFields);
5571 } else {
5572 SetGVNFlag(kChangesBackingStoreFields);
5573 }
5574 } 5627 }
5575 5628
5576 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField) 5629 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField)
5577 5630
5578 virtual Representation RequiredInputRepresentation(int index) { 5631 virtual Representation RequiredInputRepresentation(int index) {
5579 if (FLAG_track_fields && index == 1 && field_representation_.IsSmi()) { 5632 if (FLAG_track_fields && index == 1 && field_representation_.IsSmi()) {
5580 return Representation::Integer32(); 5633 return Representation::Integer32();
5581 } 5634 }
5582 return Representation::Tagged(); 5635 return Representation::Tagged();
5583 } 5636 }
5584 virtual void SetSideEffectDominator(GVNFlag side_effect, HValue* dominator) { 5637 virtual void SetSideEffectDominator(GVNFlag side_effect, HValue* dominator) {
5585 ASSERT(side_effect == kChangesNewSpacePromotion); 5638 ASSERT(side_effect == kChangesNewSpacePromotion);
5586 new_space_dominator_ = dominator; 5639 new_space_dominator_ = dominator;
5587 } 5640 }
5588 virtual void PrintDataTo(StringStream* stream); 5641 virtual void PrintDataTo(StringStream* stream);
5589 5642
5590 HValue* object() { return OperandAt(0); } 5643 HValue* object() { return OperandAt(0); }
5591 HValue* value() { return OperandAt(1); } 5644 HValue* value() { return OperandAt(1); }
5592 5645
5593 Handle<String> name() const { return name_; } 5646 Handle<String> name() const { return access_.name(); }
5594 bool is_in_object() const { return is_in_object_; } 5647 bool is_in_object() const { return access_.IsInobject(); }
5595 int offset() const { return offset_; } 5648 int offset() const { return access_.offset(); }
5596 Handle<Map> transition() const { return transition_; } 5649 Handle<Map> transition() const { return transition_; }
5597 UniqueValueId transition_unique_id() const { return transition_unique_id_; } 5650 UniqueValueId transition_unique_id() const { return transition_unique_id_; }
5598 void set_transition(Handle<Map> map) { transition_ = map; } 5651 void set_transition(Handle<Map> map) { transition_ = map; }
5599 HValue* new_space_dominator() const { return new_space_dominator_; } 5652 HValue* new_space_dominator() const { return new_space_dominator_; }
5600 5653
5601 bool NeedsWriteBarrier() { 5654 bool NeedsWriteBarrier() {
5602 return (!FLAG_track_fields || !field_representation_.IsSmi()) && 5655 return (!FLAG_track_fields || !field_representation_.IsSmi()) &&
5603 StoringValueNeedsWriteBarrier(value()) && 5656 StoringValueNeedsWriteBarrier(value()) &&
5604 ReceiverObjectNeedsWriteBarrier(object(), new_space_dominator()); 5657 ReceiverObjectNeedsWriteBarrier(object(), new_space_dominator());
5605 } 5658 }
5606 5659
5607 bool NeedsWriteBarrierForMap() { 5660 bool NeedsWriteBarrierForMap() {
5608 return ReceiverObjectNeedsWriteBarrier(object(), new_space_dominator()); 5661 return ReceiverObjectNeedsWriteBarrier(object(), new_space_dominator());
5609 } 5662 }
5610 5663
5611 virtual void FinalizeUniqueValueId() { 5664 virtual void FinalizeUniqueValueId() {
5612 transition_unique_id_ = UniqueValueId(transition_); 5665 transition_unique_id_ = UniqueValueId(transition_);
5613 } 5666 }
5614 5667
5615 Representation field_representation() const { 5668 Representation field_representation() const {
5616 return field_representation_; 5669 return field_representation_;
5617 } 5670 }
5618 5671
5619 private: 5672 private:
5620 Handle<String> name_; 5673 HObjectAccess access_;
5621 bool is_in_object_;
5622 Representation field_representation_; 5674 Representation field_representation_;
5623 int offset_;
5624 Handle<Map> transition_; 5675 Handle<Map> transition_;
5625 UniqueValueId transition_unique_id_; 5676 UniqueValueId transition_unique_id_;
5626 HValue* new_space_dominator_; 5677 HValue* new_space_dominator_;
5627 }; 5678 };
5628 5679
5629 5680
5630 class HStoreNamedGeneric: public HTemplateInstruction<3> { 5681 class HStoreNamedGeneric: public HTemplateInstruction<3> {
5631 public: 5682 public:
5632 HStoreNamedGeneric(HValue* context, 5683 HStoreNamedGeneric(HValue* context,
5633 HValue* object, 5684 HValue* object,
(...skipping 888 matching lines...) Expand 10 before | Expand all | Expand 10 after
6522 virtual bool IsDeletable() const { return true; } 6573 virtual bool IsDeletable() const { return true; }
6523 }; 6574 };
6524 6575
6525 6576
6526 #undef DECLARE_INSTRUCTION 6577 #undef DECLARE_INSTRUCTION
6527 #undef DECLARE_CONCRETE_INSTRUCTION 6578 #undef DECLARE_CONCRETE_INSTRUCTION
6528 6579
6529 } } // namespace v8::internal 6580 } } // namespace v8::internal
6530 6581
6531 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ 6582 #endif // V8_HYDROGEN_INSTRUCTIONS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698