 Chromium Code Reviews
 Chromium Code Reviews Issue 10448011:
  Keep track of which maps are associated with prototype objects  (Closed) 
  Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
    
  
    Issue 10448011:
  Keep track of which maps are associated with prototype objects  (Closed) 
  Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/| 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 | |
| 1586 // Retrieve interceptors. | 1588 // Retrieve interceptors. | 
| 1587 InterceptorInfo* GetNamedInterceptor(); | 1589 InterceptorInfo* GetNamedInterceptor(); | 
| 1588 InterceptorInfo* GetIndexedInterceptor(); | 1590 InterceptorInfo* GetIndexedInterceptor(); | 
| 1589 | 1591 | 
| 1590 // Used from JSReceiver. | 1592 // Used from JSReceiver. | 
| 1591 PropertyAttributes GetPropertyAttributePostInterceptor(JSObject* receiver, | 1593 PropertyAttributes GetPropertyAttributePostInterceptor(JSObject* receiver, | 
| 1592 String* name, | 1594 String* name, | 
| 1593 bool continue_search); | 1595 bool continue_search); | 
| 1594 PropertyAttributes GetPropertyAttributeWithInterceptor(JSObject* receiver, | 1596 PropertyAttributes GetPropertyAttributeWithInterceptor(JSObject* receiver, | 
| 1595 String* name, | 1597 String* name, | 
| (...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2046 int number_of_slow_unused_elements_; | 2048 int number_of_slow_unused_elements_; | 
| 2047 }; | 2049 }; | 
| 2048 | 2050 | 
| 2049 void IncrementSpillStatistics(SpillInformation* info); | 2051 void IncrementSpillStatistics(SpillInformation* info); | 
| 2050 #endif | 2052 #endif | 
| 2051 Object* SlowReverseLookup(Object* value); | 2053 Object* SlowReverseLookup(Object* value); | 
| 2052 | 2054 | 
| 2053 // Maximal number of fast properties for the JSObject. Used to | 2055 // Maximal number of fast properties for the JSObject. Used to | 
| 2054 // restrict the number of map transitions to avoid an explosion in | 2056 // restrict the number of map transitions to avoid an explosion in | 
| 2055 // the number of maps for objects used as dictionaries. | 2057 // the number of maps for objects used as dictionaries. | 
| 2056 inline int MaxFastProperties(); | 2058 inline bool TooManyFastProperties(int properties); | 
| 2057 | 2059 | 
| 2058 // Maximal number of elements (numbered 0 .. kMaxElementCount - 1). | 2060 // Maximal number of elements (numbered 0 .. kMaxElementCount - 1). | 
| 2059 // Also maximal value of JSArray's length property. | 2061 // Also maximal value of JSArray's length property. | 
| 2060 static const uint32_t kMaxElementCount = 0xffffffffu; | 2062 static const uint32_t kMaxElementCount = 0xffffffffu; | 
| 2061 | 2063 | 
| 2062 // Constants for heuristics controlling conversion of fast elements | 2064 // Constants for heuristics controlling conversion of fast elements | 
| 2063 // to slow elements. | 2065 // to slow elements. | 
| 2064 | 2066 | 
| 2065 // Maximal gap that can be introduced by adding an element beyond | 2067 // Maximal gap that can be introduced by adding an element beyond | 
| 2066 // the current elements length. | 2068 // the current elements length. | 
| 2067 static const uint32_t kMaxGap = 1024; | 2069 static const uint32_t kMaxGap = 1024; | 
| 2068 | 2070 | 
| 2069 // Maximal length of fast elements array that won't be checked for | 2071 // Maximal length of fast elements array that won't be checked for | 
| 2070 // being dense enough on expansion. | 2072 // being dense enough on expansion. | 
| 2071 static const int kMaxUncheckedFastElementsLength = 5000; | 2073 static const int kMaxUncheckedFastElementsLength = 5000; | 
| 2072 | 2074 | 
| 2073 // Same as above but for old arrays. This limit is more strict. We | 2075 // Same as above but for old arrays. This limit is more strict. We | 
| 2074 // don't want to be wasteful with long lived objects. | 2076 // don't want to be wasteful with long lived objects. | 
| 2075 static const int kMaxUncheckedOldFastElementsLength = 500; | 2077 static const int kMaxUncheckedOldFastElementsLength = 500; | 
| 2076 | 2078 | 
| 2077 static const int kInitialMaxFastElementArray = 100000; | 2079 static const int kInitialMaxFastElementArray = 100000; | 
| 2078 static const int kMaxFastProperties = 12; | 2080 static const int kFastPropertiesSoftLimit = 12; | 
| 2081 static const int kMaxFastProperties = 32; | |
| 2079 static const int kMaxInstanceSize = 255 * kPointerSize; | 2082 static const int kMaxInstanceSize = 255 * kPointerSize; | 
| 2080 // When extending the backing storage for property values, we increase | 2083 // When extending the backing storage for property values, we increase | 
| 2081 // its size by more than the 1 entry necessary, so sequentially adding fields | 2084 // its size by more than the 1 entry necessary, so sequentially adding fields | 
| 2082 // to the same object requires fewer allocations and copies. | 2085 // to the same object requires fewer allocations and copies. | 
| 2083 static const int kFieldsAdded = 3; | 2086 static const int kFieldsAdded = 3; | 
| 2084 | 2087 | 
| 2085 // Layout description. | 2088 // Layout description. | 
| 2086 static const int kPropertiesOffset = HeapObject::kHeaderSize; | 2089 static const int kPropertiesOffset = HeapObject::kHeaderSize; | 
| 2087 static const int kElementsOffset = kPropertiesOffset + kPointerSize; | 2090 static const int kElementsOffset = kPropertiesOffset + kPointerSize; | 
| 2088 static const int kHeaderSize = kElementsOffset + kPointerSize; | 2091 static const int kHeaderSize = kElementsOffset + kPointerSize; | 
| (...skipping 2567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4656 // Tells whether the map is attached to SharedFunctionInfo | 4659 // Tells whether the map is attached to SharedFunctionInfo | 
| 4657 // (for inobject slack tracking). | 4660 // (for inobject slack tracking). | 
| 4658 inline void set_attached_to_shared_function_info(bool value); | 4661 inline void set_attached_to_shared_function_info(bool value); | 
| 4659 | 4662 | 
| 4660 inline bool attached_to_shared_function_info(); | 4663 inline bool attached_to_shared_function_info(); | 
| 4661 | 4664 | 
| 4662 // Tells whether the map is shared between objects that may have different | 4665 // Tells whether the map is shared between objects that may have different | 
| 4663 // behavior. If true, the map should never be modified, instead a clone | 4666 // behavior. If true, the map should never be modified, instead a clone | 
| 4664 // should be created and modified. | 4667 // should be created and modified. | 
| 4665 inline void set_is_shared(bool value); | 4668 inline void set_is_shared(bool value); | 
| 4669 inline bool is_shared(); | |
| 4666 | 4670 | 
| 4667 inline bool is_shared(); | 4671 // Tells whether the map is used for an object that is a prototype for another | 
| 4672 // object or is the prototype on a function. Such maps are made faster by | |
| 4673 // tweaking the heuristics that distinguish between regular object-oriented | |
| 4674 // objects and the objects that are being used as hash maps. This flag is | |
| 4675 // for optimization, not correctness. | |
| 4676 inline void set_used_for_prototype(bool value); | |
| 4677 inline bool used_for_prototype(); | |
| 4668 | 4678 | 
| 4669 // Tells whether the instance needs security checks when accessing its | 4679 // Tells whether the instance needs security checks when accessing its | 
| 4670 // properties. | 4680 // properties. | 
| 4671 inline void set_is_access_check_needed(bool access_check_needed); | 4681 inline void set_is_access_check_needed(bool access_check_needed); | 
| 4672 inline bool is_access_check_needed(); | 4682 inline bool is_access_check_needed(); | 
| 4673 | 4683 | 
| 4674 // [prototype]: implicit prototype object. | 4684 // [prototype]: implicit prototype object. | 
| 4675 DECL_ACCESSORS(prototype, Object) | 4685 DECL_ACCESSORS(prototype, Object) | 
| 4676 | 4686 | 
| 4677 // [constructor]: points back to the function responsible for this map. | 4687 // [constructor]: points back to the function responsible for this map. | 
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4849 | 4859 | 
| 4850 inline int visitor_id(); | 4860 inline int visitor_id(); | 
| 4851 inline void set_visitor_id(int visitor_id); | 4861 inline void set_visitor_id(int visitor_id); | 
| 4852 | 4862 | 
| 4853 typedef void (*TraverseCallback)(Map* map, void* data); | 4863 typedef void (*TraverseCallback)(Map* map, void* data); | 
| 4854 | 4864 | 
| 4855 void TraverseTransitionTree(TraverseCallback callback, void* data); | 4865 void TraverseTransitionTree(TraverseCallback callback, void* data); | 
| 4856 | 4866 | 
| 4857 static const int kMaxCachedPrototypeTransitions = 256; | 4867 static const int kMaxCachedPrototypeTransitions = 256; | 
| 4858 | 4868 | 
| 4859 Object* GetPrototypeTransition(Object* prototype); | 4869 Map* GetPrototypeTransition(Object* prototype); | 
| 
Michael Starzinger
2012/05/30 14:08:03
I know this is not part of this CL, but can we add
 
Erik Corry
2012/05/30 15:24:13
Done.
 | |
| 4860 | 4870 | 
| 4861 MUST_USE_RESULT MaybeObject* PutPrototypeTransition(Object* prototype, | 4871 MUST_USE_RESULT MaybeObject* PutPrototypeTransition(Object* prototype, | 
| 4862 Map* map); | 4872 Map* map); | 
| 4863 | 4873 | 
| 4864 static const int kMaxPreAllocatedPropertyFields = 255; | 4874 static const int kMaxPreAllocatedPropertyFields = 255; | 
| 4865 | 4875 | 
| 4866 // Layout description. | 4876 // Layout description. | 
| 4867 static const int kInstanceSizesOffset = HeapObject::kHeaderSize; | 4877 static const int kInstanceSizesOffset = HeapObject::kHeaderSize; | 
| 4868 static const int kInstanceAttributesOffset = kInstanceSizesOffset + kIntSize; | 4878 static const int kInstanceAttributesOffset = kInstanceSizesOffset + kIntSize; | 
| 4869 static const int kPrototypeOffset = kInstanceAttributesOffset + kIntSize; | 4879 static const int kPrototypeOffset = kInstanceAttributesOffset + kIntSize; | 
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4942 static const int8_t kMaximumBitField2FastHoleyElementValue = | 4952 static const int8_t kMaximumBitField2FastHoleyElementValue = | 
| 4943 static_cast<int8_t>((FAST_HOLEY_ELEMENTS + 1) << | 4953 static_cast<int8_t>((FAST_HOLEY_ELEMENTS + 1) << | 
| 4944 Map::kElementsKindShift) - 1; | 4954 Map::kElementsKindShift) - 1; | 
| 4945 static const int8_t kMaximumBitField2FastHoleySmiElementValue = | 4955 static const int8_t kMaximumBitField2FastHoleySmiElementValue = | 
| 4946 static_cast<int8_t>((FAST_HOLEY_SMI_ELEMENTS + 1) << | 4956 static_cast<int8_t>((FAST_HOLEY_SMI_ELEMENTS + 1) << | 
| 4947 Map::kElementsKindShift) - 1; | 4957 Map::kElementsKindShift) - 1; | 
| 4948 | 4958 | 
| 4949 // Bit positions for bit field 3 | 4959 // Bit positions for bit field 3 | 
| 4950 static const int kIsShared = 0; | 4960 static const int kIsShared = 0; | 
| 4951 static const int kFunctionWithPrototype = 1; | 4961 static const int kFunctionWithPrototype = 1; | 
| 4962 static const int kUsedForPrototype = 2; | |
| 4952 | 4963 | 
| 4953 // Layout of the default cache. It holds alternating name and code objects. | 4964 // Layout of the default cache. It holds alternating name and code objects. | 
| 4954 static const int kCodeCacheEntrySize = 2; | 4965 static const int kCodeCacheEntrySize = 2; | 
| 4955 static const int kCodeCacheEntryNameOffset = 0; | 4966 static const int kCodeCacheEntryNameOffset = 0; | 
| 4956 static const int kCodeCacheEntryCodeOffset = 1; | 4967 static const int kCodeCacheEntryCodeOffset = 1; | 
| 4957 | 4968 | 
| 4958 typedef FixedBodyDescriptor<kPointerFieldsBeginOffset, | 4969 typedef FixedBodyDescriptor<kPointerFieldsBeginOffset, | 
| 4959 kPointerFieldsEndOffset, | 4970 kPointerFieldsEndOffset, | 
| 4960 kSize> BodyDescriptor; | 4971 kSize> BodyDescriptor; | 
| 4961 | 4972 | 
| (...skipping 3687 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 8649 } else { | 8660 } else { | 
| 8650 value &= ~(1 << bit_position); | 8661 value &= ~(1 << bit_position); | 
| 8651 } | 8662 } | 
| 8652 return value; | 8663 return value; | 
| 8653 } | 8664 } | 
| 8654 }; | 8665 }; | 
| 8655 | 8666 | 
| 8656 } } // namespace v8::internal | 8667 } } // namespace v8::internal | 
| 8657 | 8668 | 
| 8658 #endif // V8_OBJECTS_H_ | 8669 #endif // V8_OBJECTS_H_ | 
| OLD | NEW |