| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 1565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1576 PropertyDetails details); | 1576 PropertyDetails details); |
| 1577 | 1577 |
| 1578 MUST_USE_RESULT MaybeObject* SetNormalizedProperty(String* name, | 1578 MUST_USE_RESULT MaybeObject* SetNormalizedProperty(String* name, |
| 1579 Object* value, | 1579 Object* value, |
| 1580 PropertyDetails details); | 1580 PropertyDetails details); |
| 1581 | 1581 |
| 1582 // Deletes the named property in a normalized object. | 1582 // Deletes the named property in a normalized object. |
| 1583 MUST_USE_RESULT MaybeObject* DeleteNormalizedProperty(String* name, | 1583 MUST_USE_RESULT MaybeObject* DeleteNormalizedProperty(String* name, |
| 1584 DeleteMode mode); | 1584 DeleteMode mode); |
| 1585 | 1585 |
| 1586 MUST_USE_RESULT MaybeObject* OptimizeAsPrototype(); | |
| 1587 | |
| 1588 // Retrieve interceptors. | 1586 // Retrieve interceptors. |
| 1589 InterceptorInfo* GetNamedInterceptor(); | 1587 InterceptorInfo* GetNamedInterceptor(); |
| 1590 InterceptorInfo* GetIndexedInterceptor(); | 1588 InterceptorInfo* GetIndexedInterceptor(); |
| 1591 | 1589 |
| 1592 // Used from JSReceiver. | 1590 // Used from JSReceiver. |
| 1593 PropertyAttributes GetPropertyAttributePostInterceptor(JSObject* receiver, | 1591 PropertyAttributes GetPropertyAttributePostInterceptor(JSObject* receiver, |
| 1594 String* name, | 1592 String* name, |
| 1595 bool continue_search); | 1593 bool continue_search); |
| 1596 PropertyAttributes GetPropertyAttributeWithInterceptor(JSObject* receiver, | 1594 PropertyAttributes GetPropertyAttributeWithInterceptor(JSObject* receiver, |
| 1597 String* name, | 1595 String* name, |
| (...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2048 int number_of_slow_unused_elements_; | 2046 int number_of_slow_unused_elements_; |
| 2049 }; | 2047 }; |
| 2050 | 2048 |
| 2051 void IncrementSpillStatistics(SpillInformation* info); | 2049 void IncrementSpillStatistics(SpillInformation* info); |
| 2052 #endif | 2050 #endif |
| 2053 Object* SlowReverseLookup(Object* value); | 2051 Object* SlowReverseLookup(Object* value); |
| 2054 | 2052 |
| 2055 // Maximal number of fast properties for the JSObject. Used to | 2053 // Maximal number of fast properties for the JSObject. Used to |
| 2056 // restrict the number of map transitions to avoid an explosion in | 2054 // restrict the number of map transitions to avoid an explosion in |
| 2057 // the number of maps for objects used as dictionaries. | 2055 // the number of maps for objects used as dictionaries. |
| 2058 inline bool TooManyFastProperties(int properties); | 2056 inline int MaxFastProperties(); |
| 2059 | 2057 |
| 2060 // Maximal number of elements (numbered 0 .. kMaxElementCount - 1). | 2058 // Maximal number of elements (numbered 0 .. kMaxElementCount - 1). |
| 2061 // Also maximal value of JSArray's length property. | 2059 // Also maximal value of JSArray's length property. |
| 2062 static const uint32_t kMaxElementCount = 0xffffffffu; | 2060 static const uint32_t kMaxElementCount = 0xffffffffu; |
| 2063 | 2061 |
| 2064 // Constants for heuristics controlling conversion of fast elements | 2062 // Constants for heuristics controlling conversion of fast elements |
| 2065 // to slow elements. | 2063 // to slow elements. |
| 2066 | 2064 |
| 2067 // Maximal gap that can be introduced by adding an element beyond | 2065 // Maximal gap that can be introduced by adding an element beyond |
| 2068 // the current elements length. | 2066 // the current elements length. |
| 2069 static const uint32_t kMaxGap = 1024; | 2067 static const uint32_t kMaxGap = 1024; |
| 2070 | 2068 |
| 2071 // Maximal length of fast elements array that won't be checked for | 2069 // Maximal length of fast elements array that won't be checked for |
| 2072 // being dense enough on expansion. | 2070 // being dense enough on expansion. |
| 2073 static const int kMaxUncheckedFastElementsLength = 5000; | 2071 static const int kMaxUncheckedFastElementsLength = 5000; |
| 2074 | 2072 |
| 2075 // Same as above but for old arrays. This limit is more strict. We | 2073 // Same as above but for old arrays. This limit is more strict. We |
| 2076 // don't want to be wasteful with long lived objects. | 2074 // don't want to be wasteful with long lived objects. |
| 2077 static const int kMaxUncheckedOldFastElementsLength = 500; | 2075 static const int kMaxUncheckedOldFastElementsLength = 500; |
| 2078 | 2076 |
| 2079 static const int kInitialMaxFastElementArray = 100000; | 2077 static const int kInitialMaxFastElementArray = 100000; |
| 2080 static const int kFastPropertiesSoftLimit = 12; | 2078 static const int kMaxFastProperties = 12; |
| 2081 static const int kMaxFastProperties = 32; | |
| 2082 static const int kMaxInstanceSize = 255 * kPointerSize; | 2079 static const int kMaxInstanceSize = 255 * kPointerSize; |
| 2083 // When extending the backing storage for property values, we increase | 2080 // When extending the backing storage for property values, we increase |
| 2084 // its size by more than the 1 entry necessary, so sequentially adding fields | 2081 // its size by more than the 1 entry necessary, so sequentially adding fields |
| 2085 // to the same object requires fewer allocations and copies. | 2082 // to the same object requires fewer allocations and copies. |
| 2086 static const int kFieldsAdded = 3; | 2083 static const int kFieldsAdded = 3; |
| 2087 | 2084 |
| 2088 // Layout description. | 2085 // Layout description. |
| 2089 static const int kPropertiesOffset = HeapObject::kHeaderSize; | 2086 static const int kPropertiesOffset = HeapObject::kHeaderSize; |
| 2090 static const int kElementsOffset = kPropertiesOffset + kPointerSize; | 2087 static const int kElementsOffset = kPropertiesOffset + kPointerSize; |
| 2091 static const int kHeaderSize = kElementsOffset + kPointerSize; | 2088 static const int kHeaderSize = kElementsOffset + kPointerSize; |
| (...skipping 2579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4671 // Tells whether the map is attached to SharedFunctionInfo | 4668 // Tells whether the map is attached to SharedFunctionInfo |
| 4672 // (for inobject slack tracking). | 4669 // (for inobject slack tracking). |
| 4673 inline void set_attached_to_shared_function_info(bool value); | 4670 inline void set_attached_to_shared_function_info(bool value); |
| 4674 | 4671 |
| 4675 inline bool attached_to_shared_function_info(); | 4672 inline bool attached_to_shared_function_info(); |
| 4676 | 4673 |
| 4677 // Tells whether the map is shared between objects that may have different | 4674 // Tells whether the map is shared between objects that may have different |
| 4678 // behavior. If true, the map should never be modified, instead a clone | 4675 // behavior. If true, the map should never be modified, instead a clone |
| 4679 // should be created and modified. | 4676 // should be created and modified. |
| 4680 inline void set_is_shared(bool value); | 4677 inline void set_is_shared(bool value); |
| 4678 |
| 4681 inline bool is_shared(); | 4679 inline bool is_shared(); |
| 4682 | 4680 |
| 4683 // Tells whether the map is used for an object that is a prototype for another | |
| 4684 // object or is the prototype on a function. Such maps are made faster by | |
| 4685 // tweaking the heuristics that distinguish between regular object-oriented | |
| 4686 // objects and the objects that are being used as hash maps. This flag is | |
| 4687 // for optimization, not correctness. | |
| 4688 inline void set_used_for_prototype(bool value); | |
| 4689 inline bool used_for_prototype(); | |
| 4690 | |
| 4691 // Tells whether the instance needs security checks when accessing its | 4681 // Tells whether the instance needs security checks when accessing its |
| 4692 // properties. | 4682 // properties. |
| 4693 inline void set_is_access_check_needed(bool access_check_needed); | 4683 inline void set_is_access_check_needed(bool access_check_needed); |
| 4694 inline bool is_access_check_needed(); | 4684 inline bool is_access_check_needed(); |
| 4695 | 4685 |
| 4696 // [prototype]: implicit prototype object. | 4686 // [prototype]: implicit prototype object. |
| 4697 DECL_ACCESSORS(prototype, Object) | 4687 DECL_ACCESSORS(prototype, Object) |
| 4698 | 4688 |
| 4699 // [constructor]: points back to the function responsible for this map. | 4689 // [constructor]: points back to the function responsible for this map. |
| 4700 DECL_ACCESSORS(constructor, Object) | 4690 DECL_ACCESSORS(constructor, Object) |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4869 void SharedMapVerify(); | 4859 void SharedMapVerify(); |
| 4870 #endif | 4860 #endif |
| 4871 | 4861 |
| 4872 inline int visitor_id(); | 4862 inline int visitor_id(); |
| 4873 inline void set_visitor_id(int visitor_id); | 4863 inline void set_visitor_id(int visitor_id); |
| 4874 | 4864 |
| 4875 typedef void (*TraverseCallback)(Map* map, void* data); | 4865 typedef void (*TraverseCallback)(Map* map, void* data); |
| 4876 | 4866 |
| 4877 void TraverseTransitionTree(TraverseCallback callback, void* data); | 4867 void TraverseTransitionTree(TraverseCallback callback, void* data); |
| 4878 | 4868 |
| 4879 // When you set the prototype of an object using the __proto__ accessor you | |
| 4880 // need a new map for the object (the prototype is stored in the map). In | |
| 4881 // order not to multiply maps unnecessarily we store these as transitions in | |
| 4882 // the original map. That way we can transition to the same map if the same | |
| 4883 // prototype is set, rather than creating a new map every time. The | |
| 4884 // transitions are in the form of a map where the keys are prototype objects | |
| 4885 // and the values are the maps the are transitioned to. The special key | |
| 4886 // the_hole denotes the map we should transition to when the | |
| 4887 // used_for_prototype flag is set. | |
| 4888 static const int kMaxCachedPrototypeTransitions = 256; | 4869 static const int kMaxCachedPrototypeTransitions = 256; |
| 4889 | 4870 |
| 4890 Map* GetPrototypeTransition(Object* prototype); | 4871 Object* GetPrototypeTransition(Object* prototype); |
| 4891 | 4872 |
| 4892 MUST_USE_RESULT MaybeObject* PutPrototypeTransition(Object* prototype, | 4873 MUST_USE_RESULT MaybeObject* PutPrototypeTransition(Object* prototype, |
| 4893 Map* map); | 4874 Map* map); |
| 4894 | 4875 |
| 4895 static const int kMaxPreAllocatedPropertyFields = 255; | 4876 static const int kMaxPreAllocatedPropertyFields = 255; |
| 4896 | 4877 |
| 4897 // Layout description. | 4878 // Layout description. |
| 4898 static const int kInstanceSizesOffset = HeapObject::kHeaderSize; | 4879 static const int kInstanceSizesOffset = HeapObject::kHeaderSize; |
| 4899 static const int kInstanceAttributesOffset = kInstanceSizesOffset + kIntSize; | 4880 static const int kInstanceAttributesOffset = kInstanceSizesOffset + kIntSize; |
| 4900 static const int kPrototypeOffset = kInstanceAttributesOffset + kIntSize; | 4881 static const int kPrototypeOffset = kInstanceAttributesOffset + kIntSize; |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4973 static const int8_t kMaximumBitField2FastHoleyElementValue = | 4954 static const int8_t kMaximumBitField2FastHoleyElementValue = |
| 4974 static_cast<int8_t>((FAST_HOLEY_ELEMENTS + 1) << | 4955 static_cast<int8_t>((FAST_HOLEY_ELEMENTS + 1) << |
| 4975 Map::kElementsKindShift) - 1; | 4956 Map::kElementsKindShift) - 1; |
| 4976 static const int8_t kMaximumBitField2FastHoleySmiElementValue = | 4957 static const int8_t kMaximumBitField2FastHoleySmiElementValue = |
| 4977 static_cast<int8_t>((FAST_HOLEY_SMI_ELEMENTS + 1) << | 4958 static_cast<int8_t>((FAST_HOLEY_SMI_ELEMENTS + 1) << |
| 4978 Map::kElementsKindShift) - 1; | 4959 Map::kElementsKindShift) - 1; |
| 4979 | 4960 |
| 4980 // Bit positions for bit field 3 | 4961 // Bit positions for bit field 3 |
| 4981 static const int kIsShared = 0; | 4962 static const int kIsShared = 0; |
| 4982 static const int kFunctionWithPrototype = 1; | 4963 static const int kFunctionWithPrototype = 1; |
| 4983 static const int kUsedForPrototype = 2; | |
| 4984 | 4964 |
| 4985 // Layout of the default cache. It holds alternating name and code objects. | 4965 // Layout of the default cache. It holds alternating name and code objects. |
| 4986 static const int kCodeCacheEntrySize = 2; | 4966 static const int kCodeCacheEntrySize = 2; |
| 4987 static const int kCodeCacheEntryNameOffset = 0; | 4967 static const int kCodeCacheEntryNameOffset = 0; |
| 4988 static const int kCodeCacheEntryCodeOffset = 1; | 4968 static const int kCodeCacheEntryCodeOffset = 1; |
| 4989 | 4969 |
| 4990 typedef FixedBodyDescriptor<kPointerFieldsBeginOffset, | 4970 typedef FixedBodyDescriptor<kPointerFieldsBeginOffset, |
| 4991 kPointerFieldsEndOffset, | 4971 kPointerFieldsEndOffset, |
| 4992 kSize> BodyDescriptor; | 4972 kSize> BodyDescriptor; |
| 4993 | 4973 |
| (...skipping 3690 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8684 } else { | 8664 } else { |
| 8685 value &= ~(1 << bit_position); | 8665 value &= ~(1 << bit_position); |
| 8686 } | 8666 } |
| 8687 return value; | 8667 return value; |
| 8688 } | 8668 } |
| 8689 }; | 8669 }; |
| 8690 | 8670 |
| 8691 } } // namespace v8::internal | 8671 } } // namespace v8::internal |
| 8692 | 8672 |
| 8693 #endif // V8_OBJECTS_H_ | 8673 #endif // V8_OBJECTS_H_ |
| OLD | NEW |