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

Side by Side Diff: src/heap.cc

Issue 7621014: Fix the thresholds so that the heap does not grow uncontrollably. This fixes (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/gc/
Patch Set: '' Created 9 years, 4 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
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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 #endif 55 #endif
56 #if V8_TARGET_ARCH_MIPS && !V8_INTERPRETED_REGEXP 56 #if V8_TARGET_ARCH_MIPS && !V8_INTERPRETED_REGEXP
57 #include "regexp-macro-assembler.h" 57 #include "regexp-macro-assembler.h"
58 #include "mips/regexp-macro-assembler-mips.h" 58 #include "mips/regexp-macro-assembler-mips.h"
59 #endif 59 #endif
60 60
61 namespace v8 { 61 namespace v8 {
62 namespace internal { 62 namespace internal {
63 63
64 64
65 static const intptr_t kMinimumPromotionLimit =
66 2 * (Page::kPageSize > MB ? Page::kPageSize : MB);
67 static const intptr_t kMinimumAllocationLimit =
68 8 * (Page::kPageSize > MB ? Page::kPageSize : MB);
69
70
71 static Mutex* gc_initializer_mutex = OS::CreateMutex(); 65 static Mutex* gc_initializer_mutex = OS::CreateMutex();
72 66
73 67
74 Heap::Heap() 68 Heap::Heap()
75 : isolate_(NULL), 69 : isolate_(NULL),
76 // semispace_size_ should be a power of 2 and old_generation_size_ should be 70 // semispace_size_ should be a power of 2 and old_generation_size_ should be
77 // a multiple of Page::kPageSize. 71 // a multiple of Page::kPageSize.
78 #if defined(ANDROID) 72 #if defined(ANDROID)
79 #define LUMP_OF_MEMORY (128 * KB) 73 #define LUMP_OF_MEMORY (128 * KB)
80 code_range_size_(0), 74 code_range_size_(0),
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 gc_count_(0), 108 gc_count_(0),
115 unflattened_strings_length_(0), 109 unflattened_strings_length_(0),
116 #ifdef DEBUG 110 #ifdef DEBUG
117 allocation_allowed_(true), 111 allocation_allowed_(true),
118 allocation_timeout_(0), 112 allocation_timeout_(0),
119 disallow_allocation_failure_(false), 113 disallow_allocation_failure_(false),
120 debug_utils_(NULL), 114 debug_utils_(NULL),
121 #endif // DEBUG 115 #endif // DEBUG
122 old_gen_promotion_limit_(kMinimumPromotionLimit), 116 old_gen_promotion_limit_(kMinimumPromotionLimit),
123 old_gen_allocation_limit_(kMinimumAllocationLimit), 117 old_gen_allocation_limit_(kMinimumAllocationLimit),
118 old_gen_limit_factor_(1),
119 size_of_old_gen_at_last_old_space_gc_(0),
124 external_allocation_limit_(0), 120 external_allocation_limit_(0),
125 amount_of_external_allocated_memory_(0), 121 amount_of_external_allocated_memory_(0),
126 amount_of_external_allocated_memory_at_last_global_gc_(0), 122 amount_of_external_allocated_memory_at_last_global_gc_(0),
127 old_gen_exhausted_(false), 123 old_gen_exhausted_(false),
128 store_buffer_rebuilder_(store_buffer()), 124 store_buffer_rebuilder_(store_buffer()),
129 hidden_symbol_(NULL), 125 hidden_symbol_(NULL),
130 global_gc_prologue_callback_(NULL), 126 global_gc_prologue_callback_(NULL),
131 global_gc_epilogue_callback_(NULL), 127 global_gc_epilogue_callback_(NULL),
132 gc_safe_size_of_old_object_(NULL), 128 gc_safe_size_of_old_object_(NULL),
133 total_regexp_code_generated_(0), 129 total_regexp_code_generated_(0),
(...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after
722 718
723 if (collector == MARK_COMPACTOR) { 719 if (collector == MARK_COMPACTOR) {
724 // Perform mark-sweep with optional compaction. 720 // Perform mark-sweep with optional compaction.
725 MarkCompact(tracer); 721 MarkCompact(tracer);
726 sweep_generation_++; 722 sweep_generation_++;
727 bool high_survival_rate_during_scavenges = IsHighSurvivalRate() && 723 bool high_survival_rate_during_scavenges = IsHighSurvivalRate() &&
728 IsStableOrIncreasingSurvivalTrend(); 724 IsStableOrIncreasingSurvivalTrend();
729 725
730 UpdateSurvivalRateTrend(start_new_space_size); 726 UpdateSurvivalRateTrend(start_new_space_size);
731 727
732 intptr_t old_gen_size = PromotedSpaceSize(); 728 size_of_old_gen_at_last_old_space_gc_ = PromotedSpaceSize();
733 old_gen_promotion_limit_ =
734 old_gen_size +
735 Max(kMinimumPromotionLimit, old_gen_size / 3) +
736 new_space()->Capacity();
737 old_gen_allocation_limit_ =
738 old_gen_size +
739 Max(kMinimumAllocationLimit, old_gen_size / 2) +
740 new_space()->Capacity();
741 729
742 if (high_survival_rate_during_scavenges && 730 if (high_survival_rate_during_scavenges &&
743 IsStableOrIncreasingSurvivalTrend()) { 731 IsStableOrIncreasingSurvivalTrend()) {
744 // Stable high survival rates of young objects both during partial and 732 // Stable high survival rates of young objects both during partial and
745 // full collection indicate that mutator is either building or modifying 733 // full collection indicate that mutator is either building or modifying
746 // a structure with a long lifetime. 734 // a structure with a long lifetime.
747 // In this case we aggressively raise old generation memory limits to 735 // In this case we aggressively raise old generation memory limits to
748 // postpone subsequent mark-sweep collection and thus trade memory 736 // postpone subsequent mark-sweep collection and thus trade memory
749 // space for the mutation speed. 737 // space for the mutation speed.
750 old_gen_promotion_limit_ *= 2; 738 old_gen_limit_factor_ = 1;
Vyacheslav Egorov (Chromium) 2011/08/12 09:11:51 I think you wanted 2 here.
Erik Corry 2011/08/12 09:21:48 Good point.
751 old_gen_allocation_limit_ *= 2; 739 } else {
740 old_gen_limit_factor_ = 1;
752 } 741 }
753 742
743 old_gen_promotion_limit_ =
744 OldGenPromotionLimit(size_of_old_gen_at_last_old_space_gc_);
745 old_gen_allocation_limit_ =
746 OldGenAllocationLimit(size_of_old_gen_at_last_old_space_gc_);
747
754 old_gen_exhausted_ = false; 748 old_gen_exhausted_ = false;
755 } else { 749 } else {
756 tracer_ = tracer; 750 tracer_ = tracer;
757 Scavenge(); 751 Scavenge();
758 tracer_ = NULL; 752 tracer_ = NULL;
759 753
760 UpdateSurvivalRateTrend(start_new_space_size); 754 UpdateSurvivalRateTrend(start_new_space_size);
761 } 755 }
762 756
763 isolate_->counters()->objs_since_last_young()->Set(0); 757 isolate_->counters()->objs_since_last_young()->Set(0);
(...skipping 3479 matching lines...) Expand 10 before | Expand all | Expand 10 after
4243 // populated (via a call to CollectStatistics or else as a side effect of a 4237 // populated (via a call to CollectStatistics or else as a side effect of a
4244 // just-completed scavenge collection). 4238 // just-completed scavenge collection).
4245 void Heap::ReportHeapStatistics(const char* title) { 4239 void Heap::ReportHeapStatistics(const char* title) {
4246 USE(title); 4240 USE(title);
4247 PrintF(">>>>>> =============== %s (%d) =============== >>>>>>\n", 4241 PrintF(">>>>>> =============== %s (%d) =============== >>>>>>\n",
4248 title, gc_count_); 4242 title, gc_count_);
4249 PrintF("old_gen_promotion_limit_ %" V8_PTR_PREFIX "d\n", 4243 PrintF("old_gen_promotion_limit_ %" V8_PTR_PREFIX "d\n",
4250 old_gen_promotion_limit_); 4244 old_gen_promotion_limit_);
4251 PrintF("old_gen_allocation_limit_ %" V8_PTR_PREFIX "d\n", 4245 PrintF("old_gen_allocation_limit_ %" V8_PTR_PREFIX "d\n",
4252 old_gen_allocation_limit_); 4246 old_gen_allocation_limit_);
4247 PrintF("old_gen_limit_factor_ %d\n", old_gen_limit_factor_);
4253 4248
4254 PrintF("\n"); 4249 PrintF("\n");
4255 PrintF("Number of handles : %d\n", HandleScope::NumberOfHandles()); 4250 PrintF("Number of handles : %d\n", HandleScope::NumberOfHandles());
4256 isolate_->global_handles()->PrintStats(); 4251 isolate_->global_handles()->PrintStats();
4257 PrintF("\n"); 4252 PrintF("\n");
4258 4253
4259 PrintF("Heap statistics : "); 4254 PrintF("Heap statistics : ");
4260 isolate_->memory_allocator()->ReportStatistics(); 4255 isolate_->memory_allocator()->ReportStatistics();
4261 PrintF("To space : "); 4256 PrintF("To space : ");
4262 new_space_.ReportStatistics(); 4257 new_space_.ReportStatistics();
(...skipping 1766 matching lines...) Expand 10 before | Expand all | Expand 10 after
6029 } 6024 }
6030 isolate_->heap()->store_buffer()->Filter(MemoryChunk::ABOUT_TO_BE_FREED); 6025 isolate_->heap()->store_buffer()->Filter(MemoryChunk::ABOUT_TO_BE_FREED);
6031 for (chunk = chunks_queued_for_free_; chunk != NULL; chunk = next) { 6026 for (chunk = chunks_queued_for_free_; chunk != NULL; chunk = next) {
6032 next = chunk->next_chunk(); 6027 next = chunk->next_chunk();
6033 isolate_->memory_allocator()->Free(chunk); 6028 isolate_->memory_allocator()->Free(chunk);
6034 } 6029 }
6035 chunks_queued_for_free_ = NULL; 6030 chunks_queued_for_free_ = NULL;
6036 } 6031 }
6037 6032
6038 } } // namespace v8::internal 6033 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698