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

Side by Side Diff: src/objects.h

Issue 10532021: Keep track of which maps are associated with prototype objects so we can tune the fast-case vs. has… (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | src/objects.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 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
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 449 matching lines...) Expand 10 before | Expand all | Expand 10 after
2045 int number_of_slow_unused_elements_; 2047 int number_of_slow_unused_elements_;
2046 }; 2048 };
2047 2049
2048 void IncrementSpillStatistics(SpillInformation* info); 2050 void IncrementSpillStatistics(SpillInformation* info);
2049 #endif 2051 #endif
2050 Object* SlowReverseLookup(Object* value); 2052 Object* SlowReverseLookup(Object* value);
2051 2053
2052 // Maximal number of fast properties for the JSObject. Used to 2054 // Maximal number of fast properties for the JSObject. Used to
2053 // restrict the number of map transitions to avoid an explosion in 2055 // restrict the number of map transitions to avoid an explosion in
2054 // the number of maps for objects used as dictionaries. 2056 // the number of maps for objects used as dictionaries.
2055 inline int MaxFastProperties(); 2057 inline bool TooManyFastProperties(int properties);
2056 2058
2057 // Maximal number of elements (numbered 0 .. kMaxElementCount - 1). 2059 // Maximal number of elements (numbered 0 .. kMaxElementCount - 1).
2058 // Also maximal value of JSArray's length property. 2060 // Also maximal value of JSArray's length property.
2059 static const uint32_t kMaxElementCount = 0xffffffffu; 2061 static const uint32_t kMaxElementCount = 0xffffffffu;
2060 2062
2061 // Constants for heuristics controlling conversion of fast elements 2063 // Constants for heuristics controlling conversion of fast elements
2062 // to slow elements. 2064 // to slow elements.
2063 2065
2064 // Maximal gap that can be introduced by adding an element beyond 2066 // Maximal gap that can be introduced by adding an element beyond
2065 // the current elements length. 2067 // the current elements length.
2066 static const uint32_t kMaxGap = 1024; 2068 static const uint32_t kMaxGap = 1024;
2067 2069
2068 // Maximal length of fast elements array that won't be checked for 2070 // Maximal length of fast elements array that won't be checked for
2069 // being dense enough on expansion. 2071 // being dense enough on expansion.
2070 static const int kMaxUncheckedFastElementsLength = 5000; 2072 static const int kMaxUncheckedFastElementsLength = 5000;
2071 2073
2072 // Same as above but for old arrays. This limit is more strict. We 2074 // Same as above but for old arrays. This limit is more strict. We
2073 // don't want to be wasteful with long lived objects. 2075 // don't want to be wasteful with long lived objects.
2074 static const int kMaxUncheckedOldFastElementsLength = 500; 2076 static const int kMaxUncheckedOldFastElementsLength = 500;
2075 2077
2076 static const int kInitialMaxFastElementArray = 100000; 2078 static const int kInitialMaxFastElementArray = 100000;
2077 static const int kMaxFastProperties = 12; 2079 static const int kFastPropertiesSoftLimit = 12;
2080 static const int kMaxFastProperties = 32;
2078 static const int kMaxInstanceSize = 255 * kPointerSize; 2081 static const int kMaxInstanceSize = 255 * kPointerSize;
2079 // When extending the backing storage for property values, we increase 2082 // When extending the backing storage for property values, we increase
2080 // its size by more than the 1 entry necessary, so sequentially adding fields 2083 // its size by more than the 1 entry necessary, so sequentially adding fields
2081 // to the same object requires fewer allocations and copies. 2084 // to the same object requires fewer allocations and copies.
2082 static const int kFieldsAdded = 3; 2085 static const int kFieldsAdded = 3;
2083 2086
2084 // Layout description. 2087 // Layout description.
2085 static const int kPropertiesOffset = HeapObject::kHeaderSize; 2088 static const int kPropertiesOffset = HeapObject::kHeaderSize;
2086 static const int kElementsOffset = kPropertiesOffset + kPointerSize; 2089 static const int kElementsOffset = kPropertiesOffset + kPointerSize;
2087 static const int kHeaderSize = kElementsOffset + kPointerSize; 2090 static const int kHeaderSize = kElementsOffset + kPointerSize;
(...skipping 2592 matching lines...) Expand 10 before | Expand all | Expand 10 after
4680 // Tells whether the map is attached to SharedFunctionInfo 4683 // Tells whether the map is attached to SharedFunctionInfo
4681 // (for inobject slack tracking). 4684 // (for inobject slack tracking).
4682 inline void set_attached_to_shared_function_info(bool value); 4685 inline void set_attached_to_shared_function_info(bool value);
4683 4686
4684 inline bool attached_to_shared_function_info(); 4687 inline bool attached_to_shared_function_info();
4685 4688
4686 // Tells whether the map is shared between objects that may have different 4689 // Tells whether the map is shared between objects that may have different
4687 // behavior. If true, the map should never be modified, instead a clone 4690 // behavior. If true, the map should never be modified, instead a clone
4688 // should be created and modified. 4691 // should be created and modified.
4689 inline void set_is_shared(bool value); 4692 inline void set_is_shared(bool value);
4693 inline bool is_shared();
4690 4694
4691 inline bool is_shared(); 4695 // Tells whether the map is used for an object that is a prototype for another
4696 // object or is the prototype on a function. Such maps are made faster by
4697 // tweaking the heuristics that distinguish between regular object-oriented
4698 // objects and the objects that are being used as hash maps. This flag is
4699 // for optimization, not correctness.
4700 inline void set_used_for_prototype(bool value);
4701 inline bool used_for_prototype();
4692 4702
4693 // Tells whether the instance needs security checks when accessing its 4703 // Tells whether the instance needs security checks when accessing its
4694 // properties. 4704 // properties.
4695 inline void set_is_access_check_needed(bool access_check_needed); 4705 inline void set_is_access_check_needed(bool access_check_needed);
4696 inline bool is_access_check_needed(); 4706 inline bool is_access_check_needed();
4697 4707
4698 // [prototype]: implicit prototype object. 4708 // [prototype]: implicit prototype object.
4699 DECL_ACCESSORS(prototype, Object) 4709 DECL_ACCESSORS(prototype, Object)
4700 4710
4701 // [constructor]: points back to the function responsible for this map. 4711 // [constructor]: points back to the function responsible for this map.
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
4871 void SharedMapVerify(); 4881 void SharedMapVerify();
4872 #endif 4882 #endif
4873 4883
4874 inline int visitor_id(); 4884 inline int visitor_id();
4875 inline void set_visitor_id(int visitor_id); 4885 inline void set_visitor_id(int visitor_id);
4876 4886
4877 typedef void (*TraverseCallback)(Map* map, void* data); 4887 typedef void (*TraverseCallback)(Map* map, void* data);
4878 4888
4879 void TraverseTransitionTree(TraverseCallback callback, void* data); 4889 void TraverseTransitionTree(TraverseCallback callback, void* data);
4880 4890
4891 // When you set the prototype of an object using the __proto__ accessor you
4892 // need a new map for the object (the prototype is stored in the map). In
4893 // order not to multiply maps unnecessarily we store these as transitions in
4894 // the original map. That way we can transition to the same map if the same
4895 // prototype is set, rather than creating a new map every time. The
4896 // transitions are in the form of a map where the keys are prototype objects
4897 // and the values are the maps the are transitioned to. The special key
4898 // the_hole denotes the map we should transition to when the
4899 // used_for_prototype flag is set.
4881 static const int kMaxCachedPrototypeTransitions = 256; 4900 static const int kMaxCachedPrototypeTransitions = 256;
4882 4901
4883 Object* GetPrototypeTransition(Object* prototype); 4902 Map* GetPrototypeTransition(Object* prototype);
4884 4903
4885 MUST_USE_RESULT MaybeObject* PutPrototypeTransition(Object* prototype, 4904 MUST_USE_RESULT MaybeObject* PutPrototypeTransition(Object* prototype,
4886 Map* map); 4905 Map* map);
4887 4906
4888 static const int kMaxPreAllocatedPropertyFields = 255; 4907 static const int kMaxPreAllocatedPropertyFields = 255;
4889 4908
4890 // Layout description. 4909 // Layout description.
4891 static const int kInstanceSizesOffset = HeapObject::kHeaderSize; 4910 static const int kInstanceSizesOffset = HeapObject::kHeaderSize;
4892 static const int kInstanceAttributesOffset = kInstanceSizesOffset + kIntSize; 4911 static const int kInstanceAttributesOffset = kInstanceSizesOffset + kIntSize;
4893 static const int kPrototypeOffset = kInstanceAttributesOffset + kIntSize; 4912 static const int kPrototypeOffset = kInstanceAttributesOffset + kIntSize;
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
4966 static const int8_t kMaximumBitField2FastHoleyElementValue = 4985 static const int8_t kMaximumBitField2FastHoleyElementValue =
4967 static_cast<int8_t>((FAST_HOLEY_ELEMENTS + 1) << 4986 static_cast<int8_t>((FAST_HOLEY_ELEMENTS + 1) <<
4968 Map::kElementsKindShift) - 1; 4987 Map::kElementsKindShift) - 1;
4969 static const int8_t kMaximumBitField2FastHoleySmiElementValue = 4988 static const int8_t kMaximumBitField2FastHoleySmiElementValue =
4970 static_cast<int8_t>((FAST_HOLEY_SMI_ELEMENTS + 1) << 4989 static_cast<int8_t>((FAST_HOLEY_SMI_ELEMENTS + 1) <<
4971 Map::kElementsKindShift) - 1; 4990 Map::kElementsKindShift) - 1;
4972 4991
4973 // Bit positions for bit field 3 4992 // Bit positions for bit field 3
4974 static const int kIsShared = 0; 4993 static const int kIsShared = 0;
4975 static const int kFunctionWithPrototype = 1; 4994 static const int kFunctionWithPrototype = 1;
4995 static const int kUsedForPrototype = 2;
4976 4996
4977 // Layout of the default cache. It holds alternating name and code objects. 4997 // Layout of the default cache. It holds alternating name and code objects.
4978 static const int kCodeCacheEntrySize = 2; 4998 static const int kCodeCacheEntrySize = 2;
4979 static const int kCodeCacheEntryNameOffset = 0; 4999 static const int kCodeCacheEntryNameOffset = 0;
4980 static const int kCodeCacheEntryCodeOffset = 1; 5000 static const int kCodeCacheEntryCodeOffset = 1;
4981 5001
4982 typedef FixedBodyDescriptor<kPointerFieldsBeginOffset, 5002 typedef FixedBodyDescriptor<kPointerFieldsBeginOffset,
4983 kPointerFieldsEndOffset, 5003 kPointerFieldsEndOffset,
4984 kSize> BodyDescriptor; 5004 kSize> BodyDescriptor;
4985 5005
(...skipping 3692 matching lines...) Expand 10 before | Expand all | Expand 10 after
8678 } else { 8698 } else {
8679 value &= ~(1 << bit_position); 8699 value &= ~(1 << bit_position);
8680 } 8700 }
8681 return value; 8701 return value;
8682 } 8702 }
8683 }; 8703 };
8684 8704
8685 } } // namespace v8::internal 8705 } } // namespace v8::internal
8686 8706
8687 #endif // V8_OBJECTS_H_ 8707 #endif // V8_OBJECTS_H_
OLDNEW
« no previous file with comments | « no previous file | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698