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

Side by Side Diff: src/objects.h

Issue 9227007: Version 3.8.6 (Closed) Base URL: http://v8.googlecode.com/svn/trunk/
Patch Set: Created 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/mips/stub-cache-mips.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 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
11 // with the distribution. 11 // with the distribution.
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 // - ExternalAsciiString 100 // - ExternalAsciiString
101 // - ExternalTwoByteString 101 // - ExternalTwoByteString
102 // - HeapNumber 102 // - HeapNumber
103 // - Code 103 // - Code
104 // - Map 104 // - Map
105 // - Oddball 105 // - Oddball
106 // - Foreign 106 // - Foreign
107 // - SharedFunctionInfo 107 // - SharedFunctionInfo
108 // - Struct 108 // - Struct
109 // - AccessorInfo 109 // - AccessorInfo
110 // - AccessorPair
110 // - AccessCheckInfo 111 // - AccessCheckInfo
111 // - InterceptorInfo 112 // - InterceptorInfo
112 // - CallHandlerInfo 113 // - CallHandlerInfo
113 // - TemplateInfo 114 // - TemplateInfo
114 // - FunctionTemplateInfo 115 // - FunctionTemplateInfo
115 // - ObjectTemplateInfo 116 // - ObjectTemplateInfo
116 // - Script 117 // - Script
117 // - SignatureInfo 118 // - SignatureInfo
118 // - TypeSwitchInfo 119 // - TypeSwitchInfo
119 // - DebugInfo 120 // - DebugInfo
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 EXTERNAL_DOUBLE_ELEMENTS, 156 EXTERNAL_DOUBLE_ELEMENTS,
156 EXTERNAL_PIXEL_ELEMENTS, 157 EXTERNAL_PIXEL_ELEMENTS,
157 158
158 // Derived constants from ElementsKind 159 // Derived constants from ElementsKind
159 FIRST_EXTERNAL_ARRAY_ELEMENTS_KIND = EXTERNAL_BYTE_ELEMENTS, 160 FIRST_EXTERNAL_ARRAY_ELEMENTS_KIND = EXTERNAL_BYTE_ELEMENTS,
160 LAST_EXTERNAL_ARRAY_ELEMENTS_KIND = EXTERNAL_PIXEL_ELEMENTS, 161 LAST_EXTERNAL_ARRAY_ELEMENTS_KIND = EXTERNAL_PIXEL_ELEMENTS,
161 FIRST_ELEMENTS_KIND = FAST_SMI_ONLY_ELEMENTS, 162 FIRST_ELEMENTS_KIND = FAST_SMI_ONLY_ELEMENTS,
162 LAST_ELEMENTS_KIND = EXTERNAL_PIXEL_ELEMENTS 163 LAST_ELEMENTS_KIND = EXTERNAL_PIXEL_ELEMENTS
163 }; 164 };
164 165
166 enum CompareMapMode {
167 REQUIRE_EXACT_MAP,
168 ALLOW_ELEMENT_TRANSITION_MAPS
169 };
170
165 const int kElementsKindCount = LAST_ELEMENTS_KIND - FIRST_ELEMENTS_KIND + 1; 171 const int kElementsKindCount = LAST_ELEMENTS_KIND - FIRST_ELEMENTS_KIND + 1;
166 172
167 void PrintElementsKind(FILE* out, ElementsKind kind); 173 void PrintElementsKind(FILE* out, ElementsKind kind);
168 174
169 inline bool IsMoreGeneralElementsKindTransition(ElementsKind from_kind, 175 inline bool IsMoreGeneralElementsKindTransition(ElementsKind from_kind,
170 ElementsKind to_kind); 176 ElementsKind to_kind);
171 177
172 // Setter that skips the write barrier if mode is SKIP_WRITE_BARRIER. 178 // Setter that skips the write barrier if mode is SKIP_WRITE_BARRIER.
173 enum WriteBarrierMode { SKIP_WRITE_BARRIER, UPDATE_WRITE_BARRIER }; 179 enum WriteBarrierMode { SKIP_WRITE_BARRIER, UPDATE_WRITE_BARRIER };
174 180
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 V(EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE) \ 269 V(EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE) \
264 V(EXTERNAL_SHORT_ARRAY_TYPE) \ 270 V(EXTERNAL_SHORT_ARRAY_TYPE) \
265 V(EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE) \ 271 V(EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE) \
266 V(EXTERNAL_INT_ARRAY_TYPE) \ 272 V(EXTERNAL_INT_ARRAY_TYPE) \
267 V(EXTERNAL_UNSIGNED_INT_ARRAY_TYPE) \ 273 V(EXTERNAL_UNSIGNED_INT_ARRAY_TYPE) \
268 V(EXTERNAL_FLOAT_ARRAY_TYPE) \ 274 V(EXTERNAL_FLOAT_ARRAY_TYPE) \
269 V(EXTERNAL_PIXEL_ARRAY_TYPE) \ 275 V(EXTERNAL_PIXEL_ARRAY_TYPE) \
270 V(FILLER_TYPE) \ 276 V(FILLER_TYPE) \
271 \ 277 \
272 V(ACCESSOR_INFO_TYPE) \ 278 V(ACCESSOR_INFO_TYPE) \
279 V(ACCESSOR_PAIR_TYPE) \
273 V(ACCESS_CHECK_INFO_TYPE) \ 280 V(ACCESS_CHECK_INFO_TYPE) \
274 V(INTERCEPTOR_INFO_TYPE) \ 281 V(INTERCEPTOR_INFO_TYPE) \
275 V(CALL_HANDLER_INFO_TYPE) \ 282 V(CALL_HANDLER_INFO_TYPE) \
276 V(FUNCTION_TEMPLATE_INFO_TYPE) \ 283 V(FUNCTION_TEMPLATE_INFO_TYPE) \
277 V(OBJECT_TEMPLATE_INFO_TYPE) \ 284 V(OBJECT_TEMPLATE_INFO_TYPE) \
278 V(SIGNATURE_INFO_TYPE) \ 285 V(SIGNATURE_INFO_TYPE) \
279 V(TYPE_SWITCH_INFO_TYPE) \ 286 V(TYPE_SWITCH_INFO_TYPE) \
280 V(SCRIPT_TYPE) \ 287 V(SCRIPT_TYPE) \
281 V(CODE_CACHE_TYPE) \ 288 V(CODE_CACHE_TYPE) \
282 V(POLYMORPHIC_CODE_CACHE_TYPE) \ 289 V(POLYMORPHIC_CODE_CACHE_TYPE) \
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 // object type in this causes the compiler to generate most of the boilerplate 417 // object type in this causes the compiler to generate most of the boilerplate
411 // code for the class including allocation and garbage collection routines, 418 // code for the class including allocation and garbage collection routines,
412 // casts and predicates. All you need to define is the class, methods and 419 // casts and predicates. All you need to define is the class, methods and
413 // object verification routines. Easy, no? 420 // object verification routines. Easy, no?
414 // 421 //
415 // Note that for subtle reasons related to the ordering or numerical values of 422 // Note that for subtle reasons related to the ordering or numerical values of
416 // type tags, elements in this list have to be added to the INSTANCE_TYPE_LIST 423 // type tags, elements in this list have to be added to the INSTANCE_TYPE_LIST
417 // manually. 424 // manually.
418 #define STRUCT_LIST_ALL(V) \ 425 #define STRUCT_LIST_ALL(V) \
419 V(ACCESSOR_INFO, AccessorInfo, accessor_info) \ 426 V(ACCESSOR_INFO, AccessorInfo, accessor_info) \
427 V(ACCESSOR_PAIR, AccessorPair, accessor_pair) \
420 V(ACCESS_CHECK_INFO, AccessCheckInfo, access_check_info) \ 428 V(ACCESS_CHECK_INFO, AccessCheckInfo, access_check_info) \
421 V(INTERCEPTOR_INFO, InterceptorInfo, interceptor_info) \ 429 V(INTERCEPTOR_INFO, InterceptorInfo, interceptor_info) \
422 V(CALL_HANDLER_INFO, CallHandlerInfo, call_handler_info) \ 430 V(CALL_HANDLER_INFO, CallHandlerInfo, call_handler_info) \
423 V(FUNCTION_TEMPLATE_INFO, FunctionTemplateInfo, function_template_info) \ 431 V(FUNCTION_TEMPLATE_INFO, FunctionTemplateInfo, function_template_info) \
424 V(OBJECT_TEMPLATE_INFO, ObjectTemplateInfo, object_template_info) \ 432 V(OBJECT_TEMPLATE_INFO, ObjectTemplateInfo, object_template_info) \
425 V(SIGNATURE_INFO, SignatureInfo, signature_info) \ 433 V(SIGNATURE_INFO, SignatureInfo, signature_info) \
426 V(TYPE_SWITCH_INFO, TypeSwitchInfo, type_switch_info) \ 434 V(TYPE_SWITCH_INFO, TypeSwitchInfo, type_switch_info) \
427 V(SCRIPT, Script, script) \ 435 V(SCRIPT, Script, script) \
428 V(CODE_CACHE, CodeCache, code_cache) \ 436 V(CODE_CACHE, CodeCache, code_cache) \
429 V(POLYMORPHIC_CODE_CACHE, PolymorphicCodeCache, polymorphic_code_cache) 437 V(POLYMORPHIC_CODE_CACHE, PolymorphicCodeCache, polymorphic_code_cache)
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
563 EXTERNAL_INT_ARRAY_TYPE, 571 EXTERNAL_INT_ARRAY_TYPE,
564 EXTERNAL_UNSIGNED_INT_ARRAY_TYPE, 572 EXTERNAL_UNSIGNED_INT_ARRAY_TYPE,
565 EXTERNAL_FLOAT_ARRAY_TYPE, 573 EXTERNAL_FLOAT_ARRAY_TYPE,
566 EXTERNAL_DOUBLE_ARRAY_TYPE, 574 EXTERNAL_DOUBLE_ARRAY_TYPE,
567 EXTERNAL_PIXEL_ARRAY_TYPE, // LAST_EXTERNAL_ARRAY_TYPE 575 EXTERNAL_PIXEL_ARRAY_TYPE, // LAST_EXTERNAL_ARRAY_TYPE
568 FIXED_DOUBLE_ARRAY_TYPE, 576 FIXED_DOUBLE_ARRAY_TYPE,
569 FILLER_TYPE, // LAST_DATA_TYPE 577 FILLER_TYPE, // LAST_DATA_TYPE
570 578
571 // Structs. 579 // Structs.
572 ACCESSOR_INFO_TYPE, 580 ACCESSOR_INFO_TYPE,
581 ACCESSOR_PAIR_TYPE,
573 ACCESS_CHECK_INFO_TYPE, 582 ACCESS_CHECK_INFO_TYPE,
574 INTERCEPTOR_INFO_TYPE, 583 INTERCEPTOR_INFO_TYPE,
575 CALL_HANDLER_INFO_TYPE, 584 CALL_HANDLER_INFO_TYPE,
576 FUNCTION_TEMPLATE_INFO_TYPE, 585 FUNCTION_TEMPLATE_INFO_TYPE,
577 OBJECT_TEMPLATE_INFO_TYPE, 586 OBJECT_TEMPLATE_INFO_TYPE,
578 SIGNATURE_INFO_TYPE, 587 SIGNATURE_INFO_TYPE,
579 TYPE_SWITCH_INFO_TYPE, 588 TYPE_SWITCH_INFO_TYPE,
580 SCRIPT_TYPE, 589 SCRIPT_TYPE,
581 CODE_CACHE_TYPE, 590 CODE_CACHE_TYPE,
582 POLYMORPHIC_CODE_CACHE_TYPE, 591 POLYMORPHIC_CODE_CACHE_TYPE,
(...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after
1335 public: 1344 public:
1336 enum DeleteMode { 1345 enum DeleteMode {
1337 NORMAL_DELETION, 1346 NORMAL_DELETION,
1338 STRICT_DELETION, 1347 STRICT_DELETION,
1339 FORCE_DELETION 1348 FORCE_DELETION
1340 }; 1349 };
1341 1350
1342 // Casting. 1351 // Casting.
1343 static inline JSReceiver* cast(Object* obj); 1352 static inline JSReceiver* cast(Object* obj);
1344 1353
1354 static Handle<Object> SetProperty(Handle<JSReceiver> object,
1355 Handle<String> key,
1356 Handle<Object> value,
1357 PropertyAttributes attributes,
1358 StrictModeFlag strict_mode);
1345 // Can cause GC. 1359 // Can cause GC.
1346 MUST_USE_RESULT MaybeObject* SetProperty(String* key, 1360 MUST_USE_RESULT MaybeObject* SetProperty(String* key,
1347 Object* value, 1361 Object* value,
1348 PropertyAttributes attributes, 1362 PropertyAttributes attributes,
1349 StrictModeFlag strict_mode); 1363 StrictModeFlag strict_mode);
1350 MUST_USE_RESULT MaybeObject* SetProperty(LookupResult* result, 1364 MUST_USE_RESULT MaybeObject* SetProperty(LookupResult* result,
1351 String* key, 1365 String* key,
1352 Object* value, 1366 Object* value,
1353 PropertyAttributes attributes, 1367 PropertyAttributes attributes,
1354 StrictModeFlag strict_mode); 1368 StrictModeFlag strict_mode);
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
1464 inline bool HasExternalByteElements(); 1478 inline bool HasExternalByteElements();
1465 inline bool HasExternalUnsignedByteElements(); 1479 inline bool HasExternalUnsignedByteElements();
1466 inline bool HasExternalShortElements(); 1480 inline bool HasExternalShortElements();
1467 inline bool HasExternalUnsignedShortElements(); 1481 inline bool HasExternalUnsignedShortElements();
1468 inline bool HasExternalIntElements(); 1482 inline bool HasExternalIntElements();
1469 inline bool HasExternalUnsignedIntElements(); 1483 inline bool HasExternalUnsignedIntElements();
1470 inline bool HasExternalFloatElements(); 1484 inline bool HasExternalFloatElements();
1471 inline bool HasExternalDoubleElements(); 1485 inline bool HasExternalDoubleElements();
1472 bool HasFastArgumentsElements(); 1486 bool HasFastArgumentsElements();
1473 bool HasDictionaryArgumentsElements(); 1487 bool HasDictionaryArgumentsElements();
1474 inline NumberDictionary* element_dictionary(); // Gets slow elements. 1488 inline SeededNumberDictionary* element_dictionary(); // Gets slow elements.
1475 1489
1476 inline void set_map_and_elements( 1490 inline void set_map_and_elements(
1477 Map* map, 1491 Map* map,
1478 FixedArrayBase* value, 1492 FixedArrayBase* value,
1479 WriteBarrierMode mode = UPDATE_WRITE_BARRIER); 1493 WriteBarrierMode mode = UPDATE_WRITE_BARRIER);
1480 1494
1481 // Requires: HasFastElements(). 1495 // Requires: HasFastElements().
1482 MUST_USE_RESULT inline MaybeObject* EnsureWritableFastElements(); 1496 MUST_USE_RESULT inline MaybeObject* EnsureWritableFastElements();
1483 1497
1484 // Collects elements starting at index 0. 1498 // Collects elements starting at index 0.
(...skipping 29 matching lines...) Expand all
1514 MUST_USE_RESULT MaybeObject* SetPropertyWithInterceptor( 1528 MUST_USE_RESULT MaybeObject* SetPropertyWithInterceptor(
1515 String* name, 1529 String* name,
1516 Object* value, 1530 Object* value,
1517 PropertyAttributes attributes, 1531 PropertyAttributes attributes,
1518 StrictModeFlag strict_mode); 1532 StrictModeFlag strict_mode);
1519 MUST_USE_RESULT MaybeObject* SetPropertyPostInterceptor( 1533 MUST_USE_RESULT MaybeObject* SetPropertyPostInterceptor(
1520 String* name, 1534 String* name,
1521 Object* value, 1535 Object* value,
1522 PropertyAttributes attributes, 1536 PropertyAttributes attributes,
1523 StrictModeFlag strict_mode); 1537 StrictModeFlag strict_mode);
1538
1539 static Handle<Object> SetLocalPropertyIgnoreAttributes(
1540 Handle<JSObject> object,
1541 Handle<String> key,
1542 Handle<Object> value,
1543 PropertyAttributes attributes);
1544
1545 // Can cause GC.
1524 MUST_USE_RESULT MaybeObject* SetLocalPropertyIgnoreAttributes( 1546 MUST_USE_RESULT MaybeObject* SetLocalPropertyIgnoreAttributes(
1525 String* key, 1547 String* key,
1526 Object* value, 1548 Object* value,
1527 PropertyAttributes attributes); 1549 PropertyAttributes attributes);
1528 1550
1529 // Retrieve a value in a normalized object given a lookup result. 1551 // Retrieve a value in a normalized object given a lookup result.
1530 // Handles the special representation of JS global objects. 1552 // Handles the special representation of JS global objects.
1531 Object* GetNormalizedProperty(LookupResult* result); 1553 Object* GetNormalizedProperty(LookupResult* result);
1532 1554
1533 // Sets the property value in a normalized object given a lookup result. 1555 // Sets the property value in a normalized object given a lookup result.
1534 // Handles the special representation of JS global objects. 1556 // Handles the special representation of JS global objects.
1535 Object* SetNormalizedProperty(LookupResult* result, Object* value); 1557 Object* SetNormalizedProperty(LookupResult* result, Object* value);
1536 1558
1537 // Sets the property value in a normalized object given (key, value, details). 1559 // Sets the property value in a normalized object given (key, value, details).
1538 // Handles the special representation of JS global objects. 1560 // Handles the special representation of JS global objects.
1561 static Handle<Object> SetNormalizedProperty(Handle<JSObject> object,
1562 Handle<String> key,
1563 Handle<Object> value,
1564 PropertyDetails details);
1565
1539 MUST_USE_RESULT MaybeObject* SetNormalizedProperty(String* name, 1566 MUST_USE_RESULT MaybeObject* SetNormalizedProperty(String* name,
1540 Object* value, 1567 Object* value,
1541 PropertyDetails details); 1568 PropertyDetails details);
1542 1569
1543 // Deletes the named property in a normalized object. 1570 // Deletes the named property in a normalized object.
1544 MUST_USE_RESULT MaybeObject* DeleteNormalizedProperty(String* name, 1571 MUST_USE_RESULT MaybeObject* DeleteNormalizedProperty(String* name,
1545 DeleteMode mode); 1572 DeleteMode mode);
1546 1573
1547 // Retrieve interceptors. 1574 // Retrieve interceptors.
1548 InterceptorInfo* GetNamedInterceptor(); 1575 InterceptorInfo* GetNamedInterceptor();
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
1598 // Accessors for hidden properties object. 1625 // Accessors for hidden properties object.
1599 // 1626 //
1600 // Hidden properties are not local properties of the object itself. 1627 // Hidden properties are not local properties of the object itself.
1601 // Instead they are stored in an auxiliary structure kept as a local 1628 // Instead they are stored in an auxiliary structure kept as a local
1602 // property with a special name Heap::hidden_symbol(). But if the 1629 // property with a special name Heap::hidden_symbol(). But if the
1603 // receiver is a JSGlobalProxy then the auxiliary object is a property 1630 // receiver is a JSGlobalProxy then the auxiliary object is a property
1604 // of its prototype, and if it's a detached proxy, then you can't have 1631 // of its prototype, and if it's a detached proxy, then you can't have
1605 // hidden properties. 1632 // hidden properties.
1606 1633
1607 // Sets a hidden property on this object. Returns this object if successful, 1634 // Sets a hidden property on this object. Returns this object if successful,
1608 // undefined if called on a detached proxy, and a failure if a GC 1635 // undefined if called on a detached proxy.
1609 // is required 1636 static Handle<Object> SetHiddenProperty(Handle<JSObject> obj,
1637 Handle<String> key,
1638 Handle<Object> value);
1639 // Returns a failure if a GC is required.
1610 MaybeObject* SetHiddenProperty(String* key, Object* value); 1640 MaybeObject* SetHiddenProperty(String* key, Object* value);
1611 // Gets the value of a hidden property with the given key. Returns undefined 1641 // Gets the value of a hidden property with the given key. Returns undefined
1612 // if the property doesn't exist (or if called on a detached proxy), 1642 // if the property doesn't exist (or if called on a detached proxy),
1613 // otherwise returns the value set for the key. 1643 // otherwise returns the value set for the key.
1614 Object* GetHiddenProperty(String* key); 1644 Object* GetHiddenProperty(String* key);
1615 // Deletes a hidden property. Deleting a non-existing property is 1645 // Deletes a hidden property. Deleting a non-existing property is
1616 // considered successful. 1646 // considered successful.
1617 void DeleteHiddenProperty(String* key); 1647 void DeleteHiddenProperty(String* key);
1618 // Returns true if the object has a property with the hidden symbol as name. 1648 // Returns true if the object has a property with the hidden symbol as name.
1619 bool HasHiddenProperties(); 1649 bool HasHiddenProperties();
1620 1650
1651 static int GetIdentityHash(Handle<JSObject> obj);
1621 MUST_USE_RESULT MaybeObject* GetIdentityHash(CreationFlag flag); 1652 MUST_USE_RESULT MaybeObject* GetIdentityHash(CreationFlag flag);
1622 MUST_USE_RESULT MaybeObject* SetIdentityHash(Object* hash, CreationFlag flag); 1653 MUST_USE_RESULT MaybeObject* SetIdentityHash(Object* hash, CreationFlag flag);
1623 1654
1655 static Handle<Object> DeleteProperty(Handle<JSObject> obj,
1656 Handle<String> name);
1624 MUST_USE_RESULT MaybeObject* DeleteProperty(String* name, DeleteMode mode); 1657 MUST_USE_RESULT MaybeObject* DeleteProperty(String* name, DeleteMode mode);
1658
1659 static Handle<Object> DeleteElement(Handle<JSObject> obj, uint32_t index);
1625 MUST_USE_RESULT MaybeObject* DeleteElement(uint32_t index, DeleteMode mode); 1660 MUST_USE_RESULT MaybeObject* DeleteElement(uint32_t index, DeleteMode mode);
1626 1661
1627 inline void ValidateSmiOnlyElements(); 1662 inline void ValidateSmiOnlyElements();
1628 1663
1629 // Makes sure that this object can contain HeapObject as elements. 1664 // Makes sure that this object can contain HeapObject as elements.
1630 inline MaybeObject* EnsureCanContainHeapObjectElements(); 1665 inline MaybeObject* EnsureCanContainHeapObjectElements();
1631 1666
1632 // Makes sure that this object can contain the specified elements. 1667 // Makes sure that this object can contain the specified elements.
1633 inline MaybeObject* EnsureCanContainElements(Object** elements, 1668 inline MaybeObject* EnsureCanContainElements(Object** elements,
1634 uint32_t count, 1669 uint32_t count,
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
1694 Object* value, 1729 Object* value,
1695 StrictModeFlag strict_mode, 1730 StrictModeFlag strict_mode,
1696 bool check_prototype); 1731 bool check_prototype);
1697 1732
1698 MUST_USE_RESULT MaybeObject* SetFastDoubleElement( 1733 MUST_USE_RESULT MaybeObject* SetFastDoubleElement(
1699 uint32_t index, 1734 uint32_t index,
1700 Object* value, 1735 Object* value,
1701 StrictModeFlag strict_mode, 1736 StrictModeFlag strict_mode,
1702 bool check_prototype = true); 1737 bool check_prototype = true);
1703 1738
1704 // Set the index'th array element. 1739
1740 static Handle<Object> SetOwnElement(Handle<JSObject> object,
1741 uint32_t index,
1742 Handle<Object> value,
1743 StrictModeFlag strict_mode);
1744
1745 // Empty handle is returned if the element cannot be set to the given value.
1746 static MUST_USE_RESULT Handle<Object> SetElement(Handle<JSObject> object,
1747 uint32_t index,
1748 Handle<Object> value,
1749 StrictModeFlag strict_mode);
1750
1705 // A Failure object is returned if GC is needed. 1751 // A Failure object is returned if GC is needed.
1706 MUST_USE_RESULT MaybeObject* SetElement(uint32_t index, 1752 MUST_USE_RESULT MaybeObject* SetElement(uint32_t index,
1707 Object* value, 1753 Object* value,
1708 StrictModeFlag strict_mode, 1754 StrictModeFlag strict_mode,
1709 bool check_prototype); 1755 bool check_prototype);
1710 1756
1711 // Returns the index'th element. 1757 // Returns the index'th element.
1712 // The undefined object if index is out of bounds. 1758 // The undefined object if index is out of bounds.
1713 MaybeObject* GetElementWithInterceptor(Object* receiver, uint32_t index); 1759 MaybeObject* GetElementWithInterceptor(Object* receiver, uint32_t index);
1714 1760
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
1804 Object* value, 1850 Object* value,
1805 PropertyAttributes attributes); 1851 PropertyAttributes attributes);
1806 1852
1807 // Returns a new map with all transitions dropped from the object's current 1853 // Returns a new map with all transitions dropped from the object's current
1808 // map and the ElementsKind set. 1854 // map and the ElementsKind set.
1809 static Handle<Map> GetElementsTransitionMap(Handle<JSObject> object, 1855 static Handle<Map> GetElementsTransitionMap(Handle<JSObject> object,
1810 ElementsKind to_kind); 1856 ElementsKind to_kind);
1811 MUST_USE_RESULT MaybeObject* GetElementsTransitionMap( 1857 MUST_USE_RESULT MaybeObject* GetElementsTransitionMap(
1812 ElementsKind elements_kind); 1858 ElementsKind elements_kind);
1813 1859
1860 static Handle<Object> TransitionElementsKind(Handle<JSObject> object,
1861 ElementsKind to_kind);
1862
1814 MUST_USE_RESULT MaybeObject* TransitionElementsKind(ElementsKind to_kind); 1863 MUST_USE_RESULT MaybeObject* TransitionElementsKind(ElementsKind to_kind);
1815 1864
1816 // Converts a descriptor of any other type to a real field, 1865 // Converts a descriptor of any other type to a real field,
1817 // backed by the properties array. Descriptors of visible 1866 // backed by the properties array. Descriptors of visible
1818 // types, such as CONSTANT_FUNCTION, keep their enumeration order. 1867 // types, such as CONSTANT_FUNCTION, keep their enumeration order.
1819 // Converts the descriptor on the original object's map to a 1868 // Converts the descriptor on the original object's map to a
1820 // map transition, and the the new field is on the object's new map. 1869 // map transition, and the the new field is on the object's new map.
1821 MUST_USE_RESULT MaybeObject* ConvertDescriptorToFieldAndMapTransition( 1870 MUST_USE_RESULT MaybeObject* ConvertDescriptorToFieldAndMapTransition(
1822 String* name, 1871 String* name,
1823 Object* new_value, 1872 Object* new_value,
(...skipping 20 matching lines...) Expand all
1844 // Add a property to an object. 1893 // Add a property to an object.
1845 MUST_USE_RESULT MaybeObject* AddProperty(String* name, 1894 MUST_USE_RESULT MaybeObject* AddProperty(String* name,
1846 Object* value, 1895 Object* value,
1847 PropertyAttributes attributes, 1896 PropertyAttributes attributes,
1848 StrictModeFlag strict_mode); 1897 StrictModeFlag strict_mode);
1849 1898
1850 // Convert the object to use the canonical dictionary 1899 // Convert the object to use the canonical dictionary
1851 // representation. If the object is expected to have additional properties 1900 // representation. If the object is expected to have additional properties
1852 // added this number can be indicated to have the backing store allocated to 1901 // added this number can be indicated to have the backing store allocated to
1853 // an initial capacity for holding these properties. 1902 // an initial capacity for holding these properties.
1903 static void NormalizeProperties(Handle<JSObject> object,
1904 PropertyNormalizationMode mode,
1905 int expected_additional_properties);
1906
1854 MUST_USE_RESULT MaybeObject* NormalizeProperties( 1907 MUST_USE_RESULT MaybeObject* NormalizeProperties(
1855 PropertyNormalizationMode mode, 1908 PropertyNormalizationMode mode,
1856 int expected_additional_properties); 1909 int expected_additional_properties);
1857 1910
1858 // Convert and update the elements backing store to be a NumberDictionary 1911 // Convert and update the elements backing store to be a
1859 // dictionary. Returns the backing after conversion. 1912 // SeededNumberDictionary dictionary. Returns the backing after conversion.
1913 static Handle<SeededNumberDictionary> NormalizeElements(
1914 Handle<JSObject> object);
1915
1860 MUST_USE_RESULT MaybeObject* NormalizeElements(); 1916 MUST_USE_RESULT MaybeObject* NormalizeElements();
1861 1917
1862 static void UpdateMapCodeCache(Handle<JSObject> object, 1918 static void UpdateMapCodeCache(Handle<JSObject> object,
1863 Handle<String> name, 1919 Handle<String> name,
1864 Handle<Code> code); 1920 Handle<Code> code);
1865 1921
1866 MUST_USE_RESULT MaybeObject* UpdateMapCodeCache(String* name, Code* code); 1922 MUST_USE_RESULT MaybeObject* UpdateMapCodeCache(String* name, Code* code);
1867 1923
1868 // Transform slow named properties to fast variants. 1924 // Transform slow named properties to fast variants.
1869 // Returns failure if allocation failed. 1925 // Returns failure if allocation failed.
1926 static void TransformToFastProperties(Handle<JSObject> object,
1927 int unused_property_fields);
1928
1870 MUST_USE_RESULT MaybeObject* TransformToFastProperties( 1929 MUST_USE_RESULT MaybeObject* TransformToFastProperties(
1871 int unused_property_fields); 1930 int unused_property_fields);
1872 1931
1873 // Access fast-case object properties at index. 1932 // Access fast-case object properties at index.
1874 inline Object* FastPropertyAt(int index); 1933 inline Object* FastPropertyAt(int index);
1875 inline Object* FastPropertyAtPut(int index, Object* value); 1934 inline Object* FastPropertyAtPut(int index, Object* value);
1876 1935
1877 // Access to in object properties. 1936 // Access to in object properties.
1878 inline int GetInObjectPropertyOffset(int index); 1937 inline int GetInObjectPropertyOffset(int index);
1879 inline Object* InObjectPropertyAt(int index); 1938 inline Object* InObjectPropertyAt(int index);
(...skipping 11 matching lines...) Expand all
1891 Object* pre_allocated_value, 1950 Object* pre_allocated_value,
1892 Object* filler_value); 1951 Object* filler_value);
1893 1952
1894 // Check whether this object references another object 1953 // Check whether this object references another object
1895 bool ReferencesObject(Object* obj); 1954 bool ReferencesObject(Object* obj);
1896 1955
1897 // Casting. 1956 // Casting.
1898 static inline JSObject* cast(Object* obj); 1957 static inline JSObject* cast(Object* obj);
1899 1958
1900 // Disalow further properties to be added to the object. 1959 // Disalow further properties to be added to the object.
1960 static Handle<Object> PreventExtensions(Handle<JSObject> object);
1901 MUST_USE_RESULT MaybeObject* PreventExtensions(); 1961 MUST_USE_RESULT MaybeObject* PreventExtensions();
1902 1962
1903 1963
1904 // Dispatched behavior. 1964 // Dispatched behavior.
1905 void JSObjectShortPrint(StringStream* accumulator); 1965 void JSObjectShortPrint(StringStream* accumulator);
1906 #ifdef OBJECT_PRINT 1966 #ifdef OBJECT_PRINT
1907 inline void JSObjectPrint() { 1967 inline void JSObjectPrint() {
1908 JSObjectPrint(stdout); 1968 JSObjectPrint(stdout);
1909 } 1969 }
1910 void JSObjectPrint(FILE* out); 1970 void JSObjectPrint(FILE* out);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1944 int number_of_fast_used_elements_; 2004 int number_of_fast_used_elements_;
1945 int number_of_fast_unused_elements_; 2005 int number_of_fast_unused_elements_;
1946 int number_of_slow_used_elements_; 2006 int number_of_slow_used_elements_;
1947 int number_of_slow_unused_elements_; 2007 int number_of_slow_unused_elements_;
1948 }; 2008 };
1949 2009
1950 void IncrementSpillStatistics(SpillInformation* info); 2010 void IncrementSpillStatistics(SpillInformation* info);
1951 #endif 2011 #endif
1952 Object* SlowReverseLookup(Object* value); 2012 Object* SlowReverseLookup(Object* value);
1953 2013
1954 // Getters and setters are stored in a fixed array property.
1955 // These are constants for their indices.
1956 static const int kGetterIndex = 0;
1957 static const int kSetterIndex = 1;
1958
1959 // Maximal number of fast properties for the JSObject. Used to 2014 // Maximal number of fast properties for the JSObject. Used to
1960 // restrict the number of map transitions to avoid an explosion in 2015 // restrict the number of map transitions to avoid an explosion in
1961 // the number of maps for objects used as dictionaries. 2016 // the number of maps for objects used as dictionaries.
1962 inline int MaxFastProperties(); 2017 inline int MaxFastProperties();
1963 2018
1964 // Maximal number of elements (numbered 0 .. kMaxElementCount - 1). 2019 // Maximal number of elements (numbered 0 .. kMaxElementCount - 1).
1965 // Also maximal value of JSArray's length property. 2020 // Also maximal value of JSArray's length property.
1966 static const uint32_t kMaxElementCount = 0xffffffffu; 2021 static const uint32_t kMaxElementCount = 0xffffffffu;
1967 2022
1968 // Constants for heuristics controlling conversion of fast elements 2023 // Constants for heuristics controlling conversion of fast elements
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
2216 private: 2271 private:
2217 DISALLOW_IMPLICIT_CONSTRUCTORS(FixedArray); 2272 DISALLOW_IMPLICIT_CONSTRUCTORS(FixedArray);
2218 }; 2273 };
2219 2274
2220 2275
2221 // FixedDoubleArray describes fixed-sized arrays with element type double. 2276 // FixedDoubleArray describes fixed-sized arrays with element type double.
2222 class FixedDoubleArray: public FixedArrayBase { 2277 class FixedDoubleArray: public FixedArrayBase {
2223 public: 2278 public:
2224 inline void Initialize(FixedArray* from); 2279 inline void Initialize(FixedArray* from);
2225 inline void Initialize(FixedDoubleArray* from); 2280 inline void Initialize(FixedDoubleArray* from);
2226 inline void Initialize(NumberDictionary* from); 2281 inline void Initialize(SeededNumberDictionary* from);
2227 2282
2228 // Setter and getter for elements. 2283 // Setter and getter for elements.
2229 inline double get_scalar(int index); 2284 inline double get_scalar(int index);
2230 inline MaybeObject* get(int index); 2285 inline MaybeObject* get(int index);
2231 inline void set(int index, double value); 2286 inline void set(int index, double value);
2232 inline void set_the_hole(int index); 2287 inline void set_the_hole(int index);
2233 2288
2234 // Checking for the hole. 2289 // Checking for the hole.
2235 inline bool is_the_hole(int index); 2290 inline bool is_the_hole(int index);
2236 2291
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
2531 // // The prefix size indicates number of elements in the beginning 2586 // // The prefix size indicates number of elements in the beginning
2532 // // of the backing storage. 2587 // // of the backing storage.
2533 // static const int kPrefixSize = ..; 2588 // static const int kPrefixSize = ..;
2534 // // The Element size indicates number of elements per entry. 2589 // // The Element size indicates number of elements per entry.
2535 // static const int kEntrySize = ..; 2590 // static const int kEntrySize = ..;
2536 // }; 2591 // };
2537 // The prefix size indicates an amount of memory in the 2592 // The prefix size indicates an amount of memory in the
2538 // beginning of the backing storage that can be used for non-element 2593 // beginning of the backing storage that can be used for non-element
2539 // information by subclasses. 2594 // information by subclasses.
2540 2595
2596 template<typename Key>
2597 class BaseShape {
2598 public:
2599 static const bool UsesSeed = false;
2600 static uint32_t Hash(Key key) { return 0; }
2601 static uint32_t SeededHash(Key key, uint32_t seed) {
2602 ASSERT(UsesSeed);
2603 return Hash(key);
2604 }
2605 static uint32_t HashForObject(Key key, Object* object) { return 0; }
2606 static uint32_t SeededHashForObject(Key key, uint32_t seed, Object* object) {
2607 ASSERT(UsesSeed);
2608 return HashForObject(key, object);
2609 }
2610 };
2611
2541 template<typename Shape, typename Key> 2612 template<typename Shape, typename Key>
2542 class HashTable: public FixedArray { 2613 class HashTable: public FixedArray {
2543 public: 2614 public:
2615 // Wrapper methods
2616 inline uint32_t Hash(Key key) {
2617 if (Shape::UsesSeed) {
2618 return Shape::SeededHash(key,
2619 GetHeap()->HashSeed());
2620 } else {
2621 return Shape::Hash(key);
2622 }
2623 }
2624
2625 inline uint32_t HashForObject(Key key, Object* object) {
2626 if (Shape::UsesSeed) {
2627 return Shape::SeededHashForObject(key,
2628 GetHeap()->HashSeed(), object);
2629 } else {
2630 return Shape::HashForObject(key, object);
2631 }
2632 }
2633
2544 // Returns the number of elements in the hash table. 2634 // Returns the number of elements in the hash table.
2545 int NumberOfElements() { 2635 int NumberOfElements() {
2546 return Smi::cast(get(kNumberOfElementsIndex))->value(); 2636 return Smi::cast(get(kNumberOfElementsIndex))->value();
2547 } 2637 }
2548 2638
2549 // Returns the number of deleted elements in the hash table. 2639 // Returns the number of deleted elements in the hash table.
2550 int NumberOfDeletedElements() { 2640 int NumberOfDeletedElements() {
2551 return Smi::cast(get(kNumberOfDeletedElementsIndex))->value(); 2641 return Smi::cast(get(kNumberOfDeletedElementsIndex))->value();
2552 } 2642 }
2553 2643
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
2675 MUST_USE_RESULT MaybeObject* Rehash(HashTable* new_table, Key key); 2765 MUST_USE_RESULT MaybeObject* Rehash(HashTable* new_table, Key key);
2676 2766
2677 // Attempt to shrink hash table after removal of key. 2767 // Attempt to shrink hash table after removal of key.
2678 MUST_USE_RESULT MaybeObject* Shrink(Key key); 2768 MUST_USE_RESULT MaybeObject* Shrink(Key key);
2679 2769
2680 // Ensure enough space for n additional elements. 2770 // Ensure enough space for n additional elements.
2681 MUST_USE_RESULT MaybeObject* EnsureCapacity(int n, Key key); 2771 MUST_USE_RESULT MaybeObject* EnsureCapacity(int n, Key key);
2682 }; 2772 };
2683 2773
2684 2774
2685
2686 // HashTableKey is an abstract superclass for virtual key behavior. 2775 // HashTableKey is an abstract superclass for virtual key behavior.
2687 class HashTableKey { 2776 class HashTableKey {
2688 public: 2777 public:
2689 // Returns whether the other object matches this key. 2778 // Returns whether the other object matches this key.
2690 virtual bool IsMatch(Object* other) = 0; 2779 virtual bool IsMatch(Object* other) = 0;
2691 // Returns the hash value for this key. 2780 // Returns the hash value for this key.
2692 virtual uint32_t Hash() = 0; 2781 virtual uint32_t Hash() = 0;
2693 // Returns the hash value for object. 2782 // Returns the hash value for object.
2694 virtual uint32_t HashForObject(Object* key) = 0; 2783 virtual uint32_t HashForObject(Object* key) = 0;
2695 // Returns the key object for storing into the hash table. 2784 // Returns the key object for storing into the hash table.
2696 // If allocations fails a failure object is returned. 2785 // If allocations fails a failure object is returned.
2697 MUST_USE_RESULT virtual MaybeObject* AsObject() = 0; 2786 MUST_USE_RESULT virtual MaybeObject* AsObject() = 0;
2698 // Required. 2787 // Required.
2699 virtual ~HashTableKey() {} 2788 virtual ~HashTableKey() {}
2700 }; 2789 };
2701 2790
2702 class SymbolTableShape { 2791
2792 class SymbolTableShape : public BaseShape<HashTableKey*> {
2703 public: 2793 public:
2704 static inline bool IsMatch(HashTableKey* key, Object* value) { 2794 static inline bool IsMatch(HashTableKey* key, Object* value) {
2705 return key->IsMatch(value); 2795 return key->IsMatch(value);
2706 } 2796 }
2707 static inline uint32_t Hash(HashTableKey* key) { 2797 static inline uint32_t Hash(HashTableKey* key) {
2708 return key->Hash(); 2798 return key->Hash();
2709 } 2799 }
2710 static inline uint32_t HashForObject(HashTableKey* key, Object* object) { 2800 static inline uint32_t HashForObject(HashTableKey* key, Object* object) {
2711 return key->HashForObject(object); 2801 return key->HashForObject(object);
2712 } 2802 }
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
2751 // Casting. 2841 // Casting.
2752 static inline SymbolTable* cast(Object* obj); 2842 static inline SymbolTable* cast(Object* obj);
2753 2843
2754 private: 2844 private:
2755 MUST_USE_RESULT MaybeObject* LookupKey(HashTableKey* key, Object** s); 2845 MUST_USE_RESULT MaybeObject* LookupKey(HashTableKey* key, Object** s);
2756 2846
2757 DISALLOW_IMPLICIT_CONSTRUCTORS(SymbolTable); 2847 DISALLOW_IMPLICIT_CONSTRUCTORS(SymbolTable);
2758 }; 2848 };
2759 2849
2760 2850
2761 class MapCacheShape { 2851 class MapCacheShape : public BaseShape<HashTableKey*> {
2762 public: 2852 public:
2763 static inline bool IsMatch(HashTableKey* key, Object* value) { 2853 static inline bool IsMatch(HashTableKey* key, Object* value) {
2764 return key->IsMatch(value); 2854 return key->IsMatch(value);
2765 } 2855 }
2766 static inline uint32_t Hash(HashTableKey* key) { 2856 static inline uint32_t Hash(HashTableKey* key) {
2767 return key->Hash(); 2857 return key->Hash();
2768 } 2858 }
2769 2859
2770 static inline uint32_t HashForObject(HashTableKey* key, Object* object) { 2860 static inline uint32_t HashForObject(HashTableKey* key, Object* object) {
2771 return key->HashForObject(object); 2861 return key->HashForObject(object);
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
2907 uint32_t hash); 2997 uint32_t hash);
2908 2998
2909 // Generate new enumeration indices to avoid enumeration index overflow. 2999 // Generate new enumeration indices to avoid enumeration index overflow.
2910 MUST_USE_RESULT MaybeObject* GenerateNewEnumerationIndices(); 3000 MUST_USE_RESULT MaybeObject* GenerateNewEnumerationIndices();
2911 static const int kMaxNumberKeyIndex = 3001 static const int kMaxNumberKeyIndex =
2912 HashTable<Shape, Key>::kPrefixStartIndex; 3002 HashTable<Shape, Key>::kPrefixStartIndex;
2913 static const int kNextEnumerationIndexIndex = kMaxNumberKeyIndex + 1; 3003 static const int kNextEnumerationIndexIndex = kMaxNumberKeyIndex + 1;
2914 }; 3004 };
2915 3005
2916 3006
2917 class StringDictionaryShape { 3007 class StringDictionaryShape : public BaseShape<String*> {
2918 public: 3008 public:
2919 static inline bool IsMatch(String* key, Object* other); 3009 static inline bool IsMatch(String* key, Object* other);
2920 static inline uint32_t Hash(String* key); 3010 static inline uint32_t Hash(String* key);
2921 static inline uint32_t HashForObject(String* key, Object* object); 3011 static inline uint32_t HashForObject(String* key, Object* object);
2922 MUST_USE_RESULT static inline MaybeObject* AsObject(String* key); 3012 MUST_USE_RESULT static inline MaybeObject* AsObject(String* key);
2923 static const int kPrefixSize = 2; 3013 static const int kPrefixSize = 2;
2924 static const int kEntrySize = 3; 3014 static const int kEntrySize = 3;
2925 static const bool kIsEnumerable = true; 3015 static const bool kIsEnumerable = true;
2926 }; 3016 };
2927 3017
(...skipping 12 matching lines...) Expand all
2940 MUST_USE_RESULT MaybeObject* TransformPropertiesToFastFor( 3030 MUST_USE_RESULT MaybeObject* TransformPropertiesToFastFor(
2941 JSObject* obj, 3031 JSObject* obj,
2942 int unused_property_fields); 3032 int unused_property_fields);
2943 3033
2944 // Find entry for key, otherwise return kNotFound. Optimized version of 3034 // Find entry for key, otherwise return kNotFound. Optimized version of
2945 // HashTable::FindEntry. 3035 // HashTable::FindEntry.
2946 int FindEntry(String* key); 3036 int FindEntry(String* key);
2947 }; 3037 };
2948 3038
2949 3039
2950 class NumberDictionaryShape { 3040 class NumberDictionaryShape : public BaseShape<uint32_t> {
2951 public: 3041 public:
2952 static inline bool IsMatch(uint32_t key, Object* other); 3042 static inline bool IsMatch(uint32_t key, Object* other);
2953 static inline uint32_t Hash(uint32_t key);
2954 static inline uint32_t HashForObject(uint32_t key, Object* object);
2955 MUST_USE_RESULT static inline MaybeObject* AsObject(uint32_t key); 3043 MUST_USE_RESULT static inline MaybeObject* AsObject(uint32_t key);
2956 static const int kPrefixSize = 2;
2957 static const int kEntrySize = 3; 3044 static const int kEntrySize = 3;
2958 static const bool kIsEnumerable = false; 3045 static const bool kIsEnumerable = false;
2959 }; 3046 };
2960 3047
2961 3048
2962 class NumberDictionary: public Dictionary<NumberDictionaryShape, uint32_t> { 3049 class SeededNumberDictionaryShape : public NumberDictionaryShape {
2963 public: 3050 public:
2964 static NumberDictionary* cast(Object* obj) { 3051 static const bool UsesSeed = true;
3052 static const int kPrefixSize = 2;
3053
3054 static inline uint32_t SeededHash(uint32_t key, uint32_t seed);
3055 static inline uint32_t SeededHashForObject(uint32_t key,
3056 uint32_t seed,
3057 Object* object);
3058 };
3059
3060
3061 class UnseededNumberDictionaryShape : public NumberDictionaryShape {
3062 public:
3063 static const int kPrefixSize = 0;
3064
3065 static inline uint32_t Hash(uint32_t key);
3066 static inline uint32_t HashForObject(uint32_t key, Object* object);
3067 };
3068
3069
3070 class SeededNumberDictionary
3071 : public Dictionary<SeededNumberDictionaryShape, uint32_t> {
3072 public:
3073 static SeededNumberDictionary* cast(Object* obj) {
2965 ASSERT(obj->IsDictionary()); 3074 ASSERT(obj->IsDictionary());
2966 return reinterpret_cast<NumberDictionary*>(obj); 3075 return reinterpret_cast<SeededNumberDictionary*>(obj);
2967 } 3076 }
2968 3077
2969 // Type specific at put (default NONE attributes is used when adding). 3078 // Type specific at put (default NONE attributes is used when adding).
2970 MUST_USE_RESULT MaybeObject* AtNumberPut(uint32_t key, Object* value); 3079 MUST_USE_RESULT MaybeObject* AtNumberPut(uint32_t key, Object* value);
2971 MUST_USE_RESULT MaybeObject* AddNumberEntry(uint32_t key, 3080 MUST_USE_RESULT MaybeObject* AddNumberEntry(uint32_t key,
2972 Object* value, 3081 Object* value,
2973 PropertyDetails details); 3082 PropertyDetails details);
2974 3083
2975 // Set an existing entry or add a new one if needed. 3084 // Set an existing entry or add a new one if needed.
3085 // Return the updated dictionary.
3086 MUST_USE_RESULT static Handle<SeededNumberDictionary> Set(
3087 Handle<SeededNumberDictionary> dictionary,
3088 uint32_t index,
3089 Handle<Object> value,
3090 PropertyDetails details);
3091
2976 MUST_USE_RESULT MaybeObject* Set(uint32_t key, 3092 MUST_USE_RESULT MaybeObject* Set(uint32_t key,
2977 Object* value, 3093 Object* value,
2978 PropertyDetails details); 3094 PropertyDetails details);
2979 3095
2980 void UpdateMaxNumberKey(uint32_t key); 3096 void UpdateMaxNumberKey(uint32_t key);
2981 3097
2982 // If slow elements are required we will never go back to fast-case 3098 // If slow elements are required we will never go back to fast-case
2983 // for the elements kept in this dictionary. We require slow 3099 // for the elements kept in this dictionary. We require slow
2984 // elements if an element has been added at an index larger than 3100 // elements if an element has been added at an index larger than
2985 // kRequiresSlowElementsLimit or set_requires_slow_elements() has been called 3101 // kRequiresSlowElementsLimit or set_requires_slow_elements() has been called
2986 // when defining a getter or setter with a number key. 3102 // when defining a getter or setter with a number key.
2987 inline bool requires_slow_elements(); 3103 inline bool requires_slow_elements();
2988 inline void set_requires_slow_elements(); 3104 inline void set_requires_slow_elements();
2989 3105
2990 // Get the value of the max number key that has been added to this 3106 // Get the value of the max number key that has been added to this
2991 // dictionary. max_number_key can only be called if 3107 // dictionary. max_number_key can only be called if
2992 // requires_slow_elements returns false. 3108 // requires_slow_elements returns false.
2993 inline uint32_t max_number_key(); 3109 inline uint32_t max_number_key();
2994 3110
2995 // Bit masks. 3111 // Bit masks.
2996 static const int kRequiresSlowElementsMask = 1; 3112 static const int kRequiresSlowElementsMask = 1;
2997 static const int kRequiresSlowElementsTagSize = 1; 3113 static const int kRequiresSlowElementsTagSize = 1;
2998 static const uint32_t kRequiresSlowElementsLimit = (1 << 29) - 1; 3114 static const uint32_t kRequiresSlowElementsLimit = (1 << 29) - 1;
2999 }; 3115 };
3000 3116
3001 3117
3118 class UnseededNumberDictionary
3119 : public Dictionary<UnseededNumberDictionaryShape, uint32_t> {
3120 public:
3121 static UnseededNumberDictionary* cast(Object* obj) {
3122 ASSERT(obj->IsDictionary());
3123 return reinterpret_cast<UnseededNumberDictionary*>(obj);
3124 }
3125
3126 // Type specific at put (default NONE attributes is used when adding).
3127 MUST_USE_RESULT MaybeObject* AtNumberPut(uint32_t key, Object* value);
3128 MUST_USE_RESULT MaybeObject* AddNumberEntry(uint32_t key, Object* value);
3129
3130 // Set an existing entry or add a new one if needed.
3131 // Return the updated dictionary.
3132 MUST_USE_RESULT static Handle<UnseededNumberDictionary> Set(
3133 Handle<UnseededNumberDictionary> dictionary,
3134 uint32_t index,
3135 Handle<Object> value);
3136
3137 MUST_USE_RESULT MaybeObject* Set(uint32_t key, Object* value);
3138 };
3139
3140
3002 template <int entrysize> 3141 template <int entrysize>
3003 class ObjectHashTableShape { 3142 class ObjectHashTableShape : public BaseShape<Object*> {
3004 public: 3143 public:
3005 static inline bool IsMatch(Object* key, Object* other); 3144 static inline bool IsMatch(Object* key, Object* other);
3006 static inline uint32_t Hash(Object* key); 3145 static inline uint32_t Hash(Object* key);
3007 static inline uint32_t HashForObject(Object* key, Object* object); 3146 static inline uint32_t HashForObject(Object* key, Object* object);
3008 MUST_USE_RESULT static inline MaybeObject* AsObject(Object* key); 3147 MUST_USE_RESULT static inline MaybeObject* AsObject(Object* key);
3009 static const int kPrefixSize = 0; 3148 static const int kPrefixSize = 0;
3010 static const int kEntrySize = entrysize; 3149 static const int kEntrySize = entrysize;
3011 }; 3150 };
3012 3151
3013 3152
(...skipping 1770 matching lines...) Expand 10 before | Expand all | Expand 10 after
4784 V(Math, abs, MathAbs) \ 4923 V(Math, abs, MathAbs) \
4785 V(Math, log, MathLog) \ 4924 V(Math, log, MathLog) \
4786 V(Math, sin, MathSin) \ 4925 V(Math, sin, MathSin) \
4787 V(Math, cos, MathCos) \ 4926 V(Math, cos, MathCos) \
4788 V(Math, tan, MathTan) \ 4927 V(Math, tan, MathTan) \
4789 V(Math, asin, MathASin) \ 4928 V(Math, asin, MathASin) \
4790 V(Math, acos, MathACos) \ 4929 V(Math, acos, MathACos) \
4791 V(Math, atan, MathATan) \ 4930 V(Math, atan, MathATan) \
4792 V(Math, exp, MathExp) \ 4931 V(Math, exp, MathExp) \
4793 V(Math, sqrt, MathSqrt) \ 4932 V(Math, sqrt, MathSqrt) \
4794 V(Math, pow, MathPow) 4933 V(Math, pow, MathPow) \
4934 V(Math, random, MathRandom) \
4935 V(Math, max, MathMax) \
4936 V(Math, min, MathMin)
4795 4937
4796 4938
4797 enum BuiltinFunctionId { 4939 enum BuiltinFunctionId {
4798 #define DECLARE_FUNCTION_ID(ignored1, ignore2, name) \ 4940 #define DECLARE_FUNCTION_ID(ignored1, ignore2, name) \
4799 k##name, 4941 k##name,
4800 FUNCTIONS_WITH_ID_LIST(DECLARE_FUNCTION_ID) 4942 FUNCTIONS_WITH_ID_LIST(DECLARE_FUNCTION_ID)
4801 #undef DECLARE_FUNCTION_ID 4943 #undef DECLARE_FUNCTION_ID
4802 // Fake id for a special case of Math.pow. Note, it continues the 4944 // Fake id for a special case of Math.pow. Note, it continues the
4803 // list of math functions. 4945 // list of math functions.
4804 kMathPowHalf, 4946 kMathPowHalf,
(...skipping 1100 matching lines...) Expand 10 before | Expand all | Expand 10 after
5905 // object is in the saved code field. 6047 // object is in the saved code field.
5906 static const int kCompilationErrorValue = -2; 6048 static const int kCompilationErrorValue = -2;
5907 6049
5908 // When we store the sweep generation at which we moved the code from the 6050 // When we store the sweep generation at which we moved the code from the
5909 // code index to the saved code index we mask it of to be in the [0:255] 6051 // code index to the saved code index we mask it of to be in the [0:255]
5910 // range. 6052 // range.
5911 static const int kCodeAgeMask = 0xff; 6053 static const int kCodeAgeMask = 0xff;
5912 }; 6054 };
5913 6055
5914 6056
5915 class CompilationCacheShape { 6057 class CompilationCacheShape : public BaseShape<HashTableKey*> {
5916 public: 6058 public:
5917 static inline bool IsMatch(HashTableKey* key, Object* value) { 6059 static inline bool IsMatch(HashTableKey* key, Object* value) {
5918 return key->IsMatch(value); 6060 return key->IsMatch(value);
5919 } 6061 }
5920 6062
5921 static inline uint32_t Hash(HashTableKey* key) { 6063 static inline uint32_t Hash(HashTableKey* key) {
5922 return key->Hash(); 6064 return key->Hash();
5923 } 6065 }
5924 6066
5925 static inline uint32_t HashForObject(HashTableKey* key, Object* object) { 6067 static inline uint32_t HashForObject(HashTableKey* key, Object* object) {
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
6009 // Code cache layout of the default cache. Elements are alternating name and 6151 // Code cache layout of the default cache. Elements are alternating name and
6010 // code objects for non normal load/store/call IC's. 6152 // code objects for non normal load/store/call IC's.
6011 static const int kCodeCacheEntrySize = 2; 6153 static const int kCodeCacheEntrySize = 2;
6012 static const int kCodeCacheEntryNameOffset = 0; 6154 static const int kCodeCacheEntryNameOffset = 0;
6013 static const int kCodeCacheEntryCodeOffset = 1; 6155 static const int kCodeCacheEntryCodeOffset = 1;
6014 6156
6015 DISALLOW_IMPLICIT_CONSTRUCTORS(CodeCache); 6157 DISALLOW_IMPLICIT_CONSTRUCTORS(CodeCache);
6016 }; 6158 };
6017 6159
6018 6160
6019 class CodeCacheHashTableShape { 6161 class CodeCacheHashTableShape : public BaseShape<HashTableKey*> {
6020 public: 6162 public:
6021 static inline bool IsMatch(HashTableKey* key, Object* value) { 6163 static inline bool IsMatch(HashTableKey* key, Object* value) {
6022 return key->IsMatch(value); 6164 return key->IsMatch(value);
6023 } 6165 }
6024 6166
6025 static inline uint32_t Hash(HashTableKey* key) { 6167 static inline uint32_t Hash(HashTableKey* key) {
6026 return key->Hash(); 6168 return key->Hash();
6027 } 6169 }
6028 6170
6029 static inline uint32_t HashForObject(HashTableKey* key, Object* object) { 6171 static inline uint32_t HashForObject(HashTableKey* key, Object* object) {
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
6141 6283
6142 bool is_valid() { return is_valid_; } 6284 bool is_valid() { return is_valid_; }
6143 6285
6144 void invalidate() { is_valid_ = false; } 6286 void invalidate() { is_valid_ = false; }
6145 6287
6146 // Calculated hash value for a string consisting of 1 to 6288 // Calculated hash value for a string consisting of 1 to
6147 // String::kMaxArrayIndexSize digits with no leading zeros (except "0"). 6289 // String::kMaxArrayIndexSize digits with no leading zeros (except "0").
6148 // value is represented decimal value. 6290 // value is represented decimal value.
6149 static uint32_t MakeArrayIndexHash(uint32_t value, int length); 6291 static uint32_t MakeArrayIndexHash(uint32_t value, int length);
6150 6292
6293 // No string is allowed to have a hash of zero. That value is reserved
6294 // for internal properties. If the hash calculation yields zero then we
6295 // use 27 instead.
6296 static const int kZeroHash = 27;
6297
6151 private: 6298 private:
6152 uint32_t array_index() { 6299 uint32_t array_index() {
6153 ASSERT(is_array_index()); 6300 ASSERT(is_array_index());
6154 return array_index_; 6301 return array_index_;
6155 } 6302 }
6156 6303
6157 inline uint32_t GetHash(); 6304 inline uint32_t GetHash();
6158 6305
6159 int length_; 6306 int length_;
6160 uint32_t raw_running_hash_; 6307 uint32_t raw_running_hash_;
(...skipping 1360 matching lines...) Expand 10 before | Expand all | Expand 10 after
7521 // Bit positions in flag. 7668 // Bit positions in flag.
7522 static const int kAllCanReadBit = 0; 7669 static const int kAllCanReadBit = 0;
7523 static const int kAllCanWriteBit = 1; 7670 static const int kAllCanWriteBit = 1;
7524 static const int kProhibitsOverwritingBit = 2; 7671 static const int kProhibitsOverwritingBit = 2;
7525 class AttributesField: public BitField<PropertyAttributes, 3, 3> {}; 7672 class AttributesField: public BitField<PropertyAttributes, 3, 3> {};
7526 7673
7527 DISALLOW_IMPLICIT_CONSTRUCTORS(AccessorInfo); 7674 DISALLOW_IMPLICIT_CONSTRUCTORS(AccessorInfo);
7528 }; 7675 };
7529 7676
7530 7677
7678 // Support for JavaScript accessors: A pair of a getter and a setter. Each
7679 // accessor can either be
7680 // * a pointer to a JavaScript function or proxy: a real accessor
7681 // * undefined: considered an accessor by the spec, too, strangely enough
7682 // * the hole: an accessor which has not been set
7683 // * a pointer to a map: a transition used to ensure map sharing
7684 class AccessorPair: public Struct {
7685 public:
7686 DECL_ACCESSORS(getter, Object)
7687 DECL_ACCESSORS(setter, Object)
7688
7689 static inline AccessorPair* cast(Object* obj);
7690
7691 #ifdef OBJECT_PRINT
7692 void AccessorPairPrint(FILE* out = stdout);
7693 #endif
7694 #ifdef DEBUG
7695 void AccessorPairVerify();
7696 #endif
7697
7698 static const int kGetterOffset = HeapObject::kHeaderSize;
7699 static const int kSetterOffset = kGetterOffset + kPointerSize;
7700 static const int kSize = kSetterOffset + kPointerSize;
7701
7702 private:
7703 DISALLOW_IMPLICIT_CONSTRUCTORS(AccessorPair);
7704 };
7705
7706
7531 class AccessCheckInfo: public Struct { 7707 class AccessCheckInfo: public Struct {
7532 public: 7708 public:
7533 DECL_ACCESSORS(named_callback, Object) 7709 DECL_ACCESSORS(named_callback, Object)
7534 DECL_ACCESSORS(indexed_callback, Object) 7710 DECL_ACCESSORS(indexed_callback, Object)
7535 DECL_ACCESSORS(data, Object) 7711 DECL_ACCESSORS(data, Object)
7536 7712
7537 static inline AccessCheckInfo* cast(Object* obj); 7713 static inline AccessCheckInfo* cast(Object* obj);
7538 7714
7539 #ifdef OBJECT_PRINT 7715 #ifdef OBJECT_PRINT
7540 inline void AccessCheckInfoPrint() { 7716 inline void AccessCheckInfoPrint() {
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after
8015 } else { 8191 } else {
8016 value &= ~(1 << bit_position); 8192 value &= ~(1 << bit_position);
8017 } 8193 }
8018 return value; 8194 return value;
8019 } 8195 }
8020 }; 8196 };
8021 8197
8022 } } // namespace v8::internal 8198 } } // namespace v8::internal
8023 8199
8024 #endif // V8_OBJECTS_H_ 8200 #endif // V8_OBJECTS_H_
OLDNEW
« no previous file with comments | « src/mips/stub-cache-mips.cc ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698