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

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

Issue 15941016: Move field index into property details, freeing up the value slot of fields. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments Created 7 years, 6 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/property.h ('k') | no next file » | 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 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 value_ = TypeField::encode(type) 162 value_ = TypeField::encode(type)
163 | AttributesField::encode(attributes) 163 | AttributesField::encode(attributes)
164 | DictionaryStorageField::encode(index); 164 | DictionaryStorageField::encode(index);
165 165
166 ASSERT(type == this->type()); 166 ASSERT(type == this->type());
167 ASSERT(attributes == this->attributes()); 167 ASSERT(attributes == this->attributes());
168 } 168 }
169 169
170 PropertyDetails(PropertyAttributes attributes, 170 PropertyDetails(PropertyAttributes attributes,
171 PropertyType type, 171 PropertyType type,
172 Representation representation) { 172 Representation representation,
173 int field_index = 0) {
173 value_ = TypeField::encode(type) 174 value_ = TypeField::encode(type)
174 | AttributesField::encode(attributes) 175 | AttributesField::encode(attributes)
175 | RepresentationField::encode(EncodeRepresentation(representation)); 176 | RepresentationField::encode(EncodeRepresentation(representation))
177 | FieldIndexField::encode(field_index);
176 } 178 }
177 179
178 int pointer() { return DescriptorPointer::decode(value_); } 180 int pointer() { return DescriptorPointer::decode(value_); }
179 181
180 PropertyDetails set_pointer(int i) { return PropertyDetails(value_, i); } 182 PropertyDetails set_pointer(int i) { return PropertyDetails(value_, i); }
181 183
182 PropertyDetails CopyWithRepresentation(Representation representation) { 184 PropertyDetails CopyWithRepresentation(Representation representation) {
183 return PropertyDetails(value_, representation); 185 return PropertyDetails(value_, representation);
184 } 186 }
185 PropertyDetails CopyAddAttributes(PropertyAttributes new_attributes) { 187 PropertyDetails CopyAddAttributes(PropertyAttributes new_attributes) {
(...skipping 21 matching lines...) Expand all
207 } 209 }
208 210
209 int dictionary_index() { 211 int dictionary_index() {
210 return DictionaryStorageField::decode(value_); 212 return DictionaryStorageField::decode(value_);
211 } 213 }
212 214
213 Representation representation() { 215 Representation representation() {
214 return DecodeRepresentation(RepresentationField::decode(value_)); 216 return DecodeRepresentation(RepresentationField::decode(value_));
215 } 217 }
216 218
219 int field_index() {
220 return FieldIndexField::decode(value_);
221 }
222
217 inline PropertyDetails AsDeleted(); 223 inline PropertyDetails AsDeleted();
218 224
219 static bool IsValidIndex(int index) { 225 static bool IsValidIndex(int index) {
220 return DictionaryStorageField::is_valid(index); 226 return DictionaryStorageField::is_valid(index);
221 } 227 }
222 228
223 bool IsReadOnly() const { return (attributes() & READ_ONLY) != 0; } 229 bool IsReadOnly() const { return (attributes() & READ_ONLY) != 0; }
224 bool IsDontDelete() const { return (attributes() & DONT_DELETE) != 0; } 230 bool IsDontDelete() const { return (attributes() & DONT_DELETE) != 0; }
225 bool IsDontEnum() const { return (attributes() & DONT_ENUM) != 0; } 231 bool IsDontEnum() const { return (attributes() & DONT_ENUM) != 0; }
226 bool IsDeleted() const { return DeletedField::decode(value_) != 0;} 232 bool IsDeleted() const { return DeletedField::decode(value_) != 0;}
227 233
228 // Bit fields in value_ (type, shift, size). Must be public so the 234 // Bit fields in value_ (type, shift, size). Must be public so the
229 // constants can be embedded in generated code. 235 // constants can be embedded in generated code.
230 class TypeField: public BitField<PropertyType, 0, 3> {}; 236 class TypeField: public BitField<PropertyType, 0, 3> {};
231 class AttributesField: public BitField<PropertyAttributes, 3, 3> {}; 237 class AttributesField: public BitField<PropertyAttributes, 3, 3> {};
238
239 // Bit fields for normalized objects.
232 class DeletedField: public BitField<uint32_t, 6, 1> {}; 240 class DeletedField: public BitField<uint32_t, 6, 1> {};
233 class DictionaryStorageField: public BitField<uint32_t, 7, 24> {}; 241 class DictionaryStorageField: public BitField<uint32_t, 7, 24> {};
234 class DescriptorPointer: public BitField<uint32_t, 7, 11> {}; 242
235 class RepresentationField: public BitField<uint32_t, 18, 3> {}; 243 // Bit fields for fast objects.
244 class DescriptorPointer: public BitField<uint32_t, 6, 11> {};
245 class RepresentationField: public BitField<uint32_t, 17, 3> {};
246 class FieldIndexField: public BitField<uint32_t, 20, 11> {};
236 247
237 static const int kInitialIndex = 1; 248 static const int kInitialIndex = 1;
238 249
239 private: 250 private:
240 PropertyDetails(int value, int pointer) { 251 PropertyDetails(int value, int pointer) {
241 value_ = DescriptorPointer::update(value, pointer); 252 value_ = DescriptorPointer::update(value, pointer);
242 } 253 }
243 PropertyDetails(int value, Representation representation) { 254 PropertyDetails(int value, Representation representation) {
244 value_ = RepresentationField::update( 255 value_ = RepresentationField::update(
245 value, EncodeRepresentation(representation)); 256 value, EncodeRepresentation(representation));
246 } 257 }
247 PropertyDetails(int value, PropertyAttributes attributes) { 258 PropertyDetails(int value, PropertyAttributes attributes) {
248 value_ = AttributesField::update(value, attributes); 259 value_ = AttributesField::update(value, attributes);
249 } 260 }
250 261
251 uint32_t value_; 262 uint32_t value_;
252 }; 263 };
253 264
254 } } // namespace v8::internal 265 } } // namespace v8::internal
255 266
256 #endif // V8_PROPERTY_DETAILS_H_ 267 #endif // V8_PROPERTY_DETAILS_H_
OLDNEW
« no previous file with comments | « src/property.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698