| 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 #include "src/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #include "src/accessors.h" | 7 #include "src/accessors.h" |
| 8 #include "src/api.h" | 8 #include "src/api.h" |
| 9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
| 10 #include "src/base/once.h" | 10 #include "src/base/once.h" |
| (...skipping 2100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2111 if (allocation.To(&target)) { | 2111 if (allocation.To(&target)) { |
| 2112 // Order is important here: Set the promotion limit before storing a | 2112 // Order is important here: Set the promotion limit before storing a |
| 2113 // filler for double alignment or migrating the object. Otherwise we | 2113 // filler for double alignment or migrating the object. Otherwise we |
| 2114 // may end up overwriting promotion queue entries when we migrate the | 2114 // may end up overwriting promotion queue entries when we migrate the |
| 2115 // object. | 2115 // object. |
| 2116 heap->promotion_queue()->SetNewLimit(heap->new_space()->top()); | 2116 heap->promotion_queue()->SetNewLimit(heap->new_space()->top()); |
| 2117 | 2117 |
| 2118 if (alignment != kObjectAlignment) { | 2118 if (alignment != kObjectAlignment) { |
| 2119 target = EnsureDoubleAligned(heap, target, allocation_size); | 2119 target = EnsureDoubleAligned(heap, target, allocation_size); |
| 2120 } | 2120 } |
| 2121 MigrateObject(heap, object, target, object_size); |
| 2121 | 2122 |
| 2122 // Order is important: slot might be inside of the target if target | 2123 // Update slot to new target. |
| 2123 // was allocated over a dead object and slot comes from the store | |
| 2124 // buffer. | |
| 2125 *slot = target; | 2124 *slot = target; |
| 2126 MigrateObject(heap, object, target, object_size); | |
| 2127 | 2125 |
| 2128 heap->IncrementSemiSpaceCopiedObjectSize(object_size); | 2126 heap->IncrementSemiSpaceCopiedObjectSize(object_size); |
| 2129 return true; | 2127 return true; |
| 2130 } | 2128 } |
| 2131 return false; | 2129 return false; |
| 2132 } | 2130 } |
| 2133 | 2131 |
| 2134 | 2132 |
| 2135 template <ObjectContents object_contents, int alignment> | 2133 template <ObjectContents object_contents, int alignment> |
| 2136 static inline bool PromoteObject(Map* map, HeapObject** slot, | 2134 static inline bool PromoteObject(Map* map, HeapObject** slot, |
| (...skipping 13 matching lines...) Expand all Loading... |
| 2150 } else { | 2148 } else { |
| 2151 DCHECK(heap->AllowedToBeMigrated(object, OLD_POINTER_SPACE)); | 2149 DCHECK(heap->AllowedToBeMigrated(object, OLD_POINTER_SPACE)); |
| 2152 allocation = heap->old_pointer_space()->AllocateRaw(allocation_size); | 2150 allocation = heap->old_pointer_space()->AllocateRaw(allocation_size); |
| 2153 } | 2151 } |
| 2154 | 2152 |
| 2155 HeapObject* target = NULL; // Initialization to please compiler. | 2153 HeapObject* target = NULL; // Initialization to please compiler. |
| 2156 if (allocation.To(&target)) { | 2154 if (allocation.To(&target)) { |
| 2157 if (alignment != kObjectAlignment) { | 2155 if (alignment != kObjectAlignment) { |
| 2158 target = EnsureDoubleAligned(heap, target, allocation_size); | 2156 target = EnsureDoubleAligned(heap, target, allocation_size); |
| 2159 } | 2157 } |
| 2158 MigrateObject(heap, object, target, object_size); |
| 2160 | 2159 |
| 2161 // Order is important: slot might be inside of the target if target | 2160 // Update slot to new target. |
| 2162 // was allocated over a dead object and slot comes from the store | 2161 *slot = target; |
| 2163 // buffer. | |
| 2164 | |
| 2165 // Unfortunately, the allocation can also write over the slot if the slot | |
| 2166 // was in free space and the allocation wrote free list data (such as the | |
| 2167 // free list map or entry size) over the slot. We guard against this by | |
| 2168 // checking that the slot still points to the object being moved. This | |
| 2169 // should be sufficient because neither the free list map nor the free | |
| 2170 // list entry size should look like a new space pointer (the former is an | |
| 2171 // old space pointer, the latter is word-aligned). | |
| 2172 if (*slot == object) { | |
| 2173 *slot = target; | |
| 2174 } | |
| 2175 MigrateObject(heap, object, target, object_size); | |
| 2176 | 2162 |
| 2177 if (object_contents == POINTER_OBJECT) { | 2163 if (object_contents == POINTER_OBJECT) { |
| 2178 if (map->instance_type() == JS_FUNCTION_TYPE) { | 2164 if (map->instance_type() == JS_FUNCTION_TYPE) { |
| 2179 heap->promotion_queue()->insert(target, | 2165 heap->promotion_queue()->insert(target, |
| 2180 JSFunction::kNonWeakFieldsEndOffset); | 2166 JSFunction::kNonWeakFieldsEndOffset); |
| 2181 } else { | 2167 } else { |
| 2182 heap->promotion_queue()->insert(target, object_size); | 2168 heap->promotion_queue()->insert(target, object_size); |
| 2183 } | 2169 } |
| 2184 } | 2170 } |
| 2185 heap->IncrementPromotedObjectsSize(object_size); | 2171 heap->IncrementPromotedObjectsSize(object_size); |
| (...skipping 4359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6545 static_cast<int>(object_sizes_last_time_[index])); | 6531 static_cast<int>(object_sizes_last_time_[index])); |
| 6546 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) | 6532 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) |
| 6547 #undef ADJUST_LAST_TIME_OBJECT_COUNT | 6533 #undef ADJUST_LAST_TIME_OBJECT_COUNT |
| 6548 | 6534 |
| 6549 MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); | 6535 MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); |
| 6550 MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); | 6536 MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); |
| 6551 ClearObjectStats(); | 6537 ClearObjectStats(); |
| 6552 } | 6538 } |
| 6553 } | 6539 } |
| 6554 } // namespace v8::internal | 6540 } // namespace v8::internal |
| OLD | NEW |