OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 // | 4 // |
5 // Review notes: | 5 // Review notes: |
6 // | 6 // |
7 // - The use of macros in these inline functions may seem superfluous | 7 // - The use of macros in these inline functions may seem superfluous |
8 // but it is absolutely needed to make sure gcc generates optimal | 8 // but it is absolutely needed to make sure gcc generates optimal |
9 // code. gcc is not happy when attempting to inline too deep. | 9 // code. gcc is not happy when attempting to inline too deep. |
10 // | 10 // |
(...skipping 5190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5201 | 5201 |
5202 | 5202 |
5203 Map* Map::elements_transition_map() { | 5203 Map* Map::elements_transition_map() { |
5204 int index = transitions()->Search(GetHeap()->elements_transition_symbol()); | 5204 int index = transitions()->Search(GetHeap()->elements_transition_symbol()); |
5205 return transitions()->GetTarget(index); | 5205 return transitions()->GetTarget(index); |
5206 } | 5206 } |
5207 | 5207 |
5208 | 5208 |
5209 bool Map::CanHaveMoreTransitions() { | 5209 bool Map::CanHaveMoreTransitions() { |
5210 if (!HasTransitionArray()) return true; | 5210 if (!HasTransitionArray()) return true; |
5211 return FixedArray::SizeFor(transitions()->length() + | 5211 return transitions()->number_of_transitions() <= |
5212 TransitionArray::kTransitionSize) | 5212 TransitionArray::kMaxNumberOfTransitions; |
5213 <= Page::kMaxRegularHeapObjectSize; | |
5214 } | 5213 } |
5215 | 5214 |
5216 | 5215 |
5217 Map* Map::GetTransition(int transition_index) { | 5216 Map* Map::GetTransition(int transition_index) { |
5218 return transitions()->GetTarget(transition_index); | 5217 return transitions()->GetTarget(transition_index); |
5219 } | 5218 } |
5220 | 5219 |
5221 | 5220 |
5222 int Map::SearchTransition(Name* name) { | 5221 int Map::SearchTransition(Name* name) { |
5223 if (HasTransitionArray()) return transitions()->Search(name); | 5222 if (HasTransitionArray()) return transitions()->Search(name); |
(...skipping 1769 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6993 void Map::ClearCodeCache(Heap* heap) { | 6992 void Map::ClearCodeCache(Heap* heap) { |
6994 // No write barrier is needed since empty_fixed_array is not in new space. | 6993 // No write barrier is needed since empty_fixed_array is not in new space. |
6995 // Please note this function is used during marking: | 6994 // Please note this function is used during marking: |
6996 // - MarkCompactCollector::MarkUnmarkedObject | 6995 // - MarkCompactCollector::MarkUnmarkedObject |
6997 // - IncrementalMarking::Step | 6996 // - IncrementalMarking::Step |
6998 DCHECK(!heap->InNewSpace(heap->empty_fixed_array())); | 6997 DCHECK(!heap->InNewSpace(heap->empty_fixed_array())); |
6999 WRITE_FIELD(this, kCodeCacheOffset, heap->empty_fixed_array()); | 6998 WRITE_FIELD(this, kCodeCacheOffset, heap->empty_fixed_array()); |
7000 } | 6999 } |
7001 | 7000 |
7002 | 7001 |
| 7002 int Map::SlackForArraySize(int old_size, int size_limit) { |
| 7003 const int max_slack = size_limit - old_size; |
| 7004 DCHECK(max_slack >= 0); |
| 7005 if (old_size < 4) return Min(max_slack, 1); |
| 7006 return Min(max_slack, old_size / 2); |
| 7007 } |
| 7008 |
| 7009 |
7003 void JSArray::EnsureSize(Handle<JSArray> array, int required_size) { | 7010 void JSArray::EnsureSize(Handle<JSArray> array, int required_size) { |
7004 DCHECK(array->HasFastSmiOrObjectElements()); | 7011 DCHECK(array->HasFastSmiOrObjectElements()); |
7005 Handle<FixedArray> elts = handle(FixedArray::cast(array->elements())); | 7012 Handle<FixedArray> elts = handle(FixedArray::cast(array->elements())); |
7006 const int kArraySizeThatFitsComfortablyInNewSpace = 128; | 7013 const int kArraySizeThatFitsComfortablyInNewSpace = 128; |
7007 if (elts->length() < required_size) { | 7014 if (elts->length() < required_size) { |
7008 // Doubling in size would be overkill, but leave some slack to avoid | 7015 // Doubling in size would be overkill, but leave some slack to avoid |
7009 // constantly growing. | 7016 // constantly growing. |
7010 Expand(array, required_size + (required_size >> 3)); | 7017 Expand(array, required_size + (required_size >> 3)); |
7011 // It's a performance benefit to keep a frequently used array in new-space. | 7018 // It's a performance benefit to keep a frequently used array in new-space. |
7012 } else if (!array->GetHeap()->new_space()->Contains(*elts) && | 7019 } else if (!array->GetHeap()->new_space()->Contains(*elts) && |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7283 #undef READ_SHORT_FIELD | 7290 #undef READ_SHORT_FIELD |
7284 #undef WRITE_SHORT_FIELD | 7291 #undef WRITE_SHORT_FIELD |
7285 #undef READ_BYTE_FIELD | 7292 #undef READ_BYTE_FIELD |
7286 #undef WRITE_BYTE_FIELD | 7293 #undef WRITE_BYTE_FIELD |
7287 #undef NOBARRIER_READ_BYTE_FIELD | 7294 #undef NOBARRIER_READ_BYTE_FIELD |
7288 #undef NOBARRIER_WRITE_BYTE_FIELD | 7295 #undef NOBARRIER_WRITE_BYTE_FIELD |
7289 | 7296 |
7290 } } // namespace v8::internal | 7297 } } // namespace v8::internal |
7291 | 7298 |
7292 #endif // V8_OBJECTS_INL_H_ | 7299 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |