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/base/atomicops.h" | 7 #include "src/base/atomicops.h" |
8 #include "src/base/bits.h" | 8 #include "src/base/bits.h" |
9 #include "src/code-stubs.h" | 9 #include "src/code-stubs.h" |
10 #include "src/compilation-cache.h" | 10 #include "src/compilation-cache.h" |
(...skipping 3120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3131 | 3131 |
3132 bool MarkCompactCollector::IsSlotInLiveObject(Address slot) { | 3132 bool MarkCompactCollector::IsSlotInLiveObject(Address slot) { |
3133 HeapObject* object = NULL; | 3133 HeapObject* object = NULL; |
3134 // The target object is black but we don't know if the source slot is black. | 3134 // The target object is black but we don't know if the source slot is black. |
3135 // The source object could have died and the slot could be part of a free | 3135 // The source object could have died and the slot could be part of a free |
3136 // space. Find out based on mark bits if the slot is part of a live object. | 3136 // space. Find out based on mark bits if the slot is part of a live object. |
3137 if (!IsSlotInBlackObject(Page::FromAddress(slot), slot, &object)) { | 3137 if (!IsSlotInBlackObject(Page::FromAddress(slot), slot, &object)) { |
3138 return false; | 3138 return false; |
3139 } | 3139 } |
3140 | 3140 |
3141 #if V8_DOUBLE_FIELDS_UNBOXING | |
3142 // |object| is NULL only when the slot belongs to large object space. | 3141 // |object| is NULL only when the slot belongs to large object space. |
3143 DCHECK(object != NULL || | 3142 DCHECK(object != NULL || |
3144 Page::FromAnyPointerAddress(heap_, slot)->owner() == | 3143 Page::FromAnyPointerAddress(heap_, slot)->owner() == |
3145 heap_->lo_space()); | 3144 heap_->lo_space()); |
3146 // We don't need to check large objects' layout descriptor since it can't | 3145 // We don't need to check large objects' layout descriptor since it can't |
3147 // contain in-object fields anyway. | 3146 // contain in-object fields anyway. |
3148 if (object != NULL) { | 3147 if (object != NULL) { |
3149 // Filter out slots that happens to point to unboxed double fields. | 3148 // TODO(ishell): This is a workaround for crbug/454297. We must not have |
3150 LayoutDescriptorHelper helper(object->map()); | 3149 // slots in data objects at all. Remove this once we found the root cause. |
3151 bool has_only_tagged_fields = helper.all_fields_tagged(); | 3150 InstanceType type = object->map()->instance_type(); |
3152 if (!has_only_tagged_fields && | 3151 // Slots in maps and code can't be invalid because they are never shrunk. |
3153 !helper.IsTagged(static_cast<int>(slot - object->address()))) { | 3152 if (type == MAP_TYPE || type == CODE_TYPE) return true; |
3154 return false; | 3153 if (type == CONSTANT_POOL_ARRAY_TYPE) { |
| 3154 if (FLAG_enable_ool_constant_pool) { |
| 3155 // TODO(ishell): implement constant pool support if we ever enable it. |
| 3156 UNIMPLEMENTED(); |
| 3157 } else { |
| 3158 // This is left here just to make constant pool unit tests work. |
| 3159 return true; |
| 3160 } |
| 3161 } |
| 3162 // Consider slots in objects that contain ONLY raw data as invalid. |
| 3163 if (object->MayContainRawValues()) return false; |
| 3164 if (FLAG_unbox_double_fields) { |
| 3165 // Filter out slots that happen to point to unboxed double fields. |
| 3166 LayoutDescriptorHelper helper(object->map()); |
| 3167 bool has_only_tagged_fields = helper.all_fields_tagged(); |
| 3168 if (!has_only_tagged_fields && |
| 3169 !helper.IsTagged(static_cast<int>(slot - object->address()))) { |
| 3170 return false; |
| 3171 } |
3155 } | 3172 } |
3156 } | 3173 } |
3157 #endif | |
3158 | 3174 |
3159 return true; | 3175 return true; |
3160 } | 3176 } |
3161 | 3177 |
3162 | 3178 |
3163 void MarkCompactCollector::VerifyIsSlotInLiveObject(Address slot, | 3179 void MarkCompactCollector::VerifyIsSlotInLiveObject(Address slot, |
3164 HeapObject* object) { | 3180 HeapObject* object) { |
3165 // The target object has to be black. | 3181 // The target object has to be black. |
3166 CHECK(Marking::IsBlack(Marking::MarkBitFrom(object))); | 3182 CHECK(Marking::IsBlack(Marking::MarkBitFrom(object))); |
3167 | 3183 |
(...skipping 1490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4658 SlotsBuffer* buffer = *buffer_address; | 4674 SlotsBuffer* buffer = *buffer_address; |
4659 while (buffer != NULL) { | 4675 while (buffer != NULL) { |
4660 SlotsBuffer* next_buffer = buffer->next(); | 4676 SlotsBuffer* next_buffer = buffer->next(); |
4661 DeallocateBuffer(buffer); | 4677 DeallocateBuffer(buffer); |
4662 buffer = next_buffer; | 4678 buffer = next_buffer; |
4663 } | 4679 } |
4664 *buffer_address = NULL; | 4680 *buffer_address = NULL; |
4665 } | 4681 } |
4666 } // namespace internal | 4682 } // namespace internal |
4667 } // namespace v8 | 4683 } // namespace v8 |
OLD | NEW |