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

Side by Side Diff: src/objects.h

Issue 12225099: Remove prototype checks for leaf maps in optimized code. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Merge 12224035 to this CL and address Michael's comments Created 7 years, 10 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
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 844 matching lines...) Expand 10 before | Expand all | Expand 10 after
855 V(FreeSpace) \ 855 V(FreeSpace) \
856 V(JSReceiver) \ 856 V(JSReceiver) \
857 V(JSObject) \ 857 V(JSObject) \
858 V(JSContextExtensionObject) \ 858 V(JSContextExtensionObject) \
859 V(JSModule) \ 859 V(JSModule) \
860 V(Map) \ 860 V(Map) \
861 V(DescriptorArray) \ 861 V(DescriptorArray) \
862 V(TransitionArray) \ 862 V(TransitionArray) \
863 V(DeoptimizationInputData) \ 863 V(DeoptimizationInputData) \
864 V(DeoptimizationOutputData) \ 864 V(DeoptimizationOutputData) \
865 V(DependentCodes) \ 865 V(DependentCode) \
866 V(TypeFeedbackCells) \ 866 V(TypeFeedbackCells) \
867 V(FixedArray) \ 867 V(FixedArray) \
868 V(FixedDoubleArray) \ 868 V(FixedDoubleArray) \
869 V(Context) \ 869 V(Context) \
870 V(NativeContext) \ 870 V(NativeContext) \
871 V(ScopeInfo) \ 871 V(ScopeInfo) \
872 V(JSFunction) \ 872 V(JSFunction) \
873 V(Code) \ 873 V(Code) \
874 V(Oddball) \ 874 V(Oddball) \
875 V(SharedFunctionInfo) \ 875 V(SharedFunctionInfo) \
(...skipping 3800 matching lines...) Expand 10 before | Expand all | Expand 10 after
4676 4676
4677 // Code aging -- platform-specific 4677 // Code aging -- platform-specific
4678 static void PatchPlatformCodeAge(byte* sequence, Age age, 4678 static void PatchPlatformCodeAge(byte* sequence, Age age,
4679 MarkingParity parity); 4679 MarkingParity parity);
4680 4680
4681 DISALLOW_IMPLICIT_CONSTRUCTORS(Code); 4681 DISALLOW_IMPLICIT_CONSTRUCTORS(Code);
4682 }; 4682 };
4683 4683
4684 4684
4685 // This class describes the layout of dependent codes array of a map. The 4685 // This class describes the layout of dependent codes array of a map. The
4686 // first element contains the number of codes as a Smi. The subsequent 4686 // array is partitioned into several groups of dependent codes. Each group
4687 // elements contain code objects. The suffix of the array can be filled with the 4687 // contains codes with the same dependency on the map. The array has the
4688 // undefined value if the number of codes is less than the length of the array. 4688 // following layout for n dependency groups:
4689 class DependentCodes: public FixedArray { 4689 //
4690 // +----+----+-----+----+---------+----------+-----+---------+-----------+
4691 // | C1 | C2 | ... | Cn | group 1 | group 2 | ... | group n | undefined |
4692 // +----+----+-----+----+---------+----------+-----+---------+-----------+
4693 //
4694 // The first n elements are Smis, each of them specifies the number of codes
4695 // in the corresponding group. The subsequent elements contain grouped code
4696 // objects. The suffix of the array can be filled with the undefined value if
4697 // the number of codes is less than the length of the array. The order of the
4698 // code objects within a group is not preserved.
4699 //
4700 // All code indexes used in the class are counted starting from the first
4701 // code object of the first group. In other words, code index 0 corresponds
4702 // to array index n = kCodesStartIndex.
4703
4704 class DependentCode: public FixedArray {
4690 public: 4705 public:
4691 inline int number_of_codes(); 4706 enum DependencyGroup {
4692 inline void set_number_of_codes(int value); 4707 // Group of code that weakly embed this map and depend on being
4708 // deoptimized when the map is garbage collected.
4709 kWeaklyEmbeddedGroup,
4710 // Group of code that omit run-time prototype checks for prototypes
4711 // described by this map. The group is deoptimized whenever an object
4712 // described by this map changes shape (and transitions to a new map),
4713 // possibly invalidating the assumptions embedded in the code.
4714 kPrototypeCheckGroup,
4715 kGroupCount = kPrototypeCheckGroup + 1
4716 };
Michael Starzinger 2013/02/14 12:44:04 Add an empty newline after this enum.
ulan 2013/02/15 09:24:02 Done.
4717 // Array for holding the index of the first code object of each group.
4718 // The last element stores the total number of code objects.
4719 class GroupStartIndexes {
4720 public:
4721 explicit GroupStartIndexes(DependentCode* codes);
4722 void Recompute(DependentCode* codes);
4723 int at(int i) { return start_indexes_[i]; }
4724 private:
4725 int start_indexes_[kGroupCount + 1];
4726 };
Michael Starzinger 2013/02/14 12:44:04 Add and empty newline after this class.
ulan 2013/02/15 09:24:02 Done.
4727 bool Contains(DependencyGroup group, Code* code);
4728 static Handle<DependentCode> Insert(Handle<DependentCode> codes,
4729 DependencyGroup group,
4730 Handle<Code> value);
4731 void DeoptimizeDependentCodeGroup(DependentCode::DependencyGroup group);
4732
4733 // The following low-level accessors should only be used by this class
4734 // and the mark compactor.
Michael Starzinger 2013/02/14 12:44:04 s/mark compactor/mark compact collector/
ulan 2013/02/15 09:24:02 Done.
4735 inline int number_of_codes(DependencyGroup group);
4736 inline void set_number_of_codes(DependencyGroup group, int value);
4693 inline Code* code_at(int i); 4737 inline Code* code_at(int i);
4694 inline void set_code_at(int i, Code* value); 4738 inline void set_code_at(int i, Code* value);
4695 inline Object** code_slot_at(int i); 4739 inline Object** code_slot_at(int i);
4696 inline void clear_code_at(int i); 4740 inline void clear_code_at(int i);
4697 static Handle<DependentCodes> Append(Handle<DependentCodes> codes, 4741 static inline DependentCode* cast(Object* object);
4698 Handle<Code> value); 4742
4699 static inline DependentCodes* cast(Object* object);
4700 bool Contains(Code* code);
4701 private: 4743 private:
4702 static const int kNumberOfCodesIndex = 0; 4744 // Make a room at the end of the given group by moving out the first
4703 static const int kCodesIndex = 1; 4745 // code objects of the subsequent groups.
4746 inline void ExtendGroup(DependencyGroup group);
4747 static const int kCodesStartIndex = kGroupCount;
4704 }; 4748 };
4705 4749
4706 4750
4707 // All heap objects have a Map that describes their structure. 4751 // All heap objects have a Map that describes their structure.
4708 // A Map contains information about: 4752 // A Map contains information about:
4709 // - Size information about the object 4753 // - Size information about the object
4710 // - How to iterate over an object (for garbage collection) 4754 // - How to iterate over an object (for garbage collection)
4711 class Map: public HeapObject { 4755 class Map: public HeapObject {
4712 public: 4756 public:
4713 // Instance size. 4757 // Instance size.
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
4926 4970
4927 inline JSFunction* unchecked_constructor(); 4971 inline JSFunction* unchecked_constructor();
4928 4972
4929 // [instance descriptors]: describes the object. 4973 // [instance descriptors]: describes the object.
4930 DECL_ACCESSORS(instance_descriptors, DescriptorArray) 4974 DECL_ACCESSORS(instance_descriptors, DescriptorArray)
4931 inline void InitializeDescriptors(DescriptorArray* descriptors); 4975 inline void InitializeDescriptors(DescriptorArray* descriptors);
4932 4976
4933 // [stub cache]: contains stubs compiled for this map. 4977 // [stub cache]: contains stubs compiled for this map.
4934 DECL_ACCESSORS(code_cache, Object) 4978 DECL_ACCESSORS(code_cache, Object)
4935 4979
4936 // [dependent codes]: list of optimized codes that have this map embedded. 4980 // [dependent codes]: list of optimized codes that have this map embedded.
Michael Starzinger 2013/02/14 12:44:04 The name in the comment is outdated.
ulan 2013/02/15 09:24:02 Done.
4937 DECL_ACCESSORS(dependent_codes, DependentCodes) 4981 DECL_ACCESSORS(dependent_code, DependentCode)
4938 4982
4939 // [back pointer]: points back to the parent map from which a transition 4983 // [back pointer]: points back to the parent map from which a transition
4940 // leads to this map. The field overlaps with prototype transitions and the 4984 // leads to this map. The field overlaps with prototype transitions and the
4941 // back pointer will be moved into the prototype transitions array if 4985 // back pointer will be moved into the prototype transitions array if
4942 // required. 4986 // required.
4943 inline Object* GetBackPointer(); 4987 inline Object* GetBackPointer();
4944 inline void SetBackPointer(Object* value, 4988 inline void SetBackPointer(Object* value,
4945 WriteBarrierMode mode = UPDATE_WRITE_BARRIER); 4989 WriteBarrierMode mode = UPDATE_WRITE_BARRIER);
4946 inline void init_back_pointer(Object* undefined); 4990 inline void init_back_pointer(Object* undefined);
4947 4991
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
5144 // heap verification is turned on. 5188 // heap verification is turned on.
5145 void ZapPrototypeTransitions(); 5189 void ZapPrototypeTransitions();
5146 void ZapTransitions(); 5190 void ZapTransitions();
5147 5191
5148 bool CanTransition() { 5192 bool CanTransition() {
5149 // Only JSObject and subtypes have map transitions and back pointers. 5193 // Only JSObject and subtypes have map transitions and back pointers.
5150 STATIC_ASSERT(LAST_TYPE == LAST_JS_OBJECT_TYPE); 5194 STATIC_ASSERT(LAST_TYPE == LAST_JS_OBJECT_TYPE);
5151 return instance_type() >= FIRST_JS_OBJECT_TYPE; 5195 return instance_type() >= FIRST_JS_OBJECT_TYPE;
5152 } 5196 }
5153 5197
5154 inline void AddDependentCode(Handle<Code> code); 5198
5199 inline void NotifyObjectLayoutChange();
5200
5201 inline bool CanOmitPrototypeChecks();
5202
5203 inline void AddDependentCode(DependentCode::DependencyGroup group,
5204 Handle<Code> code);
5155 5205
5156 // Dispatched behavior. 5206 // Dispatched behavior.
5157 DECLARE_PRINTER(Map) 5207 DECLARE_PRINTER(Map)
5158 DECLARE_VERIFIER(Map) 5208 DECLARE_VERIFIER(Map)
5159 5209
5160 #ifdef VERIFY_HEAP 5210 #ifdef VERIFY_HEAP
5161 void SharedMapVerify(); 5211 void SharedMapVerify();
5162 #endif 5212 #endif
5163 5213
5164 inline int visitor_id(); 5214 inline int visitor_id();
(...skipping 29 matching lines...) Expand all
5194 static const int kConstructorOffset = kPrototypeOffset + kPointerSize; 5244 static const int kConstructorOffset = kPrototypeOffset + kPointerSize;
5195 // Storage for the transition array is overloaded to directly contain a back 5245 // Storage for the transition array is overloaded to directly contain a back
5196 // pointer if unused. When the map has transitions, the back pointer is 5246 // pointer if unused. When the map has transitions, the back pointer is
5197 // transferred to the transition array and accessed through an extra 5247 // transferred to the transition array and accessed through an extra
5198 // indirection. 5248 // indirection.
5199 static const int kTransitionsOrBackPointerOffset = 5249 static const int kTransitionsOrBackPointerOffset =
5200 kConstructorOffset + kPointerSize; 5250 kConstructorOffset + kPointerSize;
5201 static const int kDescriptorsOffset = 5251 static const int kDescriptorsOffset =
5202 kTransitionsOrBackPointerOffset + kPointerSize; 5252 kTransitionsOrBackPointerOffset + kPointerSize;
5203 static const int kCodeCacheOffset = kDescriptorsOffset + kPointerSize; 5253 static const int kCodeCacheOffset = kDescriptorsOffset + kPointerSize;
5204 static const int kDependentCodesOffset = kCodeCacheOffset + kPointerSize; 5254 static const int kDependentCodeOffset = kCodeCacheOffset + kPointerSize;
5205 static const int kBitField3Offset = kDependentCodesOffset + kPointerSize; 5255 static const int kBitField3Offset = kDependentCodeOffset + kPointerSize;
5206 static const int kSize = kBitField3Offset + kPointerSize; 5256 static const int kSize = kBitField3Offset + kPointerSize;
5207 5257
5208 // Layout of pointer fields. Heap iteration code relies on them 5258 // Layout of pointer fields. Heap iteration code relies on them
5209 // being continuously allocated. 5259 // being continuously allocated.
5210 static const int kPointerFieldsBeginOffset = Map::kPrototypeOffset; 5260 static const int kPointerFieldsBeginOffset = Map::kPrototypeOffset;
5211 static const int kPointerFieldsEndOffset = kBitField3Offset + kPointerSize; 5261 static const int kPointerFieldsEndOffset = kBitField3Offset + kPointerSize;
5212 5262
5213 // Byte offsets within kInstanceSizesOffset. 5263 // Byte offsets within kInstanceSizesOffset.
5214 static const int kInstanceSizeOffset = kInstanceSizesOffset + 0; 5264 static const int kInstanceSizeOffset = kInstanceSizesOffset + 0;
5215 static const int kInObjectPropertiesByte = 1; 5265 static const int kInObjectPropertiesByte = 1;
(...skipping 3669 matching lines...) Expand 10 before | Expand all | Expand 10 after
8885 } else { 8935 } else {
8886 value &= ~(1 << bit_position); 8936 value &= ~(1 << bit_position);
8887 } 8937 }
8888 return value; 8938 return value;
8889 } 8939 }
8890 }; 8940 };
8891 8941
8892 } } // namespace v8::internal 8942 } } // namespace v8::internal
8893 8943
8894 #endif // V8_OBJECTS_H_ 8944 #endif // V8_OBJECTS_H_
OLDNEW
« src/mark-compact.cc ('K') | « src/mips/lithium-codegen-mips.cc ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698