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

Side by Side Diff: src/objects.h

Issue 8404030: Version 3.7.1 (Closed) Base URL: http://v8.googlecode.com/svn/trunk/
Patch Set: Created 9 years, 1 month 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/mksnapshot.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 22 matching lines...) Expand all
33 #include "list.h" 33 #include "list.h"
34 #include "smart-array-pointer.h" 34 #include "smart-array-pointer.h"
35 #include "unicode-inl.h" 35 #include "unicode-inl.h"
36 #if V8_TARGET_ARCH_ARM 36 #if V8_TARGET_ARCH_ARM
37 #include "arm/constants-arm.h" 37 #include "arm/constants-arm.h"
38 #elif V8_TARGET_ARCH_MIPS 38 #elif V8_TARGET_ARCH_MIPS
39 #include "mips/constants-mips.h" 39 #include "mips/constants-mips.h"
40 #endif 40 #endif
41 #include "v8checks.h" 41 #include "v8checks.h"
42 42
43
43 // 44 //
44 // Most object types in the V8 JavaScript are described in this file. 45 // Most object types in the V8 JavaScript are described in this file.
45 // 46 //
46 // Inheritance hierarchy: 47 // Inheritance hierarchy:
47 // - MaybeObject (an object or a failure) 48 // - MaybeObject (an object or a failure)
48 // - Failure (immediate for marking failed operation) 49 // - Failure (immediate for marking failed operation)
49 // - Object 50 // - Object
50 // - Smi (immediate small integer) 51 // - Smi (immediate small integer)
51 // - HeapObject (superclass for everything allocated in the heap) 52 // - HeapObject (superclass for everything allocated in the heap)
52 // - JSReceiver (suitable for property access) 53 // - JSReceiver (suitable for property access)
53 // - JSObject 54 // - JSObject
54 // - JSArray 55 // - JSArray
56 // - JSSet
57 // - JSMap
55 // - JSWeakMap 58 // - JSWeakMap
56 // - JSRegExp 59 // - JSRegExp
57 // - JSFunction 60 // - JSFunction
58 // - GlobalObject 61 // - GlobalObject
59 // - JSGlobalObject 62 // - JSGlobalObject
60 // - JSBuiltinsObject 63 // - JSBuiltinsObject
61 // - JSGlobalProxy 64 // - JSGlobalProxy
62 // - JSValue 65 // - JSValue
63 // - JSMessageObject 66 // - JSMessageObject
64 // - JSProxy 67 // - JSProxy
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 // Derived constants from ElementsKind 169 // Derived constants from ElementsKind
167 FIRST_EXTERNAL_ARRAY_ELEMENTS_KIND = EXTERNAL_BYTE_ELEMENTS, 170 FIRST_EXTERNAL_ARRAY_ELEMENTS_KIND = EXTERNAL_BYTE_ELEMENTS,
168 LAST_EXTERNAL_ARRAY_ELEMENTS_KIND = EXTERNAL_PIXEL_ELEMENTS, 171 LAST_EXTERNAL_ARRAY_ELEMENTS_KIND = EXTERNAL_PIXEL_ELEMENTS,
169 FIRST_ELEMENTS_KIND = FAST_SMI_ONLY_ELEMENTS, 172 FIRST_ELEMENTS_KIND = FAST_SMI_ONLY_ELEMENTS,
170 LAST_ELEMENTS_KIND = EXTERNAL_PIXEL_ELEMENTS 173 LAST_ELEMENTS_KIND = EXTERNAL_PIXEL_ELEMENTS
171 }; 174 };
172 175
173 static const int kElementsKindCount = 176 static const int kElementsKindCount =
174 LAST_ELEMENTS_KIND - FIRST_ELEMENTS_KIND + 1; 177 LAST_ELEMENTS_KIND - FIRST_ELEMENTS_KIND + 1;
175 178
179 void PrintElementsKind(FILE* out, ElementsKind kind);
180
176 // PropertyDetails captures type and attributes for a property. 181 // PropertyDetails captures type and attributes for a property.
177 // They are used both in property dictionaries and instance descriptors. 182 // They are used both in property dictionaries and instance descriptors.
178 class PropertyDetails BASE_EMBEDDED { 183 class PropertyDetails BASE_EMBEDDED {
179 public: 184 public:
180 PropertyDetails(PropertyAttributes attributes, 185 PropertyDetails(PropertyAttributes attributes,
181 PropertyType type, 186 PropertyType type,
182 int index = 0) { 187 int index = 0) {
183 ASSERT(TypeField::is_valid(type)); 188 ASSERT(TypeField::is_valid(type));
184 ASSERT(AttributesField::is_valid(attributes)); 189 ASSERT(AttributesField::is_valid(attributes));
185 ASSERT(StorageField::is_valid(index)); 190 ASSERT(StorageField::is_valid(index));
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after
621 JS_FUNCTION_PROXY_TYPE, // FIRST_JS_RECEIVER_TYPE, FIRST_JS_PROXY_TYPE 626 JS_FUNCTION_PROXY_TYPE, // FIRST_JS_RECEIVER_TYPE, FIRST_JS_PROXY_TYPE
622 JS_PROXY_TYPE, // LAST_JS_PROXY_TYPE 627 JS_PROXY_TYPE, // LAST_JS_PROXY_TYPE
623 628
624 JS_VALUE_TYPE, // FIRST_JS_OBJECT_TYPE 629 JS_VALUE_TYPE, // FIRST_JS_OBJECT_TYPE
625 JS_OBJECT_TYPE, 630 JS_OBJECT_TYPE,
626 JS_CONTEXT_EXTENSION_OBJECT_TYPE, 631 JS_CONTEXT_EXTENSION_OBJECT_TYPE,
627 JS_GLOBAL_OBJECT_TYPE, 632 JS_GLOBAL_OBJECT_TYPE,
628 JS_BUILTINS_OBJECT_TYPE, 633 JS_BUILTINS_OBJECT_TYPE,
629 JS_GLOBAL_PROXY_TYPE, 634 JS_GLOBAL_PROXY_TYPE,
630 JS_ARRAY_TYPE, 635 JS_ARRAY_TYPE,
636 JS_SET_TYPE,
637 JS_MAP_TYPE,
631 JS_WEAK_MAP_TYPE, 638 JS_WEAK_MAP_TYPE,
632 639
633 JS_REGEXP_TYPE, 640 JS_REGEXP_TYPE,
634 641
635 JS_FUNCTION_TYPE, // LAST_JS_OBJECT_TYPE, LAST_JS_RECEIVER_TYPE 642 JS_FUNCTION_TYPE, // LAST_JS_OBJECT_TYPE, LAST_JS_RECEIVER_TYPE
636 643
637 // Pseudo-types 644 // Pseudo-types
638 FIRST_TYPE = 0x0, 645 FIRST_TYPE = 0x0,
639 LAST_TYPE = JS_FUNCTION_TYPE, 646 LAST_TYPE = JS_FUNCTION_TYPE,
640 INVALID_TYPE = FIRST_TYPE - 1, 647 INVALID_TYPE = FIRST_TYPE - 1,
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
813 V(Oddball) \ 820 V(Oddball) \
814 V(SharedFunctionInfo) \ 821 V(SharedFunctionInfo) \
815 V(JSValue) \ 822 V(JSValue) \
816 V(JSMessageObject) \ 823 V(JSMessageObject) \
817 V(StringWrapper) \ 824 V(StringWrapper) \
818 V(Foreign) \ 825 V(Foreign) \
819 V(Boolean) \ 826 V(Boolean) \
820 V(JSArray) \ 827 V(JSArray) \
821 V(JSProxy) \ 828 V(JSProxy) \
822 V(JSFunctionProxy) \ 829 V(JSFunctionProxy) \
830 V(JSSet) \
831 V(JSMap) \
823 V(JSWeakMap) \ 832 V(JSWeakMap) \
824 V(JSRegExp) \ 833 V(JSRegExp) \
825 V(HashTable) \ 834 V(HashTable) \
826 V(Dictionary) \ 835 V(Dictionary) \
827 V(SymbolTable) \ 836 V(SymbolTable) \
828 V(JSFunctionResultCache) \ 837 V(JSFunctionResultCache) \
829 V(NormalizedMapCache) \ 838 V(NormalizedMapCache) \
830 V(CompilationCacheTable) \ 839 V(CompilationCacheTable) \
831 V(CodeCacheHashTable) \ 840 V(CodeCacheHashTable) \
832 V(PolymorphicCodeCacheHashTable) \ 841 V(PolymorphicCodeCacheHashTable) \
(...skipping 17 matching lines...) Expand all
850 // Since Smi and Failure are subclasses of Object no 859 // Since Smi and Failure are subclasses of Object no
851 // data members can be present in Object. 860 // data members can be present in Object.
852 class Object : public MaybeObject { 861 class Object : public MaybeObject {
853 public: 862 public:
854 // Type testing. 863 // Type testing.
855 #define IS_TYPE_FUNCTION_DECL(type_) inline bool Is##type_(); 864 #define IS_TYPE_FUNCTION_DECL(type_) inline bool Is##type_();
856 OBJECT_TYPE_LIST(IS_TYPE_FUNCTION_DECL) 865 OBJECT_TYPE_LIST(IS_TYPE_FUNCTION_DECL)
857 HEAP_OBJECT_TYPE_LIST(IS_TYPE_FUNCTION_DECL) 866 HEAP_OBJECT_TYPE_LIST(IS_TYPE_FUNCTION_DECL)
858 #undef IS_TYPE_FUNCTION_DECL 867 #undef IS_TYPE_FUNCTION_DECL
859 868
869 inline bool IsFixedArrayBase();
870
860 // Returns true if this object is an instance of the specified 871 // Returns true if this object is an instance of the specified
861 // function template. 872 // function template.
862 inline bool IsInstanceOf(FunctionTemplateInfo* type); 873 inline bool IsInstanceOf(FunctionTemplateInfo* type);
863 874
864 inline bool IsStruct(); 875 inline bool IsStruct();
865 #define DECLARE_STRUCT_PREDICATE(NAME, Name, name) inline bool Is##Name(); 876 #define DECLARE_STRUCT_PREDICATE(NAME, Name, name) inline bool Is##Name();
866 STRUCT_LIST(DECLARE_STRUCT_PREDICATE) 877 STRUCT_LIST(DECLARE_STRUCT_PREDICATE)
867 #undef DECLARE_STRUCT_PREDICATE 878 #undef DECLARE_STRUCT_PREDICATE
868 879
869 INLINE(bool IsSpecObject()); 880 INLINE(bool IsSpecObject());
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
905 916
906 // Property access. 917 // Property access.
907 MUST_USE_RESULT inline MaybeObject* GetProperty(String* key); 918 MUST_USE_RESULT inline MaybeObject* GetProperty(String* key);
908 MUST_USE_RESULT inline MaybeObject* GetProperty( 919 MUST_USE_RESULT inline MaybeObject* GetProperty(
909 String* key, 920 String* key,
910 PropertyAttributes* attributes); 921 PropertyAttributes* attributes);
911 MUST_USE_RESULT MaybeObject* GetPropertyWithReceiver( 922 MUST_USE_RESULT MaybeObject* GetPropertyWithReceiver(
912 Object* receiver, 923 Object* receiver,
913 String* key, 924 String* key,
914 PropertyAttributes* attributes); 925 PropertyAttributes* attributes);
926
927 static Handle<Object> GetProperty(Handle<Object> object,
928 Handle<Object> receiver,
929 LookupResult* result,
930 Handle<String> key,
931 PropertyAttributes* attributes);
932
915 MUST_USE_RESULT MaybeObject* GetProperty(Object* receiver, 933 MUST_USE_RESULT MaybeObject* GetProperty(Object* receiver,
916 LookupResult* result, 934 LookupResult* result,
917 String* key, 935 String* key,
918 PropertyAttributes* attributes); 936 PropertyAttributes* attributes);
937
919 MUST_USE_RESULT MaybeObject* GetPropertyWithDefinedGetter(Object* receiver, 938 MUST_USE_RESULT MaybeObject* GetPropertyWithDefinedGetter(Object* receiver,
920 JSReceiver* getter); 939 JSReceiver* getter);
921 940
941 static Handle<Object> GetElement(Handle<Object> object, uint32_t index);
922 inline MaybeObject* GetElement(uint32_t index); 942 inline MaybeObject* GetElement(uint32_t index);
923 // For use when we know that no exception can be thrown. 943 // For use when we know that no exception can be thrown.
924 inline Object* GetElementNoExceptionThrown(uint32_t index); 944 inline Object* GetElementNoExceptionThrown(uint32_t index);
925 MaybeObject* GetElementWithReceiver(Object* receiver, uint32_t index); 945 MaybeObject* GetElementWithReceiver(Object* receiver, uint32_t index);
926 946
927 // Return the object's prototype (might be Heap::null_value()). 947 // Return the object's prototype (might be Heap::null_value()).
928 Object* GetPrototype(); 948 Object* GetPrototype();
929 949
950 // Returns the permanent hash code associated with this object depending on
951 // the actual object type. Might return a failure in case no hash was
952 // created yet or GC was caused by creation.
953 MUST_USE_RESULT MaybeObject* GetHash(CreationFlag flag);
954
955 // Checks whether this object has the same value as the given one. This
956 // function is implemented according to ES5, section 9.12 and can be used
957 // to implement the Harmony "egal" function.
958 bool SameValue(Object* other);
959
930 // Tries to convert an object to an array index. Returns true and sets 960 // Tries to convert an object to an array index. Returns true and sets
931 // the output parameter if it succeeds. 961 // the output parameter if it succeeds.
932 inline bool ToArrayIndex(uint32_t* index); 962 inline bool ToArrayIndex(uint32_t* index);
933 963
934 // Returns true if this is a JSValue containing a string and the index is 964 // Returns true if this is a JSValue containing a string and the index is
935 // < the length of the string. Used to implement [] on strings. 965 // < the length of the string. Used to implement [] on strings.
936 inline bool IsStringObjectWithCharacterAt(uint32_t index); 966 inline bool IsStringObjectWithCharacterAt(uint32_t index);
937 967
938 #ifdef DEBUG 968 #ifdef DEBUG
939 // Verify a pointer is a valid object pointer. 969 // Verify a pointer is a valid object pointer.
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
1344 MUST_USE_RESULT MaybeObject* DeleteProperty(String* name, DeleteMode mode); 1374 MUST_USE_RESULT MaybeObject* DeleteProperty(String* name, DeleteMode mode);
1345 MUST_USE_RESULT MaybeObject* DeleteElement(uint32_t index, DeleteMode mode); 1375 MUST_USE_RESULT MaybeObject* DeleteElement(uint32_t index, DeleteMode mode);
1346 1376
1347 // Set the index'th array element. 1377 // Set the index'th array element.
1348 // Can cause GC, or return failure if GC is required. 1378 // Can cause GC, or return failure if GC is required.
1349 MUST_USE_RESULT MaybeObject* SetElement(uint32_t index, 1379 MUST_USE_RESULT MaybeObject* SetElement(uint32_t index,
1350 Object* value, 1380 Object* value,
1351 StrictModeFlag strict_mode, 1381 StrictModeFlag strict_mode,
1352 bool check_prototype); 1382 bool check_prototype);
1353 1383
1384 // Tests for the fast common case for property enumeration.
1385 bool IsSimpleEnum();
1386
1354 // Returns the class name ([[Class]] property in the specification). 1387 // Returns the class name ([[Class]] property in the specification).
1355 String* class_name(); 1388 String* class_name();
1356 1389
1357 // Returns the constructor name (the name (possibly, inferred name) of the 1390 // Returns the constructor name (the name (possibly, inferred name) of the
1358 // function that was used to instantiate the object). 1391 // function that was used to instantiate the object).
1359 String* constructor_name(); 1392 String* constructor_name();
1360 1393
1361 inline PropertyAttributes GetPropertyAttribute(String* name); 1394 inline PropertyAttributes GetPropertyAttribute(String* name);
1362 PropertyAttributes GetPropertyAttributeWithReceiver(JSReceiver* receiver, 1395 PropertyAttributes GetPropertyAttributeWithReceiver(JSReceiver* receiver,
1363 String* name); 1396 String* name);
1364 PropertyAttributes GetLocalPropertyAttribute(String* name); 1397 PropertyAttributes GetLocalPropertyAttribute(String* name);
1365 1398
1366 // Can cause a GC. 1399 // Can cause a GC.
1367 inline bool HasProperty(String* name); 1400 inline bool HasProperty(String* name);
1368 inline bool HasLocalProperty(String* name); 1401 inline bool HasLocalProperty(String* name);
1369 inline bool HasElement(uint32_t index); 1402 inline bool HasElement(uint32_t index);
1370 1403
1371 // Return the object's prototype (might be Heap::null_value()). 1404 // Return the object's prototype (might be Heap::null_value()).
1372 inline Object* GetPrototype(); 1405 inline Object* GetPrototype();
1373 1406
1374 // Set the object's prototype (only JSReceiver and null are allowed). 1407 // Set the object's prototype (only JSReceiver and null are allowed).
1375 MUST_USE_RESULT MaybeObject* SetPrototype(Object* value, 1408 MUST_USE_RESULT MaybeObject* SetPrototype(Object* value,
1376 bool skip_hidden_prototypes); 1409 bool skip_hidden_prototypes);
1377 1410
1378 // Retrieves a permanent object identity hash code. The undefined value might 1411 // Retrieves a permanent object identity hash code. The undefined value might
1379 // be returned in case no has been created yet and OMIT_CREATION was used. 1412 // be returned in case no hash was created yet and OMIT_CREATION was used.
1380 inline MUST_USE_RESULT MaybeObject* GetIdentityHash(CreationFlag flag); 1413 inline MUST_USE_RESULT MaybeObject* GetIdentityHash(CreationFlag flag);
1381 1414
1382 // Lookup a property. If found, the result is valid and has 1415 // Lookup a property. If found, the result is valid and has
1383 // detailed information. 1416 // detailed information.
1384 void LocalLookup(String* name, LookupResult* result); 1417 void LocalLookup(String* name, LookupResult* result);
1385 void Lookup(String* name, LookupResult* result); 1418 void Lookup(String* name, LookupResult* result);
1386 1419
1387 protected: 1420 protected:
1388 Smi* GenerateIdentityHash(); 1421 Smi* GenerateIdentityHash();
1389 1422
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
1596 void DeleteHiddenProperty(String* key); 1629 void DeleteHiddenProperty(String* key);
1597 // Returns true if the object has a property with the hidden symbol as name. 1630 // Returns true if the object has a property with the hidden symbol as name.
1598 bool HasHiddenProperties(); 1631 bool HasHiddenProperties();
1599 1632
1600 MUST_USE_RESULT MaybeObject* GetIdentityHash(CreationFlag flag); 1633 MUST_USE_RESULT MaybeObject* GetIdentityHash(CreationFlag flag);
1601 MUST_USE_RESULT MaybeObject* SetIdentityHash(Object* hash, CreationFlag flag); 1634 MUST_USE_RESULT MaybeObject* SetIdentityHash(Object* hash, CreationFlag flag);
1602 1635
1603 MUST_USE_RESULT MaybeObject* DeleteProperty(String* name, DeleteMode mode); 1636 MUST_USE_RESULT MaybeObject* DeleteProperty(String* name, DeleteMode mode);
1604 MUST_USE_RESULT MaybeObject* DeleteElement(uint32_t index, DeleteMode mode); 1637 MUST_USE_RESULT MaybeObject* DeleteElement(uint32_t index, DeleteMode mode);
1605 1638
1606 // Tests for the fast common case for property enumeration.
1607 bool IsSimpleEnum();
1608
1609 inline void ValidateSmiOnlyElements(); 1639 inline void ValidateSmiOnlyElements();
1610 1640
1611 // Makes sure that this object can contain non-smi Object as elements. 1641 // Makes sure that this object can contain non-smi Object as elements.
1612 inline MaybeObject* EnsureCanContainNonSmiElements(); 1642 inline MaybeObject* EnsureCanContainNonSmiElements();
1613 1643
1614 // Makes sure that this object can contain the specified elements. 1644 // Makes sure that this object can contain the specified elements.
1615 inline MaybeObject* EnsureCanContainElements(Object** elements, 1645 inline MaybeObject* EnsureCanContainElements(Object** elements,
1616 uint32_t count); 1646 uint32_t count);
1617 inline MaybeObject* EnsureCanContainElements(FixedArray* elements); 1647 inline MaybeObject* EnsureCanContainElements(FixedArray* elements);
1618 MaybeObject* EnsureCanContainElements(Arguments* arguments, 1648 MaybeObject* EnsureCanContainElements(Arguments* arguments,
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
1779 JSFunction* function, 1809 JSFunction* function,
1780 PropertyAttributes attributes); 1810 PropertyAttributes attributes);
1781 1811
1782 MUST_USE_RESULT MaybeObject* ReplaceSlowProperty( 1812 MUST_USE_RESULT MaybeObject* ReplaceSlowProperty(
1783 String* name, 1813 String* name,
1784 Object* value, 1814 Object* value,
1785 PropertyAttributes attributes); 1815 PropertyAttributes attributes);
1786 1816
1787 // Returns a new map with all transitions dropped from the object's current 1817 // Returns a new map with all transitions dropped from the object's current
1788 // map and the ElementsKind set. 1818 // map and the ElementsKind set.
1819 static Handle<Map> GetElementsTransitionMap(Handle<JSObject> object,
1820 ElementsKind to_kind);
1789 MUST_USE_RESULT MaybeObject* GetElementsTransitionMap( 1821 MUST_USE_RESULT MaybeObject* GetElementsTransitionMap(
1790 ElementsKind elements_kind); 1822 ElementsKind elements_kind);
1791 1823
1824 MUST_USE_RESULT MaybeObject* TransitionElementsKind(ElementsKind to_kind);
1825
1792 // Converts a descriptor of any other type to a real field, 1826 // Converts a descriptor of any other type to a real field,
1793 // backed by the properties array. Descriptors of visible 1827 // backed by the properties array. Descriptors of visible
1794 // types, such as CONSTANT_FUNCTION, keep their enumeration order. 1828 // types, such as CONSTANT_FUNCTION, keep their enumeration order.
1795 // Converts the descriptor on the original object's map to a 1829 // Converts the descriptor on the original object's map to a
1796 // map transition, and the the new field is on the object's new map. 1830 // map transition, and the the new field is on the object's new map.
1797 MUST_USE_RESULT MaybeObject* ConvertDescriptorToFieldAndMapTransition( 1831 MUST_USE_RESULT MaybeObject* ConvertDescriptorToFieldAndMapTransition(
1798 String* name, 1832 String* name,
1799 Object* new_value, 1833 Object* new_value,
1800 PropertyAttributes attributes); 1834 PropertyAttributes attributes);
1801 1835
(...skipping 26 matching lines...) Expand all
1828 // added this number can be indicated to have the backing store allocated to 1862 // added this number can be indicated to have the backing store allocated to
1829 // an initial capacity for holding these properties. 1863 // an initial capacity for holding these properties.
1830 MUST_USE_RESULT MaybeObject* NormalizeProperties( 1864 MUST_USE_RESULT MaybeObject* NormalizeProperties(
1831 PropertyNormalizationMode mode, 1865 PropertyNormalizationMode mode,
1832 int expected_additional_properties); 1866 int expected_additional_properties);
1833 1867
1834 // Convert and update the elements backing store to be a NumberDictionary 1868 // Convert and update the elements backing store to be a NumberDictionary
1835 // dictionary. Returns the backing after conversion. 1869 // dictionary. Returns the backing after conversion.
1836 MUST_USE_RESULT MaybeObject* NormalizeElements(); 1870 MUST_USE_RESULT MaybeObject* NormalizeElements();
1837 1871
1872 static void UpdateMapCodeCache(Handle<JSObject> object,
1873 Handle<String> name,
1874 Handle<Code> code);
1875
1838 MUST_USE_RESULT MaybeObject* UpdateMapCodeCache(String* name, Code* code); 1876 MUST_USE_RESULT MaybeObject* UpdateMapCodeCache(String* name, Code* code);
1839 1877
1840 // Transform slow named properties to fast variants. 1878 // Transform slow named properties to fast variants.
1841 // Returns failure if allocation failed. 1879 // Returns failure if allocation failed.
1842 MUST_USE_RESULT MaybeObject* TransformToFastProperties( 1880 MUST_USE_RESULT MaybeObject* TransformToFastProperties(
1843 int unused_property_fields); 1881 int unused_property_fields);
1844 1882
1845 // Access fast-case object properties at index. 1883 // Access fast-case object properties at index.
1846 inline Object* FastPropertyAt(int index); 1884 inline Object* FastPropertyAt(int index);
1847 inline Object* FastPropertyAtPut(int index, Object* value); 1885 inline Object* FastPropertyAtPut(int index, Object* value);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1889 PrintProperties(stdout); 1927 PrintProperties(stdout);
1890 } 1928 }
1891 void PrintProperties(FILE* out); 1929 void PrintProperties(FILE* out);
1892 1930
1893 inline void PrintElements() { 1931 inline void PrintElements() {
1894 PrintElements(stdout); 1932 PrintElements(stdout);
1895 } 1933 }
1896 void PrintElements(FILE* out); 1934 void PrintElements(FILE* out);
1897 #endif 1935 #endif
1898 1936
1937 void PrintElementsTransition(
1938 FILE* file, ElementsKind from_kind, FixedArrayBase* from_elements,
1939 ElementsKind to_kind, FixedArrayBase* to_elements);
1940
1899 #ifdef DEBUG 1941 #ifdef DEBUG
1900 // Structure for collecting spill information about JSObjects. 1942 // Structure for collecting spill information about JSObjects.
1901 class SpillInformation { 1943 class SpillInformation {
1902 public: 1944 public:
1903 void Clear(); 1945 void Clear();
1904 void Print(); 1946 void Print();
1905 int number_of_objects_; 1947 int number_of_objects_;
1906 int number_of_objects_with_fast_properties_; 1948 int number_of_objects_with_fast_properties_;
1907 int number_of_objects_with_fast_elements_; 1949 int number_of_objects_with_fast_elements_;
1908 int number_of_fast_used_fields_; 1950 int number_of_fast_used_fields_;
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
2155 class BodyDescriptor : public FlexibleBodyDescriptor<kHeaderSize> { 2197 class BodyDescriptor : public FlexibleBodyDescriptor<kHeaderSize> {
2156 public: 2198 public:
2157 static inline int SizeOf(Map* map, HeapObject* object) { 2199 static inline int SizeOf(Map* map, HeapObject* object) {
2158 return SizeFor(reinterpret_cast<FixedArray*>(object)->length()); 2200 return SizeFor(reinterpret_cast<FixedArray*>(object)->length());
2159 } 2201 }
2160 }; 2202 };
2161 2203
2162 protected: 2204 protected:
2163 // Set operation on FixedArray without using write barriers. Can 2205 // Set operation on FixedArray without using write barriers. Can
2164 // only be used for storing old space objects or smis. 2206 // only be used for storing old space objects or smis.
2165 static inline void fast_set(FixedArray* array, int index, Object* value); 2207 static inline void NoWriteBarrierSet(FixedArray* array,
2208 int index,
2209 Object* value);
2166 2210
2167 private: 2211 private:
2168 DISALLOW_IMPLICIT_CONSTRUCTORS(FixedArray); 2212 DISALLOW_IMPLICIT_CONSTRUCTORS(FixedArray);
2169 }; 2213 };
2170 2214
2171 2215
2172 // FixedDoubleArray describes fixed-sized arrays with element type double. 2216 // FixedDoubleArray describes fixed-sized arrays with element type double.
2173 class FixedDoubleArray: public FixedArrayBase { 2217 class FixedDoubleArray: public FixedArrayBase {
2174 public: 2218 public:
2175 inline void Initialize(FixedArray* from); 2219 inline void Initialize(FixedArray* from);
2176 inline void Initialize(FixedDoubleArray* from); 2220 inline void Initialize(FixedDoubleArray* from);
2177 inline void Initialize(NumberDictionary* from); 2221 inline void Initialize(NumberDictionary* from);
2178 2222
2179 // Setter and getter for elements. 2223 // Setter and getter for elements.
2180 inline double get_scalar(int index); 2224 inline double get_scalar(int index);
2181 inline MaybeObject* get(int index); 2225 inline MaybeObject* get(int index);
2182 inline void set(int index, double value); 2226 inline void set(int index, double value);
2183 inline void set_the_hole(int index); 2227 inline void set_the_hole(int index);
2184 2228
2185 // Checking for the hole. 2229 // Checking for the hole.
2186 inline bool is_the_hole(int index); 2230 inline bool is_the_hole(int index);
2187 2231
2232 // Copy operations
2233 MUST_USE_RESULT inline MaybeObject* Copy();
2234
2188 // Garbage collection support. 2235 // Garbage collection support.
2189 inline static int SizeFor(int length) { 2236 inline static int SizeFor(int length) {
2190 return kHeaderSize + length * kDoubleSize; 2237 return kHeaderSize + length * kDoubleSize;
2191 } 2238 }
2192 2239
2193 // Code Generation support. 2240 // Code Generation support.
2194 static int OffsetOfElementAt(int index) { return SizeFor(index); } 2241 static int OffsetOfElementAt(int index) { return SizeFor(index); }
2195 2242
2196 inline static bool is_the_hole_nan(double value); 2243 inline static bool is_the_hole_nan(double value);
2197 inline static double hole_nan_as_double(); 2244 inline static double hole_nan_as_double();
(...skipping 19 matching lines...) Expand all
2217 2264
2218 #ifdef DEBUG 2265 #ifdef DEBUG
2219 void FixedDoubleArrayVerify(); 2266 void FixedDoubleArrayVerify();
2220 #endif 2267 #endif
2221 2268
2222 private: 2269 private:
2223 DISALLOW_IMPLICIT_CONSTRUCTORS(FixedDoubleArray); 2270 DISALLOW_IMPLICIT_CONSTRUCTORS(FixedDoubleArray);
2224 }; 2271 };
2225 2272
2226 2273
2274 class IncrementalMarking;
2275
2276
2227 // DescriptorArrays are fixed arrays used to hold instance descriptors. 2277 // DescriptorArrays are fixed arrays used to hold instance descriptors.
2228 // The format of the these objects is: 2278 // The format of the these objects is:
2229 // TODO(1399): It should be possible to make room for bit_field3 in the map 2279 // TODO(1399): It should be possible to make room for bit_field3 in the map
2230 // without overloading the instance descriptors field in the map 2280 // without overloading the instance descriptors field in the map
2231 // (and storing it in the DescriptorArray when the map has one). 2281 // (and storing it in the DescriptorArray when the map has one).
2232 // [0]: storage for bit_field3 for Map owning this object (Smi) 2282 // [0]: storage for bit_field3 for Map owning this object (Smi)
2233 // [1]: point to a fixed array with (value, detail) pairs. 2283 // [1]: point to a fixed array with (value, detail) pairs.
2234 // [2]: next enumeration index (Smi), or pointer to small fixed array: 2284 // [2]: next enumeration index (Smi), or pointer to small fixed array:
2235 // [0]: next enumeration index (Smi) 2285 // [0]: next enumeration index (Smi)
2236 // [1]: pointer to fixed array with enum cache 2286 // [1]: pointer to fixed array with enum cache
(...skipping 21 matching lines...) Expand all
2258 return Smi::cast(obj)->value(); 2308 return Smi::cast(obj)->value();
2259 } else { 2309 } else {
2260 Object* index = FixedArray::cast(obj)->get(kEnumCacheBridgeEnumIndex); 2310 Object* index = FixedArray::cast(obj)->get(kEnumCacheBridgeEnumIndex);
2261 return Smi::cast(index)->value(); 2311 return Smi::cast(index)->value();
2262 } 2312 }
2263 } 2313 }
2264 2314
2265 // Set next enumeration index and flush any enum cache. 2315 // Set next enumeration index and flush any enum cache.
2266 void SetNextEnumerationIndex(int value) { 2316 void SetNextEnumerationIndex(int value) {
2267 if (!IsEmpty()) { 2317 if (!IsEmpty()) {
2268 fast_set(this, kEnumerationIndexIndex, Smi::FromInt(value)); 2318 set(kEnumerationIndexIndex, Smi::FromInt(value));
2269 } 2319 }
2270 } 2320 }
2271 bool HasEnumCache() { 2321 bool HasEnumCache() {
2272 return !IsEmpty() && !get(kEnumerationIndexIndex)->IsSmi(); 2322 return !IsEmpty() && !get(kEnumerationIndexIndex)->IsSmi();
2273 } 2323 }
2274 2324
2275 Object* GetEnumCache() { 2325 Object* GetEnumCache() {
2276 ASSERT(HasEnumCache()); 2326 ASSERT(HasEnumCache());
2277 FixedArray* bridge = FixedArray::cast(get(kEnumerationIndexIndex)); 2327 FixedArray* bridge = FixedArray::cast(get(kEnumerationIndexIndex));
2278 return bridge->get(kEnumCacheBridgeCacheIndex); 2328 return bridge->get(kEnumCacheBridgeCacheIndex);
(...skipping 16 matching lines...) Expand all
2295 inline PropertyType GetType(int descriptor_number); 2345 inline PropertyType GetType(int descriptor_number);
2296 inline int GetFieldIndex(int descriptor_number); 2346 inline int GetFieldIndex(int descriptor_number);
2297 inline JSFunction* GetConstantFunction(int descriptor_number); 2347 inline JSFunction* GetConstantFunction(int descriptor_number);
2298 inline Object* GetCallbacksObject(int descriptor_number); 2348 inline Object* GetCallbacksObject(int descriptor_number);
2299 inline AccessorDescriptor* GetCallbacks(int descriptor_number); 2349 inline AccessorDescriptor* GetCallbacks(int descriptor_number);
2300 inline bool IsProperty(int descriptor_number); 2350 inline bool IsProperty(int descriptor_number);
2301 inline bool IsTransition(int descriptor_number); 2351 inline bool IsTransition(int descriptor_number);
2302 inline bool IsNullDescriptor(int descriptor_number); 2352 inline bool IsNullDescriptor(int descriptor_number);
2303 inline bool IsDontEnum(int descriptor_number); 2353 inline bool IsDontEnum(int descriptor_number);
2304 2354
2355 class WhitenessWitness {
2356 public:
2357 inline explicit WhitenessWitness(DescriptorArray* array);
2358 inline ~WhitenessWitness();
2359
2360 private:
2361 IncrementalMarking* marking_;
2362 };
2363
2305 // Accessor for complete descriptor. 2364 // Accessor for complete descriptor.
2306 inline void Get(int descriptor_number, Descriptor* desc); 2365 inline void Get(int descriptor_number, Descriptor* desc);
2307 inline void Set(int descriptor_number, Descriptor* desc); 2366 inline void Set(int descriptor_number,
2367 Descriptor* desc,
2368 const WhitenessWitness&);
2308 2369
2309 // Transfer complete descriptor from another descriptor array to 2370 // Transfer complete descriptor from another descriptor array to
2310 // this one. 2371 // this one.
2311 inline void CopyFrom(int index, DescriptorArray* src, int src_index); 2372 inline void CopyFrom(int index,
2373 DescriptorArray* src,
2374 int src_index,
2375 const WhitenessWitness&);
2312 2376
2313 // Copy the descriptor array, insert a new descriptor and optionally 2377 // Copy the descriptor array, insert a new descriptor and optionally
2314 // remove map transitions. If the descriptor is already present, it is 2378 // remove map transitions. If the descriptor is already present, it is
2315 // replaced. If a replaced descriptor is a real property (not a transition 2379 // replaced. If a replaced descriptor is a real property (not a transition
2316 // or null), its enumeration index is kept as is. 2380 // or null), its enumeration index is kept as is.
2317 // If adding a real property, map transitions must be removed. If adding 2381 // If adding a real property, map transitions must be removed. If adding
2318 // a transition, they must not be removed. All null descriptors are removed. 2382 // a transition, they must not be removed. All null descriptors are removed.
2319 MUST_USE_RESULT MaybeObject* CopyInsert(Descriptor* descriptor, 2383 MUST_USE_RESULT MaybeObject* CopyInsert(Descriptor* descriptor,
2320 TransitionFlag transition_flag); 2384 TransitionFlag transition_flag);
2321 2385
2322 // Remove all transitions. Return a copy of the array with all transitions 2386 // Remove all transitions. Return a copy of the array with all transitions
2323 // removed, or a Failure object if the new array could not be allocated. 2387 // removed, or a Failure object if the new array could not be allocated.
2324 MUST_USE_RESULT MaybeObject* RemoveTransitions(); 2388 MUST_USE_RESULT MaybeObject* RemoveTransitions();
2325 2389
2326 // Sort the instance descriptors by the hash codes of their keys. 2390 // Sort the instance descriptors by the hash codes of their keys.
2327 // Does not check for duplicates. 2391 // Does not check for duplicates.
2328 void SortUnchecked(); 2392 void SortUnchecked(const WhitenessWitness&);
2329 2393
2330 // Sort the instance descriptors by the hash codes of their keys. 2394 // Sort the instance descriptors by the hash codes of their keys.
2331 // Checks the result for duplicates. 2395 // Checks the result for duplicates.
2332 void Sort(); 2396 void Sort(const WhitenessWitness&);
2333 2397
2334 // Search the instance descriptors for given name. 2398 // Search the instance descriptors for given name.
2335 inline int Search(String* name); 2399 inline int Search(String* name);
2336 2400
2337 // As the above, but uses DescriptorLookupCache and updates it when 2401 // As the above, but uses DescriptorLookupCache and updates it when
2338 // necessary. 2402 // necessary.
2339 inline int SearchWithCache(String* name); 2403 inline int SearchWithCache(String* name);
2340 2404
2341 // Tells whether the name is present int the array. 2405 // Tells whether the name is present int the array.
2342 bool Contains(String* name) { return kNotFound != Search(name); } 2406 bool Contains(String* name) { return kNotFound != Search(name); }
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
2415 2479
2416 static int ToValueIndex(int descriptor_number) { 2480 static int ToValueIndex(int descriptor_number) {
2417 return descriptor_number << 1; 2481 return descriptor_number << 1;
2418 } 2482 }
2419 2483
2420 bool is_null_descriptor(int descriptor_number) { 2484 bool is_null_descriptor(int descriptor_number) {
2421 return PropertyDetails(GetDetails(descriptor_number)).type() == 2485 return PropertyDetails(GetDetails(descriptor_number)).type() ==
2422 NULL_DESCRIPTOR; 2486 NULL_DESCRIPTOR;
2423 } 2487 }
2424 // Swap operation on FixedArray without using write barriers. 2488 // Swap operation on FixedArray without using write barriers.
2425 static inline void fast_swap(FixedArray* array, int first, int second); 2489 static inline void NoWriteBarrierSwap(FixedArray* array,
2490 int first,
2491 int second);
2426 2492
2427 // Swap descriptor first and second. 2493 // Swap descriptor first and second.
2428 inline void Swap(int first, int second); 2494 inline void NoWriteBarrierSwapDescriptors(int first, int second);
2429 2495
2430 FixedArray* GetContentArray() { 2496 FixedArray* GetContentArray() {
2431 return FixedArray::cast(get(kContentArrayIndex)); 2497 return FixedArray::cast(get(kContentArrayIndex));
2432 } 2498 }
2433 DISALLOW_IMPLICIT_CONSTRUCTORS(DescriptorArray); 2499 DISALLOW_IMPLICIT_CONSTRUCTORS(DescriptorArray);
2434 }; 2500 };
2435 2501
2436 2502
2437 // HashTable is a subclass of FixedArray that implements a hash table 2503 // HashTable is a subclass of FixedArray that implements a hash table
2438 // that uses open addressing and quadratic probing. 2504 // that uses open addressing and quadratic probing.
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
2560 // has the given hash value. 2626 // has the given hash value.
2561 uint32_t FindInsertionEntry(uint32_t hash); 2627 uint32_t FindInsertionEntry(uint32_t hash);
2562 2628
2563 // Returns the index for an entry (of the key) 2629 // Returns the index for an entry (of the key)
2564 static inline int EntryToIndex(int entry) { 2630 static inline int EntryToIndex(int entry) {
2565 return (entry * kEntrySize) + kElementsStartIndex; 2631 return (entry * kEntrySize) + kElementsStartIndex;
2566 } 2632 }
2567 2633
2568 // Update the number of elements in the hash table. 2634 // Update the number of elements in the hash table.
2569 void SetNumberOfElements(int nof) { 2635 void SetNumberOfElements(int nof) {
2570 fast_set(this, kNumberOfElementsIndex, Smi::FromInt(nof)); 2636 set(kNumberOfElementsIndex, Smi::FromInt(nof));
2571 } 2637 }
2572 2638
2573 // Update the number of deleted elements in the hash table. 2639 // Update the number of deleted elements in the hash table.
2574 void SetNumberOfDeletedElements(int nod) { 2640 void SetNumberOfDeletedElements(int nod) {
2575 fast_set(this, kNumberOfDeletedElementsIndex, Smi::FromInt(nod)); 2641 set(kNumberOfDeletedElementsIndex, Smi::FromInt(nod));
2576 } 2642 }
2577 2643
2578 // Sets the capacity of the hash table. 2644 // Sets the capacity of the hash table.
2579 void SetCapacity(int capacity) { 2645 void SetCapacity(int capacity) {
2580 // To scale a computed hash code to fit within the hash table, we 2646 // To scale a computed hash code to fit within the hash table, we
2581 // use bit-wise AND with a mask, so the capacity must be positive 2647 // use bit-wise AND with a mask, so the capacity must be positive
2582 // and non-zero. 2648 // and non-zero.
2583 ASSERT(capacity > 0); 2649 ASSERT(capacity > 0);
2584 ASSERT(capacity <= kMaxCapacity); 2650 ASSERT(capacity <= kMaxCapacity);
2585 fast_set(this, kCapacityIndex, Smi::FromInt(capacity)); 2651 set(kCapacityIndex, Smi::FromInt(capacity));
2586 } 2652 }
2587 2653
2588 2654
2589 // Returns probe entry. 2655 // Returns probe entry.
2590 static uint32_t GetProbe(uint32_t hash, uint32_t number, uint32_t size) { 2656 static uint32_t GetProbe(uint32_t hash, uint32_t number, uint32_t size) {
2591 ASSERT(IsPowerOf2(size)); 2657 ASSERT(IsPowerOf2(size));
2592 return (hash + GetProbeOffset(number)) & (size - 1); 2658 return (hash + GetProbeOffset(number)) & (size - 1);
2593 } 2659 }
2594 2660
2595 static uint32_t FirstProbe(uint32_t hash, uint32_t size) { 2661 static uint32_t FirstProbe(uint32_t hash, uint32_t size) {
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
2783 enum SortMode { UNSORTED, SORTED }; 2849 enum SortMode { UNSORTED, SORTED };
2784 // Copies keys to preallocated fixed array. 2850 // Copies keys to preallocated fixed array.
2785 void CopyKeysTo(FixedArray* storage, 2851 void CopyKeysTo(FixedArray* storage,
2786 PropertyAttributes filter, 2852 PropertyAttributes filter,
2787 SortMode sort_mode); 2853 SortMode sort_mode);
2788 // Fill in details for properties into storage. 2854 // Fill in details for properties into storage.
2789 void CopyKeysTo(FixedArray* storage, int index, SortMode sort_mode); 2855 void CopyKeysTo(FixedArray* storage, int index, SortMode sort_mode);
2790 2856
2791 // Accessors for next enumeration index. 2857 // Accessors for next enumeration index.
2792 void SetNextEnumerationIndex(int index) { 2858 void SetNextEnumerationIndex(int index) {
2793 this->fast_set(this, kNextEnumerationIndexIndex, Smi::FromInt(index)); 2859 this->set(kNextEnumerationIndexIndex, Smi::FromInt(index));
2794 } 2860 }
2795 2861
2796 int NextEnumerationIndex() { 2862 int NextEnumerationIndex() {
2797 return Smi::cast(FixedArray::get(kNextEnumerationIndexIndex))->value(); 2863 return Smi::cast(FixedArray::get(kNextEnumerationIndexIndex))->value();
2798 } 2864 }
2799 2865
2800 // Returns a new array for dictionary usage. Might return Failure. 2866 // Returns a new array for dictionary usage. Might return Failure.
2801 MUST_USE_RESULT static MaybeObject* Allocate(int at_least_space_for); 2867 MUST_USE_RESULT static MaybeObject* Allocate(int at_least_space_for);
2802 2868
2803 // Ensure enough space for n additional elements. 2869 // Ensure enough space for n additional elements.
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
2924 // Remove all entries were key is a number and (from <= key && key < to). 2990 // Remove all entries were key is a number and (from <= key && key < to).
2925 void RemoveNumberEntries(uint32_t from, uint32_t to); 2991 void RemoveNumberEntries(uint32_t from, uint32_t to);
2926 2992
2927 // Bit masks. 2993 // Bit masks.
2928 static const int kRequiresSlowElementsMask = 1; 2994 static const int kRequiresSlowElementsMask = 1;
2929 static const int kRequiresSlowElementsTagSize = 1; 2995 static const int kRequiresSlowElementsTagSize = 1;
2930 static const uint32_t kRequiresSlowElementsLimit = (1 << 29) - 1; 2996 static const uint32_t kRequiresSlowElementsLimit = (1 << 29) - 1;
2931 }; 2997 };
2932 2998
2933 2999
3000 template <int entrysize>
2934 class ObjectHashTableShape { 3001 class ObjectHashTableShape {
2935 public: 3002 public:
2936 static inline bool IsMatch(JSReceiver* key, Object* other); 3003 static inline bool IsMatch(Object* key, Object* other);
2937 static inline uint32_t Hash(JSReceiver* key); 3004 static inline uint32_t Hash(Object* key);
2938 static inline uint32_t HashForObject(JSReceiver* key, Object* object); 3005 static inline uint32_t HashForObject(Object* key, Object* object);
2939 MUST_USE_RESULT static inline MaybeObject* AsObject(JSReceiver* key); 3006 MUST_USE_RESULT static inline MaybeObject* AsObject(Object* key);
2940 static const int kPrefixSize = 0; 3007 static const int kPrefixSize = 0;
2941 static const int kEntrySize = 2; 3008 static const int kEntrySize = entrysize;
2942 }; 3009 };
2943 3010
2944 3011
2945 // ObjectHashTable maps keys that are JavaScript objects to object values by 3012 // ObjectHashSet holds keys that are arbitrary objects by using the identity
3013 // hash of the key for hashing purposes.
3014 class ObjectHashSet: public HashTable<ObjectHashTableShape<1>, Object*> {
3015 public:
3016 static inline ObjectHashSet* cast(Object* obj) {
3017 ASSERT(obj->IsHashTable());
3018 return reinterpret_cast<ObjectHashSet*>(obj);
3019 }
3020
3021 // Looks up whether the given key is part of this hash set.
3022 bool Contains(Object* key);
3023
3024 // Adds the given key to this hash set.
3025 MUST_USE_RESULT MaybeObject* Add(Object* key);
3026
3027 // Removes the given key from this hash set.
3028 MUST_USE_RESULT MaybeObject* Remove(Object* key);
3029 };
3030
3031
3032 // ObjectHashTable maps keys that are arbitrary objects to object values by
2946 // using the identity hash of the key for hashing purposes. 3033 // using the identity hash of the key for hashing purposes.
2947 class ObjectHashTable: public HashTable<ObjectHashTableShape, JSReceiver*> { 3034 class ObjectHashTable: public HashTable<ObjectHashTableShape<2>, Object*> {
2948 public: 3035 public:
2949 static inline ObjectHashTable* cast(Object* obj) { 3036 static inline ObjectHashTable* cast(Object* obj) {
2950 ASSERT(obj->IsHashTable()); 3037 ASSERT(obj->IsHashTable());
2951 return reinterpret_cast<ObjectHashTable*>(obj); 3038 return reinterpret_cast<ObjectHashTable*>(obj);
2952 } 3039 }
2953 3040
2954 // Looks up the value associated with the given key. The undefined value is 3041 // Looks up the value associated with the given key. The undefined value is
2955 // returned in case the key is not present. 3042 // returned in case the key is not present.
2956 Object* Lookup(JSReceiver* key); 3043 Object* Lookup(Object* key);
2957 3044
2958 // Adds (or overwrites) the value associated with the given key. Mapping a 3045 // Adds (or overwrites) the value associated with the given key. Mapping a
2959 // key to the undefined value causes removal of the whole entry. 3046 // key to the undefined value causes removal of the whole entry.
2960 MUST_USE_RESULT MaybeObject* Put(JSReceiver* key, Object* value); 3047 MUST_USE_RESULT MaybeObject* Put(Object* key, Object* value);
2961 3048
2962 private: 3049 private:
2963 friend class MarkCompactCollector; 3050 friend class MarkCompactCollector;
2964 3051
2965 void AddEntry(int entry, JSReceiver* key, Object* value); 3052 void AddEntry(int entry, Object* key, Object* value);
2966 void RemoveEntry(int entry, Heap* heap); 3053 void RemoveEntry(int entry, Heap* heap);
2967 inline void RemoveEntry(int entry); 3054 inline void RemoveEntry(int entry);
2968 3055
2969 // Returns the index to the value of an entry. 3056 // Returns the index to the value of an entry.
2970 static inline int EntryToValueIndex(int entry) { 3057 static inline int EntryToValueIndex(int entry) {
2971 return EntryToIndex(entry) + 1; 3058 return EntryToIndex(entry) + 1;
2972 } 3059 }
2973 }; 3060 };
2974 3061
2975 3062
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
3013 3100
3014 // This object provides quick access to scope info details for runtime 3101 // This object provides quick access to scope info details for runtime
3015 // routines w/o the need to explicitly create a ScopeInfo object. 3102 // routines w/o the need to explicitly create a ScopeInfo object.
3016 class SerializedScopeInfo : public FixedArray { 3103 class SerializedScopeInfo : public FixedArray {
3017 public : 3104 public :
3018 static SerializedScopeInfo* cast(Object* object) { 3105 static SerializedScopeInfo* cast(Object* object) {
3019 ASSERT(object->IsSerializedScopeInfo()); 3106 ASSERT(object->IsSerializedScopeInfo());
3020 return reinterpret_cast<SerializedScopeInfo*>(object); 3107 return reinterpret_cast<SerializedScopeInfo*>(object);
3021 } 3108 }
3022 3109
3110 // Return the type of this scope.
3111 ScopeType Type();
3112
3023 // Does this scope call eval? 3113 // Does this scope call eval?
3024 bool CallsEval(); 3114 bool CallsEval();
3025 3115
3026 // Is this scope a strict mode scope? 3116 // Is this scope a strict mode scope?
3027 bool IsStrictMode(); 3117 bool IsStrictMode();
3028 3118
3029 // Return the number of stack slots for code. 3119 // Return the number of stack slots for code.
3030 int NumberOfStackSlots(); 3120 int NumberOfStackSlots();
3031 3121
3032 // Return the number of context slots for code. 3122 // Return the number of context slots for code.
3033 int NumberOfContextSlots(); 3123 int NumberOfContextSlots();
3034 3124
3035 // Return if this has context slots besides MIN_CONTEXT_SLOTS; 3125 // Return if this has context slots besides MIN_CONTEXT_SLOTS;
3036 bool HasHeapAllocatedLocals(); 3126 bool HasHeapAllocatedLocals();
3037 3127
3128 // Return if contexts are allocated for this scope.
3129 bool HasContext();
3130
3038 // Lookup support for serialized scope info. Returns the 3131 // Lookup support for serialized scope info. Returns the
3039 // the stack slot index for a given slot name if the slot is 3132 // the stack slot index for a given slot name if the slot is
3040 // present; otherwise returns a value < 0. The name must be a symbol 3133 // present; otherwise returns a value < 0. The name must be a symbol
3041 // (canonicalized). 3134 // (canonicalized).
3042 int StackSlotIndex(String* name); 3135 int StackSlotIndex(String* name);
3043 3136
3044 // Lookup support for serialized scope info. Returns the 3137 // Lookup support for serialized scope info. Returns the
3045 // context slot index for a given slot name if the slot is present; otherwise 3138 // context slot index for a given slot name if the slot is present; otherwise
3046 // returns a value < 0. The name must be a symbol (canonicalized). 3139 // returns a value < 0. The name must be a symbol (canonicalized).
3047 // If the slot is present and mode != NULL, sets *mode to the corresponding 3140 // If the slot is present and mode != NULL, sets *mode to the corresponding
3048 // mode for that variable. 3141 // mode for that variable.
3049 int ContextSlotIndex(String* name, VariableMode* mode); 3142 int ContextSlotIndex(String* name, VariableMode* mode);
3050 3143
3051 // Lookup support for serialized scope info. Returns the 3144 // Lookup support for serialized scope info. Returns the
3052 // parameter index for a given parameter name if the parameter is present; 3145 // parameter index for a given parameter name if the parameter is present;
3053 // otherwise returns a value < 0. The name must be a symbol (canonicalized). 3146 // otherwise returns a value < 0. The name must be a symbol (canonicalized).
3054 int ParameterIndex(String* name); 3147 int ParameterIndex(String* name);
3055 3148
3056 // Lookup support for serialized scope info. Returns the 3149 // Lookup support for serialized scope info. Returns the
3057 // function context slot index if the function name is present (named 3150 // function context slot index if the function name is present (named
3058 // function expressions, only), otherwise returns a value < 0. The name 3151 // function expressions, only), otherwise returns a value < 0. The name
3059 // must be a symbol (canonicalized). 3152 // must be a symbol (canonicalized).
3060 int FunctionContextSlotIndex(String* name); 3153 int FunctionContextSlotIndex(String* name, VariableMode* mode);
3061 3154
3062 static Handle<SerializedScopeInfo> Create(Scope* scope); 3155 static Handle<SerializedScopeInfo> Create(Scope* scope);
3063 3156
3064 // Serializes empty scope info. 3157 // Serializes empty scope info.
3065 static SerializedScopeInfo* Empty(); 3158 static SerializedScopeInfo* Empty();
3066 3159
3067 private: 3160 private:
3068 Object** ContextEntriesAddr(); 3161 Object** ContextEntriesAddr();
3069 3162
3070 Object** ParameterEntriesAddr(); 3163 Object** ParameterEntriesAddr();
(...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after
3739 // [has_deoptimization_support]: For FUNCTION kind, tells if it has 3832 // [has_deoptimization_support]: For FUNCTION kind, tells if it has
3740 // deoptimization support. 3833 // deoptimization support.
3741 inline bool has_deoptimization_support(); 3834 inline bool has_deoptimization_support();
3742 inline void set_has_deoptimization_support(bool value); 3835 inline void set_has_deoptimization_support(bool value);
3743 3836
3744 // [has_debug_break_slots]: For FUNCTION kind, tells if it has 3837 // [has_debug_break_slots]: For FUNCTION kind, tells if it has
3745 // been compiled with debug break slots. 3838 // been compiled with debug break slots.
3746 inline bool has_debug_break_slots(); 3839 inline bool has_debug_break_slots();
3747 inline void set_has_debug_break_slots(bool value); 3840 inline void set_has_debug_break_slots(bool value);
3748 3841
3842 // [compiled_with_optimizing]: For FUNCTION kind, tells if it has
3843 // been compiled with IsOptimizing set to true.
3844 inline bool is_compiled_optimizable();
3845 inline void set_compiled_optimizable(bool value);
3846
3749 // [allow_osr_at_loop_nesting_level]: For FUNCTION kind, tells for 3847 // [allow_osr_at_loop_nesting_level]: For FUNCTION kind, tells for
3750 // how long the function has been marked for OSR and therefore which 3848 // how long the function has been marked for OSR and therefore which
3751 // level of loop nesting we are willing to do on-stack replacement 3849 // level of loop nesting we are willing to do on-stack replacement
3752 // for. 3850 // for.
3753 inline void set_allow_osr_at_loop_nesting_level(int level); 3851 inline void set_allow_osr_at_loop_nesting_level(int level);
3754 inline int allow_osr_at_loop_nesting_level(); 3852 inline int allow_osr_at_loop_nesting_level();
3755 3853
3756 // [stack_slots]: For kind OPTIMIZED_FUNCTION, the number of stack slots 3854 // [stack_slots]: For kind OPTIMIZED_FUNCTION, the number of stack slots
3757 // reserved in the code prologue. 3855 // reserved in the code prologue.
3758 inline unsigned stack_slots(); 3856 inline unsigned stack_slots();
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
3934 static const int kUnaryOpTypeOffset = kStubMajorKeyOffset + 1; 4032 static const int kUnaryOpTypeOffset = kStubMajorKeyOffset + 1;
3935 static const int kBinaryOpTypeOffset = kStubMajorKeyOffset + 1; 4033 static const int kBinaryOpTypeOffset = kStubMajorKeyOffset + 1;
3936 static const int kCompareStateOffset = kStubMajorKeyOffset + 1; 4034 static const int kCompareStateOffset = kStubMajorKeyOffset + 1;
3937 static const int kToBooleanTypeOffset = kStubMajorKeyOffset + 1; 4035 static const int kToBooleanTypeOffset = kStubMajorKeyOffset + 1;
3938 static const int kHasFunctionCacheOffset = kStubMajorKeyOffset + 1; 4036 static const int kHasFunctionCacheOffset = kStubMajorKeyOffset + 1;
3939 4037
3940 static const int kFullCodeFlags = kOptimizableOffset + 1; 4038 static const int kFullCodeFlags = kOptimizableOffset + 1;
3941 class FullCodeFlagsHasDeoptimizationSupportField: 4039 class FullCodeFlagsHasDeoptimizationSupportField:
3942 public BitField<bool, 0, 1> {}; // NOLINT 4040 public BitField<bool, 0, 1> {}; // NOLINT
3943 class FullCodeFlagsHasDebugBreakSlotsField: public BitField<bool, 1, 1> {}; 4041 class FullCodeFlagsHasDebugBreakSlotsField: public BitField<bool, 1, 1> {};
4042 class FullCodeFlagsIsCompiledOptimizable: public BitField<bool, 2, 1> {};
3944 4043
3945 static const int kBinaryOpReturnTypeOffset = kBinaryOpTypeOffset + 1; 4044 static const int kBinaryOpReturnTypeOffset = kBinaryOpTypeOffset + 1;
3946 4045
3947 static const int kAllowOSRAtLoopNestingLevelOffset = kFullCodeFlags + 1; 4046 static const int kAllowOSRAtLoopNestingLevelOffset = kFullCodeFlags + 1;
3948 4047
3949 static const int kSafepointTableOffsetOffset = kStackSlotsOffset + kIntSize; 4048 static const int kSafepointTableOffsetOffset = kStackSlotsOffset + kIntSize;
3950 static const int kStackCheckTableOffsetOffset = kStackSlotsOffset + kIntSize; 4049 static const int kStackCheckTableOffsetOffset = kStackSlotsOffset + kIntSize;
3951 4050
3952 // Flags layout. BitField<type, shift, size>. 4051 // Flags layout. BitField<type, shift, size>.
3953 class ICStateField: public BitField<InlineCacheState, 0, 3> {}; 4052 class ICStateField: public BitField<InlineCacheState, 0, 3> {};
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
4115 inline bool has_external_array_elements() { 4214 inline bool has_external_array_elements() {
4116 ElementsKind kind(elements_kind()); 4215 ElementsKind kind(elements_kind());
4117 return kind >= FIRST_EXTERNAL_ARRAY_ELEMENTS_KIND && 4216 return kind >= FIRST_EXTERNAL_ARRAY_ELEMENTS_KIND &&
4118 kind <= LAST_EXTERNAL_ARRAY_ELEMENTS_KIND; 4217 kind <= LAST_EXTERNAL_ARRAY_ELEMENTS_KIND;
4119 } 4218 }
4120 4219
4121 inline bool has_dictionary_elements() { 4220 inline bool has_dictionary_elements() {
4122 return elements_kind() == DICTIONARY_ELEMENTS; 4221 return elements_kind() == DICTIONARY_ELEMENTS;
4123 } 4222 }
4124 4223
4224 static bool IsValidElementsTransition(ElementsKind from_kind,
4225 ElementsKind to_kind);
4226
4125 // Tells whether the map is attached to SharedFunctionInfo 4227 // Tells whether the map is attached to SharedFunctionInfo
4126 // (for inobject slack tracking). 4228 // (for inobject slack tracking).
4127 inline void set_attached_to_shared_function_info(bool value); 4229 inline void set_attached_to_shared_function_info(bool value);
4128 4230
4129 inline bool attached_to_shared_function_info(); 4231 inline bool attached_to_shared_function_info();
4130 4232
4131 // Tells whether the map is shared between objects that may have different 4233 // Tells whether the map is shared between objects that may have different
4132 // behavior. If true, the map should never be modified, instead a clone 4234 // behavior. If true, the map should never be modified, instead a clone
4133 // should be created and modified. 4235 // should be created and modified.
4134 inline void set_is_shared(bool value); 4236 inline void set_is_shared(bool value);
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
4223 4325
4224 // Locate an accessor in the instance descriptor. 4326 // Locate an accessor in the instance descriptor.
4225 AccessorDescriptor* FindAccessor(String* name); 4327 AccessorDescriptor* FindAccessor(String* name);
4226 4328
4227 // Code cache operations. 4329 // Code cache operations.
4228 4330
4229 // Clears the code cache. 4331 // Clears the code cache.
4230 inline void ClearCodeCache(Heap* heap); 4332 inline void ClearCodeCache(Heap* heap);
4231 4333
4232 // Update code cache. 4334 // Update code cache.
4335 static void UpdateCodeCache(Handle<Map> map,
4336 Handle<String> name,
4337 Handle<Code> code);
4233 MUST_USE_RESULT MaybeObject* UpdateCodeCache(String* name, Code* code); 4338 MUST_USE_RESULT MaybeObject* UpdateCodeCache(String* name, Code* code);
4234 4339
4235 // Returns the found code or undefined if absent. 4340 // Returns the found code or undefined if absent.
4236 Object* FindInCodeCache(String* name, Code::Flags flags); 4341 Object* FindInCodeCache(String* name, Code::Flags flags);
4237 4342
4238 // Returns the non-negative index of the code object if it is in the 4343 // Returns the non-negative index of the code object if it is in the
4239 // cache and -1 otherwise. 4344 // cache and -1 otherwise.
4240 int IndexInCodeCache(Object* name, Code* code); 4345 int IndexInCodeCache(Object* name, Code* code);
4241 4346
4242 // Removes a code object from the code cache at the given index. 4347 // Removes a code object from the code cache at the given index.
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
4281 // |safe_to_add_transitions| is set to false if adding transitions is not 4386 // |safe_to_add_transitions| is set to false if adding transitions is not
4282 // allowed. 4387 // allowed.
4283 Map* LookupElementsTransitionMap(ElementsKind elements_kind, 4388 Map* LookupElementsTransitionMap(ElementsKind elements_kind,
4284 bool* safe_to_add_transition); 4389 bool* safe_to_add_transition);
4285 4390
4286 // Adds an entry to this map's descriptor array for a transition to 4391 // Adds an entry to this map's descriptor array for a transition to
4287 // |transitioned_map| when its elements_kind is changed to |elements_kind|. 4392 // |transitioned_map| when its elements_kind is changed to |elements_kind|.
4288 MaybeObject* AddElementsTransition(ElementsKind elements_kind, 4393 MaybeObject* AddElementsTransition(ElementsKind elements_kind,
4289 Map* transitioned_map); 4394 Map* transitioned_map);
4290 4395
4396 // Returns the transitioned map for this map with the most generic
4397 // elements_kind that's found in |candidates|, or null handle if no match is
4398 // found at all.
4399 Handle<Map> FindTransitionedMap(MapHandleList* candidates);
4400 Map* FindTransitionedMap(MapList* candidates);
4401
4402
4291 // Dispatched behavior. 4403 // Dispatched behavior.
4292 #ifdef OBJECT_PRINT 4404 #ifdef OBJECT_PRINT
4293 inline void MapPrint() { 4405 inline void MapPrint() {
4294 MapPrint(stdout); 4406 MapPrint(stdout);
4295 } 4407 }
4296 void MapPrint(FILE* out); 4408 void MapPrint(FILE* out);
4297 #endif 4409 #endif
4298 #ifdef DEBUG 4410 #ifdef DEBUG
4299 void MapVerify(); 4411 void MapVerify();
4300 void SharedMapVerify(); 4412 void SharedMapVerify();
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after
4789 inline int code_age(); 4901 inline int code_age();
4790 inline void set_code_age(int age); 4902 inline void set_code_age(int age);
4791 4903
4792 // Indicates whether optimizations have been disabled for this 4904 // Indicates whether optimizations have been disabled for this
4793 // shared function info. If a function is repeatedly optimized or if 4905 // shared function info. If a function is repeatedly optimized or if
4794 // we cannot optimize the function we disable optimization to avoid 4906 // we cannot optimize the function we disable optimization to avoid
4795 // spending time attempting to optimize it again. 4907 // spending time attempting to optimize it again.
4796 DECL_BOOLEAN_ACCESSORS(optimization_disabled) 4908 DECL_BOOLEAN_ACCESSORS(optimization_disabled)
4797 4909
4798 // Indicates whether the function is a strict mode function. 4910 // Indicates whether the function is a strict mode function.
4799 DECL_BOOLEAN_ACCESSORS(strict_mode) 4911 inline bool strict_mode();
4912
4913 // Indicates the mode of the function.
4914 inline StrictModeFlag strict_mode_flag();
4915 inline void set_strict_mode_flag(StrictModeFlag strict_mode_flag);
4800 4916
4801 // False if the function definitely does not allocate an arguments object. 4917 // False if the function definitely does not allocate an arguments object.
4802 DECL_BOOLEAN_ACCESSORS(uses_arguments) 4918 DECL_BOOLEAN_ACCESSORS(uses_arguments)
4803 4919
4804 // True if the function has any duplicated parameter names. 4920 // True if the function has any duplicated parameter names.
4805 DECL_BOOLEAN_ACCESSORS(has_duplicate_parameters) 4921 DECL_BOOLEAN_ACCESSORS(has_duplicate_parameters)
4806 4922
4807 // Indicates whether the function is a native function. 4923 // Indicates whether the function is a native function.
4808 // These needs special treatment in .call and .apply since 4924 // These needs special treatment in .call and .apply since
4809 // null passed as the receiver should not be translated to the 4925 // null passed as the receiver should not be translated to the
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
4881 #ifdef OBJECT_PRINT 4997 #ifdef OBJECT_PRINT
4882 inline void SharedFunctionInfoPrint() { 4998 inline void SharedFunctionInfoPrint() {
4883 SharedFunctionInfoPrint(stdout); 4999 SharedFunctionInfoPrint(stdout);
4884 } 5000 }
4885 void SharedFunctionInfoPrint(FILE* out); 5001 void SharedFunctionInfoPrint(FILE* out);
4886 #endif 5002 #endif
4887 #ifdef DEBUG 5003 #ifdef DEBUG
4888 void SharedFunctionInfoVerify(); 5004 void SharedFunctionInfoVerify();
4889 #endif 5005 #endif
4890 5006
5007 // Helpers to compile the shared code. Returns true on success, false on
5008 // failure (e.g., stack overflow during compilation).
5009 static bool EnsureCompiled(Handle<SharedFunctionInfo> shared,
5010 ClearExceptionFlag flag);
5011 static bool CompileLazy(Handle<SharedFunctionInfo> shared,
5012 ClearExceptionFlag flag);
5013
4891 // Casting. 5014 // Casting.
4892 static inline SharedFunctionInfo* cast(Object* obj); 5015 static inline SharedFunctionInfo* cast(Object* obj);
4893 5016
4894 // Constants. 5017 // Constants.
4895 static const int kDontAdaptArgumentsSentinel = -1; 5018 static const int kDontAdaptArgumentsSentinel = -1;
4896 5019
4897 // Layout description. 5020 // Layout description.
4898 // Pointer fields. 5021 // Pointer fields.
4899 static const int kNameOffset = HeapObject::kHeaderSize; 5022 static const int kNameOffset = HeapObject::kHeaderSize;
4900 static const int kCodeOffset = kNameOffset + kPointerSize; 5023 static const int kCodeOffset = kNameOffset + kPointerSize;
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
5031 static const int kCompilerHintsSmiTagSize = 0; 5154 static const int kCompilerHintsSmiTagSize = 0;
5032 static const int kCompilerHintsSize = kIntSize; 5155 static const int kCompilerHintsSize = kIntSize;
5033 #endif 5156 #endif
5034 5157
5035 STATIC_ASSERT(SharedFunctionInfo::kCompilerHintsCount <= 5158 STATIC_ASSERT(SharedFunctionInfo::kCompilerHintsCount <=
5036 SharedFunctionInfo::kCompilerHintsSize * kBitsPerByte); 5159 SharedFunctionInfo::kCompilerHintsSize * kBitsPerByte);
5037 5160
5038 public: 5161 public:
5039 // Constants for optimizing codegen for strict mode function and 5162 // Constants for optimizing codegen for strict mode function and
5040 // native tests. 5163 // native tests.
5041 // Allows to use byte-widgh instructions. 5164 // Allows to use byte-width instructions.
5042 static const int kStrictModeBitWithinByte = 5165 static const int kStrictModeBitWithinByte =
5043 (kStrictModeFunction + kCompilerHintsSmiTagSize) % kBitsPerByte; 5166 (kStrictModeFunction + kCompilerHintsSmiTagSize) % kBitsPerByte;
5044 5167
5045 static const int kNativeBitWithinByte = 5168 static const int kNativeBitWithinByte =
5046 (kNative + kCompilerHintsSmiTagSize) % kBitsPerByte; 5169 (kNative + kCompilerHintsSmiTagSize) % kBitsPerByte;
5047 5170
5048 #if __BYTE_ORDER == __LITTLE_ENDIAN 5171 #if __BYTE_ORDER == __LITTLE_ENDIAN
5049 static const int kStrictModeByteOffset = kCompilerHintsOffset + 5172 static const int kStrictModeByteOffset = kCompilerHintsOffset +
5050 (kStrictModeFunction + kCompilerHintsSmiTagSize) / kBitsPerByte; 5173 (kStrictModeFunction + kCompilerHintsSmiTagSize) / kBitsPerByte;
5051 static const int kNativeByteOffset = kCompilerHintsOffset + 5174 static const int kNativeByteOffset = kCompilerHintsOffset +
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
5102 // Tells whether or not this function has been optimized. 5225 // Tells whether or not this function has been optimized.
5103 inline bool IsOptimized(); 5226 inline bool IsOptimized();
5104 5227
5105 // Tells whether or not this function can be optimized. 5228 // Tells whether or not this function can be optimized.
5106 inline bool IsOptimizable(); 5229 inline bool IsOptimizable();
5107 5230
5108 // Mark this function for lazy recompilation. The function will be 5231 // Mark this function for lazy recompilation. The function will be
5109 // recompiled the next time it is executed. 5232 // recompiled the next time it is executed.
5110 void MarkForLazyRecompilation(); 5233 void MarkForLazyRecompilation();
5111 5234
5235 // Helpers to compile this function. Returns true on success, false on
5236 // failure (e.g., stack overflow during compilation).
5237 static bool CompileLazy(Handle<JSFunction> function,
5238 ClearExceptionFlag flag);
5239 static bool CompileOptimized(Handle<JSFunction> function,
5240 int osr_ast_id,
5241 ClearExceptionFlag flag);
5242
5112 // Tells whether or not the function is already marked for lazy 5243 // Tells whether or not the function is already marked for lazy
5113 // recompilation. 5244 // recompilation.
5114 inline bool IsMarkedForLazyRecompilation(); 5245 inline bool IsMarkedForLazyRecompilation();
5115 5246
5116 // Check whether or not this function is inlineable. 5247 // Check whether or not this function is inlineable.
5117 bool IsInlineable(); 5248 bool IsInlineable();
5118 5249
5119 // [literals]: Fixed array holding the materialized literals. 5250 // [literals_or_bindings]: Fixed array holding either
5251 // the materialized literals or the bindings of a bound function.
5120 // 5252 //
5121 // If the function contains object, regexp or array literals, the 5253 // If the function contains object, regexp or array literals, the
5122 // literals array prefix contains the object, regexp, and array 5254 // literals array prefix contains the object, regexp, and array
5123 // function to be used when creating these literals. This is 5255 // function to be used when creating these literals. This is
5124 // necessary so that we do not dynamically lookup the object, regexp 5256 // necessary so that we do not dynamically lookup the object, regexp
5125 // or array functions. Performing a dynamic lookup, we might end up 5257 // or array functions. Performing a dynamic lookup, we might end up
5126 // using the functions from a new context that we should not have 5258 // using the functions from a new context that we should not have
5127 // access to. 5259 // access to.
5128 DECL_ACCESSORS(literals, FixedArray) 5260 //
5261 // On bound functions, the array is a (copy-on-write) fixed-array containing
5262 // the function that was bound, bound this-value and any bound
5263 // arguments. Bound functions never contain literals.
5264 DECL_ACCESSORS(literals_or_bindings, FixedArray)
5265
5266 inline FixedArray* literals();
5267 inline void set_literals(FixedArray* literals);
5268
5269 inline FixedArray* function_bindings();
5270 inline void set_function_bindings(FixedArray* bindings);
5129 5271
5130 // The initial map for an object created by this constructor. 5272 // The initial map for an object created by this constructor.
5131 inline Map* initial_map(); 5273 inline Map* initial_map();
5132 inline void set_initial_map(Map* value); 5274 inline void set_initial_map(Map* value);
5133 inline bool has_initial_map(); 5275 inline bool has_initial_map();
5134 5276
5135 // Get and set the prototype property on a JSFunction. If the 5277 // Get and set the prototype property on a JSFunction. If the
5136 // function has an initial map the prototype is set on the initial 5278 // function has an initial map the prototype is set on the initial
5137 // map. Otherwise, the prototype is put in the initial map field 5279 // map. Otherwise, the prototype is put in the initial map field
5138 // until an initial map is needed. 5280 // until an initial map is needed.
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
5206 static const int kContextOffset = kSharedFunctionInfoOffset + kPointerSize; 5348 static const int kContextOffset = kSharedFunctionInfoOffset + kPointerSize;
5207 static const int kLiteralsOffset = kContextOffset + kPointerSize; 5349 static const int kLiteralsOffset = kContextOffset + kPointerSize;
5208 static const int kNonWeakFieldsEndOffset = kLiteralsOffset + kPointerSize; 5350 static const int kNonWeakFieldsEndOffset = kLiteralsOffset + kPointerSize;
5209 static const int kNextFunctionLinkOffset = kNonWeakFieldsEndOffset; 5351 static const int kNextFunctionLinkOffset = kNonWeakFieldsEndOffset;
5210 static const int kSize = kNextFunctionLinkOffset + kPointerSize; 5352 static const int kSize = kNextFunctionLinkOffset + kPointerSize;
5211 5353
5212 // Layout of the literals array. 5354 // Layout of the literals array.
5213 static const int kLiteralsPrefixSize = 1; 5355 static const int kLiteralsPrefixSize = 1;
5214 static const int kLiteralGlobalContextIndex = 0; 5356 static const int kLiteralGlobalContextIndex = 0;
5215 5357
5358 // Layout of the bound-function binding array.
5359 static const int kBoundFunctionIndex = 0;
5360 static const int kBoundThisIndex = 1;
5361 static const int kBoundArgumentsStartIndex = 2;
5362
5216 private: 5363 private:
5217 DISALLOW_IMPLICIT_CONSTRUCTORS(JSFunction); 5364 DISALLOW_IMPLICIT_CONSTRUCTORS(JSFunction);
5218 }; 5365 };
5219 5366
5220 5367
5221 // JSGlobalProxy's prototype must be a JSGlobalObject or null, 5368 // JSGlobalProxy's prototype must be a JSGlobalObject or null,
5222 // and the prototype is hidden. JSGlobalProxy always delegates 5369 // and the prototype is hidden. JSGlobalProxy always delegates
5223 // property accesses to its prototype if the prototype is not null. 5370 // property accesses to its prototype if the prototype is not null.
5224 // 5371 //
5225 // A JSGlobalProxy can be reinitialized which will preserve its identity. 5372 // A JSGlobalProxy can be reinitialized which will preserve its identity.
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
5278 // This is like GetProperty, but is used when you know the lookup won't fail 5425 // This is like GetProperty, but is used when you know the lookup won't fail
5279 // by throwing an exception. This is for the debug and builtins global 5426 // by throwing an exception. This is for the debug and builtins global
5280 // objects, where it is known which properties can be expected to be present 5427 // objects, where it is known which properties can be expected to be present
5281 // on the object. 5428 // on the object.
5282 Object* GetPropertyNoExceptionThrown(String* key) { 5429 Object* GetPropertyNoExceptionThrown(String* key) {
5283 Object* answer = GetProperty(key)->ToObjectUnchecked(); 5430 Object* answer = GetProperty(key)->ToObjectUnchecked();
5284 return answer; 5431 return answer;
5285 } 5432 }
5286 5433
5287 // Ensure that the global object has a cell for the given property name. 5434 // Ensure that the global object has a cell for the given property name.
5435 static Handle<JSGlobalPropertyCell> EnsurePropertyCell(
5436 Handle<GlobalObject> global,
5437 Handle<String> name);
5438 // TODO(kmillikin): This function can be eliminated once the stub cache is
5439 // full handlified (and the static helper can be written directly).
5288 MUST_USE_RESULT MaybeObject* EnsurePropertyCell(String* name); 5440 MUST_USE_RESULT MaybeObject* EnsurePropertyCell(String* name);
5289 5441
5290 // Casting. 5442 // Casting.
5291 static inline GlobalObject* cast(Object* obj); 5443 static inline GlobalObject* cast(Object* obj);
5292 5444
5293 // Layout description. 5445 // Layout description.
5294 static const int kBuiltinsOffset = JSObject::kHeaderSize; 5446 static const int kBuiltinsOffset = JSObject::kHeaderSize;
5295 static const int kGlobalContextOffset = kBuiltinsOffset + kPointerSize; 5447 static const int kGlobalContextOffset = kBuiltinsOffset + kPointerSize;
5296 static const int kGlobalReceiverOffset = kGlobalContextOffset + kPointerSize; 5448 static const int kGlobalReceiverOffset = kGlobalContextOffset + kPointerSize;
5297 static const int kHeaderSize = kGlobalReceiverOffset + kPointerSize; 5449 static const int kHeaderSize = kGlobalReceiverOffset + kPointerSize;
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after
5750 5902
5751 private: 5903 private:
5752 DISALLOW_IMPLICIT_CONSTRUCTORS(CodeCacheHashTable); 5904 DISALLOW_IMPLICIT_CONSTRUCTORS(CodeCacheHashTable);
5753 }; 5905 };
5754 5906
5755 5907
5756 class PolymorphicCodeCache: public Struct { 5908 class PolymorphicCodeCache: public Struct {
5757 public: 5909 public:
5758 DECL_ACCESSORS(cache, Object) 5910 DECL_ACCESSORS(cache, Object)
5759 5911
5760 MUST_USE_RESULT MaybeObject* Update(MapList* maps, 5912 static void Update(Handle<PolymorphicCodeCache> cache,
5913 MapHandleList* maps,
5914 Code::Flags flags,
5915 Handle<Code> code);
5916
5917 MUST_USE_RESULT MaybeObject* Update(MapHandleList* maps,
5761 Code::Flags flags, 5918 Code::Flags flags,
5762 Code* code); 5919 Code* code);
5763 Object* Lookup(MapList* maps, Code::Flags flags); 5920
5921 // Returns an undefined value if the entry is not found.
5922 Handle<Object> Lookup(MapHandleList* maps, Code::Flags flags);
5764 5923
5765 static inline PolymorphicCodeCache* cast(Object* obj); 5924 static inline PolymorphicCodeCache* cast(Object* obj);
5766 5925
5767 #ifdef OBJECT_PRINT 5926 #ifdef OBJECT_PRINT
5768 inline void PolymorphicCodeCachePrint() { 5927 inline void PolymorphicCodeCachePrint() {
5769 PolymorphicCodeCachePrint(stdout); 5928 PolymorphicCodeCachePrint(stdout);
5770 } 5929 }
5771 void PolymorphicCodeCachePrint(FILE* out); 5930 void PolymorphicCodeCachePrint(FILE* out);
5772 #endif 5931 #endif
5773 #ifdef DEBUG 5932 #ifdef DEBUG
5774 void PolymorphicCodeCacheVerify(); 5933 void PolymorphicCodeCacheVerify();
5775 #endif 5934 #endif
5776 5935
5777 static const int kCacheOffset = HeapObject::kHeaderSize; 5936 static const int kCacheOffset = HeapObject::kHeaderSize;
5778 static const int kSize = kCacheOffset + kPointerSize; 5937 static const int kSize = kCacheOffset + kPointerSize;
5779 5938
5780 private: 5939 private:
5781 DISALLOW_IMPLICIT_CONSTRUCTORS(PolymorphicCodeCache); 5940 DISALLOW_IMPLICIT_CONSTRUCTORS(PolymorphicCodeCache);
5782 }; 5941 };
5783 5942
5784 5943
5785 class PolymorphicCodeCacheHashTable 5944 class PolymorphicCodeCacheHashTable
5786 : public HashTable<CodeCacheHashTableShape, HashTableKey*> { 5945 : public HashTable<CodeCacheHashTableShape, HashTableKey*> {
5787 public: 5946 public:
5788 Object* Lookup(MapList* maps, int code_kind); 5947 Object* Lookup(MapHandleList* maps, int code_kind);
5789 MUST_USE_RESULT MaybeObject* Put(MapList* maps, int code_kind, Code* code); 5948
5949 MUST_USE_RESULT MaybeObject* Put(MapHandleList* maps,
5950 int code_kind,
5951 Code* code);
5790 5952
5791 static inline PolymorphicCodeCacheHashTable* cast(Object* obj); 5953 static inline PolymorphicCodeCacheHashTable* cast(Object* obj);
5792 5954
5793 static const int kInitialSize = 64; 5955 static const int kInitialSize = 64;
5794 private: 5956 private:
5795 DISALLOW_IMPLICIT_CONSTRUCTORS(PolymorphicCodeCacheHashTable); 5957 DISALLOW_IMPLICIT_CONSTRUCTORS(PolymorphicCodeCacheHashTable);
5796 }; 5958 };
5797 5959
5798 5960
5799 enum AllowNullsFlag {ALLOW_NULLS, DISALLOW_NULLS}; 5961 enum AllowNullsFlag {ALLOW_NULLS, DISALLOW_NULLS};
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
6050 SmartArrayPointer<char> ToCString(AllowNullsFlag allow_nulls, 6212 SmartArrayPointer<char> ToCString(AllowNullsFlag allow_nulls,
6051 RobustnessFlag robustness_flag, 6213 RobustnessFlag robustness_flag,
6052 int offset, 6214 int offset,
6053 int length, 6215 int length,
6054 int* length_output = 0); 6216 int* length_output = 0);
6055 SmartArrayPointer<char> ToCString( 6217 SmartArrayPointer<char> ToCString(
6056 AllowNullsFlag allow_nulls = DISALLOW_NULLS, 6218 AllowNullsFlag allow_nulls = DISALLOW_NULLS,
6057 RobustnessFlag robustness_flag = FAST_STRING_TRAVERSAL, 6219 RobustnessFlag robustness_flag = FAST_STRING_TRAVERSAL,
6058 int* length_output = 0); 6220 int* length_output = 0);
6059 6221
6060 int Utf8Length(); 6222 inline int Utf8Length() { return Utf8Length(this, 0, length()); }
6223 static int Utf8Length(String* input, int from, int to);
6061 6224
6062 // Return a 16 bit Unicode representation of the string. 6225 // Return a 16 bit Unicode representation of the string.
6063 // The string should be nearly flat, otherwise the performance of 6226 // The string should be nearly flat, otherwise the performance of
6064 // of this method may be very bad. Setting robustness_flag to 6227 // of this method may be very bad. Setting robustness_flag to
6065 // ROBUST_STRING_TRAVERSAL invokes behaviour that is robust This means it 6228 // ROBUST_STRING_TRAVERSAL invokes behaviour that is robust This means it
6066 // handles unexpected data without causing assert failures and it does not 6229 // handles unexpected data without causing assert failures and it does not
6067 // do any heap allocations. This is useful when printing stack traces. 6230 // do any heap allocations. This is useful when printing stack traces.
6068 SmartArrayPointer<uc16> ToWideCString( 6231 SmartArrayPointer<uc16> ToWideCString(
6069 RobustnessFlag robustness_flag = FAST_STRING_TRAVERSAL); 6232 RobustnessFlag robustness_flag = FAST_STRING_TRAVERSAL);
6070 6233
(...skipping 839 matching lines...) Expand 10 before | Expand all | Expand 10 after
6910 7073
6911 typedef FixedBodyDescriptor<kHandlerOffset, 7074 typedef FixedBodyDescriptor<kHandlerOffset,
6912 kConstructTrapOffset + kPointerSize, 7075 kConstructTrapOffset + kPointerSize,
6913 kSize> BodyDescriptor; 7076 kSize> BodyDescriptor;
6914 7077
6915 private: 7078 private:
6916 DISALLOW_IMPLICIT_CONSTRUCTORS(JSFunctionProxy); 7079 DISALLOW_IMPLICIT_CONSTRUCTORS(JSFunctionProxy);
6917 }; 7080 };
6918 7081
6919 7082
7083 // The JSSet describes EcmaScript Harmony maps
7084 class JSSet: public JSObject {
7085 public:
7086 // [set]: the backing hash set containing keys.
7087 DECL_ACCESSORS(table, Object)
7088
7089 // Casting.
7090 static inline JSSet* cast(Object* obj);
7091
7092 #ifdef OBJECT_PRINT
7093 inline void JSSetPrint() {
7094 JSSetPrint(stdout);
7095 }
7096 void JSSetPrint(FILE* out);
7097 #endif
7098 #ifdef DEBUG
7099 void JSSetVerify();
7100 #endif
7101
7102 static const int kTableOffset = JSObject::kHeaderSize;
7103 static const int kSize = kTableOffset + kPointerSize;
7104
7105 private:
7106 DISALLOW_IMPLICIT_CONSTRUCTORS(JSSet);
7107 };
7108
7109
7110 // The JSMap describes EcmaScript Harmony maps
7111 class JSMap: public JSObject {
7112 public:
7113 // [table]: the backing hash table mapping keys to values.
7114 DECL_ACCESSORS(table, Object)
7115
7116 // Casting.
7117 static inline JSMap* cast(Object* obj);
7118
7119 #ifdef OBJECT_PRINT
7120 inline void JSMapPrint() {
7121 JSMapPrint(stdout);
7122 }
7123 void JSMapPrint(FILE* out);
7124 #endif
7125 #ifdef DEBUG
7126 void JSMapVerify();
7127 #endif
7128
7129 static const int kTableOffset = JSObject::kHeaderSize;
7130 static const int kSize = kTableOffset + kPointerSize;
7131
7132 private:
7133 DISALLOW_IMPLICIT_CONSTRUCTORS(JSMap);
7134 };
7135
7136
6920 // The JSWeakMap describes EcmaScript Harmony weak maps 7137 // The JSWeakMap describes EcmaScript Harmony weak maps
6921 class JSWeakMap: public JSObject { 7138 class JSWeakMap: public JSObject {
6922 public: 7139 public:
6923 // [table]: the backing hash table mapping keys to values. 7140 // [table]: the backing hash table mapping keys to values.
6924 DECL_ACCESSORS(table, Object) 7141 DECL_ACCESSORS(table, Object)
6925 7142
6926 // [next]: linked list of encountered weak maps during GC. 7143 // [next]: linked list of encountered weak maps during GC.
6927 DECL_ACCESSORS(next, Object) 7144 DECL_ACCESSORS(next, Object)
6928 7145
6929 // Unchecked accessors to be used during GC. 7146 // Unchecked accessors to be used during GC.
(...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after
7589 } else { 7806 } else {
7590 value &= ~(1 << bit_position); 7807 value &= ~(1 << bit_position);
7591 } 7808 }
7592 return value; 7809 return value;
7593 } 7810 }
7594 }; 7811 };
7595 7812
7596 } } // namespace v8::internal 7813 } } // namespace v8::internal
7597 7814
7598 #endif // V8_OBJECTS_H_ 7815 #endif // V8_OBJECTS_H_
OLDNEW
« no previous file with comments | « src/mksnapshot.cc ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698