| 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 5185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5196 | 5196 |
| 5197 | 5197 |
| 5198 Map* Map::elements_transition_map() { | 5198 Map* Map::elements_transition_map() { |
| 5199 int index = transitions()->Search(GetHeap()->elements_transition_symbol()); | 5199 int index = transitions()->Search(GetHeap()->elements_transition_symbol()); |
| 5200 return transitions()->GetTarget(index); | 5200 return transitions()->GetTarget(index); |
| 5201 } | 5201 } |
| 5202 | 5202 |
| 5203 | 5203 |
| 5204 bool Map::CanHaveMoreTransitions() { | 5204 bool Map::CanHaveMoreTransitions() { |
| 5205 if (!HasTransitionArray()) return true; | 5205 if (!HasTransitionArray()) return true; |
| 5206 return FixedArray::SizeFor(transitions()->length() + | 5206 return transitions()->number_of_transitions() < |
| 5207 TransitionArray::kTransitionSize) | 5207 TransitionArray::kMaxNumberOfTransitions; |
| 5208 <= Page::kMaxRegularHeapObjectSize; | |
| 5209 } | 5208 } |
| 5210 | 5209 |
| 5211 | 5210 |
| 5212 Map* Map::GetTransition(int transition_index) { | 5211 Map* Map::GetTransition(int transition_index) { |
| 5213 return transitions()->GetTarget(transition_index); | 5212 return transitions()->GetTarget(transition_index); |
| 5214 } | 5213 } |
| 5215 | 5214 |
| 5216 | 5215 |
| 5217 int Map::SearchTransition(Name* name) { | 5216 int Map::SearchTransition(Name* name) { |
| 5218 if (HasTransitionArray()) return transitions()->Search(name); | 5217 if (HasTransitionArray()) return transitions()->Search(name); |
| (...skipping 1769 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6988 void Map::ClearCodeCache(Heap* heap) { | 6987 void Map::ClearCodeCache(Heap* heap) { |
| 6989 // No write barrier is needed since empty_fixed_array is not in new space. | 6988 // No write barrier is needed since empty_fixed_array is not in new space. |
| 6990 // Please note this function is used during marking: | 6989 // Please note this function is used during marking: |
| 6991 // - MarkCompactCollector::MarkUnmarkedObject | 6990 // - MarkCompactCollector::MarkUnmarkedObject |
| 6992 // - IncrementalMarking::Step | 6991 // - IncrementalMarking::Step |
| 6993 DCHECK(!heap->InNewSpace(heap->empty_fixed_array())); | 6992 DCHECK(!heap->InNewSpace(heap->empty_fixed_array())); |
| 6994 WRITE_FIELD(this, kCodeCacheOffset, heap->empty_fixed_array()); | 6993 WRITE_FIELD(this, kCodeCacheOffset, heap->empty_fixed_array()); |
| 6995 } | 6994 } |
| 6996 | 6995 |
| 6997 | 6996 |
| 6997 int Map::SlackForArraySize(int old_size, int size_limit) { |
| 6998 const int max_slack = size_limit - old_size; |
| 6999 CHECK(max_slack >= 0); |
| 7000 if (old_size < 4) return Min(max_slack, 1); |
| 7001 return Min(max_slack, old_size / 2); |
| 7002 } |
| 7003 |
| 7004 |
| 6998 void JSArray::EnsureSize(Handle<JSArray> array, int required_size) { | 7005 void JSArray::EnsureSize(Handle<JSArray> array, int required_size) { |
| 6999 DCHECK(array->HasFastSmiOrObjectElements()); | 7006 DCHECK(array->HasFastSmiOrObjectElements()); |
| 7000 Handle<FixedArray> elts = handle(FixedArray::cast(array->elements())); | 7007 Handle<FixedArray> elts = handle(FixedArray::cast(array->elements())); |
| 7001 const int kArraySizeThatFitsComfortablyInNewSpace = 128; | 7008 const int kArraySizeThatFitsComfortablyInNewSpace = 128; |
| 7002 if (elts->length() < required_size) { | 7009 if (elts->length() < required_size) { |
| 7003 // Doubling in size would be overkill, but leave some slack to avoid | 7010 // Doubling in size would be overkill, but leave some slack to avoid |
| 7004 // constantly growing. | 7011 // constantly growing. |
| 7005 Expand(array, required_size + (required_size >> 3)); | 7012 Expand(array, required_size + (required_size >> 3)); |
| 7006 // It's a performance benefit to keep a frequently used array in new-space. | 7013 // It's a performance benefit to keep a frequently used array in new-space. |
| 7007 } else if (!array->GetHeap()->new_space()->Contains(*elts) && | 7014 } else if (!array->GetHeap()->new_space()->Contains(*elts) && |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7278 #undef READ_SHORT_FIELD | 7285 #undef READ_SHORT_FIELD |
| 7279 #undef WRITE_SHORT_FIELD | 7286 #undef WRITE_SHORT_FIELD |
| 7280 #undef READ_BYTE_FIELD | 7287 #undef READ_BYTE_FIELD |
| 7281 #undef WRITE_BYTE_FIELD | 7288 #undef WRITE_BYTE_FIELD |
| 7282 #undef NOBARRIER_READ_BYTE_FIELD | 7289 #undef NOBARRIER_READ_BYTE_FIELD |
| 7283 #undef NOBARRIER_WRITE_BYTE_FIELD | 7290 #undef NOBARRIER_WRITE_BYTE_FIELD |
| 7284 | 7291 |
| 7285 } } // namespace v8::internal | 7292 } } // namespace v8::internal |
| 7286 | 7293 |
| 7287 #endif // V8_OBJECTS_INL_H_ | 7294 #endif // V8_OBJECTS_INL_H_ |
| OLD | NEW |