Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(150)

Side by Side Diff: src/heap.cc

Issue 7891010: Implement shrinking of paged spaces during sweeping. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/gc
Patch Set: Added tracing output. Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/heap.h ('k') | src/mark-compact.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 min_in_mutator_(kMaxInt), 137 min_in_mutator_(kMaxInt),
138 alive_after_last_gc_(0), 138 alive_after_last_gc_(0),
139 last_gc_end_timestamp_(0.0), 139 last_gc_end_timestamp_(0.0),
140 store_buffer_(this), 140 store_buffer_(this),
141 marking_(this), 141 marking_(this),
142 incremental_marking_(this), 142 incremental_marking_(this),
143 number_idle_notifications_(0), 143 number_idle_notifications_(0),
144 last_idle_notification_gc_count_(0), 144 last_idle_notification_gc_count_(0),
145 last_idle_notification_gc_count_init_(false), 145 last_idle_notification_gc_count_init_(false),
146 configured_(false), 146 configured_(false),
147 last_empty_page_was_given_back_to_the_os_(false),
148 chunks_queued_for_free_(NULL) { 147 chunks_queued_for_free_(NULL) {
149 // Allow build-time customization of the max semispace size. Building 148 // Allow build-time customization of the max semispace size. Building
150 // V8 with snapshots and a non-default max semispace size is much 149 // V8 with snapshots and a non-default max semispace size is much
151 // easier if you can define it as part of the build environment. 150 // easier if you can define it as part of the build environment.
152 #if defined(V8_MAX_SEMISPACE_SIZE) 151 #if defined(V8_MAX_SEMISPACE_SIZE)
153 max_semispace_size_ = reserved_semispace_size_ = V8_MAX_SEMISPACE_SIZE; 152 max_semispace_size_ = reserved_semispace_size_ = V8_MAX_SEMISPACE_SIZE;
154 #endif 153 #endif
155 154
156 intptr_t max_virtual = OS::MaxVirtualMemory(); 155 intptr_t max_virtual = OS::MaxVirtualMemory();
157 156
(...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after
806 tracer->set_full_gc_count(ms_count_); 805 tracer->set_full_gc_count(ms_count_);
807 806
808 MarkCompactPrologue(); 807 MarkCompactPrologue();
809 808
810 mark_compact_collector_.CollectGarbage(); 809 mark_compact_collector_.CollectGarbage();
811 810
812 LOG(isolate_, ResourceEvent("markcompact", "end")); 811 LOG(isolate_, ResourceEvent("markcompact", "end"));
813 812
814 gc_state_ = NOT_IN_GC; 813 gc_state_ = NOT_IN_GC;
815 814
816 Shrink();
817
818 isolate_->counters()->objs_since_last_full()->Set(0); 815 isolate_->counters()->objs_since_last_full()->Set(0);
819 816
820 contexts_disposed_ = 0; 817 contexts_disposed_ = 0;
821 } 818 }
822 819
823 820
824 void Heap::MarkCompactPrologue() { 821 void Heap::MarkCompactPrologue() {
825 // At any old GC clear the keyed lookup cache to enable collection of unused 822 // At any old GC clear the keyed lookup cache to enable collection of unused
826 // maps. 823 // maps.
827 isolate_->keyed_lookup_cache()->Clear(); 824 isolate_->keyed_lookup_cache()->Clear();
(...skipping 4792 matching lines...) Expand 10 before | Expand all | Expand 10 after
5620 delete debug_utils_; 5617 delete debug_utils_;
5621 debug_utils_ = NULL; 5618 debug_utils_ = NULL;
5622 #endif 5619 #endif
5623 } 5620 }
5624 5621
5625 5622
5626 void Heap::Shrink() { 5623 void Heap::Shrink() {
5627 // Try to shrink all paged spaces. 5624 // Try to shrink all paged spaces.
5628 PagedSpaces spaces; 5625 PagedSpaces spaces;
5629 for (PagedSpace* space = spaces.next(); space != NULL; space = spaces.next()) 5626 for (PagedSpace* space = spaces.next(); space != NULL; space = spaces.next())
5630 space->Shrink(); 5627 space->ReleaseAllUnusedPages();
5631 } 5628 }
5632 5629
5633 5630
5634 void Heap::AddGCPrologueCallback(GCPrologueCallback callback, GCType gc_type) { 5631 void Heap::AddGCPrologueCallback(GCPrologueCallback callback, GCType gc_type) {
5635 ASSERT(callback != NULL); 5632 ASSERT(callback != NULL);
5636 GCPrologueCallbackPair pair(callback, gc_type); 5633 GCPrologueCallbackPair pair(callback, gc_type);
5637 ASSERT(!gc_prologue_callbacks_.Contains(pair)); 5634 ASSERT(!gc_prologue_callbacks_.Contains(pair));
5638 return gc_prologue_callbacks_.Add(pair); 5635 return gc_prologue_callbacks_.Add(pair);
5639 } 5636 }
5640 5637
(...skipping 822 matching lines...) Expand 10 before | Expand all | Expand 10 after
6463 // Size of a large chunk is always a multiple of 6460 // Size of a large chunk is always a multiple of
6464 // OS::AllocationAlignment() so there is always 6461 // OS::AllocationAlignment() so there is always
6465 // enough space for a fake MemoryChunk header. 6462 // enough space for a fake MemoryChunk header.
6466 inner->set_owner(lo_space()); 6463 inner->set_owner(lo_space());
6467 inner->SetFlag(MemoryChunk::ABOUT_TO_BE_FREED); 6464 inner->SetFlag(MemoryChunk::ABOUT_TO_BE_FREED);
6468 inner = MemoryChunk::FromAddress( 6465 inner = MemoryChunk::FromAddress(
6469 inner->address() + Page::kPageSize); 6466 inner->address() + Page::kPageSize);
6470 } 6467 }
6471 } 6468 }
6472 } 6469 }
6470 isolate_->heap()->store_buffer()->Compact();
6473 isolate_->heap()->store_buffer()->Filter(MemoryChunk::ABOUT_TO_BE_FREED); 6471 isolate_->heap()->store_buffer()->Filter(MemoryChunk::ABOUT_TO_BE_FREED);
6474 for (chunk = chunks_queued_for_free_; chunk != NULL; chunk = next) { 6472 for (chunk = chunks_queued_for_free_; chunk != NULL; chunk = next) {
6475 next = chunk->next_chunk(); 6473 next = chunk->next_chunk();
6476 isolate_->memory_allocator()->Free(chunk); 6474 isolate_->memory_allocator()->Free(chunk);
6477 } 6475 }
6478 chunks_queued_for_free_ = NULL; 6476 chunks_queued_for_free_ = NULL;
6479 } 6477 }
6480 6478
6481 } } // namespace v8::internal 6479 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/heap.h ('k') | src/mark-compact.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698