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

Unified Diff: src/property-details.h

Issue 2591233002: [runtime] Add PropertyConstness bit to PropertyDetails. (Closed)
Patch Set: Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: src/property-details.h
diff --git a/src/property-details.h b/src/property-details.h
index d616ae76e164c1768d8cd35b2ae7a4603e760f27..143d210a94d8938693b6af2e483cd2a756fdbbcb 100644
--- a/src/property-details.h
+++ b/src/property-details.h
@@ -72,6 +72,10 @@ enum PropertyKind { kData = 0, kAccessor = 1 };
// Must fit in the BitField PropertyDetails::LocationField.
enum PropertyLocation { kField = 0, kDescriptor = 1 };
+// Order of modes is significant.
+// Must fit in the BitField PropertyDetails::ConstnessField.
+enum PropertyConstness { kMutable = 0, kConst = 1 };
+
class Representation {
public:
enum Kind {
@@ -231,10 +235,11 @@ class PropertyDetails BASE_EMBEDDED {
// Property details for fast mode properties.
PropertyDetails(PropertyKind kind, PropertyAttributes attributes,
- PropertyLocation location, Representation representation,
- int field_index = 0) {
- value_ = KindField::encode(kind) | LocationField::encode(location) |
- AttributesField::encode(attributes) |
+ PropertyLocation location, PropertyConstness constness,
+ Representation representation, int field_index = 0) {
+ value_ = KindField::encode(kind) | AttributesField::encode(attributes) |
+ LocationField::encode(location) |
+ ConstnessField::encode(constness) |
RepresentationField::encode(EncodeRepresentation(representation)) |
FieldIndexField::encode(field_index);
}
@@ -285,6 +290,7 @@ class PropertyDetails BASE_EMBEDDED {
PropertyKind kind() const { return KindField::decode(value_); }
PropertyLocation location() const { return LocationField::decode(value_); }
+ PropertyConstness constness() const { return ConstnessField::decode(value_); }
PropertyAttributes attributes() const {
return AttributesField::decode(value_);
@@ -317,22 +323,30 @@ class PropertyDetails BASE_EMBEDDED {
// Bit fields in value_ (type, shift, size). Must be public so the
// constants can be embedded in generated code.
class KindField : public BitField<PropertyKind, 0, 1> {};
- class LocationField : public BitField<PropertyLocation, 1, 1> {};
- class AttributesField : public BitField<PropertyAttributes, 2, 3> {};
+ class LocationField : public BitField<PropertyLocation, KindField::kNext, 1> {
+ };
+ class ConstnessField
+ : public BitField<PropertyConstness, LocationField::kNext, 1> {};
+ class AttributesField
+ : public BitField<PropertyAttributes, ConstnessField::kNext, 3> {};
static const int kAttributesReadOnlyMask =
(READ_ONLY << AttributesField::kShift);
// Bit fields for normalized objects.
- class PropertyCellTypeField : public BitField<PropertyCellType, 5, 2> {};
- class DictionaryStorageField : public BitField<uint32_t, 7, 24> {};
+ class PropertyCellTypeField
+ : public BitField<PropertyCellType, AttributesField::kNext, 2> {};
+ class DictionaryStorageField
+ : public BitField<uint32_t, PropertyCellTypeField::kNext, 23> {};
// Bit fields for fast objects.
- class RepresentationField : public BitField<uint32_t, 5, 4> {};
+ class RepresentationField
+ : public BitField<uint32_t, AttributesField::kNext, 4> {};
class DescriptorPointer
- : public BitField<uint32_t, 9, kDescriptorIndexBitCount> {}; // NOLINT
- class FieldIndexField
- : public BitField<uint32_t, 9 + kDescriptorIndexBitCount,
+ : public BitField<uint32_t, RepresentationField::kNext,
kDescriptorIndexBitCount> {}; // NOLINT
+ class FieldIndexField : public BitField<uint32_t, DescriptorPointer::kNext,
+ kDescriptorIndexBitCount> {
+ }; // NOLINT
// All bits for both fast and slow objects must fit in a smi.
STATIC_ASSERT(DictionaryStorageField::kNext <= 31);
@@ -373,6 +387,18 @@ class PropertyDetails BASE_EMBEDDED {
uint32_t value_;
};
+inline bool LocationFitsInto(PropertyLocation what, PropertyLocation where) {
Toon Verwaest 2017/01/18 12:04:05 Maybe LocationIsMoreGeneralThan? That fits the Gen
Igor Sheludko 2017/01/18 14:06:43 Done.
+ return where == kField || what == kDescriptor;
Toon Verwaest 2017/01/18 12:04:05 // Everything fits in a field, and a descriptor on
Igor Sheludko 2017/01/18 14:06:43 Done.
+}
+
+inline bool ConstnessFitsInto(PropertyConstness what, PropertyConstness where) {
+ return where == kMutable || what == kConst;
+}
+
+inline PropertyConstness GeneralizeConstness(PropertyConstness c1,
+ PropertyConstness c2) {
+ return c1 == kMutable ? kMutable : c2;
+}
std::ostream& operator<<(std::ostream& os,
const PropertyAttributes& attributes);

Powered by Google App Engine
This is Rietveld 408576698