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

Side by Side Diff: src/objects.h

Issue 6528: This change rewrites some of the code to add properties to an object.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 12 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 | « no previous file | 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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 1285 matching lines...) Expand 10 before | Expand all | Expand 10 after
1296 // Add a constant function property to a fast-case object. 1296 // Add a constant function property to a fast-case object.
1297 // This leaves a CONSTANT_TRANSITION in the old map, and 1297 // This leaves a CONSTANT_TRANSITION in the old map, and
1298 // if it is called on a second object with this map, a 1298 // if it is called on a second object with this map, a
1299 // normal property is added instead, with a map transition. 1299 // normal property is added instead, with a map transition.
1300 // This avoids the creation of many maps with the same constant 1300 // This avoids the creation of many maps with the same constant
1301 // function, all orphaned. 1301 // function, all orphaned.
1302 Object* AddConstantFunctionProperty(String* name, 1302 Object* AddConstantFunctionProperty(String* name,
1303 JSFunction* function, 1303 JSFunction* function,
1304 PropertyAttributes attributes); 1304 PropertyAttributes attributes);
1305 1305
1306 // Replace a constant function property on a fast-case object. 1306 Object* ReplaceSlowProperty(String* name,
1307 Object* ReplaceConstantFunctionProperty(String* name, 1307 Object* value,
1308 Object* value); 1308 PropertyAttributes attributes);
1309
1310 // Converts a descriptor of any other type to a real field,
1311 // backed by the properties array. Descriptors of visible
1312 // types, such as CONSTANT_FUNCTION, keep their enumeration order.
1313 // Converts the descriptor on the original object's map to a
1314 // map transition, and the the new field is on the object's new map.
1315 Object* ConvertDescriptorToFieldAndMapTransition(
1316 String* name,
1317 Object* new_value,
1318 PropertyAttributes attributes);
1319
1320 // Converts a descriptor of any other type to a real field,
1321 // backed by the properties array. Descriptors of visible
1322 // types, such as CONSTANT_FUNCTION, keep their enumeration order.
1323 Object* ConvertDescriptorToField(String* name,
1324 Object* new_value,
1325 PropertyAttributes attributes);
1309 1326
1310 // Add a property to a fast-case object. 1327 // Add a property to a fast-case object.
1311 Object* AddFastProperty(String* name, 1328 Object* AddFastProperty(String* name,
1312 Object* value, 1329 Object* value,
1313 PropertyAttributes attributes); 1330 PropertyAttributes attributes);
1314 1331
1315 // Add a property to a slow-case object. 1332 // Add a property to a slow-case object.
1316 Object* AddSlowProperty(String* name, 1333 Object* AddSlowProperty(String* name,
1317 Object* value, 1334 Object* value,
1318 PropertyAttributes attributes); 1335 PropertyAttributes attributes);
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1370 int number_of_slow_unused_elements_; 1387 int number_of_slow_unused_elements_;
1371 }; 1388 };
1372 1389
1373 void IncrementSpillStatistics(SpillInformation* info); 1390 void IncrementSpillStatistics(SpillInformation* info);
1374 #endif 1391 #endif
1375 Object* SlowReverseLookup(Object* value); 1392 Object* SlowReverseLookup(Object* value);
1376 1393
1377 static const uint32_t kMaxGap = 1024; 1394 static const uint32_t kMaxGap = 1024;
1378 static const int kMaxFastElementsLength = 5000; 1395 static const int kMaxFastElementsLength = 5000;
1379 static const int kMaxFastProperties = 8; 1396 static const int kMaxFastProperties = 8;
1397 // When extending the backing storage for property values, we increase
1398 // its size by more than the 1 entry necessary, so sequentially adding fields
1399 // to the same object requires fewer allocations and copies.
1400 static const int kFieldsAdded = 3;
1380 1401
1381 // Layout description. 1402 // Layout description.
1382 static const int kPropertiesOffset = HeapObject::kHeaderSize; 1403 static const int kPropertiesOffset = HeapObject::kHeaderSize;
1383 static const int kElementsOffset = kPropertiesOffset + kPointerSize; 1404 static const int kElementsOffset = kPropertiesOffset + kPointerSize;
1384 static const int kHeaderSize = kElementsOffset + kPointerSize; 1405 static const int kHeaderSize = kElementsOffset + kPointerSize;
1385 1406
1386 Object* GetElementWithInterceptor(JSObject* receiver, uint32_t index); 1407 Object* GetElementWithInterceptor(JSObject* receiver, uint32_t index);
1387 1408
1388 private: 1409 private:
1389 Object* SetElementWithInterceptor(uint32_t index, Object* value); 1410 Object* SetElementWithInterceptor(uint32_t index, Object* value);
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
1555 1576
1556 // Accessors for fetching instance descriptor at descriptor number.. 1577 // Accessors for fetching instance descriptor at descriptor number..
1557 inline String* GetKey(int descriptor_number); 1578 inline String* GetKey(int descriptor_number);
1558 inline Object* GetValue(int descriptor_number); 1579 inline Object* GetValue(int descriptor_number);
1559 inline Smi* GetDetails(int descriptor_number); 1580 inline Smi* GetDetails(int descriptor_number);
1560 1581
1561 // Accessor for complete descriptor. 1582 // Accessor for complete descriptor.
1562 inline void Get(int descriptor_number, Descriptor* desc); 1583 inline void Get(int descriptor_number, Descriptor* desc);
1563 inline void Set(int descriptor_number, Descriptor* desc); 1584 inline void Set(int descriptor_number, Descriptor* desc);
1564 1585
1565 void ReplaceConstantFunction(int descriptor_number, JSFunction* value);
1566 1586
1567 // Copy the descriptor array, insert a new descriptor and optionally 1587 // Copy the descriptor array, insert a new descriptor and optionally
1568 // remove map transitions. If the descriptor is already present, it is 1588 // remove map transitions. If the descriptor is already present, it is
1569 // replaced. If a replaced descriptor is a real property (not a transition 1589 // replaced. If a replaced descriptor is a real property (not a transition
1570 // or null), its enumeration index is kept as is. 1590 // or null), its enumeration index is kept as is.
1571 // If adding a real property, map transitions must be removed. If adding 1591 // If adding a real property, map transitions must be removed. If adding
1572 // a transition, they must not be removed. All null descriptors are removed. 1592 // a transition, they must not be removed. All null descriptors are removed.
1573 Object* CopyInsert(Descriptor* descriptor, TransitionFlag transition_flag); 1593 Object* CopyInsert(Descriptor* descriptor, TransitionFlag transition_flag);
1574 1594
1575 // Makes a copy of the descriptor array with the descriptor with key name
1576 // removed. If name is the empty string, the descriptor array is copied.
1577 // Transitions are removed if TransitionFlag is REMOVE_TRANSITIONS.
1578 // All null descriptors are removed.
1579 Object* CopyRemove(TransitionFlag remove_transitions, String* name);
1580
1581 // Copy the descriptor array, replace the property index and attributes
1582 // of the named property, but preserve its enumeration index.
1583 Object* CopyReplace(String* name, int index, PropertyAttributes attributes);
1584
1585 // Copy the descriptor array, removing the property index and attributes
1586 // of the named property.
1587 Object* CopyRemove(String* name);
1588
1589 // Remove all transitions. Return a copy of the array with all transitions 1595 // Remove all transitions. Return a copy of the array with all transitions
1590 // removed, or a Failure object if the new array could not be allocated. 1596 // removed, or a Failure object if the new array could not be allocated.
1591 Object* RemoveTransitions(); 1597 Object* RemoveTransitions();
1592 1598
1593 // Sort the instance descriptors by the hash codes of their keys. 1599 // Sort the instance descriptors by the hash codes of their keys.
1594 void Sort(); 1600 void Sort();
1595 1601
1596 // Search the instance descriptors for given name. 1602 // Search the instance descriptors for given name.
1597 inline int Search(String* name); 1603 inline int Search(String* name);
1598 1604
(...skipping 2391 matching lines...) Expand 10 before | Expand all | Expand 10 after
3990 } else { 3996 } else {
3991 value &= ~(1 << bit_position); 3997 value &= ~(1 << bit_position);
3992 } 3998 }
3993 return value; 3999 return value;
3994 } 4000 }
3995 }; 4001 };
3996 4002
3997 } } // namespace v8::internal 4003 } } // namespace v8::internal
3998 4004
3999 #endif // V8_OBJECTS_H_ 4005 #endif // V8_OBJECTS_H_
OLDNEW
« no previous file with comments | « no previous file | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698