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

Side by Side Diff: src/objects.h

Issue 8017003: Cache multiple ElementsKind map transition per map. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: review feedback Created 9 years, 2 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/mark-compact.cc ('k') | src/objects.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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 static const int kElementsKindCount = 173 static const int kElementsKindCount =
174 LAST_ELEMENTS_KIND - FIRST_ELEMENTS_KIND + 1; 174 LAST_ELEMENTS_KIND - FIRST_ELEMENTS_KIND + 1;
175 175
176 // PropertyDetails captures type and attributes for a property. 176 // PropertyDetails captures type and attributes for a property.
177 // They are used both in property dictionaries and instance descriptors. 177 // They are used both in property dictionaries and instance descriptors.
178 class PropertyDetails BASE_EMBEDDED { 178 class PropertyDetails BASE_EMBEDDED {
179 public: 179 public:
180 PropertyDetails(PropertyAttributes attributes, 180 PropertyDetails(PropertyAttributes attributes,
181 PropertyType type, 181 PropertyType type,
182 int index = 0) { 182 int index = 0) {
183 ASSERT(type != ELEMENTS_TRANSITION);
184 ASSERT(TypeField::is_valid(type)); 183 ASSERT(TypeField::is_valid(type));
185 ASSERT(AttributesField::is_valid(attributes)); 184 ASSERT(AttributesField::is_valid(attributes));
186 ASSERT(StorageField::is_valid(index)); 185 ASSERT(StorageField::is_valid(index));
187 186
188 value_ = TypeField::encode(type) 187 value_ = TypeField::encode(type)
189 | AttributesField::encode(attributes) 188 | AttributesField::encode(attributes)
190 | StorageField::encode(index); 189 | StorageField::encode(index);
191 190
192 ASSERT(type == this->type()); 191 ASSERT(type == this->type());
193 ASSERT(attributes == this->attributes()); 192 ASSERT(attributes == this->attributes());
194 ASSERT(index == this->index()); 193 ASSERT(index == this->index());
195 } 194 }
196 195
197 PropertyDetails(PropertyAttributes attributes,
198 PropertyType type,
199 ElementsKind elements_kind) {
200 ASSERT(type == ELEMENTS_TRANSITION);
201 ASSERT(TypeField::is_valid(type));
202 ASSERT(AttributesField::is_valid(attributes));
203 ASSERT(StorageField::is_valid(static_cast<int>(elements_kind)));
204
205 value_ = TypeField::encode(type)
206 | AttributesField::encode(attributes)
207 | StorageField::encode(static_cast<int>(elements_kind));
208
209 ASSERT(type == this->type());
210 ASSERT(attributes == this->attributes());
211 ASSERT(elements_kind == this->elements_kind());
212 }
213
214 // Conversion for storing details as Object*. 196 // Conversion for storing details as Object*.
215 explicit inline PropertyDetails(Smi* smi); 197 explicit inline PropertyDetails(Smi* smi);
216 inline Smi* AsSmi(); 198 inline Smi* AsSmi();
217 199
218 PropertyType type() { return TypeField::decode(value_); } 200 PropertyType type() { return TypeField::decode(value_); }
219 201
220 bool IsTransition() { 202 bool IsTransition() {
221 PropertyType t = type(); 203 PropertyType t = type();
222 ASSERT(t != INTERCEPTOR); 204 ASSERT(t != INTERCEPTOR);
223 return t == MAP_TRANSITION || t == CONSTANT_TRANSITION || 205 return t == MAP_TRANSITION || t == CONSTANT_TRANSITION ||
224 t == ELEMENTS_TRANSITION; 206 t == ELEMENTS_TRANSITION;
225 } 207 }
226 208
227 bool IsProperty() { 209 bool IsProperty() {
228 return type() < FIRST_PHANTOM_PROPERTY_TYPE; 210 return type() < FIRST_PHANTOM_PROPERTY_TYPE;
229 } 211 }
230 212
231 PropertyAttributes attributes() { return AttributesField::decode(value_); } 213 PropertyAttributes attributes() { return AttributesField::decode(value_); }
232 214
233 int index() { return StorageField::decode(value_); } 215 int index() { return StorageField::decode(value_); }
234 216
235 ElementsKind elements_kind() {
236 ASSERT(type() == ELEMENTS_TRANSITION);
237 return static_cast<ElementsKind>(StorageField::decode(value_));
238 }
239
240 inline PropertyDetails AsDeleted(); 217 inline PropertyDetails AsDeleted();
241 218
242 static bool IsValidIndex(int index) { 219 static bool IsValidIndex(int index) {
243 return StorageField::is_valid(index); 220 return StorageField::is_valid(index);
244 } 221 }
245 222
246 bool IsReadOnly() { return (attributes() & READ_ONLY) != 0; } 223 bool IsReadOnly() { return (attributes() & READ_ONLY) != 0; }
247 bool IsDontDelete() { return (attributes() & DONT_DELETE) != 0; } 224 bool IsDontDelete() { return (attributes() & DONT_DELETE) != 0; }
248 bool IsDontEnum() { return (attributes() & DONT_ENUM) != 0; } 225 bool IsDontEnum() { return (attributes() & DONT_ENUM) != 0; }
249 bool IsDeleted() { return DeletedField::decode(value_) != 0;} 226 bool IsDeleted() { return DeletedField::decode(value_) != 0;}
(...skipping 3919 matching lines...) Expand 10 before | Expand all | Expand 10 after
4169 int IndexInCodeCache(Object* name, Code* code); 4146 int IndexInCodeCache(Object* name, Code* code);
4170 4147
4171 // Removes a code object from the code cache at the given index. 4148 // Removes a code object from the code cache at the given index.
4172 void RemoveFromCodeCache(String* name, Code* code, int index); 4149 void RemoveFromCodeCache(String* name, Code* code, int index);
4173 4150
4174 // For every transition in this map, makes the transition's 4151 // For every transition in this map, makes the transition's
4175 // target's prototype pointer point back to this map. 4152 // target's prototype pointer point back to this map.
4176 // This is undone in MarkCompactCollector::ClearNonLiveTransitions(). 4153 // This is undone in MarkCompactCollector::ClearNonLiveTransitions().
4177 void CreateBackPointers(); 4154 void CreateBackPointers();
4178 4155
4156 void CreateOneBackPointer(Map* transition_target);
4157
4179 // Set all map transitions from this map to dead maps to null. 4158 // Set all map transitions from this map to dead maps to null.
4180 // Also, restore the original prototype on the targets of these 4159 // Also, restore the original prototype on the targets of these
4181 // transitions, so that we do not process this map again while 4160 // transitions, so that we do not process this map again while
4182 // following back pointers. 4161 // following back pointers.
4183 void ClearNonLiveTransitions(Heap* heap, Object* real_prototype); 4162 void ClearNonLiveTransitions(Heap* heap, Object* real_prototype);
4184 4163
4185 // Computes a hash value for this map, to be used in HashTables and such. 4164 // Computes a hash value for this map, to be used in HashTables and such.
4186 int Hash(); 4165 int Hash();
4187 4166
4188 // Compares this map to another to see if they describe equivalent objects. 4167 // Compares this map to another to see if they describe equivalent objects.
(...skipping 3305 matching lines...) Expand 10 before | Expand all | Expand 10 after
7494 } else { 7473 } else {
7495 value &= ~(1 << bit_position); 7474 value &= ~(1 << bit_position);
7496 } 7475 }
7497 return value; 7476 return value;
7498 } 7477 }
7499 }; 7478 };
7500 7479
7501 } } // namespace v8::internal 7480 } } // namespace v8::internal
7502 7481
7503 #endif // V8_OBJECTS_H_ 7482 #endif // V8_OBJECTS_H_
OLDNEW
« no previous file with comments | « src/mark-compact.cc ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698