OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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/heap/spaces.h" | 5 #include "src/heap/spaces.h" |
6 | 6 |
7 #include "src/base/bits.h" | 7 #include "src/base/bits.h" |
8 #include "src/base/platform/platform.h" | 8 #include "src/base/platform/platform.h" |
9 #include "src/full-codegen/full-codegen.h" | 9 #include "src/full-codegen/full-codegen.h" |
10 #include "src/heap/mark-compact.h" | 10 #include "src/heap/mark-compact.h" |
(...skipping 2915 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2926 LargePage* page = reinterpret_cast<LargePage*>(e->value); | 2926 LargePage* page = reinterpret_cast<LargePage*>(e->value); |
2927 DCHECK(page->is_valid()); | 2927 DCHECK(page->is_valid()); |
2928 if (page->Contains(a)) { | 2928 if (page->Contains(a)) { |
2929 return page; | 2929 return page; |
2930 } | 2930 } |
2931 } | 2931 } |
2932 return NULL; | 2932 return NULL; |
2933 } | 2933 } |
2934 | 2934 |
2935 | 2935 |
| 2936 void LargeObjectSpace::ClearMarkingStateOfLiveObjects() { |
| 2937 LargePage* current = first_page_; |
| 2938 while (current != NULL) { |
| 2939 HeapObject* object = current->GetObject(); |
| 2940 MarkBit mark_bit = Marking::MarkBitFrom(object); |
| 2941 DCHECK(Marking::IsBlackOrGrey(mark_bit)); |
| 2942 Marking::BlackToWhite(mark_bit); |
| 2943 Page::FromAddress(object->address())->ResetProgressBar(); |
| 2944 Page::FromAddress(object->address())->ResetLiveBytes(); |
| 2945 current = current->next_page(); |
| 2946 } |
| 2947 } |
| 2948 |
| 2949 |
2936 void LargeObjectSpace::FreeUnmarkedObjects() { | 2950 void LargeObjectSpace::FreeUnmarkedObjects() { |
2937 LargePage* previous = NULL; | 2951 LargePage* previous = NULL; |
2938 LargePage* current = first_page_; | 2952 LargePage* current = first_page_; |
2939 while (current != NULL) { | 2953 while (current != NULL) { |
2940 HeapObject* object = current->GetObject(); | 2954 HeapObject* object = current->GetObject(); |
2941 // Can this large page contain pointers to non-trivial objects. No other | |
2942 // pointer object is this big. | |
2943 bool is_pointer_object = object->IsFixedArray(); | |
2944 MarkBit mark_bit = Marking::MarkBitFrom(object); | 2955 MarkBit mark_bit = Marking::MarkBitFrom(object); |
2945 if (Marking::IsBlackOrGrey(mark_bit)) { | 2956 if (Marking::IsBlackOrGrey(mark_bit)) { |
2946 Marking::BlackToWhite(mark_bit); | |
2947 Page::FromAddress(object->address())->ResetProgressBar(); | |
2948 Page::FromAddress(object->address())->ResetLiveBytes(); | |
2949 previous = current; | 2957 previous = current; |
2950 current = current->next_page(); | 2958 current = current->next_page(); |
2951 } else { | 2959 } else { |
2952 LargePage* page = current; | 2960 LargePage* page = current; |
2953 // Cut the chunk out from the chunk list. | 2961 // Cut the chunk out from the chunk list. |
2954 current = current->next_page(); | 2962 current = current->next_page(); |
2955 if (previous == NULL) { | 2963 if (previous == NULL) { |
2956 first_page_ = current; | 2964 first_page_ = current; |
2957 } else { | 2965 } else { |
2958 previous->set_next_page(current); | 2966 previous->set_next_page(current); |
(...skipping 10 matching lines...) Expand all Loading... |
2969 // Use variable alignment to help pass length check (<= 80 characters) | 2977 // Use variable alignment to help pass length check (<= 80 characters) |
2970 // of single line in tools/presubmit.py. | 2978 // of single line in tools/presubmit.py. |
2971 const intptr_t alignment = MemoryChunk::kAlignment; | 2979 const intptr_t alignment = MemoryChunk::kAlignment; |
2972 uintptr_t base = reinterpret_cast<uintptr_t>(page) / alignment; | 2980 uintptr_t base = reinterpret_cast<uintptr_t>(page) / alignment; |
2973 uintptr_t limit = base + (page->size() - 1) / alignment; | 2981 uintptr_t limit = base + (page->size() - 1) / alignment; |
2974 for (uintptr_t key = base; key <= limit; key++) { | 2982 for (uintptr_t key = base; key <= limit; key++) { |
2975 chunk_map_.Remove(reinterpret_cast<void*>(key), | 2983 chunk_map_.Remove(reinterpret_cast<void*>(key), |
2976 static_cast<uint32_t>(key)); | 2984 static_cast<uint32_t>(key)); |
2977 } | 2985 } |
2978 | 2986 |
2979 if (is_pointer_object) { | 2987 heap()->QueueMemoryChunkForFree(page); |
2980 heap()->QueueMemoryChunkForFree(page); | |
2981 } else { | |
2982 heap()->isolate()->memory_allocator()->Free(page); | |
2983 } | |
2984 } | 2988 } |
2985 } | 2989 } |
2986 heap()->FreeQueuedChunks(); | |
2987 } | 2990 } |
2988 | 2991 |
2989 | 2992 |
2990 bool LargeObjectSpace::Contains(HeapObject* object) { | 2993 bool LargeObjectSpace::Contains(HeapObject* object) { |
2991 Address address = object->address(); | 2994 Address address = object->address(); |
2992 MemoryChunk* chunk = MemoryChunk::FromAddress(address); | 2995 MemoryChunk* chunk = MemoryChunk::FromAddress(address); |
2993 | 2996 |
2994 bool owned = (chunk->owner() == this); | 2997 bool owned = (chunk->owner() == this); |
2995 | 2998 |
2996 SLOW_DCHECK(!owned || FindObject(address)->IsHeapObject()); | 2999 SLOW_DCHECK(!owned || FindObject(address)->IsHeapObject()); |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3110 object->ShortPrint(); | 3113 object->ShortPrint(); |
3111 PrintF("\n"); | 3114 PrintF("\n"); |
3112 } | 3115 } |
3113 printf(" --------------------------------------\n"); | 3116 printf(" --------------------------------------\n"); |
3114 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); | 3117 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); |
3115 } | 3118 } |
3116 | 3119 |
3117 #endif // DEBUG | 3120 #endif // DEBUG |
3118 } // namespace internal | 3121 } // namespace internal |
3119 } // namespace v8 | 3122 } // namespace v8 |
OLD | NEW |