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

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

Issue 14146005: Track representations of fields (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Add test for tracking fields 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
« no previous file with comments | « src/hydrogen.cc ('k') | src/hydrogen-instructions.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 bool MulAndCheckOverflow(Range* other); 297 bool MulAndCheckOverflow(Range* other);
298 298
299 private: 299 private:
300 int32_t lower_; 300 int32_t lower_;
301 int32_t upper_; 301 int32_t upper_;
302 Range* next_; 302 Range* next_;
303 bool can_be_minus_zero_; 303 bool can_be_minus_zero_;
304 }; 304 };
305 305
306 306
307 class Representation {
308 public:
309 enum Kind {
310 kNone,
311 kInteger32,
312 kDouble,
313 kTagged,
314 kExternal,
315 kNumRepresentations
316 };
317
318 Representation() : kind_(kNone) { }
319
320 static Representation None() { return Representation(kNone); }
321 static Representation Tagged() { return Representation(kTagged); }
322 static Representation Integer32() { return Representation(kInteger32); }
323 static Representation Double() { return Representation(kDouble); }
324 static Representation External() { return Representation(kExternal); }
325
326 static Representation FromKind(Kind kind) { return Representation(kind); }
327
328 bool Equals(const Representation& other) {
329 return kind_ == other.kind_;
330 }
331
332 bool is_more_general_than(const Representation& other) {
333 ASSERT(kind_ != kExternal);
334 ASSERT(other.kind_ != kExternal);
335 return kind_ > other.kind_;
336 }
337
338 Kind kind() const { return static_cast<Kind>(kind_); }
339 bool IsNone() const { return kind_ == kNone; }
340 bool IsTagged() const { return kind_ == kTagged; }
341 bool IsInteger32() const { return kind_ == kInteger32; }
342 bool IsDouble() const { return kind_ == kDouble; }
343 bool IsExternal() const { return kind_ == kExternal; }
344 bool IsSpecialization() const {
345 return kind_ == kInteger32 || kind_ == kDouble;
346 }
347 const char* Mnemonic() const;
348
349 private:
350 explicit Representation(Kind k) : kind_(k) { }
351
352 // Make sure kind fits in int8.
353 STATIC_ASSERT(kNumRepresentations <= (1 << kBitsPerByte));
354
355 int8_t kind_;
356 };
357
358
359 class UniqueValueId { 307 class UniqueValueId {
360 public: 308 public:
361 UniqueValueId() : raw_address_(NULL) { } 309 UniqueValueId() : raw_address_(NULL) { }
362 310
363 explicit UniqueValueId(Object* object) { 311 explicit UniqueValueId(Object* object) {
364 raw_address_ = reinterpret_cast<Address>(object); 312 raw_address_ = reinterpret_cast<Address>(object);
365 ASSERT(IsInitialized()); 313 ASSERT(IsInitialized());
366 } 314 }
367 315
368 explicit UniqueValueId(Handle<Object> handle) { 316 explicit UniqueValueId(Handle<Object> handle) {
(...skipping 4835 matching lines...) Expand 10 before | Expand all | Expand 10 after
5204 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot) 5152 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot)
5205 5153
5206 private: 5154 private:
5207 int slot_index_; 5155 int slot_index_;
5208 Mode mode_; 5156 Mode mode_;
5209 }; 5157 };
5210 5158
5211 5159
5212 class HLoadNamedField: public HTemplateInstruction<2> { 5160 class HLoadNamedField: public HTemplateInstruction<2> {
5213 public: 5161 public:
5214 HLoadNamedField(HValue* object, bool is_in_object, int offset, 5162 HLoadNamedField(HValue* object, bool is_in_object,
5215 HValue* typecheck = NULL) 5163 Representation field_representation,
5164 int offset, HValue* typecheck = NULL)
5216 : is_in_object_(is_in_object), 5165 : is_in_object_(is_in_object),
5166 field_representation_(field_representation),
5217 offset_(offset) { 5167 offset_(offset) {
5218 ASSERT(object != NULL); 5168 ASSERT(object != NULL);
5219 SetOperandAt(0, object); 5169 SetOperandAt(0, object);
5220 SetOperandAt(1, typecheck != NULL ? typecheck : object); 5170 SetOperandAt(1, typecheck != NULL ? typecheck : object);
5221 5171
5222 set_representation(Representation::Tagged()); 5172 if (FLAG_track_fields && field_representation.IsSmi()) {
5173 set_type(HType::Smi());
5174 set_representation(Representation::Tagged());
5175 } else if (FLAG_track_double_fields && field_representation.IsDouble()) {
5176 set_representation(field_representation);
5177 } else {
5178 set_representation(Representation::Tagged());
5179 }
5223 SetFlag(kUseGVN); 5180 SetFlag(kUseGVN);
5224 SetGVNFlag(kDependsOnMaps); 5181 SetGVNFlag(kDependsOnMaps);
5225 if (is_in_object) { 5182 if (is_in_object) {
5226 SetGVNFlag(kDependsOnInobjectFields); 5183 SetGVNFlag(kDependsOnInobjectFields);
5227 } else { 5184 } else {
5228 SetGVNFlag(kDependsOnBackingStoreFields); 5185 SetGVNFlag(kDependsOnBackingStoreFields);
5229 } 5186 }
5230 } 5187 }
5231 5188
5232 static HLoadNamedField* NewArrayLength(Zone* zone, HValue* object, 5189 static HLoadNamedField* NewArrayLength(Zone* zone, HValue* object,
5233 HValue* typecheck, 5190 HValue* typecheck,
5234 HType type = HType::Tagged()) { 5191 HType type = HType::Tagged()) {
5192 Representation representation =
5193 type.IsSmi() ? Representation::Smi() : Representation::Tagged();
5235 HLoadNamedField* result = new(zone) HLoadNamedField( 5194 HLoadNamedField* result = new(zone) HLoadNamedField(
5236 object, true, JSArray::kLengthOffset, typecheck); 5195 object, true, representation, JSArray::kLengthOffset, typecheck);
5237 result->set_type(type); 5196 result->set_type(type);
5238 result->SetGVNFlag(kDependsOnArrayLengths); 5197 result->SetGVNFlag(kDependsOnArrayLengths);
5239 result->ClearGVNFlag(kDependsOnInobjectFields); 5198 result->ClearGVNFlag(kDependsOnInobjectFields);
5240 return result; 5199 return result;
5241 } 5200 }
5242 5201
5243 HValue* object() { return OperandAt(0); } 5202 HValue* object() { return OperandAt(0); }
5244 HValue* typecheck() { 5203 HValue* typecheck() {
5245 ASSERT(HasTypeCheck()); 5204 ASSERT(HasTypeCheck());
5246 return OperandAt(1); 5205 return OperandAt(1);
5247 } 5206 }
5248 5207
5249 bool HasTypeCheck() const { return OperandAt(0) != OperandAt(1); } 5208 bool HasTypeCheck() const { return OperandAt(0) != OperandAt(1); }
5250 bool is_in_object() const { return is_in_object_; } 5209 bool is_in_object() const { return is_in_object_; }
5210 Representation field_representation() const { return representation_; }
5251 int offset() const { return offset_; } 5211 int offset() const { return offset_; }
5252 5212
5253 virtual Representation RequiredInputRepresentation(int index) { 5213 virtual Representation RequiredInputRepresentation(int index) {
5254 return Representation::Tagged(); 5214 return Representation::Tagged();
5255 } 5215 }
5256 virtual void PrintDataTo(StringStream* stream); 5216 virtual void PrintDataTo(StringStream* stream);
5257 5217
5258 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField) 5218 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField)
5259 5219
5260 protected: 5220 protected:
5261 virtual bool DataEquals(HValue* other) { 5221 virtual bool DataEquals(HValue* other) {
5262 HLoadNamedField* b = HLoadNamedField::cast(other); 5222 HLoadNamedField* b = HLoadNamedField::cast(other);
5263 return is_in_object_ == b->is_in_object_ && offset_ == b->offset_; 5223 return is_in_object_ == b->is_in_object_ && offset_ == b->offset_;
5264 } 5224 }
5265 5225
5266 private: 5226 private:
5267 virtual bool IsDeletable() const { return true; } 5227 virtual bool IsDeletable() const { return true; }
5268 5228
5269 bool is_in_object_; 5229 bool is_in_object_;
5230 Representation field_representation_;
5270 int offset_; 5231 int offset_;
5271 }; 5232 };
5272 5233
5273 5234
5274 class HLoadNamedFieldPolymorphic: public HTemplateInstruction<2> { 5235 class HLoadNamedFieldPolymorphic: public HTemplateInstruction<2> {
5275 public: 5236 public:
5276 HLoadNamedFieldPolymorphic(HValue* context, 5237 HLoadNamedFieldPolymorphic(HValue* context,
5277 HValue* object, 5238 HValue* object,
5278 SmallMapList* types, 5239 SmallMapList* types,
5279 Handle<String> name, 5240 Handle<String> name,
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
5557 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric) 5518 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric)
5558 }; 5519 };
5559 5520
5560 5521
5561 class HStoreNamedField: public HTemplateInstruction<2> { 5522 class HStoreNamedField: public HTemplateInstruction<2> {
5562 public: 5523 public:
5563 HStoreNamedField(HValue* obj, 5524 HStoreNamedField(HValue* obj,
5564 Handle<String> name, 5525 Handle<String> name,
5565 HValue* val, 5526 HValue* val,
5566 bool in_object, 5527 bool in_object,
5528 Representation field_representation,
5567 int offset) 5529 int offset)
5568 : name_(name), 5530 : name_(name),
5569 is_in_object_(in_object), 5531 is_in_object_(in_object),
5532 field_representation_(field_representation),
5570 offset_(offset), 5533 offset_(offset),
5571 transition_unique_id_(), 5534 transition_unique_id_(),
5572 new_space_dominator_(NULL) { 5535 new_space_dominator_(NULL) {
5573 SetOperandAt(0, obj); 5536 SetOperandAt(0, obj);
5574 SetOperandAt(1, val); 5537 SetOperandAt(1, val);
5575 SetFlag(kTrackSideEffectDominators); 5538 SetFlag(kTrackSideEffectDominators);
5576 SetGVNFlag(kDependsOnNewSpacePromotion); 5539 SetGVNFlag(kDependsOnNewSpacePromotion);
5577 if (is_in_object_) { 5540 if (is_in_object_) {
5578 SetGVNFlag(kChangesInobjectFields); 5541 SetGVNFlag(kChangesInobjectFields);
5579 } else { 5542 } else {
5580 SetGVNFlag(kChangesBackingStoreFields); 5543 SetGVNFlag(kChangesBackingStoreFields);
5581 } 5544 }
5582 } 5545 }
5583 5546
5584 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField) 5547 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField)
5585 5548
5586 virtual Representation RequiredInputRepresentation(int index) { 5549 virtual Representation RequiredInputRepresentation(int index) {
5550 if (FLAG_track_fields && index == 1 && field_representation_.IsSmi()) {
5551 return Representation::Integer32();
5552 }
5587 return Representation::Tagged(); 5553 return Representation::Tagged();
5588 } 5554 }
5589 virtual void SetSideEffectDominator(GVNFlag side_effect, HValue* dominator) { 5555 virtual void SetSideEffectDominator(GVNFlag side_effect, HValue* dominator) {
5590 ASSERT(side_effect == kChangesNewSpacePromotion); 5556 ASSERT(side_effect == kChangesNewSpacePromotion);
5591 new_space_dominator_ = dominator; 5557 new_space_dominator_ = dominator;
5592 } 5558 }
5593 virtual void PrintDataTo(StringStream* stream); 5559 virtual void PrintDataTo(StringStream* stream);
5594 5560
5595 HValue* object() { return OperandAt(0); } 5561 HValue* object() { return OperandAt(0); }
5596 HValue* value() { return OperandAt(1); } 5562 HValue* value() { return OperandAt(1); }
5597 5563
5598 Handle<String> name() const { return name_; } 5564 Handle<String> name() const { return name_; }
5599 bool is_in_object() const { return is_in_object_; } 5565 bool is_in_object() const { return is_in_object_; }
5600 int offset() const { return offset_; } 5566 int offset() const { return offset_; }
5601 Handle<Map> transition() const { return transition_; } 5567 Handle<Map> transition() const { return transition_; }
5602 UniqueValueId transition_unique_id() const { return transition_unique_id_; } 5568 UniqueValueId transition_unique_id() const { return transition_unique_id_; }
5603 void set_transition(Handle<Map> map) { transition_ = map; } 5569 void set_transition(Handle<Map> map) { transition_ = map; }
5604 HValue* new_space_dominator() const { return new_space_dominator_; } 5570 HValue* new_space_dominator() const { return new_space_dominator_; }
5605 5571
5606 bool NeedsWriteBarrier() { 5572 bool NeedsWriteBarrier() {
5607 return StoringValueNeedsWriteBarrier(value()) && 5573 return (!FLAG_track_fields || !field_representation_.IsSmi()) &&
5574 StoringValueNeedsWriteBarrier(value()) &&
5608 ReceiverObjectNeedsWriteBarrier(object(), new_space_dominator()); 5575 ReceiverObjectNeedsWriteBarrier(object(), new_space_dominator());
5609 } 5576 }
5610 5577
5611 bool NeedsWriteBarrierForMap() { 5578 bool NeedsWriteBarrierForMap() {
5612 return ReceiverObjectNeedsWriteBarrier(object(), new_space_dominator()); 5579 return ReceiverObjectNeedsWriteBarrier(object(), new_space_dominator());
5613 } 5580 }
5614 5581
5615 virtual void FinalizeUniqueValueId() { 5582 virtual void FinalizeUniqueValueId() {
5616 transition_unique_id_ = UniqueValueId(transition_); 5583 transition_unique_id_ = UniqueValueId(transition_);
5617 } 5584 }
5618 5585
5586 Representation field_representation() const {
5587 return field_representation_;
5588 }
5589
5619 private: 5590 private:
5620 Handle<String> name_; 5591 Handle<String> name_;
5621 bool is_in_object_; 5592 bool is_in_object_;
5593 Representation field_representation_;
5622 int offset_; 5594 int offset_;
5623 Handle<Map> transition_; 5595 Handle<Map> transition_;
5624 UniqueValueId transition_unique_id_; 5596 UniqueValueId transition_unique_id_;
5625 HValue* new_space_dominator_; 5597 HValue* new_space_dominator_;
5626 }; 5598 };
5627 5599
5628 5600
5629 class HStoreNamedGeneric: public HTemplateInstruction<3> { 5601 class HStoreNamedGeneric: public HTemplateInstruction<3> {
5630 public: 5602 public:
5631 HStoreNamedGeneric(HValue* context, 5603 HStoreNamedGeneric(HValue* context,
(...skipping 859 matching lines...) Expand 10 before | Expand all | Expand 10 after
6491 virtual bool IsDeletable() const { return true; } 6463 virtual bool IsDeletable() const { return true; }
6492 }; 6464 };
6493 6465
6494 6466
6495 #undef DECLARE_INSTRUCTION 6467 #undef DECLARE_INSTRUCTION
6496 #undef DECLARE_CONCRETE_INSTRUCTION 6468 #undef DECLARE_CONCRETE_INSTRUCTION
6497 6469
6498 } } // namespace v8::internal 6470 } } // namespace v8::internal
6499 6471
6500 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ 6472 #endif // V8_HYDROGEN_INSTRUCTIONS_H_
OLDNEW
« no previous file with comments | « src/hydrogen.cc ('k') | src/hydrogen-instructions.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698