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

Side by Side Diff: src/property-details.h

Issue 14146005: Track representations of fields (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Make double support consistent. Now DOUBLE always contains smi or heapnumber Created 7 years, 8 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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 CALLBACKS = 3, 69 CALLBACKS = 3,
70 // Only in lookup results, not in descriptors. 70 // Only in lookup results, not in descriptors.
71 HANDLER = 4, 71 HANDLER = 4,
72 INTERCEPTOR = 5, 72 INTERCEPTOR = 5,
73 TRANSITION = 6, 73 TRANSITION = 6,
74 // Only used as a marker in LookupResult. 74 // Only used as a marker in LookupResult.
75 NONEXISTENT = 7 75 NONEXISTENT = 7
76 }; 76 };
77 77
78 78
79 enum StorageType {
80 TAGGED = 0,
81 SMI = 1,
82 DOUBLE = 2,
83 ANY = 3
84 };
85
86
87 inline bool IsMoreGeneralStorageType(StorageType first, StorageType second) {
88 ASSERT(second != ANY);
89 if (first == ANY) return false;
90 if (second == TAGGED) return false;
91 if (first == DOUBLE) return second == SMI;
92 return first != SMI;
93 }
94
95
79 // PropertyDetails captures type and attributes for a property. 96 // PropertyDetails captures type and attributes for a property.
80 // They are used both in property dictionaries and instance descriptors. 97 // They are used both in property dictionaries and instance descriptors.
81 class PropertyDetails BASE_EMBEDDED { 98 class PropertyDetails BASE_EMBEDDED {
82 public: 99 public:
83 PropertyDetails(PropertyAttributes attributes, 100 PropertyDetails(PropertyAttributes attributes,
84 PropertyType type, 101 PropertyType type,
85 int index = 0) { 102 int index = 0) {
86 value_ = TypeField::encode(type) 103 value_ = TypeField::encode(type)
104 | StorageTypeField::encode(TAGGED)
87 | AttributesField::encode(attributes) 105 | AttributesField::encode(attributes)
88 | DictionaryStorageField::encode(index); 106 | DictionaryStorageField::encode(index);
89 107
90 ASSERT(type == this->type()); 108 ASSERT(type == this->type());
91 ASSERT(attributes == this->attributes()); 109 ASSERT(attributes == this->attributes());
92 ASSERT(index == this->dictionary_index()); 110 ASSERT(index == this->dictionary_index());
93 } 111 }
94 112
95 int pointer() { return DescriptorPointer::decode(value_); } 113 int pointer() { return DescriptorPointer::decode(value_); }
96 114
97 PropertyDetails set_pointer(int i) { return PropertyDetails(value_, i); } 115 PropertyDetails set_pointer(int i) { return PropertyDetails(value_, i); }
98 116
117 PropertyDetails set_storage_type(StorageType storage) {
118 return PropertyDetails(value_, storage);
119 }
120
99 // Conversion for storing details as Object*. 121 // Conversion for storing details as Object*.
100 explicit inline PropertyDetails(Smi* smi); 122 explicit inline PropertyDetails(Smi* smi);
101 inline Smi* AsSmi(); 123 inline Smi* AsSmi();
102 124
103 PropertyType type() { return TypeField::decode(value_); } 125 PropertyType type() { return TypeField::decode(value_); }
104 126
105 PropertyAttributes attributes() const { 127 PropertyAttributes attributes() const {
106 return AttributesField::decode(value_); 128 return AttributesField::decode(value_);
107 } 129 }
108 130
109 int dictionary_index() { 131 int dictionary_index() {
110 return DictionaryStorageField::decode(value_); 132 return DictionaryStorageField::decode(value_);
111 } 133 }
112 134
113 int descriptor_index() { 135 int descriptor_index() {
114 return DescriptorStorageField::decode(value_); 136 return DescriptorStorageField::decode(value_);
115 } 137 }
116 138
139 StorageType storage_type() {
140 return StorageTypeField::decode(value_);
141 }
142
117 inline PropertyDetails AsDeleted(); 143 inline PropertyDetails AsDeleted();
118 144
119 static bool IsValidIndex(int index) { 145 static bool IsValidIndex(int index) {
120 return DictionaryStorageField::is_valid(index); 146 return DictionaryStorageField::is_valid(index);
121 } 147 }
122 148
123 bool IsReadOnly() const { return (attributes() & READ_ONLY) != 0; } 149 bool IsReadOnly() const { return (attributes() & READ_ONLY) != 0; }
124 bool IsDontDelete() const { return (attributes() & DONT_DELETE) != 0; } 150 bool IsDontDelete() const { return (attributes() & DONT_DELETE) != 0; }
125 bool IsDontEnum() const { return (attributes() & DONT_ENUM) != 0; } 151 bool IsDontEnum() const { return (attributes() & DONT_ENUM) != 0; }
126 bool IsDeleted() const { return DeletedField::decode(value_) != 0;} 152 bool IsDeleted() const { return DeletedField::decode(value_) != 0;}
127 153
128 // Bit fields in value_ (type, shift, size). Must be public so the 154 // Bit fields in value_ (type, shift, size). Must be public so the
129 // constants can be embedded in generated code. 155 // constants can be embedded in generated code.
130 class TypeField: public BitField<PropertyType, 0, 3> {}; 156 class TypeField: public BitField<PropertyType, 0, 3> {};
131 class AttributesField: public BitField<PropertyAttributes, 3, 3> {}; 157 class AttributesField: public BitField<PropertyAttributes, 3, 3> {};
132 class DeletedField: public BitField<uint32_t, 6, 1> {}; 158 class DeletedField: public BitField<uint32_t, 6, 1> {};
133 class DictionaryStorageField: public BitField<uint32_t, 7, 24> {}; 159 class DictionaryStorageField: public BitField<uint32_t, 7, 24> {};
134 class DescriptorStorageField: public BitField<uint32_t, 7, 11> {}; 160 class DescriptorStorageField: public BitField<uint32_t, 7, 11> {};
135 class DescriptorPointer: public BitField<uint32_t, 18, 11> {}; 161 class DescriptorPointer: public BitField<uint32_t, 18, 11> {};
162 class StorageTypeField: public BitField<StorageType, 29, 2> {};
136 163
137 static const int kInitialIndex = 1; 164 static const int kInitialIndex = 1;
138 165
139 private: 166 private:
140 PropertyDetails(int value, int pointer) { 167 PropertyDetails(int value, int pointer) {
141 value_ = DescriptorPointer::update(value, pointer); 168 value_ = DescriptorPointer::update(value, pointer);
169 }
170 PropertyDetails(int value, StorageType storage) {
171 value_ = StorageTypeField::update(value, storage);
142 } 172 }
143 173
144 uint32_t value_; 174 uint32_t value_;
145 }; 175 };
146 176
147 } } // namespace v8::internal 177 } } // namespace v8::internal
148 178
149 #endif // V8_PROPERTY_DETAILS_H_ 179 #endif // V8_PROPERTY_DETAILS_H_
OLDNEW
« src/objects.cc ('K') | « src/property.h ('k') | src/runtime.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698