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

Side by Side Diff: src/transitions.h

Issue 10909007: Sharing of descriptor arrays. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments Created 8 years, 3 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 | « src/string-stream.cc ('k') | src/transitions.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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 inline PropertyDetails GetTargetDetails(int transition_number); 65 inline PropertyDetails GetTargetDetails(int transition_number);
66 66
67 inline Map* elements_transition(); 67 inline Map* elements_transition();
68 inline void set_elements_transition( 68 inline void set_elements_transition(
69 Map* target, 69 Map* target,
70 WriteBarrierMode mode = UPDATE_WRITE_BARRIER); 70 WriteBarrierMode mode = UPDATE_WRITE_BARRIER);
71 inline bool HasElementsTransition(); 71 inline bool HasElementsTransition();
72 inline void ClearElementsTransition(); 72 inline void ClearElementsTransition();
73 73
74 inline DescriptorArray* descriptors(); 74 inline DescriptorArray* descriptors();
75 inline void set_descriptors(DescriptorArray* descriptors, 75 inline void set_descriptors(DescriptorArray* descriptors);
76 WriteBarrierMode mode = UPDATE_WRITE_BARRIER); 76 inline JSGlobalPropertyCell* descriptors_pointer();
77 inline Object** GetDescriptorsSlot(); 77 inline void set_descriptors_pointer(JSGlobalPropertyCell* pointer);
78 78
79 inline Object* back_pointer_storage(); 79 inline Object* back_pointer_storage();
80 inline void set_back_pointer_storage( 80 inline void set_back_pointer_storage(
81 Object* back_pointer, 81 Object* back_pointer,
82 WriteBarrierMode mode = UPDATE_WRITE_BARRIER); 82 WriteBarrierMode mode = UPDATE_WRITE_BARRIER);
83 83
84 inline FixedArray* GetPrototypeTransitions(); 84 inline FixedArray* GetPrototypeTransitions();
85 inline void SetPrototypeTransitions( 85 inline void SetPrototypeTransitions(
86 FixedArray* prototype_transitions, 86 FixedArray* prototype_transitions,
87 WriteBarrierMode mode = UPDATE_WRITE_BARRIER); 87 WriteBarrierMode mode = UPDATE_WRITE_BARRIER);
88 inline Object** GetPrototypeTransitionsSlot(); 88 inline Object** GetPrototypeTransitionsSlot();
89 inline bool HasPrototypeTransitions(); 89 inline bool HasPrototypeTransitions();
90 inline HeapObject* UncheckedPrototypeTransitions(); 90 inline HeapObject* UncheckedPrototypeTransitions();
91 91
92 // Returns the number of transitions in the array. 92 // Returns the number of transitions in the array.
93 int number_of_transitions() { 93 int number_of_transitions() {
94 ASSERT(length() >= kFirstIndex); 94 ASSERT(length() >= kFirstIndex);
95 int len = length(); 95 int len = length();
96 return len <= kFirstIndex ? 0 : (len - kFirstIndex) / kTransitionSize; 96 return len <= kFirstIndex ? 0 : (len - kFirstIndex) / kTransitionSize;
97 } 97 }
98 98
99 inline int number_of_entries() { return number_of_transitions(); } 99 inline int number_of_entries() { return number_of_transitions(); }
100 100
101 // Allocate a new transition array with a single entry. 101 // Allocate a new transition array with a single entry.
102 static MUST_USE_RESULT MaybeObject* NewWith(String* name, Map* target); 102 static MUST_USE_RESULT MaybeObject* NewWith(
103 String* name,
104 Map* target,
105 JSGlobalPropertyCell* descriptor_pointer,
106 Object* back_pointer);
103 107
104 // Copy the transition array, inserting a new transition. 108 // Copy the transition array, inserting a new transition.
105 // TODO(verwaest): This should not cause an existing transition to be 109 // TODO(verwaest): This should not cause an existing transition to be
106 // overwritten. 110 // overwritten.
107 MUST_USE_RESULT MaybeObject* CopyInsert(String* name, Map* target); 111 MUST_USE_RESULT MaybeObject* CopyInsert(String* name, Map* target);
108 112
109 // Copy a single transition from the origin array. 113 // Copy a single transition from the origin array.
110 inline void CopyFrom(TransitionArray* origin, 114 inline void CopyFrom(TransitionArray* origin,
111 int origin_transition, 115 int origin_transition,
112 int target_transition, 116 int target_transition,
113 const WhitenessWitness& witness); 117 const WhitenessWitness& witness);
114 118
115 // Search a transition for a given property name. 119 // Search a transition for a given property name.
116 inline int Search(String* name); 120 inline int Search(String* name);
117 121
118 // Allocates a TransitionArray. 122 // Allocates a TransitionArray.
119 MUST_USE_RESULT static MaybeObject* Allocate(int number_of_transitions); 123 MUST_USE_RESULT static MaybeObject* Allocate(
124 int number_of_transitions,
125 JSGlobalPropertyCell* descriptors_cell);
120 126
121 // Casting. 127 // Casting.
122 static inline TransitionArray* cast(Object* obj); 128 static inline TransitionArray* cast(Object* obj);
123 129
124 // Constant for denoting key was not found. 130 // Constant for denoting key was not found.
125 static const int kNotFound = -1; 131 static const int kNotFound = -1;
126 132
127 static const int kDescriptorsIndex = 0; 133 static const int kDescriptorsPointerIndex = 0;
128 static const int kBackPointerStorageIndex = 1; 134 static const int kBackPointerStorageIndex = 1;
129 static const int kElementsTransitionIndex = 2; 135 static const int kElementsTransitionIndex = 2;
130 static const int kPrototypeTransitionsIndex = 3; 136 static const int kPrototypeTransitionsIndex = 3;
131 static const int kFirstIndex = 4; 137 static const int kFirstIndex = 4;
132 138
133 // Layout transition array header. 139 // Layout transition array header.
134 static const int kDescriptorsOffset = FixedArray::kHeaderSize; 140 static const int kDescriptorsPointerOffset = FixedArray::kHeaderSize;
135 static const int kBackPointerStorageOffset = kDescriptorsOffset + 141 static const int kBackPointerStorageOffset = kDescriptorsPointerOffset +
136 kPointerSize; 142 kPointerSize;
137 static const int kElementsTransitionOffset = kBackPointerStorageOffset + 143 static const int kElementsTransitionOffset = kBackPointerStorageOffset +
138 kPointerSize; 144 kPointerSize;
139 static const int kPrototypeTransitionsOffset = kElementsTransitionOffset + 145 static const int kPrototypeTransitionsOffset = kElementsTransitionOffset +
140 kPointerSize; 146 kPointerSize;
141 147
142 // Layout of map transition. 148 // Layout of map transition.
143 static const int kTransitionKey = 0; 149 static const int kTransitionKey = 0;
144 static const int kTransitionTarget = 1; 150 static const int kTransitionTarget = 1;
145 static const int kTransitionSize = 2; 151 static const int kTransitionSize = 2;
146 152
147 #ifdef OBJECT_PRINT 153 #ifdef OBJECT_PRINT
148 // Print all the transitions. 154 // Print all the transitions.
149 inline void PrintTransitions() { 155 inline void PrintTransitions() {
150 PrintTransitions(stdout); 156 PrintTransitions(stdout);
151 } 157 }
152 void PrintTransitions(FILE* out); 158 void PrintTransitions(FILE* out);
153 #endif 159 #endif
154 160
155 #ifdef DEBUG 161 #ifdef DEBUG
156 bool IsSortedNoDuplicates(); 162 bool IsSortedNoDuplicates(int valid_entries = -1);
157 bool IsConsistentWithBackPointers(Map* current_map); 163 bool IsConsistentWithBackPointers(Map* current_map);
158 bool IsEqualTo(TransitionArray* other); 164 bool IsEqualTo(TransitionArray* other);
159 #endif 165 #endif
160 166
161 // The maximum number of transitions we want in a transition array (should 167 // The maximum number of transitions we want in a transition array (should
162 // fit in a page). 168 // fit in a page).
163 static const int kMaxNumberOfTransitions = 1024 + 512; 169 static const int kMaxNumberOfTransitions = 1024 + 512;
164 170
165 private: 171 private:
166 // Conversion from transition number to array indices. 172 // Conversion from transition number to array indices.
(...skipping 14 matching lines...) Expand all
181 Map* target, 187 Map* target,
182 const WhitenessWitness&); 188 const WhitenessWitness&);
183 189
184 DISALLOW_IMPLICIT_CONSTRUCTORS(TransitionArray); 190 DISALLOW_IMPLICIT_CONSTRUCTORS(TransitionArray);
185 }; 191 };
186 192
187 193
188 } } // namespace v8::internal 194 } } // namespace v8::internal
189 195
190 #endif // V8_TRANSITIONS_H_ 196 #endif // V8_TRANSITIONS_H_
OLDNEW
« no previous file with comments | « src/string-stream.cc ('k') | src/transitions.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698