| 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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 if (IsSimpleTransition()) return 1; |
| 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( | 102 static MUST_USE_RESULT MaybeObject* NewWith( |
| 103 String* name, | 103 SimpleTransitionFlag flag, |
| 104 String* key, |
| 104 Map* target, | 105 Map* target, |
| 105 JSGlobalPropertyCell* descriptor_pointer, | 106 JSGlobalPropertyCell* descriptor_pointer, |
| 106 Object* back_pointer); | 107 Object* back_pointer); |
| 107 | 108 |
| 109 static MUST_USE_RESULT MaybeObject* AllocateDescriptorsHolder( |
| 110 JSGlobalPropertyCell* descriptor_pointer); |
| 111 |
| 112 MUST_USE_RESULT MaybeObject* ExtendToFullTransitionArray(); |
| 113 |
| 108 // Copy the transition array, inserting a new transition. | 114 // Copy the transition array, inserting a new transition. |
| 109 // TODO(verwaest): This should not cause an existing transition to be | 115 // TODO(verwaest): This should not cause an existing transition to be |
| 110 // overwritten. | 116 // overwritten. |
| 111 MUST_USE_RESULT MaybeObject* CopyInsert(String* name, Map* target); | 117 MUST_USE_RESULT MaybeObject* CopyInsert(String* name, Map* target); |
| 112 | 118 |
| 113 // Copy a single transition from the origin array. | 119 // Copy a single transition from the origin array. |
| 114 inline void NoIncrementalWriteBarrierCopyFrom(TransitionArray* origin, | 120 inline void NoIncrementalWriteBarrierCopyFrom(TransitionArray* origin, |
| 115 int origin_transition, | 121 int origin_transition, |
| 116 int target_transition); | 122 int target_transition); |
| 117 | 123 |
| 118 // Search a transition for a given property name. | 124 // Search a transition for a given property name. |
| 119 inline int Search(String* name); | 125 inline int Search(String* name); |
| 120 | 126 |
| 121 // Allocates a TransitionArray. | 127 // Allocates a TransitionArray. |
| 122 MUST_USE_RESULT static MaybeObject* Allocate( | 128 MUST_USE_RESULT static MaybeObject* Allocate( |
| 123 int number_of_transitions, | 129 int number_of_transitions, |
| 124 JSGlobalPropertyCell* descriptors_cell); | 130 JSGlobalPropertyCell* descriptors_cell); |
| 125 | 131 |
| 132 bool IsDescriptorsHolder() { return length() == kDescriptorsHolderSize; } |
| 133 bool IsSimpleTransition() { return length() == kSimpleTransitionSize; } |
| 134 bool IsFullTransitionArray() { return length() >= kFirstIndex; } |
| 135 |
| 126 // Casting. | 136 // Casting. |
| 127 static inline TransitionArray* cast(Object* obj); | 137 static inline TransitionArray* cast(Object* obj); |
| 128 | 138 |
| 129 // Constant for denoting key was not found. | 139 // Constant for denoting key was not found. |
| 130 static const int kNotFound = -1; | 140 static const int kNotFound = -1; |
| 131 | 141 |
| 132 static const int kDescriptorsPointerIndex = 0; | 142 static const int kDescriptorsPointerIndex = 0; |
| 133 static const int kBackPointerStorageIndex = 1; | 143 static const int kBackPointerStorageIndex = 1; |
| 144 static const int kDescriptorsHolderSize = 2; |
| 145 |
| 146 // Layout for full transition arrays. |
| 134 static const int kElementsTransitionIndex = 2; | 147 static const int kElementsTransitionIndex = 2; |
| 135 static const int kPrototypeTransitionsIndex = 3; | 148 static const int kPrototypeTransitionsIndex = 3; |
| 136 static const int kFirstIndex = 4; | 149 static const int kFirstIndex = 4; |
| 137 | 150 |
| 138 // Layout transition array header. | 151 // Layout for simple transition arrays. |
| 152 static const int kSimpleTransitionTarget = 2; |
| 153 static const int kSimpleTransitionSize = 3; |
| 154 static const int kSimpleTransitionIndex = 0; |
| 155 STATIC_ASSERT(kSimpleTransitionIndex != kNotFound); |
| 156 |
| 139 static const int kDescriptorsPointerOffset = FixedArray::kHeaderSize; | 157 static const int kDescriptorsPointerOffset = FixedArray::kHeaderSize; |
| 140 static const int kBackPointerStorageOffset = kDescriptorsPointerOffset + | 158 static const int kBackPointerStorageOffset = kDescriptorsPointerOffset + |
| 141 kPointerSize; | 159 kPointerSize; |
| 160 |
| 161 // Layout for the full transition array header. |
| 142 static const int kElementsTransitionOffset = kBackPointerStorageOffset + | 162 static const int kElementsTransitionOffset = kBackPointerStorageOffset + |
| 143 kPointerSize; | 163 kPointerSize; |
| 144 static const int kPrototypeTransitionsOffset = kElementsTransitionOffset + | 164 static const int kPrototypeTransitionsOffset = kElementsTransitionOffset + |
| 145 kPointerSize; | 165 kPointerSize; |
| 146 | 166 |
| 147 // Layout of map transition. | 167 // Layout of map transition entries in full transition arrays. |
| 148 static const int kTransitionKey = 0; | 168 static const int kTransitionKey = 0; |
| 149 static const int kTransitionTarget = 1; | 169 static const int kTransitionTarget = 1; |
| 150 static const int kTransitionSize = 2; | 170 static const int kTransitionSize = 2; |
| 151 | 171 |
| 152 #ifdef OBJECT_PRINT | 172 #ifdef OBJECT_PRINT |
| 153 // Print all the transitions. | 173 // Print all the transitions. |
| 154 inline void PrintTransitions() { | 174 inline void PrintTransitions() { |
| 155 PrintTransitions(stdout); | 175 PrintTransitions(stdout); |
| 156 } | 176 } |
| 157 void PrintTransitions(FILE* out); | 177 void PrintTransitions(FILE* out); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 185 String* key, | 205 String* key, |
| 186 Map* target); | 206 Map* target); |
| 187 | 207 |
| 188 DISALLOW_IMPLICIT_CONSTRUCTORS(TransitionArray); | 208 DISALLOW_IMPLICIT_CONSTRUCTORS(TransitionArray); |
| 189 }; | 209 }; |
| 190 | 210 |
| 191 | 211 |
| 192 } } // namespace v8::internal | 212 } } // namespace v8::internal |
| 193 | 213 |
| 194 #endif // V8_TRANSITIONS_H_ | 214 #endif // V8_TRANSITIONS_H_ |
| OLD | NEW |