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

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

Issue 23241027: Avoid setting / depending on flags when transitioning, and when fields are known to be constant. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fix size. Created 7 years, 3 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 5402 matching lines...) Expand 10 before | Expand all | Expand 10 after
5413 5413
5414 int slot_index_; 5414 int slot_index_;
5415 Mode mode_; 5415 Mode mode_;
5416 }; 5416 };
5417 5417
5418 5418
5419 // Represents an access to a portion of an object, such as the map pointer, 5419 // Represents an access to a portion of an object, such as the map pointer,
5420 // array elements pointer, etc, but not accesses to array elements themselves. 5420 // array elements pointer, etc, but not accesses to array elements themselves.
5421 class HObjectAccess V8_FINAL { 5421 class HObjectAccess V8_FINAL {
5422 public: 5422 public:
5423 // Indicates whether the field is initialized while transitioning, or also
5424 // mutable afterwards. Transitioning stores only initialize new fields rather
5425 // than changing existing fields, so they are marked as CONSTANT.
5426 enum FieldType { MUTABLE, CONSTANT };
5427
5423 inline bool IsInobject() const { 5428 inline bool IsInobject() const {
5424 return portion() != kBackingStore && portion() != kExternalMemory; 5429 return portion() != kBackingStore && portion() != kExternalMemory;
5425 } 5430 }
5426 5431
5427 inline bool IsExternalMemory() const { 5432 inline bool IsExternalMemory() const {
5428 return portion() == kExternalMemory; 5433 return portion() == kExternalMemory;
5429 } 5434 }
5430 5435
5431 inline bool IsStringLength() const { 5436 inline bool IsStringLength() const {
5432 return portion() == kStringLengths; 5437 return portion() == kStringLengths;
5433 } 5438 }
5434 5439
5435 inline int offset() const { 5440 inline int offset() const {
5436 return OffsetField::decode(value_); 5441 return OffsetField::decode(value_);
5437 } 5442 }
5438 5443
5439 inline Representation representation() const { 5444 inline Representation representation() const {
5440 return Representation::FromKind(RepresentationField::decode(value_)); 5445 return Representation::FromKind(RepresentationField::decode(value_));
5441 } 5446 }
5442 5447
5443 inline Handle<String> name() const { 5448 inline Handle<String> name() const {
5444 return name_; 5449 return name_;
5445 } 5450 }
5446 5451
5447 inline HObjectAccess WithRepresentation(Representation representation) { 5452 inline HObjectAccess WithRepresentation(Representation representation,
5448 return HObjectAccess(portion(), offset(), representation, name()); 5453 FieldType field_type = MUTABLE) {
5454 return HObjectAccess(
5455 portion(), offset(), representation, name(), field_type);
5449 } 5456 }
5450 5457
5451 static HObjectAccess ForHeapNumberValue() { 5458 static HObjectAccess ForHeapNumberValue() {
5452 return HObjectAccess( 5459 return HObjectAccess(
5453 kDouble, HeapNumber::kValueOffset, Representation::Double()); 5460 kDouble, HeapNumber::kValueOffset, Representation::Double());
5454 } 5461 }
5455 5462
5456 static HObjectAccess ForElementsPointer() { 5463 static HObjectAccess ForElementsPointer() {
5457 return HObjectAccess(kElementsPointer, JSObject::kElementsOffset); 5464 return HObjectAccess(kElementsPointer, JSObject::kElementsOffset);
5458 } 5465 }
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
5559 kStringLengths, // the length of a string 5566 kStringLengths, // the length of a string
5560 kElementsPointer, // elements pointer 5567 kElementsPointer, // elements pointer
5561 kBackingStore, // some field in the backing store 5568 kBackingStore, // some field in the backing store
5562 kDouble, // some double field 5569 kDouble, // some double field
5563 kInobject, // some other in-object field 5570 kInobject, // some other in-object field
5564 kExternalMemory // some field in external memory 5571 kExternalMemory // some field in external memory
5565 }; 5572 };
5566 5573
5567 HObjectAccess(Portion portion, int offset, 5574 HObjectAccess(Portion portion, int offset,
5568 Representation representation = Representation::Tagged(), 5575 Representation representation = Representation::Tagged(),
5569 Handle<String> name = Handle<String>::null()) 5576 Handle<String> name = Handle<String>::null(),
5577 FieldType field_type = MUTABLE)
5570 : value_(PortionField::encode(portion) | 5578 : value_(PortionField::encode(portion) |
5571 RepresentationField::encode(representation.kind()) | 5579 RepresentationField::encode(representation.kind()) |
5572 OffsetField::encode(offset)), 5580 FieldTypeField::encode(field_type) |
5581 OffsetField::encode(offset)),
5573 name_(name) { 5582 name_(name) {
5574 // assert that the fields decode correctly 5583 // assert that the fields decode correctly
5575 ASSERT(this->offset() == offset); 5584 ASSERT(this->offset() == offset);
5576 ASSERT(this->portion() == portion); 5585 ASSERT(this->portion() == portion);
5577 ASSERT(RepresentationField::decode(value_) == representation.kind()); 5586 ASSERT(RepresentationField::decode(value_) == representation.kind());
5578 } 5587 }
5579 5588
5580 class PortionField : public BitField<Portion, 0, 3> {}; 5589 class PortionField : public BitField<Portion, 0, 3> {};
5581 class RepresentationField : public BitField<Representation::Kind, 3, 3> {}; 5590 class RepresentationField : public BitField<Representation::Kind, 3, 3> {};
5582 class OffsetField : public BitField<int, 6, 26> {}; 5591 class FieldTypeField : public BitField<FieldType, 6, 1> {};
5592 class OffsetField : public BitField<int, 7, 25> {};
5583 5593
5584 uint32_t value_; // encodes portion, representation, and offset 5594 uint32_t value_; // encodes portion, representation, and offset
5585 Handle<String> name_; 5595 Handle<String> name_;
5586 5596
5587 friend class HLoadNamedField; 5597 friend class HLoadNamedField;
5588 friend class HStoreNamedField; 5598 friend class HStoreNamedField;
5589 5599
5590 inline Portion portion() const { 5600 inline Portion portion() const {
5591 return PortionField::decode(value_); 5601 return PortionField::decode(value_);
5592 } 5602 }
(...skipping 1199 matching lines...) Expand 10 before | Expand all | Expand 10 after
6792 virtual bool IsDeletable() const V8_OVERRIDE { return true; } 6802 virtual bool IsDeletable() const V8_OVERRIDE { return true; }
6793 }; 6803 };
6794 6804
6795 6805
6796 #undef DECLARE_INSTRUCTION 6806 #undef DECLARE_INSTRUCTION
6797 #undef DECLARE_CONCRETE_INSTRUCTION 6807 #undef DECLARE_CONCRETE_INSTRUCTION
6798 6808
6799 } } // namespace v8::internal 6809 } } // namespace v8::internal
6800 6810
6801 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ 6811 #endif // V8_HYDROGEN_INSTRUCTIONS_H_
OLDNEW
« no previous file with comments | « src/hydrogen.cc ('k') | src/hydrogen-instructions.cc » ('j') | src/hydrogen-instructions.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698